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