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++;
}

View file

@ -228,6 +228,7 @@ struct interface_info {
u16 netmask_bits; /* CIDR-style. So 24 means class C (255.255.255.0)*/
devtype device_type; /* devt_ethernet, devt_loopback, devt_p2p, devt_other */
int device_up; /* True if the device is up (enabled) */
int mtu; /* Interface's MTU size */
u8 mac[6]; /* Interface MAC address if device_type is devt_ethernet */
};