1
0
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:
dmiller
2025-06-30 19:24:32 +00:00
parent fc71b7544d
commit 67a796844f
16 changed files with 162 additions and 207 deletions

View File

@@ -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, &ethsd)) {
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;