diff options
| author | Jakub Hrozek <jakub.hrozek@gmail.com> | 2014-07-02 00:01:04 +0200 |
|---|---|---|
| committer | Andreas Schneider <asn@samba.org> | 2014-07-29 15:03:33 +0200 |
| commit | d9bae3a469d4803003711ae282a52d72905068e9 (patch) | |
| tree | cb0517a500afab2bac27a919cda4b5fce387fde9 | |
| parent | 1fcf8726753f38651d009c63d12a179854b506b8 (diff) | |
| download | socket_wrapper-d9bae3a469d4803003711ae282a52d72905068e9.tar.gz socket_wrapper-d9bae3a469d4803003711ae282a52d72905068e9.tar.xz socket_wrapper-d9bae3a469d4803003711ae282a52d72905068e9.zip | |
SO_PROTOCOL is platform-dependent
SO_PROTOCOL is not defined on all platforms. In particular, OSX doesn't
include it and so far I haven't found any compatible declaration.
Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
| -rw-r--r-- | src/socket_wrapper.c | 3 | ||||
| -rw-r--r-- | tests/test_echo_tcp_socket_options.c | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 7ee5b64..903eec2 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -3169,6 +3169,8 @@ static int swrap_getsockopt(int s, int level, int optname, *(int *)optval = si->family; return 0; #endif /* SO_DOMAIN */ + +#ifdef SO_PROTOCOL case SO_PROTOCOL: if (optval == NULL || optlen == NULL || *optlen < (socklen_t)sizeof(int)) { @@ -3179,6 +3181,7 @@ static int swrap_getsockopt(int s, int level, int optname, *optlen = sizeof(int); *(int *)optval = si->protocol; return 0; +#endif /* SO_PROTOCOL */ case SO_TYPE: if (optval == NULL || optlen == NULL || *optlen < (socklen_t)sizeof(int)) { diff --git a/tests/test_echo_tcp_socket_options.c b/tests/test_echo_tcp_socket_options.c index 023ac72..3da4a95 100644 --- a/tests/test_echo_tcp_socket_options.c +++ b/tests/test_echo_tcp_socket_options.c @@ -101,8 +101,10 @@ static void test_sockopt_so(void **state) #ifdef SO_DOMAIN int so_domain = -1; #endif /* SO_DOMAIN */ +#ifdef SO_PROTOCOL int so_protocol = -1; int so_type = -1; +#endif /* SO_PROTOCOL */ int rc; int s; @@ -135,6 +137,7 @@ static void test_sockopt_so(void **state) assert_int_equal(so_len, sizeof(int)); #endif /* SO_DOMAIN */ +#ifdef SO_PROTOCOL so_len = sizeof(so_protocol); rc = getsockopt(s, SOL_SOCKET, @@ -154,6 +157,7 @@ static void test_sockopt_so(void **state) assert_return_code(rc, errno); assert_int_equal(so_type, SOCK_STREAM); assert_int_equal(so_len, sizeof(int)); +#endif /* SO_PROTOCOL */ close(s); } @@ -163,12 +167,14 @@ static void test_sockopt_so6(void **state) { struct sockaddr_in6 sin6; socklen_t slen = sizeof(struct sockaddr_in6); - socklen_t so_len; #ifdef SO_DOMAIN int so_domain = -1; #endif /* SO_DOMAIN */ +#ifdef SO_PROTOCOL + socklen_t so_len; int so_protocol = -1; int so_type = -1; +#endif /* SO_PROTOCOL */ int rc; int s; @@ -201,6 +207,7 @@ static void test_sockopt_so6(void **state) assert_int_equal(so_len, sizeof(int)); #endif /* SO_DOMAIN */ +#ifdef SO_PROTOCOL so_len = sizeof(so_protocol); rc = getsockopt(s, SOL_SOCKET, @@ -220,6 +227,7 @@ static void test_sockopt_so6(void **state) assert_return_code(rc, errno); assert_int_equal(so_type, SOCK_STREAM); assert_int_equal(so_len, sizeof(int)); +#endif /* SO_PROTOCOL */ close(s); } |
