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