diff --git a/nmap.cc b/nmap.cc index f576f6cb5..a007312ea 100644 --- a/nmap.cc +++ b/nmap.cc @@ -2088,36 +2088,6 @@ int gather_logfile_resumption_state(char *fname, int *myargc, char ***myargv) { return 0; } -/* We set the socket lingering so we will RST connection instead of wasting - bandwidth with the four step close */ -void init_socket(int sd) { - struct linger l; - int res; - static int bind_failed=0; - struct sockaddr_storage ss; - size_t sslen; - - l.l_onoff = 1; - l.l_linger = 0; - - if (setsockopt(sd, SOL_SOCKET, SO_LINGER, (const char *) &l, sizeof(struct linger))) - { - error("Problem setting socket SO_LINGER, errno: %d", socket_errno()); - perror("setsockopt"); - } - if (o.spoofsource && !bind_failed) - { - o.SourceSockAddr(&ss, &sslen); - res=bind(sd, (struct sockaddr*)&ss, sslen); - if (res<0) - { - error("%s: Problem binding source address (%s), errno: %d", __func__, inet_socktop(&ss), socket_errno()); - perror("bind"); - bind_failed=1; - } - } -} - /* Convert a string like "-100,n*tp,200-1024,3000-4000,[60000-]" into an array diff --git a/nmap.h b/nmap.h index 4e3bd3af2..4d804fada 100644 --- a/nmap.h +++ b/nmap.h @@ -425,9 +425,6 @@ void getpts_simple(const char *origexpr, int range_type, unsigned short **list, int *count); void free_scan_lists(struct scan_lists *ports); -/* socket manipulation functions */ -void init_socket(int sd); - /* Renamed main so that interactive mode could preprocess when necessary */ int nmap_main(int argc, char *argv[]); diff --git a/scan_engine.cc b/scan_engine.cc index 23af4887d..3210aa833 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -2951,6 +2951,35 @@ static void ultrascan_port_probe_update(UltraScanInfo *USI, HostScanStats *hss, +/* We set the socket lingering so we will RST connection instead of wasting + bandwidth with the four step close */ +static void init_socket(int sd) { + struct linger l; + int res; + static int bind_failed=0; + struct sockaddr_storage ss; + size_t sslen; + + l.l_onoff = 1; + l.l_linger = 0; + + if (setsockopt(sd, SOL_SOCKET, SO_LINGER, (const char *) &l, sizeof(struct linger))) + { + error("Problem setting socket SO_LINGER, errno: %d", socket_errno()); + perror("setsockopt"); + } + if (o.spoofsource && !bind_failed) + { + o.SourceSockAddr(&ss, &sslen); + res=bind(sd, (struct sockaddr*)&ss, sslen); + if (res<0) + { + error("%s: Problem binding source address (%s), errno: %d", __func__, inet_socktop(&ss), socket_errno()); + perror("bind"); + bind_failed=1; + } + } +} /* If this is NOT a ping probe, set pingseq to 0. Otherwise it will be the ping sequence number (they start at 1). The probe sent is returned. */