diff -pbruN sbin/ifconfig.orig/ifconfig.c sbin/ifconfig/ifconfig.c --- sbin/ifconfig.orig/ifconfig.c Fri Jul 15 21:13:18 2005 +++ sbin/ifconfig/ifconfig.c Fri Jul 15 21:55:43 2005 @@ -93,6 +93,7 @@ int verbose; int supmedia = 0; int printname = 0; /* Print the name of the created interface. */ +void setifdesc(const char *, int, int); static int ifconfig(int argc, char *const *argv, const struct afswtch *afp); static void status(const struct afswtch *afp, int addrcount, struct sockaddr_dl *sdl, struct if_msghdr *ifm, @@ -722,6 +723,14 @@ setifflags(const char *vname, int value, } void +setifdesc(const char *val, int dummy __unused, int s) +{ + ifr.ifr_data = (caddr_t)val; + if (ioctl(s, SIOCSIFDESCR, &ifr) < 0) + warn("SIOCSIFDESCR"); +} + +void setifcap(const char *vname, int value, int s, const struct afswtch *afp) { @@ -825,6 +834,8 @@ status(const struct afswtch *afp, int ad struct rt_addrinfo info; int allfamilies, s; struct ifstat ifs; + struct ifreq ifrdesc; + char ifdescr[IFDESCRSIZE]; if (afp == NULL) { allfamilies = 1; @@ -847,6 +858,13 @@ status(const struct afswtch *afp, int ad printf(" mtu %ld", ifm->ifm_data.ifi_mtu); putchar('\n'); + (void) memset(&ifrdesc, 0, sizeof(ifrdesc)); + (void) strlcpy(ifrdesc.ifr_name, name, sizeof(ifrdesc.ifr_name)); + ifrdesc.ifr_data = (caddr_t)&ifdescr; + if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0 && + strlen(ifrdesc.ifr_data)) + printf("\tdescription: %s\n", ifrdesc.ifr_data); + if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) { if (ifr.ifr_curcap != 0) { printb("\toptions", ifr.ifr_curcap, IFCAPBITS); @@ -1044,6 +1062,8 @@ static struct cmd basic_cmds[] = { DEF_CMD("normal", -IFF_LINK0, setifflags), DEF_CMD("compress", IFF_LINK0, setifflags), DEF_CMD("noicmp", IFF_LINK1, setifflags), + DEF_CMD("description", NEXTARG, setifdesc), + DEF_CMD("descr", NEXTARG, setifdesc), DEF_CMD_ARG("mtu", setifmtu), DEF_CMD_ARG("name", setifname), }; diff -pbruN sys/net.orig/if.c sys/net/if.c --- sys/net.orig/if.c Fri Jul 15 15:45:33 2005 +++ sys/net/if.c Fri Jul 15 20:54:38 2005 @@ -1223,7 +1223,9 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, { struct ifreq *ifr; struct ifstat *ifs; + char ifdescrbuf[IFDESCRSIZE]; int error = 0; + size_t bytesdone; int new_flags; size_t namelen, onamelen; char new_name[IFNAMSIZ]; @@ -1485,6 +1487,24 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, ifr->ifr_addr.sa_data, ifr->ifr_addr.sa_len); break; + case SIOCGIFDESCR: + strlcpy(ifdescrbuf, ifp->if_description, IFDESCRSIZE); +/* error = copyoutstr(ifdescrbuf, ifr->ifr_data, IFDESCRSIZE, + &bytesdone);*/ + error = copyout(ifdescrbuf, ifr->ifr_data, IFDESCRSIZE); + break; + + case SIOCSIFDESCR: + if ((error = suser(td)) != 0) + return (error); + error = copyinstr(ifr->ifr_data, ifdescrbuf, + IFDESCRSIZE, &bytesdone); + if (error == 0) { + (void)memset(ifp->if_description, 0, IFDESCRSIZE); + strlcpy(ifp->if_description, ifdescrbuf, IFDESCRSIZE); + } + break; + default: error = ENOIOCTL; break; @@ -1500,7 +1520,9 @@ ifioctl(struct socket *so, u_long cmd, c { struct ifnet *ifp; struct ifreq *ifr; +/* char ifdescrbuf[IFDESCRSIZE];*/ int error; +/* size_t bytesdone;*/ int oif_flags; switch (cmd) { diff -pbruN sys/net.orig/if.h sys/net/if.h --- sys/net.orig/if.h Fri Jul 15 15:45:33 2005 +++ sys/net/if.h Fri Jul 15 15:53:18 2005 @@ -63,6 +63,11 @@ struct ifnet; #if __BSD_VISIBLE /* + + * Length of interface description, including terminating '\0'. + */ +#define IFDESCRSIZE 64 + +/* * Structure used to query names of interface cloners. */ diff -pbruN sys/net.orig/if_var.h sys/net/if_var.h --- sys/net.orig/if_var.h Fri Jul 15 15:45:33 2005 +++ sys/net/if_var.h Fri Jul 15 15:54:19 2005 @@ -137,6 +137,7 @@ struct ifnet { int if_flags; /* up/down, broadcast, etc. */ int if_capabilities; /* interface capabilities */ int if_capenable; /* enabled features */ + char if_description[IFDESCRSIZE]; /* interface description */ void *if_linkmib; /* link-type-specific MIB data */ size_t if_linkmiblen; /* length of above data */ struct if_data if_data; --- sys/sys/sockio.h.orig Fri Jul 15 15:55:41 2005 +++ sys/sys/sockio.h Fri Jul 15 15:56:10 2005 @@ -114,4 +114,8 @@ #define SIOCIFDESTROY _IOW('i', 121, struct ifreq) /* destroy clone if */ #define SIOCIFGCLONERS _IOWR('i', 120, struct if_clonereq) /* get cloners */ +#define SIOCSIFDESCR _IOW('i', 128, struct ifreq) /* set ifnet descr */ +#define SIOCGIFDESCR _IOWR('i', 129, struct ifreq) /* get ifnet descr */ + + #endif /* !_SYS_SOCKIO_H_ */