]>
The Tcpdump Group git mirrors - tcpdump/blob - print-ripng.c
2 * Copyright (c) 1989, 1990, 1991, 1993, 1994
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: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 static const char rcsid
[] =
24 "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.11 2002-08-01 08:53:26 risso Exp $";
33 #include <tcpdump-stdinc.h>
37 IN6_ADDR_EQUAL(const struct in6_addr
*a
, const struct in6_addr
*b
)
39 return (memcmp(a
, b
, sizeof(struct in6_addr
)) == 0);
42 #define IN6_IS_ADDR_UNSPECIFIED(a) IN6_ADDR_EQUAL((a), &in6addr_any)
43 #endif /* __MINGW32__ */
49 #include "interface.h"
50 #include "addrtoname.h"
53 rip6_entry_print(register const struct netinfo6
*ni
, int metric
)
56 l
= printf("%s/%d", ip6addr_string(&ni
->rip6_dest
), ni
->rip6_plen
);
58 l
+= printf(" [%d]", ntohs(ni
->rip6_tag
));
60 l
+= printf(" (%d)", ni
->rip6_metric
);
65 ripng_print(const u_char
*dat
, unsigned int length
)
67 register const struct rip6
*rp
= (struct rip6
*)dat
;
68 register const struct netinfo6
*ni
;
69 register int amt
= snapend
- dat
;
70 register int i
= min(length
, amt
) -
71 (sizeof(struct rip6
) - sizeof(struct netinfo6
));
78 switch (rp
->rip6_cmd
) {
81 j
= length
/ sizeof(*ni
);
83 && rp
->rip6_nets
->rip6_metric
== HOPCNT_INFINITY6
84 && IN6_IS_ADDR_UNSPECIFIED(&rp
->rip6_nets
->rip6_dest
)) {
85 printf(" ripng-req dump");
88 if (j
* sizeof(*ni
) != length
- 4)
89 printf(" ripng-req %d[%u]:", j
, length
);
91 printf(" ripng-req %d:", j
);
92 trunc
= ((i
/ sizeof(*ni
)) * sizeof(*ni
) != i
);
93 for (ni
= rp
->rip6_nets
; (i
-= sizeof(*ni
)) >= 0; ++ni
) {
98 rip6_entry_print(ni
, 0);
102 j
= length
/ sizeof(*ni
);
103 if (j
* sizeof(*ni
) != length
- 4)
104 printf(" ripng-resp %d[%u]:", j
, length
);
106 printf(" ripng-resp %d:", j
);
107 trunc
= ((i
/ sizeof(*ni
)) * sizeof(*ni
) != i
);
108 for (ni
= rp
->rip6_nets
; (i
-= sizeof(*ni
)) >= 0; ++ni
) {
113 rip6_entry_print(ni
, ni
->rip6_metric
);
119 printf(" ripng-%d ?? %u", rp
->rip6_cmd
, length
);
122 if (rp
->rip6_vers
!= RIP6_VERSION
)
123 printf(" [vers %d]", rp
->rip6_vers
);