]> The Tcpdump Group git mirrors - tcpdump/blob - print-lspping.c
Remove useless 'return' at end of void functions (style)
[tcpdump] / print-lspping.c
1 /*
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.
12 *
13 * Original code by Hannes Gredler (hannes@gredler.at)
14 */
15
16 /* \summary: MPLS LSP PING printer */
17
18 /* specification: RFC 4379 */
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include "netdissect-stdinc.h"
25
26 #include "netdissect.h"
27 #include "extract.h"
28 #include "addrtoname.h"
29 #include "ntp.h"
30
31 #include "l2vpn.h"
32 #include "oui.h"
33
34
35 /*
36 * LSPPING common header
37 *
38 * 0 1 2 3
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 * | Sender's Handle |
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 * | Sequence Number |
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * | TimeStamp Sent (seconds) |
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * | TimeStamp Sent (microseconds) |
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 * | TimeStamp Received (seconds) |
54 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 * | TimeStamp Received (microseconds) |
56 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 * | TLVs ... |
58 * . .
59 * . .
60 * . .
61 */
62
63 struct lspping_common_header {
64 nd_uint16_t version;
65 nd_uint16_t global_flags;
66 nd_uint8_t msg_type;
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;
74 };
75
76 #define LSPPING_VERSION 1
77
78 static const struct tok lspping_msg_type_values[] = {
79 { 1, "MPLS Echo Request"},
80 { 2, "MPLS Echo Reply"},
81 { 0, NULL}
82 };
83
84 static const struct tok lspping_reply_mode_values[] = {
85 { 1, "Do not reply"},
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"},
89 { 0, NULL}
90 };
91
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"},
98 { 5, "Reserved"},
99 { 6, "Reserved"},
100 { 7, "Reserved"},
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"},
107 { 0, NULL},
108 };
109
110
111 /*
112 * LSPPING TLV header
113 * 0 1 2 3
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116 * | Type | Length |
117 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
118 * | Value |
119 * . .
120 * . .
121 * . .
122 * | |
123 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
124 */
125
126 struct lspping_tlv_header {
127 nd_uint16_t type;
128 nd_uint16_t length;
129 };
130
131 #define LSPPING_TLV_TARGET_FEC_STACK 1
132 #define LSPPING_TLV_DOWNSTREAM_MAPPING 2
133 #define LSPPING_TLV_PAD 3
134 /* not assigned 4 */
135 #define LSPPING_TLV_VENDOR_ENTERPRISE 5
136 #define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
137 /* not assigned 6 */
138 #define LSPPING_TLV_INTERFACE_LABEL_STACK 7
139 /* not assigned 8 */
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
145
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" },
156 { 0, NULL}
157 };
158
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
163 /* not assigned 5 */
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
175
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"},
181 { 5, "Reserved"},
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"},
189 { 0, NULL}
190 };
191
192 /*
193 * 0 1 2 3
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
196 * | IPv4 prefix |
197 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
198 * | Prefix Length | Must Be Zero |
199 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
200 */
201 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
202 nd_ipv4 prefix;
203 nd_uint8_t prefix_len;
204 };
205
206 /*
207 * 0 1 2 3
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
210 * | IPv6 prefix |
211 * | (16 octets) |
212 * | |
213 * | |
214 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
215 * | Prefix Length | Must Be Zero |
216 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
217 */
218 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
219 nd_ipv6 prefix;
220 nd_uint8_t prefix_len;
221 };
222
223 /*
224 * 0 1 2 3
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
237 */
238 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
239 nd_ipv4 tunnel_endpoint;
240 nd_byte res[2];
241 nd_uint16_t tunnel_id;
242 nd_ipv4 extended_tunnel_id;
243 nd_ipv4 tunnel_sender;
244 nd_byte res2[2];
245 nd_uint16_t lsp_id;
246 };
247
248 /*
249 * 0 1 2 3
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 |
253 * | |
254 * | |
255 * | |
256 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257 * | Must Be Zero | Tunnel ID |
258 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259 * | Extended Tunnel ID |
260 * | |
261 * | |
262 * | |
263 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
264 * | IPv6 tunnel sender address |
265 * | |
266 * | |
267 * | |
268 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
269 * | Must Be Zero | LSP ID |
270 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
271 */
272 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
273 nd_ipv6 tunnel_endpoint;
274 nd_byte res[2];
275 nd_uint16_t tunnel_id;
276 nd_ipv6 extended_tunnel_id;
277 nd_ipv6 tunnel_sender;
278 nd_byte res2[2];
279 nd_uint16_t lsp_id;
280 };
281
282 /*
283 * 0 1 2 3
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 |
287 * | (8 octets) |
288 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
289 * | IPv4 prefix |
290 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
291 * | Prefix Length | Must Be Zero |
292 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
293 */
294 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
295 nd_byte rd[8];
296 nd_ipv4 prefix;
297 nd_uint8_t prefix_len;
298 };
299
300 /*
301 * 0 1 2 3
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 |
305 * | (8 octets) |
306 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307 * | IPv6 prefix |
308 * | (16 octets) |
309 * | |
310 * | |
311 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
312 * | Prefix Length | Must Be Zero |
313 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
314 */
315 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
316 nd_byte rd[8];
317 nd_ipv6 prefix;
318 nd_uint8_t prefix_len;
319 };
320
321 /*
322 * 0 1 2 3
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 |
326 * | (8 octets) |
327 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
328 * | Sender's VE ID | Receiver's VE ID |
329 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
330 * | Encapsulation Type | Must Be Zero |
331 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
332 * 0 1 2 3
333 */
334 struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
335 nd_byte rd[8];
336 nd_uint16_t sender_ve_id;
337 nd_uint16_t receiver_ve_id;
338 nd_uint16_t encapsulation;
339 };
340
341 /*
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
346 * | PW ID |
347 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
348 * | PW Type | Must Be Zero |
349 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
350 */
351 struct lspping_tlv_targetfec_subtlv_fec_128_pw_old {
352 nd_ipv4 remote_pe_address;
353 nd_uint32_t pw_id;
354 nd_uint16_t pw_type;
355 };
356
357 /*
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
364 * | PW ID |
365 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
366 * | PW Type | Must Be Zero |
367 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
368 */
369 struct lspping_tlv_targetfec_subtlv_fec_128_pw {
370 nd_ipv4 sender_pe_address;
371 nd_ipv4 remote_pe_address;
372 nd_uint32_t pw_id;
373 nd_uint16_t pw_type;
374 };
375
376 /*
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
379 * | IPv4 prefix |
380 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
381 * | Prefix Length | Must Be Zero |
382 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
383 */
384 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
385 nd_ipv4 prefix;
386 nd_uint8_t prefix_len;
387 };
388
389 /*
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
392 * | IPv6 prefix |
393 * | (16 octets) |
394 * | |
395 * | |
396 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
397 * | Prefix Length | Must Be Zero |
398 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
399 */
400 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
401 nd_ipv6 prefix;
402 nd_uint8_t prefix_len;
403 };
404
405 /*
406 * 0 1 2 3
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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
417 * . .
418 * . (Multipath Information) .
419 * . .
420 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
421 * | Downstream Label | Protocol |
422 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
423 * . .
424 * . .
425 * . .
426 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
427 * | Downstream Label | Protocol |
428 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
429 */
430 /* Enough to get the address type */
431 struct lspping_tlv_downstream_map_t {
432 nd_uint16_t mtu;
433 nd_uint8_t address_type;
434 nd_uint8_t ds_flags;
435 };
436
437 struct lspping_tlv_downstream_map_ipv4_t {
438 nd_uint16_t mtu;
439 nd_uint8_t address_type;
440 nd_uint8_t ds_flags;
441 nd_ipv4 downstream_ip;
442 nd_ipv4 downstream_interface;
443 };
444
445 struct lspping_tlv_downstream_map_ipv4_unmb_t {
446 nd_uint16_t mtu;
447 nd_uint8_t address_type;
448 nd_uint8_t ds_flags;
449 nd_ipv4 downstream_ip;
450 nd_uint32_t downstream_interface;
451 };
452
453 struct lspping_tlv_downstream_map_ipv6_t {
454 nd_uint16_t mtu;
455 nd_uint8_t address_type;
456 nd_uint8_t ds_flags;
457 nd_ipv6 downstream_ip;
458 nd_ipv6 downstream_interface;
459 };
460
461 struct lspping_tlv_downstream_map_ipv6_unmb_t {
462 nd_uint16_t mtu;
463 nd_uint8_t address_type;
464 nd_uint8_t ds_flags;
465 nd_ipv6 downstream_ip;
466 nd_uint32_t downstream_interface;
467 };
468
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;
473 };
474
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
479
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"},
485 { 0, NULL}
486 };
487
488 void
489 lspping_print(netdissect_options *ndo,
490 const u_char *pptr, u_int len)
491 {
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;
501 u_int address_type;
502
503 union {
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;
510 } tlv_ptr;
511
512 union {
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;
524 } subtlv_ptr;
525
526 ndo->ndo_protocol = "lspping";
527 tptr=pptr;
528 lspping_com_header = (const struct lspping_common_header *)pptr;
529 if (len < sizeof(struct lspping_common_header))
530 goto tooshort;
531 ND_TCHECK_SIZE(lspping_com_header);
532
533 /*
534 * Sanity checking of the header.
535 */
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));
539 return;
540 }
541
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),
548 len);
549 return;
550 }
551
552 /* ok they seem to want to know everything - lets fully decode it */
553
554 tlen=len;
555
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),
560 len,
561 tok2str(lspping_reply_mode_values, "unknown",GET_U_1(lspping_com_header->reply_mode)),
562 GET_U_1(lspping_com_header->reply_mode));
563
564 /*
565 * the following return codes require that the subcode is attached
566 * at the end of the translated token output
567 */
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 ||
571 return_code == 4 ||
572 return_code == 8 ||
573 return_code == 10 ||
574 return_code == 11 ||
575 return_code == 12 )
576 ND_PRINT("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
577 tok2str(lspping_return_code_values, "unknown",return_code),
578 return_subcode,
579 return_code,
580 return_subcode);
581 else
582 ND_PRINT("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
583 tok2str(lspping_return_code_values, "unknown",return_code),
584 return_code,
585 return_subcode);
586
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));
590
591 ND_PRINT("\n\t Sender Timestamp: ");
592 p_ntp_time(ndo, &lspping_com_header->ts_sent);
593 ND_PRINT(" ");
594
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);
600 else
601 ND_PRINT("no timestamp");
602
603 tptr+=sizeof(struct lspping_common_header);
604 tlen-=sizeof(struct lspping_common_header);
605
606 while (tlen != 0) {
607 /* Does the TLV go past the end of the packet? */
608 if (tlen < sizeof(struct lspping_tlv_header))
609 goto tooshort;
610
611 /* did we capture enough for fully decoding the tlv header ? */
612 ND_TCHECK_LEN(tptr, sizeof(struct lspping_tlv_header));
613
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);
617
618 ND_PRINT("\n\t %s TLV (%u), length: %u",
619 tok2str(lspping_tlv_values,
620 "Unknown",
621 lspping_tlv_type),
622 lspping_tlv_type,
623 lspping_tlv_len);
624
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 */
630 }
631
632 tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
633 tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
634
635 /* Does the TLV go past the end of the packet? */
636 if (tlen < lspping_tlv_len+sizeof(struct lspping_tlv_header))
637 goto tooshort;
638 /* did we capture enough for fully decoding the tlv ? */
639 ND_TCHECK_LEN(tlv_tptr, lspping_tlv_len);
640 tlv_hexdump=FALSE;
641
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");
648 tlv_hexdump = TRUE;
649 goto tlv_tooshort;
650 }
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;
654
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);
659
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");
663 tlv_hexdump = TRUE;
664 goto tlv_tooshort;
665 }
666
667 /* Did we capture enough for fully decoding the subTLV? */
668 ND_TCHECK_LEN(subtlv_tptr, lspping_subtlv_len);
669
670 ND_PRINT("\n\t %s subTLV (%u), length: %u",
671 tok2str(lspping_tlvtargetfec_subtlv_values,
672 "Unknown",
673 lspping_subtlv_type),
674 lspping_subtlv_type,
675 lspping_subtlv_len);
676
677 switch(lspping_subtlv_type) {
678
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 */
684 } else {
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));
690 }
691 break;
692
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 */
698 } else {
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));
704 }
705 break;
706
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 */
712 } else {
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));
718 }
719 break;
720
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 */
726 } else {
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));
732 }
733 break;
734
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 */
740 } else {
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));
750 }
751 break;
752
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 */
758 } else {
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));
768 }
769 break;
770
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 */
776 } else {
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));
783 }
784 break;
785
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 */
791 } else {
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));
798 }
799 break;
800
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 */
806 } else {
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,
815 "unknown",
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));
818 }
819 break;
820
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 */
827 } else {
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,
835 "unknown",
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));
838 }
839 break;
840
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 */
846 } else {
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,
855 "unknown",
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));
858 }
859 break;
860
861 default:
862 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
863 break;
864 }
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),
868 "\n\t ",
869 lspping_subtlv_len);
870
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");
877 return;
878 }
879 }
880 tlv_tptr+=lspping_subtlv_len;
881 tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header);
882 }
883 break;
884
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");
889 tlv_hexdump = TRUE;
890 goto tlv_tooshort;
891 }
892 /* Did we capture enough to get the address family? */
893 ND_TCHECK_LEN(tlv_tptr,
894 sizeof(struct lspping_tlv_downstream_map_t));
895
896 tlv_ptr.lspping_tlv_downstream_map=
897 (const struct lspping_tlv_downstream_map_t *)tlv_tptr;
898
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. */
902
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,
907 "unknown",
908 address_type),
909 address_type);
910
911 switch(address_type) {
912
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");
917 tlv_hexdump = TRUE;
918 goto tlv_tooshort;
919 }
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));
923
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);
932 break;
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");
937 tlv_hexdump = TRUE;
938 goto tlv_tooshort;
939 }
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));
943
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);
952 break;
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");
957 tlv_hexdump = TRUE;
958 goto tlv_tooshort;
959 }
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));
963
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);
972 break;
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");
977 tlv_hexdump = TRUE;
978 goto tlv_tooshort;
979 }
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));
983
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);
992 break;
993
994 default:
995 /* should not happen ! - no error message - tok2str() has barked already */
996 break;
997 }
998
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");
1002 tlv_hexdump = TRUE;
1003 goto tlv_tooshort;
1004 }
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));
1008
1009 tlv_ptr.lspping_tlv_downstream_map_info=
1010 (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
1011
1012 /* FIXME add hash-key type, depth limit, multipath processing */
1013
1014 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t);
1015 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t);
1016
1017 /* FIXME print downstream labels */
1018
1019 tlv_hexdump=TRUE; /* dump the TLV until code complete */
1020
1021 break;
1022
1023 case LSPPING_TLV_BFD_DISCRIMINATOR:
1024 if (tlv_tlen < LSPPING_TLV_BFD_DISCRIMINATOR_LEN) {
1025 ND_PRINT("\n\t TLV is too short");
1026 tlv_hexdump = TRUE;
1027 goto tlv_tooshort;
1028 } else {
1029 ND_TCHECK_LEN(tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
1030 ND_PRINT("\n\t BFD Discriminator 0x%08x", GET_BE_U_4(tptr));
1031 }
1032 break;
1033
1034 case LSPPING_TLV_VENDOR_ENTERPRISE:
1035 {
1036 uint32_t vendor_id;
1037
1038 if (tlv_tlen < LSPPING_TLV_VENDOR_ENTERPRISE_LEN) {
1039 ND_PRINT("\n\t TLV is too short");
1040 tlv_hexdump = TRUE;
1041 goto tlv_tooshort;
1042 } else {
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),
1047 vendor_id);
1048 }
1049 }
1050 break;
1051
1052 /*
1053 * FIXME those are the defined TLVs that lack a decoder
1054 * you are welcome to contribute code ;-)
1055 */
1056 case LSPPING_TLV_PAD:
1057 case LSPPING_TLV_ERROR_CODE:
1058 case LSPPING_TLV_VENDOR_PRIVATE:
1059
1060 default:
1061 if (ndo->ndo_vflag <= 1)
1062 print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
1063 break;
1064 }
1065 /* do we want to see an additionally tlv hexdump ? */
1066 tlv_tooshort:
1067 if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
1068 print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t ",
1069 lspping_tlv_len);
1070
1071
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))
1077 goto tooshort;
1078 }
1079
1080 tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header);
1081 tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header);
1082 }
1083 return;
1084 tooshort:
1085 ND_PRINT("\n\t\t packet is too short");
1086 return;
1087 trunc:
1088 nd_print_trunc(ndo);
1089 }