summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/socket_wrapper.c3
-rw-r--r--tests/test_echo_tcp_socket_options.c10
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);
}