mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Inline broadcast_socket(), only used in one place.
Also remove the check for the special socket value 501, which is a vestige of a workaround leftover from when raw sockets mostly worked on Windows. That code was removed in r2812 back in 2005.
This commit is contained in:
19
tcpip.cc
19
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
|
||||
|
||||
3
tcpip.h
3
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
|
||||
|
||||
Reference in New Issue
Block a user