]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
Check if SO_BINDTODEVICE is defined 443/head
authorRobert Vollmer <robert.vollmer@sap.com>
Wed, 10 Aug 2022 09:15:55 +0000 (11:15 +0200)
committerRobert Vollmer <robert.vollmer@sap.com>
Wed, 10 Aug 2022 09:19:41 +0000 (11:19 +0200)
packet/construct_unix.c

index 65f0b633ca79df53ca8c7c83e4a36f87b582d04a..e78228aacb12cfa676a9a3381798444497c2efe0 100644 (file)
@@ -398,12 +398,14 @@ int set_stream_socket_options(
     }
 #endif
 
+#ifdef SO_BINDTODEVICE
     if (param->local_device) {
         if (setsockopt(stream_socket, SOL_SOCKET,
                        SO_BINDTODEVICE, param->local_device, strlen(param->local_device))) {
             return -1;
         }
     }
+#endif
 
     return 0;
 }
@@ -621,12 +623,14 @@ int construct_ip4_packet(
     }
 #endif
 
+#ifdef SO_BINDTODEVICE
     if (param->local_device) {
         if (setsockopt(send_socket, SOL_SOCKET,
                        SO_BINDTODEVICE, param->local_device, strlen(param->local_device))) {
             return -1;
         }
     }
+#endif
 
     /*
        Bind src port when not using raw socket to pass in ICMP id, kernel
@@ -796,6 +800,7 @@ int construct_ip6_packet(
     }
 #endif
 
+#ifdef SO_BINDTODEVICE
     if (param->local_device) {
         if (setsockopt(send_socket,
                        SOL_SOCKET, SO_BINDTODEVICE, param->local_device,
@@ -803,6 +808,7 @@ int construct_ip6_packet(
             return -1;
         }
     }
+#endif
 
     return 0;
 }