diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-08-03 11:23:12 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-08-03 11:23:12 +0000 |
commit | c04b122966d038b53c821703962a4d199da35cee (patch) | |
tree | 392ed5dd38e68dced61ea70b028dc60555773d44 | |
parent | 4db9c1a02eeb9a2f2cab3f9d37ff1c15ce1b91dd (diff) |
display route labels with "route get", and allow them to be set
-rw-r--r-- | sbin/route/keywords.c | 3 | ||||
-rw-r--r-- | sbin/route/keywords.h | 59 | ||||
-rw-r--r-- | sbin/route/keywords.sh | 3 | ||||
-rw-r--r-- | sbin/route/route.c | 37 |
4 files changed, 66 insertions, 36 deletions
diff --git a/sbin/route/keywords.c b/sbin/route/keywords.c index a205ff55ae5..f229e7dad5f 100644 --- a/sbin/route/keywords.c +++ b/sbin/route/keywords.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keywords.c,v 1.9 2004/06/25 01:26:01 henning Exp $ */ +/* $OpenBSD: keywords.c,v 1.10 2004/08/03 11:23:11 henning Exp $ */ /* WARNING! This file was generated by keywords.sh */ @@ -26,6 +26,7 @@ struct keytab keywords[] = { {"inet", K_INET}, {"inet6", K_INET6}, {"ipx", K_IPX}, + {"label", K_LABEL}, {"link", K_LINK}, {"llinfo", K_LLINFO}, {"lock", K_LOCK}, diff --git a/sbin/route/keywords.h b/sbin/route/keywords.h index c3cf9177d51..6863b02ca9c 100644 --- a/sbin/route/keywords.h +++ b/sbin/route/keywords.h @@ -1,4 +1,4 @@ -/* $OpenBSD: keywords.h,v 1.9 2004/06/25 01:26:01 henning Exp $ */ +/* $OpenBSD: keywords.h,v 1.10 2004/08/03 11:23:11 henning Exp $ */ /* WARNING! This file was generated by keywords.sh */ @@ -28,31 +28,32 @@ extern struct keytab { #define K_INET 18 #define K_INET6 19 #define K_IPX 20 -#define K_LINK 21 -#define K_LLINFO 22 -#define K_LOCK 23 -#define K_LOCKREST 24 -#define K_MASK 25 -#define K_MONITOR 26 -#define K_MPATH 27 -#define K_MTU 28 -#define K_NET 29 -#define K_NETMASK 30 -#define K_NOSTATIC 31 -#define K_OSI 32 -#define K_PREFIXLEN 33 -#define K_PROTO1 34 -#define K_PROTO2 35 -#define K_RECVPIPE 36 -#define K_REJECT 37 -#define K_RTT 38 -#define K_RTTVAR 39 -#define K_SA 40 -#define K_SENDPIPE 41 -#define K_SHOW 42 -#define K_SRC 43 -#define K_SRCMASK 44 -#define K_SSTHRESH 45 -#define K_STATIC 46 -#define K_X25 47 -#define K_XRESOLVE 48 +#define K_LABEL 21 +#define K_LINK 22 +#define K_LLINFO 23 +#define K_LOCK 24 +#define K_LOCKREST 25 +#define K_MASK 26 +#define K_MONITOR 27 +#define K_MPATH 28 +#define K_MTU 29 +#define K_NET 30 +#define K_NETMASK 31 +#define K_NOSTATIC 32 +#define K_OSI 33 +#define K_PREFIXLEN 34 +#define K_PROTO1 35 +#define K_PROTO2 36 +#define K_RECVPIPE 37 +#define K_REJECT 38 +#define K_RTT 39 +#define K_RTTVAR 40 +#define K_SA 41 +#define K_SENDPIPE 42 +#define K_SHOW 43 +#define K_SRC 44 +#define K_SRCMASK 45 +#define K_SSTHRESH 46 +#define K_STATIC 47 +#define K_X25 48 +#define K_XRESOLVE 49 diff --git a/sbin/route/keywords.sh b/sbin/route/keywords.sh index 4c8bc5989e9..aaa2a4c3260 100644 --- a/sbin/route/keywords.sh +++ b/sbin/route/keywords.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: keywords.sh,v 1.8 2004/06/25 01:26:01 henning Exp $ +# $OpenBSD: keywords.sh,v 1.9 2004/08/03 11:23:11 henning Exp $ # $NetBSD: keywords.sh,v 1.2 1996/11/15 18:57:21 gwr Exp $ # @(#)keywords 8.2 (Berkeley) 3/19/94 # @@ -29,6 +29,7 @@ ifp inet inet6 ipx +label link llinfo lock diff --git a/sbin/route/route.c b/sbin/route/route.c index 06cb5762fd7..cd771abd969 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.71 2004/06/25 01:26:01 henning Exp $ */ +/* $OpenBSD: route.c,v 1.72 2004/08/03 11:23:11 henning Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94"; #else -static const char rcsid[] = "$OpenBSD: route.c,v 1.71 2004/06/25 01:26:01 henning Exp $"; +static const char rcsid[] = "$OpenBSD: route.c,v 1.72 2004/08/03 11:23:11 henning Exp $"; #endif #endif /* not lint */ @@ -84,7 +84,8 @@ union sockunion { struct sockaddr_dl sdl; struct sockaddr_x25 sx25; struct sockaddr_rtin rtin; -} so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp, so_src, so_srcmask; + struct sockaddr_rtlabel rtlabel; +} so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp, so_src, so_srcmask, so_label; typedef union sockunion *sup; pid_t pid; @@ -120,6 +121,7 @@ void quit(char *); void set_metric(char *, int); void inet_makenetandmask(u_int32_t, struct sockaddr_in *, int, int); void interfaces(void); +void getlabel(char *); __dead void usage(char *cp) @@ -480,6 +482,11 @@ newroute(int argc, char **argv) usage(1+*argv); (void) getaddr(RTA_SRCMASK, *++argv, 0); break; + case K_LABEL: + if (!--argc) + usage(1+*argv); + (void) getlabel(*++argv); + break; case K_NETMASK: if (!--argc) usage(1+*argv); @@ -1068,6 +1075,7 @@ rtmsg(int cmd, int flags) NEXTADDR(RTA_IFA, so_ifa); NEXTADDR(RTA_SRC, so_src); NEXTADDR(RTA_SRCMASK, so_srcmask); + NEXTADDR(RTA_LABEL, so_label); rtm.rtm_msglen = l = cp - (char *)&m_rtmsg; if (verbose) print_rtmsg(&rtm, l); @@ -1152,7 +1160,7 @@ char routeflags[] = char ifnetflags[] = "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST"; char addrnames[] = -"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\011SRC\012SRCMASK"; +"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\011SRC\012SRCMASK\13LABEL"; void print_rtmsg(struct rt_msghdr *rtm, int msglen) @@ -1224,6 +1232,7 @@ print_getmsg(struct rt_msghdr *rtm, int msglen) struct sockaddr *dst = NULL, *gate = NULL, *mask = NULL; struct sockaddr *src = NULL, *srcmask = NULL; struct sockaddr_dl *ifp = NULL; + struct sockaddr_rtlabel *sa_rl = NULL; struct sockaddr *sa; char *cp; int i; @@ -1271,6 +1280,9 @@ print_getmsg(struct rt_msghdr *rtm, int msglen) ((struct sockaddr_dl *)sa)->sdl_nlen) ifp = (struct sockaddr_dl *)sa; break; + case RTA_LABEL: + sa_rl = (struct sockaddr_rtlabel *)sa; + break; } ADVANCE(cp, sa); } @@ -1303,11 +1315,14 @@ print_getmsg(struct rt_msghdr *rtm, int msglen) ifp->sdl_nlen, ifp->sdl_data); (void)printf(" flags: "); bprintf(stdout, rtm->rtm_flags, routeflags); + printf("\n"); + if (sa_rl != NULL) + printf(" label: %s\n", sa_rl->sr_label); #define lock(f) ((rtm->rtm_rmx.rmx_locks & __CONCAT(RTV_,f)) ? 'L' : ' ') #define msec(u) (((u) + 500) / 1000) /* usec to msec */ - (void) printf("\n%s\n", "\ + (void) printf("%s\n", "\ recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire"); printf("%8d%c ", (int)rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); printf("%8d%c ", (int)rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); @@ -1481,3 +1496,15 @@ sockaddr(char *addr, struct sockaddr *sa) } while (cp < cplim); sa->sa_len = cp - (char *)sa; } + +void +getlabel(char *name) +{ + so_label.rtlabel.sr_len = sizeof(so_label.rtlabel); + so_label.rtlabel.sr_family = AF_UNSPEC; + if (strlcpy(so_label.rtlabel.sr_label, name, + sizeof(so_label.rtlabel.sr_label)) >= + sizeof(so_label.rtlabel.sr_label)) + err(1, "label too long"); + rtm_addrs |= RTA_LABEL; +} |