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:
parent
8482fec621
commit
240b4c5b53
@ -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;
|
||||
|
@ -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) \
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user