summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-02-07 17:08:40 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-02-07 17:08:40 +0100
commit26ef6a9a79da53c67b2759f772c01195eed084e4 (patch)
treec92df96c797bc5a2ece43f5927635eb399db7ed0 /src
parentc184d6317c27ccebdd2d31a7aa7b1bf41be068ff (diff)
downloadsocket_wrapper-26ef6a9a79da53c67b2759f772c01195eed084e4.tar.gz
socket_wrapper-26ef6a9a79da53c67b2759f772c01195eed084e4.tar.xz
socket_wrapper-26ef6a9a79da53c67b2759f772c01195eed084e4.zip
Add socket() wrapper.
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 0876de5..2ce5100 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -124,6 +124,10 @@
* without changing the format above */
#define MAX_WRAPPED_INTERFACES 40
+/*********************************************************
+ * SWRAP LOADING LIBC FUNCTIONS
+ *********************************************************/
+
#include <dlfcn.h>
#define LIBC_NAME "libc.so.6"
@@ -206,6 +210,21 @@ static int real_getsockname(int sockfd,
return libc_getsockname(sockfd, addr, addrlen);
}
+static int (*libc_socket)(int domain, int type, int protocol);
+
+static int real_socket(int domain, int type, int protocol)
+{
+ if (libc_socket == NULL) {
+ *(void **)(&libc_socket) = libc_dlsym("socket");
+ }
+
+ return libc_socket(domain, type, protocol);
+}
+
+/*********************************************************
+ * SWRAP HELPER FUNCTIONS
+ *********************************************************/
+
#ifdef HAVE_IPV6
/*
* FD00::5357:5FXX
@@ -1461,8 +1480,7 @@ static void swrap_dump_packet(struct socket_info *si,
free(packet);
}
-#if 0
-_PUBLIC_ int swrap_socket(int family, int type, int protocol)
+int socket(int family, int type, int protocol)
{
struct socket_info *si;
struct socket_info_fd *fi;
@@ -1553,7 +1571,6 @@ _PUBLIC_ int swrap_socket(int family, int type, int protocol)
return fd;
}
-#endif
int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{