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)
16 /* \summary: MPLS LSP PING printer */
18 /* specification: RFC 4379 */
24 #include "netdissect-stdinc.h"
26 #include "netdissect.h"
28 #include "addrtoname.h"
36 * LSPPING common header
39 * 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
40 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 * | Version Number | Must Be Zero |
42 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 * | Message Type | Reply mode | Return Code | Return Subcode|
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * | TimeStamp Sent (seconds) |
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * | TimeStamp Sent (microseconds) |
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 * | TimeStamp Received (seconds) |
54 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 * | TimeStamp Received (microseconds) |
56 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 struct lspping_common_header
{
65 nd_uint16_t global_flags
;
67 nd_uint8_t reply_mode
;
68 nd_uint8_t return_code
;
69 nd_uint8_t return_subcode
;
70 nd_uint32_t sender_handle
;
71 nd_uint32_t seq_number
;
72 struct l_fixedpt ts_sent
;
73 struct l_fixedpt ts_rcvd
;
76 #define LSPPING_VERSION 1
78 static const struct tok lspping_msg_type_values
[] = {
79 { 1, "MPLS Echo Request"},
80 { 2, "MPLS Echo Reply"},
84 static const struct tok lspping_reply_mode_values
[] = {
86 { 2, "Reply via an IPv4/IPv6 UDP packet"},
87 { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
88 { 4, "Reply via application level control channel"},
92 static const struct tok lspping_return_code_values
[] = {
93 { 0, "No return code or return code contained in the Error Code TLV"},
94 { 1, "Malformed echo request received"},
95 { 2, "One or more of the TLVs was not understood"},
96 { 3, "Replying router is an egress for the FEC at stack depth"},
97 { 4, "Replying router has no mapping for the FEC at stack depth"},
101 { 8, "Label switched at stack-depth"},
102 { 9, "Label switched but no MPLS forwarding at stack-depth"},
103 { 10, "Mapping for this FEC is not the given label at stack depth"},
104 { 11, "No label entry at stack-depth"},
105 { 12, "Protocol not associated with interface at FEC stack depth"},
106 { 13, "Premature termination of ping due to label stack shrinking to a single label"},
114 * 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
115 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
117 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
123 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
126 struct lspping_tlv_header
{
131 #define LSPPING_TLV_TARGET_FEC_STACK 1
132 #define LSPPING_TLV_DOWNSTREAM_MAPPING 2
133 #define LSPPING_TLV_PAD 3
135 #define LSPPING_TLV_VENDOR_ENTERPRISE 5
136 #define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
138 #define LSPPING_TLV_INTERFACE_LABEL_STACK 7
140 #define LSPPING_TLV_ERROR_CODE 9
141 #define LSPPING_TLV_REPLY_TOS_BYTE 10
142 #define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
143 #define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
144 #define LSPPING_TLV_VENDOR_PRIVATE 0xfc00
146 static const struct tok lspping_tlv_values
[] = {
147 { LSPPING_TLV_TARGET_FEC_STACK
, "Target FEC Stack" },
148 { LSPPING_TLV_DOWNSTREAM_MAPPING
, "Downstream Mapping" },
149 { LSPPING_TLV_PAD
, "Pad" },
150 { LSPPING_TLV_ERROR_CODE
, "Error Code" },
151 { LSPPING_TLV_VENDOR_ENTERPRISE
, "Vendor Enterprise Code" },
152 { LSPPING_TLV_INTERFACE_LABEL_STACK
, "Interface Label Stack" },
153 { LSPPING_TLV_REPLY_TOS_BYTE
, "Reply TOS Byte" },
154 { LSPPING_TLV_BFD_DISCRIMINATOR
, "BFD Discriminator" },
155 { LSPPING_TLV_VENDOR_PRIVATE
, "Vendor Private Code" },
159 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
160 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
161 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
162 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
164 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
165 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
166 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
167 #define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD 9
168 #define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW 10
169 #define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_129_PW 11
170 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 12
171 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 13
172 #define LSPPING_TLV_TARGETFEC_SUBTLV_GENERIC_IPV4 14
173 #define LSPPING_TLV_TARGETFEC_SUBTLV_GENERIC_IPV6 15
174 #define LSPPING_TLV_TARGETFEC_SUBTLV_NIL_FEC 16
176 static const struct tok lspping_tlvtargetfec_subtlv_values
[] = {
177 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4
, "LDP IPv4 prefix"},
178 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6
, "LDP IPv6 prefix"},
179 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4
, "RSVP IPv4 Session Query"},
180 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6
, "RSVP IPv6 Session Query"},
182 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4
, "VPN IPv4 prefix"},
183 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6
, "VPN IPv6 prefix"},
184 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT
, "L2 VPN endpoint"},
185 { LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD
, "FEC 128 pseudowire (old)"},
186 { LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW
, "FEC 128 pseudowire"},
187 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4
, "BGP labeled IPv4 prefix"},
188 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6
, "BGP labeled IPv6 prefix"},
194 * 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
195 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
197 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
198 * | Prefix Length | Must Be Zero |
199 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
{
203 nd_uint8_t prefix_len
;
208 * 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
209 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
214 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
215 * | Prefix Length | Must Be Zero |
216 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
218 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
{
220 nd_uint8_t prefix_len
;
225 * 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
226 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
227 * | IPv4 tunnel end point address |
228 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
229 * | Must Be Zero | Tunnel ID |
230 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
231 * | Extended Tunnel ID |
232 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
233 * | IPv4 tunnel sender address |
234 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
235 * | Must Be Zero | LSP ID |
236 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
{
239 nd_ipv4 tunnel_endpoint
;
241 nd_uint16_t tunnel_id
;
242 nd_ipv4 extended_tunnel_id
;
243 nd_ipv4 tunnel_sender
;
250 * 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
251 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
252 * | IPv6 tunnel end point address |
256 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257 * | Must Be Zero | Tunnel ID |
258 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259 * | Extended Tunnel ID |
263 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
264 * | IPv6 tunnel sender address |
268 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
269 * | Must Be Zero | LSP ID |
270 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
272 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
{
273 nd_ipv6 tunnel_endpoint
;
275 nd_uint16_t tunnel_id
;
276 nd_ipv6 extended_tunnel_id
;
277 nd_ipv6 tunnel_sender
;
284 * 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
285 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
286 * | Route Distinguisher |
288 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
290 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
291 * | Prefix Length | Must Be Zero |
292 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
294 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
{
297 nd_uint8_t prefix_len
;
302 * 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
303 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
304 * | Route Distinguisher |
306 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
311 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
312 * | Prefix Length | Must Be Zero |
313 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
315 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
{
318 nd_uint8_t prefix_len
;
323 * 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
324 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
325 * | Route Distinguisher |
327 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
328 * | Sender's VE ID | Receiver's VE ID |
329 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
330 * | Encapsulation Type | Must Be Zero |
331 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
334 struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
{
336 nd_uint16_t sender_ve_id
;
337 nd_uint16_t receiver_ve_id
;
338 nd_uint16_t encapsulation
;
342 * 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
343 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
344 * | Remote PE Address |
345 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
347 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
348 * | PW Type | Must Be Zero |
349 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
351 struct lspping_tlv_targetfec_subtlv_fec_128_pw_old
{
352 nd_ipv4 remote_pe_address
;
358 * 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
359 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
360 * | Sender's PE Address |
361 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
362 * | Remote PE Address |
363 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
365 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
366 * | PW Type | Must Be Zero |
367 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
369 struct lspping_tlv_targetfec_subtlv_fec_128_pw
{
370 nd_ipv4 sender_pe_address
;
371 nd_ipv4 remote_pe_address
;
377 * 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
378 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
380 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
381 * | Prefix Length | Must Be Zero |
382 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
384 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
{
386 nd_uint8_t prefix_len
;
390 * 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
391 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
396 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
397 * | Prefix Length | Must Be Zero |
398 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
400 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
{
402 nd_uint8_t prefix_len
;
407 * 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
408 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
409 * | MTU | Address Type | Resvd (SBZ) |
410 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
411 * | Downstream IP Address (4 or 16 octets) |
412 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
413 * | Downstream Interface Address (4 or 16 octets) |
414 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
415 * | Multipath Type| Depth Limit | Multipath Length |
416 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
418 * . (Multipath Information) .
420 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
421 * | Downstream Label | Protocol |
422 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
426 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
427 * | Downstream Label | Protocol |
428 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
430 /* Enough to get the address type */
431 struct lspping_tlv_downstream_map_t
{
433 nd_uint8_t address_type
;
437 struct lspping_tlv_downstream_map_ipv4_t
{
439 nd_uint8_t address_type
;
441 nd_ipv4 downstream_ip
;
442 nd_ipv4 downstream_interface
;
445 struct lspping_tlv_downstream_map_ipv4_unmb_t
{
447 nd_uint8_t address_type
;
449 nd_ipv4 downstream_ip
;
450 nd_uint32_t downstream_interface
;
453 struct lspping_tlv_downstream_map_ipv6_t
{
455 nd_uint8_t address_type
;
457 nd_ipv6 downstream_ip
;
458 nd_ipv6 downstream_interface
;
461 struct lspping_tlv_downstream_map_ipv6_unmb_t
{
463 nd_uint8_t address_type
;
465 nd_ipv6 downstream_ip
;
466 nd_uint32_t downstream_interface
;
469 struct lspping_tlv_downstream_map_info_t
{
470 nd_uint8_t multipath_type
;
471 nd_uint8_t depth_limit
;
472 nd_uint16_t multipath_length
;
475 #define LSPPING_AFI_IPV4 1
476 #define LSPPING_AFI_IPV4_UNMB 2
477 #define LSPPING_AFI_IPV6 3
478 #define LSPPING_AFI_IPV6_UNMB 4
480 static const struct tok lspping_tlv_downstream_addr_values
[] = {
481 { LSPPING_AFI_IPV4
, "IPv4"},
482 { LSPPING_AFI_IPV4_UNMB
, "Unnumbered IPv4"},
483 { LSPPING_AFI_IPV6
, "IPv6"},
484 { LSPPING_AFI_IPV6_UNMB
, "IPv6"},
489 lspping_print(netdissect_options
*ndo
,
490 const u_char
*pptr
, u_int len
)
492 const struct lspping_common_header
*lspping_com_header
;
493 const struct lspping_tlv_header
*lspping_tlv_header
;
494 const struct lspping_tlv_header
*lspping_subtlv_header
;
495 const u_char
*tptr
,*tlv_tptr
,*subtlv_tptr
;
496 u_int return_code
, return_subcode
;
497 u_int tlen
,lspping_tlv_len
,lspping_tlv_type
,tlv_tlen
;
498 int tlv_hexdump
,subtlv_hexdump
;
499 u_int lspping_subtlv_len
,lspping_subtlv_type
;
500 uint32_t int_part
, fraction
;
504 const struct lspping_tlv_downstream_map_t
*lspping_tlv_downstream_map
;
505 const struct lspping_tlv_downstream_map_ipv4_t
*lspping_tlv_downstream_map_ipv4
;
506 const struct lspping_tlv_downstream_map_ipv4_unmb_t
*lspping_tlv_downstream_map_ipv4_unmb
;
507 const struct lspping_tlv_downstream_map_ipv6_t
*lspping_tlv_downstream_map_ipv6
;
508 const struct lspping_tlv_downstream_map_ipv6_unmb_t
*lspping_tlv_downstream_map_ipv6_unmb
;
509 const struct lspping_tlv_downstream_map_info_t
*lspping_tlv_downstream_map_info
;
513 const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
*lspping_tlv_targetfec_subtlv_ldp_ipv4
;
514 const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
*lspping_tlv_targetfec_subtlv_ldp_ipv6
;
515 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
*lspping_tlv_targetfec_subtlv_rsvp_ipv4
;
516 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
*lspping_tlv_targetfec_subtlv_rsvp_ipv6
;
517 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
*lspping_tlv_targetfec_subtlv_l3vpn_ipv4
;
518 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
*lspping_tlv_targetfec_subtlv_l3vpn_ipv6
;
519 const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
*lspping_tlv_targetfec_subtlv_l2vpn_endpt
;
520 const struct lspping_tlv_targetfec_subtlv_fec_128_pw_old
*lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
;
521 const struct lspping_tlv_targetfec_subtlv_fec_128_pw
*lspping_tlv_targetfec_subtlv_l2vpn_vcid
;
522 const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
*lspping_tlv_targetfec_subtlv_bgp_ipv4
;
523 const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
*lspping_tlv_targetfec_subtlv_bgp_ipv6
;
526 ndo
->ndo_protocol
= "lspping";
528 lspping_com_header
= (const struct lspping_common_header
*)pptr
;
529 if (len
< sizeof(struct lspping_common_header
))
531 ND_TCHECK_SIZE(lspping_com_header
);
534 * Sanity checking of the header.
536 if (GET_BE_U_2(lspping_com_header
->version
) != LSPPING_VERSION
) {
537 ND_PRINT("LSP-PING version %u packet not supported",
538 GET_BE_U_2(lspping_com_header
->version
));
542 /* in non-verbose mode just lets print the basic Message Type*/
543 if (ndo
->ndo_vflag
< 1) {
544 ND_PRINT("LSP-PINGv%u, %s, seq %u, length: %u",
545 GET_BE_U_2(lspping_com_header
->version
),
546 tok2str(lspping_msg_type_values
, "unknown (%u)",GET_U_1(lspping_com_header
->msg_type
)),
547 GET_BE_U_4(lspping_com_header
->seq_number
),
552 /* ok they seem to want to know everything - lets fully decode it */
556 ND_PRINT("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
557 GET_BE_U_2(lspping_com_header
->version
),
558 tok2str(lspping_msg_type_values
, "unknown",GET_U_1(lspping_com_header
->msg_type
)),
559 GET_U_1(lspping_com_header
->msg_type
),
561 tok2str(lspping_reply_mode_values
, "unknown",GET_U_1(lspping_com_header
->reply_mode
)),
562 GET_U_1(lspping_com_header
->reply_mode
));
565 * the following return codes require that the subcode is attached
566 * at the end of the translated token output
568 return_code
= GET_U_1(lspping_com_header
->return_code
);
569 return_subcode
= GET_U_1(lspping_com_header
->return_subcode
);
570 if (return_code
== 3 ||
576 ND_PRINT("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
577 tok2str(lspping_return_code_values
, "unknown",return_code
),
582 ND_PRINT("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
583 tok2str(lspping_return_code_values
, "unknown",return_code
),
587 ND_PRINT("\n\t Sender Handle: 0x%08x, Sequence: %u",
588 GET_BE_U_4(lspping_com_header
->sender_handle
),
589 GET_BE_U_4(lspping_com_header
->seq_number
));
591 ND_PRINT("\n\t Sender Timestamp: ");
592 p_ntp_time(ndo
, &lspping_com_header
->ts_sent
);
595 int_part
=GET_BE_U_4(lspping_com_header
->ts_rcvd
.int_part
);
596 fraction
=GET_BE_U_4(lspping_com_header
->ts_rcvd
.fraction
);
597 ND_PRINT("Receiver Timestamp: ");
598 if (! (int_part
== 0 && fraction
== 0))
599 p_ntp_time(ndo
, &lspping_com_header
->ts_rcvd
);
601 ND_PRINT("no timestamp");
603 tptr
+=sizeof(struct lspping_common_header
);
604 tlen
-=sizeof(struct lspping_common_header
);
607 /* Does the TLV go past the end of the packet? */
608 if (tlen
< sizeof(struct lspping_tlv_header
))
611 /* did we capture enough for fully decoding the tlv header ? */
612 ND_TCHECK_LEN(tptr
, sizeof(struct lspping_tlv_header
));
614 lspping_tlv_header
= (const struct lspping_tlv_header
*)tptr
;
615 lspping_tlv_type
=GET_BE_U_2(lspping_tlv_header
->type
);
616 lspping_tlv_len
=GET_BE_U_2(lspping_tlv_header
->length
);
618 ND_PRINT("\n\t %s TLV (%u), length: %u",
619 tok2str(lspping_tlv_values
,
625 /* some little sanity checking */
626 if (lspping_tlv_len
== 0) {
627 tptr
+=sizeof(struct lspping_tlv_header
);
628 tlen
-=sizeof(struct lspping_tlv_header
);
629 continue; /* no value to dissect */
632 tlv_tptr
=tptr
+sizeof(struct lspping_tlv_header
);
633 tlv_tlen
=lspping_tlv_len
; /* header not included -> no adjustment */
635 /* Does the TLV go past the end of the packet? */
636 if (tlen
< lspping_tlv_len
+sizeof(struct lspping_tlv_header
))
638 /* did we capture enough for fully decoding the tlv ? */
639 ND_TCHECK_LEN(tlv_tptr
, lspping_tlv_len
);
642 switch(lspping_tlv_type
) {
643 case LSPPING_TLV_TARGET_FEC_STACK
:
644 while (tlv_tlen
!= 0) {
645 /* Does the subTLV header go past the end of the TLV? */
646 if (tlv_tlen
< sizeof(struct lspping_tlv_header
)) {
647 ND_PRINT("\n\t TLV is too short");
651 /* did we capture enough for fully decoding the subtlv header ? */
652 ND_TCHECK_LEN(tlv_tptr
, sizeof(struct lspping_tlv_header
));
653 subtlv_hexdump
=FALSE
;
655 lspping_subtlv_header
= (const struct lspping_tlv_header
*)tlv_tptr
;
656 lspping_subtlv_type
=GET_BE_U_2(lspping_subtlv_header
->type
);
657 lspping_subtlv_len
=GET_BE_U_2(lspping_subtlv_header
->length
);
658 subtlv_tptr
=tlv_tptr
+sizeof(struct lspping_tlv_header
);
660 /* Does the subTLV go past the end of the TLV? */
661 if (tlv_tlen
< lspping_subtlv_len
+sizeof(struct lspping_tlv_header
)) {
662 ND_PRINT("\n\t TLV is too short");
667 /* Did we capture enough for fully decoding the subTLV? */
668 ND_TCHECK_LEN(subtlv_tptr
, lspping_subtlv_len
);
670 ND_PRINT("\n\t %s subTLV (%u), length: %u",
671 tok2str(lspping_tlvtargetfec_subtlv_values
,
673 lspping_subtlv_type
),
677 switch(lspping_subtlv_type
) {
679 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4
:
680 /* Is the subTLV length correct? */
681 if (lspping_subtlv_len
!= 5) {
682 ND_PRINT("\n\t invalid subTLV length, should be 5");
683 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
685 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
=
686 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
*)subtlv_tptr
;
687 ND_PRINT("\n\t %s/%u",
688 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
->prefix
),
689 GET_U_1(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
->prefix_len
));
693 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6
:
694 /* Is the subTLV length correct? */
695 if (lspping_subtlv_len
!= 17) {
696 ND_PRINT("\n\t invalid subTLV length, should be 17");
697 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
699 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
=
700 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
*)subtlv_tptr
;
701 ND_PRINT("\n\t %s/%u",
702 GET_IP6ADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
->prefix
),
703 GET_U_1(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
->prefix_len
));
707 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4
:
708 /* Is the subTLV length correct? */
709 if (lspping_subtlv_len
!= 5) {
710 ND_PRINT("\n\t invalid subTLV length, should be 5");
711 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
713 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
=
714 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
*)subtlv_tptr
;
715 ND_PRINT("\n\t %s/%u",
716 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->prefix
),
717 GET_U_1(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->prefix_len
));
721 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6
:
722 /* Is the subTLV length correct? */
723 if (lspping_subtlv_len
!= 17) {
724 ND_PRINT("\n\t invalid subTLV length, should be 17");
725 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
727 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
=
728 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
*)subtlv_tptr
;
729 ND_PRINT("\n\t %s/%u",
730 GET_IP6ADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->prefix
),
731 GET_U_1(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->prefix_len
));
735 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4
:
736 /* Is the subTLV length correct? */
737 if (lspping_subtlv_len
!= 20) {
738 ND_PRINT("\n\t invalid subTLV length, should be 20");
739 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
741 subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
=
742 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
*)subtlv_tptr
;
743 ND_PRINT("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x"
744 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
745 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_endpoint
),
746 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_sender
),
747 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->lsp_id
),
748 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_id
),
749 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->extended_tunnel_id
));
753 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6
:
754 /* Is the subTLV length correct? */
755 if (lspping_subtlv_len
!= 56) {
756 ND_PRINT("\n\t invalid subTLV length, should be 56");
757 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
759 subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
=
760 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
*)subtlv_tptr
;
761 ND_PRINT("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x"
762 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
763 GET_IP6ADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_endpoint
),
764 GET_IP6ADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_sender
),
765 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->lsp_id
),
766 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_id
),
767 GET_IP6ADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->extended_tunnel_id
));
771 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4
:
772 /* Is the subTLV length correct? */
773 if (lspping_subtlv_len
!= 13) {
774 ND_PRINT("\n\t invalid subTLV length, should be 13");
775 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
777 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
=
778 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
*)subtlv_tptr
;
779 ND_PRINT("\n\t RD: %s, %s/%u",
780 bgp_vpn_rd_print(ndo
, subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->rd
),
781 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->prefix
),
782 GET_U_1(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->prefix_len
));
786 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6
:
787 /* Is the subTLV length correct? */
788 if (lspping_subtlv_len
!= 25) {
789 ND_PRINT("\n\t invalid subTLV length, should be 25");
790 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
792 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
=
793 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
*)subtlv_tptr
;
794 ND_PRINT("\n\t RD: %s, %s/%u",
795 bgp_vpn_rd_print(ndo
, subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->rd
),
796 GET_IP6ADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->prefix
),
797 GET_U_1(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->prefix_len
));
801 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT
:
802 /* Is the subTLV length correct? */
803 if (lspping_subtlv_len
!= 14) {
804 ND_PRINT("\n\t invalid subTLV length, should be 14");
805 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
807 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
=
808 (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
*)subtlv_tptr
;
809 ND_PRINT("\n\t RD: %s, Sender VE ID: %u, Receiver VE ID: %u"
810 "\n\t Encapsulation Type: %s (%u)",
811 bgp_vpn_rd_print(ndo
, subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->rd
),
812 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->sender_ve_id
),
813 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->receiver_ve_id
),
814 tok2str(mpls_pw_types_values
,
816 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
)),
817 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
));
821 /* the old L2VPN VCID subTLV does not have support for the sender field */
822 case LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD
:
823 /* Is the subTLV length correct? */
824 if (lspping_subtlv_len
!= 10) {
825 ND_PRINT("\n\t invalid subTLV length, should be 10");
826 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
828 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
=
829 (const struct lspping_tlv_targetfec_subtlv_fec_128_pw_old
*)subtlv_tptr
;
830 ND_PRINT("\n\t Remote PE: %s"
831 "\n\t PW ID: 0x%08x, PW Type: %s (%u)",
832 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->remote_pe_address
),
833 GET_BE_U_4(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->pw_id
),
834 tok2str(mpls_pw_types_values
,
836 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->pw_type
)),
837 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->pw_type
));
841 case LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW
:
842 /* Is the subTLV length correct? */
843 if (lspping_subtlv_len
!= 14) {
844 ND_PRINT("\n\t invalid subTLV length, should be 14");
845 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
847 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
=
848 (const struct lspping_tlv_targetfec_subtlv_fec_128_pw
*)subtlv_tptr
;
849 ND_PRINT("\n\t Sender PE: %s, Remote PE: %s"
850 "\n\t PW ID: 0x%08x, PW Type: %s (%u)",
851 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->sender_pe_address
),
852 GET_IPADDR_STRING(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->remote_pe_address
),
853 GET_BE_U_4(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->pw_id
),
854 tok2str(mpls_pw_types_values
,
856 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->pw_type
)),
857 GET_BE_U_2(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->pw_type
));
862 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
865 /* do we want to see an additionally subtlv hexdump ? */
866 if (ndo
->ndo_vflag
> 1 || subtlv_hexdump
==TRUE
)
867 print_unknown_data(ndo
, tlv_tptr
+sizeof(struct lspping_tlv_header
),
871 /* All subTLVs are aligned to four octet boundary */
872 if (lspping_subtlv_len
% 4) {
873 lspping_subtlv_len
+= 4 - (lspping_subtlv_len
% 4);
874 /* Does the subTLV, including padding, go past the end of the TLV? */
875 if (tlv_tlen
< lspping_subtlv_len
+sizeof(struct lspping_tlv_header
)) {
876 ND_PRINT("\n\t\t TLV is too short");
880 tlv_tptr
+=lspping_subtlv_len
;
881 tlv_tlen
-=lspping_subtlv_len
+sizeof(struct lspping_tlv_header
);
885 case LSPPING_TLV_DOWNSTREAM_MAPPING
:
886 /* Does the header go past the end of the TLV? */
887 if (tlv_tlen
< sizeof(struct lspping_tlv_downstream_map_t
)) {
888 ND_PRINT("\n\t TLV is too short");
892 /* Did we capture enough to get the address family? */
893 ND_TCHECK_LEN(tlv_tptr
,
894 sizeof(struct lspping_tlv_downstream_map_t
));
896 tlv_ptr
.lspping_tlv_downstream_map
=
897 (const struct lspping_tlv_downstream_map_t
*)tlv_tptr
;
899 /* that strange thing with the downstream map TLV is that until now
900 * we do not know if its IPv4 or IPv6 or is unnumbered; after
901 * we find the address-type, we recast the tlv_tptr and move on. */
903 address_type
= GET_U_1(tlv_ptr
.lspping_tlv_downstream_map
->address_type
);
904 ND_PRINT("\n\t MTU: %u, Address-Type: %s (%u)",
905 GET_BE_U_2(tlv_ptr
.lspping_tlv_downstream_map
->mtu
),
906 tok2str(lspping_tlv_downstream_addr_values
,
911 switch(address_type
) {
913 case LSPPING_AFI_IPV4
:
914 /* Does the data go past the end of the TLV? */
915 if (tlv_tlen
< sizeof(struct lspping_tlv_downstream_map_ipv4_t
)) {
916 ND_PRINT("\n\t TLV is too short");
920 /* Did we capture enough for this part of the TLV? */
921 ND_TCHECK_LEN(tlv_tptr
,
922 sizeof(struct lspping_tlv_downstream_map_ipv4_t
));
924 tlv_ptr
.lspping_tlv_downstream_map_ipv4
=
925 (const struct lspping_tlv_downstream_map_ipv4_t
*)tlv_tptr
;
926 ND_PRINT("\n\t Downstream IP: %s"
927 "\n\t Downstream Interface IP: %s",
928 GET_IPADDR_STRING(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_ip
),
929 GET_IPADDR_STRING(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_interface
));
930 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
931 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
933 case LSPPING_AFI_IPV4_UNMB
:
934 /* Does the data go past the end of the TLV? */
935 if (tlv_tlen
< sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t
)) {
936 ND_PRINT("\n\t TLV is too short");
940 /* Did we capture enough for this part of the TLV? */
941 ND_TCHECK_LEN(tlv_tptr
,
942 sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t
));
944 tlv_ptr
.lspping_tlv_downstream_map_ipv4_unmb
=
945 (const struct lspping_tlv_downstream_map_ipv4_unmb_t
*)tlv_tptr
;
946 ND_PRINT("\n\t Downstream IP: %s"
947 "\n\t Downstream Interface Index: 0x%08x",
948 GET_IPADDR_STRING(tlv_ptr
.lspping_tlv_downstream_map_ipv4_unmb
->downstream_ip
),
949 GET_BE_U_4(tlv_ptr
.lspping_tlv_downstream_map_ipv4_unmb
->downstream_interface
));
950 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t
);
951 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t
);
953 case LSPPING_AFI_IPV6
:
954 /* Does the data go past the end of the TLV? */
955 if (tlv_tlen
< sizeof(struct lspping_tlv_downstream_map_ipv6_t
)) {
956 ND_PRINT("\n\t TLV is too short");
960 /* Did we capture enough for this part of the TLV? */
961 ND_TCHECK_LEN(tlv_tptr
,
962 sizeof(struct lspping_tlv_downstream_map_ipv6_t
));
964 tlv_ptr
.lspping_tlv_downstream_map_ipv6
=
965 (const struct lspping_tlv_downstream_map_ipv6_t
*)tlv_tptr
;
966 ND_PRINT("\n\t Downstream IP: %s"
967 "\n\t Downstream Interface IP: %s",
968 GET_IP6ADDR_STRING(tlv_ptr
.lspping_tlv_downstream_map_ipv6
->downstream_ip
),
969 GET_IP6ADDR_STRING(tlv_ptr
.lspping_tlv_downstream_map_ipv6
->downstream_interface
));
970 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv6_t
);
971 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv6_t
);
973 case LSPPING_AFI_IPV6_UNMB
:
974 /* Does the data go past the end of the TLV? */
975 if (tlv_tlen
< sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t
)) {
976 ND_PRINT("\n\t TLV is too short");
980 /* Did we capture enough for this part of the TLV? */
981 ND_TCHECK_LEN(tlv_tptr
,
982 sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t
));
984 tlv_ptr
.lspping_tlv_downstream_map_ipv6_unmb
=
985 (const struct lspping_tlv_downstream_map_ipv6_unmb_t
*)tlv_tptr
;
986 ND_PRINT("\n\t Downstream IP: %s"
987 "\n\t Downstream Interface Index: 0x%08x",
988 GET_IP6ADDR_STRING(tlv_ptr
.lspping_tlv_downstream_map_ipv6_unmb
->downstream_ip
),
989 GET_BE_U_4(tlv_ptr
.lspping_tlv_downstream_map_ipv6_unmb
->downstream_interface
));
990 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t
);
991 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t
);
995 /* should not happen ! - no error message - tok2str() has barked already */
999 /* Does the data go past the end of the TLV? */
1000 if (tlv_tlen
< sizeof(struct lspping_tlv_downstream_map_info_t
)) {
1001 ND_PRINT("\n\t TLV is too short");
1005 /* Did we capture enough for this part of the TLV? */
1006 ND_TCHECK_LEN(tlv_tptr
,
1007 sizeof(struct lspping_tlv_downstream_map_info_t
));
1009 tlv_ptr
.lspping_tlv_downstream_map_info
=
1010 (const struct lspping_tlv_downstream_map_info_t
*)tlv_tptr
;
1012 /* FIXME add hash-key type, depth limit, multipath processing */
1014 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_info_t
);
1015 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_info_t
);
1017 /* FIXME print downstream labels */
1019 tlv_hexdump
=TRUE
; /* dump the TLV until code complete */
1023 case LSPPING_TLV_BFD_DISCRIMINATOR
:
1024 if (tlv_tlen
< LSPPING_TLV_BFD_DISCRIMINATOR_LEN
) {
1025 ND_PRINT("\n\t TLV is too short");
1029 ND_TCHECK_LEN(tptr
, LSPPING_TLV_BFD_DISCRIMINATOR_LEN
);
1030 ND_PRINT("\n\t BFD Discriminator 0x%08x", GET_BE_U_4(tptr
));
1034 case LSPPING_TLV_VENDOR_ENTERPRISE
:
1038 if (tlv_tlen
< LSPPING_TLV_VENDOR_ENTERPRISE_LEN
) {
1039 ND_PRINT("\n\t TLV is too short");
1043 ND_TCHECK_LEN(tptr
, LSPPING_TLV_VENDOR_ENTERPRISE_LEN
);
1044 vendor_id
= GET_BE_U_4(tlv_tptr
);
1045 ND_PRINT("\n\t Vendor: %s (0x%04x)",
1046 tok2str(smi_values
, "Unknown", vendor_id
),
1053 * FIXME those are the defined TLVs that lack a decoder
1054 * you are welcome to contribute code ;-)
1056 case LSPPING_TLV_PAD
:
1057 case LSPPING_TLV_ERROR_CODE
:
1058 case LSPPING_TLV_VENDOR_PRIVATE
:
1061 if (ndo
->ndo_vflag
<= 1)
1062 print_unknown_data(ndo
, tlv_tptr
, "\n\t ", tlv_tlen
);
1065 /* do we want to see an additionally tlv hexdump ? */
1067 if (ndo
->ndo_vflag
> 1 || tlv_hexdump
==TRUE
)
1068 print_unknown_data(ndo
, tptr
+sizeof(struct lspping_tlv_header
), "\n\t ",
1072 /* All TLVs are aligned to four octet boundary */
1073 if (lspping_tlv_len
% 4) {
1074 lspping_tlv_len
+= (4 - lspping_tlv_len
% 4);
1075 /* Does the TLV, including padding, go past the end of the packet? */
1076 if (tlen
< lspping_tlv_len
+sizeof(struct lspping_tlv_header
))
1080 tptr
+=lspping_tlv_len
+sizeof(struct lspping_tlv_header
);
1081 tlen
-=lspping_tlv_len
+sizeof(struct lspping_tlv_header
);
1085 ND_PRINT("\n\t\t packet is too short");
1088 nd_print_trunc(ndo
);