diff options
author | wollman <wollman@FreeBSD.org> | 1996-08-27 16:22:05 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1996-08-27 16:22:05 +0000 |
commit | d8acfc1242287034b488b68b2e7cbc9eb77eca20 (patch) | |
tree | b7d8d0f637b06c8682c5e4f6c7d874a8d0684fdd /usr.sbin/routed/trace.c | |
parent | 5af28cc1576c5d5f5d3fbe2ac63044a9727dc7eb (diff) | |
download | FreeBSD-src-d8acfc1242287034b488b68b2e7cbc9eb77eca20.zip FreeBSD-src-d8acfc1242287034b488b68b2e7cbc9eb77eca20.tar.gz |
Merge new routed from vendor branch.
Diffstat (limited to 'usr.sbin/routed/trace.c')
-rw-r--r-- | usr.sbin/routed/trace.c | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/usr.sbin/routed/trace.c b/usr.sbin/routed/trace.c index 8c66a9f..f38b393 100644 --- a/usr.sbin/routed/trace.c +++ b/usr.sbin/routed/trace.c @@ -31,9 +31,12 @@ * SUCH DAMAGE. */ -#if !defined(lint) && !defined(sgi) +#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__) static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93"; -#endif /* not lint */ +#elif defined(__NetBSD__) +static char rcsid[] = "$NetBSD$"; +#endif +#ident "$Revision: 1.1.3.3 $" #define RIPCMDS #include "defs.h" @@ -63,17 +66,18 @@ char * naddr_ntoa(naddr a) { #define NUM_BUFS 4 - static int i; + static int bufno; static struct { char str[16]; /* xxx.xxx.xxx.xxx\0 */ } bufs[NUM_BUFS]; - struct in_addr addr; char *s; + struct in_addr addr; addr.s_addr = a; - s = strcpy(bufs[i].str, inet_ntoa(addr)); - i = (i+1) % NUM_BUFS; + s = strcpy(bufs[bufno].str, inet_ntoa(addr)); + bufno = (bufno+1) % NUM_BUFS; return s; +#undef NUM_BUFS } @@ -318,12 +322,17 @@ addrname(naddr addr, /* in network byte order */ naddr mask, int force) /* 0=show mask if nonstandard, */ { /* 1=always show mask, 2=never */ - static char s[15+20]; - char *sp; +#define NUM_BUFS 4 + static int bufno; + static struct { + char str[15+20]; + } bufs[NUM_BUFS]; + char *s, *sp; naddr dmask; int i; - (void)strcpy(s, naddr_ntoa(addr)); + s = strcpy(bufs[bufno].str, naddr_ntoa(addr)); + bufno = (bufno+1) % NUM_BUFS; if (force == 1 || (force == 0 && mask != std_mask(addr))) { sp = &s[strlen(s)]; @@ -335,11 +344,12 @@ addrname(naddr addr, /* in network byte order */ (void)sprintf(sp, "/%d", 32-i); } else { - (void)sprintf(sp, " (mask %#x)", mask); + (void)sprintf(sp, " (mask %#x)", (u_int)mask); } } return s; +#undef NUM_BUFS } @@ -448,7 +458,7 @@ trace_bits(struct bits *tbl, c = '|'; } - if (c || force) + if (c != '<' || force) (void)fputs("> ", ftrace); } @@ -477,12 +487,14 @@ trace_if(char *act, lastlog(); (void)fprintf(ftrace, "%s interface %-4s ", act, ifp->int_name); - (void)fprintf(ftrace, "%-15s --> %s ", + (void)fprintf(ftrace, "%-15s-->%-15s ", naddr_ntoa(ifp->int_addr), - ((ifp->int_if_flags & IFF_POINTOPOINT) - ? naddr_ntoa(ifp->int_dstaddr) - : addrname(htonl(ifp->int_net), ifp->int_mask, 0))); - (void)fprintf(ftrace, "metric=%d ", ifp->int_metric); + addrname(htonl((ifp->int_if_flags & IFF_POINTOPOINT) + ? ifp->int_dstaddr + : ifp->int_net), + ifp->int_mask, 1)); + if (ifp->int_metric != 0) + (void)fprintf(ftrace, "metric=%d ", ifp->int_metric); trace_bits(if_bits, ifp->int_if_flags, 0); trace_bits(is_bits, ifp->int_state, 0); (void)fputc('\n',ftrace); @@ -517,7 +529,7 @@ trace_upslot(struct rt_entry *rt, (void)fprintf(ftrace, "router=%s ", naddr_ntoa(rts->rts_gate)); if (rts->rts_tag != 0) - (void)fprintf(ftrace, "tag=%#x ", rts->rts_tag); + (void)fprintf(ftrace, "tag=%#x ", ntohs(rts->rts_tag)); (void)fprintf(ftrace, "metric=%-2d ", rts->rts_metric); if (rts->rts_ifp != 0) (void)fprintf(ftrace, "%s ", @@ -530,7 +542,7 @@ trace_upslot(struct rt_entry *rt, if (gate != router) (void)fprintf(ftrace,"router=%s ",naddr_ntoa(router)); if (tag != rts->rts_tag) - (void)fprintf(ftrace, "tag=%#x ", tag); + (void)fprintf(ftrace, "tag=%#x ", ntohs(tag)); if (metric != rts->rts_metric) (void)fprintf(ftrace, "metric=%-2d ", metric); if (ifp != rts->rts_ifp && ifp != 0 ) @@ -546,7 +558,7 @@ trace_upslot(struct rt_entry *rt, if (gate != router) (void)fprintf(ftrace, "router=%s ", naddr_ntoa(gate)); if (tag != 0) - (void)fprintf(ftrace, "tag=%#x ", tag); + (void)fprintf(ftrace, "tag=%#x ", ntohs(tag)); (void)fprintf(ftrace, "metric=%-2d ", metric); if (ifp != 0) (void)fprintf(ftrace, "%s ", ifp->int_name); @@ -618,7 +630,7 @@ trace_change(struct rt_entry *rt, (void)fprintf(ftrace, "router=%s ", naddr_ntoa(rt->rt_router)); if (rt->rt_tag != 0) - (void)fprintf(ftrace, "tag=%#x ", rt->rt_tag); + (void)fprintf(ftrace, "tag=%#x ", ntohs(rt->rt_tag)); trace_bits(rs_bits, rt->rt_state, rt->rt_state != state); (void)fprintf(ftrace, "%s ", rt->rt_ifp == 0 ? "?" : rt->rt_ifp->int_name); @@ -633,7 +645,7 @@ trace_change(struct rt_entry *rt, if (router != gate) (void)fprintf(ftrace, "router=%s ", naddr_ntoa(router)); if (rt->rt_tag != tag) - (void)fprintf(ftrace, "tag=%#x ", tag); + (void)fprintf(ftrace, "tag=%#x ", ntohs(tag)); if (rt->rt_state != state) trace_bits(rs_bits, state, 1); if (rt->rt_ifp != ifp) @@ -663,10 +675,10 @@ trace_add_del(char * action, struct rt_entry *rt) (void)fprintf(ftrace, "router=%s ", naddr_ntoa(rt->rt_router)); if (rt->rt_tag != 0) - (void)fprintf(ftrace, "tag=%#x ", rt->rt_tag); + (void)fprintf(ftrace, "tag=%#x ", ntohs(rt->rt_tag)); trace_bits(rs_bits, state, 0); - if (rt->rt_ifp != 0) - (void)fprintf(ftrace, "%s ", rt->rt_ifp->int_name); + (void)fprintf(ftrace, "%s ", + rt->rt_ifp != 0 ? rt->rt_ifp->int_name : "?"); (void)fprintf(ftrace, "%s\n", ts(rt->rt_time)); } @@ -688,12 +700,12 @@ trace_rip(char *dir1, char *dir2, lastlog(); if (msg->rip_cmd >= RIPCMD_MAX || msg->rip_vers == 0) { - (void)fprintf(ftrace, "%s bad RIPv%d cmd=%d %s %s.%d%s%s" - " size=%d msg=%#x\n", + (void)fprintf(ftrace, "%s bad RIPv%d cmd=%d %s" + " %s.%d size=%d\n", dir1, msg->rip_vers, msg->rip_cmd, dir2, naddr_ntoa(who->sin_addr.s_addr), ntohs(who->sin_port), - size, msg); + size); return; } @@ -721,13 +733,13 @@ trace_rip(char *dir1, char *dir2, naddr_ntoa(n->n_dst)); if (n->n_mask != 0) (void)fprintf(ftrace, "mask=%#x ", - ntohl(n->n_mask)); + (u_int)ntohl(n->n_mask)); if (n->n_nhop != 0) (void)fprintf(ftrace, " nhop=%s ", naddr_ntoa(n->n_nhop)); if (n->n_tag != 0) (void)fprintf(ftrace, "tag=%#x", - n->n_tag); + ntohs(n->n_tag)); (void)fputc('\n',ftrace); continue; } @@ -751,7 +763,7 @@ trace_rip(char *dir1, char *dir2, "\t(af %d) %-18s mask=%#x", ntohs(n->n_family), naddr_ntoa(n->n_dst), - ntohl(n->n_mask)); + (u_int)ntohl(n->n_mask)); } else if (msg->rip_vers == RIPv1) { (void)fprintf(ftrace, "\t%-18s ", addrname(n->n_dst, @@ -764,13 +776,13 @@ trace_rip(char *dir1, char *dir2, n->n_mask==0 ? 2 : 0)); } (void)fprintf(ftrace, "metric=%-2d ", - ntohl(n->n_metric)); + (u_int)ntohl(n->n_metric)); if (n->n_nhop != 0) (void)fprintf(ftrace, " nhop=%s ", naddr_ntoa(n->n_nhop)); if (n->n_tag != 0) (void)fprintf(ftrace, "tag=%#x", - n->n_tag); + ntohs(n->n_tag)); (void)fputc('\n',ftrace); } if (size != (char *)n - (char *)msg) |