mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Consolidate raw socket acquisition.
This commit is contained in:
21
osscan2.cc
21
osscan2.cc
@@ -1336,24 +1336,11 @@ HostOsScan::HostOsScan(Target *t) {
|
||||
rawsd = -1;
|
||||
ethsd = NULL;
|
||||
|
||||
if ((o.sendpref & PACKET_SEND_ETH) && (t->ifType() == devt_ethernet
|
||||
#ifdef WIN32
|
||||
|| (o.have_pcap && t->ifType() == devt_loopback)
|
||||
#endif
|
||||
)) {
|
||||
if ((ethsd = eth_open_cached(t->deviceName())) == NULL)
|
||||
fatal("%s: Failed to open ethernet device (%s)", __func__, t->deviceName());
|
||||
rawsd = -1;
|
||||
} else {
|
||||
#ifdef WIN32
|
||||
win32_fatal_raw_sockets(t->deviceName());
|
||||
#endif
|
||||
rawsd = nmap_raw_socket();
|
||||
if (rawsd < 0)
|
||||
pfatal("socket troubles in %s", __func__);
|
||||
unblock_socket(rawsd);
|
||||
ethsd = NULL;
|
||||
if (!raw_socket_or_eth(o.sendpref, t->deviceName(), &rawsd, ðsd)) {
|
||||
fatal("%s: Failed to open raw socket or ethernet device", __func__);
|
||||
}
|
||||
if (rawsd >= 0)
|
||||
unblock_socket(rawsd);
|
||||
|
||||
if (o.magic_port_set) {
|
||||
tcpPortBase = o.magic_port;
|
||||
|
||||
Reference in New Issue
Block a user