SO_PROTOCOL is platform-dependent
authorJakub Hrozek <jakub.hrozek@gmail.com>
Tue, 1 Jul 2014 22:01:04 +0000 (00:01 +0200)
committerAndreas Schneider <asn@samba.org>
Tue, 29 Jul 2014 13:03:33 +0000 (15:03 +0200)
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>
src/socket_wrapper.c
tests/test_echo_tcp_socket_options.c

index 7ee5b6410658dd03c27dc70c0ecbb8e3fffe6426..903eec21537429fc69ea4979094888cf71c244a0 100644 (file)
@@ -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)) {
index 023ac72ce53444578209994fddcf088484470d55..3da4a95c4e0fa4a12a73ce1506f09626e2c5d2df 100644 (file)
@@ -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);
 }