diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-12-08 18:07:46 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-12-08 18:07:46 -0800 |
commit | 49d76c631190152301e42b656da683b3bc461484 (patch) | |
tree | ad8c0e70477c2e2c969e93506890254960bd08c1 /netcon | |
parent | 5717dfe3b9c103f0434dbc83fdf9f2d067c63a6d (diff) | |
download | infinitytier-49d76c631190152301e42b656da683b3bc461484.tar.gz infinitytier-49d76c631190152301e42b656da683b3bc461484.zip |
Stub out getsockname()
Diffstat (limited to 'netcon')
-rw-r--r-- | netcon/Intercept.c | 47 | ||||
-rw-r--r-- | netcon/Intercept.h | 1 |
2 files changed, 21 insertions, 27 deletions
diff --git a/netcon/Intercept.c b/netcon/Intercept.c index 3890c08b..30d57901 100644 --- a/netcon/Intercept.c +++ b/netcon/Intercept.c @@ -75,6 +75,7 @@ static int (*realclose)(CLOSE_SIG); static int (*realclone)(CLONE_SIG); static int (*realdup2)(DUP2_SIG); static int (*realdup3)(DUP3_SIG); +static int (*realgetsockname)(GETSOCKNAME_SIG); /* Exported Function Prototypes */ void my_init(void); @@ -92,6 +93,7 @@ int close(CLOSE_SIG); int clone(CLONE_SIG); int dup2(DUP2_SIG); int dup3(DUP3_SIG); +int getsockname(GETSOCKNAME_SIG); int connect_to_service(void); int init_service_connection(); @@ -309,16 +311,11 @@ void my_dest(void) { void load_symbols(void) { -#ifdef USE_OLD_DLSYM - void *lib; -#endif - /* possibly add check to beginning of each method to avoid needing to cll the constructor */ if(thispid == getpid()) { - dwr(MSG_DEBUG,"detected duplicate call to global ctor (pid=%d).\n", thispid); + dwr(MSG_DEBUG,"detected duplicate call to global constructor (pid=%d).\n", thispid); } thispid = getpid(); -#ifndef USE_OLD_DLSYM realconnect = dlsym(RTLD_NEXT, "connect"); realbind = dlsym(RTLD_NEXT, "bind"); realaccept = dlsym(RTLD_NEXT, "accept"); @@ -334,26 +331,7 @@ void load_symbols(void) realsyscall = dlsym(RTLD_NEXT, "syscall"); realdup2 = dlsym(RTLD_NEXT, "dup2"); realdup3 = dlsym(RTLD_NEXT, "dup3"); -#else - lib = dlopen(LIBCONNECT, RTLD_LAZY); - realconnect = dlsym(lib, "connect"); - realbind = dlsym(lib, "bind"); - realaccept = dlsym(lib, "accept"); - reallisten = dlsym(lib, "listen"); - realsocket = dlsym(lib, "socket"); - realselect = dlsym(lib, "select"); - realsetsockopt = dlsym(lib, "setsockopt"); - realgetsockopt = dlsym(lib, "getsockopt"); - realaccept4 = dlsym(lib), "accept4"); - realclone = dlsym(lib, "clone"); - realclose = dlsym(lib, "close"); - realsyscall = dlsym(lib, "syscall"); - realdup2 = dlsym(RTLD_NEXT, "dup2"); - realdup3 = dlsym(RTLD_NEXT, "dup3"); - dlclose(lib); - lib = dlopen(LIBC, RTLD_LAZY); - dlclose(lib); -#endif + realgetsockname = dlsym(RTLD_NEXT, "getsockname"); } /* Private Function Prototypes */ @@ -825,7 +803,7 @@ int accept(ACCEPT_SIG) } /* The following line is required for libuv/nodejs to accept connections properly, - however, this has the side effect of causing certain webservers to max out the CPU + however, this has the side effect of causing certain webservers to max out the CPU in an accept loop */ //fcntl(sockfd, F_SETFL, O_NONBLOCK); @@ -1040,6 +1018,21 @@ int dup3(DUP3_SIG) return realdup3(oldfd, newfd, flags); } +/*------------------------------------------------------------------------------ +-------------------------------------- getsockname()---------------------------- +------------------------------------------------------------------------------*/ + +int getsockname(GETSOCKNAME_SIG) +{ + if (realgetsockname == NULL) { + dwr(MSG_ERROR, "getsockname(): SYMBOL NOT FOUND.\n"); + return -1; + } + + // TODO + + return realgetsockname(sockfd,addr,addrlen); +} /*------------------------------------------------------------------------------ ------------------------------------ syscall()---------------------------------- diff --git a/netcon/Intercept.h b/netcon/Intercept.h index ef10dc64..0a9103ad 100644 --- a/netcon/Intercept.h +++ b/netcon/Intercept.h @@ -185,6 +185,7 @@ struct shutdown_st #define SYSCALL_SIG long number, ... #define CLONE_SIG int (*fn)(void *), void *child_stack, int flags, void *arg, ... #define POLL_SIG struct pollfd *fds, nfds_t nfds, int timeout +#define GETSOCKNAME_SIG int sockfd, struct sockaddr *addr, socklen_t *addrlen #define DUP2_SIG int oldfd, int newfd #define DUP3_SIG int oldfd, int newfd, int flags |