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(sgi) && !defined(__NetBSD__)
40 static char sccsid
[] __attribute__((unused
)) = "@(#)trace.c 8.1 (Berkeley) 6/5/93";
41 #elif defined(__NetBSD__)
47 /* use *stat64 for files on large filesystems */
51 #define NRECORDS 50 /* size of circular trace buffer */
53 int tracelevel
, new_tracelevel
;
54 FILE *ftrace
; /* output trace file */
55 static const char *sigtrace_pat
= "%s";
56 static char savetracename
[MAXPATHLEN
+1];
57 char inittracename
[MAXPATHLEN
+1];
58 int file_trace
; /* 1=tracing to file, not stdout */
60 static void trace_dump(void);
61 static void tmsg(const char *, ...) PATTRIB(1,2);
64 /* convert string to printable characters
67 qstring(u_char
*s
, int len
)
69 static char buf
[8*20+1];
74 for (p
= buf
; len
!= 0 && p
< &buf
[sizeof(buf
)-1]; len
--) {
77 for (s2
= s
+1; s2
< &s
[len
]; s2
++) {
85 if (c
>= ' ' && c
< 0x7f && c
!= '\\') {
107 p
+= sprintf(p
,"%o",c
);
117 /* convert IP address to a string, but not into a single buffer
125 char str
[16]; /* xxx.xxx.xxx.xxx\0 */
131 s
= strcpy(bufs
[bufno
].str
, inet_ntoa(addr
));
132 bufno
= (bufno
+1) % NUM_BUFS
;
139 saddr_ntoa(struct sockaddr
*sa
)
141 return (sa
== NULL
) ? "?" : naddr_ntoa(S_ADDR(sa
));
149 secs
+= epoch
.tv_sec
;
151 cftime(s
, "%T", &secs
);
153 memcpy(s
, ctime(&secs
)+11, 8);
160 /* On each event, display a time stamp.
161 * This assumes that 'now' is update once for each event, and
162 * that at least now.tv_usec changes.
164 static struct timeval lastlog_time
;
169 if (lastlog_time
.tv_sec
!= now
.tv_sec
170 || lastlog_time
.tv_usec
!= now
.tv_usec
) {
171 fprintf(ftrace
, "-- %s --\n", ts(now
.tv_sec
));
178 tmsg(const char *p
, ...)
182 if (ftrace
!= NULL
) {
185 vfprintf(ftrace
, p
, args
);
193 trace_close(int zap_stdio
)
201 if (ftrace
!= NULL
&& zap_stdio
) {
202 if (ftrace
!= stdout
)
205 fd
= open(_PATH_DEVNULL
, O_RDWR
);
206 if (isatty(STDIN_FILENO
))
207 dup2(fd
, STDIN_FILENO
);
208 if (isatty(STDOUT_FILENO
))
209 dup2(fd
, STDOUT_FILENO
);
210 if (isatty(STDERR_FILENO
))
211 dup2(fd
, STDERR_FILENO
);
214 lastlog_time
.tv_sec
= 0;
221 if (ftrace
!= NULL
) {
224 trace_off("tracing off: %s", strerror(ferror(ftrace
)));
230 trace_off(const char *p
, ...)
235 if (ftrace
!= NULL
) {
238 vfprintf(ftrace
, p
, args
);
241 trace_close(file_trace
);
243 new_tracelevel
= tracelevel
= 0;
247 /* log a change in tracing
250 tracelevel_msg(const char *pat
,
251 int dump
) /* -1=no dump, 0=default, 1=force */
253 static const char *off_msgs
[MAX_TRACELEVEL
] = {
254 "Tracing actions stopped",
255 "Tracing packets stopped",
256 "Tracing packet contents stopped",
257 "Tracing kernel changes stopped",
259 static const char *on_msgs
[MAX_TRACELEVEL
] = {
260 "Tracing actions started",
261 "Tracing packets started",
262 "Tracing packet contents started",
263 "Tracing kernel changes started",
265 u_int old_tracelevel
= tracelevel
;
268 if (new_tracelevel
< 0)
270 else if (new_tracelevel
> MAX_TRACELEVEL
)
271 new_tracelevel
= MAX_TRACELEVEL
;
273 if (new_tracelevel
< tracelevel
) {
274 if (new_tracelevel
<= 0) {
275 trace_off(pat
, off_msgs
[0]);
277 tmsg(pat
, off_msgs
[tracelevel
]);
279 while (--tracelevel
!= new_tracelevel
);
281 } else if (new_tracelevel
> tracelevel
) {
283 tmsg(pat
, on_msgs
[tracelevel
++]);
284 } while (tracelevel
!= new_tracelevel
);
288 || (dump
== 0 && old_tracelevel
== 0 && tracelevel
!= 0))
294 set_tracefile(const char *filename
,
296 int dump
) /* -1=no dump, 0=default, 1=force */
303 /* Allow a null filename to increase the level if the trace file
304 * is already open or if coming from a trusted source, such as
305 * a signal or the command line.
307 if (filename
== NULL
|| filename
[0] == '\0') {
309 if (ftrace
== NULL
) {
310 if (inittracename
[0] == '\0') {
311 msglog("missing trace file name");
319 } else if (!strcmp(filename
,"dump/../table")) {
324 /* Allow the file specified with "-T file" to be reopened,
325 * but require all other names specified over the net to
326 * match the official path. The path can specify a directory
327 * in which the file is to be created.
329 if (strcmp(filename
, inittracename
)
331 && (strncmp(filename
, _PATH_TRACE
, sizeof(_PATH_TRACE
)-1)
332 || strstr(filename
,"../")
333 || 0 > stat(_PATH_TRACE
, &stbuf
))
336 msglog("wrong trace file \"%s\"", filename
);
340 /* If the new tracefile exists, it must be a regular file.
342 if (stat(filename
, &stbuf
) >= 0 && !S_ISREG(stbuf
.st_mode
)) {
343 msglog("wrong type (%#x) of trace file \"%s\"",
344 stbuf
.st_mode
, filename
);
352 n_ftrace
= fopen(fn
, "a");
353 if (n_ftrace
== NULL
) {
354 msglog("failed to open trace file \"%s\" %s",
355 fn
, strerror(errno
));
356 if (fn
== inittracename
)
357 inittracename
[0] = '\0';
361 tmsg("switch to trace file %s", fn
);
363 trace_close(file_trace
= 1);
365 if (fn
!= savetracename
)
366 strncpy(savetracename
, fn
, sizeof(savetracename
)-1);
371 dup2(fileno(ftrace
), STDOUT_FILENO
);
372 dup2(fileno(ftrace
), STDERR_FILENO
);
375 if (new_tracelevel
== 0 || filename
== NULL
)
377 tracelevel_msg(pat
, dump
!= 0 ? dump
: (filename
!= NULL
));
383 sigtrace_on(int s UNUSED
)
386 sigtrace_pat
= "SIGUSR1: %s";
392 sigtrace_off(int s UNUSED
)
395 sigtrace_pat
= "SIGUSR2: %s";
399 /* Set tracing after a signal.
404 if (new_tracelevel
== tracelevel
)
407 /* If tracing entirely off, and there was no tracefile specified
408 * on the command line, then leave it off.
410 if (new_tracelevel
> tracelevel
&& ftrace
== NULL
) {
411 if (savetracename
[0] != '\0') {
412 set_tracefile(savetracename
,sigtrace_pat
,0);
413 } else if (inittracename
[0] != '\0') {
414 set_tracefile(inittracename
,sigtrace_pat
,0);
420 tracelevel_msg(sigtrace_pat
, 0);
425 /* display an address
428 addrname(naddr addr
, /* in network byte order */
430 int force
) /* 0=show mask if nonstandard, */
431 { /* 1=always show mask, 2=never */
441 s
= strcpy(bufs
[bufno
].str
, naddr_ntoa(addr
));
442 bufno
= (bufno
+1) % NUM_BUFS
;
444 if (force
== 1 || (force
== 0 && mask
!= std_mask(addr
))) {
447 dmask
= mask
& -mask
;
448 if (mask
+ dmask
== 0) {
449 for (i
= 0; i
!= 32 && ((1<<i
) & mask
) == 0; i
++)
451 sprintf(sp
, "/%d", 32-i
);
454 sprintf(sp
, " (mask %#x)", (u_int
)mask
);
463 /* display a bit-field
468 const char *bits_name
;
471 static struct bits if_bits
[] = {
472 { IFF_LOOPBACK
, 0, "LOOPBACK" },
473 { IFF_POINTOPOINT
, 0, "PT-TO-PT" },
477 static struct bits is_bits
[] = {
478 { IS_ALIAS
, 0, "ALIAS" },
479 { IS_SUBNET
, 0, "" },
480 { IS_REMOTE
, (IS_NO_RDISC
481 | IS_BCAST_RDISC
), "REMOTE" },
482 { IS_PASSIVE
, (IS_NO_RDISC
486 | IS_NO_AG
), "PASSIVE" },
487 { IS_EXTERNAL
, 0, "EXTERNAL" },
488 { IS_CHECKED
, 0, "" },
489 { IS_ALL_HOSTS
, 0, "" },
490 { IS_ALL_ROUTERS
, 0, "" },
491 { IS_DISTRUST
, 0, "DISTRUST" },
492 { IS_BROKE
, IS_SICK
, "BROKEN" },
493 { IS_SICK
, 0, "SICK" },
494 { IS_DUP
, 0, "DUPLICATE" },
495 { IS_REDIRECT_OK
, 0, "REDIRECT_OK" },
496 { IS_NEED_NET_SYN
, 0, "" },
497 { IS_NO_AG
, IS_NO_SUPER_AG
, "NO_AG" },
498 { IS_NO_SUPER_AG
, 0, "NO_SUPER_AG" },
502 | IS_NO_RIPV2_OUT
), 0, "NO_RIP" },
504 | IS_NO_RIPV1_OUT
), 0, "RIPV2" },
505 { IS_NO_RIPV1_IN
, 0, "NO_RIPV1_IN" },
506 { IS_NO_RIPV2_IN
, 0, "NO_RIPV2_IN" },
507 { IS_NO_RIPV1_OUT
, 0, "NO_RIPV1_OUT" },
508 { IS_NO_RIPV2_OUT
, 0, "NO_RIPV2_OUT" },
511 | IS_NO_ADV_OUT
), IS_BCAST_RDISC
, "NO_RDISC" },
512 { IS_NO_SOL_OUT
, 0, "NO_SOLICIT" },
513 { IS_SOL_OUT
, 0, "SEND_SOLICIT" },
514 { IS_NO_ADV_OUT
, IS_BCAST_RDISC
, "NO_RDISC_ADV" },
515 { IS_ADV_OUT
, 0, "RDISC_ADV" },
516 { IS_BCAST_RDISC
, 0, "BCAST_RDISC" },
517 { IS_PM_RDISC
, 0, "" },
521 static struct bits rs_bits
[] = {
523 { RS_NET_INT
, RS_NET_SYN
, "NET_INT" },
524 { RS_NET_SYN
, 0, "NET_SYN" },
525 { RS_SUBNET
, 0, "" },
526 { RS_LOCAL
, 0, "LOCAL" },
527 { RS_MHOME
, 0, "MHOME" },
528 { RS_STATIC
, 0, "STATIC" },
529 { RS_RDISC
, 0, "RDISC" },
535 trace_bits(const struct bits
*tbl
,
550 && (b
= tbl
->bits_mask
) != 0) {
551 if ((b
& field
) == b
) {
552 if (tbl
->bits_name
[0] != '\0') {
555 fprintf(ftrace
, "%s", tbl
->bits_name
);
558 if (0 == (field
&= ~(b
| tbl
->bits_clear
)))
563 if (field
!= 0 && tbl
->bits_name
!= NULL
) {
566 fprintf(ftrace
, tbl
->bits_name
, field
);
570 if (c
!= '<' || force
)
580 static char buf
[3*4+3+1+2+3 /* "xxx.xxx.xxx.xxx/xx-->" */
581 +3*4+3+1]; /* "xxx.xxx.xxx.xxx" */
584 i
= sprintf(buf
, "%-16s-->", addrname(dst
, mask
, 0));
585 sprintf(&buf
[i
], "%-*s", 15+20-MAX(20,i
), naddr_ntoa(gate
));
591 print_rts(struct rt_spare
*rts
,
592 int force_metric
, /* -1=suppress, 0=default */
593 int force_ifp
, /* -1=suppress, 0=default */
594 int force_router
, /* -1=suppress, 0=default, 1=display */
595 int force_tag
, /* -1=suppress, 0=default, 1=display */
596 int force_time
) /* 0=suppress, 1=display */
601 if (force_metric
>= 0)
602 fprintf(ftrace
, "metric=%-2d ", rts
->rts_metric
);
604 fprintf(ftrace
, "%s ", (rts
->rts_ifp
== 0 ?
605 "if?" : rts
->rts_ifp
->int_name
));
607 || (force_router
== 0 && rts
->rts_router
!= rts
->rts_gate
))
608 fprintf(ftrace
, "router=%s ", naddr_ntoa(rts
->rts_router
));
610 fprintf(ftrace
, "%s ", ts(rts
->rts_time
));
612 || (force_tag
== 0 && rts
->rts_tag
!= 0))
613 fprintf(ftrace
, "tag=%#x ", ntohs(rts
->rts_tag
));
614 if (rts
->rts_de_ag
!= 0) {
615 for (i
= 1; (u_int
)(1 << i
) <= rts
->rts_de_ag
; i
++)
617 fprintf(ftrace
, "de_ag=%d ", i
);
624 trace_if(const char *act
,
625 struct interface
*ifp
)
627 if (!TRACEACTIONS
|| ftrace
== NULL
)
631 fprintf(ftrace
, "%-3s interface %-4s ", act
, ifp
->int_name
);
632 fprintf(ftrace
, "%-15s-->%-15s ",
633 naddr_ntoa(ifp
->int_addr
),
634 addrname(((ifp
->int_if_flags
& IFF_POINTOPOINT
)
635 ? ifp
->int_dstaddr
: htonl(ifp
->int_net
)),
637 if (ifp
->int_metric
!= 0)
638 fprintf(ftrace
, "metric=%d ", ifp
->int_metric
);
639 if (!IS_RIP_OUT_OFF(ifp
->int_state
)
640 && ifp
->int_d_metric
!= 0)
641 fprintf(ftrace
, "fake_default=%d ", ifp
->int_d_metric
);
642 trace_bits(if_bits
, ifp
->int_if_flags
, 0);
643 trace_bits(is_bits
, ifp
->int_state
, 0);
649 trace_upslot(struct rt_entry
*rt
,
650 struct rt_spare
*rts
,
651 struct rt_spare
*new)
653 if (!TRACEACTIONS
|| ftrace
== NULL
)
656 if (rts
->rts_gate
== new->rts_gate
657 && rts
->rts_router
== new->rts_router
658 && rts
->rts_metric
== new->rts_metric
659 && rts
->rts_tag
== new->rts_tag
660 && rts
->rts_de_ag
== new->rts_de_ag
)
664 if (new->rts_gate
== 0) {
665 fprintf(ftrace
, "Del #%d %-35s ",
666 (int)(rts
- rt
->rt_spares
),
667 rtname(rt
->rt_dst
, rt
->rt_mask
, rts
->rts_gate
));
668 print_rts(rts
, 0,0,0,0,
669 (rts
!= rt
->rt_spares
670 || AGE_RT(rt
->rt_state
,new->rts_ifp
)));
672 } else if (rts
->rts_gate
!= RIP_DEFAULT
) {
673 fprintf(ftrace
, "Chg #%d %-35s ",
674 (int)(rts
- rt
->rt_spares
),
675 rtname(rt
->rt_dst
, rt
->rt_mask
, rts
->rts_gate
));
677 rts
->rts_gate
!= new->rts_gate
,
678 rts
->rts_tag
!= new->rts_tag
,
679 rts
!= rt
->rt_spares
|| AGE_RT(rt
->rt_state
,
682 fprintf(ftrace
, "\n %19s%-16s ", "",
683 (new->rts_gate
!= rts
->rts_gate
684 ? naddr_ntoa(new->rts_gate
) : ""));
686 -(new->rts_metric
== rts
->rts_metric
),
687 -(new->rts_ifp
== rts
->rts_ifp
),
689 rts
->rts_tag
!= new->rts_tag
,
690 (new->rts_time
!= rts
->rts_time
691 && (rts
!= rt
->rt_spares
692 || AGE_RT(rt
->rt_state
, new->rts_ifp
))));
695 fprintf(ftrace
, "Add #%d %-35s ",
696 (int)(rts
- rt
->rt_spares
),
697 rtname(rt
->rt_dst
, rt
->rt_mask
, new->rts_gate
));
698 print_rts(new, 0,0,0,0,
699 (rts
!= rt
->rt_spares
700 || AGE_RT(rt
->rt_state
,new->rts_ifp
)));
706 /* miscellaneous message checked by the caller
709 trace_misc(const char *p
, ...)
718 vfprintf(ftrace
, p
, args
);
723 /* display a message if tracing actions
726 trace_act(const char *p
, ...)
730 if (!TRACEACTIONS
|| ftrace
== NULL
)
735 vfprintf(ftrace
, p
, args
);
740 /* display a message if tracing packets
743 trace_pkt(const char *p
, ...)
747 if (!TRACEPACKETS
|| ftrace
== NULL
)
752 vfprintf(ftrace
, p
, args
);
758 trace_change(struct rt_entry
*rt
,
760 struct rt_spare
*new,
766 if (rt
->rt_metric
== new->rts_metric
767 && rt
->rt_gate
== new->rts_gate
768 && rt
->rt_router
== new->rts_router
769 && rt
->rt_state
== state
770 && rt
->rt_tag
== new->rts_tag
771 && rt
->rt_de_ag
== new->rts_de_ag
)
775 fprintf(ftrace
, "%s %-35s ",
776 label
, rtname(rt
->rt_dst
, rt
->rt_mask
, rt
->rt_gate
));
777 print_rts(rt
->rt_spares
,
778 0,0,0,0, AGE_RT(rt
->rt_state
, rt
->rt_ifp
));
779 trace_bits(rs_bits
, rt
->rt_state
, rt
->rt_state
!= state
);
781 fprintf(ftrace
, "\n%*s %19s%-16s ",
782 (int)strlen(label
), "", "",
783 (rt
->rt_gate
!= new->rts_gate
784 ? naddr_ntoa(new->rts_gate
) : ""));
786 -(new->rts_metric
== rt
->rt_metric
),
787 -(new->rts_ifp
== rt
->rt_ifp
),
789 rt
->rt_tag
!= new->rts_tag
,
790 (rt
->rt_time
!= new->rts_time
791 && AGE_RT(rt
->rt_state
,new->rts_ifp
)));
792 if (rt
->rt_state
!= state
)
793 trace_bits(rs_bits
, state
, 1);
799 trace_add_del(const char * action
, struct rt_entry
*rt
)
805 fprintf(ftrace
, "%s %-35s ",
806 action
, rtname(rt
->rt_dst
, rt
->rt_mask
, rt
->rt_gate
));
807 print_rts(rt
->rt_spares
, 0,0,0,0,AGE_RT(rt
->rt_state
,rt
->rt_ifp
));
808 trace_bits(rs_bits
, rt
->rt_state
, 0);
815 walk_trace(struct radix_node
*rn
,
816 struct walkarg
*w UNUSED
)
818 #define RT ((struct rt_entry *)rn)
819 struct rt_spare
*rts
;
822 fprintf(ftrace
, " %-35s ",
823 rtname(RT
->rt_dst
, RT
->rt_mask
, RT
->rt_gate
));
824 print_rts(&RT
->rt_spares
[0], 0,0,0,0, AGE_RT(RT
->rt_state
, RT
->rt_ifp
));
825 trace_bits(rs_bits
, RT
->rt_state
, 0);
826 if (RT
->rt_poison_time
>= now_garbage
827 && RT
->rt_poison_metric
< RT
->rt_metric
)
828 fprintf(ftrace
, "pm=%d@%s",
829 RT
->rt_poison_metric
, ts(RT
->rt_poison_time
));
831 rts
= &RT
->rt_spares
[1];
832 for (i
= 1; i
< NUM_SPARES
; i
++, rts
++) {
833 if (rts
->rts_gate
!= RIP_DEFAULT
) {
834 fprintf(ftrace
,"\n #%d%15s%-16s ",
835 i
, "", naddr_ntoa(rts
->rts_gate
));
836 print_rts(rts
, 0,0,0,0,1);
848 struct interface
*ifp
;
854 fputs("current daemon state:\n", ftrace
);
855 for (ifp
= ifnet
; ifp
!= NULL
; ifp
= ifp
->int_next
)
857 rn_walktree(rhead
, walk_trace
, 0);
862 trace_rip(const char *dir1
, const char *dir2
,
863 struct sockaddr_in
*who
,
864 struct interface
*ifp
,
866 int size
) /* total size of message */
868 struct netinfo
*n
, *lim
;
869 # define NA ((struct netauth*)n)
872 if (!TRACEPACKETS
|| ftrace
== NULL
)
876 if (msg
->rip_cmd
>= RIPCMD_MAX
877 || msg
->rip_vers
== 0) {
878 fprintf(ftrace
, "%s bad RIPv%d cmd=%d %s"
880 dir1
, msg
->rip_vers
, msg
->rip_cmd
, dir2
,
881 naddr_ntoa(who
->sin_addr
.s_addr
),
882 ntohs(who
->sin_port
),
887 fprintf(ftrace
, "%s RIPv%d %s %s %s.%d%s%s\n",
888 dir1
, msg
->rip_vers
, ripcmds
[msg
->rip_cmd
], dir2
,
889 naddr_ntoa(who
->sin_addr
.s_addr
), ntohs(who
->sin_port
),
890 ifp
? " via " : "", ifp
? ifp
->int_name
: "");
895 switch (msg
->rip_cmd
) {
897 case RIPCMD_RESPONSE
:
899 lim
= (struct netinfo
*)((char*)msg
+ size
);
900 for (; n
< lim
; n
++) {
902 && n
->n_family
== RIP_AF_UNSPEC
903 && ntohl(n
->n_metric
) == HOPCNT_INFINITY
904 && msg
->rip_cmd
== RIPCMD_REQUEST
907 && (n
+1)->n_family
== RIP_AF_AUTH
))) {
908 fputs("\tQUERY ", ftrace
);
910 fprintf(ftrace
, "%s ",
911 naddr_ntoa(n
->n_dst
));
913 fprintf(ftrace
, "mask=%#x ",
914 (u_int
)ntohl(n
->n_mask
));
916 fprintf(ftrace
, "nhop=%s ",
917 naddr_ntoa(n
->n_nhop
));
919 fprintf(ftrace
, "tag=%#x ",
925 if (n
->n_family
== RIP_AF_AUTH
) {
926 if (NA
->a_type
== RIP_AUTH_PW
927 && n
== msg
->rip_nets
) {
928 fprintf(ftrace
, "\tPassword"
931 qstring(NA
->au
.au_pw
,
936 if (NA
->a_type
== RIP_AUTH_MD5
937 && n
== msg
->rip_nets
) {
940 " pkt_len=%d KeyID=%u"
944 ntohs(NA
->au
.a_md5
.md5_pkt_len
),
945 NA
->au
.a_md5
.md5_keyid
,
946 NA
->au
.a_md5
.md5_auth_len
,
947 (int)ntohl(NA
->au
.a_md5
.md5_seqno
),
948 (int)ntohs(NA
->au
.a_md5
.rsvd
[0]),
949 (int)ntohs(NA
->au
.a_md5
.rsvd
[1]));
953 "\tAuthentication type %d: ",
956 i
< (int)sizeof(NA
->au
.au_pw
);
958 fprintf(ftrace
, "%02x ",
965 if (n
->n_family
!= RIP_AF_INET
) {
967 "\t(af %d) %-18s mask=%#x ",
969 naddr_ntoa(n
->n_dst
),
970 (u_int
)ntohl(n
->n_mask
));
971 } else if (msg
->rip_vers
== RIPv1
) {
972 fprintf(ftrace
, "\t%-18s ",
973 addrname(n
->n_dst
, ntohl(n
->n_mask
),
974 n
->n_mask
==0 ? 2 : 1));
976 fprintf(ftrace
, "\t%-18s ",
977 addrname(n
->n_dst
, ntohl(n
->n_mask
),
978 n
->n_mask
==0 ? 2 : 0));
980 fprintf(ftrace
, "metric=%-2d ",
981 (u_int
)ntohl(n
->n_metric
));
983 fprintf(ftrace
, " nhop=%s ",
984 naddr_ntoa(n
->n_nhop
));
986 fprintf(ftrace
, "tag=%#x", ntohs(n
->n_tag
));
989 if (size
!= (char *)n
- (char *)msg
)
990 fprintf(ftrace
, "truncated record, len %d\n", size
);
994 fprintf(ftrace
, "\tfile=\"%.*s\"\n", size
-4,
998 case RIPCMD_TRACEOFF
: