From 4f454a29d26f4c33bf8f146d4550ba464d6f327c Mon Sep 17 00:00:00 2001 From: david Date: Tue, 30 Aug 2011 23:55:07 +0000 Subject: [PATCH] Add the intf_entry.intf_index member. This is the operating system's interface index, as used by if_indextoname and sockaddr_sin6.sin6_scope_id. --- libdnet-stripped/include/dnet/intf.h | 1 + libdnet-stripped/src/intf.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/libdnet-stripped/include/dnet/intf.h b/libdnet-stripped/include/dnet/intf.h index ae54861dc..fd6e6aa2a 100644 --- a/libdnet-stripped/include/dnet/intf.h +++ b/libdnet-stripped/include/dnet/intf.h @@ -19,6 +19,7 @@ struct intf_entry { u_int intf_len; /* length of entry */ char intf_name[INTF_NAME_LEN]; /* interface name */ + u_int intf_index; /* interface index (r/o) */ u_short intf_type; /* interface type (r/o) */ u_short intf_flags; /* interface flags */ u_int intf_mtu; /* interface MTU */ diff --git a/libdnet-stripped/src/intf.c b/libdnet-stripped/src/intf.c index 93e7b00cf..3e13a3b51 100644 --- a/libdnet-stripped/src/intf.c +++ b/libdnet-stripped/src/intf.c @@ -391,6 +391,11 @@ _intf_get_noalias(intf_t *intf, struct intf_entry *entry) strlcpy(ifr.ifr_name, entry->intf_name, sizeof(ifr.ifr_name)); + /* Get interface index. */ + if (ioctl(intf->fd, SIOCGIFINDEX, &ifr) < 0) + return (-1); + entry->intf_index = ifr.ifr_ifindex; + /* Get interface flags. */ if (ioctl(intf->fd, SIOCGIFFLAGS, &ifr) < 0) return (-1);