[tor-commits] [torsocks/master] Use extern for tsocks_libc_* in torsocks.h
dgoulet at torproject.org
dgoulet at torproject.org
Fri Apr 4 22:40:26 UTC 2014
commit a25ae10b74dedc2c023449563a1471842fae4c99
Author: Luke Gallagher <luke at hypergeometric.net>
Date: Fri Aug 30 09:53:45 2013 +1000
Use extern for tsocks_libc_* in torsocks.h
Define tsocks_libc_* in the relevant source files and define them as
external in torsocks.h to avoid duplicate symbol errors.
Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
src/lib/connect.c | 3 +++
src/lib/getaddrinfo.c | 4 ++++
src/lib/gethostbyname.c | 29 +++++++++++++++++++++++++++++
src/lib/getpeername.c | 4 ++++
src/lib/recv.c | 3 +++
src/lib/socket.c | 3 +++
src/lib/socketpair.c | 3 +++
src/lib/syscall.c | 6 ++++++
src/lib/torsocks.h | 36 ++++++++++++++++++------------------
9 files changed, 73 insertions(+), 18 deletions(-)
diff --git a/src/lib/connect.c b/src/lib/connect.c
index 357a313..3d75a94 100644
--- a/src/lib/connect.c
+++ b/src/lib/connect.c
@@ -25,6 +25,9 @@
#include "torsocks.h"
+/* connect(2) */
+TSOCKS_LIBC_DECL(connect, LIBC_CONNECT_RET_TYPE, LIBC_CONNECT_SIG)
+
/*
* Torsocks call for connect(2).
*/
diff --git a/src/lib/getaddrinfo.c b/src/lib/getaddrinfo.c
index 683bfc7..7a7a144 100644
--- a/src/lib/getaddrinfo.c
+++ b/src/lib/getaddrinfo.c
@@ -24,6 +24,10 @@
#include "torsocks.h"
+/* getaddrinfo(3) */
+TSOCKS_LIBC_DECL(getaddrinfo, LIBC_GETADDRINFO_RET_TYPE,
+ LIBC_GETADDRINFO_SIG)
+
/*
* Torsocks call for getaddrinfo(3).
*/
diff --git a/src/lib/gethostbyname.c b/src/lib/gethostbyname.c
index bab01b0..9ba5cee 100644
--- a/src/lib/gethostbyname.c
+++ b/src/lib/gethostbyname.c
@@ -25,6 +25,35 @@
#include "torsocks.h"
+struct hostent tsocks_he;
+char *tsocks_he_addr_list[2];
+char tsocks_he_addr[INET_ADDRSTRLEN];
+char tsocks_he_name[255];
+
+/* gethostbyname(3) */
+TSOCKS_LIBC_DECL(gethostbyname, LIBC_GETHOSTBYNAME_RET_TYPE,
+ LIBC_GETHOSTBYNAME_SIG)
+
+/* gethostbyname_r(3) */
+TSOCKS_LIBC_DECL(gethostbyname_r, LIBC_GETHOSTBYNAME_R_RET_TYPE,
+ LIBC_GETHOSTBYNAME_R_SIG)
+
+/* gethostbyname2(3) */
+TSOCKS_LIBC_DECL(gethostbyname2, LIBC_GETHOSTBYNAME2_RET_TYPE,
+ LIBC_GETHOSTBYNAME2_SIG)
+
+/* gethostbyname2_r(3) */
+TSOCKS_LIBC_DECL(gethostbyname2_r, LIBC_GETHOSTBYNAME2_R_RET_TYPE,
+ LIBC_GETHOSTBYNAME2_R_SIG)
+
+/* gethostbyaddr(3) */
+TSOCKS_LIBC_DECL(gethostbyaddr, LIBC_GETHOSTBYADDR_RET_TYPE,
+ LIBC_GETHOSTBYADDR_SIG)
+
+/* gethostbyaddr_r(3) */
+TSOCKS_LIBC_DECL(gethostbyaddr_r, LIBC_GETHOSTBYADDR_R_RET_TYPE,
+ LIBC_GETHOSTBYADDR_R_SIG)
+
/*
* Torsocks call for gethostbyname(3).
*
diff --git a/src/lib/getpeername.c b/src/lib/getpeername.c
index 8e4b671..8e2bd44 100644
--- a/src/lib/getpeername.c
+++ b/src/lib/getpeername.c
@@ -22,6 +22,10 @@
#include "torsocks.h"
+/* getpeername(2) */
+TSOCKS_LIBC_DECL(getpeername, LIBC_GETPEERNAME_RET_TYPE,
+ LIBC_GETPEERNAME_SIG)
+
/*
* Torsocks call for getpeername(2).
*/
diff --git a/src/lib/recv.c b/src/lib/recv.c
index 895892d..9f9aefc 100644
--- a/src/lib/recv.c
+++ b/src/lib/recv.c
@@ -22,6 +22,9 @@
#include "torsocks.h"
+/* recvmsg(2) */
+TSOCKS_LIBC_DECL(recvmsg, LIBC_RECVMSG_RET_TYPE, LIBC_RECVMSG_SIG)
+
/*
* Torsocks call for recvmsg(2)
*
diff --git a/src/lib/socket.c b/src/lib/socket.c
index ce28576..aa5297e 100644
--- a/src/lib/socket.c
+++ b/src/lib/socket.c
@@ -21,6 +21,9 @@
#include "torsocks.h"
+/* socket(2) */
+TSOCKS_LIBC_DECL(socket, LIBC_SOCKET_RET_TYPE, LIBC_SOCKET_SIG)
+
/*
* Torsocks call for socket(2)
*/
diff --git a/src/lib/socketpair.c b/src/lib/socketpair.c
index 97a5761..599b4c3 100644
--- a/src/lib/socketpair.c
+++ b/src/lib/socketpair.c
@@ -21,6 +21,9 @@
#include "torsocks.h"
+/* socketpair(2) */
+TSOCKS_LIBC_DECL(socketpair, LIBC_SOCKETPAIR_RET_TYPE, LIBC_SOCKETPAIR_SIG)
+
/*
* Torsocks call for socketpair(2)
*/
diff --git a/src/lib/syscall.c b/src/lib/syscall.c
index af60060..0edd460 100644
--- a/src/lib/syscall.c
+++ b/src/lib/syscall.c
@@ -22,6 +22,12 @@
#include "torsocks.h"
+/* syscall(2) */
+TSOCKS_LIBC_DECL(syscall, LIBC_SYSCALL_RET_TYPE, LIBC_SYSCALL_SIG)
+
+/* close(2) */
+TSOCKS_LIBC_DECL(close, LIBC_CLOSE_RET_TYPE, LIBC_CLOSE_SIG)
+
/*
* Handle close syscall to be called with tsocks call.
*/
diff --git a/src/lib/torsocks.h b/src/lib/torsocks.h
index 3a23eb4..1554abc 100644
--- a/src/lib/torsocks.h
+++ b/src/lib/torsocks.h
@@ -83,10 +83,10 @@
* use free(). So, we use static memory here to mimic the libc call and avoid
* memory leaks. This also void the need of hijacking freehostent(3).
*/
-struct hostent tsocks_he;
-char *tsocks_he_addr_list[2];
-char tsocks_he_addr[INET_ADDRSTRLEN];
-char tsocks_he_name[255];
+extern struct hostent tsocks_he;
+extern char *tsocks_he_addr_list[2];
+extern char tsocks_he_addr[INET_ADDRSTRLEN];
+extern char tsocks_he_name[255];
#define LIBC_GETHOSTBYNAME_NAME gethostbyname
#define LIBC_GETHOSTBYNAME_NAME_STR XSTR(LIBC_GETHOSTBYNAME_NAME)
@@ -208,83 +208,83 @@ struct hostent **__result, int *__h_errnop
*/
/* connect(2) */
-TSOCKS_LIBC_DECL(connect, LIBC_CONNECT_RET_TYPE, LIBC_CONNECT_SIG)
+extern TSOCKS_LIBC_DECL(connect, LIBC_CONNECT_RET_TYPE, LIBC_CONNECT_SIG)
TSOCKS_DECL(connect, LIBC_CONNECT_RET_TYPE, LIBC_CONNECT_SIG)
#define LIBC_CONNECT_DECL \
LIBC_CONNECT_RET_TYPE LIBC_CONNECT_NAME(LIBC_CONNECT_SIG)
/* recvmsg(2) */
-TSOCKS_LIBC_DECL(recvmsg, LIBC_RECVMSG_RET_TYPE, LIBC_RECVMSG_SIG)
+extern TSOCKS_LIBC_DECL(recvmsg, LIBC_RECVMSG_RET_TYPE, LIBC_RECVMSG_SIG)
#define LIBC_RECVMSG_DECL \
LIBC_RECVMSG_RET_TYPE LIBC_RECVMSG_NAME(LIBC_RECVMSG_SIG)
/* socket(2) */
-TSOCKS_LIBC_DECL(socket, LIBC_SOCKET_RET_TYPE, LIBC_SOCKET_SIG)
+extern TSOCKS_LIBC_DECL(socket, LIBC_SOCKET_RET_TYPE, LIBC_SOCKET_SIG)
TSOCKS_DECL(socket, LIBC_SOCKET_RET_TYPE, LIBC_SOCKET_SIG)
#define LIBC_SOCKET_DECL \
LIBC_SOCKET_RET_TYPE LIBC_SOCKET_NAME(LIBC_SOCKET_SIG)
/* socketpair(2) */
-TSOCKS_LIBC_DECL(socketpair, LIBC_SOCKETPAIR_RET_TYPE, LIBC_SOCKETPAIR_SIG)
+extern TSOCKS_LIBC_DECL(socketpair, LIBC_SOCKETPAIR_RET_TYPE, LIBC_SOCKETPAIR_SIG)
TSOCKS_DECL(socketpair, LIBC_SOCKETPAIR_RET_TYPE, LIBC_SOCKETPAIR_SIG)
#define LIBC_SOCKETPAIR_DECL \
LIBC_SOCKETPAIR_RET_TYPE LIBC_SOCKETPAIR_NAME(LIBC_SOCKETPAIR_SIG)
/* syscall(2) */
-TSOCKS_LIBC_DECL(syscall, LIBC_SYSCALL_RET_TYPE, LIBC_SYSCALL_SIG)
+extern TSOCKS_LIBC_DECL(syscall, LIBC_SYSCALL_RET_TYPE, LIBC_SYSCALL_SIG)
#define LIBC_SYSCALL_DECL \
LIBC_SYSCALL_RET_TYPE LIBC_SYSCALL_NAME(LIBC_SYSCALL_SIG)
/* close(2) */
-TSOCKS_LIBC_DECL(close, LIBC_CLOSE_RET_TYPE, LIBC_CLOSE_SIG)
+extern TSOCKS_LIBC_DECL(close, LIBC_CLOSE_RET_TYPE, LIBC_CLOSE_SIG)
TSOCKS_DECL(close, LIBC_CLOSE_RET_TYPE, LIBC_CLOSE_SIG)
#define LIBC_CLOSE_DECL \
LIBC_CLOSE_RET_TYPE LIBC_CLOSE_NAME(LIBC_CLOSE_SIG)
/* gethostbyname(3) */
-TSOCKS_LIBC_DECL(gethostbyname, LIBC_GETHOSTBYNAME_RET_TYPE,
+extern TSOCKS_LIBC_DECL(gethostbyname, LIBC_GETHOSTBYNAME_RET_TYPE,
LIBC_GETHOSTBYNAME_SIG)
#define LIBC_GETHOSTBYNAME_DECL LIBC_GETHOSTBYNAME_RET_TYPE \
LIBC_GETHOSTBYNAME_NAME(LIBC_GETHOSTBYNAME_SIG)
/* gethostbyname_r(3) */
-TSOCKS_LIBC_DECL(gethostbyname_r, LIBC_GETHOSTBYNAME_R_RET_TYPE,
+extern TSOCKS_LIBC_DECL(gethostbyname_r, LIBC_GETHOSTBYNAME_R_RET_TYPE,
LIBC_GETHOSTBYNAME_R_SIG)
#define LIBC_GETHOSTBYNAME_R_DECL LIBC_GETHOSTBYNAME_R_RET_TYPE \
LIBC_GETHOSTBYNAME_R_NAME(LIBC_GETHOSTBYNAME_R_SIG)
/* gethostbyname2(3) */
-TSOCKS_LIBC_DECL(gethostbyname2, LIBC_GETHOSTBYNAME2_RET_TYPE,
+extern TSOCKS_LIBC_DECL(gethostbyname2, LIBC_GETHOSTBYNAME2_RET_TYPE,
LIBC_GETHOSTBYNAME2_SIG)
#define LIBC_GETHOSTBYNAME2_DECL LIBC_GETHOSTBYNAME2_RET_TYPE \
LIBC_GETHOSTBYNAME2_NAME(LIBC_GETHOSTBYNAME2_SIG)
/* gethostbyname2_r(3) */
-TSOCKS_LIBC_DECL(gethostbyname2_r, LIBC_GETHOSTBYNAME2_R_RET_TYPE,
+extern TSOCKS_LIBC_DECL(gethostbyname2_r, LIBC_GETHOSTBYNAME2_R_RET_TYPE,
LIBC_GETHOSTBYNAME2_R_SIG)
#define LIBC_GETHOSTBYNAME2_R_DECL LIBC_GETHOSTBYNAME2_R_RET_TYPE \
LIBC_GETHOSTBYNAME2_R_NAME(LIBC_GETHOSTBYNAME2_R_SIG)
/* gethostbyaddr(3) */
-TSOCKS_LIBC_DECL(gethostbyaddr, LIBC_GETHOSTBYADDR_RET_TYPE,
+extern TSOCKS_LIBC_DECL(gethostbyaddr, LIBC_GETHOSTBYADDR_RET_TYPE,
LIBC_GETHOSTBYADDR_SIG)
#define LIBC_GETHOSTBYADDR_DECL LIBC_GETHOSTBYADDR_RET_TYPE \
LIBC_GETHOSTBYADDR_NAME(LIBC_GETHOSTBYADDR_SIG)
/* gethostbyaddr_r(3) */
-TSOCKS_LIBC_DECL(gethostbyaddr_r, LIBC_GETHOSTBYADDR_R_RET_TYPE,
+extern TSOCKS_LIBC_DECL(gethostbyaddr_r, LIBC_GETHOSTBYADDR_R_RET_TYPE,
LIBC_GETHOSTBYADDR_R_SIG)
#define LIBC_GETHOSTBYADDR_R_DECL LIBC_GETHOSTBYADDR_R_RET_TYPE \
LIBC_GETHOSTBYADDR_R_NAME(LIBC_GETHOSTBYADDR_R_SIG)
/* getaddrinfo(3) */
-TSOCKS_LIBC_DECL(getaddrinfo, LIBC_GETADDRINFO_RET_TYPE,
+extern TSOCKS_LIBC_DECL(getaddrinfo, LIBC_GETADDRINFO_RET_TYPE,
LIBC_GETADDRINFO_SIG)
#define LIBC_GETADDRINFO_DECL LIBC_GETADDRINFO_RET_TYPE \
LIBC_GETADDRINFO_NAME(LIBC_GETADDRINFO_SIG)
/* getpeername(2) */
-TSOCKS_LIBC_DECL(getpeername, LIBC_GETPEERNAME_RET_TYPE,
+extern TSOCKS_LIBC_DECL(getpeername, LIBC_GETPEERNAME_RET_TYPE,
LIBC_GETPEERNAME_SIG)
#define LIBC_GETPEERNAME_DECL LIBC_GETPEERNAME_RET_TYPE \
LIBC_GETPEERNAME_NAME(LIBC_GETPEERNAME_SIG)
More information about the tor-commits
mailing list