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@gredler.at)
14 * and Steinar Haug (sthaug@nethelp.no)
17 /* \summary: Label Distribution Protocol (LDP) printer */
21 #include "netdissect-stdinc.h"
23 #include "netdissect.h"
25 #include "addrtoname.h"
34 * 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
35 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 * | Version | PDU Length |
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 struct ldp_common_header
{
47 nd_uint16_t pdu_length
;
49 nd_uint16_t label_space
;
58 * 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
59 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60 * |U| Message Type | Message Length |
61 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 * | Mandatory Parameters |
69 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 * | Optional Parameters |
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 struct ldp_msg_header
{
84 #define LDP_MASK_MSG_TYPE(x) ((x)&0x7fff)
85 #define LDP_MASK_U_BIT(x) ((x)&0x8000)
87 #define LDP_MSG_NOTIF 0x0001
88 #define LDP_MSG_HELLO 0x0100
89 #define LDP_MSG_INIT 0x0200
90 #define LDP_MSG_KEEPALIVE 0x0201
91 #define LDP_MSG_ADDRESS 0x0300
92 #define LDP_MSG_ADDRESS_WITHDRAW 0x0301
93 #define LDP_MSG_LABEL_MAPPING 0x0400
94 #define LDP_MSG_LABEL_REQUEST 0x0401
95 #define LDP_MSG_LABEL_WITHDRAW 0x0402
96 #define LDP_MSG_LABEL_RELEASE 0x0403
97 #define LDP_MSG_LABEL_ABORT_REQUEST 0x0404
99 #define LDP_VENDOR_PRIVATE_MIN 0x3e00
100 #define LDP_VENDOR_PRIVATE_MAX 0x3eff
101 #define LDP_EXPERIMENTAL_MIN 0x3f00
102 #define LDP_EXPERIMENTAL_MAX 0x3fff
104 static const struct tok ldp_msg_values
[] = {
105 { LDP_MSG_NOTIF
, "Notification" },
106 { LDP_MSG_HELLO
, "Hello" },
107 { LDP_MSG_INIT
, "Initialization" },
108 { LDP_MSG_KEEPALIVE
, "Keepalive" },
109 { LDP_MSG_ADDRESS
, "Address" },
110 { LDP_MSG_ADDRESS_WITHDRAW
, "Address Withdraw" },
111 { LDP_MSG_LABEL_MAPPING
, "Label Mapping" },
112 { LDP_MSG_LABEL_REQUEST
, "Label Request" },
113 { LDP_MSG_LABEL_WITHDRAW
, "Label Withdraw" },
114 { LDP_MSG_LABEL_RELEASE
, "Label Release" },
115 { LDP_MSG_LABEL_ABORT_REQUEST
, "Label Abort Request" },
119 #define LDP_MASK_TLV_TYPE(x) ((x)&0x3fff)
120 #define LDP_MASK_F_BIT(x) ((x)&0x4000)
122 #define LDP_TLV_FEC 0x0100
123 #define LDP_TLV_ADDRESS_LIST 0x0101
124 #define LDP_TLV_ADDRESS_LIST_AFNUM_LEN 2
125 #define LDP_TLV_HOP_COUNT 0x0103
126 #define LDP_TLV_PATH_VECTOR 0x0104
127 #define LDP_TLV_GENERIC_LABEL 0x0200
128 #define LDP_TLV_ATM_LABEL 0x0201
129 #define LDP_TLV_FR_LABEL 0x0202
130 #define LDP_TLV_STATUS 0x0300
131 #define LDP_TLV_EXTD_STATUS 0x0301
132 #define LDP_TLV_RETURNED_PDU 0x0302
133 #define LDP_TLV_RETURNED_MSG 0x0303
134 #define LDP_TLV_COMMON_HELLO 0x0400
135 #define LDP_TLV_IPV4_TRANSPORT_ADDR 0x0401
136 #define LDP_TLV_CONFIG_SEQ_NUMBER 0x0402
137 #define LDP_TLV_IPV6_TRANSPORT_ADDR 0x0403
138 #define LDP_TLV_COMMON_SESSION 0x0500
139 #define LDP_TLV_ATM_SESSION_PARM 0x0501
140 #define LDP_TLV_FR_SESSION_PARM 0x0502
141 #define LDP_TLV_FT_SESSION 0x0503
142 #define LDP_TLV_TYPED_WC_FEC_CAP 0x050b /* rfc 5918 */
143 #define LDP_TLV_LABEL_REQUEST_MSG_ID 0x0600
144 #define LDP_TLV_MTU 0x0601 /* rfc 3988 */
145 #define LDP_TLV_DUAL_STACK_CAP 0x0701 /* rfc 7552 */
147 static const struct tok ldp_tlv_values
[] = {
148 { LDP_TLV_FEC
, "FEC" },
149 { LDP_TLV_ADDRESS_LIST
, "Address List" },
150 { LDP_TLV_HOP_COUNT
, "Hop Count" },
151 { LDP_TLV_PATH_VECTOR
, "Path Vector" },
152 { LDP_TLV_GENERIC_LABEL
, "Generic Label" },
153 { LDP_TLV_ATM_LABEL
, "ATM Label" },
154 { LDP_TLV_FR_LABEL
, "Frame-Relay Label" },
155 { LDP_TLV_STATUS
, "Status" },
156 { LDP_TLV_EXTD_STATUS
, "Extended Status" },
157 { LDP_TLV_RETURNED_PDU
, "Returned PDU" },
158 { LDP_TLV_RETURNED_MSG
, "Returned Message" },
159 { LDP_TLV_COMMON_HELLO
, "Common Hello Parameters" },
160 { LDP_TLV_IPV4_TRANSPORT_ADDR
, "IPv4 Transport Address" },
161 { LDP_TLV_CONFIG_SEQ_NUMBER
, "Configuration Sequence Number" },
162 { LDP_TLV_IPV6_TRANSPORT_ADDR
, "IPv6 Transport Address" },
163 { LDP_TLV_COMMON_SESSION
, "Common Session Parameters" },
164 { LDP_TLV_ATM_SESSION_PARM
, "ATM Session Parameters" },
165 { LDP_TLV_FR_SESSION_PARM
, "Frame-Relay Session Parameters" },
166 { LDP_TLV_FT_SESSION
, "Fault-Tolerant Session Parameters" },
167 { LDP_TLV_TYPED_WC_FEC_CAP
, "Typed Wildcard FEC Capability" },
168 { LDP_TLV_LABEL_REQUEST_MSG_ID
, "Label Request Message ID" },
169 { LDP_TLV_MTU
, "MTU" },
170 { LDP_TLV_DUAL_STACK_CAP
, "Dual-Stack Capability" },
174 static const struct tok ldp_status_code_values
[] = {
176 { 0x00000000, "Success" },
177 { 0x00000001, "Bad LDP Identifier" },
178 { 0x00000002, "Bad Protocol Version" },
179 { 0x00000003, "Bad PDU Length" },
180 { 0x00000004, "Unknown Message Type" },
181 { 0x00000005, "Bad Message Length" },
182 { 0x00000006, "Unknown TLV" },
183 { 0x00000007, "Bad TLV Length" },
184 { 0x00000008, "Malformted TLV Value" },
185 { 0x00000009, "Hold Timer Expired" },
186 { 0x0000000A, "Shutdown" },
187 { 0x0000000B, "Loop Detected" },
188 { 0x0000000C, "Unknown FEC" },
189 { 0x0000000D, "No Route" },
190 { 0x0000000E, "No Label Resources" },
191 { 0x0000000F, "Label Resources/Available" },
192 { 0x00000010, "Session Rejected/No Hello" },
193 { 0x00000011, "Session Rejected/Parameters Advertisement Mode" },
194 { 0x00000012, "Session Rejected/Parameters Max PDU Length" },
195 { 0x00000013, "Session Rejected/Parameters Label Range" },
196 { 0x00000014, "KeepAlive Timer Expired" },
197 { 0x00000015, "Label Request Aborted" },
198 { 0x00000016, "Missing Message Parameters" },
199 { 0x00000017, "Unsupported Address Family" },
200 { 0x00000018, "Session Rejected/Bad KeepAlive Time" },
201 { 0x00000019, "Internal Error" },
205 #define LDP_FEC_WILDCARD 0x01
206 #define LDP_FEC_PREFIX 0x02
207 #define LDP_FEC_HOSTADDRESS 0x03
208 /* From RFC 4906; should probably be updated to RFC 4447 (e.g., VC -> PW) */
209 #define LDP_FEC_MARTINI_VC 0x80
211 static const struct tok ldp_fec_values
[] = {
212 { LDP_FEC_WILDCARD
, "Wildcard" },
213 { LDP_FEC_PREFIX
, "Prefix" },
214 { LDP_FEC_HOSTADDRESS
, "Host address" },
215 { LDP_FEC_MARTINI_VC
, "Martini VC" },
219 #define LDP_FEC_MARTINI_IFPARM_MTU 0x01
220 #define LDP_FEC_MARTINI_IFPARM_DESC 0x03
221 #define LDP_FEC_MARTINI_IFPARM_VCCV 0x0c
223 static const struct tok ldp_fec_martini_ifparm_values
[] = {
224 { LDP_FEC_MARTINI_IFPARM_MTU
, "MTU" },
225 { LDP_FEC_MARTINI_IFPARM_DESC
, "Description" },
226 { LDP_FEC_MARTINI_IFPARM_VCCV
, "VCCV" },
230 /* draft-ietf-pwe3-vccv-04.txt */
231 static const struct tok ldp_fec_martini_ifparm_vccv_cc_values
[] = {
232 { 0x01, "PWE3 control word" },
233 { 0x02, "MPLS Router Alert Label" },
234 { 0x04, "MPLS inner label TTL = 1" },
238 /* draft-ietf-pwe3-vccv-04.txt */
239 static const struct tok ldp_fec_martini_ifparm_vccv_cv_values
[] = {
240 { 0x01, "ICMP Ping" },
241 { 0x02, "LSP Ping" },
247 #define LDP_DUAL_STACK_TRANSPORT_PREF_IPV4 0x40
248 #define LDP_DUAL_STACK_TRANSPORT_PREF_IPV6 0x60
250 static const struct tok ldp_dual_stack_transport_pref_values
[] = {
251 { LDP_DUAL_STACK_TRANSPORT_PREF_IPV4
, "IPv4" },
252 { LDP_DUAL_STACK_TRANSPORT_PREF_IPV6
, "IPv6" },
256 static u_int
ldp_pdu_print(netdissect_options
*, const u_char
*);
262 * 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
263 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
264 * |U|F| Type | Length |
265 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
270 * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
272 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
276 ldp_tlv_print(netdissect_options
*ndo
,
280 struct ldp_tlv_header
{
285 const struct ldp_tlv_header
*ldp_tlv_header
;
286 u_short tlv_type
,tlv_len
,tlv_tlen
,af
,ft_flags
;
287 u_char fec_type
, transport_pref
;
288 u_int ui
,vc_info_len
, vc_info_tlv_type
, vc_info_tlv_len
;
292 ldp_tlv_header
= (const struct ldp_tlv_header
*)tptr
;
293 ND_TCHECK_SIZE(ldp_tlv_header
);
294 tlv_len
=GET_BE_U_2(ldp_tlv_header
->length
);
295 if (tlv_len
+ 4U > msg_tlen
) {
296 ND_PRINT("\n\t\t TLV contents go past end of message");
300 tlv_type
=LDP_MASK_TLV_TYPE(GET_BE_U_2(ldp_tlv_header
->type
));
302 /* FIXME vendor private / experimental check */
303 ND_PRINT("\n\t %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]",
304 tok2str(ldp_tlv_values
,
309 LDP_MASK_U_BIT(GET_BE_U_2(ldp_tlv_header
->type
)) ? "continue processing" : "ignore",
310 LDP_MASK_F_BIT(GET_BE_U_2(ldp_tlv_header
->type
)) ? "do" : "don't");
312 tptr
+=sizeof(struct ldp_tlv_header
);
316 case LDP_TLV_COMMON_HELLO
:
317 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
318 ND_PRINT("\n\t Hold Time: %us, Flags: [%s Hello%s]",
320 (GET_BE_U_2(tptr
+ 2)&0x8000) ? "Targeted" : "Link",
321 (GET_BE_U_2(tptr
+ 2)&0x4000) ? ", Request for targeted Hellos" : "");
324 case LDP_TLV_IPV4_TRANSPORT_ADDR
:
325 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
326 ND_PRINT("\n\t IPv4 Transport Address: %s", GET_IPADDR_STRING(tptr
));
328 case LDP_TLV_IPV6_TRANSPORT_ADDR
:
329 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 16);
330 ND_PRINT("\n\t IPv6 Transport Address: %s", GET_IP6ADDR_STRING(tptr
));
332 case LDP_TLV_CONFIG_SEQ_NUMBER
:
333 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
334 ND_PRINT("\n\t Sequence Number: %u", GET_BE_U_4(tptr
));
337 case LDP_TLV_ADDRESS_LIST
:
338 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <,
339 LDP_TLV_ADDRESS_LIST_AFNUM_LEN
);
340 af
= GET_BE_U_2(tptr
);
341 tptr
+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN
;
342 tlv_tlen
-= LDP_TLV_ADDRESS_LIST_AFNUM_LEN
;
343 ND_PRINT("\n\t Address Family: %s, addresses",
344 tok2str(af_values
, "Unknown (%u)", af
));
347 while(tlv_tlen
>= sizeof(nd_ipv4
)) {
348 ND_PRINT(" %s", GET_IPADDR_STRING(tptr
));
349 tlv_tlen
-=sizeof(nd_ipv4
);
350 tptr
+=sizeof(nd_ipv4
);
354 while(tlv_tlen
>= sizeof(nd_ipv6
)) {
355 ND_PRINT(" %s", GET_IP6ADDR_STRING(tptr
));
356 tlv_tlen
-=sizeof(nd_ipv6
);
357 tptr
+=sizeof(nd_ipv6
);
366 case LDP_TLV_HOP_COUNT
:
367 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 1);
368 ND_PRINT("\n\t Hop Count: %u", GET_U_1(tptr
));
371 case LDP_TLV_PATH_VECTOR
:
372 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
373 ND_PRINT("\n\t Path Vector: %s", GET_IPADDR_STRING(tptr
));
376 while (tlv_tlen
>= 4) {
377 ND_PRINT(", %s", GET_IPADDR_STRING(tptr
));
383 case LDP_TLV_COMMON_SESSION
:
384 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 14);
385 ND_PRINT("\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
386 GET_BE_U_2(tptr
), GET_BE_U_2(tptr
+ 2),
387 (GET_BE_U_2(tptr
+ 4)&0x8000) ? "On Demand" : "Unsolicited",
388 (GET_BE_U_2(tptr
+ 4)&0x4000) ? "Enabled" : "Disabled"
390 ND_PRINT("\n\t Path Vector Limit %u, Max-PDU length: %u, Receiver Label-Space-ID %s:%u",
393 GET_IPADDR_STRING(tptr
+8),
399 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 1);
400 fec_type
= GET_U_1(tptr
);
401 ND_PRINT("\n\t %s FEC (0x%02x)",
402 tok2str(ldp_fec_values
, "Unknown", fec_type
),
409 case LDP_FEC_WILDCARD
:
412 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 2);
413 af
= GET_BE_U_2(tptr
);
416 if (af
== AFNUM_IP
) {
417 i
=decode_prefix4(ndo
, tptr
, tlv_tlen
, buf
, sizeof(buf
));
421 ND_PRINT(": IPv4 prefix (goes past end of TLV)");
423 ND_PRINT(": IPv4 prefix (invalid length)");
425 ND_PRINT(": IPv4 prefix %s", buf
);
426 } else if (af
== AFNUM_IP6
) {
427 i
=decode_prefix6(ndo
, tptr
, tlv_tlen
, buf
, sizeof(buf
));
431 ND_PRINT(": IPv4 prefix (goes past end of TLV)");
433 ND_PRINT(": IPv6 prefix (invalid length)");
435 ND_PRINT(": IPv6 prefix %s", buf
);
437 ND_PRINT(": Address family %u prefix", af
);
439 case LDP_FEC_HOSTADDRESS
:
441 case LDP_FEC_MARTINI_VC
:
443 * We assume the type was supposed to be one of the MPLS
446 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 7);
447 vc_info_len
= GET_U_1(tptr
+ 2);
450 * According to RFC 4908, the VC info Length field can be zero,
451 * in which case not only are there no interface parameters,
454 if (vc_info_len
== 0) {
455 ND_PRINT(": %s, %scontrol word, group-ID %u, VC-info-length: %u",
456 tok2str(mpls_pw_types_values
, "Unknown", GET_BE_U_2(tptr
)&0x7fff),
457 GET_BE_U_2(tptr
)&0x8000 ? "" : "no ",
458 GET_BE_U_4(tptr
+ 3),
463 /* Make sure we have the VC ID as well */
464 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 11);
465 ND_PRINT(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
466 tok2str(mpls_pw_types_values
, "Unknown", GET_BE_U_2(tptr
)&0x7fff),
467 GET_BE_U_2(tptr
)&0x8000 ? "" : "no ",
468 GET_BE_U_4(tptr
+ 3),
469 GET_BE_U_4(tptr
+ 7),
471 if (vc_info_len
< 4) {
472 /* minimum 4, for the VC ID */
473 ND_PRINT(" (invalid, < 4");
474 return(tlv_len
+4); /* Type & Length fields not included */
476 vc_info_len
-= 4; /* subtract out the VC ID, giving the length of the interface parameters */
478 /* Skip past the fixed information and the VC ID */
481 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, vc_info_len
);
483 while (vc_info_len
> 2) {
484 vc_info_tlv_type
= GET_U_1(tptr
);
485 vc_info_tlv_len
= GET_U_1(tptr
+ 1);
486 if (vc_info_tlv_len
< 2)
488 if (vc_info_len
< vc_info_tlv_len
)
491 ND_PRINT("\n\t\tInterface Parameter: %s (0x%02x), len %u",
492 tok2str(ldp_fec_martini_ifparm_values
,"Unknown",vc_info_tlv_type
),
496 switch(vc_info_tlv_type
) {
497 case LDP_FEC_MARTINI_IFPARM_MTU
:
498 ND_PRINT(": %u", GET_BE_U_2(tptr
+ 2));
501 case LDP_FEC_MARTINI_IFPARM_DESC
:
503 nd_printjn(ndo
, tptr
+ 2, vc_info_tlv_len
- 2);
506 case LDP_FEC_MARTINI_IFPARM_VCCV
:
507 ND_PRINT("\n\t\t Control Channels (0x%02x) = [%s]",
509 bittok2str(ldp_fec_martini_ifparm_vccv_cc_values
, "none", GET_U_1((tptr
+ 2))));
510 ND_PRINT("\n\t\t CV Types (0x%02x) = [%s]",
512 bittok2str(ldp_fec_martini_ifparm_vccv_cv_values
, "none", GET_U_1((tptr
+ 3))));
516 print_unknown_data(ndo
, tptr
+2, "\n\t\t ", vc_info_tlv_len
-2);
520 vc_info_len
-= vc_info_tlv_len
;
521 tptr
+= vc_info_tlv_len
;
528 case LDP_TLV_GENERIC_LABEL
:
529 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
530 ND_PRINT("\n\t Label: %u", GET_BE_U_4(tptr
) & 0xfffff);
534 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 10);
535 ui
= GET_BE_U_4(tptr
);
537 ND_PRINT("\n\t Status Code: %s, Flags: [%s and %s forward]",
538 tok2str(ldp_status_code_values
, "Unknown", ui
&0x3fffffff),
539 ui
&0x80000000 ? "Fatal error" : "Advisory Notification",
540 ui
&0x40000000 ? "do" : "don't");
541 ui
= GET_BE_U_4(tptr
);
544 ND_PRINT(", causing Message ID: 0x%08x", ui
);
545 ui
= GET_BE_U_2(tptr
);
547 ND_PRINT(", Message Type: %s", tok2str(ldp_msg_values
, "Unknown", ui
));
550 case LDP_TLV_FT_SESSION
:
551 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 12);
552 ft_flags
= GET_BE_U_2(tptr
);
553 ND_PRINT("\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
554 ft_flags
&0x8000 ? "" : "No ",
555 ft_flags
&0x8 ? "" : "Don't ",
556 ft_flags
&0x4 ? "" : "No ",
557 ft_flags
&0x2 ? "Sequence Numbered Label" : "All Labels",
558 ft_flags
&0x1 ? "" : "Don't ");
559 /* 16 bits (FT Flags) + 16 bits (Reserved) */
561 ui
= GET_BE_U_4(tptr
);
563 ND_PRINT(", Reconnect Timeout: %ums", ui
);
565 ui
= GET_BE_U_4(tptr
);
567 ND_PRINT(", Recovery Time: %ums", ui
);
570 case LDP_TLV_TYPED_WC_FEC_CAP
:
571 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 1);
572 ND_PRINT("\n\t %s", GET_U_1(tptr
)&0x80 ? "Support" : "No Support");
576 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 2);
577 ND_PRINT("\n\t MTU: %u", GET_BE_U_2(tptr
));
580 case LDP_TLV_DUAL_STACK_CAP
:
581 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
582 transport_pref
= GET_U_1(tptr
);
583 ND_PRINT("\n\t Transport Connection Preference: %s",
584 tok2str(ldp_dual_stack_transport_pref_values
,
590 * FIXME those are the defined TLVs that lack a decoder
591 * you are welcome to contribute code ;-)
594 case LDP_TLV_ATM_LABEL
:
595 case LDP_TLV_FR_LABEL
:
596 case LDP_TLV_EXTD_STATUS
:
597 case LDP_TLV_RETURNED_PDU
:
598 case LDP_TLV_RETURNED_MSG
:
599 case LDP_TLV_ATM_SESSION_PARM
:
600 case LDP_TLV_FR_SESSION_PARM
:
601 case LDP_TLV_LABEL_REQUEST_MSG_ID
:
604 if (ndo
->ndo_vflag
<= 1)
605 print_unknown_data(ndo
, tptr
, "\n\t ", tlv_tlen
);
608 return(tlv_len
+4); /* Type & Length fields not included */
611 nd_trunc_longjmp(ndo
);
614 nd_print_invalid(ndo
);
615 return(tlv_len
+4); /* Type & Length fields not included */
619 ldp_print(netdissect_options
*ndo
,
620 const u_char
*pptr
, u_int len
)
624 ndo
->ndo_protocol
= "ldp";
625 while (len
> (sizeof(struct ldp_common_header
) + sizeof(struct ldp_msg_header
))) {
626 processed
= ldp_pdu_print(ndo
, pptr
);
629 if (len
< processed
) {
630 ND_PRINT(" [remaining length %u < %u]", len
, processed
);
631 nd_print_invalid(ndo
);
640 ldp_pdu_print(netdissect_options
*ndo
,
643 const struct ldp_common_header
*ldp_com_header
;
644 const struct ldp_msg_header
*ldp_msg_header
;
645 const u_char
*tptr
,*msg_tptr
;
647 u_short pdu_len
,msg_len
,msg_type
;
649 int hexdump
,processed
;
651 ldp_com_header
= (const struct ldp_common_header
*)pptr
;
652 ND_TCHECK_SIZE(ldp_com_header
);
655 * Sanity checking of the header.
657 if (GET_BE_U_2(ldp_com_header
->version
) != LDP_VERSION
) {
658 ND_PRINT("%sLDP version %u packet not supported",
659 (ndo
->ndo_vflag
< 1) ? "" : "\n\t",
660 GET_BE_U_2(ldp_com_header
->version
));
664 pdu_len
= GET_BE_U_2(ldp_com_header
->pdu_length
);
665 if (pdu_len
< sizeof(struct ldp_common_header
)-4) {
666 /* length too short */
667 ND_PRINT("%sLDP, pdu-length: %u (too short, < %zu)",
668 (ndo
->ndo_vflag
< 1) ? "" : "\n\t",
670 sizeof(struct ldp_common_header
)-4);
674 /* print the LSR-ID, label-space & length */
675 ND_PRINT("%sLDP, Label-Space-ID: %s:%u, pdu-length: %u",
676 (ndo
->ndo_vflag
< 1) ? "" : "\n\t",
677 GET_IPADDR_STRING(ldp_com_header
->lsr_id
),
678 GET_BE_U_2(ldp_com_header
->label_space
),
681 /* bail out if non-verbose */
682 if (ndo
->ndo_vflag
< 1)
685 /* ok they seem to want to know everything - lets fully decode it */
686 tptr
= pptr
+ sizeof(struct ldp_common_header
);
687 tlen
= pdu_len
- (sizeof(struct ldp_common_header
)-4); /* Type & Length fields not included */
690 /* did we capture enough for fully decoding the msg header ? */
691 ND_TCHECK_LEN(tptr
, sizeof(struct ldp_msg_header
));
693 ldp_msg_header
= (const struct ldp_msg_header
*)tptr
;
694 msg_len
=GET_BE_U_2(ldp_msg_header
->length
);
695 msg_type
=LDP_MASK_MSG_TYPE(GET_BE_U_2(ldp_msg_header
->type
));
697 if (msg_len
< sizeof(struct ldp_msg_header
)-4) {
698 /* length too short */
699 /* FIXME vendor private / experimental check */
700 ND_PRINT("\n\t %s Message (0x%04x), length: %u (too short, < %zu)",
701 tok2str(ldp_msg_values
,
706 sizeof(struct ldp_msg_header
)-4);
710 /* FIXME vendor private / experimental check */
711 ND_PRINT("\n\t %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]",
712 tok2str(ldp_msg_values
,
717 GET_BE_U_4(ldp_msg_header
->id
),
718 LDP_MASK_U_BIT(GET_BE_U_2(ldp_msg_header
->type
)) ? "continue processing" : "ignore");
720 msg_tptr
=tptr
+sizeof(struct ldp_msg_header
);
721 msg_tlen
=msg_len
-(sizeof(struct ldp_msg_header
)-4); /* Type & Length fields not included */
723 /* did we capture enough for fully decoding the message ? */
724 ND_TCHECK_LEN(tptr
, msg_len
);
732 case LDP_MSG_KEEPALIVE
:
733 case LDP_MSG_ADDRESS
:
734 case LDP_MSG_LABEL_MAPPING
:
735 case LDP_MSG_ADDRESS_WITHDRAW
:
736 case LDP_MSG_LABEL_WITHDRAW
:
737 case LDP_MSG_LABEL_REQUEST
:
738 case LDP_MSG_LABEL_RELEASE
:
739 case LDP_MSG_LABEL_ABORT_REQUEST
:
740 while(msg_tlen
>= 4) {
741 processed
= ldp_tlv_print(ndo
, msg_tptr
, msg_tlen
);
750 if (ndo
->ndo_vflag
<= 1)
751 print_unknown_data(ndo
, msg_tptr
, "\n\t ", msg_tlen
);
754 /* do we want to see an additionally hexdump ? */
755 if (ndo
->ndo_vflag
> 1 || hexdump
==TRUE
)
756 print_unknown_data(ndo
, tptr
+sizeof(struct ldp_msg_header
), "\n\t ",
764 nd_trunc_longjmp(ndo
);