1 /* Load the real underlying functions for withsctp and related scripts.
3 * Copyright 2003 La Monte HP Yarroll <piggy@acm.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials provided with
15 * 3. The name of the author may not be used to endorse or promote
16 * products derived from this software without specific prior written
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
29 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "sctp_socket.h"
35 int (*real_bind)(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);
36 int (*real_socket)(int domain, int type, int protocol);
37 int (*real_setsockopt)(int s, int level, int optname, const void *optval,
39 static void *lib_handle = NULL;
44 if (NULL != lib_handle) return; /* Only init once. */
46 if (!(lib_handle = dlopen("libc.so", RTLD_LAZY))) {
47 if (!(lib_handle = dlopen("libc.so.6", RTLD_LAZY))) {
48 fprintf(stderr, "error loading libc!\n");
53 if (!(real_socket = dlsym(lib_handle, "socket"))) {
54 fprintf(stderr, "socket() not found in libc!\n");
58 if (!(real_bind = dlsym(lib_handle, "bind"))) {
59 fprintf(stderr, "bind() not found in libc!\n");
63 if (!(real_setsockopt = dlsym(lib_handle, "setsockopt"))) {
64 fprintf(stderr, "setsockopt() not found in libc!\n");