4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that: (1) source code
6 * distributions retain the above copyright notice and this paragraph
7 * in its entirety, and (2) distributions including binary code include
8 * the above copyright notice and this paragraph in its entirety in
9 * the documentation or other materials provided with the distribution.
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 * FOR A PARTICULAR PURPOSE.
15 * Original code by Hannes Gredler (hannes@juniper.net)
18 #include <sys/cdefs.h>
21 static const char rcsid
[] _U_
=
22 "@(#) Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.5.2.5 2006/02/02 06:36:37 hannes Exp";
24 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
32 #include <tcpdump-stdinc.h>
37 #include "interface.h"
39 #include "addrtoname.h"
44 * Control packet, BFDv0, draft-katz-ward-bfd-01.txt
47 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * |Vers | Diag |H|D|P|F| Rsvd | Detect Mult | Length |
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * | My Discriminator |
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 * | Your Discriminator |
54 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 * | Desired Min TX Interval |
56 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 * | Required Min RX Interval |
58 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 * | Required Min Echo RX Interval |
60 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 * Control packet, BFDv1, draft-ietf-bfd-base-02.txt
67 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
68 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69 * |Vers | Diag |Sta|P|F|C|A|D|R| Detect Mult | Length |
70 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
71 * | My Discriminator |
72 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 * | Your Discriminator |
74 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75 * | Desired Min TX Interval |
76 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 * | Required Min RX Interval |
78 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 * | Required Min Echo RX Interval |
80 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84 u_int8_t version_diag
;
86 u_int8_t detect_time_multiplier
;
88 u_int8_t my_discriminator
[4];
89 u_int8_t your_discriminator
[4];
90 u_int8_t desired_min_tx_interval
[4];
91 u_int8_t required_min_rx_interval
[4];
92 u_int8_t required_min_echo_interval
[4];
96 * An optional Authentication Header may be present
99 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
100 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
101 * | Auth Type | Auth Len | Authentication Data... |
102 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
105 struct bfd_auth_header_t
{
111 static const struct tok bfd_v1_authentication_values
[] = {
113 { 1, "Simple Password" },
115 { 3, "Meticulous Keyed MD5" },
117 { 5, "Meticulous Keyed SHA1" },
121 #define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
122 #define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
124 static const struct tok bfd_port_values
[] = {
125 { BFD_CONTROL_PORT
, "Control" },
126 { BFD_ECHO_PORT
, "Echo" },
131 static const struct tok bfd_diag_values
[] = {
132 { 0, "No Diagnostic" },
133 { 1, "Control Detection Time Expired" },
134 { 2, "Echo Function Failed" },
135 { 3, "Neighbor Signaled Session Down" },
136 { 4, "Forwarding Plane Reset" },
138 { 6, "Concatenated Path Down" },
139 { 7, "Administratively Down" },
140 { 8, "Reverse Concatenated Path Down" },
144 static const struct tok bfd_v0_flag_values
[] = {
145 { 0x80, "I Hear You" },
149 { 0x08, "Reserved" },
150 { 0x04, "Reserved" },
151 { 0x02, "Reserved" },
152 { 0x01, "Reserved" },
156 #define BFD_FLAG_AUTH 0x04
158 static const struct tok bfd_v1_flag_values
[] = {
161 { 0x08, "Control Plane Independent" },
162 { BFD_FLAG_AUTH
, "Authentication Present" },
164 { 0x01, "Reserved" },
168 static const struct tok bfd_v1_state_values
[] = {
177 bfd_print(register const u_char
*pptr
, register u_int len
, register u_int port
)
179 const struct bfd_header_t
*bfd_header
;
180 const struct bfd_auth_header_t
*bfd_auth_header
;
183 bfd_header
= (const struct bfd_header_t
*)pptr
;
185 version
= BFD_EXTRACT_VERSION(bfd_header
->version_diag
);
187 switch (port
<< 8 | version
) {
190 case (BFD_CONTROL_PORT
<< 8):
193 printf("BFDv%u, %s, Flags: [%s], length: %u",
195 tok2str(bfd_port_values
, "unknown (%u)", port
),
196 bittok2str(bfd_v0_flag_values
, "none", bfd_header
->flags
),
201 printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
204 tok2str(bfd_port_values
, "unknown (%u)", port
),
205 bittok2str(bfd_v0_flag_values
, "none", bfd_header
->flags
),
206 tok2str(bfd_diag_values
,"unknown",BFD_EXTRACT_DIAG(bfd_header
->version_diag
)),
207 BFD_EXTRACT_DIAG(bfd_header
->version_diag
));
209 printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
210 bfd_header
->detect_time_multiplier
,
211 bfd_header
->detect_time_multiplier
* EXTRACT_32BITS(bfd_header
->desired_min_tx_interval
)/1000,
215 printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header
->my_discriminator
));
216 printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header
->your_discriminator
));
217 printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header
->desired_min_tx_interval
)/1000);
218 printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header
->required_min_rx_interval
)/1000);
219 printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header
->required_min_echo_interval
)/1000);
223 case (BFD_CONTROL_PORT
<< 8 | 1):
226 printf("BFDv%u, %s, State %s, Flags: [%s], length: %u",
228 tok2str(bfd_port_values
, "unknown (%u)", port
),
229 tok2str(bfd_v1_state_values
, "unknown (%u)", (bfd_header
->flags
& 0xc0) >> 6),
230 bittok2str(bfd_v1_flag_values
, "none", bfd_header
->flags
& 0x3f),
235 printf("BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
238 tok2str(bfd_port_values
, "unknown (%u)", port
),
239 tok2str(bfd_v1_state_values
, "unknown (%u)", (bfd_header
->flags
& 0xc0) >> 6),
240 bittok2str(bfd_v1_flag_values
, "none", bfd_header
->flags
& 0x3f),
241 tok2str(bfd_diag_values
,"unknown",BFD_EXTRACT_DIAG(bfd_header
->version_diag
)),
242 BFD_EXTRACT_DIAG(bfd_header
->version_diag
));
244 printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
245 bfd_header
->detect_time_multiplier
,
246 bfd_header
->detect_time_multiplier
* EXTRACT_32BITS(bfd_header
->desired_min_tx_interval
)/1000,
250 printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header
->my_discriminator
));
251 printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header
->your_discriminator
));
252 printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header
->desired_min_tx_interval
)/1000);
253 printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header
->required_min_rx_interval
)/1000);
254 printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header
->required_min_echo_interval
)/1000);
256 if (bfd_header
->flags
& BFD_FLAG_AUTH
) {
257 pptr
+= sizeof (const struct bfd_header_t
);
258 bfd_auth_header
= (const struct bfd_auth_header_t
*)pptr
;
259 TCHECK2(*bfd_auth_header
, sizeof(const struct bfd_auth_header_t
));
260 printf("\n\t%s (%u) Authentication, length %u present",
261 tok2str(bfd_v1_authentication_values
,"Unknown",bfd_auth_header
->auth_type
),
262 bfd_auth_header
->auth_type
,
263 bfd_auth_header
->auth_len
);
268 case (BFD_ECHO_PORT
<< 8): /* not yet supported - fall through */
270 case (BFD_ECHO_PORT
<< 8 | 1):
273 printf("BFD, %s, length: %u",
274 tok2str(bfd_port_values
, "unknown (%u)", port
),
277 if(!print_unknown_data(pptr
,"\n\t",len
))