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>
33 #include <epan/to_str.h>
35 /* MSDP message types. The messages are TLV (Type-Length-Value) encoded */
42 /* Theses are only assigned in MSDP spec. Their use is specifed
44 MSDP_TRACE_IN_PROGRESS
,
48 static const value_string msdp_types
[] = {
49 { MSDP_SA
, "IPv4 Source-Active" },
50 { MSDP_SA_REQ
, "IPv4 Source-Active Request" },
51 { MSDP_SA_RSP
, "IPv4 Source-Active Response" },
52 { MSDP_KEEP_ALIVE
, "KeepAlive" },
53 { MSDP_NOTIFICATION
, "Notification" },
55 { MSDP_TRACE_IN_PROGRESS
, "MSDP traceroute in progress" },
56 { MSDP_TRACE_REPLY
, "MSDP traceroute reply" },
62 enum { MESSAGE_HEADER_ERROR
= 1,
64 SA_MESSAGE_SA_RESPONSE_ERROR
,
71 static const value_string error_vals
[] = {
72 { MESSAGE_HEADER_ERROR
, "Message Header Error" },
73 { SA_REQUEST_ERROR
, "SA-Request Error" },
74 { SA_MESSAGE_SA_RESPONSE_ERROR
, "SA-Message/SA-Response Error" },
75 { HOLD_TIMER_EXPIRED
, "Hold Timer Expired" },
76 { FSM_ERROR
, "Finite State Machine Error" },
77 { NOTIFICATION
, "Notification" },
83 /* Message Header Error subcodes */
84 static const value_string hdr_error_vals
[] = {
86 { 2, "Bad Message Length" },
87 { 3, "Bad Message Type" },
91 /* SA-Request Error subcodes (the O-bit is always clear) */
92 static const value_string sa_req_error_vals
[] = {
94 { 1, "Invalid Group" },
98 /* SA-Message/SA-Response Error subcodes */
99 static const value_string sa_msg_error_vals
[] = {
101 { 1, "Invalid Entry Count" },
102 { 2, "Invalid RP Address" },
103 { 3, "Invalid Group Address" },
104 { 4, "Invalid Source Address" },
105 { 5, "Invalid Sprefix Length" },
106 { 6, "Looping SA (Self is RP)" },
107 { 7, "Unknown Encapsulation" },
108 { 8, "Administrative Scope Boundary Violated" },
112 /* Finite State Machine Error subcodes (the O-bit is always clear) */
113 static const value_string fsm_error_vals
[] = {
115 { 1, "Unexpected Message Type FSM Error" },
120 * Hold Timer Expired subcodes (the O-bit is always clear):
121 * Notification subcodes (the O-bit is always clear):
122 * Cease subcodes (the O-bit is always clear):
124 * These have only "Unspecific" specified.
126 static const value_string sa_unspec_error_vals
[] = {
132 /* Initialize the protocol and registered fields */
133 static int proto_msdp
= -1;
134 static int hf_msdp_type
= -1;
135 static int hf_msdp_length
= -1;
137 static int hf_msdp_sa_entry_count
= -1;
138 static int hf_msdp_sa_rp_addr
= -1;
139 static int hf_msdp_sa_reserved
= -1;
140 static int hf_msdp_sa_sprefix_len
= -1;
141 static int hf_msdp_sa_group_addr
= -1;
142 static int hf_msdp_sa_src_addr
= -1;
144 static int hf_msdp_sa_req_res
= -1;
145 static int hf_msdp_sa_req_group
= -1;
147 static int hf_msdp_not_o
= -1;
148 static int hf_msdp_not_error
= -1;
149 static int hf_msdp_not_error_sub
= -1;
151 static int hf_msdp_not_group_address
= -1;
152 static int hf_msdp_not_rp_address
= -1;
153 static int hf_msdp_not_source_address
= -1;
154 static int hf_msdp_not_res
= -1;
155 static int hf_msdp_not_entry_count
= -1;
156 static int hf_msdp_not_sprefix_len
= -1;
159 static gint ett_msdp
= -1;
160 static gint ett_msdp_sa_entry
= -1;
161 static gint ett_msdp_sa_enc_data
= -1;
162 static gint ett_msdp_not_data
= -1;
165 static dissector_handle_t ip_handle
;
169 dissect_msdp_sa(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
170 int *offset
, int len
);
172 dissect_msdp_notification(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int *offset
, guint16 tlv_len
);
176 dissect_msdp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
179 proto_tree
*msdp_tree
;
185 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MSDP");
187 col_set_str(pinfo
->cinfo
, COL_INFO
, val_to_str_const(tvb_get_guint8(tvb
, 0),
189 "<Unknown MSDP message type>"));
191 ti
= proto_tree_add_item(tree
, proto_msdp
, tvb
, 0, -1, ENC_NA
);
192 msdp_tree
= proto_item_add_subtree(ti
, ett_msdp
);
195 while (tvb_reported_length_remaining(tvb
, offset
) >= 3) {
196 type
= tvb_get_guint8(tvb
, offset
);
197 length
= tvb_get_ntohs(tvb
, offset
+ 1);
200 proto_tree_add_uint(msdp_tree
, hf_msdp_type
, tvb
, offset
, 1, type
);
201 proto_tree_add_uint(msdp_tree
, hf_msdp_length
, tvb
, offset
+ 1, 2, length
);
208 dissect_msdp_sa(tvb
, pinfo
, msdp_tree
, &offset
,
212 proto_tree_add_item(msdp_tree
, hf_msdp_sa_req_res
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
213 proto_tree_add_item(msdp_tree
, hf_msdp_sa_req_group
, tvb
, offset
+ 1, 4, ENC_BIG_ENDIAN
);
216 case MSDP_NOTIFICATION
:
217 dissect_msdp_notification(tvb
, pinfo
, msdp_tree
, &offset
, length
);
221 proto_tree_add_text(msdp_tree
, tvb
, offset
, length
, "TLV contents");
227 if (tvb_length_remaining(tvb
, offset
) > 0)
228 proto_tree_add_text(msdp_tree
, tvb
, offset
,
229 -1, "Trailing junk");
234 /* Both Source-Active and Source-Active Response have the same format
235 * with one exception. Encapsulated multicast data is not allowed in
238 static void dissect_msdp_sa(tvbuff_t
*tvb
, packet_info
*pinfo
,
239 proto_tree
*tree
, int *offset
, int length
)
245 entries
= tvb_get_guint8(tvb
, *offset
);
246 proto_tree_add_uint(tree
, hf_msdp_sa_entry_count
, tvb
, *offset
, 1, entries
);
254 proto_tree_add_item(tree
, hf_msdp_sa_rp_addr
, tvb
, *offset
, 4, ENC_BIG_ENDIAN
);
258 /* Put each of the (S,G) entries in their own subtree.
259 * This is probably visually better.
261 while (entries
-- > 0) {
263 proto_tree
*entry_tree
;
269 ei
= proto_tree_add_text(tree
, tvb
, *offset
, 12, "(S,G) block: %s/%u -> %s",
270 tvb_ip_to_str(tvb
, *offset
+ 8),
271 tvb_get_guint8(tvb
, *offset
+ 3),
272 tvb_ip_to_str(tvb
, *offset
+ 4));
273 entry_tree
= proto_item_add_subtree(ei
, ett_msdp_sa_entry
);
275 proto_tree_add_item(entry_tree
, hf_msdp_sa_reserved
, tvb
, *offset
, 3, ENC_BIG_ENDIAN
);
278 proto_tree_add_item(entry_tree
, hf_msdp_sa_sprefix_len
, tvb
, *offset
, 1, ENC_BIG_ENDIAN
);
281 proto_tree_add_item(entry_tree
, hf_msdp_sa_group_addr
, tvb
, *offset
, 4, ENC_BIG_ENDIAN
);
284 proto_tree_add_item(entry_tree
, hf_msdp_sa_src_addr
, tvb
, *offset
, 4, ENC_BIG_ENDIAN
);
290 * Check if an encapsulated multicast IPv4 packet follows
294 proto_tree
*enc_tree
;
295 gint available_length
, reported_length
;
298 ei
= proto_tree_add_text(tree
, tvb
, *offset
, length
,
299 "Encapsulated IPv4 packet: %u bytes",
301 enc_tree
= proto_item_add_subtree(ei
, ett_msdp_sa_enc_data
);
303 available_length
= tvb_length_remaining(tvb
, *offset
);
304 reported_length
= tvb_reported_length_remaining(tvb
, *offset
);
305 DISSECTOR_ASSERT(available_length
>= 0);
306 DISSECTOR_ASSERT(reported_length
>= 0);
307 if (available_length
> reported_length
)
308 available_length
= reported_length
;
309 if (available_length
> length
)
310 available_length
= length
;
311 if (reported_length
> length
)
312 reported_length
= length
;
314 next_tvb
= tvb_new_subset(tvb
, *offset
, available_length
,
316 /* Set the information columns read-only so that they
317 * reflect the MSDP packet rather than the
318 * encapsulated packet.
320 col_set_writable(pinfo
->cinfo
, FALSE
);
321 call_dissector(ip_handle
, next_tvb
, pinfo
, enc_tree
);
328 /* Note: updates *offset */
329 static void add_notification_data_ipv4addr(tvbuff_t
*tvb
, proto_tree
*tree
, int *offset
, int hf_addr
)
331 proto_tree_add_item(tree
, hf_msdp_not_res
, tvb
, *offset
, 3, ENC_BIG_ENDIAN
);
333 proto_tree_add_item(tree
, hf_addr
, tvb
, *offset
, 4, ENC_BIG_ENDIAN
);
339 static void dissect_msdp_notification(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int *offset
, guint16 tlv_len
)
341 guint8 error
, error_sub
;
342 const value_string
*vals
;
344 proto_tree_add_item(tree
, hf_msdp_not_o
, tvb
, *offset
, 1, ENC_BIG_ENDIAN
);
345 proto_tree_add_item(tree
, hf_msdp_not_error
, tvb
, *offset
, 1, ENC_BIG_ENDIAN
);
346 error
= tvb_get_guint8(tvb
, *offset
);
347 error
&= 0x7F; /* Error is 7-bit field. O-bit is bit 8 */
350 /* Depending on the Error Code, we collect the correct
351 * value_strings for the Error subcode
354 case MESSAGE_HEADER_ERROR
:
355 vals
= hdr_error_vals
;
357 case SA_REQUEST_ERROR
:
358 vals
= sa_req_error_vals
;
360 case SA_MESSAGE_SA_RESPONSE_ERROR
:
361 vals
= sa_msg_error_vals
;
364 vals
= fsm_error_vals
;
366 case HOLD_TIMER_EXPIRED
:
369 vals
= sa_unspec_error_vals
;
372 vals
= sa_unspec_error_vals
;
376 error_sub
= tvb_get_guint8(tvb
, *offset
);
377 proto_tree_add_uint_format_value(tree
, hf_msdp_not_error_sub
, tvb
, *offset
, 1,
378 error_sub
, "%s (%u)",
379 val_to_str_const(error_sub
, vals
, "<Unknown Error subcode>"),
383 /* Do switch again, this time to dissect the data portion
388 case SA_REQUEST_ERROR
:
389 add_notification_data_ipv4addr(tvb
, tree
, offset
, hf_msdp_not_group_address
);
391 case SA_MESSAGE_SA_RESPONSE_ERROR
:
392 if (error_sub
== 0) {
394 } else if (error_sub
== 1) {
395 proto_tree_add_item(tree
, hf_msdp_not_entry_count
, tvb
, *offset
, 1, ENC_BIG_ENDIAN
);
398 } else if (error_sub
== 2) {
399 add_notification_data_ipv4addr(tvb
, tree
, offset
, hf_msdp_not_rp_address
);
401 } else if (error_sub
== 3 || error_sub
== 8) {
402 add_notification_data_ipv4addr(tvb
, tree
, offset
, hf_msdp_not_group_address
);
404 } else if (error_sub
== 4) {
405 add_notification_data_ipv4addr(tvb
, tree
, offset
, hf_msdp_not_source_address
);
407 } else if (error_sub
== 5) {
408 proto_tree_add_item(tree
, hf_msdp_not_sprefix_len
, tvb
, *offset
, 1, ENC_BIG_ENDIAN
);
411 } else if (error_sub
== 6) {
412 /* No break, causes fall through to next label */
413 } else if (error_sub
== 7) {
414 proto_tree_add_text(tree
, tvb
, *offset
, tlv_len
- 5,
415 "Packet with unknown encapsulation: %u bytes",
417 *offset
+= tlv_len
- 5;
420 proto_tree_add_text(tree
, tvb
, *offset
, tlv_len
- 5,
421 "<Unknown data>: %u bytes",
423 *offset
+= tlv_len
- 5;
427 case MESSAGE_HEADER_ERROR
:
429 /* Data contains the message that had an error. Even a
430 * broken Notification message causes a Notification
431 * message with Error Code set to Notification to be
434 next_tvb
= tvb_new_subset_remaining(tvb
, *offset
);
435 dissect_msdp(next_tvb
, pinfo
, tree
);
438 case HOLD_TIMER_EXPIRED
:
440 /* Do nothing. These contain no data */
444 proto_tree_add_text(tree
, tvb
, *offset
, tlv_len
- 5,
445 "<Unknown data>: %u bytes",
447 *offset
+= tlv_len
- 5;
455 proto_register_msdp(void)
457 static hf_register_info hf
[] = {
459 { "Type", "msdp.type",
460 FT_UINT8
, BASE_DEC
, VALS(msdp_types
), 0,
461 "MSDP TLV type", HFILL
}
464 { "Length", "msdp.length",
465 FT_UINT16
, BASE_DEC
, NULL
, 0,
466 "MSDP TLV Length", HFILL
}
468 { &hf_msdp_sa_entry_count
,
469 { "Entry Count", "msdp.sa.entry_count",
470 FT_UINT8
, BASE_DEC
, NULL
, 0,
471 "MSDP SA Entry Count", HFILL
}
473 { &hf_msdp_sa_rp_addr
,
474 { "RP Address", "msdp.sa.rp_addr",
475 FT_IPv4
, BASE_NONE
, NULL
, 0,
476 "Active source's RP address", HFILL
}
478 { &hf_msdp_sa_reserved
,
479 { "Reserved", "msdp.sa.reserved",
480 FT_UINT24
, BASE_HEX
, NULL
, 0,
481 "Transmitted as zeros and ignored by a receiver", HFILL
}
483 { &hf_msdp_sa_sprefix_len
,
484 { "Sprefix len", "msdp.sa.sprefix_len",
485 FT_UINT8
, BASE_DEC
, NULL
, 0,
486 "The route prefix length associated with source address", HFILL
}
488 { &hf_msdp_sa_group_addr
,
489 { "Group Address", "msdp.sa.group_addr",
490 FT_IPv4
, BASE_NONE
, NULL
, 0,
491 "The group address the active source has sent data to", HFILL
}
493 { &hf_msdp_sa_src_addr
,
494 { "Source Address", "msdp.sa.src_addr",
495 FT_IPv4
, BASE_NONE
, NULL
, 0,
496 "The IP address of the active source", HFILL
}
498 { &hf_msdp_sa_req_res
,
499 { "Reserved", "msdp.sa_req.res",
500 FT_UINT8
, BASE_HEX
, NULL
, 0,
501 "Transmitted as zeros and ignored by a receiver", HFILL
}
503 { &hf_msdp_sa_req_group
,
504 { "Group Address", "msdp.sa_req.group_addr",
505 FT_IPv4
, BASE_NONE
, NULL
, 0,
506 "The group address the MSDP peer is requesting", HFILL
}
509 { "Open-bit", "msdp.not.o",
510 FT_UINT8
, BASE_HEX
, NULL
, 0x80,
511 "If clear, the connection will be closed", HFILL
}
513 { &hf_msdp_not_error
,
514 { "Error Code", "msdp.not.error",
515 FT_UINT8
, BASE_DEC
, VALS(error_vals
), 0x7F,
516 "Indicates the type of Notification", HFILL
}
518 { &hf_msdp_not_error_sub
,
519 { "Error subcode", "msdp.not.error_sub",
520 FT_UINT8
, BASE_DEC
, NULL
, 0,
523 { &hf_msdp_not_group_address
,
524 { "Group address", "msdp.not.group_address",
525 FT_IPv4
, BASE_NONE
, NULL
, 0,
526 "Group address in Notification messages", HFILL
}
528 { &hf_msdp_not_rp_address
,
529 { "RP address", "msdp.not.rp_address",
530 FT_IPv4
, BASE_NONE
, NULL
, 0,
531 "RP address in Notification messages", HFILL
}
533 { &hf_msdp_not_source_address
,
534 { "Source address", "msdp.not.source_address",
535 FT_IPv4
, BASE_NONE
, NULL
, 0,
536 "Source address in Notification messages", HFILL
}
539 { "Reserved", "msdp.not.res",
540 FT_UINT24
, BASE_HEX
, NULL
, 0,
541 "Reserved field in Notification messages", HFILL
}
543 { &hf_msdp_not_entry_count
,
544 { "Entry Count", "msdp.not.entry_count",
545 FT_UINT24
, BASE_HEX
, NULL
, 0,
546 "Entry Count in Notification messages", HFILL
}
548 { &hf_msdp_not_sprefix_len
,
549 { "Sprefix len", "msdp.not.sprefix_len",
550 FT_UINT8
, BASE_DEC
, NULL
, 0,
551 "Source prefix length in Notification messages", HFILL
}
555 static gint
*ett
[] = {
558 &ett_msdp_sa_enc_data
,
562 proto_msdp
= proto_register_protocol("Multicast Source Discovery Protocol",
565 proto_register_field_array(proto_msdp
, hf
, array_length(hf
));
566 proto_register_subtree_array(ett
, array_length(ett
));
570 proto_reg_handoff_msdp(void)
572 dissector_handle_t msdp_handle
;
574 msdp_handle
= create_dissector_handle(dissect_msdp
, proto_msdp
);
575 dissector_add_uint("tcp.port", 639, msdp_handle
);
577 ip_handle
= find_dissector("ip");