Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/route Use the definitions from the standard header file...
details: https://anonhg.NetBSD.org/src/rev/c007f2dc591c
branches: trunk
changeset: 358133:c007f2dc591c
user: christos <christos%NetBSD.org@localhost>
date: Wed Dec 13 17:42:44 2017 +0000
description:
Use the definitions from the standard header files and replace homebrew
snprintb with the libutil one.
diffstat:
sbin/route/Makefile | 5 ++++-
sbin/route/route.c | 43 ++++++++++---------------------------------
2 files changed, 14 insertions(+), 34 deletions(-)
diffs (98 lines):
diff -r 4b34f1c33da7 -r c007f2dc591c sbin/route/Makefile
--- a/sbin/route/Makefile Wed Dec 13 16:50:46 2017 +0000
+++ b/sbin/route/Makefile Wed Dec 13 17:42:44 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.30 2017/10/10 19:30:06 christos Exp $
+# $NetBSD: Makefile,v 1.31 2017/12/13 17:42:44 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/5/93
.include <bsd.own.mk>
@@ -17,6 +17,9 @@
CPPFLAGS+=-DINET6
.endif
+LDADD+=-lutil
+DPADD+=${LIBUTIL}
+
# The Makefile over in ../../distrib/utils/x_route
# would like keywords.[ch] to always exist here, so
# they are now checked in as sources.
diff -r 4b34f1c33da7 -r c007f2dc591c sbin/route/route.c
--- a/sbin/route/route.c Wed Dec 13 16:50:46 2017 +0000
+++ b/sbin/route/route.c Wed Dec 13 17:42:44 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.c,v 1.157 2017/12/13 11:31:42 uwe Exp $ */
+/* $NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $ */
/*
* Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)route.c 8.6 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: route.c,v 1.157 2017/12/13 11:31:42 uwe Exp $");
+__RCSID("$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $");
#endif
#endif /* not lint */
@@ -68,6 +68,7 @@
#include <time.h>
#include <paths.h>
#include <err.h>
+#include <util.h>
#include "keywords.h"
#include "extern.h"
@@ -1291,14 +1292,10 @@
[RTM_CHGADDR] = "RTM_CHGADDR: address being changed on iface",
};
-const char metricnames[] =
-"\011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount\1mtu";
-const char routeflags[] =
-"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT\011CONNECTED\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016CLONED\017PROTO2\020PROTO1\023LOCAL\024BROADCAST";
-const char ifnetflags[] =
-"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST";
-const char addrnames[] =
-"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\011TAG";
+const char metricnames[] = RTVBITS;
+const char routeflags[] = RTFBITS;
+const char ifnetflags[] = IFFBITS;
+const char addrnames[] = RTABITS;
#ifndef SMALL
@@ -1659,30 +1656,10 @@
static void
bprintf(FILE *fp, int b, const char *f)
{
- int i;
- int gotsome = 0;
- const uint8_t *s = (const uint8_t *)f;
+ char buf[1024];
- if (b == 0) {
- fputs("none", fp);
- return;
- }
- while ((i = *s++) != 0) {
- if (b & (1 << (i-1))) {
- if (gotsome == 0)
- i = '<';
- else
- i = ',';
- (void)putc(i, fp);
- gotsome = 1;
- for (; (i = *s) > 32; s++)
- (void)putc(i, fp);
- } else
- while (*s > 32)
- s++;
- }
- if (gotsome)
- (void)putc('>', fp);
+ snprintb(buf, sizeof(buf), f, b);
+ fputs(buf, fp);
}
int
Home |
Main Index |
Thread Index |
Old Index