From 84f4697c503132ad3ce02b9a8887cb2d39b7769c Mon Sep 17 00:00:00 2001 From: david Date: Wed, 3 Oct 2012 15:43:23 +0000 Subject: [PATCH] Call socket_bindtodevice in nmap_raw_socket. --- tcpip.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tcpip.cc b/tcpip.cc index 8370a510e..d7f66f9df 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -142,11 +142,13 @@ static PacketCounter PktCt; * Emit a fatal error on Windows. * Set SO_BROADCAST. * Set IP_HDRINCL. + * Bind to an interface with SO_BINDTODEVICE (if o.device is set). The socket is created with address family AF_INET, but may be usable for AF_INET6, depending on the operating system. The argument warning_device_name is used *only* in the Windows fatal error - message, and does not affect any socket characteristics. */ + message, and does not affect any socket characteristics. The global o.device + controls which interface to bind to with SO_BINDTODEVICE. */ int nmap_raw_socket(const char *warning_device_name) { int rawsd; @@ -159,6 +161,7 @@ int nmap_raw_socket(const char *warning_device_name) { #ifndef WIN32 sethdrinclude(rawsd); #endif + socket_bindtodevice(rawsd, o.device); return rawsd; }