diff options
author | joshua stein <jcs@cvs.openbsd.org> | 2004-05-29 17:54:47 +0000 |
---|---|---|
committer | joshua stein <jcs@cvs.openbsd.org> | 2004-05-29 17:54:47 +0000 |
commit | 4d102c539fde3c0ed85b6e72d7762111b986fdb3 (patch) | |
tree | cb546f34b9a8cba2250874c4d51940e2382efd28 /sbin | |
parent | 25f31fc4bbca56a9826d5afd73ecf39068e32148 (diff) |
introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig
help from various, ok deraadt@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 11 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 25 |
2 files changed, 33 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 618e11de1cc..dc7a9681257 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.81 2004/05/18 10:54:07 otto Exp $ +.\" $OpenBSD: ifconfig.8,v 1.82 2004/05/29 17:54:46 jcs Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -314,6 +314,11 @@ allow you to respecify the host portion. .It Cm deletetunnel Removes the source and destination tunnel addresses, configured onto a tunnel interface. +.It Cm description Ar value +Specify a description of the interface. +This can be used to label interfaces in situations where they may +otherwise be difficult to identify +.Pq e.g. machines with many active interfaces . .It Ar dest_address Specify the address of the correspondent on the other end of a point-to-point link. @@ -692,6 +697,10 @@ Configure the xl0 interface to use 100baseTX, full duplex: .Pp .Dl # ifconfig xl0 media 100baseTX mediaopt full-duplex .Pp +Label the em0 interface as an uplink: +.Pp +.Dl # ifconfig em0 description \&"Uplink to Gigabit Switch 2\&" +.Pp Configure the vlan0 interface for IP address 192.168.254.1, vlan tag 4, and vlan parent device fxp0: .Pp diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 088650850cb..b329e6b0157 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.99 2004/05/18 10:54:07 otto Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.100 2004/05/29 17:54:46 jcs Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -77,7 +77,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; #else -static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.99 2004/05/18 10:54:07 otto Exp $"; +static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.100 2004/05/29 17:54:46 jcs Exp $"; #endif #endif /* not lint */ @@ -163,6 +163,7 @@ void setifaddr(const char *, int); void setifdstaddr(const char *, int); void setifflags(const char *, int); void setifbroadaddr(const char *, int); +void setifdesc(const char *, int); void setifipdst(const char *, int); void setifmetric(const char *, int); void setifmtu(const char *, int); @@ -317,6 +318,8 @@ const struct cmd { { "-mediaopt", NEXTARG, A_MEDIAOPTCLR, unsetmediaopt }, { "instance", NEXTARG, A_MEDIAINST, setmediainst }, { "inst", NEXTARG, A_MEDIAINST, setmediainst }, + { "description", NEXTARG, 0, setifdesc }, + { "descr", NEXTARG, 0, setifdesc }, { NULL, /*src*/ 0, 0, setifaddr }, { NULL, /*dst*/ 0, 0, setifdstaddr }, { NULL, /*illegal*/0, 0, NULL }, @@ -871,6 +874,14 @@ setifbroadaddr(const char *addr, int ignored) } void +setifdesc(const char *val, int ignored) +{ + ifr.ifr_data = (caddr_t)val; + if (ioctl(s, SIOCSIFDESCR, &ifr) < 0) + warn("SIOCSIFDESCR"); +} + +void setifipdst(const char *addr, int ignored) { in_getaddr(addr, DSTADDR); @@ -1667,7 +1678,9 @@ status(int link, struct sockaddr_dl *sdl) { const struct afswtch *p = afp; struct ifmediareq ifmr; + struct ifreq ifrdesc; int *media_list, i; + char *ifdescr[IFDESCRSIZE]; printf("%s: ", name); printb("flags", flags, IFFBITS); @@ -1680,6 +1693,13 @@ status(int link, struct sockaddr_dl *sdl) (void)printf("\taddress: %s\n", ether_ntoa( (struct ether_addr *)LLADDR(sdl))); + (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); + vlan_status(); carp_status(); pfsync_status(); @@ -2540,6 +2560,7 @@ usage(void) "\t[[-]alias] [[-]arp] [broadcast addr]\n" "\t[[-]debug] [delete] [up] [down] [ipdst addr]\n" "\t[tunnel src_address dest_address] [deletetunnel]\n" + "\t[description value]\n" "\t[[-]link0] [[-]link1] [[-]link2]\n" "\t[media type] [[-]mediaopt opts] [instance minst]\n" "\t[mtu value] [metric nhops] [netmask mask] [prefixlen n]\n" |