2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $FreeBSD: src/sbin/routed/trace.c,v 1.5.2.1 2002/11/07 17:19:13 imp Exp $
34 #include "pathnames.h"
36 #include <sys/signal.h>
39 #if !defined(__NetBSD__)
40 static char sccsid
[] __attribute__((unused
)) = "@(#)trace.c 8.1 (Berkeley) 6/5/93";
41 #elif defined(__NetBSD__)
46 #define NRECORDS 50 /* size of circular trace buffer */
48 int tracelevel
, new_tracelevel
;
49 FILE *ftrace
; /* output trace file */
50 static const char *sigtrace_pat
= "%s";
51 static char savetracename
[MAXPATHLEN
+1];
52 char inittracename
[MAXPATHLEN
+1];
53 int file_trace
; /* 1=tracing to file, not stdout */
55 static void trace_dump(void);
56 static void tmsg(const char *, ...) PATTRIB(1,2);
59 /* convert string to printable characters
62 qstring(u_char
*s
, int len
)
64 static char buf
[8*20+1];
69 for (p
= buf
; len
!= 0 && p
< &buf
[sizeof(buf
)-1]; len
--) {
72 for (s2
= s
+1; s2
< &s
[len
]; s2
++) {
80 if (c
>= ' ' && c
< 0x7f && c
!= '\\') {
102 p
+= sprintf(p
,"%o",c
);
112 /* convert IP address to a string, but not into a single buffer
120 char str
[16]; /* xxx.xxx.xxx.xxx\0 */
126 s
= strcpy(bufs
[bufno
].str
, inet_ntoa(addr
));
127 bufno
= (bufno
+1) % NUM_BUFS
;
134 saddr_ntoa(struct sockaddr
*sa
)
136 return (sa
== NULL
) ? "?" : naddr_ntoa(S_ADDR(sa
));
144 secs
+= epoch
.tv_sec
;
145 memcpy(s
, ctime(&secs
)+11, 8);
151 /* On each event, display a time stamp.
152 * This assumes that 'now' is update once for each event, and
153 * that at least now.tv_usec changes.
155 static struct timeval lastlog_time
;
160 if (lastlog_time
.tv_sec
!= now
.tv_sec
161 || lastlog_time
.tv_usec
!= now
.tv_usec
) {
162 fprintf(ftrace
, "-- %s --\n", ts(now
.tv_sec
));
169 tmsg(const char *p
, ...)
173 if (ftrace
!= NULL
) {
176 vfprintf(ftrace
, p
, args
);
184 trace_close(int zap_stdio
)
192 if (ftrace
!= NULL
&& zap_stdio
) {
193 if (ftrace
!= stdout
)
196 fd
= open(_PATH_DEVNULL
, O_RDWR
);
197 if (isatty(STDIN_FILENO
))
198 dup2(fd
, STDIN_FILENO
);
199 if (isatty(STDOUT_FILENO
))
200 dup2(fd
, STDOUT_FILENO
);
201 if (isatty(STDERR_FILENO
))
202 dup2(fd
, STDERR_FILENO
);
205 lastlog_time
.tv_sec
= 0;
212 if (ftrace
!= NULL
) {
215 trace_off("tracing off: %s", strerror(ferror(ftrace
)));
221 trace_off(const char *p
, ...)
226 if (ftrace
!= NULL
) {
229 vfprintf(ftrace
, p
, args
);
232 trace_close(file_trace
);
234 new_tracelevel
= tracelevel
= 0;
238 /* log a change in tracing
241 tracelevel_msg(const char *pat
,
242 int dump
) /* -1=no dump, 0=default, 1=force */
244 static const char *off_msgs
[MAX_TRACELEVEL
] = {
245 "Tracing actions stopped",
246 "Tracing packets stopped",
247 "Tracing packet contents stopped",
248 "Tracing kernel changes stopped",
250 static const char *on_msgs
[MAX_TRACELEVEL
] = {
251 "Tracing actions started",
252 "Tracing packets started",
253 "Tracing packet contents started",
254 "Tracing kernel changes started",
256 u_int old_tracelevel
= tracelevel
;
259 if (new_tracelevel
< 0)
261 else if (new_tracelevel
> MAX_TRACELEVEL
)
262 new_tracelevel
= MAX_TRACELEVEL
;
264 if (new_tracelevel
< tracelevel
) {
265 if (new_tracelevel
<= 0) {
266 trace_off(pat
, off_msgs
[0]);
268 tmsg(pat
, off_msgs
[tracelevel
]);
270 while (--tracelevel
!= new_tracelevel
);
272 } else if (new_tracelevel
> tracelevel
) {
274 tmsg(pat
, on_msgs
[tracelevel
++]);
275 } while (tracelevel
!= new_tracelevel
);
279 || (dump
== 0 && old_tracelevel
== 0 && tracelevel
!= 0))
285 set_tracefile(const char *filename
,
287 int dump
) /* -1=no dump, 0=default, 1=force */
294 /* Allow a null filename to increase the level if the trace file
295 * is already open or if coming from a trusted source, such as
296 * a signal or the command line.
298 if (filename
== NULL
|| filename
[0] == '\0') {
300 if (ftrace
== NULL
) {
301 if (inittracename
[0] == '\0') {
302 msglog("missing trace file name");
310 } else if (!strcmp(filename
,"dump/../table")) {
315 /* Allow the file specified with "-T file" to be reopened,
316 * but require all other names specified over the net to
317 * match the official path. The path can specify a directory
318 * in which the file is to be created.
320 if (strcmp(filename
, inittracename
)
322 && (strncmp(filename
, _PATH_TRACE
, sizeof(_PATH_TRACE
)-1)
323 || strstr(filename
,"../")
324 || 0 > stat(_PATH_TRACE
, &stbuf
))
327 msglog("wrong trace file \"%s\"", filename
);
331 /* If the new tracefile exists, it must be a regular file.
333 if (stat(filename
, &stbuf
) >= 0 && !S_ISREG(stbuf
.st_mode
)) {
334 msglog("wrong type (%#x) of trace file \"%s\"",
335 stbuf
.st_mode
, filename
);
343 n_ftrace
= fopen(fn
, "a");
344 if (n_ftrace
== NULL
) {
345 msglog("failed to open trace file \"%s\" %s",
346 fn
, strerror(errno
));
347 if (fn
== inittracename
)
348 inittracename
[0] = '\0';
352 tmsg("switch to trace file %s", fn
);
354 trace_close(file_trace
= 1);
356 if (fn
!= savetracename
)
357 strncpy(savetracename
, fn
, sizeof(savetracename
)-1);
362 dup2(fileno(ftrace
), STDOUT_FILENO
);
363 dup2(fileno(ftrace
), STDERR_FILENO
);
366 if (new_tracelevel
== 0 || filename
== NULL
)
368 tracelevel_msg(pat
, dump
!= 0 ? dump
: (filename
!= NULL
));
374 sigtrace_on(int s UNUSED
)
377 sigtrace_pat
= "SIGUSR1: %s";
383 sigtrace_off(int s UNUSED
)
386 sigtrace_pat
= "SIGUSR2: %s";
390 /* Set tracing after a signal.
395 if (new_tracelevel
== tracelevel
)
398 /* If tracing entirely off, and there was no tracefile specified
399 * on the command line, then leave it off.
401 if (new_tracelevel
> tracelevel
&& ftrace
== NULL
) {
402 if (savetracename
[0] != '\0') {
403 set_tracefile(savetracename
,sigtrace_pat
,0);
404 } else if (inittracename
[0] != '\0') {
405 set_tracefile(inittracename
,sigtrace_pat
,0);
411 tracelevel_msg(sigtrace_pat
, 0);
416 /* display an address
419 addrname(naddr addr
, /* in network byte order */
421 int force
) /* 0=show mask if nonstandard, */
422 { /* 1=always show mask, 2=never */
432 s
= strcpy(bufs
[bufno
].str
, naddr_ntoa(addr
));
433 bufno
= (bufno
+1) % NUM_BUFS
;
435 if (force
== 1 || (force
== 0 && mask
!= std_mask(addr
))) {
438 dmask
= mask
& -mask
;
439 if (mask
+ dmask
== 0) {
440 for (i
= 0; i
!= 32 && ((1<<i
) & mask
) == 0; i
++)
442 sprintf(sp
, "/%d", 32-i
);
445 sprintf(sp
, " (mask %#x)", (u_int
)mask
);
454 /* display a bit-field
459 const char *bits_name
;
462 static struct bits if_bits
[] = {
463 { IFF_LOOPBACK
, 0, "LOOPBACK" },
464 { IFF_POINTOPOINT
, 0, "PT-TO-PT" },
468 static struct bits is_bits
[] = {
469 { IS_ALIAS
, 0, "ALIAS" },
470 { IS_SUBNET
, 0, "" },
471 { IS_REMOTE
, (IS_NO_RDISC
472 | IS_BCAST_RDISC
), "REMOTE" },
473 { IS_PASSIVE
, (IS_NO_RDISC
477 | IS_NO_AG
), "PASSIVE" },
478 { IS_EXTERNAL
, 0, "EXTERNAL" },
479 { IS_CHECKED
, 0, "" },
480 { IS_ALL_HOSTS
, 0, "" },
481 { IS_ALL_ROUTERS
, 0, "" },
482 { IS_DISTRUST
, 0, "DISTRUST" },
483 { IS_BROKE
, IS_SICK
, "BROKEN" },
484 { IS_SICK
, 0, "SICK" },
485 { IS_DUP
, 0, "DUPLICATE" },
486 { IS_REDIRECT_OK
, 0, "REDIRECT_OK" },
487 { IS_NEED_NET_SYN
, 0, "" },
488 { IS_NO_AG
, IS_NO_SUPER_AG
, "NO_AG" },
489 { IS_NO_SUPER_AG
, 0, "NO_SUPER_AG" },
493 | IS_NO_RIPV2_OUT
), 0, "NO_RIP" },
495 | IS_NO_RIPV1_OUT
), 0, "RIPV2" },
496 { IS_NO_RIPV1_IN
, 0, "NO_RIPV1_IN" },
497 { IS_NO_RIPV2_IN
, 0, "NO_RIPV2_IN" },
498 { IS_NO_RIPV1_OUT
, 0, "NO_RIPV1_OUT" },
499 { IS_NO_RIPV2_OUT
, 0, "NO_RIPV2_OUT" },
502 | IS_NO_ADV_OUT
), IS_BCAST_RDISC
, "NO_RDISC" },
503 { IS_NO_SOL_OUT
, 0, "NO_SOLICIT" },
504 { IS_SOL_OUT
, 0, "SEND_SOLICIT" },
505 { IS_NO_ADV_OUT
, IS_BCAST_RDISC
, "NO_RDISC_ADV" },
506 { IS_ADV_OUT
, 0, "RDISC_ADV" },
507 { IS_BCAST_RDISC
, 0, "BCAST_RDISC" },
508 { IS_PM_RDISC
, 0, "" },
512 static struct bits rs_bits
[] = {
514 { RS_NET_INT
, RS_NET_SYN
, "NET_INT" },
515 { RS_NET_SYN
, 0, "NET_SYN" },
516 { RS_SUBNET
, 0, "" },
517 { RS_LOCAL
, 0, "LOCAL" },
518 { RS_MHOME
, 0, "MHOME" },
519 { RS_STATIC
, 0, "STATIC" },
520 { RS_RDISC
, 0, "RDISC" },
526 trace_bits(const struct bits
*tbl
,
541 && (b
= tbl
->bits_mask
) != 0) {
542 if ((b
& field
) == b
) {
543 if (tbl
->bits_name
[0] != '\0') {
546 fprintf(ftrace
, "%s", tbl
->bits_name
);
549 if (0 == (field
&= ~(b
| tbl
->bits_clear
)))
554 if (field
!= 0 && tbl
->bits_name
!= NULL
) {
557 fprintf(ftrace
, tbl
->bits_name
, field
);
561 if (c
!= '<' || force
)
571 static char buf
[3*4+3+1+2+3 /* "xxx.xxx.xxx.xxx/xx-->" */
572 +3*4+3+1]; /* "xxx.xxx.xxx.xxx" */
575 i
= sprintf(buf
, "%-16s-->", addrname(dst
, mask
, 0));
576 sprintf(&buf
[i
], "%-*s", 15+20-MAX(20,i
), naddr_ntoa(gate
));
582 print_rts(struct rt_spare
*rts
,
583 int force_metric
, /* -1=suppress, 0=default */
584 int force_ifp
, /* -1=suppress, 0=default */
585 int force_router
, /* -1=suppress, 0=default, 1=display */
586 int force_tag
, /* -1=suppress, 0=default, 1=display */
587 int force_time
) /* 0=suppress, 1=display */
592 if (force_metric
>= 0)
593 fprintf(ftrace
, "metric=%-2d ", rts
->rts_metric
);
595 fprintf(ftrace
, "%s ", (rts
->rts_ifp
== 0 ?
596 "if?" : rts
->rts_ifp
->int_name
));
598 || (force_router
== 0 && rts
->rts_router
!= rts
->rts_gate
))
599 fprintf(ftrace
, "router=%s ", naddr_ntoa(rts
->rts_router
));
601 fprintf(ftrace
, "%s ", ts(rts
->rts_time
));
603 || (force_tag
== 0 && rts
->rts_tag
!= 0))
604 fprintf(ftrace
, "tag=%#x ", ntohs(rts
->rts_tag
));
605 if (rts
->rts_de_ag
!= 0) {
606 for (i
= 1; (u_int
)(1 << i
) <= rts
->rts_de_ag
; i
++)
608 fprintf(ftrace
, "de_ag=%d ", i
);
615 trace_if(const char *act
,
616 struct interface
*ifp
)
618 if (!TRACEACTIONS
|| ftrace
== NULL
)
622 fprintf(ftrace
, "%-3s interface %-4s ", act
, ifp
->int_name
);
623 fprintf(ftrace
, "%-15s-->%-15s ",
624 naddr_ntoa(ifp
->int_addr
),
625 addrname(((ifp
->int_if_flags
& IFF_POINTOPOINT
)
626 ? ifp
->int_dstaddr
: htonl(ifp
->int_net
)),
628 if (ifp
->int_metric
!= 0)
629 fprintf(ftrace
, "metric=%d ", ifp
->int_metric
);
630 if (!IS_RIP_OUT_OFF(ifp
->int_state
)
631 && ifp
->int_d_metric
!= 0)
632 fprintf(ftrace
, "fake_default=%d ", ifp
->int_d_metric
);
633 trace_bits(if_bits
, ifp
->int_if_flags
, 0);
634 trace_bits(is_bits
, ifp
->int_state
, 0);
640 trace_upslot(struct rt_entry
*rt
,
641 struct rt_spare
*rts
,
642 struct rt_spare
*new)
644 if (!TRACEACTIONS
|| ftrace
== NULL
)
647 if (rts
->rts_gate
== new->rts_gate
648 && rts
->rts_router
== new->rts_router
649 && rts
->rts_metric
== new->rts_metric
650 && rts
->rts_tag
== new->rts_tag
651 && rts
->rts_de_ag
== new->rts_de_ag
)
655 if (new->rts_gate
== 0) {
656 fprintf(ftrace
, "Del #%d %-35s ",
657 (int)(rts
- rt
->rt_spares
),
658 rtname(rt
->rt_dst
, rt
->rt_mask
, rts
->rts_gate
));
659 print_rts(rts
, 0,0,0,0,
660 (rts
!= rt
->rt_spares
661 || AGE_RT(rt
->rt_state
,new->rts_ifp
)));
663 } else if (rts
->rts_gate
!= RIP_DEFAULT
) {
664 fprintf(ftrace
, "Chg #%d %-35s ",
665 (int)(rts
- rt
->rt_spares
),
666 rtname(rt
->rt_dst
, rt
->rt_mask
, rts
->rts_gate
));
668 rts
->rts_gate
!= new->rts_gate
,
669 rts
->rts_tag
!= new->rts_tag
,
670 rts
!= rt
->rt_spares
|| AGE_RT(rt
->rt_state
,
673 fprintf(ftrace
, "\n %19s%-16s ", "",
674 (new->rts_gate
!= rts
->rts_gate
675 ? naddr_ntoa(new->rts_gate
) : ""));
677 -(new->rts_metric
== rts
->rts_metric
),
678 -(new->rts_ifp
== rts
->rts_ifp
),
680 rts
->rts_tag
!= new->rts_tag
,
681 (new->rts_time
!= rts
->rts_time
682 && (rts
!= rt
->rt_spares
683 || AGE_RT(rt
->rt_state
, new->rts_ifp
))));
686 fprintf(ftrace
, "Add #%d %-35s ",
687 (int)(rts
- rt
->rt_spares
),
688 rtname(rt
->rt_dst
, rt
->rt_mask
, new->rts_gate
));
689 print_rts(new, 0,0,0,0,
690 (rts
!= rt
->rt_spares
691 || AGE_RT(rt
->rt_state
,new->rts_ifp
)));
697 /* miscellaneous message checked by the caller
700 trace_misc(const char *p
, ...)
709 vfprintf(ftrace
, p
, args
);
714 /* display a message if tracing actions
717 trace_act(const char *p
, ...)
721 if (!TRACEACTIONS
|| ftrace
== NULL
)
726 vfprintf(ftrace
, p
, args
);
731 /* display a message if tracing packets
734 trace_pkt(const char *p
, ...)
738 if (!TRACEPACKETS
|| ftrace
== NULL
)
743 vfprintf(ftrace
, p
, args
);
749 trace_change(struct rt_entry
*rt
,
751 struct rt_spare
*new,
757 if (rt
->rt_metric
== new->rts_metric
758 && rt
->rt_gate
== new->rts_gate
759 && rt
->rt_router
== new->rts_router
760 && rt
->rt_state
== state
761 && rt
->rt_tag
== new->rts_tag
762 && rt
->rt_de_ag
== new->rts_de_ag
)
766 fprintf(ftrace
, "%s %-35s ",
767 label
, rtname(rt
->rt_dst
, rt
->rt_mask
, rt
->rt_gate
));
768 print_rts(rt
->rt_spares
,
769 0,0,0,0, AGE_RT(rt
->rt_state
, rt
->rt_ifp
));
770 trace_bits(rs_bits
, rt
->rt_state
, rt
->rt_state
!= state
);
772 fprintf(ftrace
, "\n%*s %19s%-16s ",
773 (int)strlen(label
), "", "",
774 (rt
->rt_gate
!= new->rts_gate
775 ? naddr_ntoa(new->rts_gate
) : ""));
777 -(new->rts_metric
== rt
->rt_metric
),
778 -(new->rts_ifp
== rt
->rt_ifp
),
780 rt
->rt_tag
!= new->rts_tag
,
781 (rt
->rt_time
!= new->rts_time
782 && AGE_RT(rt
->rt_state
,new->rts_ifp
)));
783 if (rt
->rt_state
!= state
)
784 trace_bits(rs_bits
, state
, 1);
790 trace_add_del(const char * action
, struct rt_entry
*rt
)
796 fprintf(ftrace
, "%s %-35s ",
797 action
, rtname(rt
->rt_dst
, rt
->rt_mask
, rt
->rt_gate
));
798 print_rts(rt
->rt_spares
, 0,0,0,0,AGE_RT(rt
->rt_state
,rt
->rt_ifp
));
799 trace_bits(rs_bits
, rt
->rt_state
, 0);
806 walk_trace(struct radix_node
*rn
,
807 struct walkarg
*w UNUSED
)
809 #define RT ((struct rt_entry *)rn)
810 struct rt_spare
*rts
;
813 fprintf(ftrace
, " %-35s ",
814 rtname(RT
->rt_dst
, RT
->rt_mask
, RT
->rt_gate
));
815 print_rts(&RT
->rt_spares
[0], 0,0,0,0, AGE_RT(RT
->rt_state
, RT
->rt_ifp
));
816 trace_bits(rs_bits
, RT
->rt_state
, 0);
817 if (RT
->rt_poison_time
>= now_garbage
818 && RT
->rt_poison_metric
< RT
->rt_metric
)
819 fprintf(ftrace
, "pm=%d@%s",
820 RT
->rt_poison_metric
, ts(RT
->rt_poison_time
));
822 rts
= &RT
->rt_spares
[1];
823 for (i
= 1; i
< NUM_SPARES
; i
++, rts
++) {
824 if (rts
->rts_gate
!= RIP_DEFAULT
) {
825 fprintf(ftrace
,"\n #%d%15s%-16s ",
826 i
, "", naddr_ntoa(rts
->rts_gate
));
827 print_rts(rts
, 0,0,0,0,1);
839 struct interface
*ifp
;
845 fputs("current daemon state:\n", ftrace
);
846 for (ifp
= ifnet
; ifp
!= NULL
; ifp
= ifp
->int_next
)
848 rn_walktree(rhead
, walk_trace
, 0);
853 trace_rip(const char *dir1
, const char *dir2
,
854 struct sockaddr_in
*who
,
855 struct interface
*ifp
,
857 int size
) /* total size of message */
859 struct netinfo
*n
, *lim
;
860 # define NA ((struct netauth*)n)
863 if (!TRACEPACKETS
|| ftrace
== NULL
)
867 if (msg
->rip_cmd
>= RIPCMD_MAX
868 || msg
->rip_vers
== 0) {
869 fprintf(ftrace
, "%s bad RIPv%d cmd=%d %s"
871 dir1
, msg
->rip_vers
, msg
->rip_cmd
, dir2
,
872 naddr_ntoa(who
->sin_addr
.s_addr
),
873 ntohs(who
->sin_port
),
878 fprintf(ftrace
, "%s RIPv%d %s %s %s.%d%s%s\n",
879 dir1
, msg
->rip_vers
, ripcmds
[msg
->rip_cmd
], dir2
,
880 naddr_ntoa(who
->sin_addr
.s_addr
), ntohs(who
->sin_port
),
881 ifp
? " via " : "", ifp
? ifp
->int_name
: "");
886 switch (msg
->rip_cmd
) {
888 case RIPCMD_RESPONSE
:
890 lim
= (struct netinfo
*)((char*)msg
+ size
);
891 for (; n
< lim
; n
++) {
893 && n
->n_family
== RIP_AF_UNSPEC
894 && ntohl(n
->n_metric
) == HOPCNT_INFINITY
895 && msg
->rip_cmd
== RIPCMD_REQUEST
898 && (n
+1)->n_family
== RIP_AF_AUTH
))) {
899 fputs("\tQUERY ", ftrace
);
901 fprintf(ftrace
, "%s ",
902 naddr_ntoa(n
->n_dst
));
904 fprintf(ftrace
, "mask=%#x ",
905 (u_int
)ntohl(n
->n_mask
));
907 fprintf(ftrace
, "nhop=%s ",
908 naddr_ntoa(n
->n_nhop
));
910 fprintf(ftrace
, "tag=%#x ",
916 if (n
->n_family
== RIP_AF_AUTH
) {
917 if (NA
->a_type
== RIP_AUTH_PW
918 && n
== msg
->rip_nets
) {
919 fprintf(ftrace
, "\tPassword"
922 qstring(NA
->au
.au_pw
,
927 if (NA
->a_type
== RIP_AUTH_MD5
928 && n
== msg
->rip_nets
) {
931 " pkt_len=%d KeyID=%u"
935 ntohs(NA
->au
.a_md5
.md5_pkt_len
),
936 NA
->au
.a_md5
.md5_keyid
,
937 NA
->au
.a_md5
.md5_auth_len
,
938 (int)ntohl(NA
->au
.a_md5
.md5_seqno
),
939 (int)ntohs(NA
->au
.a_md5
.rsvd
[0]),
940 (int)ntohs(NA
->au
.a_md5
.rsvd
[1]));
944 "\tAuthentication type %d: ",
947 i
< (int)sizeof(NA
->au
.au_pw
);
949 fprintf(ftrace
, "%02x ",
956 if (n
->n_family
!= RIP_AF_INET
) {
958 "\t(af %d) %-18s mask=%#x ",
960 naddr_ntoa(n
->n_dst
),
961 (u_int
)ntohl(n
->n_mask
));
962 } else if (msg
->rip_vers
== RIPv1
) {
963 fprintf(ftrace
, "\t%-18s ",
964 addrname(n
->n_dst
, ntohl(n
->n_mask
),
965 n
->n_mask
==0 ? 2 : 1));
967 fprintf(ftrace
, "\t%-18s ",
968 addrname(n
->n_dst
, ntohl(n
->n_mask
),
969 n
->n_mask
==0 ? 2 : 0));
971 fprintf(ftrace
, "metric=%-2d ",
972 (u_int
)ntohl(n
->n_metric
));
974 fprintf(ftrace
, " nhop=%s ",
975 naddr_ntoa(n
->n_nhop
));
977 fprintf(ftrace
, "tag=%#x", ntohs(n
->n_tag
));
980 if (size
!= (char *)n
- (char *)msg
)
981 fprintf(ftrace
, "truncated record, len %d\n", size
);
985 fprintf(ftrace
, "\tfile=\"%.*s\"\n", size
-4,
989 case RIPCMD_TRACEOFF
: