diff options
author | Andreas Schneider <asn@samba.org> | 2014-05-22 11:18:08 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2014-05-26 16:45:16 +0200 |
commit | e7f7bec0b56acd7b9744af53f7d96a53abd46ad3 (patch) | |
tree | 5c61ec019d586657f169328ace0099dfbcf88f24 /src | |
parent | c9b06b39df767539e47da8b6ce2208a5463a5314 (diff) | |
download | socket_wrapper-e7f7bec0b56acd7b9744af53f7d96a53abd46ad3.tar.gz socket_wrapper-e7f7bec0b56acd7b9744af53f7d96a53abd46ad3.tar.xz socket_wrapper-e7f7bec0b56acd7b9744af53f7d96a53abd46ad3.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 'src')
-rw-r--r-- | src/socket_wrapper.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index c52f3d7..19ac184 100644 --- a/src/socket_wrapper.c +++ b/src/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; |