1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-01 12:29:03 +00:00

Use if_nametoindex instead of SIOCGIFINDEX.

The latter isn't available on OS X.
This commit is contained in:
david
2011-09-17 06:40:41 +00:00
parent 2511cd1d2a
commit 70d2105b9f

View File

@@ -389,12 +389,12 @@ _intf_get_noalias(intf_t *intf, struct intf_entry *entry)
{
struct ifreq ifr;
strlcpy(ifr.ifr_name, entry->intf_name, sizeof(ifr.ifr_name));
/* Get interface index. */
if (ioctl(intf->fd, SIOCGIFINDEX, &ifr) < 0)
entry->intf_index = if_nametoindex(entry->intf_name);
if (entry->intf_index == 0)
return (-1);
entry->intf_index = ifr.ifr_ifindex;
strlcpy(ifr.ifr_name, entry->intf_name, sizeof(ifr.ifr_name));
/* Get interface flags. */
if (ioctl(intf->fd, SIOCGIFFLAGS, &ifr) < 0)