diff options
author | jlemon <jlemon@FreeBSD.org> | 2001-10-17 19:40:44 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 2001-10-17 19:40:44 +0000 |
commit | 85e1c0879143bd206c275035a79c73a212654cfa (patch) | |
tree | 48c6a8b547edcdd9d4d3efc68bc8d9880786c0e3 /sys | |
parent | ae7cec463fe49996e919eb79d6b94c2ececcb688 (diff) | |
download | FreeBSD-src-85e1c0879143bd206c275035a79c73a212654cfa.zip FreeBSD-src-85e1c0879143bd206c275035a79c73a212654cfa.tar.gz |
Add a SIOCGIFINDEX ioctl, which returns the index of a named interface.
This will be used to more efficiently support if_nametoindex(3).
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 4 | ||||
-rw-r--r-- | sys/net/if.h | 2 | ||||
-rw-r--r-- | sys/sys/sockio.h | 1 |
3 files changed, 7 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 2728141..7ffb296 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -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; diff --git a/sys/net/if.h b/sys/net/if.h index eb4d199..83116b9 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -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) \ diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h index c681f8e..03ea70c 100644 --- a/sys/sys/sockio.h +++ b/sys/sys/sockio.h @@ -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 */ |