2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that: (1) source code
4 * distributions retain the above copyright notice and this paragraph
5 * in its entirety, and (2) distributions including binary code include
6 * the above copyright notice and this paragraph in its entirety in
7 * the documentation or other materials provided with the distribution.
8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE.
13 * Original code by Hannes Gredler (hannes@juniper.net)
17 static const char rcsid
[] _U_
=
18 "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.3.2.2 2003-11-16 08:51:12 guy Exp $";
25 #include <tcpdump-stdinc.h>
30 #include "interface.h"
32 #include "addrtoname.h"
37 * Control packet, draft-katz-ward-bfd-01.txt
40 * 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
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * |Vers | Diag |H|D|P|F| Rsvd | Detect Mult | Length |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | My Discriminator |
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * | Your Discriminator |
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * | Desired Min TX Interval |
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | Required Min RX Interval |
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * | Required Min Echo RX Interval |
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 u_int8_t version_diag
;
59 u_int8_t detect_time_multiplier
;
61 u_int8_t my_discriminator
[4];
62 u_int8_t your_discriminator
[4];
63 u_int8_t desired_min_tx_interval
[4];
64 u_int8_t required_min_rx_interval
[4];
65 u_int8_t required_min_echo_interval
[4];
68 #define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
69 #define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
71 static const struct tok bfd_port_values
[] = {
72 { BFD_CONTROL_PORT
, "Control" },
73 { BFD_ECHO_PORT
, "Echo" },
78 static const struct tok bfd_diag_values
[] = {
79 { 0, "No Diagnostic" },
80 { 1, "Control Detection Time Expired" },
81 { 2, "Echo Function Failed" },
82 { 3, "Neighbor Signaled Session Down" },
83 { 4, "Forwarding Plane Reset" },
85 { 6, "Concatenated Path Down" },
86 { 7, "Administratively Down" },
90 static const struct tok bfd_flag_values
[] = {
91 { 0x80, "I Hear You" },
103 bfd_print(register const u_char
*pptr
, register u_int len
, register u_int port
)
105 const struct bfd_header_t
*bfd_header
;
107 bfd_header
= (const struct bfd_header_t
*)pptr
;
112 case BFD_CONTROL_PORT
:
115 printf("BFDv%u, %s, Flags: [%s], length: %u",
116 BFD_EXTRACT_VERSION(bfd_header
->version_diag
),
117 tok2str(bfd_port_values
, "unknown (%u)", port
),
118 bittok2str(bfd_flag_values
, "none", bfd_header
->flags
),
123 printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
124 BFD_EXTRACT_VERSION(bfd_header
->version_diag
),
126 tok2str(bfd_port_values
, "unknown (%u)", port
),
127 bittok2str(bfd_flag_values
, "none", bfd_header
->flags
),
128 tok2str(bfd_diag_values
,"unknown",BFD_EXTRACT_DIAG(bfd_header
->version_diag
)),
129 BFD_EXTRACT_DIAG(bfd_header
->version_diag
));
131 printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
132 bfd_header
->detect_time_multiplier
,
133 bfd_header
->detect_time_multiplier
* EXTRACT_32BITS(bfd_header
->desired_min_tx_interval
)/1000,
137 printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header
->my_discriminator
));
138 printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header
->your_discriminator
));
139 printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header
->desired_min_tx_interval
)/1000);
140 printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header
->required_min_rx_interval
)/1000);
141 printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header
->required_min_echo_interval
)/1000);
144 case BFD_ECHO_PORT
: /* not yet supported - fall through */
147 printf("BFD, %s, length: %u",
148 tok2str(bfd_port_values
, "unknown (%u)", port
),
151 if(!print_unknown_data(pptr
,"\n\t",len
))