Deleted Added
full compact
trace.c (18316) trace.c (19880)
1/*
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
35static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93";
36#elif defined(__NetBSD__)
37static char rcsid[] = "$NetBSD$";
38#endif
1/*
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
35static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93";
36#elif defined(__NetBSD__)
37static char rcsid[] = "$NetBSD$";
38#endif
39#ident "$Revision: 1.13 $"
39#ident "$Revision: 1.14 $"
40
41#define RIPCMDS
42#include "defs.h"
43#include "pathnames.h"
44#include <sys/stat.h>
45#include <sys/signal.h>
46#include <fcntl.h>
47

--- 9 unchanged lines hidden (view full) ---

57FILE *ftrace = stdout; /* output trace file */
58static char *tracelevel_pat = "%s\n";
59
60char savetracename[MAXPATHLEN+1];
61
62static void trace_dump(void);
63
64
40
41#define RIPCMDS
42#include "defs.h"
43#include "pathnames.h"
44#include <sys/stat.h>
45#include <sys/signal.h>
46#include <fcntl.h>
47

--- 9 unchanged lines hidden (view full) ---

57FILE *ftrace = stdout; /* output trace file */
58static char *tracelevel_pat = "%s\n";
59
60char savetracename[MAXPATHLEN+1];
61
62static void trace_dump(void);
63
64
65/* convert string to printable characters
66 */
67static char *
68qstring(u_char *s, int len)
69{
70 static char buf[8*20+1];
71 char *p;
72 u_char *s2, c;
73
74
75 for (p = buf; len != 0 && p < &buf[sizeof(buf)-1]; len--) {
76 c = *s++;
77 if (c == '\0') {
78 for (s2 = s+1; s2 < &s[len]; s2++) {
79 if (*s2 != '\0')
80 break;
81 }
82 if (s2 >= &s[len])
83 goto exit;
84 }
85
86 if (c >= ' ' && c < 0x7f && c != '\\') {
87 *p++ = c;
88 continue;
89 }
90 *p++ = '\\';
91 switch (c) {
92 case '\\':
93 *p++ = '\\';
94 break;
95 case '\n':
96 *p++= 'n';
97 break;
98 case '\r':
99 *p++= 'r';
100 break;
101 case '\t':
102 *p++ = 't';
103 break;
104 case '\b':
105 *p++ = 'b';
106 break;
107 default:
108 p += sprintf(p,"%o",c);
109 break;
110 }
111 }
112exit:
113 *p = '\0';
114 return buf;
115}
116
117
65/* convert IP address to a string, but not into a single buffer
66 */
67char *
68naddr_ntoa(naddr a)
69{
70#define NUM_BUFS 4
71 static int bufno;
72 static struct {

--- 110 unchanged lines hidden (view full) ---

183 trace_close();
184
185 new_tracelevel = tracelevel = 0;
186}
187
188
189void
190trace_on(char *filename,
118/* convert IP address to a string, but not into a single buffer
119 */
120char *
121naddr_ntoa(naddr a)
122{
123#define NUM_BUFS 4
124 static int bufno;
125 static struct {

--- 110 unchanged lines hidden (view full) ---

236 trace_close();
237
238 new_tracelevel = tracelevel = 0;
239}
240
241
242void
243trace_on(char *filename,
191 int trusted)
244 int initial) /* 1=setting from command line */
192{
193 struct stat stbuf;
194 FILE *n_ftrace;
245{
246 struct stat stbuf;
247 FILE *n_ftrace;
248 u_int old_tracelevel;
195
196
197 /* Given a null filename when tracing is already on, increase the
198 * debugging level and re-open the file in case it has been unlinked.
199 */
200 if (filename[0] == '\0') {
201 if (tracelevel != 0) {
202 new_tracelevel++;

--- 11 unchanged lines hidden (view full) ---

214 } else {
215 if (stat(filename, &stbuf) >= 0
216 && (stbuf.st_mode & S_IFMT) != S_IFREG) {
217 msglog("wrong type (%#x) of trace file \"%s\"",
218 stbuf.st_mode, filename);
219 return;
220 }
221
249
250
251 /* Given a null filename when tracing is already on, increase the
252 * debugging level and re-open the file in case it has been unlinked.
253 */
254 if (filename[0] == '\0') {
255 if (tracelevel != 0) {
256 new_tracelevel++;

--- 11 unchanged lines hidden (view full) ---

268 } else {
269 if (stat(filename, &stbuf) >= 0
270 && (stbuf.st_mode & S_IFMT) != S_IFREG) {
271 msglog("wrong type (%#x) of trace file \"%s\"",
272 stbuf.st_mode, filename);
273 return;
274 }
275
222 if (!trusted
276 if (!initial
223#ifdef _PATH_TRACE
224 && (strncmp(filename, _PATH_TRACE, sizeof(_PATH_TRACE)-1)
225 || strstr(filename,"../")
226 || 0 > stat(_PATH_TRACE, &stbuf))
227#endif
228 && strcmp(filename, savetracename)) {
229 msglog("wrong directory for trace file \"%s\"",
230 filename);

--- 16 unchanged lines hidden (view full) ---

247
248 fflush(stdout);
249 fflush(stderr);
250 dup2(fileno(ftrace), STDOUT_FILENO);
251 dup2(fileno(ftrace), STDERR_FILENO);
252
253 if (new_tracelevel == 0)
254 new_tracelevel = 1;
277#ifdef _PATH_TRACE
278 && (strncmp(filename, _PATH_TRACE, sizeof(_PATH_TRACE)-1)
279 || strstr(filename,"../")
280 || 0 > stat(_PATH_TRACE, &stbuf))
281#endif
282 && strcmp(filename, savetracename)) {
283 msglog("wrong directory for trace file \"%s\"",
284 filename);

--- 16 unchanged lines hidden (view full) ---

301
302 fflush(stdout);
303 fflush(stderr);
304 dup2(fileno(ftrace), STDOUT_FILENO);
305 dup2(fileno(ftrace), STDERR_FILENO);
306
307 if (new_tracelevel == 0)
308 new_tracelevel = 1;
255 set_tracelevel();
309 old_tracelevel = tracelevel;
310 set_tracelevel(initial);
311
312 if (!initial && old_tracelevel == 0)
313 trace_dump();
256}
257
258
259/* ARGSUSED */
260void
261sigtrace_on(int s)
262{
263 new_tracelevel++;

--- 12 unchanged lines hidden (view full) ---

276
277/* Move to next higher level of tracing when -t option processed or
278 * SIGUSR1 is received. Successive levels are:
279 * actions
280 * actions + packets
281 * actions + packets + contents
282 */
283void
314}
315
316
317/* ARGSUSED */
318void
319sigtrace_on(int s)
320{
321 new_tracelevel++;

--- 12 unchanged lines hidden (view full) ---

334
335/* Move to next higher level of tracing when -t option processed or
336 * SIGUSR1 is received. Successive levels are:
337 * actions
338 * actions + packets
339 * actions + packets + contents
340 */
341void
284set_tracelevel(void)
342set_tracelevel(int initial)
285{
286 static char *off_msgs[MAX_TRACELEVEL] = {
287 "Tracing actions stopped",
288 "Tracing packets stopped",
289 "Tracing packet contents stopped",
290 "Tracing kernel changes stopped",
291 };
292 static char *on_msgs[MAX_TRACELEVEL] = {

--- 6 unchanged lines hidden (view full) ---

299
300 if (new_tracelevel > MAX_TRACELEVEL) {
301 new_tracelevel = MAX_TRACELEVEL;
302 if (new_tracelevel == tracelevel) {
303 tmsg(tracelevel_pat, on_msgs[tracelevel-1]);
304 return;
305 }
306 }
343{
344 static char *off_msgs[MAX_TRACELEVEL] = {
345 "Tracing actions stopped",
346 "Tracing packets stopped",
347 "Tracing packet contents stopped",
348 "Tracing kernel changes stopped",
349 };
350 static char *on_msgs[MAX_TRACELEVEL] = {

--- 6 unchanged lines hidden (view full) ---

357
358 if (new_tracelevel > MAX_TRACELEVEL) {
359 new_tracelevel = MAX_TRACELEVEL;
360 if (new_tracelevel == tracelevel) {
361 tmsg(tracelevel_pat, on_msgs[tracelevel-1]);
362 return;
363 }
364 }
307 while (new_tracelevel != tracelevel) {
365
366 for (; new_tracelevel != tracelevel; tracelevel++) {
308 if (new_tracelevel < tracelevel) {
309 if (--tracelevel == 0)
310 trace_off(tracelevel_pat, off_msgs[0]);
311 else
312 tmsg(tracelevel_pat, off_msgs[tracelevel]);
313 } else {
314 if (ftrace == 0) {
315 if (savetracename[0] != '\0')
316 trace_on(savetracename, 1);
317 else
318 ftrace = stdout;
319 }
367 if (new_tracelevel < tracelevel) {
368 if (--tracelevel == 0)
369 trace_off(tracelevel_pat, off_msgs[0]);
370 else
371 tmsg(tracelevel_pat, off_msgs[tracelevel]);
372 } else {
373 if (ftrace == 0) {
374 if (savetracename[0] != '\0')
375 trace_on(savetracename, 1);
376 else
377 ftrace = stdout;
378 }
320 tmsg(tracelevel_pat, on_msgs[tracelevel++]);
379 if (!initial || tracelevel+1 == new_tracelevel)
380 tmsg(tracelevel_pat, on_msgs[tracelevel]);
321 }
322 }
323 tracelevel_pat = "%s\n";
324}
325
326
327/* display an address
328 */

--- 43 unchanged lines hidden (view full) ---

372
373static struct bits if_bits[] = {
374 { IFF_LOOPBACK, 0, "LOOPBACK" },
375 { IFF_POINTOPOINT, 0, "PT-TO-PT" },
376 { 0, 0, 0}
377};
378
379static struct bits is_bits[] = {
381 }
382 }
383 tracelevel_pat = "%s\n";
384}
385
386
387/* display an address
388 */

--- 43 unchanged lines hidden (view full) ---

432
433static struct bits if_bits[] = {
434 { IFF_LOOPBACK, 0, "LOOPBACK" },
435 { IFF_POINTOPOINT, 0, "PT-TO-PT" },
436 { 0, 0, 0}
437};
438
439static struct bits is_bits[] = {
440 { IS_ALIAS, 0, "ALIAS" },
380 { IS_SUBNET, 0, "" },
441 { IS_SUBNET, 0, "" },
381 { IS_REMOTE, 0, "REMOTE" },
442 { IS_REMOTE, (IS_NO_RDISC
443 | IS_BCAST_RDISC), "REMOTE" },
382 { IS_PASSIVE, (IS_NO_RDISC
444 { IS_PASSIVE, (IS_NO_RDISC
383 | IS_BCAST_RDISC
384 | IS_NO_RIP
385 | IS_NO_SUPER_AG
386 | IS_PM_RDISC
387 | IS_NO_AG), "PASSIVE" },
388 { IS_EXTERNAL, 0, "EXTERNAL" },
389 { IS_CHECKED, 0, "" },
390 { IS_ALL_HOSTS, 0, "" },
391 { IS_ALL_ROUTERS, 0, "" },
445 | IS_NO_RIP
446 | IS_NO_SUPER_AG
447 | IS_PM_RDISC
448 | IS_NO_AG), "PASSIVE" },
449 { IS_EXTERNAL, 0, "EXTERNAL" },
450 { IS_CHECKED, 0, "" },
451 { IS_ALL_HOSTS, 0, "" },
452 { IS_ALL_ROUTERS, 0, "" },
392 { IS_RIP_QUERIED, 0, "" },
453 { IS_DISTRUST, 0, "DISTRUST" },
393 { IS_BROKE, IS_SICK, "BROKEN" },
394 { IS_SICK, 0, "SICK" },
454 { IS_BROKE, IS_SICK, "BROKEN" },
455 { IS_SICK, 0, "SICK" },
395 { IS_ACTIVE, 0, "ACTIVE" },
456 { IS_DUP, 0, "DUPLICATE" },
396 { IS_NEED_NET_SYN, 0, "" },
397 { IS_NO_AG, IS_NO_SUPER_AG, "NO_AG" },
398 { IS_NO_SUPER_AG, 0, "NO_SUPER_AG" },
399 { (IS_NO_RIPV1_IN
400 | IS_NO_RIPV2_IN
401 | IS_NO_RIPV1_OUT
402 | IS_NO_RIPV2_OUT), 0, "NO_RIP" },
403 { (IS_NO_RIPV1_IN

--- 5 unchanged lines hidden (view full) ---

409 { (IS_NO_ADV_IN
410 | IS_NO_SOL_OUT
411 | IS_NO_ADV_OUT), IS_BCAST_RDISC, "NO_RDISC" },
412 { IS_NO_SOL_OUT, 0, "NO_SOLICIT" },
413 { IS_SOL_OUT, 0, "SEND_SOLICIT" },
414 { IS_NO_ADV_OUT, IS_BCAST_RDISC, "NO_RDISC_ADV" },
415 { IS_ADV_OUT, 0, "RDISC_ADV" },
416 { IS_BCAST_RDISC, 0, "BCAST_RDISC" },
457 { IS_NEED_NET_SYN, 0, "" },
458 { IS_NO_AG, IS_NO_SUPER_AG, "NO_AG" },
459 { IS_NO_SUPER_AG, 0, "NO_SUPER_AG" },
460 { (IS_NO_RIPV1_IN
461 | IS_NO_RIPV2_IN
462 | IS_NO_RIPV1_OUT
463 | IS_NO_RIPV2_OUT), 0, "NO_RIP" },
464 { (IS_NO_RIPV1_IN

--- 5 unchanged lines hidden (view full) ---

470 { (IS_NO_ADV_IN
471 | IS_NO_SOL_OUT
472 | IS_NO_ADV_OUT), IS_BCAST_RDISC, "NO_RDISC" },
473 { IS_NO_SOL_OUT, 0, "NO_SOLICIT" },
474 { IS_SOL_OUT, 0, "SEND_SOLICIT" },
475 { IS_NO_ADV_OUT, IS_BCAST_RDISC, "NO_RDISC_ADV" },
476 { IS_ADV_OUT, 0, "RDISC_ADV" },
477 { IS_BCAST_RDISC, 0, "BCAST_RDISC" },
417 { IS_PM_RDISC, 0, "PM_RDISC" },
478 { IS_PM_RDISC, 0, "" },
418 { 0, 0, "%#x"}
419};
420
421static struct bits rs_bits[] = {
422 { RS_IF, 0, "IF" },
423 { RS_NET_INT, RS_NET_SYN, "NET_INT" },
424 { RS_NET_SYN, 0, "NET_SYN" },
425 { RS_SUBNET, 0, "" },

--- 64 unchanged lines hidden (view full) ---

490void
491trace_if(char *act,
492 struct interface *ifp)
493{
494 if (!TRACEACTIONS || ftrace == 0)
495 return;
496
497 lastlog();
479 { 0, 0, "%#x"}
480};
481
482static struct bits rs_bits[] = {
483 { RS_IF, 0, "IF" },
484 { RS_NET_INT, RS_NET_SYN, "NET_INT" },
485 { RS_NET_SYN, 0, "NET_SYN" },
486 { RS_SUBNET, 0, "" },

--- 64 unchanged lines hidden (view full) ---

551void
552trace_if(char *act,
553 struct interface *ifp)
554{
555 if (!TRACEACTIONS || ftrace == 0)
556 return;
557
558 lastlog();
498 (void)fprintf(ftrace, "%s interface %-4s ", act, ifp->int_name);
559 (void)fprintf(ftrace, "%-3s interface %-4s ", act, ifp->int_name);
499 (void)fprintf(ftrace, "%-15s-->%-15s ",
500 naddr_ntoa(ifp->int_addr),
560 (void)fprintf(ftrace, "%-15s-->%-15s ",
561 naddr_ntoa(ifp->int_addr),
501 addrname(htonl((ifp->int_if_flags & IFF_POINTOPOINT)
502 ? ifp->int_dstaddr
503 : ifp->int_net),
562 addrname(((ifp->int_if_flags & IFF_POINTOPOINT)
563 ? ifp->int_dstaddr
564 : htonl(ifp->int_net)),
504 ifp->int_mask, 1));
505 if (ifp->int_metric != 0)
506 (void)fprintf(ftrace, "metric=%d ", ifp->int_metric);
565 ifp->int_mask, 1));
566 if (ifp->int_metric != 0)
567 (void)fprintf(ftrace, "metric=%d ", ifp->int_metric);
568 if (!IS_RIP_OUT_OFF(ifp->int_state)
569 && ifp->int_d_metric != 0)
570 (void)fprintf(ftrace, "fake_default=%d ", ifp->int_d_metric);
507 trace_bits(if_bits, ifp->int_if_flags, 0);
508 trace_bits(is_bits, ifp->int_state, 0);
509 (void)fputc('\n',ftrace);
510}
511
512
513void
514trace_upslot(struct rt_entry *rt,

--- 85 unchanged lines hidden (view full) ---

600 va_list args;
601
602 if (!TRACEACTIONS || ftrace == 0)
603 return;
604
605 lastlog();
606 va_start(args, p);
607 vfprintf(ftrace, p, args);
571 trace_bits(if_bits, ifp->int_if_flags, 0);
572 trace_bits(is_bits, ifp->int_state, 0);
573 (void)fputc('\n',ftrace);
574}
575
576
577void
578trace_upslot(struct rt_entry *rt,

--- 85 unchanged lines hidden (view full) ---

664 va_list args;
665
666 if (!TRACEACTIONS || ftrace == 0)
667 return;
668
669 lastlog();
670 va_start(args, p);
671 vfprintf(ftrace, p, args);
672 (void)fputc('\n',ftrace);
608}
609
610
611/* display a message if tracing packets
612 */
613void
614trace_pkt(char *p, ...)
615{
616 va_list args;
617
618 if (!TRACEPACKETS || ftrace == 0)
619 return;
620
621 lastlog();
622 va_start(args, p);
623 vfprintf(ftrace, p, args);
673}
674
675
676/* display a message if tracing packets
677 */
678void
679trace_pkt(char *p, ...)
680{
681 va_list args;
682
683 if (!TRACEPACKETS || ftrace == 0)
684 return;
685
686 lastlog();
687 va_start(args, p);
688 vfprintf(ftrace, p, args);
689 (void)fputc('\n',ftrace);
624}
625
626
627void
628trace_change(struct rt_entry *rt,
629 u_int state,
630 naddr gate, /* forward packets here */
631 naddr router, /* on the authority of this router */

--- 125 unchanged lines hidden (view full) ---

757
758 return 0;
759}
760
761
762static void
763trace_dump(void)
764{
690}
691
692
693void
694trace_change(struct rt_entry *rt,
695 u_int state,
696 naddr gate, /* forward packets here */
697 naddr router, /* on the authority of this router */

--- 125 unchanged lines hidden (view full) ---

823
824 return 0;
825}
826
827
828static void
829trace_dump(void)
830{
831 struct interface *ifp;
832
765 if (ftrace == 0)
766 return;
767 lastlog();
768
833 if (ftrace == 0)
834 return;
835 lastlog();
836
837 for (ifp = ifnet; ifp != 0; ifp = ifp->int_next)
838 trace_if("", ifp);
769 (void)rn_walktree(rhead, walk_trace, 0);
770}
771
772
773void
774trace_rip(char *dir1, char *dir2,
775 struct sockaddr_in *who,
776 struct interface *ifp,
777 struct rip *msg,
778 int size) /* total size of message */
779{
780 struct netinfo *n, *lim;
839 (void)rn_walktree(rhead, walk_trace, 0);
840}
841
842
843void
844trace_rip(char *dir1, char *dir2,
845 struct sockaddr_in *who,
846 struct interface *ifp,
847 struct rip *msg,
848 int size) /* total size of message */
849{
850 struct netinfo *n, *lim;
781 struct netauth *a;
782 int i;
851# define NA (msg->rip_auths)
852 int i, seen_route;
783
784 if (!TRACEPACKETS || ftrace == 0)
785 return;
786
787 lastlog();
788 if (msg->rip_cmd >= RIPCMD_MAX
789 || msg->rip_vers == 0) {
790 (void)fprintf(ftrace, "%s bad RIPv%d cmd=%d %s"

--- 7 unchanged lines hidden (view full) ---

798
799 (void)fprintf(ftrace, "%s RIPv%d %s %s %s.%d%s%s\n",
800 dir1, msg->rip_vers, ripcmds[msg->rip_cmd], dir2,
801 naddr_ntoa(who->sin_addr.s_addr), ntohs(who->sin_port),
802 ifp ? " via " : "", ifp ? ifp->int_name : "");
803 if (!TRACECONTENTS)
804 return;
805
853
854 if (!TRACEPACKETS || ftrace == 0)
855 return;
856
857 lastlog();
858 if (msg->rip_cmd >= RIPCMD_MAX
859 || msg->rip_vers == 0) {
860 (void)fprintf(ftrace, "%s bad RIPv%d cmd=%d %s"

--- 7 unchanged lines hidden (view full) ---

868
869 (void)fprintf(ftrace, "%s RIPv%d %s %s %s.%d%s%s\n",
870 dir1, msg->rip_vers, ripcmds[msg->rip_cmd], dir2,
871 naddr_ntoa(who->sin_addr.s_addr), ntohs(who->sin_port),
872 ifp ? " via " : "", ifp ? ifp->int_name : "");
873 if (!TRACECONTENTS)
874 return;
875
876 seen_route = 0;
806 switch (msg->rip_cmd) {
807 case RIPCMD_REQUEST:
808 case RIPCMD_RESPONSE:
809 n = msg->rip_nets;
810 lim = (struct netinfo *)((char*)msg + size);
811 for (; n < lim; n++) {
877 switch (msg->rip_cmd) {
878 case RIPCMD_REQUEST:
879 case RIPCMD_RESPONSE:
880 n = msg->rip_nets;
881 lim = (struct netinfo *)((char*)msg + size);
882 for (; n < lim; n++) {
812 if (n->n_family == RIP_AF_UNSPEC
883 if (!seen_route
884 && n->n_family == RIP_AF_UNSPEC
813 && ntohl(n->n_metric) == HOPCNT_INFINITY
885 && ntohl(n->n_metric) == HOPCNT_INFINITY
814 && n+1 == lim
815 && n == msg->rip_nets
816 && msg->rip_cmd == RIPCMD_REQUEST) {
886 && msg->rip_cmd == RIPCMD_REQUEST
887 && (n+1 == lim
888 || (n+2 == lim
889 && (n+1)->n_family == RIP_AF_AUTH))) {
817 (void)fputs("\tQUERY ", ftrace);
818 if (n->n_dst != 0)
819 (void)fprintf(ftrace, "%s ",
820 naddr_ntoa(n->n_dst));
821 if (n->n_mask != 0)
822 (void)fprintf(ftrace, "mask=%#x ",
823 (u_int)ntohl(n->n_mask));
824 if (n->n_nhop != 0)
890 (void)fputs("\tQUERY ", ftrace);
891 if (n->n_dst != 0)
892 (void)fprintf(ftrace, "%s ",
893 naddr_ntoa(n->n_dst));
894 if (n->n_mask != 0)
895 (void)fprintf(ftrace, "mask=%#x ",
896 (u_int)ntohl(n->n_mask));
897 if (n->n_nhop != 0)
825 (void)fprintf(ftrace, " nhop=%s ",
898 (void)fprintf(ftrace, "nhop=%s ",
826 naddr_ntoa(n->n_nhop));
827 if (n->n_tag != 0)
899 naddr_ntoa(n->n_nhop));
900 if (n->n_tag != 0)
828 (void)fprintf(ftrace, "tag=%#x",
901 (void)fprintf(ftrace, "tag=%#x ",
829 ntohs(n->n_tag));
830 (void)fputc('\n',ftrace);
831 continue;
832 }
833
834 if (n->n_family == RIP_AF_AUTH) {
902 ntohs(n->n_tag));
903 (void)fputc('\n',ftrace);
904 continue;
905 }
906
907 if (n->n_family == RIP_AF_AUTH) {
835 a = (struct netauth*)n;
908 if (NA->a_type == RIP_AUTH_PW
909 && n == msg->rip_nets) {
910 (void)fprintf(ftrace, "\tPassword"
911 " Authentication:"
912 " \"%s\"\n",
913 qstring(NA->au.au_pw,
914 RIP_AUTH_PW_LEN));
915 continue;
916 }
917
918 if (NA->a_type == RIP_AUTH_MD5
919 && n == msg->rip_nets) {
920 (void)fprintf(ftrace,
921 "\tMD5 Authentication"
922 " len=%d KeyID=%u"
923 " seqno=%u"
924 " rsvd=%#x,%#x\n",
925 NA->au.a_md5.md5_pkt_len,
926 NA->au.a_md5.md5_keyid,
927 NA->au.a_md5.md5_seqno,
928 NA->au.a_md5.rsvd[0],
929 NA->au.a_md5.rsvd[1]);
930 continue;
931 }
836 (void)fprintf(ftrace,
932 (void)fprintf(ftrace,
837 "\tAuthentication type %d: ",
838 ntohs(a->a_type));
933 "\tAuthentication"
934 " type %d: ",
935 ntohs(NA->a_type));
839 for (i = 0;
936 for (i = 0;
840 i < sizeof(a->au.au_pw);
937 i < sizeof(NA->au.au_pw);
841 i++)
842 (void)fprintf(ftrace, "%02x ",
938 i++)
939 (void)fprintf(ftrace, "%02x ",
843 a->au.au_pw[i]);
940 NA->au.au_pw[i]);
844 (void)fputc('\n',ftrace);
845 continue;
846 }
847
941 (void)fputc('\n',ftrace);
942 continue;
943 }
944
945 seen_route = 1;
848 if (n->n_family != RIP_AF_INET) {
849 (void)fprintf(ftrace,
946 if (n->n_family != RIP_AF_INET) {
947 (void)fprintf(ftrace,
850 "\t(af %d) %-18s mask=%#x",
948 "\t(af %d) %-18s mask=%#x ",
851 ntohs(n->n_family),
852 naddr_ntoa(n->n_dst),
853 (u_int)ntohl(n->n_mask));
854 } else if (msg->rip_vers == RIPv1) {
855 (void)fprintf(ftrace, "\t%-18s ",
856 addrname(n->n_dst,
857 ntohl(n->n_mask),
858 n->n_mask==0 ? 2 : 1));

--- 29 unchanged lines hidden ---
949 ntohs(n->n_family),
950 naddr_ntoa(n->n_dst),
951 (u_int)ntohl(n->n_mask));
952 } else if (msg->rip_vers == RIPv1) {
953 (void)fprintf(ftrace, "\t%-18s ",
954 addrname(n->n_dst,
955 ntohl(n->n_mask),
956 n->n_mask==0 ? 2 : 1));

--- 29 unchanged lines hidden ---