2 * Routines for Bidirectional Forwarding Detection (BFD) message dissection
3 * RFCs 5880, 5881, 5882, 5883, 5884, 5885
4 * (and http://tools.ietf.org/html/draft-ietf-bfd-base-01 for version 0)
6 * Copyright 2003, Hannes Gredler <hannes@juniper.net>
7 * Copyright 2006, Balint Reczey <Balint.Reczey@ericsson.com>
8 * Copyright 2007, Todd J Martin <todd.martin@acm.org>
10 * Copyright 2011, Jaihari Kalijanakiraman <jaiharik@ipinfusion.com>
11 * Krishnamurthy Mayya <krishnamurthy.mayya@ipinfusion.com>
12 * Nikitha Malgi <malgi.nikitha@ipinfusion.com>
13 * - support for MPLS-TP BFD Proactive CV Message Format as per RFC 6428
14 * - includes decoding support for Section MEP-ID, LSP MEP-ID, PW MEP-ID
18 * Wireshark - Network traffic analyzer
19 * By Gerald Combs <gerald@wireshark.org>
20 * Copyright 1998 Gerald Combs
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * as published by the Free Software Foundation; either version 2
25 * of the License, or (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
41 #include <epan/packet.h>
42 #include <epan/expert.h>
44 #include "packet-bfd.h"
46 void proto_register_bfd(void);
47 void proto_reg_handoff_bfd(void);
49 #define UDP_PORT_BFD_1HOP_CONTROL 3784 /* draft-katz-ward-bfd-v4v6-1hop-00.txt */
50 #define UDP_PORT_BFD_MULTIHOP_CONTROL 4784 /* draft-ietf-bfd-multihop-05.txt */
52 /* As per RFC 6428 : http://tools.ietf.org/html/rfc6428
54 #define TLV_TYPE_MPLSTP_SECTION_MEP 0
55 #define TLV_TYPE_MPLSTP_LSP_MEP 1
56 #define TLV_TYPE_MPLSTP_PW_MEP 2
58 static const value_string mplstp_mep_tlv_type_values
[] = {
59 { TLV_TYPE_MPLSTP_SECTION_MEP
, "Section MEP-ID" },
60 { TLV_TYPE_MPLSTP_LSP_MEP
, "LSP MEP-ID" },
61 { TLV_TYPE_MPLSTP_PW_MEP
, "PW MEP-ID" },
64 static const value_string bfd_control_v0_diag_values
[] = {
65 { 0, "No Diagnostic" },
66 { 1, "Control Detection Time Expired" },
67 { 2, "Echo Function Failed" },
68 { 3, "Neighbor Signaled Session Down" },
69 { 4, "Forwarding Plane Reset" },
71 { 6, "Concatenated Path Down" },
72 { 7, "Administratively Down" },
76 static const value_string bfd_control_v1_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" },
85 { 8, "Reverse Concatenated Path Down" },
86 { 9, "Mis-Connectivity Defect" },
90 static const value_string bfd_control_sta_values
[] = {
98 #define BFD_AUTH_SIMPLE 1
99 #define BFD_AUTH_MD5 2
100 #define BFD_AUTH_MET_MD5 3
101 #define BFD_AUTH_SHA1 4
102 #define BFD_AUTH_MET_SHA1 5
103 static const value_string bfd_control_auth_type_values
[] = {
104 { BFD_AUTH_SIMPLE
, "Simple Password" },
105 { BFD_AUTH_MD5
, "Keyed MD5" },
106 { BFD_AUTH_MET_MD5
, "Meticulous Keyed MD5" },
107 { BFD_AUTH_SHA1
, "Keyed SHA1" },
108 { BFD_AUTH_MET_SHA1
, "Meticulous Keyed SHA1" },
111 /* Per the standard, the simple password must by 1-16 bytes in length */
112 #define MAX_PASSWORD_LEN 16
113 /* Per the standard, the length of the MD5 authentication packets must be 24
114 * bytes and the checksum is 16 bytes */
115 #define MD5_AUTH_LEN 24
116 #define MD5_CHECKSUM_LEN 16
117 /* Per the standard, the length of the SHA1 authentication packets must be 28
118 * bytes and the checksum is 20 bytes */
119 #define SHA1_AUTH_LEN 28
120 #define SHA1_CHECKSUM_LEN 20
122 #define APPEND_BOOLEAN_FLAG(flag, item, string) \
125 proto_item_append_text(item, string, sep); \
128 static const char *const initial_sep
= " (";
129 static const char *const cont_sep
= ", ";
131 static gint proto_bfd
= -1;
133 static gint hf_bfd_version
= -1;
134 static gint hf_bfd_diag
= -1;
135 static gint hf_bfd_sta
= -1;
136 /* static gint hf_bfd_flags = -1; */
137 static gint hf_bfd_flags_h
= -1;
138 static gint hf_bfd_flags_p
= -1;
139 static gint hf_bfd_flags_f
= -1;
140 static gint hf_bfd_flags_c
= -1;
141 static gint hf_bfd_flags_a
= -1;
142 static gint hf_bfd_flags_d
= -1;
143 static gint hf_bfd_flags_m
= -1;
144 static gint hf_bfd_flags_d_v0
= -1;
145 static gint hf_bfd_flags_p_v0
= -1;
146 static gint hf_bfd_flags_f_v0
= -1;
147 static gint hf_bfd_detect_time_multiplier
= -1;
148 static gint hf_bfd_message_length
= -1;
149 static gint hf_bfd_my_discriminator
= -1;
150 static gint hf_bfd_your_discriminator
= -1;
151 static gint hf_bfd_desired_min_tx_interval
= -1;
152 static gint hf_bfd_required_min_rx_interval
= -1;
153 static gint hf_bfd_required_min_echo_interval
= -1;
155 static gint hf_bfd_auth_type
= -1;
156 static gint hf_bfd_auth_len
= -1;
157 static gint hf_bfd_auth_key
= -1;
158 static gint hf_bfd_auth_password
= -1;
159 static gint hf_bfd_auth_seq_num
= -1;
161 static gint ett_bfd
= -1;
162 static gint ett_bfd_flags
= -1;
163 static gint ett_bfd_auth
= -1;
165 static expert_field ei_bfd_auth_len_invalid
= EI_INIT
;
166 static expert_field ei_bfd_auth_no_data
= EI_INIT
;
168 static gint hf_mep_type
= -1;
169 static gint hf_mep_len
= -1;
170 static gint hf_mep_global_id
= -1;
171 static gint hf_mep_node_id
= -1;
172 /* static gint hf_mep_interface_no = -1; */
173 static gint hf_mep_tunnel_no
= -1;
174 static gint hf_mep_lsp_no
= -1;
175 static gint hf_mep_ac_id
= -1;
176 static gint hf_mep_agi_type
= -1;
177 static gint hf_mep_agi_len
= -1;
178 static gint hf_mep_agi_val
= -1;
179 static gint hf_section_interface_no
= -1;
181 * Control packet version 0, draft-katz-ward-bfd-01.txt
184 * 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
185 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
186 * |Vers | Diag |H|D|P|F| Rsvd | Detect Mult | Length |
187 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
188 * | My Discriminator |
189 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
190 * | Your Discriminator |
191 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
192 * | Desired Min TX Interval |
193 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
194 * | Required Min RX Interval |
195 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
196 * | Required Min Echo RX Interval |
197 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201 * Control packet version 1, draft-ietf-bfd-base-04.txt
204 * 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
205 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
206 * |Vers | Diag |Sta|P|F|C|A|D|R| Detect Mult | Length |
207 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
208 * | My Discriminator |
209 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
210 * | Your Discriminator |
211 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
212 * | Desired Min TX Interval |
213 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
214 * | Required Min RX Interval |
215 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
216 * | Required Min Echo RX Interval |
217 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
219 * An optional Authentication Section may be present:
221 * 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
222 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
223 * | Auth Type | Auth Len | Authentication Data... |
224 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
226 * There are 5 types of authentication defined:
227 * 1 - Simple Password
229 * 3 - Meticulous Keyed MD5
231 * 5 - Meticulous Keyed SHA1
233 * The format for Simple Password authentication is:
235 * 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
236 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
237 * | Auth Type | Auth Len | Auth Key ID | Password... |
238 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242 * The format for Keyed MD5 and Meticulous Keyed MD5 authentication is:
244 * 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
245 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
246 * | Auth Type | Auth Len | Auth Key ID | Reserved |
247 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
248 * | Sequence Number |
249 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
250 * | Auth Key/Checksum... |
251 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
253 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
255 * The format for Keyed SHA1 and Meticulous Keyed SHA1 authentication is:
257 * 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
258 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259 * | Auth Type | Auth Len | Auth Key ID | Reserved |
260 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
261 * | Sequence Number |
262 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
263 * | Auth Key/Checksum... |
264 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
266 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
272 /* Given the type of authentication being used, return the required length of
273 * the authentication header
276 get_bfd_required_auth_len(guint8 auth_type
)
282 case BFD_AUTH_MET_MD5
:
283 auth_len
= MD5_AUTH_LEN
;
286 case BFD_AUTH_MET_SHA1
:
287 auth_len
= SHA1_AUTH_LEN
;
295 /* Given the type of authentication being used, return the length of
299 get_bfd_checksum_len(guint8 auth_type
)
301 guint8 checksum_len
= 0;
304 case BFD_AUTH_MET_MD5
:
305 checksum_len
= MD5_CHECKSUM_LEN
;
308 case BFD_AUTH_MET_SHA1
:
309 checksum_len
= SHA1_CHECKSUM_LEN
;
318 dissect_bfd_authentication(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
323 proto_item
*ti
= NULL
;
324 proto_item
*auth_item
= NULL
;
325 proto_tree
*auth_tree
= NULL
;
328 auth_type
= tvb_get_guint8(tvb
, offset
);
329 auth_len
= tvb_get_guint8(tvb
, offset
+ 1);
332 auth_item
= proto_tree_add_text(tree
, tvb
, offset
, auth_len
, "Authentication: %s",
333 val_to_str(auth_type
,
334 bfd_control_auth_type_values
,
335 "Unknown Authentication Type (%d)") );
336 auth_tree
= proto_item_add_subtree(auth_item
, ett_bfd_auth
);
338 proto_tree_add_item(auth_tree
, hf_bfd_auth_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
340 ti
= proto_tree_add_item(auth_tree
, hf_bfd_auth_len
, tvb
, offset
+ 1, 1, ENC_BIG_ENDIAN
);
341 proto_item_append_text(ti
, " bytes");
343 proto_tree_add_item(auth_tree
, hf_bfd_auth_key
, tvb
, offset
+ 2, 1, ENC_BIG_ENDIAN
);
347 case BFD_AUTH_SIMPLE
:
349 password
= tvb_get_string(wmem_packet_scope(), tvb
, offset
+3, auth_len
-3);
350 proto_tree_add_string(auth_tree
, hf_bfd_auth_password
, tvb
, offset
+3,
351 auth_len
-3, password
);
352 proto_item_append_text(auth_item
, ": %s", password
);
356 case BFD_AUTH_MET_MD5
:
358 case BFD_AUTH_MET_SHA1
:
359 if (auth_len
!= get_bfd_required_auth_len(auth_type
)) {
361 ti
= proto_tree_add_text(auth_tree
, tvb
, offset
, auth_len
,
362 "Length of authentication is invalid (%d)", auth_len
);
363 proto_item_append_text(auth_item
, ": Invalid Authentication Section");
365 expert_add_info_format(pinfo
, ti
, &ei_bfd_auth_len_invalid
,
366 "Length of authentication section is invalid for Authentication Type: %s",
367 val_to_str(auth_type
, bfd_control_auth_type_values
, "Unknown Authentication Type (%d)") );
371 proto_tree_add_item(auth_tree
, hf_bfd_auth_seq_num
, tvb
, offset
+4, 4, ENC_BIG_ENDIAN
);
373 proto_tree_add_text(auth_tree
, tvb
, offset
+8, get_bfd_checksum_len(auth_type
), "Checksum: 0x%s",
374 tvb_bytes_to_str(tvb
, offset
+8, get_bfd_checksum_len(auth_type
)) );
384 dissect_bfd_control(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
391 guint bfd_flags_h
= 0;
392 guint bfd_flags_p
= 0;
393 guint bfd_flags_f
= 0;
394 guint bfd_flags_c
= 0;
395 guint bfd_flags_a
= 0;
396 guint bfd_flags_d
= 0;
397 guint bfd_flags_m
= 0;
398 guint bfd_flags_d_v0
= 0;
399 guint bfd_flags_p_v0
= 0;
400 guint bfd_flags_f_v0
= 0;
401 guint bfd_detect_time_multiplier
;
403 guint bfd_my_discriminator
;
404 guint bfd_your_discriminator
;
405 guint bfd_desired_min_tx_interval
;
406 guint bfd_required_min_rx_interval
;
407 guint bfd_required_min_echo_interval
;
408 proto_tree
*bfd_tree
= NULL
;
410 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BFD Control");
411 col_clear(pinfo
->cinfo
, COL_INFO
);
413 bfd_version
= (tvb_get_guint8(tvb
, 0) & 0xe0) >> 5;
414 bfd_diag
= (tvb_get_guint8(tvb
, 0) & 0x1f);
415 flags
= tvb_get_guint8(tvb
, 1);
416 switch (bfd_version
) {
419 bfd_flags_h
= flags
& 0x80;
420 bfd_flags_d_v0
= flags
& 0x40;
421 bfd_flags_p_v0
= flags
& 0x20;
422 bfd_flags_f_v0
= flags
& 0x10;
426 bfd_sta
= flags
& 0xc0;
427 bfd_flags
= flags
& 0x3e;
428 bfd_flags_p
= flags
& 0x20;
429 bfd_flags_f
= flags
& 0x10;
430 bfd_flags_c
= flags
& 0x08;
431 bfd_flags_a
= flags
& 0x04;
432 bfd_flags_d
= flags
& 0x02;
433 bfd_flags_m
= flags
& 0x01;
437 bfd_detect_time_multiplier
= tvb_get_guint8(tvb
, 2);
438 bfd_length
= tvb_get_guint8(tvb
, 3);
439 bfd_my_discriminator
= tvb_get_ntohl(tvb
, 4);
440 bfd_your_discriminator
= tvb_get_ntohl(tvb
, 8);
441 bfd_desired_min_tx_interval
= tvb_get_ntohl(tvb
, 12);
442 bfd_required_min_rx_interval
= tvb_get_ntohl(tvb
, 16);
443 bfd_required_min_echo_interval
= tvb_get_ntohl(tvb
, 20);
445 switch (bfd_version
) {
447 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Diag: %s, Flags: 0x%02x",
448 val_to_str_const(bfd_diag
, bfd_control_v0_diag_values
, "Unknown"),
453 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Diag: %s, State: %s, Flags: 0x%02x",
454 val_to_str_const(bfd_diag
, bfd_control_v1_diag_values
, "Unknown"),
455 val_to_str_const(bfd_sta
>> 6 , bfd_control_sta_values
, "Unknown"),
462 proto_tree
*bfd_flags_tree
;
465 ti
= proto_tree_add_protocol_format(tree
, proto_bfd
, tvb
, 0, bfd_length
,
466 "BFD Control message");
468 bfd_tree
= proto_item_add_subtree(ti
, ett_bfd
);
470 proto_tree_add_uint(bfd_tree
, hf_bfd_version
, tvb
, 0,
471 1, bfd_version
<< 5);
473 proto_tree_add_uint(bfd_tree
, hf_bfd_diag
, tvb
, 0,
476 switch (bfd_version
) {
481 proto_tree_add_uint(bfd_tree
, hf_bfd_sta
, tvb
, 1,
486 switch (bfd_version
) {
488 ti
= proto_tree_add_text ( bfd_tree
, tvb
, 1, 1, "Message Flags: 0x%02x",
490 bfd_flags_tree
= proto_item_add_subtree(ti
, ett_bfd_flags
);
491 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_h
, tvb
, 1, 1, bfd_flags_h
);
492 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_d_v0
, tvb
, 1, 1, bfd_flags_d_v0
);
493 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_p_v0
, tvb
, 1, 1, bfd_flags_p_v0
);
494 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_f_v0
, tvb
, 1, 1, bfd_flags_f_v0
);
497 APPEND_BOOLEAN_FLAG(bfd_flags_h
, ti
, "%sH");
498 APPEND_BOOLEAN_FLAG(bfd_flags_d_v0
, ti
, "%sD");
499 APPEND_BOOLEAN_FLAG(bfd_flags_p_v0
, ti
, "%sP");
500 APPEND_BOOLEAN_FLAG(bfd_flags_f_v0
, ti
, "%sF");
501 if (sep
!= initial_sep
) {
502 proto_item_append_text (ti
, ")");
507 ti
= proto_tree_add_text ( bfd_tree
, tvb
, 1, 1, "Message Flags: 0x%02x",
509 bfd_flags_tree
= proto_item_add_subtree(ti
, ett_bfd_flags
);
510 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_p
, tvb
, 1, 1, bfd_flags_p
);
511 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_f
, tvb
, 1, 1, bfd_flags_f
);
512 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_c
, tvb
, 1, 1, bfd_flags_c
);
513 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_a
, tvb
, 1, 1, bfd_flags_a
);
514 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_d
, tvb
, 1, 1, bfd_flags_d
);
515 proto_tree_add_boolean(bfd_flags_tree
, hf_bfd_flags_m
, tvb
, 1, 1, bfd_flags_m
);
518 APPEND_BOOLEAN_FLAG(bfd_flags_p
, ti
, "%sP");
519 APPEND_BOOLEAN_FLAG(bfd_flags_f
, ti
, "%sF");
520 APPEND_BOOLEAN_FLAG(bfd_flags_c
, ti
, "%sC");
521 APPEND_BOOLEAN_FLAG(bfd_flags_a
, ti
, "%sA");
522 APPEND_BOOLEAN_FLAG(bfd_flags_d
, ti
, "%sD");
523 APPEND_BOOLEAN_FLAG(bfd_flags_m
, ti
, "%sM");
524 if (sep
!= initial_sep
) {
525 proto_item_append_text (ti
, ")");
530 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_detect_time_multiplier
, tvb
, 2,
531 1, bfd_detect_time_multiplier
,
532 "%u (= %u ms Detection time)",
533 bfd_detect_time_multiplier
,
534 bfd_detect_time_multiplier
* (bfd_desired_min_tx_interval
/1000));
536 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_message_length
, tvb
, 3, 1, bfd_length
,
537 "%u bytes", bfd_length
);
539 proto_tree_add_uint(bfd_tree
, hf_bfd_my_discriminator
, tvb
, 4,
540 4, bfd_my_discriminator
);
542 proto_tree_add_uint(bfd_tree
, hf_bfd_your_discriminator
, tvb
, 8,
543 4, bfd_your_discriminator
);
545 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_desired_min_tx_interval
, tvb
, 12,
546 4, bfd_desired_min_tx_interval
,
548 bfd_desired_min_tx_interval
/1000,
549 bfd_desired_min_tx_interval
);
551 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_required_min_rx_interval
, tvb
, 16,
552 4, bfd_required_min_rx_interval
,
554 bfd_required_min_rx_interval
/1000,
555 bfd_required_min_rx_interval
);
557 proto_tree_add_uint_format_value(bfd_tree
, hf_bfd_required_min_echo_interval
, tvb
, 20,
558 4, bfd_required_min_echo_interval
,
560 bfd_required_min_echo_interval
/1000,
561 bfd_required_min_echo_interval
);
564 /* Dissect the authentication fields if the Authentication flag has
567 if (bfd_version
&& bfd_flags_a
) {
568 if (bfd_length
>= 28) {
569 dissect_bfd_authentication(tvb
, pinfo
, bfd_tree
);
571 proto_item
*ti
= proto_tree_add_text(bfd_tree
, tvb
, 24, bfd_length
-24,
572 "Authentication: Length of the BFD frame is invalid (%d)", bfd_length
);
573 expert_add_info(pinfo
, ti
, &ei_bfd_auth_no_data
);
580 /* BFD CV Source MEP-ID TLV Decoder,
581 As per RFC 6428 : http://tools.ietf.org/html/rfc6428
582 sections - 3.5.1, 3.5.2, 3.5.3 */
584 dissect_bfd_mep (tvbuff_t
*tvb
, proto_tree
*tree
, const int hfindex
)
587 proto_tree
*bfd_tree
;
596 /* Fetch the BFD control message length and move the offset
597 to point to the data portion after the control message */
599 /* The parameter hfindex is used for determining the tree under which MEP-ID TLV
600 has to be determined. Since according to RFC 6428, MEP-ID TLV can be used by any
601 OAM function, if hfindex is 0, as per this function the MEP-TLV is a part of
602 BFD-CV payload. If a non-zero hfindex comes, then tht TLV info will be displayed
603 under a particular protocol-tree. */
606 offset
= tvb_get_guint8(tvb
, 3);
607 mep_type
= tvb_get_ntohs (tvb
, offset
);
608 mep_len
= tvb_get_ntohs (tvb
, (offset
+ 2));
609 ti
= proto_tree_add_protocol_format (tree
, proto_bfd
, tvb
, offset
, (mep_len
+ 4),
610 "MPLS-TP SOURCE MEP-ID TLV");
614 mep_type
= tvb_get_ntohs (tvb
, offset
);
615 mep_len
= tvb_get_ntohs (tvb
, (offset
+ 2));
616 ti
= proto_tree_add_protocol_format (tree
, hfindex
, tvb
, offset
, (mep_len
+ 4),
617 "MPLS-TP SOURCE MEP-ID TLV");
621 case TLV_TYPE_MPLSTP_SECTION_MEP
:
623 bfd_tree
= proto_item_add_subtree (ti
, ett_bfd
);
624 proto_tree_add_uint (bfd_tree
, hf_mep_type
, tvb
, offset
,
626 proto_tree_add_uint (bfd_tree
, hf_mep_len
, tvb
, (offset
+ 2),
628 proto_tree_add_item (bfd_tree
, hf_mep_global_id
, tvb
, (offset
+ 4),
630 proto_tree_add_item (bfd_tree
, hf_mep_node_id
, tvb
, (offset
+ 8),
632 proto_tree_add_item (bfd_tree
, hf_section_interface_no
, tvb
, (offset
+ 12),
637 case TLV_TYPE_MPLSTP_LSP_MEP
:
639 bfd_tree
= proto_item_add_subtree (ti
, ett_bfd
);
640 proto_tree_add_uint (bfd_tree
, hf_mep_type
, tvb
, offset
,
642 proto_tree_add_uint (bfd_tree
, hf_mep_len
, tvb
, (offset
+ 2),
644 proto_tree_add_item (bfd_tree
, hf_mep_global_id
, tvb
, (offset
+ 4),
646 proto_tree_add_item (bfd_tree
, hf_mep_node_id
, tvb
, (offset
+ 8),
648 proto_tree_add_item (bfd_tree
, hf_mep_tunnel_no
, tvb
, (offset
+ 12),
650 proto_tree_add_item (bfd_tree
, hf_mep_lsp_no
, tvb
, (offset
+ 14),
655 case TLV_TYPE_MPLSTP_PW_MEP
:
657 mep_agi_len
= tvb_get_guint8 (tvb
, (offset
+ 17));
658 bfd_tree
= proto_item_add_subtree (ti
, ett_bfd
);
659 proto_tree_add_uint (bfd_tree
, hf_mep_type
, tvb
, offset
,
661 proto_tree_add_uint (bfd_tree
, hf_mep_len
, tvb
, (offset
+ 2),
663 proto_tree_add_item (bfd_tree
, hf_mep_global_id
, tvb
, (offset
+ 4),
665 proto_tree_add_item (bfd_tree
, hf_mep_node_id
, tvb
, (offset
+ 8),
667 proto_tree_add_item (bfd_tree
, hf_mep_ac_id
, tvb
, (offset
+ 12),
669 proto_tree_add_item (bfd_tree
, hf_mep_agi_type
, tvb
, (offset
+ 16),
671 proto_tree_add_uint (bfd_tree
, hf_mep_agi_len
, tvb
, (offset
+ 17),
673 proto_tree_add_item (bfd_tree
, hf_mep_agi_val
, tvb
, (offset
+ 18),
674 mep_agi_len
, ENC_ASCII
|ENC_NA
);
684 /* Register the protocol with Wireshark */
686 proto_register_bfd(void)
689 /* Setup list of header fields */
690 static hf_register_info hf
[] = {
692 { "Protocol Version", "bfd.version",
693 FT_UINT8
, BASE_DEC
, NULL
, 0xe0,
694 "The version number of the BFD protocol", HFILL
}
697 { "Diagnostic Code", "bfd.diag",
698 FT_UINT8
, BASE_HEX
, VALS(bfd_control_v1_diag_values
), 0x1f,
699 "This field give the reason for a BFD session failure", HFILL
}
702 { "Session State", "bfd.sta",
703 FT_UINT8
, BASE_HEX
, VALS(bfd_control_sta_values
), 0xc0,
704 "The BFD state as seen by the transmitting system", HFILL
}
708 { "Message Flags", "bfd.flags",
709 FT_UINT8
, BASE_HEX
, NULL
, 0xf0,
714 { "I hear you", "bfd.flags.h",
715 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x80,
718 { &hf_bfd_flags_d_v0
,
719 { "Demand", "bfd.flags.d",
720 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x40,
723 { &hf_bfd_flags_p_v0
,
724 { "Poll", "bfd.flags.p",
725 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x20,
728 { &hf_bfd_flags_f_v0
,
729 { "Final", "bfd.flags.f",
730 FT_BOOLEAN
, 8, TFS(&tfs_set_notset
), 0x10,
734 { "Poll", "bfd.flags.p",
735 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x20, /* 6 flag bits; Sta is shown separately */
736 "If set, the transmitting system is expecting a packet with the Final (F) bit in reply",
740 { "Final", "bfd.flags.f",
741 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x10, /* 6 flag bits; Sta is shown separately */
742 "If set, the transmitting system is replying to a packet with the Poll (P) bit set",
746 { "Control Plane Independent", "bfd.flags.c",
747 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x08, /* 6 flag bits; Sta is shown separately */
748 "If set, the BFD implementation is implemented in the forwarding plane", HFILL
}
751 { "Authentication Present", "bfd.flags.a",
752 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x04, /* 6 flag bits; Sta is shown separately */
753 "The Authentication Section is present", HFILL
}
756 { "Demand", "bfd.flags.d",
757 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x02, /* 6 flag bits; Sta is shown separately */
758 "If set, Demand mode is active in the transmitting system", HFILL
}
761 { "Multipoint", "bfd.flags.m",
762 FT_BOOLEAN
, 6, TFS(&tfs_set_notset
), 0x01, /* 6 flag bits; Sta is shown separately */
763 "Reserved for future point-to-multipoint extensions", HFILL
}
765 { &hf_bfd_detect_time_multiplier
,
766 { "Detect Time Multiplier", "bfd.detect_time_multiplier",
767 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
768 "The transmit interval multiplied by this value is the failure detection time", HFILL
}
770 { &hf_bfd_message_length
,
771 { "Message Length", "bfd.message_length",
772 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
773 "Length of the BFD Control packet, in bytes", HFILL
}
775 { &hf_bfd_my_discriminator
,
776 { "My Discriminator", "bfd.my_discriminator",
777 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
780 { &hf_bfd_your_discriminator
,
781 { "Your Discriminator", "bfd.your_discriminator",
782 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
785 { &hf_bfd_desired_min_tx_interval
,
786 { "Desired Min TX Interval", "bfd.desired_min_tx_interval",
787 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
788 "The minimum interval to use when transmitting BFD Control packets", HFILL
}
790 { &hf_bfd_required_min_rx_interval
,
791 { "Required Min RX Interval", "bfd.required_min_rx_interval",
792 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
793 "The minimum interval between received BFD Control packets that this system can support", HFILL
}
795 { &hf_bfd_required_min_echo_interval
,
796 { "Required Min Echo Interval", "bfd.required_min_echo_interval",
797 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
798 "The minimum interval between received BFD Echo packets that this system can support", HFILL
}
801 { "Authentication Type", "bfd.auth.type",
802 FT_UINT8
, BASE_DEC
, VALS(bfd_control_auth_type_values
), 0x0,
803 "The type of authentication in use on this session", HFILL
}
806 { "Authentication Length", "bfd.auth.len",
807 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
808 "The length, in bytes, of the authentication section", HFILL
}
811 { "Authentication Key ID", "bfd.auth.key",
812 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
813 "The Authentication Key ID, identifies which password is in use for this packet", HFILL
}
815 { &hf_bfd_auth_password
,
816 { "Password", "bfd.auth.password",
817 FT_STRING
, BASE_NONE
, NULL
, 0x0,
818 "The simple password in use on this session", HFILL
}
820 { &hf_bfd_auth_seq_num
,
821 { "Sequence Number", "bfd.auth.seq_num",
822 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
823 "The Sequence Number is periodically incremented to prevent replay attacks", HFILL
}
826 { "Type", "bfd.mep.type",
827 FT_UINT16
, BASE_DEC
, VALS(mplstp_mep_tlv_type_values
), 0x0,
828 "The type of the MEP Id", HFILL
}
831 { "Length", "bfd.mep.len",
832 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
833 "The length of the MEP Id", HFILL
}
836 { "Global Id", "bfd.mep.global.id",
837 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
838 "MPLS-TP Global MEP Id", HFILL
}
841 { "Node Id", "bfd.mep.node.id",
842 FT_IPv4
, BASE_NONE
, NULL
, 0x0,
843 "MPLS-TP Node Identifier", HFILL
}
846 { &hf_mep_interface_no
,
847 { "Interface Number", "bfd.mep.interface.no",
848 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
849 "MPLS-TP Interface Number", HFILL
}
853 { "Tunnel Number", "bfd.mep.tunnel.no",
854 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
858 { "LSP Number", "bfd.mep.lsp.no",
859 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
863 { "AC Id", "bfd.mep.ac.id",
864 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
868 { "AGI TYPE", "bfd.mep.agi.type",
869 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
873 { "AGI Length", "bfd.mep.agi.len",
874 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
878 { "AGI value", "bfd.mep.agi.val",
879 FT_STRING
, BASE_NONE
, NULL
, 0x0,
882 { &hf_section_interface_no
,
883 { "Interface Number", "bfd.mep.interface.no",
884 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
885 "MPLS-TP Interface Number", HFILL
}
889 /* Setup protocol subtree array */
890 static gint
*ett
[] = {
896 static ei_register_info ei
[] = {
897 { &ei_bfd_auth_len_invalid
, { "bfd.auth.len.invalid", PI_MALFORMED
, PI_WARN
, "Length of authentication section is invalid", EXPFILL
}},
898 { &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
}},
901 expert_module_t
* expert_bfd
;
903 /* Register the protocol name and description */
904 proto_bfd
= proto_register_protocol("Bidirectional Forwarding Detection Control Message",
907 register_dissector("bfd", dissect_bfd_control
, proto_bfd
);
909 /* Required function calls to register the header fields and subtrees used */
910 proto_register_field_array(proto_bfd
, hf
, array_length(hf
));
911 proto_register_subtree_array(ett
, array_length(ett
));
912 expert_bfd
= expert_register_protocol(proto_bfd
);
913 expert_register_field_array(expert_bfd
, ei
, array_length(ei
));
917 proto_reg_handoff_bfd(void)
919 dissector_handle_t bfd_control_handle
;
921 bfd_control_handle
= find_dissector("bfd");
922 dissector_add_uint("udp.port", UDP_PORT_BFD_1HOP_CONTROL
, bfd_control_handle
);
923 dissector_add_uint("udp.port", UDP_PORT_BFD_MULTIHOP_CONTROL
, bfd_control_handle
);