summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorjoshua stein <jcs@cvs.openbsd.org>2004-05-29 17:54:47 +0000
committerjoshua stein <jcs@cvs.openbsd.org>2004-05-29 17:54:47 +0000
commit4d102c539fde3c0ed85b6e72d7762111b986fdb3 (patch)
treecb546f34b9a8cba2250874c4d51940e2382efd28 /sys/net
parent25f31fc4bbca56a9826d5afd73ecf39068e32148 (diff)
introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig help from various, ok deraadt@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c21
-rw-r--r--sys/net/if.h8
2 files changed, 27 insertions, 2 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) */