1 /* Wrap bind() to force the protocol for STREAM connections to SCTP.
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 bind().
7 * gcc sctp_socket.c sctp_bind.c -o sctp_socket.so -ldl -shared -O2 -s
8 * export LD_PRELOAD=./sctp_socket.so
10 * Copyright 2003 La Monte HP Yarroll <piggy@acm.org>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials provided with
22 * 3. The name of the author may not be used to endorse or promote
23 * products derived from this software without specific prior written
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
30 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
34 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
36 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <string.h> /* for strncmp() */
40 #include "sctp_socket.h"
42 /* IPPROTO_SCTP SHOULD be defined in
43 * /usr/include/linux/in.h but probably isn't.
44 * It is an enum element, not a #define, so we can't easily check.
46 #define SHOULD_IPPROTO_SCTP 132
49 bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen)
53 /* STUB. The intent is to allow us to substitute an elaborate call to
54 * bindx() for the initial call to bind(). TBD.
57 return (real_bind)(sockfd, my_addr, addrlen);