2 * Routines for Multicast Source Discovery Protocol (MSDP) dissection.
3 * draft-ietf-msdp-spec-10.txt
5 * Copyright 2001, Heikki Vatiainen <hessu@cs.tut.fi>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include <epan/packet.h>
34 /* MSDP message types. The messages are TLV (Type-Length-Value) encoded */
41 /* Theses are only assigned in MSDP spec. Their use is specifed
43 MSDP_TRACE_IN_PROGRESS,
47 static const value_string msdp_types[] = {
48 { MSDP_SA, "IPv4 Source-Active" },
49 { MSDP_SA_REQ, "IPv4 Source-Active Request" },
50 { MSDP_SA_RSP, "IPv4 Source-Active Response" },
51 { MSDP_KEEP_ALIVE, "KeepAlive" },
52 { MSDP_NOTIFICATION, "Notification" },
54 { MSDP_TRACE_IN_PROGRESS, "MSDP traceroute in progress" },
55 { MSDP_TRACE_REPLY, "MSDP traceroute reply" },
61 enum { MESSAGE_HEADER_ERROR = 1,
63 SA_MESSAGE_SA_RESPONSE_ERROR,
70 static const value_string error_vals[] = {
71 { MESSAGE_HEADER_ERROR, "Message Header Error" },
72 { SA_REQUEST_ERROR, "SA-Request Error" },
73 { SA_MESSAGE_SA_RESPONSE_ERROR, "SA-Message/SA-Response Error" },
74 { HOLD_TIMER_EXPIRED, "Hold Timer Expired" },
75 { FSM_ERROR, "Finite State Machine Error" },
76 { NOTIFICATION, "Notification" },
82 /* Message Header Error subcodes */
83 static const value_string hdr_error_vals[] = {
85 { 2, "Bad Message Length" },
86 { 3, "Bad Message Type" },
90 /* SA-Request Error subcodes (the O-bit is always clear) */
91 static const value_string sa_req_error_vals[] = {
93 { 1, "Invalid Group" },
97 /* SA-Message/SA-Response Error subcodes */
98 static const value_string sa_msg_error_vals[] = {
100 { 1, "Invalid Entry Count" },
101 { 2, "Invalid RP Address" },
102 { 3, "Invalid Group Address" },
103 { 4, "Invalid Source Address" },
104 { 5, "Invalid Sprefix Length" },
105 { 6, "Looping SA (Self is RP)" },
106 { 7, "Unknown Encapsulation" },
107 { 8, "Administrative Scope Boundary Violated" },
111 /* Finite State Machine Error subcodes (the O-bit is always clear) */
112 static const value_string fsm_error_vals[] = {
114 { 1, "Unexpected Message Type FSM Error" },
119 * Hold Timer Expired subcodes (the O-bit is always clear):
120 * Notification subcodes (the O-bit is always clear):
121 * Cease subcodes (the O-bit is always clear):
123 * These have only "Unspecific" specified.
125 static const value_string sa_unspec_error_vals[] = {
131 /* Initialize the protocol and registered fields */
132 static int proto_msdp = -1;
133 static int hf_msdp_type = -1;
134 static int hf_msdp_length = -1;
136 static int hf_msdp_sa_entry_count = -1;
137 static int hf_msdp_sa_rp_addr = -1;
138 static int hf_msdp_sa_reserved = -1;
139 static int hf_msdp_sa_sprefix_len = -1;
140 static int hf_msdp_sa_group_addr = -1;
141 static int hf_msdp_sa_src_addr = -1;
143 static int hf_msdp_sa_req_res = -1;
144 static int hf_msdp_sa_req_group = -1;
146 static int hf_msdp_not_o = -1;
147 static int hf_msdp_not_error = -1;
148 static int hf_msdp_not_error_sub = -1;
150 static int hf_msdp_not_ipv4 = -1;
151 static int hf_msdp_not_res = -1;
152 static int hf_msdp_not_entry_count = -1;
153 static int hf_msdp_not_sprefix_len = -1;
156 static gint ett_msdp = -1;
157 static gint ett_msdp_sa_entry = -1;
158 static gint ett_msdp_sa_enc_data = -1;
159 static gint ett_msdp_not_data = -1;
162 static dissector_handle_t ip_handle;
166 dissect_msdp_sa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
167 int *offset, int len);
169 dissect_msdp_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, guint16 tlv_len);
173 dissect_msdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
176 proto_tree *msdp_tree;
182 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSDP");
184 if (check_col(pinfo->cinfo, COL_INFO))
185 col_add_str(pinfo->cinfo, COL_INFO, val_to_str_const(tvb_get_guint8(tvb, 0),
187 "<Unknown MSDP message type>"));
189 ti = proto_tree_add_item(tree, proto_msdp, tvb, 0, -1, ENC_NA);
190 msdp_tree = proto_item_add_subtree(ti, ett_msdp);
193 while (tvb_reported_length_remaining(tvb, offset) >= 3) {
194 type = tvb_get_guint8(tvb, offset);
195 length = tvb_get_ntohs(tvb, offset + 1);
198 proto_tree_add_uint(msdp_tree, hf_msdp_type, tvb, offset, 1, type);
199 proto_tree_add_uint(msdp_tree, hf_msdp_length, tvb, offset + 1, 2, length);
206 dissect_msdp_sa(tvb, pinfo, msdp_tree, &offset,
210 proto_tree_add_item(msdp_tree, hf_msdp_sa_req_res, tvb, offset, 1, ENC_BIG_ENDIAN);
211 proto_tree_add_item(msdp_tree, hf_msdp_sa_req_group, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
214 case MSDP_NOTIFICATION:
215 dissect_msdp_notification(tvb, pinfo, msdp_tree, &offset, length);
219 proto_tree_add_text(msdp_tree, tvb, offset, length, "TLV contents");
225 if (tvb_length_remaining(tvb, offset) > 0)
226 proto_tree_add_text(msdp_tree, tvb, offset,
227 -1, "Trailing junk");
232 /* Both Source-Active and Source-Active Response have the same format
233 * with one exception. Encapsulated multicast data is not allowed in
236 static void dissect_msdp_sa(tvbuff_t *tvb, packet_info *pinfo,
237 proto_tree *tree, int *offset, int length)
243 entries = tvb_get_guint8(tvb, *offset);
244 proto_tree_add_uint(tree, hf_msdp_sa_entry_count, tvb, *offset, 1, entries);
252 proto_tree_add_item(tree, hf_msdp_sa_rp_addr, tvb, *offset, 4, ENC_BIG_ENDIAN);
256 /* Put each of the (S,G) entries in their own subtree.
257 * This is probably visually better.
259 while (entries-- > 0) {
261 proto_tree *entry_tree;
267 ei = proto_tree_add_text(tree, tvb, *offset, 12, "(S,G) block: %s/%u -> %s",
268 tvb_ip_to_str(tvb, *offset + 8),
269 tvb_get_guint8(tvb, *offset + 3),
270 tvb_ip_to_str(tvb, *offset + 4));
271 entry_tree = proto_item_add_subtree(ei, ett_msdp_sa_entry);
273 proto_tree_add_item(entry_tree, hf_msdp_sa_reserved, tvb, *offset, 3, ENC_BIG_ENDIAN);
276 proto_tree_add_item(entry_tree, hf_msdp_sa_sprefix_len, tvb, *offset, 1, ENC_BIG_ENDIAN);
279 proto_tree_add_item(entry_tree, hf_msdp_sa_group_addr, tvb, *offset, 4, ENC_BIG_ENDIAN);
282 proto_tree_add_item(entry_tree, hf_msdp_sa_src_addr, tvb, *offset, 4, ENC_BIG_ENDIAN);
288 * Check if an encapsulated multicast IPv4 packet follows
292 proto_tree *enc_tree;
293 gint available_length, reported_length;
296 ei = proto_tree_add_text(tree, tvb, *offset, length,
297 "Encapsulated IPv4 packet: %u bytes",
299 enc_tree = proto_item_add_subtree(ei, ett_msdp_sa_enc_data);
301 available_length = tvb_length_remaining(tvb, *offset);
302 reported_length = tvb_reported_length_remaining(tvb, *offset);
303 DISSECTOR_ASSERT(available_length >= 0);
304 DISSECTOR_ASSERT(reported_length >= 0);
305 if (available_length > reported_length)
306 available_length = reported_length;
307 if (available_length > length)
308 available_length = length;
309 if (reported_length > length)
310 reported_length = length;
312 next_tvb = tvb_new_subset(tvb, *offset, available_length,
314 /* Set the information columns read-only so that they
315 * reflect the MSDP packet rather than the
316 * encapsulated packet.
318 col_set_writable(pinfo->cinfo, FALSE);
319 call_dissector(ip_handle, next_tvb, pinfo, enc_tree);
326 /* Note: updates *offset */
327 static void add_notification_data_ipv4addr(tvbuff_t *tvb, proto_tree *tree, int *offset, const char *addrtype)
331 proto_tree_add_item(tree, hf_msdp_not_res, tvb, *offset, 3, ENC_BIG_ENDIAN);
333 ipaddr = tvb_get_ipv4(tvb, *offset);
334 proto_tree_add_ipv4_format(tree, hf_msdp_not_ipv4, tvb, *offset, 4, ipaddr,
335 "%s: %s", addrtype, ip_to_str((guint8 *)&ipaddr));
341 static void dissect_msdp_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset, guint16 tlv_len)
343 guint8 error, error_sub;
344 const value_string *vals;
346 proto_tree_add_item(tree, hf_msdp_not_o, tvb, *offset, 1, ENC_BIG_ENDIAN);
347 proto_tree_add_item(tree, hf_msdp_not_error, tvb, *offset, 1, ENC_BIG_ENDIAN);
348 error = tvb_get_guint8(tvb, *offset);
349 error &= 0x7F; /* Error is 7-bit field. O-bit is bit 8 */
352 /* Depending on the Error Code, we collect the correct
353 * value_strings for the Error subcode
356 case MESSAGE_HEADER_ERROR:
357 vals = hdr_error_vals;
359 case SA_REQUEST_ERROR:
360 vals = sa_req_error_vals;
362 case SA_MESSAGE_SA_RESPONSE_ERROR:
363 vals = sa_msg_error_vals;
366 vals = fsm_error_vals;
368 case HOLD_TIMER_EXPIRED:
371 vals = sa_unspec_error_vals;
374 vals = sa_unspec_error_vals;
378 error_sub = tvb_get_guint8(tvb, *offset);
379 proto_tree_add_uint_format(tree, hf_msdp_not_error_sub, tvb, *offset, 1,
380 error_sub, "Error subcode: %s (%u)",
381 val_to_str_const(error_sub, vals, "<Unknown Error subcode>"),
385 /* Do switch again, this time to dissect the data portion
390 case SA_REQUEST_ERROR:
391 add_notification_data_ipv4addr(tvb, tree, offset, "Group address");
393 case SA_MESSAGE_SA_RESPONSE_ERROR:
394 if (error_sub == 0) {
396 } else if (error_sub == 1) {
397 proto_tree_add_item(tree, hf_msdp_not_entry_count, tvb, *offset, 1, ENC_BIG_ENDIAN);
400 } else if (error_sub == 2) {
401 add_notification_data_ipv4addr(tvb, tree, offset, "RP address");
403 } else if (error_sub == 3 || error_sub == 8) {
404 add_notification_data_ipv4addr(tvb, tree, offset, "Group address");
406 } else if (error_sub == 4) {
407 add_notification_data_ipv4addr(tvb, tree, offset, "Source address");
409 } else if (error_sub == 5) {
410 proto_tree_add_item(tree, hf_msdp_not_sprefix_len, tvb, *offset, 1, ENC_BIG_ENDIAN);
413 } else if (error_sub == 6) {
414 /* No break, causes fall through to next label */
415 } else if (error_sub == 7) {
416 proto_tree_add_text(tree, tvb, *offset, tlv_len - 5,
417 "Packet with unknown encapsulation: %u bytes",
419 *offset += tlv_len - 5;
422 proto_tree_add_text(tree, tvb, *offset, tlv_len - 5,
423 "<Unknown data>: %u bytes",
425 *offset += tlv_len - 5;
429 case MESSAGE_HEADER_ERROR:
431 /* Data contains the message that had an error. Even a
432 * broken Notification message causes a Notification
433 * message with Error Code set to Notification to be
436 next_tvb = tvb_new_subset_remaining(tvb, *offset);
437 dissect_msdp(next_tvb, pinfo, tree);
440 case HOLD_TIMER_EXPIRED:
442 /* Do nothing. These contain no data */
446 proto_tree_add_text(tree, tvb, *offset, tlv_len - 5,
447 "<Unknown data>: %u bytes",
449 *offset += tlv_len - 5;
457 proto_register_msdp(void)
459 static hf_register_info hf[] = {
461 { "Type", "msdp.type",
462 FT_UINT8, BASE_DEC, VALS(msdp_types), 0,
463 "MSDP TLV type", HFILL }
466 { "Length", "msdp.length",
467 FT_UINT16, BASE_DEC, NULL, 0,
468 "MSDP TLV Length", HFILL }
470 { &hf_msdp_sa_entry_count,
471 { "Entry Count", "msdp.sa.entry_count",
472 FT_UINT8, BASE_DEC, NULL, 0,
473 "MSDP SA Entry Count", HFILL }
475 { &hf_msdp_sa_rp_addr,
476 { "RP Address", "msdp.sa.rp_addr",
477 FT_IPv4, BASE_NONE, NULL, 0,
478 "Active source's RP address", HFILL }
480 { &hf_msdp_sa_reserved,
481 { "Reserved", "msdp.sa.reserved",
482 FT_UINT24, BASE_HEX, NULL, 0,
483 "Transmitted as zeros and ignored by a receiver", HFILL }
485 { &hf_msdp_sa_sprefix_len,
486 { "Sprefix len", "msdp.sa.sprefix_len",
487 FT_UINT8, BASE_DEC, NULL, 0,
488 "The route prefix length associated with source address", HFILL }
490 { &hf_msdp_sa_group_addr,
491 { "Group Address", "msdp.sa.group_addr",
492 FT_IPv4, BASE_NONE, NULL, 0,
493 "The group address the active source has sent data to", HFILL }
495 { &hf_msdp_sa_src_addr,
496 { "Source Address", "msdp.sa.src_addr",
497 FT_IPv4, BASE_NONE, NULL, 0,
498 "The IP address of the active source", HFILL }
500 { &hf_msdp_sa_req_res,
501 { "Reserved", "msdp.sa_req.res",
502 FT_UINT8, BASE_HEX, NULL, 0,
503 "Transmitted as zeros and ignored by a receiver", HFILL }
505 { &hf_msdp_sa_req_group,
506 { "Group Address", "msdp.sa_req.group_addr",
507 FT_IPv4, BASE_NONE, NULL, 0,
508 "The group address the MSDP peer is requesting", HFILL }
511 { "Open-bit", "msdp.not.o",
512 FT_UINT8, BASE_HEX, NULL, 0x80,
513 "If clear, the connection will be closed", HFILL }
515 { &hf_msdp_not_error,
516 { "Error Code", "msdp.not.error",
517 FT_UINT8, BASE_DEC, VALS(error_vals), 0x7F,
518 "Indicates the type of Notification", HFILL }
520 { &hf_msdp_not_error_sub,
521 { "Error subode", "msdp.not.error_sub",
522 FT_UINT8, BASE_DEC, NULL, 0,
523 "Error subcode", HFILL }
526 { "IPv4 address", "msdp.not.ipv4",
527 FT_IPv4, BASE_NONE, NULL, 0,
528 "Group/RP/Source address in Notification messages", HFILL }
531 { "Reserved", "msdp.not.res",
532 FT_UINT24, BASE_HEX, NULL, 0,
533 "Reserved field in Notification messages", HFILL }
535 { &hf_msdp_not_entry_count,
536 { "Entry Count", "msdp.not.entry_count",
537 FT_UINT24, BASE_HEX, NULL, 0,
538 "Entry Count in Notification messages", HFILL }
540 { &hf_msdp_not_sprefix_len,
541 { "Sprefix len", "msdp.not.sprefix_len",
542 FT_UINT8, BASE_DEC, NULL, 0,
543 "Source prefix length in Notification messages", HFILL }
547 static gint *ett[] = {
550 &ett_msdp_sa_enc_data,
554 proto_msdp = proto_register_protocol("Multicast Source Discovery Protocol",
557 proto_register_field_array(proto_msdp, hf, array_length(hf));
558 proto_register_subtree_array(ett, array_length(ett));
562 proto_reg_handoff_msdp(void)
564 dissector_handle_t msdp_handle;
566 msdp_handle = create_dissector_handle(dissect_msdp, proto_msdp);
567 dissector_add_uint("tcp.port", 639, msdp_handle);
569 ip_handle = find_dissector("ip");