Add a SIOCGIFINDEX ioctl, which returns the index of a named interface.

This will be used to more efficiently support if_nametoindex(3).
This commit is contained in:
Jonathan Lemon 2001-10-17 19:40:44 +00:00
parent 10930aad3f
commit de5934508a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=85079
3 changed files with 7 additions and 0 deletions

View File

@ -1145,6 +1145,10 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
ifr = (struct ifreq *)data;
switch (cmd) {
case SIOCGIFINDEX:
ifr->ifr_index = ifp->if_index;
break;
case SIOCGIFFLAGS:
ifr->ifr_flags = ifp->if_flags;
break;

View File

@ -200,6 +200,7 @@ struct ifreq {
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
short ifru_flags[2];
short ifru_index;
int ifru_metric;
int ifru_mtu;
int ifru_phys;
@ -219,6 +220,7 @@ struct ifreq {
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
#define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */
#define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */
#define ifr_index ifr_ifru.ifru_index /* interface index */
};
#define _SIZEOF_ADDR_IFREQ(ifr) \

View File

@ -79,6 +79,7 @@
#define SIOCDLIFADDR _IOW('i', 29, struct if_laddrreq) /* delete IF addr */
#define SIOCSIFCAP _IOW('i', 30, struct ifreq) /* set IF features */
#define SIOCGIFCAP _IOWR('i', 31, struct ifreq) /* get IF features */
#define SIOCGIFINDEX _IOWR('i', 32, struct ifreq) /* get IF index */
#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */
#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */