| 1 | /* Wrap socket() to force the protocol to SCTP for STREAM connections. |
| 2 | * |
| 3 | * Thanks to Midgard Security Services for |
| 4 | * http://www.securiteam.com/tools/3D5PTR5QAE.html |
| 5 | * from whence I cribbed the code to find the old socket(). |
| 6 | * |
| 7 | * Copyright 2003 La Monte HP Yarroll <[email protected]> |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above |
| 16 | * copyright notice, this list of conditions and the following |
| 17 | * disclaimer in the documentation and/or other materials provided with |
| 18 | * the distribution. |
| 19 | * 3. The name of the author may not be used to endorse or promote |
| 20 | * products derived from this software without specific prior written |
| 21 | * permission. |
| 22 | * |
| 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 27 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 29 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 31 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 32 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 33 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | */ |
| 35 | #include <string.h> /* for strncmp() */ |
| 36 | #include <stdio.h> |
| 37 | #include "sctp_socket.h"cxx . . $ `<file>/src/withsctp/sctp_socket.h`/ |
| 38 | |
| 39 | /* IPPROTO_SCTP SHOULD be defined in |
| 40 | * /usr/include/linux/in.h but probably isn't. |
| 41 | * It is an enum element, not a #define, so we can't easily check. |
| 42 | */ |
| 43 | #define SHOULD_IPPROTO_SCTPcxx . . $ `src/withsctp/sctp_sockopt.c:43:9`! 132 |
| 44 | |
| 45 | int |
| 46 | setsockoptcxx . . $ setsockopt(506cc1d0fc70fdf1).(int s, int level, int optname, const void *optval, socklen_tcxx . . $ socklen_t# optlen) |
| 47 | { |
| 48 | _sctp_load_libscxx . . $ _sctp_load_libs(49f6e7a06ebc5aa8).(); |
| 49 | |
| 50 | if ((IPPROTO_TCPcxx . . $ `<external>/9581057695539925927/in.h:51:9`! == level) && (TCP_NODELAYcxx . . $ `<external>/14446708121216675145/tcp.h:40:9`! == optname)) { |
| 51 | level = SHOULD_IPPROTO_SCTPcxx . . $ `src/withsctp/sctp_sockopt.c:43:9`!; |
| 52 | optname = SCTP_NODELAYcxx . . $ `<external>/17169092326581286071/sctp.h:72:9`!; |
| 53 | } |
| 54 | |
| 55 | return (real_setsockoptcxx . . $ real_setsockopt.)(s, level, optname, optval, optlen); |
| 56 | } |