diff options
author | Andreas Schneider <asn@samba.org> | 2014-06-03 15:05:56 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-06-05 23:57:10 +0200 |
commit | 353709b3f35cffa8a8003dc2e7f4371f8fe90c0a (patch) | |
tree | 9a9c20096e787cf1dd972c35aca32005a3fcfff7 /lib/socket_wrapper | |
parent | 3689addffbcd351e2ac0b62834b976a01c6200e0 (diff) | |
download | samba-353709b3f35cffa8a8003dc2e7f4371f8fe90c0a.tar.gz samba-353709b3f35cffa8a8003dc2e7f4371f8fe90c0a.tar.xz samba-353709b3f35cffa8a8003dc2e7f4371f8fe90c0a.zip |
swrap: Support more socket options in getsockopt().
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'lib/socket_wrapper')
-rw-r--r-- | lib/socket_wrapper/socket_wrapper.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index c52f3d71821..19ac1840cdc 100644 --- a/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -2844,6 +2844,12 @@ int getsockname(int s, struct sockaddr *name, socklen_t *addrlen) * GETSOCKOPT ***************************************************************************/ +#ifndef SO_PROTOCOL +# ifdef SO_PROTOTYPE /* The Solaris name */ +# define SO_PROTOCOL SO_PROTOTYPE +# endif /* SO_PROTOTYPE */ +#endif /* SO_PROTOCOL */ + static int swrap_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) { @@ -2858,11 +2864,46 @@ static int swrap_getsockopt(int s, int level, int optname, } if (level == SOL_SOCKET) { - return libc_getsockopt(s, - level, - optname, - optval, - optlen); + switch (optname) { +#ifdef SO_DOMAIN + case SO_DOMAIN: + if (optval == NULL || optlen == NULL || + *optlen < (socklen_t)sizeof(int)) { + errno = EINVAL; + return -1; + } + + *optlen = sizeof(int); + *(int *)optval = si->family; + return 0; +#endif /* SO_DOMAIN */ + case SO_PROTOCOL: + if (optval == NULL || optlen == NULL || + *optlen < (socklen_t)sizeof(int)) { + errno = EINVAL; + return -1; + } + + *optlen = sizeof(int); + *(int *)optval = si->protocol; + return 0; + case SO_TYPE: + if (optval == NULL || optlen == NULL || + *optlen < (socklen_t)sizeof(int)) { + errno = EINVAL; + return -1; + } + + *optlen = sizeof(int); + *(int *)optval = si->type; + return 0; + default: + return libc_getsockopt(s, + level, + optname, + optval, + optlen); + } } errno = ENOPROTOOPT; |