diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 21 | ||||
-rw-r--r-- | sys/net/if.h | 8 | ||||
-rw-r--r-- | sys/sys/sockio.h | 5 |
3 files changed, 31 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 831a76336a1..1beb9f670e0 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.87 2004/04/28 01:20:29 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.88 2004/05/29 17:54:45 jcs Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1117,7 +1117,9 @@ ifioctl(so, cmd, data, p) { struct ifnet *ifp; struct ifreq *ifr; + char ifdescrbuf[IFDESCRSIZE]; int error = 0; + size_t bytesdone; short oif_flags; switch (cmd) { @@ -1231,6 +1233,23 @@ ifioctl(so, cmd, data, p) error = (*ifp->if_ioctl)(ifp, cmd, data); break; + case SIOCGIFDESCR: + strlcpy(ifdescrbuf, ifp->if_description, IFDESCRSIZE); + error = copyoutstr(ifdescrbuf, ifr->ifr_data, IFDESCRSIZE, + &bytesdone); + break; + + case SIOCSIFDESCR: + if ((error = suser(p, 0)) != 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: if (so->so_proto == 0) return (EOPNOTSUPP); diff --git a/sys/net/if.h b/sys/net/if.h index 98ec6ef3eaa..283ef39a693 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.52 2004/05/18 21:10:14 brad Exp $ */ +/* $OpenBSD: if.h,v 1.53 2004/05/29 17:54:45 jcs Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -165,6 +165,11 @@ TAILQ_HEAD(ifnet_head, ifnet); /* the actual queue head */ #define IFNAMSIZ 16 #define IF_NAMESIZE IFNAMSIZ +/* + * Length of interface description, including terminating '\0'. + */ +#define IFDESCRSIZE 64 + struct ifnet { /* and the entries */ void *if_softc; /* lower-level data for this if */ TAILQ_ENTRY(ifnet) if_list; /* all struct ifnets are chained */ @@ -180,6 +185,7 @@ struct ifnet { /* and the entries */ short if_flags; /* up/down, broadcast, etc. */ struct if_data if_data; /* stats and other data about if */ int if_capabilities; /* interface capabilities */ + char if_description[IFDESCRSIZE]; /* interface description */ /* procedure handles */ /* output routine (enqueue) */ diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h index e78f68b9e94..bc16dff5daa 100644 --- a/sys/sys/sockio.h +++ b/sys/sys/sockio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sockio.h,v 1.24 2003/12/08 09:09:03 markus Exp $ */ +/* $OpenBSD: sockio.h,v 1.25 2004/05/29 17:54:45 jcs Exp $ */ /* $NetBSD: sockio.h,v 1.5 1995/08/23 00:40:47 thorpej Exp $ */ /*- @@ -143,4 +143,7 @@ #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_ */ |