summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-09-27 10:13:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:20:23 -0500
commit174742a74ce448d1944ada9dd602aadf20bce6f8 (patch)
tree672f8a13af40ac57988a35a15ec1e40a494fc948 /source4/lib
parentee97148354090aa63b99abc02fe2811bf18a549e (diff)
downloadsamba-174742a74ce448d1944ada9dd602aadf20bce6f8.tar.gz
samba-174742a74ce448d1944ada9dd602aadf20bce6f8.tar.bz2
samba-174742a74ce448d1944ada9dd602aadf20bce6f8.zip
r18947: overload listen() and ioctl() in socket_wrapper
metze (This used to be commit dfaccdca1b6954cd61828749d7b000f804f3b066)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/replace/system/network.h4
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c30
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.h12
3 files changed, 46 insertions, 0 deletions
diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h
index 615fcab5c8..a21f8e2eaf 100644
--- a/source4/lib/replace/system/network.h
+++ b/source4/lib/replace/system/network.h
@@ -66,6 +66,10 @@
#include <net/if.h>
#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
#ifdef SOCKET_WRAPPER
#ifndef SOCKET_WRAPPER_NOT_REPLACE
#define SOCKET_WRAPPER_REPLACE
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
index 224d521b30..c884b96c6c 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ b/source4/lib/socket_wrapper/socket_wrapper.c
@@ -67,12 +67,14 @@
#define real_accept accept
#define real_connect connect
#define real_bind bind
+#define real_listen listen
#define real_getpeername getpeername
#define real_getsockname getsockname
#define real_getsockopt getsockopt
#define real_setsockopt setsockopt
#define real_recvfrom recvfrom
#define real_sendto sendto
+#define real_ioctl ioctl
#define real_recv recv
#define real_send send
#define real_socket socket
@@ -712,6 +714,20 @@ _PUBLIC_ int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen)
return ret;
}
+_PUBLIC_ int swrap_listen(int s, int backlog)
+{
+ int ret;
+ struct socket_info *si = find_socket_info(s);
+
+ if (!si) {
+ return real_listen(s, backlog);
+ }
+
+ ret = real_listen(s, backlog);
+
+ return ret;
+}
+
_PUBLIC_ int swrap_getpeername(int s, struct sockaddr *name, socklen_t *addrlen)
{
struct socket_info *si = find_socket_info(s);
@@ -864,6 +880,20 @@ _PUBLIC_ ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, con
return ret;
}
+_PUBLIC_ int swrap_ioctl(int s, int r, void *p)
+{
+ int ret;
+ struct socket_info *si = find_socket_info(s);
+
+ if (!si) {
+ return real_ioctl(s, r, p);
+ }
+
+ ret = real_ioctl(s, r, p);
+
+ return ret;
+}
+
_PUBLIC_ ssize_t swrap_recv(int s, void *buf, size_t len, int flags)
{
int ret;
diff --git a/source4/lib/socket_wrapper/socket_wrapper.h b/source4/lib/socket_wrapper/socket_wrapper.h
index 23a261faaf..07cf2c6601 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.h
+++ b/source4/lib/socket_wrapper/socket_wrapper.h
@@ -23,12 +23,14 @@ int swrap_socket(int family, int type, int protocol);
int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t addrlen);
int swrap_bind(int s, const struct sockaddr *myaddr, socklen_t addrlen);
+int swrap_listen(int s, int backlog);
int swrap_getpeername(int s, struct sockaddr *name, socklen_t *addrlen);
int swrap_getsockname(int s, struct sockaddr *name, socklen_t *addrlen);
int swrap_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);
int swrap_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);
ssize_t swrap_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
+int swrap_ioctl(int s, int req, void *ptr);
ssize_t swrap_recv(int s, void *buf, size_t len, int flags);
ssize_t swrap_send(int s, const void *buf, size_t len, int flags);
int swrap_close(int);
@@ -50,6 +52,11 @@ int swrap_close(int);
#endif
#define bind(s,myaddr,addrlen) swrap_bind(s,myaddr,addrlen)
+#ifdef listen
+#undef listen
+#endif
+#define listen(s,blog) swrap_listen(s,blog)
+
#ifdef getpeername
#undef getpeername
#endif
@@ -80,6 +87,11 @@ int swrap_close(int);
#endif
#define sendto(s,buf,len,flags,to,tolen) swrap_sendto(s,buf,len,flags,to,tolen)
+#ifdef ioctl
+#undef ioctl
+#endif
+#define ioctl(s,req,ptr) swrap_ioctl(s,req,ptr)
+
#ifdef recv
#undef recv
#endif