[go: nahoru, domu]

Nmap Development mailing list archives

[PATCH 2/2] nping: use socket_bindtodevice nbase function for IPv6 interface binding


From: ValdikSS via dev <dev () nmap org>
Date: Fri, 21 Jun 2024 15:46:48 +0300

There's a socket_bindtodevice() function in nbase misc which binds to
devise, use it instead of raw system function.
---
 nping/ProbeMode.cc | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/nping/ProbeMode.cc b/nping/ProbeMode.cc
index 382b330c4..7abb20692 100644
--- a/nping/ProbeMode.cc
+++ b/nping/ProbeMode.cc
@@ -722,12 +722,10 @@ int ProbeMode::doIPv6ThroughSocket(int rawfd){
 
     /* Bind IPv6 socket to a specific network interface */
     if ( o.issetDevice() )  {
-        /* It seems that SO_BINDTODEVICE only work on Linux */
-        #ifdef LINUX
-        if (setsockopt(rawfd, SOL_SOCKET, SO_BINDTODEVICE, o.getDevice(), strlen(o.getDevice())+1) == -1) {
+        if (socket_bindtodevice(rawfd, o.getDevice()))
+        {
             nping_warning(QT_2, "Error binding IPv6 socket to device %s", o.getDevice() );
         }
-        #endif
     }
 
     return OP_SUCCESS;
-- 
2.45.2

_______________________________________________
Sent through the dev mailing list
https://nmap.org/mailman/listinfo/dev
Archived at https://seclists.org/nmap-dev/


Current thread: