2 * Routines for Bidirectional Forwarding Detection (BFD) message dissection
4 * 5880: Bidirectional Forwarding Detection (BFD)
5 * 5881: Bidirectional Forwarding Detection (BFD) for IPv4 and IPv6 (Single Hop)
6 * 5882: Generic Application of Bidirectional Forwarding Detection (BFD)
7 * 5883: Bidirectional Forwarding Detection (BFD) for Multihop Paths
8 * 5884: Bidirectional Forwarding Detection (BFD) for MPLS Label Switched Paths (LSPs)
9 * 5885: Bidirectional Forwarding Detection (BFD) for the Pseudowire Virtual Circuit Connectivity Verification (VCCV)
10 * 7130: Bidirectional Forwarding Detection (BFD) on Link Aggregation Group (LAG) Interfaces
11 * 7881: Seamless Bidirectional Forwarding Detection (S-BFD) for IPv4, IPv6, and MPLS
12 * (and https://tools.ietf.org/html/draft-ietf-bfd-base-01 for version 0)
14 * Copyright 2003, Hannes Gredler <hannes@juniper.net>
15 * Copyright 2006, Balint Reczey <Balint.Reczey@ericsson.com>
16 * Copyright 2007, Todd J Martin <todd.martin@acm.org>
18 * Copyright 2011, Jaihari Kalijanakiraman <jaiharik@ipinfusion.com>
19 * Krishnamurthy Mayya <krishnamurthy.mayya@ipinfusion.com>
20 * Nikitha Malgi <malgi.nikitha@ipinfusion.com>
21 * - support for MPLS-TP BFD Proactive CV Message Format as per RFC 6428
22 * - includes decoding support for Section MEP-ID, LSP MEP-ID, PW MEP-ID
24 * Wireshark - Network traffic analyzer
25 * By Gerald Combs <gerald@wireshark.org>
26 * Copyright 1998 Gerald Combs
28 * SPDX-License-Identifier: GPL-2.0-or-later
33 #include <epan/packet.h>
34 #include <epan/expert.h>
36 #include <epan/unit_strings.h>
38 #include "packet-bfd.h"
39 #include "packet-mpls.h"
41 void proto_register_bfd(void);
42 void proto_reg_handoff_bfd(void);
44 static dissector_handle_t bfd_control_handle
;
45 static dissector_handle_t bfd_echo_handle
;
47 /* 3784: BFD control, 3785: BFD echo, 4784: BFD multi hop control */
48 /* 6784: BFD on LAG, 7784: seamless BFD */
49 /* https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=bfd */
50 #define UDP_PORT_RANGE_BFD_CTRL "3784,4784,6784,7784"
51 #define UDP_PORT_BFD_ECHO 3785
53 /* As per RFC 6428 : https://tools.ietf.org/html/rfc6428
55 #define TLV_TYPE_MPLSTP_SECTION_MEP 0
56 #define TLV_TYPE_MPLSTP_LSP_MEP 1
57 #define TLV_TYPE_MPLSTP_PW_MEP 2
59 static const value_string mplstp_mep_tlv_type_values
[] = {
60 { TLV_TYPE_MPLSTP_SECTION_MEP
, "Section MEP-ID" },
61 { TLV_TYPE_MPLSTP_LSP_MEP
, "LSP MEP-ID" },
62 { TLV_TYPE_MPLSTP_PW_MEP
, "PW MEP-ID" },
65 static const value_string bfd_control_v0_diag_values
[] = {
66 { 0, "No Diagnostic" },
67 { 1, "Control Detection Time Expired" },
68 { 2, "Echo Function Failed" },
69 { 3, "Neighbor Signaled Session Down" },
70 { 4, "Forwarding Plane Reset" },
72 { 6, "Concatenated Path Down" },
73 { 7, "Administratively Down" },
77 static const value_string bfd_control_v1_diag_values
[] = {
78 { 0, "No Diagnostic" },
79 { 1, "Control Detection Time Expired" },
80 { 2, "Echo Function Failed" },
81 { 3, "Neighbor Signaled Session Down" },
82 { 4, "Forwarding Plane Reset" },
84 { 6, "Concatenated Path Down" },
85 { 7, "Administratively Down" },
86 { 8, "Reverse Concatenated Path Down" },
87 { 9, "Mis-Connectivity Defect" },
91 static const value_string bfd_control_sta_values
[] = {
99 #define BFD_AUTH_SIMPLE 1
100 #define BFD_AUTH_MD5 2
101 #define BFD_AUTH_MET_MD5 3
102 #define BFD_AUTH_SHA1 4
103 #define BFD_AUTH_MET_SHA1 5
104 static const value_string bfd_control_auth_type_values
[] = {
105 { BFD_AUTH_SIMPLE
, "Simple Password" },
106 { BFD_AUTH_MD5
, "Keyed MD5" },
107 { BFD_AUTH_MET_MD5
, "Meticulous Keyed MD5" },
108 { BFD_AUTH_SHA1
, "Keyed SHA1" },
109 { BFD_AUTH_MET_SHA1
, "Meticulous Keyed SHA1" },
112 /* Per the standard, the simple password must by 1-16 bytes in length */
113 #define MAX_PASSWORD_LEN 16
114 /* Per the standard, the length of the MD5 authentication packets must be 24
115 * bytes and the checksum is 16 bytes */
116 #define MD5_AUTH_LEN 24
117 #define MD5_CHECKSUM_LEN 16
118 /* Per the standard, the length of the SHA1 authentication packets must be 28
119 * bytes and the checksum is 20 bytes */
120 #define SHA1_AUTH_LEN 28
121 #define SHA1_CHECKSUM_LEN 20
123 static int proto_bfd
;
124 static int proto_bfd_echo
;
126 static int hf_bfd_version
;
127 static int hf_bfd_diag
;
128 static int hf_bfd_sta
;
129 static int hf_bfd_flags
;
130 static int hf_bfd_flags_h
;
131 static int hf_bfd_flags_p
;
132 static int hf_bfd_flags_f
;
133 static int hf_bfd_flags_c
;
134 static int hf_bfd_flags_a
;
135 static int hf_bfd_flags_d
;
136 static int hf_bfd_flags_m
;
137 static int hf_bfd_flags_d_v0
;
138 static int hf_bfd_flags_p_v0
;
139 static int hf_bfd_flags_f_v0
;
140 static int hf_bfd_detect_time_multiplier
;
141 static int hf_bfd_message_length
;
142 static int hf_bfd_my_discriminator
;
143 static int hf_bfd_your_discriminator
;
144 static int hf_bfd_desired_min_tx_interval
;
145 static int hf_bfd_required_min_rx_interval
;
146 static int hf_bfd_required_min_echo_interval
;
147 static int hf_bfd_checksum
;
149 static int hf_bfd_auth_type
;
150 static int hf_bfd_auth_len
;
151 static int hf_bfd_auth_key
;
152 static int hf_bfd_auth_password
;
153 static int hf_bfd_auth_seq_num
;
155 static int hf_bfd_echo
;
158 static int ett_bfd_flags
;
159 static int ett_bfd_auth
;
161 static int ett_bfd_echo
;
163 static expert_field ei_bfd_auth_len_invalid
;
164 static expert_field ei_bfd_auth_no_data
;
166 static int hf_mep_type
;
167 static int hf_mep_len
;
168 static int hf_mep_global_id
;
169 static int hf_mep_node_id
;
170 /* static int hf_mep_interface_no; */
171 static int hf_mep_tunnel_no
;
172 static int hf_mep_lsp_no
;
173 static int hf_mep_ac_id
;
174 static int hf_mep_agi_type
;
175 static int hf_mep_agi_len
;
176 static int hf_mep_agi_val
;
177 static int hf_section_interface_no
;
179 * Control packet version 0, draft-katz-ward-bfd-01.txt
182 * 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
183 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
184 * |Vers | Diag |H|D|P|F| Rsvd | Detect Mult | Length |
185 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
186 * | My Discriminator |
187 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
188 * | Your Discriminator |
189 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
190 * | Desired Min TX Interval |
191 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
192 * | Required Min RX Interval |
193 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
194 * | Required Min Echo RX Interval |
195 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
199 * Control packet version 1, RFC 5880
202 * 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
203 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
204 * |Vers | Diag |Sta|P|F|C|A|D|M| Detect Mult | Length |
205 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
206 * | My Discriminator |
207 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
208 * | Your Discriminator |
209 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
210 * | Desired Min TX Interval |
211 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
212 * | Required Min RX Interval |
213 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
214 * | Required Min Echo RX Interval |
215 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
217 * An optional Authentication Section may be present:
219 * 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
220 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
221 * | Auth Type | Auth Len | Authentication Data... |
222 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
224 * There are 5 types of authentication defined:
225 * 1 - Simple Password
227 * 3 - Meticulous Keyed MD5
229 * 5 - Meticulous Keyed SHA1
231 * The format for Simple Password authentication is:
233 * 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
234 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
235 * | Auth Type | Auth Len | Auth Key ID | Password... |
236 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240 * The format for Keyed MD5 and Meticulous Keyed MD5 authentication is:
242 * 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
243 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
244 * | Auth Type | Auth Len | Auth Key ID | Reserved |
245 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
246 * | Sequence Number |
247 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
248 * | Auth Key/Checksum... |
249 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
251 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
253 * The format for Keyed SHA1 and Meticulous Keyed SHA1 authentication is:
255 * 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
256 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257 * | Auth Type | Auth Len | Auth Key ID | Reserved |
258 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259 * | Sequence Number |
260 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
261 * | Auth Key/Checksum... |
262 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
264 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
270 /* Given the type of authentication being used, return the required length of
271 * the authentication header
274 get_bfd_required_auth_len(uint8_t auth_type
)
276 uint8_t auth_len
= 0;
280 case BFD_AUTH_MET_MD5
:
281 auth_len
= MD5_AUTH_LEN
;
284 case BFD_AUTH_MET_SHA1
:
285 auth_len
= SHA1_AUTH_LEN
;
293 /* Given the type of authentication being used, return the length of
297 get_bfd_checksum_len(uint8_t auth_type
)
299 uint8_t checksum_len
= 0;
302 case BFD_AUTH_MET_MD5
:
303 checksum_len
= MD5_CHECKSUM_LEN
;
306 case BFD_AUTH_MET_SHA1
:
307 checksum_len
= SHA1_CHECKSUM_LEN
;
316 dissect_bfd_authentication(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
321 proto_item
*auth_item
= NULL
;
322 proto_tree
*auth_tree
= NULL
;
323 const uint8_t *password
;
325 auth_type
= tvb_get_uint8(tvb
, offset
);
326 auth_len
= tvb_get_uint8(tvb
, offset
+ 1);
329 auth_tree
= proto_tree_add_subtree_format(tree
, tvb
, offset
, auth_len
,
330 ett_bfd_auth
, NULL
, "Authentication: %s",
331 val_to_str(auth_type
,
332 bfd_control_auth_type_values
,
333 "Unknown Authentication Type (%d)") );
335 proto_tree_add_item(auth_tree
, hf_bfd_auth_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
337 proto_tree_add_item(auth_tree
, hf_bfd_auth_len
, tvb
, offset
+ 1, 1, ENC_BIG_ENDIAN
);
339 proto_tree_add_item(auth_tree
, hf_bfd_auth_key
, tvb
, offset
+ 2, 1, ENC_BIG_ENDIAN
);
343 case BFD_AUTH_SIMPLE
:
344 proto_tree_add_item_ret_string(auth_tree
, hf_bfd_auth_password
, tvb
, offset
+3,
345 auth_len
-3, ENC_ASCII
|ENC_NA
, pinfo
->pool
, &password
);
346 proto_item_append_text(auth_item
, ": %s", password
);
349 case BFD_AUTH_MET_MD5
:
351 case BFD_AUTH_MET_SHA1
:
352 if (auth_len
!= get_bfd_required_auth_len(auth_type
)) {
353 proto_tree_add_expert_format(auth_tree
, pinfo
, &ei_bfd_auth_len_invalid
, tvb
, offset
, auth_len
,
354 "Length of authentication section (%d) is invalid for Authentication Type: %s",
355 auth_len
, val_to_str(auth_type
, bfd_control_auth_type_values
, "Unknown Authentication Type (%d)") );
357 proto_item_append_text(auth_item
, ": Invalid Authentication Section");
361 proto_tree_add_item(auth_tree
, hf_bfd_auth_seq_num
, tvb
, offset
+4, 4, ENC_BIG_ENDIAN
);
363 proto_tree_add_item(auth_tree
, hf_bfd_checksum
, tvb
, offset
+8, get_bfd_checksum_len(auth_type
), ENC_NA
);
372 dissect_bfd_echo(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
374 proto_tree
*bfd_tree
= NULL
;
375 unsigned bfd_length
= tvb_reported_length_remaining(tvb
, 0);
377 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BFD Echo");
378 /* XXX Add direction */
379 col_set_str(pinfo
->cinfo
, COL_INFO
, "Originator specific content");
384 ti
= proto_tree_add_protocol_format(tree
, proto_bfd_echo
, tvb
, 0, bfd_length
,
387 bfd_tree
= proto_item_add_subtree(ti
, ett_bfd_echo
);
389 proto_tree_add_item(bfd_tree
, hf_bfd_echo
, tvb
, 0, bfd_length
, ENC_NA
);
396 dissect_bfd_control(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
399 unsigned bfd_version
;
401 unsigned bfd_sta
= 0;
403 unsigned bfd_flags_a
= 0;
404 unsigned bfd_detect_time_multiplier
;
406 unsigned bfd_my_discriminator
;
407 unsigned bfd_your_discriminator
;
408 unsigned bfd_desired_min_tx_interval
;
409 unsigned bfd_required_min_rx_interval
;
410 unsigned bfd_required_min_echo_interval
;
411 proto_tree
*bfd_tree
= NULL
;
413 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BFD Control");
414 col_clear(pinfo
->cinfo
, COL_INFO
);
416 bfd_version
= (tvb_get_uint8(tvb
, 0) & 0xe0) >> 5;
417 bfd_diag
= (tvb_get_uint8(tvb
, 0) & 0x1f);
418 flags
= tvb_get_uint8(tvb
, 1);
419 switch (bfd_version
) {
425 bfd_sta
= flags
& 0xc0;
426 bfd_flags
= flags
& 0x3e;
427 bfd_flags_a
= flags
& 0x04;
431 bfd_detect_time_multiplier
= tvb_get_uint8(tvb
, 2);
432 bfd_length
= tvb_get_uint8(tvb
, 3);
433 bfd_my_discriminator
= tvb_get_ntohl(tvb
, 4);
434 bfd_your_discriminator
= tvb_get_ntohl(tvb
, 8);
435 bfd_desired_min_tx_interval
= tvb_get_ntohl(tvb
, 12);
436 bfd_required_min_rx_interval
= tvb_get_ntohl(tvb
, 16);
437 bfd_required_min_echo_interval
= tvb_get_ntohl(tvb
, 20);
439 switch (bfd_version
) {
441 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Diag: %s, Flags: 0x%02x",
442 val_to_str_const(bfd_diag
, bfd_control_v0_diag_values
, "Unknown"),
447 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Diag: %s, State: %s, Flags: 0x%02x",
448 val_to_str_const(bfd_diag
, bfd_control_v1_diag_values
, "Unknown"),
449 val_to_str_const(bfd_sta
>> 6 , bfd_control_sta_values
, "Unknown"),
457 ti
= proto_tree_add_protocol_format(tree
, proto_bfd
, tvb
, 0, bfd_length
,
458 "BFD Control message");
460 bfd_tree
= proto_item_add_subtree(ti
, ett_bfd
);
462 proto_tree_add_uint(bfd_tree
, hf_bfd_version
, tvb
, 0,
463 1, bfd_version
<< 5);
465 proto_tree_add_uint(bfd_tree
, hf_bfd_diag
, tvb
, 0,
468 switch (bfd_version
) {
473 proto_tree_add_uint(bfd_tree
, hf_bfd_sta
, tvb
, 1,
478 switch (bfd_version
) {
481 static int * const bfd_message_flags
[] = {
488 proto_tree_add_bitmask_with_flags(bfd_tree
, tvb
, 1, hf_bfd_flags
, ett_bfd_flags
, bfd_message_flags
, ENC_NA
, BMT_NO_FALSE
);
494 static int * const bfd_message_flags
[] = {
503 proto_tree_add_bitmask_with_flags(bfd_tree
, tvb
, 1, hf_bfd_flags
, ett_bfd_flags
, bfd_message_flags
, ENC_NA
, BMT_NO_FALSE
);
508 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_detect_time_multiplier
, tvb
, 2,
509 1, bfd_detect_time_multiplier
,
510 "%u (= %u ms Detection time)",
511 bfd_detect_time_multiplier
,
512 bfd_detect_time_multiplier
* (bfd_desired_min_tx_interval
/1000));
514 proto_tree_add_uint(bfd_tree
, hf_bfd_message_length
, tvb
, 3, 1, bfd_length
);
516 proto_tree_add_uint(bfd_tree
, hf_bfd_my_discriminator
, tvb
, 4,
517 4, bfd_my_discriminator
);
519 proto_tree_add_uint(bfd_tree
, hf_bfd_your_discriminator
, tvb
, 8,
520 4, bfd_your_discriminator
);
522 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_desired_min_tx_interval
, tvb
, 12,
523 4, bfd_desired_min_tx_interval
,
525 bfd_desired_min_tx_interval
/1000,
526 bfd_desired_min_tx_interval
);
528 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_required_min_rx_interval
, tvb
, 16,
529 4, bfd_required_min_rx_interval
,
531 bfd_required_min_rx_interval
/1000,
532 bfd_required_min_rx_interval
);
534 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_required_min_echo_interval
, tvb
, 20,
535 4, bfd_required_min_echo_interval
,
537 bfd_required_min_echo_interval
/1000,
538 bfd_required_min_echo_interval
);
541 /* Dissect the authentication fields if the Authentication flag has
544 if (bfd_version
&& bfd_flags_a
) {
545 if (bfd_length
>= 28) {
546 dissect_bfd_authentication(tvb
, pinfo
, bfd_tree
);
548 proto_tree_add_expert_format(bfd_tree
, pinfo
, &ei_bfd_auth_no_data
, tvb
, 24, bfd_length
-24,
549 "Authentication: Length of the BFD frame is invalid (%d)", bfd_length
);
553 return tvb_captured_length(tvb
);
556 /* BFD CV Source MEP-ID TLV Decoder,
557 As per RFC 6428 : https://tools.ietf.org/html/rfc6428
558 sections - 3.5.1, 3.5.2, 3.5.3 */
560 dissect_bfd_mep (tvbuff_t
*tvb
, proto_tree
*tree
, const int hfindex
)
563 proto_tree
*bfd_tree
;
572 /* Fetch the BFD control message length and move the offset
573 to point to the data portion after the control message */
575 /* The parameter hfindex is used for determining the tree under which MEP-ID TLV
576 has to be determined. Since according to RFC 6428, MEP-ID TLV can be used by any
577 OAM function, if hfindex is 0, as per this function the MEP-TLV is a part of
578 BFD-CV payload. If a non-zero hfindex comes, then tht TLV info will be displayed
579 under a particular protocol-tree. */
582 offset
= tvb_get_uint8(tvb
, 3);
583 mep_type
= tvb_get_ntohs (tvb
, offset
);
584 mep_len
= tvb_get_ntohs (tvb
, (offset
+ 2));
585 ti
= proto_tree_add_protocol_format (tree
, proto_bfd
, tvb
, offset
, (mep_len
+ 4),
586 "MPLS-TP SOURCE MEP-ID TLV");
590 mep_type
= tvb_get_ntohs (tvb
, offset
);
591 mep_len
= tvb_get_ntohs (tvb
, (offset
+ 2));
592 ti
= proto_tree_add_protocol_format (tree
, hfindex
, tvb
, offset
, (mep_len
+ 4),
593 "MPLS-TP SOURCE MEP-ID TLV");
597 case TLV_TYPE_MPLSTP_SECTION_MEP
:
599 bfd_tree
= proto_item_add_subtree (ti
, ett_bfd
);
600 proto_tree_add_uint (bfd_tree
, hf_mep_type
, tvb
, offset
,
602 proto_tree_add_uint (bfd_tree
, hf_mep_len
, tvb
, (offset
+ 2),
604 proto_tree_add_item (bfd_tree
, hf_mep_global_id
, tvb
, (offset
+ 4),
606 proto_tree_add_item (bfd_tree
, hf_mep_node_id
, tvb
, (offset
+ 8),
608 proto_tree_add_item (bfd_tree
, hf_section_interface_no
, tvb
, (offset
+ 12),
613 case TLV_TYPE_MPLSTP_LSP_MEP
:
615 bfd_tree
= proto_item_add_subtree (ti
, ett_bfd
);
616 proto_tree_add_uint (bfd_tree
, hf_mep_type
, tvb
, offset
,
618 proto_tree_add_uint (bfd_tree
, hf_mep_len
, tvb
, (offset
+ 2),
620 proto_tree_add_item (bfd_tree
, hf_mep_global_id
, tvb
, (offset
+ 4),
622 proto_tree_add_item (bfd_tree
, hf_mep_node_id
, tvb
, (offset
+ 8),
624 proto_tree_add_item (bfd_tree
, hf_mep_tunnel_no
, tvb
, (offset
+ 12),
626 proto_tree_add_item (bfd_tree
, hf_mep_lsp_no
, tvb
, (offset
+ 14),
631 case TLV_TYPE_MPLSTP_PW_MEP
:
633 mep_agi_len
= tvb_get_uint8 (tvb
, (offset
+ 17));
634 bfd_tree
= proto_item_add_subtree (ti
, ett_bfd
);
635 proto_tree_add_uint (bfd_tree
, hf_mep_type
, tvb
, offset
,
637 proto_tree_add_uint (bfd_tree
, hf_mep_len
, tvb
, (offset
+ 2),
639 proto_tree_add_item (bfd_tree
, hf_mep_global_id
, tvb
, (offset
+ 4),
641 proto_tree_add_item (bfd_tree
, hf_mep_node_id
, tvb
, (offset
+ 8),
643 proto_tree_add_item (bfd_tree
, hf_mep_ac_id
, tvb
, (offset
+ 12),
645 proto_tree_add_item (bfd_tree
, hf_mep_agi_type
, tvb
, (offset
+ 16),
647 proto_tree_add_uint (bfd_tree
, hf_mep_agi_len
, tvb
, (offset
+ 17),
649 proto_tree_add_item (bfd_tree
, hf_mep_agi_val
, tvb
, (offset
+ 18),
650 mep_agi_len
, ENC_ASCII
);
660 /* Register the protocol with Wireshark */
662 proto_register_bfd(void)
665 /* Setup list of header fields */
666 static hf_register_info hf
[] = {
668 { "Protocol Version", "bfd.version",
669 FT_UINT8
, BASE_DEC
, NULL
, 0xe0,
670 "The version number of the BFD protocol", HFILL
}
673 { "Diagnostic Code", "bfd.diag",
674 FT_UINT8
, BASE_HEX
, VALS(bfd_control_v1_diag_values
), 0x1f,
675 "This field give the reason for a BFD session failure", HFILL
}
678 { "Session State", "bfd.sta",
679 FT_UINT8
, BASE_HEX
, VALS(bfd_control_sta_values
), 0xc0,
680 "The BFD state as seen by the transmitting system", HFILL
}
683 { "Message Flags", "bfd.flags",
684 FT_UINT8
, BASE_HEX
, NULL
, 0x00,
688 { "I hear you", "bfd.flags.h",
689 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x80,
692 { &hf_bfd_flags_d_v0
,
693 { "Demand", "bfd.flags.d",
694 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x40,
697 { &hf_bfd_flags_p_v0
,
698 { "Poll", "bfd.flags.p",
699 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x20,
702 { &hf_bfd_flags_f_v0
,
703 { "Final", "bfd.flags.f",
704 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x10,
708 { "Poll", "bfd.flags.p",
709 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x20, /* 6 flag bits; Sta is shown separately */
710 "If set, the transmitting system is expecting a packet with the Final (F) bit in reply",
714 { "Final", "bfd.flags.f",
715 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x10, /* 6 flag bits; Sta is shown separately */
716 "If set, the transmitting system is replying to a packet with the Poll (P) bit set",
720 { "Control Plane Independent", "bfd.flags.c",
721 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x08, /* 6 flag bits; Sta is shown separately */
722 "If set, the BFD implementation is implemented in the forwarding plane", HFILL
}
725 { "Authentication Present", "bfd.flags.a",
726 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x04, /* 6 flag bits; Sta is shown separately */
727 "The Authentication Section is present", HFILL
}
730 { "Demand", "bfd.flags.d",
731 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x02, /* 6 flag bits; Sta is shown separately */
732 "If set, Demand mode is active in the transmitting system", HFILL
}
735 { "Multipoint", "bfd.flags.m",
736 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x01, /* 6 flag bits; Sta is shown separately */
737 "Reserved for future point-to-multipoint extensions", HFILL
}
739 { &hf_bfd_detect_time_multiplier
,
740 { "Detect Time Multiplier", "bfd.detect_time_multiplier",
741 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
742 "The transmit interval multiplied by this value is the failure detection time", HFILL
}
744 { &hf_bfd_message_length
,
745 { "Message Length", "bfd.message_length",
746 FT_UINT8
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_byte_bytes
), 0x0,
747 "Length of the BFD Control packet, in bytes", HFILL
}
749 { &hf_bfd_my_discriminator
,
750 { "My Discriminator", "bfd.my_discriminator",
751 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
754 { &hf_bfd_your_discriminator
,
755 { "Your Discriminator", "bfd.your_discriminator",
756 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
759 { &hf_bfd_desired_min_tx_interval
,
760 { "Desired Min TX Interval", "bfd.desired_min_tx_interval",
761 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
762 "The minimum interval to use when transmitting BFD Control packets", HFILL
}
764 { &hf_bfd_required_min_rx_interval
,
765 { "Required Min RX Interval", "bfd.required_min_rx_interval",
766 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
767 "The minimum interval between received BFD Control packets that this system can support", HFILL
}
769 { &hf_bfd_required_min_echo_interval
,
770 { "Required Min Echo Interval", "bfd.required_min_echo_interval",
771 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
772 "The minimum interval between received BFD Echo packets that this system can support", HFILL
}
775 { "Checksum", "bfd.checksum",
776 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
780 { "Authentication Type", "bfd.auth.type",
781 FT_UINT8
, BASE_DEC
, VALS(bfd_control_auth_type_values
), 0x0,
782 "The type of authentication in use on this session", HFILL
}
785 { "Authentication Length", "bfd.auth.len",
786 FT_UINT8
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_byte_bytes
), 0x0,
787 "The length, in bytes, of the authentication section", HFILL
}
790 { "Authentication Key ID", "bfd.auth.key",
791 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
792 "The Authentication Key ID, identifies which password is in use for this packet", HFILL
}
794 { &hf_bfd_auth_password
,
795 { "Password", "bfd.auth.password",
796 FT_STRING
, BASE_NONE
, NULL
, 0x0,
797 "The simple password in use on this session", HFILL
}
799 { &hf_bfd_auth_seq_num
,
800 { "Sequence Number", "bfd.auth.seq_num",
801 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
802 "The Sequence Number is periodically incremented to prevent replay attacks", HFILL
}
805 { "Type", "bfd.mep.type",
806 FT_UINT16
, BASE_DEC
, VALS(mplstp_mep_tlv_type_values
), 0x0,
807 "The type of the MEP Id", HFILL
}
810 { "Length", "bfd.mep.len",
811 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
812 "The length of the MEP Id", HFILL
}
815 { "Global Id", "bfd.mep.global.id",
816 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
817 "MPLS-TP Global MEP Id", HFILL
}
820 { "Node Id", "bfd.mep.node.id",
821 FT_IPv4
, BASE_NONE
, NULL
, 0x0,
822 "MPLS-TP Node Identifier", HFILL
}
825 { &hf_mep_interface_no
,
826 { "Interface Number", "bfd.mep.interface.no",
827 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
828 "MPLS-TP Interface Number", HFILL
}
832 { "Tunnel Number", "bfd.mep.tunnel.no",
833 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
837 { "LSP Number", "bfd.mep.lsp.no",
838 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
842 { "AC Id", "bfd.mep.ac.id",
843 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
847 { "AGI TYPE", "bfd.mep.agi.type",
848 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
852 { "AGI Length", "bfd.mep.agi.len",
853 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
857 { "AGI value", "bfd.mep.agi.val",
858 FT_STRING
, BASE_NONE
, NULL
, 0x0,
861 { &hf_section_interface_no
,
862 { "Interface Number", "bfd.mep.interface.no",
863 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
864 "MPLS-TP Interface Number", HFILL
}
868 static hf_register_info hf_echo
[] = {
870 { "Echo", "bfd_echo.packet",
871 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
872 "Originator specific echo packet", HFILL
}
876 /* Setup protocol subtree array */
877 static int *ett
[] = {
884 static ei_register_info ei
[] = {
885 { &ei_bfd_auth_len_invalid
, { "bfd.auth.len.invalid", PI_MALFORMED
, PI_WARN
, "Length of authentication section is invalid", EXPFILL
}},
886 { &ei_bfd_auth_no_data
, { "bfd.auth.no_data", PI_MALFORMED
, PI_WARN
, "Authentication flag is set in a BFD packet, but no authentication data is present", EXPFILL
}},
889 expert_module_t
* expert_bfd
;
891 /* Register the protocol name and description */
892 proto_bfd
= proto_register_protocol("Bidirectional Forwarding Detection Control Message",
895 proto_bfd_echo
= proto_register_protocol("Bidirectional Forwarding Detection Echo Packet",
899 /* Required function calls to register the header fields and subtrees used */
900 proto_register_field_array(proto_bfd
, hf
, array_length(hf
));
901 proto_register_field_array(proto_bfd_echo
, hf_echo
, array_length(hf_echo
));
902 proto_register_subtree_array(ett
, array_length(ett
));
903 expert_bfd
= expert_register_protocol(proto_bfd
);
904 expert_register_field_array(expert_bfd
, ei
, array_length(ei
));
906 /* Register dissectors */
907 bfd_control_handle
= register_dissector("bfd", dissect_bfd_control
, proto_bfd
);
908 bfd_echo_handle
= register_dissector("bfd_echo", dissect_bfd_echo
, proto_bfd_echo
);
912 proto_reg_handoff_bfd(void)
914 dissector_add_uint_range_with_preference("udp.port", UDP_PORT_RANGE_BFD_CTRL
, bfd_control_handle
);
915 dissector_add_uint("udp.port", UDP_PORT_BFD_ECHO
, bfd_echo_handle
);
917 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_BFD_CC
, bfd_control_handle
);
918 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_BFD_CV
, bfd_control_handle
);
919 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_BFD
, bfd_control_handle
);
923 * Editor modelines - https://www.wireshark.org/tools/modelines.html
928 * indent-tabs-mode: nil
931 * vi: set shiftwidth=4 tabstop=8 expandtab:
932 * :indentSize=4:tabSize=8:noTabs=true: