1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 00:49:01 +00:00

Committing MTU-related changes:

* Adding path-mtu.nse for Path MTU Discovery
* Nmap now stores the MTU for interfaces (from SIOCGIFMTU or libdnet)
* Scripts can access the MTU for host.interface via host.interface_mtu
* Nmap prints the MTU for interfaces in --iflist
This commit is contained in:
kris
2010-08-24 01:47:12 +00:00
parent c3a1ec9f02
commit 57664a51cf
11 changed files with 459 additions and 5 deletions

View File

@@ -995,6 +995,8 @@ static int collect_dnet_interfaces(const struct intf_entry *entry, void *arg) {
dcrn->ifaces[dcrn->numifaces].device_type = devt_other;
}
dcrn->ifaces[dcrn->numifaces].mtu = entry->intf_mtu;
/* Is the interface up and running? */
dcrn->ifaces[dcrn->numifaces].device_up = (entry->intf_flags & INTF_FLAG_UP) ? true : false;
@@ -1197,6 +1199,27 @@ static struct interface_info *getinterfaces_siocgifconf(int *howmany, char *errs
else
devs[count].device_up = 0;
#ifdef SIOCGIFMTU
memcpy(&tmpifr.ifr_addr, sin, MIN(sizeof(tmpifr.ifr_addr), sizeof(*sin)));
rc = ioctl(sd, SIOCGIFMTU, &tmpifr);
if (rc < 0) {
if(errstr) Snprintf(errstr, errstrlen, "Failed to determine the mtu of %s!", tmpifr.ifr_name);
*howmany=-1;
return NULL;
} else {
#ifdef ifr_mtu
devs[count].mtu = tmpifr.ifr_mtu;
#else
/* Some systems lack ifr_mtu and a common solution (see pcap, dnet and
* others) is using ifr_metric instead
*/
devs[count].mtu = tmpifr.ifr_metric;
#endif
}
#else
devs[count].mtu = 0;
#endif
/* All done with this interface. Increase the count. */
count++;
}