]> The Tcpdump Group git mirrors - tcpdump/blob - print-lspping.c
Revert partially the commit 21b1273
[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 4349 */
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
30 #include "l2vpn.h"
31 #include "oui.h"
32
33
34 /*
35 * LSPPING common header
36 *
37 * 0 1 2 3
38 * 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
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 * | Version Number | Must Be Zero |
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * | Message Type | Reply mode | Return Code | Return Subcode|
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | Sender's Handle |
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * | Sequence Number |
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * | TimeStamp Sent (seconds) |
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | TimeStamp Sent (microseconds) |
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * | TimeStamp Received (seconds) |
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 * | TimeStamp Received (microseconds) |
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * | TLVs ... |
57 * . .
58 * . .
59 * . .
60 */
61
62 struct lspping_common_header {
63 nd_uint16_t version;
64 nd_uint16_t global_flags;
65 nd_uint8_t msg_type;
66 nd_uint8_t reply_mode;
67 nd_uint8_t return_code;
68 nd_uint8_t return_subcode;
69 nd_uint32_t sender_handle;
70 nd_uint32_t seq_number;
71 nd_uint32_t ts_sent_sec;
72 nd_uint32_t ts_sent_usec;
73 nd_uint32_t ts_rcvd_sec;
74 nd_uint32_t ts_rcvd_usec;
75 };
76
77 #define LSPPING_VERSION 1
78
79 static const struct tok lspping_msg_type_values[] = {
80 { 1, "MPLS Echo Request"},
81 { 2, "MPLS Echo Reply"},
82 { 0, NULL}
83 };
84
85 static const struct tok lspping_reply_mode_values[] = {
86 { 1, "Do not reply"},
87 { 2, "Reply via an IPv4/IPv6 UDP packet"},
88 { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
89 { 4, "Reply via application level control channel"},
90 { 0, NULL}
91 };
92
93 static const struct tok lspping_return_code_values[] = {
94 { 0, "No return code or return code contained in the Error Code TLV"},
95 { 1, "Malformed echo request received"},
96 { 2, "One or more of the TLVs was not understood"},
97 { 3, "Replying router is an egress for the FEC at stack depth"},
98 { 4, "Replying router has no mapping for the FEC at stack depth"},
99 { 5, "Reserved"},
100 { 6, "Reserved"},
101 { 7, "Reserved"},
102 { 8, "Label switched at stack-depth"},
103 { 9, "Label switched but no MPLS forwarding at stack-depth"},
104 { 10, "Mapping for this FEC is not the given label at stack depth"},
105 { 11, "No label entry at stack-depth"},
106 { 12, "Protocol not associated with interface at FEC stack depth"},
107 { 13, "Premature termination of ping due to label stack shrinking to a single label"},
108 { 0, NULL},
109 };
110
111
112 /*
113 * LSPPING TLV header
114 * 0 1 2 3
115 * 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
116 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
117 * | Type | Length |
118 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
119 * | Value |
120 * . .
121 * . .
122 * . .
123 * | |
124 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
125 */
126
127 struct lspping_tlv_header {
128 nd_uint16_t type;
129 nd_uint16_t length;
130 };
131
132 #define LSPPING_TLV_TARGET_FEC_STACK 1
133 #define LSPPING_TLV_DOWNSTREAM_MAPPING 2
134 #define LSPPING_TLV_PAD 3
135 /* not assigned 4 */
136 #define LSPPING_TLV_VENDOR_ENTERPRISE 5
137 #define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
138 /* not assigned 6 */
139 #define LSPPING_TLV_INTERFACE_LABEL_STACK 7
140 /* not assigned 8 */
141 #define LSPPING_TLV_ERROR_CODE 9
142 #define LSPPING_TLV_REPLY_TOS_BYTE 10
143 #define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
144 #define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
145 #define LSPPING_TLV_VENDOR_PRIVATE 0xfc00
146
147 static const struct tok lspping_tlv_values[] = {
148 { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" },
149 { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" },
150 { LSPPING_TLV_PAD, "Pad" },
151 { LSPPING_TLV_ERROR_CODE, "Error Code" },
152 { LSPPING_TLV_VENDOR_ENTERPRISE, "Vendor Enterprise Code" },
153 { LSPPING_TLV_INTERFACE_LABEL_STACK, "Interface Label Stack" },
154 { LSPPING_TLV_REPLY_TOS_BYTE, "Reply TOS Byte" },
155 { LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" },
156 { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Private Code" },
157 { 0, NULL}
158 };
159
160 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
161 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
162 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
163 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
164 /* not assigned 5 */
165 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
166 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
167 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
168 #define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD 9
169 #define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW 10
170 #define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_129_PW 11
171 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 12
172 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 13
173 #define LSPPING_TLV_TARGETFEC_SUBTLV_GENERIC_IPV4 14
174 #define LSPPING_TLV_TARGETFEC_SUBTLV_GENERIC_IPV6 15
175 #define LSPPING_TLV_TARGETFEC_SUBTLV_NIL_FEC 16
176
177 static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
178 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"},
179 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"},
180 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"},
181 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"},
182 { 5, "Reserved"},
183 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"},
184 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"},
185 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"},
186 { LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD, "FEC 128 pseudowire (old)"},
187 { LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW, "FEC 128 pseudowire"},
188 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"},
189 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"},
190 { 0, NULL}
191 };
192
193 /*
194 * 0 1 2 3
195 * 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
196 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
197 * | IPv4 prefix |
198 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
199 * | Prefix Length | Must Be Zero |
200 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201 */
202 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
203 nd_ipv4 prefix;
204 nd_uint8_t prefix_len;
205 };
206
207 /*
208 * 0 1 2 3
209 * 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
210 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
211 * | IPv6 prefix |
212 * | (16 octets) |
213 * | |
214 * | |
215 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
216 * | Prefix Length | Must Be Zero |
217 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
218 */
219 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
220 nd_ipv6 prefix;
221 nd_uint8_t prefix_len;
222 };
223
224 /*
225 * 0 1 2 3
226 * 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
227 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
228 * | IPv4 tunnel end point address |
229 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
230 * | Must Be Zero | Tunnel ID |
231 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
232 * | Extended Tunnel ID |
233 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
234 * | IPv4 tunnel sender address |
235 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
236 * | Must Be Zero | LSP ID |
237 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238 */
239 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
240 nd_ipv4 tunnel_endpoint;
241 nd_byte res[2];
242 nd_uint16_t tunnel_id;
243 nd_ipv4 extended_tunnel_id;
244 nd_ipv4 tunnel_sender;
245 nd_byte res2[2];
246 nd_uint16_t lsp_id;
247 };
248
249 /*
250 * 0 1 2 3
251 * 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
252 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
253 * | IPv6 tunnel end point address |
254 * | |
255 * | |
256 * | |
257 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
258 * | Must Be Zero | Tunnel ID |
259 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
260 * | Extended Tunnel ID |
261 * | |
262 * | |
263 * | |
264 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
265 * | IPv6 tunnel sender address |
266 * | |
267 * | |
268 * | |
269 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
270 * | Must Be Zero | LSP ID |
271 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
272 */
273 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
274 nd_ipv6 tunnel_endpoint;
275 nd_byte res[2];
276 nd_uint16_t tunnel_id;
277 nd_ipv6 extended_tunnel_id;
278 nd_ipv6 tunnel_sender;
279 nd_byte res2[2];
280 nd_uint16_t lsp_id;
281 };
282
283 /*
284 * 0 1 2 3
285 * 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
286 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
287 * | Route Distinguisher |
288 * | (8 octets) |
289 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
290 * | IPv4 prefix |
291 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
292 * | Prefix Length | Must Be Zero |
293 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
294 */
295 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
296 nd_byte rd[8];
297 nd_ipv4 prefix;
298 nd_uint8_t prefix_len;
299 };
300
301 /*
302 * 0 1 2 3
303 * 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
304 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305 * | Route Distinguisher |
306 * | (8 octets) |
307 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
308 * | IPv6 prefix |
309 * | (16 octets) |
310 * | |
311 * | |
312 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
313 * | Prefix Length | Must Be Zero |
314 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
315 */
316 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
317 nd_byte rd[8];
318 nd_ipv6 prefix;
319 nd_uint8_t prefix_len;
320 };
321
322 /*
323 * 0 1 2 3
324 * 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
325 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
326 * | Route Distinguisher |
327 * | (8 octets) |
328 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
329 * | Sender's VE ID | Receiver's VE ID |
330 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
331 * | Encapsulation Type | Must Be Zero |
332 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
333 * 0 1 2 3
334 */
335 struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
336 nd_byte rd[8];
337 nd_uint16_t sender_ve_id;
338 nd_uint16_t receiver_ve_id;
339 nd_uint16_t encapsulation;
340 };
341
342 /*
343 * 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
344 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
345 * | Remote PE Address |
346 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
347 * | PW ID |
348 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
349 * | PW Type | Must Be Zero |
350 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
351 */
352 struct lspping_tlv_targetfec_subtlv_fec_128_pw_old {
353 nd_ipv4 remote_pe_address;
354 nd_uint32_t pw_id;
355 nd_uint16_t pw_type;
356 };
357
358 /*
359 * 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
360 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
361 * | Sender's PE Address |
362 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
363 * | Remote PE Address |
364 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
365 * | PW ID |
366 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367 * | PW Type | Must Be Zero |
368 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
369 */
370 struct lspping_tlv_targetfec_subtlv_fec_128_pw {
371 nd_ipv4 sender_pe_address;
372 nd_ipv4 remote_pe_address;
373 nd_uint32_t pw_id;
374 nd_uint16_t pw_type;
375 };
376
377 /*
378 * 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
379 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
380 * | IPv4 prefix |
381 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
382 * | Prefix Length | Must Be Zero |
383 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
384 */
385 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
386 nd_ipv4 prefix;
387 nd_uint8_t prefix_len;
388 };
389
390 /*
391 * 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
392 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
393 * | IPv6 prefix |
394 * | (16 octets) |
395 * | |
396 * | |
397 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
398 * | Prefix Length | Must Be Zero |
399 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
400 */
401 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
402 nd_ipv6 prefix;
403 nd_uint8_t prefix_len;
404 };
405
406 /*
407 * 0 1 2 3
408 * 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
409 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
410 * | MTU | Address Type | Resvd (SBZ) |
411 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
412 * | Downstream IP Address (4 or 16 octets) |
413 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
414 * | Downstream Interface Address (4 or 16 octets) |
415 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
416 * | Multipath Type| Depth Limit | Multipath Length |
417 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
418 * . .
419 * . (Multipath Information) .
420 * . .
421 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
422 * | Downstream Label | Protocol |
423 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
424 * . .
425 * . .
426 * . .
427 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
428 * | Downstream Label | Protocol |
429 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
430 */
431 /* Enough to get the address type */
432 struct lspping_tlv_downstream_map_t {
433 nd_uint16_t mtu;
434 nd_uint8_t address_type;
435 nd_uint8_t ds_flags;
436 };
437
438 struct lspping_tlv_downstream_map_ipv4_t {
439 nd_uint16_t mtu;
440 nd_uint8_t address_type;
441 nd_uint8_t ds_flags;
442 nd_ipv4 downstream_ip;
443 nd_ipv4 downstream_interface;
444 };
445
446 struct lspping_tlv_downstream_map_ipv4_unmb_t {
447 nd_uint16_t mtu;
448 nd_uint8_t address_type;
449 nd_uint8_t ds_flags;
450 nd_ipv4 downstream_ip;
451 nd_uint32_t downstream_interface;
452 };
453
454 struct lspping_tlv_downstream_map_ipv6_t {
455 nd_uint16_t mtu;
456 nd_uint8_t address_type;
457 nd_uint8_t ds_flags;
458 nd_ipv6 downstream_ip;
459 nd_ipv6 downstream_interface;
460 };
461
462 struct lspping_tlv_downstream_map_ipv6_unmb_t {
463 nd_uint16_t mtu;
464 nd_uint8_t address_type;
465 nd_uint8_t ds_flags;
466 nd_ipv6 downstream_ip;
467 nd_uint32_t downstream_interface;
468 };
469
470 struct lspping_tlv_downstream_map_info_t {
471 nd_uint8_t multipath_type;
472 nd_uint8_t depth_limit;
473 nd_uint16_t multipath_length;
474 };
475
476 #define LSPPING_AFI_IPV4 1
477 #define LSPPING_AFI_IPV4_UNMB 2
478 #define LSPPING_AFI_IPV6 3
479 #define LSPPING_AFI_IPV6_UNMB 4
480
481 static const struct tok lspping_tlv_downstream_addr_values[] = {
482 { LSPPING_AFI_IPV4, "IPv4"},
483 { LSPPING_AFI_IPV4_UNMB, "Unnumbered IPv4"},
484 { LSPPING_AFI_IPV6, "IPv6"},
485 { LSPPING_AFI_IPV6_UNMB, "IPv6"},
486 { 0, NULL}
487 };
488
489 void
490 lspping_print(netdissect_options *ndo,
491 const u_char *pptr, u_int len)
492 {
493 const struct lspping_common_header *lspping_com_header;
494 const struct lspping_tlv_header *lspping_tlv_header;
495 const struct lspping_tlv_header *lspping_subtlv_header;
496 const u_char *tptr,*tlv_tptr,*subtlv_tptr;
497 u_int return_code, return_subcode;
498 u_int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
499 int tlv_hexdump,subtlv_hexdump;
500 u_int lspping_subtlv_len,lspping_subtlv_type;
501 struct timeval timestamp;
502 u_int address_type;
503
504 union {
505 const struct lspping_tlv_downstream_map_t *lspping_tlv_downstream_map;
506 const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4;
507 const struct lspping_tlv_downstream_map_ipv4_unmb_t *lspping_tlv_downstream_map_ipv4_unmb;
508 const struct lspping_tlv_downstream_map_ipv6_t *lspping_tlv_downstream_map_ipv6;
509 const struct lspping_tlv_downstream_map_ipv6_unmb_t *lspping_tlv_downstream_map_ipv6_unmb;
510 const struct lspping_tlv_downstream_map_info_t *lspping_tlv_downstream_map_info;
511 } tlv_ptr;
512
513 union {
514 const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *lspping_tlv_targetfec_subtlv_ldp_ipv4;
515 const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *lspping_tlv_targetfec_subtlv_ldp_ipv6;
516 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *lspping_tlv_targetfec_subtlv_rsvp_ipv4;
517 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *lspping_tlv_targetfec_subtlv_rsvp_ipv6;
518 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4;
519 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6;
520 const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *lspping_tlv_targetfec_subtlv_l2vpn_endpt;
521 const struct lspping_tlv_targetfec_subtlv_fec_128_pw_old *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old;
522 const struct lspping_tlv_targetfec_subtlv_fec_128_pw *lspping_tlv_targetfec_subtlv_l2vpn_vcid;
523 const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4;
524 const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6;
525 } subtlv_ptr;
526
527 ndo->ndo_protocol = "lspping";
528 tptr=pptr;
529 lspping_com_header = (const struct lspping_common_header *)pptr;
530 if (len < sizeof(struct lspping_common_header))
531 goto tooshort;
532 ND_TCHECK_SIZE(lspping_com_header);
533
534 /*
535 * Sanity checking of the header.
536 */
537 if (GET_BE_U_2(lspping_com_header->version) != LSPPING_VERSION) {
538 ND_PRINT("LSP-PING version %u packet not supported",
539 GET_BE_U_2(lspping_com_header->version));
540 return;
541 }
542
543 /* in non-verbose mode just lets print the basic Message Type*/
544 if (ndo->ndo_vflag < 1) {
545 ND_PRINT("LSP-PINGv%u, %s, seq %u, length: %u",
546 GET_BE_U_2(lspping_com_header->version),
547 tok2str(lspping_msg_type_values, "unknown (%u)",GET_U_1(lspping_com_header->msg_type)),
548 GET_BE_U_4(lspping_com_header->seq_number),
549 len);
550 return;
551 }
552
553 /* ok they seem to want to know everything - lets fully decode it */
554
555 tlen=len;
556
557 ND_PRINT("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
558 GET_BE_U_2(lspping_com_header->version),
559 tok2str(lspping_msg_type_values, "unknown",GET_U_1(lspping_com_header->msg_type)),
560 GET_U_1(lspping_com_header->msg_type),
561 len,
562 tok2str(lspping_reply_mode_values, "unknown",GET_U_1(lspping_com_header->reply_mode)),
563 GET_U_1(lspping_com_header->reply_mode));
564
565 /*
566 * the following return codes require that the subcode is attached
567 * at the end of the translated token output
568 */
569 return_code = GET_U_1(lspping_com_header->return_code);
570 return_subcode = GET_U_1(lspping_com_header->return_subcode);
571 if (return_code == 3 ||
572 return_code == 4 ||
573 return_code == 8 ||
574 return_code == 10 ||
575 return_code == 11 ||
576 return_code == 12 )
577 ND_PRINT("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
578 tok2str(lspping_return_code_values, "unknown",return_code),
579 return_subcode,
580 return_code,
581 return_subcode);
582 else
583 ND_PRINT("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
584 tok2str(lspping_return_code_values, "unknown",return_code),
585 return_code,
586 return_subcode);
587
588 ND_PRINT("\n\t Sender Handle: 0x%08x, Sequence: %u",
589 GET_BE_U_4(lspping_com_header->sender_handle),
590 GET_BE_U_4(lspping_com_header->seq_number));
591
592 timestamp.tv_sec=GET_BE_U_4(lspping_com_header->ts_sent_sec);
593 timestamp.tv_usec=GET_BE_U_4(lspping_com_header->ts_sent_usec);
594 ND_PRINT("\n\t Sender Timestamp: ");
595 ts_print(ndo, &timestamp);
596
597 timestamp.tv_sec=GET_BE_U_4(lspping_com_header->ts_rcvd_sec);
598 timestamp.tv_usec=GET_BE_U_4(lspping_com_header->ts_rcvd_usec);
599 ND_PRINT("Receiver Timestamp: ");
600 if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
601 ts_print(ndo, &timestamp);
602 else
603 ND_PRINT("no timestamp");
604
605 tptr+=sizeof(struct lspping_common_header);
606 tlen-=sizeof(struct lspping_common_header);
607
608 while (tlen != 0) {
609 /* Does the TLV go past the end of the packet? */
610 if (tlen < sizeof(struct lspping_tlv_header))
611 goto tooshort;
612
613 /* did we capture enough for fully decoding the tlv header ? */
614 ND_TCHECK_LEN(tptr, sizeof(struct lspping_tlv_header));
615
616 lspping_tlv_header = (const struct lspping_tlv_header *)tptr;
617 lspping_tlv_type=GET_BE_U_2(lspping_tlv_header->type);
618 lspping_tlv_len=GET_BE_U_2(lspping_tlv_header->length);
619
620 ND_PRINT("\n\t %s TLV (%u), length: %u",
621 tok2str(lspping_tlv_values,
622 "Unknown",
623 lspping_tlv_type),
624 lspping_tlv_type,
625 lspping_tlv_len);
626
627 /* some little sanity checking */
628 if (lspping_tlv_len == 0) {
629 tptr+=sizeof(struct lspping_tlv_header);
630 tlen-=sizeof(struct lspping_tlv_header);
631 continue; /* no value to dissect */
632 }
633
634 tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
635 tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
636
637 /* Does the TLV go past the end of the packet? */
638 if (tlen < lspping_tlv_len+sizeof(struct lspping_tlv_header))
639 goto tooshort;
640 /* did we capture enough for fully decoding the tlv ? */
641 ND_TCHECK_LEN(tlv_tptr, lspping_tlv_len);
642 tlv_hexdump=FALSE;
643
644 switch(lspping_tlv_type) {
645 case LSPPING_TLV_TARGET_FEC_STACK:
646 while (tlv_tlen != 0) {
647 /* Does the subTLV header go past the end of the TLV? */
648 if (tlv_tlen < sizeof(struct lspping_tlv_header)) {
649 ND_PRINT("\n\t TLV is too short");
650 tlv_hexdump = TRUE;
651 goto tlv_tooshort;
652 }
653 /* did we capture enough for fully decoding the subtlv header ? */
654 ND_TCHECK_LEN(tlv_tptr, sizeof(struct lspping_tlv_header));
655 subtlv_hexdump=FALSE;
656
657 lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
658 lspping_subtlv_type=GET_BE_U_2(lspping_subtlv_header->type);
659 lspping_subtlv_len=GET_BE_U_2(lspping_subtlv_header->length);
660 subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
661
662 /* Does the subTLV go past the end of the TLV? */
663 if (tlv_tlen < lspping_subtlv_len+sizeof(struct lspping_tlv_header)) {
664 ND_PRINT("\n\t TLV is too short");
665 tlv_hexdump = TRUE;
666 goto tlv_tooshort;
667 }
668
669 /* Did we capture enough for fully decoding the subTLV? */
670 ND_TCHECK_LEN(subtlv_tptr, lspping_subtlv_len);
671
672 ND_PRINT("\n\t %s subTLV (%u), length: %u",
673 tok2str(lspping_tlvtargetfec_subtlv_values,
674 "Unknown",
675 lspping_subtlv_type),
676 lspping_subtlv_type,
677 lspping_subtlv_len);
678
679 switch(lspping_subtlv_type) {
680
681 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
682 /* Is the subTLV length correct? */
683 if (lspping_subtlv_len != 5) {
684 ND_PRINT("\n\t invalid subTLV length, should be 5");
685 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
686 } else {
687 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 =
688 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
689 ND_PRINT("\n\t %s/%u",
690 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
691 GET_U_1(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
692 }
693 break;
694
695 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
696 /* Is the subTLV length correct? */
697 if (lspping_subtlv_len != 17) {
698 ND_PRINT("\n\t invalid subTLV length, should be 17");
699 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
700 } else {
701 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 =
702 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
703 ND_PRINT("\n\t %s/%u",
704 GET_IP6ADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
705 GET_U_1(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
706 }
707 break;
708
709 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
710 /* Is the subTLV length correct? */
711 if (lspping_subtlv_len != 5) {
712 ND_PRINT("\n\t invalid subTLV length, should be 5");
713 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
714 } else {
715 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 =
716 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
717 ND_PRINT("\n\t %s/%u",
718 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
719 GET_U_1(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len));
720 }
721 break;
722
723 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
724 /* Is the subTLV length correct? */
725 if (lspping_subtlv_len != 17) {
726 ND_PRINT("\n\t invalid subTLV length, should be 17");
727 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
728 } else {
729 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 =
730 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
731 ND_PRINT("\n\t %s/%u",
732 GET_IP6ADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
733 GET_U_1(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len));
734 }
735 break;
736
737 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
738 /* Is the subTLV length correct? */
739 if (lspping_subtlv_len != 20) {
740 ND_PRINT("\n\t invalid subTLV length, should be 20");
741 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
742 } else {
743 subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 =
744 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
745 ND_PRINT("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x"
746 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
747 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
748 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
749 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
750 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
751 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id));
752 }
753 break;
754
755 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
756 /* Is the subTLV length correct? */
757 if (lspping_subtlv_len != 56) {
758 ND_PRINT("\n\t invalid subTLV length, should be 56");
759 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
760 } else {
761 subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 =
762 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
763 ND_PRINT("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x"
764 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
765 GET_IP6ADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
766 GET_IP6ADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
767 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
768 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
769 GET_IP6ADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id));
770 }
771 break;
772
773 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
774 /* Is the subTLV length correct? */
775 if (lspping_subtlv_len != 13) {
776 ND_PRINT("\n\t invalid subTLV length, should be 13");
777 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
778 } else {
779 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 =
780 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
781 ND_PRINT("\n\t RD: %s, %s/%u",
782 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
783 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
784 GET_U_1(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
785 }
786 break;
787
788 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
789 /* Is the subTLV length correct? */
790 if (lspping_subtlv_len != 25) {
791 ND_PRINT("\n\t invalid subTLV length, should be 25");
792 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
793 } else {
794 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 =
795 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
796 ND_PRINT("\n\t RD: %s, %s/%u",
797 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
798 GET_IP6ADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
799 GET_U_1(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
800 }
801 break;
802
803 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
804 /* Is the subTLV length correct? */
805 if (lspping_subtlv_len != 14) {
806 ND_PRINT("\n\t invalid subTLV length, should be 14");
807 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
808 } else {
809 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt =
810 (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
811 ND_PRINT("\n\t RD: %s, Sender VE ID: %u, Receiver VE ID: %u"
812 "\n\t Encapsulation Type: %s (%u)",
813 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
814 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ve_id),
815 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ve_id),
816 tok2str(mpls_pw_types_values,
817 "unknown",
818 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
819 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation));
820 }
821 break;
822
823 /* the old L2VPN VCID subTLV does not have support for the sender field */
824 case LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD:
825 /* Is the subTLV length correct? */
826 if (lspping_subtlv_len != 10) {
827 ND_PRINT("\n\t invalid subTLV length, should be 10");
828 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
829 } else {
830 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old =
831 (const struct lspping_tlv_targetfec_subtlv_fec_128_pw_old *)subtlv_tptr;
832 ND_PRINT("\n\t Remote PE: %s"
833 "\n\t PW ID: 0x%08x, PW Type: %s (%u)",
834 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
835 GET_BE_U_4(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_id),
836 tok2str(mpls_pw_types_values,
837 "unknown",
838 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_type)),
839 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_type));
840 }
841 break;
842
843 case LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW:
844 /* Is the subTLV length correct? */
845 if (lspping_subtlv_len != 14) {
846 ND_PRINT("\n\t invalid subTLV length, should be 14");
847 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
848 } else {
849 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid =
850 (const struct lspping_tlv_targetfec_subtlv_fec_128_pw *)subtlv_tptr;
851 ND_PRINT("\n\t Sender PE: %s, Remote PE: %s"
852 "\n\t PW ID: 0x%08x, PW Type: %s (%u)",
853 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
854 GET_IPADDR_STRING(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
855 GET_BE_U_4(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_id),
856 tok2str(mpls_pw_types_values,
857 "unknown",
858 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_type)),
859 GET_BE_U_2(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_type));
860 }
861 break;
862
863 default:
864 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
865 break;
866 }
867 /* do we want to see an additionally subtlv hexdump ? */
868 if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE)
869 print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header),
870 "\n\t ",
871 lspping_subtlv_len);
872
873 /* All subTLVs are aligned to four octet boundary */
874 if (lspping_subtlv_len % 4) {
875 lspping_subtlv_len += 4 - (lspping_subtlv_len % 4);
876 /* Does the subTLV, including padding, go past the end of the TLV? */
877 if (tlv_tlen < lspping_subtlv_len+sizeof(struct lspping_tlv_header)) {
878 ND_PRINT("\n\t\t TLV is too short");
879 return;
880 }
881 }
882 tlv_tptr+=lspping_subtlv_len;
883 tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header);
884 }
885 break;
886
887 case LSPPING_TLV_DOWNSTREAM_MAPPING:
888 /* Does the header go past the end of the TLV? */
889 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_t)) {
890 ND_PRINT("\n\t TLV is too short");
891 tlv_hexdump = TRUE;
892 goto tlv_tooshort;
893 }
894 /* Did we capture enough to get the address family? */
895 ND_TCHECK_LEN(tlv_tptr,
896 sizeof(struct lspping_tlv_downstream_map_t));
897
898 tlv_ptr.lspping_tlv_downstream_map=
899 (const struct lspping_tlv_downstream_map_t *)tlv_tptr;
900
901 /* that strange thing with the downstream map TLV is that until now
902 * we do not know if its IPv4 or IPv6 or is unnumbered; after
903 * we find the address-type, we recast the tlv_tptr and move on. */
904
905 address_type = GET_U_1(tlv_ptr.lspping_tlv_downstream_map->address_type);
906 ND_PRINT("\n\t MTU: %u, Address-Type: %s (%u)",
907 GET_BE_U_2(tlv_ptr.lspping_tlv_downstream_map->mtu),
908 tok2str(lspping_tlv_downstream_addr_values,
909 "unknown",
910 address_type),
911 address_type);
912
913 switch(address_type) {
914
915 case LSPPING_AFI_IPV4:
916 /* Does the data go past the end of the TLV? */
917 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv4_t)) {
918 ND_PRINT("\n\t TLV is too short");
919 tlv_hexdump = TRUE;
920 goto tlv_tooshort;
921 }
922 /* Did we capture enough for this part of the TLV? */
923 ND_TCHECK_LEN(tlv_tptr,
924 sizeof(struct lspping_tlv_downstream_map_ipv4_t));
925
926 tlv_ptr.lspping_tlv_downstream_map_ipv4=
927 (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
928 ND_PRINT("\n\t Downstream IP: %s"
929 "\n\t Downstream Interface IP: %s",
930 GET_IPADDR_STRING(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
931 GET_IPADDR_STRING(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface));
932 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
933 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
934 break;
935 case LSPPING_AFI_IPV4_UNMB:
936 /* Does the data go past the end of the TLV? */
937 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t)) {
938 ND_PRINT("\n\t TLV is too short");
939 tlv_hexdump = TRUE;
940 goto tlv_tooshort;
941 }
942 /* Did we capture enough for this part of the TLV? */
943 ND_TCHECK_LEN(tlv_tptr,
944 sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t));
945
946 tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb=
947 (const struct lspping_tlv_downstream_map_ipv4_unmb_t *)tlv_tptr;
948 ND_PRINT("\n\t Downstream IP: %s"
949 "\n\t Downstream Interface Index: 0x%08x",
950 GET_IPADDR_STRING(tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb->downstream_ip),
951 GET_BE_U_4(tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb->downstream_interface));
952 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t);
953 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t);
954 break;
955 case LSPPING_AFI_IPV6:
956 /* Does the data go past the end of the TLV? */
957 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv6_t)) {
958 ND_PRINT("\n\t TLV is too short");
959 tlv_hexdump = TRUE;
960 goto tlv_tooshort;
961 }
962 /* Did we capture enough for this part of the TLV? */
963 ND_TCHECK_LEN(tlv_tptr,
964 sizeof(struct lspping_tlv_downstream_map_ipv6_t));
965
966 tlv_ptr.lspping_tlv_downstream_map_ipv6=
967 (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
968 ND_PRINT("\n\t Downstream IP: %s"
969 "\n\t Downstream Interface IP: %s",
970 GET_IP6ADDR_STRING(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
971 GET_IP6ADDR_STRING(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface));
972 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
973 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
974 break;
975 case LSPPING_AFI_IPV6_UNMB:
976 /* Does the data go past the end of the TLV? */
977 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t)) {
978 ND_PRINT("\n\t TLV is too short");
979 tlv_hexdump = TRUE;
980 goto tlv_tooshort;
981 }
982 /* Did we capture enough for this part of the TLV? */
983 ND_TCHECK_LEN(tlv_tptr,
984 sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t));
985
986 tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb=
987 (const struct lspping_tlv_downstream_map_ipv6_unmb_t *)tlv_tptr;
988 ND_PRINT("\n\t Downstream IP: %s"
989 "\n\t Downstream Interface Index: 0x%08x",
990 GET_IP6ADDR_STRING(tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb->downstream_ip),
991 GET_BE_U_4(tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb->downstream_interface));
992 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t);
993 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t);
994 break;
995
996 default:
997 /* should not happen ! - no error message - tok2str() has barked already */
998 break;
999 }
1000
1001 /* Does the data go past the end of the TLV? */
1002 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_info_t)) {
1003 ND_PRINT("\n\t TLV is too short");
1004 tlv_hexdump = TRUE;
1005 goto tlv_tooshort;
1006 }
1007 /* Did we capture enough for this part of the TLV? */
1008 ND_TCHECK_LEN(tlv_tptr,
1009 sizeof(struct lspping_tlv_downstream_map_info_t));
1010
1011 tlv_ptr.lspping_tlv_downstream_map_info=
1012 (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
1013
1014 /* FIXME add hash-key type, depth limit, multipath processing */
1015
1016 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t);
1017 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t);
1018
1019 /* FIXME print downstream labels */
1020
1021 tlv_hexdump=TRUE; /* dump the TLV until code complete */
1022
1023 break;
1024
1025 case LSPPING_TLV_BFD_DISCRIMINATOR:
1026 if (tlv_tlen < LSPPING_TLV_BFD_DISCRIMINATOR_LEN) {
1027 ND_PRINT("\n\t TLV is too short");
1028 tlv_hexdump = TRUE;
1029 goto tlv_tooshort;
1030 } else {
1031 ND_TCHECK_LEN(tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
1032 ND_PRINT("\n\t BFD Discriminator 0x%08x", GET_BE_U_4(tptr));
1033 }
1034 break;
1035
1036 case LSPPING_TLV_VENDOR_ENTERPRISE:
1037 {
1038 uint32_t vendor_id;
1039
1040 if (tlv_tlen < LSPPING_TLV_VENDOR_ENTERPRISE_LEN) {
1041 ND_PRINT("\n\t TLV is too short");
1042 tlv_hexdump = TRUE;
1043 goto tlv_tooshort;
1044 } else {
1045 ND_TCHECK_LEN(tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN);
1046 vendor_id = GET_BE_U_4(tlv_tptr);
1047 ND_PRINT("\n\t Vendor: %s (0x%04x)",
1048 tok2str(smi_values, "Unknown", vendor_id),
1049 vendor_id);
1050 }
1051 }
1052 break;
1053
1054 /*
1055 * FIXME those are the defined TLVs that lack a decoder
1056 * you are welcome to contribute code ;-)
1057 */
1058 case LSPPING_TLV_PAD:
1059 case LSPPING_TLV_ERROR_CODE:
1060 case LSPPING_TLV_VENDOR_PRIVATE:
1061
1062 default:
1063 if (ndo->ndo_vflag <= 1)
1064 print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
1065 break;
1066 }
1067 /* do we want to see an additionally tlv hexdump ? */
1068 tlv_tooshort:
1069 if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
1070 print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t ",
1071 lspping_tlv_len);
1072
1073
1074 /* All TLVs are aligned to four octet boundary */
1075 if (lspping_tlv_len % 4) {
1076 lspping_tlv_len += (4 - lspping_tlv_len % 4);
1077 /* Does the TLV, including padding, go past the end of the packet? */
1078 if (tlen < lspping_tlv_len+sizeof(struct lspping_tlv_header))
1079 goto tooshort;
1080 }
1081
1082 tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header);
1083 tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header);
1084 }
1085 return;
1086 tooshort:
1087 ND_PRINT("\n\t\t packet is too short");
1088 return;
1089 trunc:
1090 nd_print_trunc(ndo);
1091 return;
1092 }