mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
Inline getpcapinterfaces, used in only 1 location
This commit is contained in:
@@ -311,6 +311,7 @@ void win32_fatal_raw_sockets(const char *devname) {
|
|||||||
static void print_iflist_pcap_mapping(const struct interface_info *iflist,
|
static void print_iflist_pcap_mapping(const struct interface_info *iflist,
|
||||||
int numifs) {
|
int numifs) {
|
||||||
pcap_if_t *pcap_ifs = NULL;
|
pcap_if_t *pcap_ifs = NULL;
|
||||||
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
std::list<const pcap_if_t *> leftover_pcap_ifs;
|
std::list<const pcap_if_t *> leftover_pcap_ifs;
|
||||||
std::list<const pcap_if_t *>::iterator leftover_p;
|
std::list<const pcap_if_t *>::iterator leftover_p;
|
||||||
int i;
|
int i;
|
||||||
@@ -318,7 +319,9 @@ static void print_iflist_pcap_mapping(const struct interface_info *iflist,
|
|||||||
/* Build a list of "leftover" libpcap interfaces. Initially it contains all
|
/* Build a list of "leftover" libpcap interfaces. Initially it contains all
|
||||||
the interfaces. */
|
the interfaces. */
|
||||||
if (o.have_pcap) {
|
if (o.have_pcap) {
|
||||||
pcap_ifs = getpcapinterfaces();
|
if (pcap_findalldevs(&p_ifaces, errbuf) == -1) {
|
||||||
|
fatal("pcap_findalldevs(): Cannot retrieve pcap interfaces: %s", errbuf);
|
||||||
|
}
|
||||||
for (const pcap_if_t *p = pcap_ifs; p != NULL; p = p->next)
|
for (const pcap_if_t *p = pcap_ifs; p != NULL; p = p->next)
|
||||||
leftover_pcap_ifs.push_front(p);
|
leftover_pcap_ifs.push_front(p);
|
||||||
}
|
}
|
||||||
|
|||||||
23
tcpip.cc
23
tcpip.cc
@@ -1774,29 +1774,6 @@ bool getNextHopMAC(const char *iface, const u8 *srcmac, const struct sockaddr_st
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pcap_if_t *getpcapinterfaces() {
|
|
||||||
#ifndef WIN32
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
pcap_if_t *p_ifaces;
|
|
||||||
char errbuf[PCAP_ERRBUF_SIZE];
|
|
||||||
|
|
||||||
if ((pcap_findalldevs(&p_ifaces, errbuf)) == -1) {
|
|
||||||
fatal("pcap_findalldevs(): Cannot retrieve pcap interfaces: %s", errbuf);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return p_ifaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int nmap_route_dst(const struct sockaddr_storage *dst, struct route_nfo *rnfo) {
|
int nmap_route_dst(const struct sockaddr_storage *dst, struct route_nfo *rnfo) {
|
||||||
struct sockaddr_storage spoofss;
|
struct sockaddr_storage spoofss;
|
||||||
size_t spoofsslen;
|
size_t spoofsslen;
|
||||||
|
|||||||
4
tcpip.h
4
tcpip.h
@@ -393,10 +393,6 @@ int readudppacket(const u8 *packet, int readdata);
|
|||||||
the interface_info for the first one found. If non found, returns NULL */
|
the interface_info for the first one found. If non found, returns NULL */
|
||||||
struct interface_info *getInterfaceByIP(struct sockaddr_storage *ss);
|
struct interface_info *getInterfaceByIP(struct sockaddr_storage *ss);
|
||||||
|
|
||||||
|
|
||||||
pcap_if_t *getpcapinterfaces();
|
|
||||||
|
|
||||||
|
|
||||||
/* Fill buf (up to buflen -- truncate if necessary but always
|
/* Fill buf (up to buflen -- truncate if necessary but always
|
||||||
terminate) with a short representation of the packet stats.
|
terminate) with a short representation of the packet stats.
|
||||||
Returns buf. Aborts if there is a problem. */
|
Returns buf. Aborts if there is a problem. */
|
||||||
|
|||||||
Reference in New Issue
Block a user