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
[] =
18 "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.2 2003-10-27 17:21:32 hannes Exp $";
25 #include <tcpdump-stdinc.h>
30 #include "interface.h"
32 #include "addrtoname.h"
35 * Control packet, draft-katz-ward-bfd-01.txt
38 * 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
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 * |Vers | Diag |H|D|P|F| Rsvd | Detect Mult | Length |
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * | My Discriminator |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | Your Discriminator |
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * | Desired Min TX Interval |
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * | Required Min RX Interval |
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | Required Min Echo RX Interval |
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 u_int8_t version_diag
;
57 u_int8_t detect_time_multiplier
;
59 u_int8_t my_discriminator
[4];
60 u_int8_t your_discriminator
[4];
61 u_int8_t desired_min_tx_interval
[4];
62 u_int8_t required_min_rx_interval
[4];
63 u_int8_t required_min_echo_interval
[4];
66 #define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
67 #define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
69 static const struct tok bfd_port_values
[] = {
76 static const struct tok bfd_diag_values
[] = {
77 { 0, "No Diagnostic" },
78 { 1, "Control Detection Time Expired" },
79 { 2, "Echo Function Failed" },
80 { 3, "Neighbor Signaled Session Down" },
81 { 4, "Forwarding Plane Reset" },
83 { 6, "Concatenated Path Down" },
84 { 7, "Administratively Down" },
88 static const struct tok bfd_flag_values
[] = {
89 { 0x80, "I Hear You" },
101 bfd_print(register const u_char
*pptr
, register u_int len
, register u_int port
)
103 const struct bfd_header_t
*bfd_header
;
105 bfd_header
= (const struct bfd_header_t
*)pptr
;
110 printf("BFDv%u, %s, Flags: [%s], length: %u",
111 BFD_EXTRACT_VERSION(bfd_header
->version_diag
),
112 tok2str(bfd_port_values
, "unknown (%u)", port
),
113 bittok2str(bfd_flag_values
, "none", bfd_header
->flags
),
118 printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
119 BFD_EXTRACT_VERSION(bfd_header
->version_diag
),
121 tok2str(bfd_port_values
, "unknown (%u)", port
),
122 bittok2str(bfd_flag_values
, "none", bfd_header
->flags
),
123 tok2str(bfd_diag_values
,"unknown",BFD_EXTRACT_DIAG(bfd_header
->version_diag
)),
124 BFD_EXTRACT_DIAG(bfd_header
->version_diag
));
126 printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
127 bfd_header
->detect_time_multiplier
,
128 bfd_header
->detect_time_multiplier
* EXTRACT_32BITS(bfd_header
->desired_min_tx_interval
)/1000,
132 printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header
->my_discriminator
));
133 printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header
->your_discriminator
));
134 printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header
->desired_min_tx_interval
)/1000);
135 printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header
->required_min_rx_interval
)/1000);
136 printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header
->required_min_echo_interval
)/1000);