mirror of
https://github.com/nmap/nmap.git
synced 2026-02-05 21:16:33 +00:00
merge soc07 r4829 - Added winpcap device names to the --iflist table
This commit is contained in:
20
output.cc
20
output.cc
@@ -290,6 +290,7 @@ int print_iflist(void) {
|
||||
int numifs = 0, numroutes = 0;
|
||||
struct interface_info *iflist;
|
||||
struct sys_route *routes;
|
||||
pcap_if_t *p_ifaces, *p_iface_iter;
|
||||
NmapOutputTable *Tbl = NULL;
|
||||
iflist = getinterfaces(&numifs);
|
||||
int i;
|
||||
@@ -325,6 +326,25 @@ int print_iflist(void) {
|
||||
log_flush_all();
|
||||
delete Tbl;
|
||||
}
|
||||
|
||||
/* Display windows device names */
|
||||
if((p_ifaces = getpcapinterfaces()) != NULL && numifs > 0) {
|
||||
Tbl = new NmapOutputTable(3, numifs);
|
||||
Tbl->addItem(0, 0, false, "DEV");
|
||||
Tbl->addItem(0, 1, false, "WINDEVICE");
|
||||
i = numifs-1;
|
||||
|
||||
for(p_iface_iter = p_ifaces; p_iface_iter != NULL && i >= 0; i--) {
|
||||
Tbl->addItem(i+1, 0, false, iflist[i].devname);
|
||||
Tbl->addItem(i+1, 1, false, p_iface_iter->name);
|
||||
p_iface_iter = p_iface_iter->next;
|
||||
}
|
||||
|
||||
log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "%s\n", Tbl->printableTable(NULL));
|
||||
log_flush_all();
|
||||
delete Tbl;
|
||||
pcap_freealldevs(p_ifaces);
|
||||
}
|
||||
|
||||
/* OK -- time to handle routes */
|
||||
routes = getsysroutes(&numroutes);
|
||||
|
||||
14
tcpip.cc
14
tcpip.cc
@@ -2615,6 +2615,19 @@ static int collect_dnet_interfaces(const struct intf_entry *entry, void *arg) {
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
pcap_if_t *getpcapinterfaces() {
|
||||
#ifndef WIN32
|
||||
return NULL;
|
||||
#endif
|
||||
pcap_if_t *p_ifaces;
|
||||
|
||||
if((pcap_findalldevs(&p_ifaces, NULL)) == -1) {
|
||||
fatal("pcap_findalldevs() : Cannot retrieve pcap interfaces");
|
||||
return NULL;
|
||||
}
|
||||
return p_ifaces;
|
||||
}
|
||||
|
||||
struct interface_info *getinterfaces(int *howmany) {
|
||||
static bool initialized = 0;
|
||||
static struct interface_info *mydevs;
|
||||
@@ -2644,7 +2657,6 @@ int sd;
|
||||
|
||||
#if WIN32
|
||||
/* On Win32 we just use Dnet to determine the interface list */
|
||||
|
||||
dcrn.routes = NULL;
|
||||
dcrn.numroutes = 0;
|
||||
dcrn.capacity = ii_capacity; // I'm reusing this struct for ii now
|
||||
|
||||
1
tcpip.h
1
tcpip.h
@@ -648,6 +648,7 @@ struct interface_info *getInterfaceByIP(struct sockaddr_storage *ss);
|
||||
struct interface_info *getInterfaceByName(char *iname);
|
||||
/* Where the above 4 functions get their info */
|
||||
struct interface_info *getinterfaces(int *howmany);
|
||||
pcap_if_t *getpcapinterfaces();
|
||||
|
||||
/* Parse the system routing table, converting each route into a
|
||||
sys_route entry. Returns an array of sys_routes. numroutes is set
|
||||
|
||||
Reference in New Issue
Block a user