summaryrefslogtreecommitdiff
path: root/usr.sbin/rtadvd/dump.c
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-05-29 14:34:06 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2002-05-29 14:34:06 +0000
commit4e73dbad4c3660ec16039bce183644753e91c0b3 (patch)
tree8119f44d0414448dd88f4c0b19a2778546ceb7fd /usr.sbin/rtadvd/dump.c
parent861f79da55d01dd792fed4274d6c50c14ea21fb9 (diff)
KNF, strlcpy, cleanups from kame
Diffstat (limited to 'usr.sbin/rtadvd/dump.c')
-rw-r--r--usr.sbin/rtadvd/dump.c86
1 files changed, 36 insertions, 50 deletions
diff --git a/usr.sbin/rtadvd/dump.c b/usr.sbin/rtadvd/dump.c
index 7735afed4ce..49c7565ff81 100644
--- a/usr.sbin/rtadvd/dump.c
+++ b/usr.sbin/rtadvd/dump.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: dump.c,v 1.4 2002/02/16 21:28:08 millert Exp $ */
-/* $KAME: dump.c,v 1.15 2000/11/11 06:57:22 jinmei Exp $ */
+/* $OpenBSD: dump.c,v 1.5 2002/05/29 14:34:05 itojun Exp $ */
+/* $KAME: dump.c,v 1.27 2002/05/29 14:23:55 itojun Exp $ */
/*
* Copyright (C) 2000 WIDE Project.
@@ -34,9 +34,6 @@
#include <sys/queue.h>
#include <net/if.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
-#include <net/if_var.h>
-#endif /* __FreeBSD__ >= 3 */
#include <net/if_dl.h>
#include <netinet/in.h>
@@ -53,6 +50,7 @@
#include <syslog.h>
#include <string.h>
#include <errno.h>
+#include <netdb.h>
#include "rtadvd.h"
#include "timer.h"
@@ -66,29 +64,28 @@ extern struct rainfo *ralist;
static char *ether_str(struct sockaddr_dl *);
static void if_dump(void);
-#ifdef __FreeBSD__ /* XXX: see PORTABILITY */
-#define LONGLONG "%qu"
-#else
-#define LONGLONG "%llu"
-#endif
+static char *rtpref_str[] = {
+ "medium", /* 00 */
+ "high", /* 01 */
+ "rsv", /* 10 */
+ "low" /* 11 */
+};
static char *
ether_str(sdl)
struct sockaddr_dl *sdl;
{
- static char ebuf[32];
+ static char hbuf[NI_MAXHOST];
u_char *cp;
- if (sdl->sdl_alen && sdl->sdl_alen > 5) {
+ if (sdl->sdl_alen) {
cp = (u_char *)LLADDR(sdl);
- sprintf(ebuf, "%x:%x:%x:%x:%x:%x",
+ snprintf(hbuf, sizeof(hbuf), "%x:%x:%x:%x:%x:%x",
cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
- }
- else {
- sprintf(ebuf, "NONE");
- }
+ } else
+ snprintf(hbuf, sizeof(hbuf), "NONE");
- return(ebuf);
+ return(hbuf);
}
static void
@@ -124,43 +121,36 @@ if_dump()
rai->waiting, rai->initcounter);
/* statistics */
- fprintf(fp,
- " statistics: RA(out/in/inconsistent): "
- LONGLONG "/" LONGLONG "/" LONGLONG ", ",
- (unsigned long long)rai->raoutput,
- (unsigned long long)rai->rainput,
- (unsigned long long)rai->rainconsistent);
- fprintf(fp, "RS(input): " LONGLONG "\n",
- (unsigned long long)rai->rsinput);
+ fprintf(fp, " statistics: RA(out/in/inconsistent): "
+ "%llu/%llu/%llu, ",
+ (unsigned long long)rai->raoutput,
+ (unsigned long long)rai->rainput,
+ (unsigned long long)rai->rainconsistent);
+ fprintf(fp, "RS(input): %llu\n",
+ (unsigned long long)rai->rsinput);
/* interface information */
if (rai->advlinkopt)
fprintf(fp, " Link-layer address: %s\n",
- ether_str(rai->sdl));
+ ether_str(rai->sdl));
fprintf(fp, " MTU: %d\n", rai->phymtu);
/* Router configuration variables */
- fprintf(fp,
- " DefaultLifetime: %d, MaxAdvInterval: %d, "
- "MinAdvInterval: %d\n",
- rai->lifetime, rai->maxinterval, rai->mininterval);
- fprintf(fp, " Flags: %s%s%s MTU: %d\n",
- rai->managedflg ? "M" : "", rai->otherflg ? "O" : "",
-#ifdef MIP6
- rai->haflg ? "H" :
-#endif
- "", rai->linkmtu);
+ fprintf(fp, " DefaultLifetime: %d, MaxAdvInterval: %d, "
+ "MinAdvInterval: %d\n", rai->lifetime, rai->maxinterval,
+ rai->mininterval);
+ fprintf(fp, " Flags: %s%s%s, ",
+ rai->managedflg ? "M" : "", rai->otherflg ? "O" : "",
+ "");
+ fprintf(fp, "Preference: %s, ",
+ rtpref_str[(rai->rtpref >> 3) & 0xff]);
+ fprintf(fp, "MTU: %d\n", rai->linkmtu);
fprintf(fp, " ReachableTime: %d, RetransTimer: %d, "
"CurHopLimit: %d\n", rai->reachabletime,
rai->retranstimer, rai->hoplimit);
-#ifdef MIP6
- fprintf(fp, " HAPreference: %d, HALifetime: %d\n",
- rai->hapref, rai->hatime);
-#endif
-
if (rai->clockskew)
fprintf(fp, " Clock skew: %ldsec\n",
- rai->clockskew);
+ rai->clockskew);
for (first = 1, pfx = rai->prefix.next; pfx != &rai->prefix;
pfx = pfx->next) {
if (first) {
@@ -168,10 +158,9 @@ if_dump()
first = 0;
}
fprintf(fp, " %s/%d(",
- inet_ntop(AF_INET6, &pfx->prefix,
- prefixbuf, sizeof(prefixbuf)),
- pfx->prefixlen);
- switch(pfx->origin) {
+ inet_ntop(AF_INET6, &pfx->prefix, prefixbuf,
+ sizeof(prefixbuf)), pfx->prefixlen);
+ switch (pfx->origin) {
case PREFIX_FROM_KERNEL:
fprintf(fp, "KERNEL, ");
break;
@@ -207,9 +196,6 @@ if_dump()
fprintf(fp, "flags: %s%s%s",
pfx->onlinkflg ? "L" : "",
pfx->autoconfflg ? "A" : "",
-#ifdef MIP6
- pfx->routeraddr ? "R" :
-#endif
"");
fprintf(fp, ")\n");
}