]> The Tcpdump Group git mirrors - tcpdump/blob - print-lspping.c
Move the printer summaries from INSTALL.txt to each printer
[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@juniper.net)
14 */
15
16 /* \summary: MPLS LSP PING printer */
17
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21
22 #include <netdissect-stdinc.h>
23
24 #include "netdissect.h"
25 #include "extract.h"
26 #include "addrtoname.h"
27
28 #include "l2vpn.h"
29 #include "oui.h"
30
31 /*
32 * LSPPING common header
33 *
34 * 0 1 2 3
35 * 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
36 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 * | Version Number | Must Be Zero |
38 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 * | Message Type | Reply mode | Return Code | Return Subcode|
40 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 * | Sender's Handle |
42 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 * | Sequence Number |
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 * | TimeStamp Sent (seconds) |
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 * | TimeStamp Sent (microseconds) |
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * | TimeStamp Received (seconds) |
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * | TimeStamp Received (microseconds) |
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 * | TLVs ... |
54 * . .
55 * . .
56 * . .
57 */
58
59 struct lspping_common_header {
60 uint8_t version[2];
61 uint8_t reserved[2];
62 uint8_t msg_type;
63 uint8_t reply_mode;
64 uint8_t return_code;
65 uint8_t return_subcode;
66 uint8_t sender_handle[4];
67 uint8_t seq_number[4];
68 uint8_t ts_sent_sec[4];
69 uint8_t ts_sent_usec[4];
70 uint8_t ts_rcvd_sec[4];
71 uint8_t ts_rcvd_usec[4];
72 };
73
74 #define LSPPING_VERSION 1
75
76 static const struct tok lspping_msg_type_values[] = {
77 { 1, "MPLS Echo Request"},
78 { 2, "MPLS Echo Reply"},
79 { 0, NULL}
80 };
81
82 static const struct tok lspping_reply_mode_values[] = {
83 { 1, "Do not reply"},
84 { 2, "Reply via an IPv4/IPv6 UDP packet"},
85 { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
86 { 4, "Reply via application level control channel"},
87 { 0, NULL}
88 };
89
90 static const struct tok lspping_return_code_values[] = {
91 { 0, "No return code or return code contained in the Error Code TLV"},
92 { 1, "Malformed echo request received"},
93 { 2, "One or more of the TLVs was not understood"},
94 { 3, "Replying router is an egress for the FEC at stack depth"},
95 { 4, "Replying router has no mapping for the FEC at stack depth"},
96 { 5, "Reserved"},
97 { 6, "Reserved"},
98 { 7, "Reserved"},
99 { 8, "Label switched at stack-depth"},
100 { 9, "Label switched but no MPLS forwarding at stack-depth"},
101 { 10, "Mapping for this FEC is not the given label at stack depth"},
102 { 11, "No label entry at stack-depth"},
103 { 12, "Protocol not associated with interface at FEC stack depth"},
104 };
105
106
107 /*
108 * LSPPING TLV header
109 * 0 1 2 3
110 * 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
111 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
112 * | Type | Length |
113 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
114 * | Value |
115 * . .
116 * . .
117 * . .
118 * | |
119 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
120 */
121
122 struct lspping_tlv_header {
123 uint8_t type[2];
124 uint8_t length[2];
125 };
126
127 #define LSPPING_TLV_TARGET_FEC_STACK 1
128 #define LSPPING_TLV_DOWNSTREAM_MAPPING 2
129 #define LSPPING_TLV_PAD 3
130 #define LSPPING_TLV_VENDOR_ENTERPRISE 5
131 #define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
132 #define LSPPING_TLV_INTERFACE_LABEL_STACK 7
133 #define LSPPING_TLV_ERROR_CODE 9
134 #define LSPPING_TLV_REPLY_TOS_BYTE 10
135 #define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
136 #define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
137 #define LSPPING_TLV_VENDOR_PRIVATE 0xfc00
138
139 static const struct tok lspping_tlv_values[] = {
140 { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" },
141 { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" },
142 { LSPPING_TLV_PAD, "Pad" },
143 { LSPPING_TLV_ERROR_CODE, "Error Code" },
144 { LSPPING_TLV_VENDOR_ENTERPRISE, "Vendor Enterprise Code" },
145 { LSPPING_TLV_INTERFACE_LABEL_STACK, "Interface Label Stack" },
146 { LSPPING_TLV_REPLY_TOS_BYTE, "Reply TOS Byte" },
147 { LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" },
148 { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Private Code" },
149 { 0, NULL}
150 };
151
152 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
153 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
154 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
155 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
156 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
157 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
158 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
159 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9
160 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 10
161 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 11
162 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 12
163
164 static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
165 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"},
166 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"},
167 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"},
168 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"},
169 { 5, "Reserved"},
170 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"},
171 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"},
172 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"},
173 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD, "L2 circuit ID (old)"},
174 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"},
175 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"},
176 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"},
177 { 0, NULL}
178 };
179
180 /*
181 * 0 1 2 3
182 * 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
183 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
184 * | IPv4 prefix |
185 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
186 * | Prefix Length | Must Be Zero |
187 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
188 */
189 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
190 uint8_t prefix [4];
191 uint8_t prefix_len;
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 * | IPv6 prefix |
199 * | (16 octets) |
200 * | |
201 * | |
202 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
203 * | Prefix Length | Must Be Zero |
204 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
205 */
206 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
207 uint8_t prefix [16];
208 uint8_t prefix_len;
209 };
210
211 /*
212 * 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
213 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
214 * | Sender identifier |
215 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
216 * | IPv4 prefix |
217 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
218 * | Prefix Length | Must Be Zero |
219 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
220 */
221 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
222 uint8_t sender_id [4];
223 uint8_t prefix [4];
224 uint8_t prefix_len;
225 };
226
227 /*
228 * 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
229 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
230 * | Sender identifier |
231 * | (16 octets) |
232 * | |
233 * | |
234 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
235 * | IPv6 prefix |
236 * | (16 octets) |
237 * | |
238 * | |
239 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240 * | Prefix Length | Must Be Zero |
241 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242 */
243 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
244 uint8_t sender_id [16];
245 uint8_t prefix [16];
246 uint8_t prefix_len;
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 * | IPv4 tunnel end point address |
254 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
255 * | Must Be Zero | Tunnel ID |
256 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257 * | Extended Tunnel ID |
258 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259 * | IPv4 tunnel sender address |
260 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
261 * | Must Be Zero | LSP ID |
262 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
263 */
264 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
265 uint8_t tunnel_endpoint [4];
266 uint8_t res[2];
267 uint8_t tunnel_id[2];
268 uint8_t extended_tunnel_id[4];
269 uint8_t tunnel_sender [4];
270 uint8_t res2[2];
271 uint8_t lsp_id [2];
272 };
273
274 /*
275 * 0 1 2 3
276 * 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
277 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
278 * | IPv6 tunnel end point address |
279 * | |
280 * | |
281 * | |
282 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
283 * | Must Be Zero | Tunnel ID |
284 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
285 * | Extended Tunnel ID |
286 * | |
287 * | |
288 * | |
289 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
290 * | IPv6 tunnel sender address |
291 * | |
292 * | |
293 * | |
294 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
295 * | Must Be Zero | LSP ID |
296 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
297 */
298 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
299 uint8_t tunnel_endpoint [16];
300 uint8_t res[2];
301 uint8_t tunnel_id[2];
302 uint8_t extended_tunnel_id[16];
303 uint8_t tunnel_sender [16];
304 uint8_t res2[2];
305 uint8_t lsp_id [2];
306 };
307
308 /*
309 * 0 1 2 3
310 * 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
311 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
312 * | Route Distinguisher |
313 * | (8 octets) |
314 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
315 * | IPv4 prefix |
316 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
317 * | Prefix Length | Must Be Zero |
318 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
319 */
320 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
321 uint8_t rd [8];
322 uint8_t prefix [4];
323 uint8_t prefix_len;
324 };
325
326 /*
327 * 0 1 2 3
328 * 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
329 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
330 * | Route Distinguisher |
331 * | (8 octets) |
332 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
333 * | IPv6 prefix |
334 * | (16 octets) |
335 * | |
336 * | |
337 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
338 * | Prefix Length | Must Be Zero |
339 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
340 */
341 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
342 uint8_t rd [8];
343 uint8_t prefix [16];
344 uint8_t prefix_len;
345 };
346
347 /*
348 * 0 1 2 3
349 * 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
350 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
351 * | Route Distinguisher |
352 * | (8 octets) |
353 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
354 * | Sender's CE ID | Receiver's CE ID |
355 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
356 * | Encapsulation Type | Must Be Zero |
357 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
358 * 0 1 2 3
359 */
360 struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
361 uint8_t rd [8];
362 uint8_t sender_ce_id [2];
363 uint8_t receiver_ce_id [2];
364 uint8_t encapsulation[2];
365 };
366
367 /*
368 * 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
369 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
370 * | Remote PE Address |
371 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
372 * | VC ID |
373 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
374 * | Encapsulation Type | Must Be Zero |
375 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
376 */
377 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t {
378 uint8_t remote_pe_address [4];
379 uint8_t vc_id [4];
380 uint8_t encapsulation[2];
381 };
382
383 /*
384 * 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
385 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
386 * | Sender's PE Address |
387 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
388 * | Remote PE Address |
389 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
390 * | VC ID |
391 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
392 * | Encapsulation Type | Must Be Zero |
393 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
394 */
395 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
396 uint8_t sender_pe_address [4];
397 uint8_t remote_pe_address [4];
398 uint8_t vc_id [4];
399 uint8_t encapsulation[2];
400 };
401
402 /*
403 * 0 1 2 3
404 * 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
405 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
406 * | MTU | Address Type | Resvd (SBZ) |
407 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
408 * | Downstream IP Address (4 or 16 octets) |
409 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
410 * | Downstream Interface Address (4 or 16 octets) |
411 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
412 * | Hash Key Type | Depth Limit | Multipath Length |
413 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
414 * . .
415 * . (Multipath Information) .
416 * . .
417 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
418 * | Downstream Label | Protocol |
419 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
420 * . .
421 * . .
422 * . .
423 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
424 * | Downstream Label | Protocol |
425 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
426 */
427 struct lspping_tlv_downstream_map_ipv4_t {
428 uint8_t mtu [2];
429 uint8_t address_type;
430 uint8_t res;
431 uint8_t downstream_ip[4];
432 uint8_t downstream_interface[4];
433 };
434
435 struct lspping_tlv_downstream_map_ipv6_t {
436 uint8_t mtu [2];
437 uint8_t address_type;
438 uint8_t res;
439 uint8_t downstream_ip[16];
440 uint8_t downstream_interface[16];
441 };
442
443 struct lspping_tlv_downstream_map_info_t {
444 uint8_t hash_key_type;
445 uint8_t depth_limit;
446 uint8_t multipath_length [2];
447 };
448
449 #define LSPPING_AFI_IPV4 1
450 #define LSPPING_AFI_UNMB 2
451 #define LSPPING_AFI_IPV6 3
452
453 static const struct tok lspping_tlv_downstream_addr_values[] = {
454 { LSPPING_AFI_IPV4, "IPv4"},
455 { LSPPING_AFI_IPV6, "IPv6"},
456 { LSPPING_AFI_UNMB, "Unnumbered"},
457 { 0, NULL}
458 };
459
460 void
461 lspping_print(netdissect_options *ndo,
462 register const u_char *pptr, register u_int len)
463 {
464 const struct lspping_common_header *lspping_com_header;
465 const struct lspping_tlv_header *lspping_tlv_header;
466 const struct lspping_tlv_header *lspping_subtlv_header;
467 const u_char *tptr,*tlv_tptr,*subtlv_tptr;
468 int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
469 int tlv_hexdump,subtlv_hexdump;
470 int lspping_subtlv_len,lspping_subtlv_type;
471 struct timeval timestamp;
472
473 union {
474 const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4;
475 const struct lspping_tlv_downstream_map_ipv6_t *lspping_tlv_downstream_map_ipv6;
476 const struct lspping_tlv_downstream_map_info_t *lspping_tlv_downstream_map_info;
477 } tlv_ptr;
478
479 union {
480 const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *lspping_tlv_targetfec_subtlv_ldp_ipv4;
481 const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *lspping_tlv_targetfec_subtlv_ldp_ipv6;
482 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *lspping_tlv_targetfec_subtlv_rsvp_ipv4;
483 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *lspping_tlv_targetfec_subtlv_rsvp_ipv6;
484 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4;
485 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6;
486 const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *lspping_tlv_targetfec_subtlv_l2vpn_endpt;
487 const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old;
488 const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid;
489 const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4;
490 const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6;
491 } subtlv_ptr;
492
493 tptr=pptr;
494 lspping_com_header = (const struct lspping_common_header *)pptr;
495 ND_TCHECK(*lspping_com_header);
496
497 /*
498 * Sanity checking of the header.
499 */
500 if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) {
501 ND_PRINT((ndo, "LSP-PING version %u packet not supported",
502 EXTRACT_16BITS(&lspping_com_header->version[0])));
503 return;
504 }
505
506 /* in non-verbose mode just lets print the basic Message Type*/
507 if (ndo->ndo_vflag < 1) {
508 ND_PRINT((ndo, "LSP-PINGv%u, %s, seq %u, length: %u",
509 EXTRACT_16BITS(&lspping_com_header->version[0]),
510 tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type),
511 EXTRACT_32BITS(lspping_com_header->seq_number),
512 len));
513 return;
514 }
515
516 /* ok they seem to want to know everything - lets fully decode it */
517
518 tlen=len;
519
520 ND_PRINT((ndo, "\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
521 EXTRACT_16BITS(&lspping_com_header->version[0]),
522 tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type),
523 lspping_com_header->msg_type,
524 len,
525 tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode),
526 lspping_com_header->reply_mode));
527
528 /*
529 * the following return codes require that the subcode is attached
530 * at the end of the translated token output
531 */
532 if (lspping_com_header->return_code == 3 ||
533 lspping_com_header->return_code == 4 ||
534 lspping_com_header->return_code == 8 ||
535 lspping_com_header->return_code == 10 ||
536 lspping_com_header->return_code == 11 ||
537 lspping_com_header->return_code == 12 )
538 ND_PRINT((ndo, "\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
539 tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
540 lspping_com_header->return_subcode,
541 lspping_com_header->return_code,
542 lspping_com_header->return_subcode));
543 else
544 ND_PRINT((ndo, "\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
545 tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
546 lspping_com_header->return_code,
547 lspping_com_header->return_subcode));
548
549 ND_PRINT((ndo, "\n\t Sender Handle: 0x%08x, Sequence: %u",
550 EXTRACT_32BITS(lspping_com_header->sender_handle),
551 EXTRACT_32BITS(lspping_com_header->seq_number)));
552
553 timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec);
554 timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
555 ND_PRINT((ndo, "\n\t Sender Timestamp: "));
556 ts_print(ndo, &timestamp);
557
558 timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec);
559 timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
560 ND_PRINT((ndo, "Receiver Timestamp: "));
561 if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
562 ts_print(ndo, &timestamp);
563 else
564 ND_PRINT((ndo, "no timestamp"));
565
566 tptr+=sizeof(const struct lspping_common_header);
567 tlen-=sizeof(const struct lspping_common_header);
568
569 while(tlen>(int)sizeof(struct lspping_tlv_header)) {
570
571 /* did we capture enough for fully decoding the tlv header ? */
572 ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
573
574 lspping_tlv_header = (const struct lspping_tlv_header *)tptr;
575 lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type);
576 lspping_tlv_len=EXTRACT_16BITS(lspping_tlv_header->length);
577
578 /* some little sanity checking */
579 if (lspping_tlv_type == 0 || lspping_tlv_len == 0)
580 return;
581
582 if(lspping_tlv_len < 4) {
583 ND_PRINT((ndo, "\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len));
584 return;
585 }
586
587 ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u",
588 tok2str(lspping_tlv_values,
589 "Unknown",
590 lspping_tlv_type),
591 lspping_tlv_type,
592 lspping_tlv_len));
593
594 tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
595 tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
596
597 /* did we capture enough for fully decoding the tlv ? */
598 ND_TCHECK2(*tptr, lspping_tlv_len);
599 tlv_hexdump=FALSE;
600
601 switch(lspping_tlv_type) {
602 case LSPPING_TLV_TARGET_FEC_STACK:
603 while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) {
604
605 /* did we capture enough for fully decoding the subtlv header ? */
606 ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
607 subtlv_hexdump=FALSE;
608
609 lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
610 lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type);
611 lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
612 subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
613
614 if (lspping_subtlv_len == 0)
615 break;
616
617 ND_PRINT((ndo, "\n\t %s subTLV (%u), length: %u",
618 tok2str(lspping_tlvtargetfec_subtlv_values,
619 "Unknown",
620 lspping_subtlv_type),
621 lspping_subtlv_type,
622 lspping_subtlv_len));
623
624 switch(lspping_subtlv_type) {
625
626 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
627 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
628 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
629 ND_PRINT((ndo, "\n\t %s/%u",
630 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
631 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
632 break;
633
634 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
635 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
636 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
637 ND_PRINT((ndo, "\n\t %s/%u",
638 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
639 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
640 break;
641
642 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
643 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
644 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
645 ND_PRINT((ndo, "\n\t %s/%u, sender-id %s",
646 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
647 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len,
648 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)));
649 break;
650
651 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
652 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
653 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
654 ND_PRINT((ndo, "\n\t %s/%u, sender-id %s",
655 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
656 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
657 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)));
658 break;
659
660 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
661 subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
662 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
663 ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
664 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
665 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
666 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
667 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
668 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
669 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)));
670 break;
671
672 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
673 subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
674 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
675 ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
676 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
677 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
678 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
679 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
680 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
681 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)));
682 break;
683
684 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
685 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
686 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
687 ND_PRINT((ndo, "\n\t RD: %s, %s/%u",
688 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
689 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
690 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
691 break;
692
693 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
694 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
695 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
696 ND_PRINT((ndo, "\n\t RD: %s, %s/%u",
697 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
698 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
699 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
700 break;
701
702 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
703 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
704 (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
705 ND_PRINT((ndo, "\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
706 "\n\t Encapsulation Type: %s (%u)",
707 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
708 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id),
709 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id),
710 tok2str(l2vpn_encaps_values,
711 "unknown",
712 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
713 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)));
714
715 break;
716
717 /* the old L2VPN VCID subTLV does not have support for the sender field */
718 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD:
719 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \
720 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr;
721 ND_PRINT((ndo, "\n\t Remote PE: %s" \
722 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
723 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
724 EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id),
725 tok2str(l2vpn_encaps_values,
726 "unknown",
727 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)),
728 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)));
729
730 break;
731
732 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID:
733 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \
734 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr;
735 ND_PRINT((ndo, "\n\t Sender PE: %s, Remote PE: %s" \
736 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
737 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
738 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
739 EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id),
740 tok2str(l2vpn_encaps_values,
741 "unknown",
742 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)),
743 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)));
744
745 break;
746
747 default:
748 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
749 break;
750 }
751 /* do we want to see an additionally subtlv hexdump ? */
752 if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE)
753 print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header), \
754 "\n\t ",
755 lspping_subtlv_len);
756
757 tlv_tptr+=lspping_subtlv_len;
758 tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header);
759 }
760 break;
761
762 case LSPPING_TLV_DOWNSTREAM_MAPPING:
763 /* that strange thing with the downstream map TLV is that until now
764 * we do not know if its IPv4 or IPv6 , after we found the address-type
765 * lets recast the tlv_tptr and move on */
766
767 tlv_ptr.lspping_tlv_downstream_map_ipv4= \
768 (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
769 tlv_ptr.lspping_tlv_downstream_map_ipv6= \
770 (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
771 ND_PRINT((ndo, "\n\t MTU: %u, Address-Type: %s (%u)",
772 EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu),
773 tok2str(lspping_tlv_downstream_addr_values,
774 "unknown",
775 tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type),
776 tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type));
777
778 switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) {
779
780 case LSPPING_AFI_IPV4:
781 ND_PRINT((ndo, "\n\t Downstream IP: %s" \
782 "\n\t Downstream Interface IP: %s",
783 ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
784 ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
785 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
786 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
787 break;
788 case LSPPING_AFI_IPV6:
789 ND_PRINT((ndo, "\n\t Downstream IP: %s" \
790 "\n\t Downstream Interface IP: %s",
791 ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
792 ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)));
793 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
794 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
795 break;
796 case LSPPING_AFI_UNMB:
797 ND_PRINT((ndo, "\n\t Downstream IP: %s" \
798 "\n\t Downstream Interface Index: 0x%08x",
799 ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
800 EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
801 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
802 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
803 break;
804
805 default:
806 /* should not happen ! - no error message - tok2str() has barked already */
807 break;
808 }
809
810 tlv_ptr.lspping_tlv_downstream_map_info= \
811 (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
812
813 /* FIXME add hash-key type, depth limit, multipath processing */
814
815
816 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t);
817 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t);
818
819 /* FIXME print downstream labels */
820
821
822 tlv_hexdump=TRUE; /* dump the TLV until code complete */
823
824 break;
825
826 case LSPPING_TLV_BFD_DISCRIMINATOR:
827 tptr += sizeof(struct lspping_tlv_header);
828 ND_TCHECK2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
829 ND_PRINT((ndo, "\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)));
830 break;
831
832 case LSPPING_TLV_VENDOR_ENTERPRISE:
833 {
834 uint32_t vendor_id;
835
836 ND_TCHECK2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN);
837 vendor_id = EXTRACT_32BITS(tlv_tptr);
838 ND_PRINT((ndo, "\n\t Vendor: %s (0x%04x)",
839 tok2str(smi_values, "Unknown", vendor_id),
840 vendor_id));
841 }
842 break;
843
844 /*
845 * FIXME those are the defined TLVs that lack a decoder
846 * you are welcome to contribute code ;-)
847 */
848 case LSPPING_TLV_PAD:
849 case LSPPING_TLV_ERROR_CODE:
850 case LSPPING_TLV_VENDOR_PRIVATE:
851
852 default:
853 if (ndo->ndo_vflag <= 1)
854 print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
855 break;
856 }
857 /* do we want to see an additionally tlv hexdump ? */
858 if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
859 print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t ",
860 lspping_tlv_len);
861
862
863 /* All TLVs are aligned to four octet boundary */
864 if (lspping_tlv_len % 4) {
865 lspping_tlv_len += (4 - lspping_tlv_len % 4);
866 }
867
868 tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header);
869 tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header);
870 }
871 return;
872 trunc:
873 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
874 }
875 /*
876 * Local Variables:
877 * c-style: whitesmith
878 * c-basic-offset: 8
879 * End:
880 */