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 */
23 #include "netdissect-stdinc.h"
25 #include "netdissect.h"
27 #include "addrtoname.h"
36 * 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
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 * | Version | PDU Length |
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 struct ldp_common_header
{
49 nd_uint16_t pdu_length
;
51 nd_uint16_t label_space
;
60 * 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
61 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62 * |U| Message Type | Message Length |
63 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 * | Mandatory Parameters |
71 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 * | Optional Parameters |
77 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80 struct ldp_msg_header
{
86 #define LDP_MASK_MSG_TYPE(x) ((x)&0x7fff)
87 #define LDP_MASK_U_BIT(x) ((x)&0x8000)
89 #define LDP_MSG_NOTIF 0x0001
90 #define LDP_MSG_HELLO 0x0100
91 #define LDP_MSG_INIT 0x0200
92 #define LDP_MSG_KEEPALIVE 0x0201
93 #define LDP_MSG_ADDRESS 0x0300
94 #define LDP_MSG_ADDRESS_WITHDRAW 0x0301
95 #define LDP_MSG_LABEL_MAPPING 0x0400
96 #define LDP_MSG_LABEL_REQUEST 0x0401
97 #define LDP_MSG_LABEL_WITHDRAW 0x0402
98 #define LDP_MSG_LABEL_RELEASE 0x0403
99 #define LDP_MSG_LABEL_ABORT_REQUEST 0x0404
101 #define LDP_VENDOR_PRIVATE_MIN 0x3e00
102 #define LDP_VENDOR_PRIVATE_MAX 0x3eff
103 #define LDP_EXPERIMENTAL_MIN 0x3f00
104 #define LDP_EXPERIMENTAL_MAX 0x3fff
106 static const struct tok ldp_msg_values
[] = {
107 { LDP_MSG_NOTIF
, "Notification" },
108 { LDP_MSG_HELLO
, "Hello" },
109 { LDP_MSG_INIT
, "Initialization" },
110 { LDP_MSG_KEEPALIVE
, "Keepalive" },
111 { LDP_MSG_ADDRESS
, "Address" },
112 { LDP_MSG_ADDRESS_WITHDRAW
, "Address Withdraw" },
113 { LDP_MSG_LABEL_MAPPING
, "Label Mapping" },
114 { LDP_MSG_LABEL_REQUEST
, "Label Request" },
115 { LDP_MSG_LABEL_WITHDRAW
, "Label Withdraw" },
116 { LDP_MSG_LABEL_RELEASE
, "Label Release" },
117 { LDP_MSG_LABEL_ABORT_REQUEST
, "Label Abort Request" },
121 #define LDP_MASK_TLV_TYPE(x) ((x)&0x3fff)
122 #define LDP_MASK_F_BIT(x) ((x)&0x4000)
124 #define LDP_TLV_FEC 0x0100
125 #define LDP_TLV_ADDRESS_LIST 0x0101
126 #define LDP_TLV_ADDRESS_LIST_AFNUM_LEN 2
127 #define LDP_TLV_HOP_COUNT 0x0103
128 #define LDP_TLV_PATH_VECTOR 0x0104
129 #define LDP_TLV_GENERIC_LABEL 0x0200
130 #define LDP_TLV_ATM_LABEL 0x0201
131 #define LDP_TLV_FR_LABEL 0x0202
132 #define LDP_TLV_STATUS 0x0300
133 #define LDP_TLV_EXTD_STATUS 0x0301
134 #define LDP_TLV_RETURNED_PDU 0x0302
135 #define LDP_TLV_RETURNED_MSG 0x0303
136 #define LDP_TLV_COMMON_HELLO 0x0400
137 #define LDP_TLV_IPV4_TRANSPORT_ADDR 0x0401
138 #define LDP_TLV_CONFIG_SEQ_NUMBER 0x0402
139 #define LDP_TLV_IPV6_TRANSPORT_ADDR 0x0403
140 #define LDP_TLV_COMMON_SESSION 0x0500
141 #define LDP_TLV_ATM_SESSION_PARM 0x0501
142 #define LDP_TLV_FR_SESSION_PARM 0x0502
143 #define LDP_TLV_FT_SESSION 0x0503
144 #define LDP_TLV_TYPED_WC_FEC_CAP 0x050b /* rfc 5918 */
145 #define LDP_TLV_LABEL_REQUEST_MSG_ID 0x0600
146 #define LDP_TLV_MTU 0x0601 /* rfc 3988 */
147 #define LDP_TLV_DUAL_STACK_CAP 0x0701 /* rfc 7552 */
149 static const struct tok ldp_tlv_values
[] = {
150 { LDP_TLV_FEC
, "FEC" },
151 { LDP_TLV_ADDRESS_LIST
, "Address List" },
152 { LDP_TLV_HOP_COUNT
, "Hop Count" },
153 { LDP_TLV_PATH_VECTOR
, "Path Vector" },
154 { LDP_TLV_GENERIC_LABEL
, "Generic Label" },
155 { LDP_TLV_ATM_LABEL
, "ATM Label" },
156 { LDP_TLV_FR_LABEL
, "Frame-Relay Label" },
157 { LDP_TLV_STATUS
, "Status" },
158 { LDP_TLV_EXTD_STATUS
, "Extended Status" },
159 { LDP_TLV_RETURNED_PDU
, "Returned PDU" },
160 { LDP_TLV_RETURNED_MSG
, "Returned Message" },
161 { LDP_TLV_COMMON_HELLO
, "Common Hello Parameters" },
162 { LDP_TLV_IPV4_TRANSPORT_ADDR
, "IPv4 Transport Address" },
163 { LDP_TLV_CONFIG_SEQ_NUMBER
, "Configuration Sequence Number" },
164 { LDP_TLV_IPV6_TRANSPORT_ADDR
, "IPv6 Transport Address" },
165 { LDP_TLV_COMMON_SESSION
, "Common Session Parameters" },
166 { LDP_TLV_ATM_SESSION_PARM
, "ATM Session Parameters" },
167 { LDP_TLV_FR_SESSION_PARM
, "Frame-Relay Session Parameters" },
168 { LDP_TLV_FT_SESSION
, "Fault-Tolerant Session Parameters" },
169 { LDP_TLV_TYPED_WC_FEC_CAP
, "Typed Wildcard FEC Capability" },
170 { LDP_TLV_LABEL_REQUEST_MSG_ID
, "Label Request Message ID" },
171 { LDP_TLV_MTU
, "MTU" },
172 { LDP_TLV_DUAL_STACK_CAP
, "Dual-Stack Capability" },
176 static const struct tok ldp_status_code_values
[] = {
178 { 0x00000000, "Success" },
179 { 0x00000001, "Bad LDP Identifier" },
180 { 0x00000002, "Bad Protocol Version" },
181 { 0x00000003, "Bad PDU Length" },
182 { 0x00000004, "Unknown Message Type" },
183 { 0x00000005, "Bad Message Length" },
184 { 0x00000006, "Unknown TLV" },
185 { 0x00000007, "Bad TLV Length" },
186 { 0x00000008, "Malformted TLV Value" },
187 { 0x00000009, "Hold Timer Expired" },
188 { 0x0000000A, "Shutdown" },
189 { 0x0000000B, "Loop Detected" },
190 { 0x0000000C, "Unknown FEC" },
191 { 0x0000000D, "No Route" },
192 { 0x0000000E, "No Label Resources" },
193 { 0x0000000F, "Label Resources/Available" },
194 { 0x00000010, "Session Rejected/No Hello" },
195 { 0x00000011, "Session Rejected/Parameters Advertisement Mode" },
196 { 0x00000012, "Session Rejected/Parameters Max PDU Length" },
197 { 0x00000013, "Session Rejected/Parameters Label Range" },
198 { 0x00000014, "KeepAlive Timer Expired" },
199 { 0x00000015, "Label Request Aborted" },
200 { 0x00000016, "Missing Message Parameters" },
201 { 0x00000017, "Unsupported Address Family" },
202 { 0x00000018, "Session Rejected/Bad KeepAlive Time" },
203 { 0x00000019, "Internal Error" },
207 #define LDP_FEC_WILDCARD 0x01
208 #define LDP_FEC_PREFIX 0x02
209 #define LDP_FEC_HOSTADDRESS 0x03
210 /* From RFC 4906; should probably be updated to RFC 4447 (e.g., VC -> PW) */
211 #define LDP_FEC_MARTINI_VC 0x80
213 static const struct tok ldp_fec_values
[] = {
214 { LDP_FEC_WILDCARD
, "Wildcard" },
215 { LDP_FEC_PREFIX
, "Prefix" },
216 { LDP_FEC_HOSTADDRESS
, "Host address" },
217 { LDP_FEC_MARTINI_VC
, "Martini VC" },
221 #define LDP_FEC_MARTINI_IFPARM_MTU 0x01
222 #define LDP_FEC_MARTINI_IFPARM_DESC 0x03
223 #define LDP_FEC_MARTINI_IFPARM_VCCV 0x0c
225 static const struct tok ldp_fec_martini_ifparm_values
[] = {
226 { LDP_FEC_MARTINI_IFPARM_MTU
, "MTU" },
227 { LDP_FEC_MARTINI_IFPARM_DESC
, "Description" },
228 { LDP_FEC_MARTINI_IFPARM_VCCV
, "VCCV" },
232 /* draft-ietf-pwe3-vccv-04.txt */
233 static const struct tok ldp_fec_martini_ifparm_vccv_cc_values
[] = {
234 { 0x01, "PWE3 control word" },
235 { 0x02, "MPLS Router Alert Label" },
236 { 0x04, "MPLS inner label TTL = 1" },
240 /* draft-ietf-pwe3-vccv-04.txt */
241 static const struct tok ldp_fec_martini_ifparm_vccv_cv_values
[] = {
242 { 0x01, "ICMP Ping" },
243 { 0x02, "LSP Ping" },
249 #define LDP_DUAL_STACK_TRANSPORT_PREF_IPV4 0x40
250 #define LDP_DUAL_STACK_TRANSPORT_PREF_IPV6 0x60
252 static const struct tok ldp_dual_stack_transport_pref_values
[] = {
253 { LDP_DUAL_STACK_TRANSPORT_PREF_IPV4
, "IPv4" },
254 { LDP_DUAL_STACK_TRANSPORT_PREF_IPV6
, "IPv6" },
258 static u_int
ldp_pdu_print(netdissect_options
*, const u_char
*);
264 * 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
265 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
266 * |U|F| Type | Length |
267 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
272 * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
274 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
278 ldp_tlv_print(netdissect_options
*ndo
,
282 struct ldp_tlv_header
{
287 const struct ldp_tlv_header
*ldp_tlv_header
;
288 u_short tlv_type
,tlv_len
,tlv_tlen
,af
,ft_flags
;
289 u_char fec_type
, transport_pref
;
290 u_int ui
,vc_info_len
, vc_info_tlv_type
, vc_info_tlv_len
,idx
;
294 ldp_tlv_header
= (const struct ldp_tlv_header
*)tptr
;
295 ND_TCHECK_SIZE(ldp_tlv_header
);
296 tlv_len
=GET_BE_U_2(ldp_tlv_header
->length
);
297 if (tlv_len
+ 4U > msg_tlen
) {
298 ND_PRINT("\n\t\t TLV contents go past end of message");
302 tlv_type
=LDP_MASK_TLV_TYPE(GET_BE_U_2(ldp_tlv_header
->type
));
304 /* FIXME vendor private / experimental check */
305 ND_PRINT("\n\t %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]",
306 tok2str(ldp_tlv_values
,
311 LDP_MASK_U_BIT(GET_BE_U_2(ldp_tlv_header
->type
)) ? "continue processing" : "ignore",
312 LDP_MASK_F_BIT(GET_BE_U_2(ldp_tlv_header
->type
)) ? "do" : "don't");
314 tptr
+=sizeof(struct ldp_tlv_header
);
318 case LDP_TLV_COMMON_HELLO
:
319 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
320 ND_PRINT("\n\t Hold Time: %us, Flags: [%s Hello%s]",
322 (GET_BE_U_2(tptr
+ 2)&0x8000) ? "Targeted" : "Link",
323 (GET_BE_U_2(tptr
+ 2)&0x4000) ? ", Request for targeted Hellos" : "");
326 case LDP_TLV_IPV4_TRANSPORT_ADDR
:
327 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
328 ND_PRINT("\n\t IPv4 Transport Address: %s", GET_IPADDR_STRING(tptr
));
330 case LDP_TLV_IPV6_TRANSPORT_ADDR
:
331 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 16);
332 ND_PRINT("\n\t IPv6 Transport Address: %s", GET_IP6ADDR_STRING(tptr
));
334 case LDP_TLV_CONFIG_SEQ_NUMBER
:
335 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
336 ND_PRINT("\n\t Sequence Number: %u", GET_BE_U_4(tptr
));
339 case LDP_TLV_ADDRESS_LIST
:
340 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <,
341 LDP_TLV_ADDRESS_LIST_AFNUM_LEN
);
342 af
= GET_BE_U_2(tptr
);
343 tptr
+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN
;
344 tlv_tlen
-= LDP_TLV_ADDRESS_LIST_AFNUM_LEN
;
345 ND_PRINT("\n\t Address Family: %s, addresses",
346 tok2str(af_values
, "Unknown (%u)", af
));
349 while(tlv_tlen
>= sizeof(nd_ipv4
)) {
350 ND_PRINT(" %s", GET_IPADDR_STRING(tptr
));
351 tlv_tlen
-=sizeof(nd_ipv4
);
352 tptr
+=sizeof(nd_ipv4
);
356 while(tlv_tlen
>= sizeof(nd_ipv6
)) {
357 ND_PRINT(" %s", GET_IP6ADDR_STRING(tptr
));
358 tlv_tlen
-=sizeof(nd_ipv6
);
359 tptr
+=sizeof(nd_ipv6
);
368 case LDP_TLV_HOP_COUNT
:
369 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 1);
370 ND_PRINT("\n\t Hop Count: %u", GET_U_1(tptr
));
373 case LDP_TLV_PATH_VECTOR
:
374 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
375 ND_PRINT("\n\t Path Vector: %s", GET_IPADDR_STRING(tptr
));
378 while (tlv_tlen
>= 4) {
379 ND_PRINT(", %s", GET_IPADDR_STRING(tptr
));
385 case LDP_TLV_COMMON_SESSION
:
386 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 14);
387 ND_PRINT("\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
388 GET_BE_U_2(tptr
), GET_BE_U_2(tptr
+ 2),
389 (GET_BE_U_2(tptr
+ 4)&0x8000) ? "On Demand" : "Unsolicited",
390 (GET_BE_U_2(tptr
+ 4)&0x4000) ? "Enabled" : "Disabled"
392 ND_PRINT("\n\t Path Vector Limit %u, Max-PDU length: %u, Receiver Label-Space-ID %s:%u",
395 GET_IPADDR_STRING(tptr
+8),
401 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 1);
402 fec_type
= GET_U_1(tptr
);
403 ND_PRINT("\n\t %s FEC (0x%02x)",
404 tok2str(ldp_fec_values
, "Unknown", fec_type
),
411 case LDP_FEC_WILDCARD
:
414 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 2);
415 af
= GET_BE_U_2(tptr
);
418 if (af
== AFNUM_IP
) {
419 i
=decode_prefix4(ndo
, tptr
, tlv_tlen
, buf
, sizeof(buf
));
423 ND_PRINT(": IPv4 prefix (goes past end of TLV)");
425 ND_PRINT(": IPv4 prefix (invalid length)");
427 ND_PRINT(": IPv4 prefix %s", buf
);
428 } else if (af
== AFNUM_IP6
) {
429 i
=decode_prefix6(ndo
, tptr
, tlv_tlen
, buf
, sizeof(buf
));
433 ND_PRINT(": IPv4 prefix (goes past end of TLV)");
435 ND_PRINT(": IPv6 prefix (invalid length)");
437 ND_PRINT(": IPv6 prefix %s", buf
);
439 ND_PRINT(": Address family %u prefix", af
);
441 case LDP_FEC_HOSTADDRESS
:
443 case LDP_FEC_MARTINI_VC
:
445 * We assume the type was supposed to be one of the MPLS
448 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 7);
449 vc_info_len
= GET_U_1(tptr
+ 2);
452 * According to RFC 4908, the VC info Length field can be zero,
453 * in which case not only are there no interface parameters,
456 if (vc_info_len
== 0) {
457 ND_PRINT(": %s, %scontrol word, group-ID %u, VC-info-length: %u",
458 tok2str(mpls_pw_types_values
, "Unknown", GET_BE_U_2(tptr
)&0x7fff),
459 GET_BE_U_2(tptr
)&0x8000 ? "" : "no ",
460 GET_BE_U_4(tptr
+ 3),
465 /* Make sure we have the VC ID as well */
466 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 11);
467 ND_PRINT(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
468 tok2str(mpls_pw_types_values
, "Unknown", GET_BE_U_2(tptr
)&0x7fff),
469 GET_BE_U_2(tptr
)&0x8000 ? "" : "no ",
470 GET_BE_U_4(tptr
+ 3),
471 GET_BE_U_4(tptr
+ 7),
473 if (vc_info_len
< 4) {
474 /* minimum 4, for the VC ID */
475 ND_PRINT(" (invalid, < 4");
476 return(tlv_len
+4); /* Type & Length fields not included */
478 vc_info_len
-= 4; /* subtract out the VC ID, giving the length of the interface parameters */
480 /* Skip past the fixed information and the VC ID */
483 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, vc_info_len
);
485 while (vc_info_len
> 2) {
486 vc_info_tlv_type
= GET_U_1(tptr
);
487 vc_info_tlv_len
= GET_U_1(tptr
+ 1);
488 if (vc_info_tlv_len
< 2)
490 if (vc_info_len
< vc_info_tlv_len
)
493 ND_PRINT("\n\t\tInterface Parameter: %s (0x%02x), len %u",
494 tok2str(ldp_fec_martini_ifparm_values
,"Unknown",vc_info_tlv_type
),
498 switch(vc_info_tlv_type
) {
499 case LDP_FEC_MARTINI_IFPARM_MTU
:
500 ND_PRINT(": %u", GET_BE_U_2(tptr
+ 2));
503 case LDP_FEC_MARTINI_IFPARM_DESC
:
505 for (idx
= 2; idx
< vc_info_tlv_len
; idx
++)
506 fn_print_char(ndo
, GET_U_1(tptr
+ idx
));
509 case LDP_FEC_MARTINI_IFPARM_VCCV
:
510 ND_PRINT("\n\t\t Control Channels (0x%02x) = [%s]",
512 bittok2str(ldp_fec_martini_ifparm_vccv_cc_values
, "none", GET_U_1((tptr
+ 2))));
513 ND_PRINT("\n\t\t CV Types (0x%02x) = [%s]",
515 bittok2str(ldp_fec_martini_ifparm_vccv_cv_values
, "none", GET_U_1((tptr
+ 3))));
519 print_unknown_data(ndo
, tptr
+2, "\n\t\t ", vc_info_tlv_len
-2);
523 vc_info_len
-= vc_info_tlv_len
;
524 tptr
+= vc_info_tlv_len
;
531 case LDP_TLV_GENERIC_LABEL
:
532 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
533 ND_PRINT("\n\t Label: %u", GET_BE_U_4(tptr
) & 0xfffff);
537 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 10);
538 ui
= GET_BE_U_4(tptr
);
540 ND_PRINT("\n\t Status Code: %s, Flags: [%s and %s forward]",
541 tok2str(ldp_status_code_values
, "Unknown", ui
&0x3fffffff),
542 ui
&0x80000000 ? "Fatal error" : "Advisory Notification",
543 ui
&0x40000000 ? "do" : "don't");
544 ui
= GET_BE_U_4(tptr
);
547 ND_PRINT(", causing Message ID: 0x%08x", ui
);
548 ui
= GET_BE_U_2(tptr
);
550 ND_PRINT(", Message Type: %s", tok2str(ldp_msg_values
, "Unknown", ui
));
553 case LDP_TLV_FT_SESSION
:
554 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 12);
555 ft_flags
= GET_BE_U_2(tptr
);
556 ND_PRINT("\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
557 ft_flags
&0x8000 ? "" : "No ",
558 ft_flags
&0x8 ? "" : "Don't ",
559 ft_flags
&0x4 ? "" : "No ",
560 ft_flags
&0x2 ? "Sequence Numbered Label" : "All Labels",
561 ft_flags
&0x1 ? "" : "Don't ");
562 /* 16 bits (FT Flags) + 16 bits (Reserved) */
564 ui
= GET_BE_U_4(tptr
);
566 ND_PRINT(", Reconnect Timeout: %ums", ui
);
568 ui
= GET_BE_U_4(tptr
);
570 ND_PRINT(", Recovery Time: %ums", ui
);
573 case LDP_TLV_TYPED_WC_FEC_CAP
:
574 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 1);
575 ND_PRINT("\n\t %s", GET_U_1(tptr
)&0x80 ? "Support" : "No Support");
579 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 2);
580 ND_PRINT("\n\t MTU: %u", GET_BE_U_2(tptr
));
583 case LDP_TLV_DUAL_STACK_CAP
:
584 ND_ICHECKMSG_U("tlv length", tlv_tlen
, <, 4);
585 transport_pref
= GET_U_1(tptr
);
586 ND_PRINT("\n\t Transport Connection Preference: %s",
587 tok2str(ldp_dual_stack_transport_pref_values
,
593 * FIXME those are the defined TLVs that lack a decoder
594 * you are welcome to contribute code ;-)
597 case LDP_TLV_ATM_LABEL
:
598 case LDP_TLV_FR_LABEL
:
599 case LDP_TLV_EXTD_STATUS
:
600 case LDP_TLV_RETURNED_PDU
:
601 case LDP_TLV_RETURNED_MSG
:
602 case LDP_TLV_ATM_SESSION_PARM
:
603 case LDP_TLV_FR_SESSION_PARM
:
604 case LDP_TLV_LABEL_REQUEST_MSG_ID
:
607 if (ndo
->ndo_vflag
<= 1)
608 print_unknown_data(ndo
, tptr
, "\n\t ", tlv_tlen
);
611 return(tlv_len
+4); /* Type & Length fields not included */
614 nd_trunc_longjmp(ndo
);
617 nd_print_invalid(ndo
);
618 return(tlv_len
+4); /* Type & Length fields not included */
622 ldp_print(netdissect_options
*ndo
,
623 const u_char
*pptr
, u_int len
)
627 ndo
->ndo_protocol
= "ldp";
628 while (len
> (sizeof(struct ldp_common_header
) + sizeof(struct ldp_msg_header
))) {
629 processed
= ldp_pdu_print(ndo
, pptr
);
632 if (len
< processed
) {
633 ND_PRINT(" [remaining length %u < %u]", len
, processed
);
634 nd_print_invalid(ndo
);
643 ldp_pdu_print(netdissect_options
*ndo
,
646 const struct ldp_common_header
*ldp_com_header
;
647 const struct ldp_msg_header
*ldp_msg_header
;
648 const u_char
*tptr
,*msg_tptr
;
650 u_short pdu_len
,msg_len
,msg_type
;
652 int hexdump
,processed
;
654 ldp_com_header
= (const struct ldp_common_header
*)pptr
;
655 ND_TCHECK_SIZE(ldp_com_header
);
658 * Sanity checking of the header.
660 if (GET_BE_U_2(ldp_com_header
->version
) != LDP_VERSION
) {
661 ND_PRINT("%sLDP version %u packet not supported",
662 (ndo
->ndo_vflag
< 1) ? "" : "\n\t",
663 GET_BE_U_2(ldp_com_header
->version
));
667 pdu_len
= GET_BE_U_2(ldp_com_header
->pdu_length
);
668 if (pdu_len
< sizeof(struct ldp_common_header
)-4) {
669 /* length too short */
670 ND_PRINT("%sLDP, pdu-length: %u (too short, < %zu)",
671 (ndo
->ndo_vflag
< 1) ? "" : "\n\t",
673 sizeof(struct ldp_common_header
)-4);
677 /* print the LSR-ID, label-space & length */
678 ND_PRINT("%sLDP, Label-Space-ID: %s:%u, pdu-length: %u",
679 (ndo
->ndo_vflag
< 1) ? "" : "\n\t",
680 GET_IPADDR_STRING(ldp_com_header
->lsr_id
),
681 GET_BE_U_2(ldp_com_header
->label_space
),
684 /* bail out if non-verbose */
685 if (ndo
->ndo_vflag
< 1)
688 /* ok they seem to want to know everything - lets fully decode it */
689 tptr
= pptr
+ sizeof(struct ldp_common_header
);
690 tlen
= pdu_len
- (sizeof(struct ldp_common_header
)-4); /* Type & Length fields not included */
693 /* did we capture enough for fully decoding the msg header ? */
694 ND_TCHECK_LEN(tptr
, sizeof(struct ldp_msg_header
));
696 ldp_msg_header
= (const struct ldp_msg_header
*)tptr
;
697 msg_len
=GET_BE_U_2(ldp_msg_header
->length
);
698 msg_type
=LDP_MASK_MSG_TYPE(GET_BE_U_2(ldp_msg_header
->type
));
700 if (msg_len
< sizeof(struct ldp_msg_header
)-4) {
701 /* length too short */
702 /* FIXME vendor private / experimental check */
703 ND_PRINT("\n\t %s Message (0x%04x), length: %u (too short, < %zu)",
704 tok2str(ldp_msg_values
,
709 sizeof(struct ldp_msg_header
)-4);
713 /* FIXME vendor private / experimental check */
714 ND_PRINT("\n\t %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]",
715 tok2str(ldp_msg_values
,
720 GET_BE_U_4(ldp_msg_header
->id
),
721 LDP_MASK_U_BIT(GET_BE_U_2(ldp_msg_header
->type
)) ? "continue processing" : "ignore");
723 msg_tptr
=tptr
+sizeof(struct ldp_msg_header
);
724 msg_tlen
=msg_len
-(sizeof(struct ldp_msg_header
)-4); /* Type & Length fields not included */
726 /* did we capture enough for fully decoding the message ? */
727 ND_TCHECK_LEN(tptr
, msg_len
);
735 case LDP_MSG_KEEPALIVE
:
736 case LDP_MSG_ADDRESS
:
737 case LDP_MSG_LABEL_MAPPING
:
738 case LDP_MSG_ADDRESS_WITHDRAW
:
739 case LDP_MSG_LABEL_WITHDRAW
:
740 case LDP_MSG_LABEL_REQUEST
:
741 case LDP_MSG_LABEL_RELEASE
:
742 case LDP_MSG_LABEL_ABORT_REQUEST
:
743 while(msg_tlen
>= 4) {
744 processed
= ldp_tlv_print(ndo
, msg_tptr
, msg_tlen
);
753 if (ndo
->ndo_vflag
<= 1)
754 print_unknown_data(ndo
, msg_tptr
, "\n\t ", msg_tlen
);
757 /* do we want to see an additionally hexdump ? */
758 if (ndo
->ndo_vflag
> 1 || hexdump
==TRUE
)
759 print_unknown_data(ndo
, tptr
+sizeof(struct ldp_msg_header
), "\n\t ",
767 nd_trunc_longjmp(ndo
);