diff --git a/tcpip.cc b/tcpip.cc index 4dd003fda..8f33edaee 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -163,11 +163,15 @@ static PacketCounter PktCt; AF_INET6, depending on the operating system. */ int nmap_raw_socket() { int rawsd; + int one = 1; rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); if (rawsd < 0) return rawsd; - broadcast_socket(rawsd); + if (setsockopt (rawsd, SOL_SOCKET, SO_BROADCAST, (const char *) &one, sizeof(int)) != 0) { + error("Failed to secure socket broadcasting permission"); + perror("setsockopt"); + } #ifndef WIN32 sethdrinclude(rawsd); #endif @@ -1804,19 +1808,6 @@ void max_rcvbuf(int sd) { } -/* Give broadcast permission to a socket */ -void broadcast_socket(int sd) { - int one = 1; -#ifdef WIN32 - if (sd == 501) - return; -#endif - if (setsockopt (sd, SOL_SOCKET, SO_BROADCAST, (const char *) &one, sizeof(int)) != 0) { - error("Failed to secure socket broadcasting permission"); - perror("setsockopt"); - } -} - /* Do a receive (recv()) on a socket and stick the results (up to len) into buf . Give up after 'seconds'. Returns the number of bytes read (or -1 in the case of an error. It only does one recv diff --git a/tcpip.h b/tcpip.h index 538622aa2..b94c47d9d 100644 --- a/tcpip.h +++ b/tcpip.h @@ -453,9 +453,6 @@ int gettcpopt_ts(struct tcp_hdr *tcp, u32 *timestamp, u32 *echots); /* Maximize the receive buffer of a socket descriptor (up to 500K) */ void max_rcvbuf(int sd); -/* Give broadcast permission to a socket */ -void broadcast_socket(int sd); - /* Do a receive (recv()) on a socket and stick the results (upt to len) into buf . Give up after 'seconds'. Returns the number of bytes read (or -1 in the case of an error. It only does one recv