diff --git a/boards/native/drivers/native-uart0.c b/boards/native/drivers/native-uart0.c index ccde12f704..4f651d3b7f 100644 --- a/boards/native/drivers/native-uart0.c +++ b/boards/native/drivers/native-uart0.c @@ -122,7 +122,7 @@ int init_tcp_socket(char *tcpport) err(EXIT_FAILURE, "init_uart_socket: setsockopt"); } - if (bind(s, p->ai_addr, p->ai_addrlen) == -1) { + if (real_bind(s, p->ai_addr, p->ai_addrlen) == -1) { close(s); warn("init_uart_socket: bind"); continue; @@ -135,7 +135,7 @@ int init_tcp_socket(char *tcpport) } freeaddrinfo(info); - if (listen(s, 1) == -1) { + if (real_listen(s, 1) == -1) { err(EXIT_FAILURE, "init_uart_socket: listen"); } @@ -160,11 +160,11 @@ int init_unix_socket(void) snprintf(sa.sun_path, sizeof(sa.sun_path), "/tmp/riot.tty.%d", _native_pid); } real_unlink(sa.sun_path); /* remove stale socket */ - if (bind(s, (struct sockaddr *)&sa, SUN_LEN(&sa)) == -1) { + if (real_bind(s, (struct sockaddr *)&sa, SUN_LEN(&sa)) == -1) { err(EXIT_FAILURE, "init_unix_socket: bind"); } - if (listen(s, 5) == -1) { + if (real_listen(s, 5) == -1) { err(EXIT_FAILURE, "init_unix_socket: listen"); } diff --git a/cpu/native/include/native_internal.h b/cpu/native/include/native_internal.h index 74c1a113ac..5c63ffc2f2 100644 --- a/cpu/native/include/native_internal.h +++ b/cpu/native/include/native_internal.h @@ -71,6 +71,8 @@ extern void (*real_free)(void *ptr); extern void* (*real_calloc)(size_t nmemb, size_t size); extern void* (*real_malloc)(size_t size); extern void* (*real_realloc)(void *ptr, size_t size); +/* The ... is a hack to save includes: */ +extern int (*real_bind)(int socket, ...); extern int (*real_close)(int); extern int (*real_dup2)(int, int); extern int (*real_execve)(const char *, char *const[], char *const[]); @@ -78,6 +80,7 @@ extern int (*real_feof)(FILE *stream); extern int (*real_ferror)(FILE *stream); extern int (*real_fork)(void); extern int (*real_getpid)(void); +extern int (*real_listen)(int socket, int backlog); extern int (*real_pause)(void); extern int (*real_pipe)(int[2]); extern int (*real_printf)(const char *format, ...); diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index ff3e29b3b5..77e7e0d48c 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -55,6 +55,7 @@ void (*real_free)(void *ptr); void* (*real_malloc)(size_t size); void* (*real_calloc)(size_t nmemb, size_t size); void* (*real_realloc)(void *ptr, size_t size); +int (*real_bind)(int socket, ...); int (*real_printf)(const char *format, ...); int (*real_getpid)(void); int (*real_pipe)(int[2]); @@ -64,6 +65,7 @@ int (*real_execve)(const char *, char *const[], char *const[]); int (*real_fork)(void); int (*real_feof)(FILE *stream); int (*real_ferror)(FILE *stream); +int (*real_listen)(int socket, int backlog); int (*real_pause)(void); int (*real_unlink)(const char *); FILE* (*real_fopen)(const char *path, const char *mode); @@ -351,6 +353,7 @@ void _native_init_syscalls(void) *(void **)(&real_malloc) = dlsym(RTLD_NEXT, "malloc"); *(void **)(&real_realloc) = dlsym(RTLD_NEXT, "realloc"); *(void **)(&real_free) = dlsym(RTLD_NEXT, "free"); + *(void **)(&real_bind) = dlsym(RTLD_NEXT, "bind"); *(void **)(&real_printf) = dlsym(RTLD_NEXT, "printf"); *(void **)(&real_getpid) = dlsym(RTLD_NEXT, "getpid"); *(void **)(&real_pipe) = dlsym(RTLD_NEXT, "pipe"); @@ -359,6 +362,7 @@ void _native_init_syscalls(void) *(void **)(&real_dup2) = dlsym(RTLD_NEXT, "dup2"); *(void **)(&real_unlink) = dlsym(RTLD_NEXT, "unlink"); *(void **)(&real_execve) = dlsym(RTLD_NEXT, "execve"); + *(void **)(&real_listen) = dlsym(RTLD_NEXT, "listen"); *(void **)(&real_pause) = dlsym(RTLD_NEXT, "pause"); *(void **)(&real_fopen) = dlsym(RTLD_NEXT, "fopen"); *(void **)(&real_fread) = dlsym(RTLD_NEXT, "fread");