]> The Tcpdump Group git mirrors - tcpdump/blob - print-lspping.c
655a933d3dbea6bd767b6b90288da721224e3fea
[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.4 2004-06-12 08:23:45 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 #include "bgp.h"
35
36 /*
37 * LSPPING common header
38 *
39 * 0 1 2 3
40 * 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
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * | Version Number | Must Be Zero |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | Message Type | Reply mode | Return Code | Return Subcode|
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * | Sender's Handle |
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * | Sequence Number |
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | TimeStamp Sent (seconds) |
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * | TimeStamp Sent (microseconds) |
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 * | TimeStamp Received (seconds) |
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * | TimeStamp Received (microseconds) |
57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 * | TLVs ... |
59 * . .
60 * . .
61 * . .
62 */
63
64 struct lspping_common_header {
65 u_int8_t version[2];
66 u_int8_t reserved[2];
67 u_int8_t msg_type;
68 u_int8_t reply_mode;
69 u_int8_t return_code;
70 u_int8_t return_subcode;
71 u_int8_t sender_handle[4];
72 u_int8_t seq_number[4];
73 u_int8_t ts_sent_sec[4];
74 u_int8_t ts_sent_usec[4];
75 u_int8_t ts_rcvd_sec[4];
76 u_int8_t ts_rcvd_usec[4];
77 };
78
79 #define LSPPING_VERSION 1
80 #define FALSE 0
81 #define TRUE 1
82
83 static const struct tok lspping_msg_type_values[] = {
84 { 1, "MPLS Echo Request"},
85 { 2, "MPLS Echo Reply"},
86 { 0, NULL}
87 };
88
89 static const struct tok lspping_reply_mode_values[] = {
90 { 1, "Do not reply"},
91 { 2, "Reply via an IPv4/IPv6 UDP packet"},
92 { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
93 { 4, "Reply via application level control channel"},
94 { 0, NULL}
95 };
96
97 static const struct tok lspping_return_code_values[] = {
98 { 0, "No return code or return code contained in the Error Code TLV"},
99 { 1, "Malformed echo request received"},
100 { 2, "One or more of the TLVs was not understood"},
101 { 3, "Replying router is an egress for the FEC at stack depth"},
102 { 4, "Replying router has no mapping for the FEC at stack depth"},
103 { 5, "Reserved"},
104 { 6, "Reserved"},
105 { 7, "Reserved"},
106 { 8, "Label switched at stack-depth"},
107 { 9, "Label switched but no MPLS forwarding at stack-depth"},
108 { 10, "Mapping for this FEC is not the given label at stack depth"},
109 { 11, "No label entry at stack-depth"},
110 { 12, "Protocol not associated with interface at FEC stack depth"},
111 };
112
113
114 /*
115 * LSPPING TLV header
116 * 0 1 2 3
117 * 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
118 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
119 * | Type | Length |
120 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
121 * | Value |
122 * . .
123 * . .
124 * . .
125 * | |
126 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
127 */
128
129 struct lspping_tlv_header {
130 u_int8_t type[2];
131 u_int8_t length[2];
132 };
133
134 #define LSPPING_TLV_TARGET_FEC_STACK 1
135 #define LSPPING_TLV_DOWNSTREAM_MAPPING 2
136 #define LSPPING_TLV_PAD 3
137 #define LSPPING_TLV_ERROR_CODE 4
138 #define LSPPING_TLV_VENDOR_PRIVATE 5
139
140 static const struct tok lspping_tlv_values[] = {
141 { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" },
142 { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" },
143 { LSPPING_TLV_PAD, "Pad" },
144 { LSPPING_TLV_ERROR_CODE, "Error Code" },
145 { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Enterprise Code" },
146 { 0, NULL}
147 };
148
149 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
150 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
151 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
152 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
153 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
154 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
155 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
156 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 9
157 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 10
158 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 11
159
160 static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
161 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"},
162 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"},
163 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"},
164 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"},
165 { 5, "Reserved"},
166 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"},
167 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"},
168 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"},
169 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"},
170 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"},
171 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"},
172 { 0, NULL}
173 };
174
175 /*
176 * 0 1 2 3
177 * 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
178 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
179 * | IPv4 prefix |
180 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
181 * | Prefix Length | Must Be Zero |
182 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
183 */
184 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
185 u_int8_t prefix [4];
186 u_int8_t prefix_len;
187 };
188
189 /*
190 * 0 1 2 3
191 * 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
192 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
193 * | IPv6 prefix |
194 * | (16 octets) |
195 * | |
196 * | |
197 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
198 * | Prefix Length | Must Be Zero |
199 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
200 */
201 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
202 u_int8_t prefix [16];
203 u_int8_t prefix_len;
204 };
205
206 /*
207 * 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
208 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
209 * | Sender identifier |
210 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
211 * | IPv4 prefix |
212 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
213 * | Prefix Length | Must Be Zero |
214 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
215 */
216 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
217 u_int8_t sender_id [4];
218 u_int8_t prefix [4];
219 u_int8_t prefix_len;
220 };
221
222 /*
223 * 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
224 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
225 * | Sender identifier |
226 * | (16 octets) |
227 * | |
228 * | |
229 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
230 * | IPv6 prefix |
231 * | (16 octets) |
232 * | |
233 * | |
234 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
235 * | Prefix Length | Must Be Zero |
236 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
237 */
238 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
239 u_int8_t sender_id [16];
240 u_int8_t prefix [16];
241 u_int8_t prefix_len;
242 };
243
244 /*
245 * 0 1 2 3
246 * 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
247 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
248 * | IPv4 tunnel end point address |
249 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
250 * | Must Be Zero | Tunnel ID |
251 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
252 * | Extended Tunnel ID |
253 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
254 * | IPv4 tunnel sender address |
255 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
256 * | Must Be Zero | LSP ID |
257 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
258 */
259 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
260 u_int8_t tunnel_endpoint [4];
261 u_int8_t res[2];
262 u_int8_t tunnel_id[2];
263 u_int8_t extended_tunnel_id[4];
264 u_int8_t tunnel_sender [4];
265 u_int8_t res2[2];
266 u_int8_t lsp_id [2];
267 };
268
269 /*
270 * 0 1 2 3
271 * 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
272 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
273 * | IPv6 tunnel end point address |
274 * | |
275 * | |
276 * | |
277 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
278 * | Must Be Zero | Tunnel ID |
279 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
280 * | Extended Tunnel ID |
281 * | |
282 * | |
283 * | |
284 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
285 * | IPv6 tunnel sender address |
286 * | |
287 * | |
288 * | |
289 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
290 * | Must Be Zero | LSP ID |
291 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
292 */
293 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
294 u_int8_t tunnel_endpoint [16];
295 u_int8_t res[2];
296 u_int8_t tunnel_id[2];
297 u_int8_t extended_tunnel_id[16];
298 u_int8_t tunnel_sender [16];
299 u_int8_t res2[2];
300 u_int8_t lsp_id [2];
301 };
302
303 /*
304 * 0 1 2 3
305 * 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
306 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307 * | Route Distinguisher |
308 * | (8 octets) |
309 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
310 * | IPv4 prefix |
311 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
312 * | Prefix Length | Must Be Zero |
313 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
314 */
315 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
316 u_int8_t rd [8];
317 u_int8_t prefix [4];
318 u_int8_t prefix_len;
319 };
320
321 /*
322 * 0 1 2 3
323 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
324 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
325 * | Route Distinguisher |
326 * | (8 octets) |
327 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
328 * | IPv6 prefix |
329 * | (16 octets) |
330 * | |
331 * | |
332 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
333 * | Prefix Length | Must Be Zero |
334 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
335 */
336 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
337 u_int8_t rd [8];
338 u_int8_t prefix [16];
339 u_int8_t prefix_len;
340 };
341
342 void
343 lspping_print(register const u_char *pptr, register u_int len) {
344
345 const struct lspping_common_header *lspping_com_header;
346 const struct lspping_tlv_header *lspping_tlv_header;
347 const struct lspping_tlv_header *lspping_subtlv_header;
348 const u_char *tptr,*tlv_tptr,*subtlv_tptr;
349 int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
350 int tlv_hexdump,subtlv_hexdump;
351 int lspping_subtlv_len,lspping_subtlv_type;
352
353 union {
354 const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *lspping_tlv_targetfec_subtlv_ldp_ipv4;
355 const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *lspping_tlv_targetfec_subtlv_ldp_ipv6;
356 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *lspping_tlv_targetfec_subtlv_rsvp_ipv4;
357 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *lspping_tlv_targetfec_subtlv_rsvp_ipv6;
358 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4;
359 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6;
360 const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4;
361 const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6;
362 } subtlv_ptr;
363
364 tptr=pptr;
365 lspping_com_header = (const struct lspping_common_header *)pptr;
366 TCHECK(*lspping_com_header);
367
368 /*
369 * Sanity checking of the header.
370 */
371 if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) {
372 printf("LSP-PING version %u packet not supported",
373 EXTRACT_16BITS(&lspping_com_header->version[0]));
374 return;
375 }
376
377 /* in non-verbose mode just lets print the basic Message Type*/
378 if (vflag < 1) {
379 printf("LSP-PINGv%u, %s, seq %u, length: %u",
380 EXTRACT_16BITS(&lspping_com_header->version[0]),
381 tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type),
382 EXTRACT_32BITS(lspping_com_header->seq_number),
383 len);
384 return;
385 }
386
387 /* ok they seem to want to know everything - lets fully decode it */
388
389 tlen=len;
390
391 printf("\n\tLSP-PINGv%u, msg-type: %s (%u), reply-mode: %s (%u)",
392 EXTRACT_16BITS(&lspping_com_header->version[0]),
393 tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type),
394 lspping_com_header->msg_type,
395 tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode),
396 lspping_com_header->reply_mode);
397
398 /*
399 * the following return codes require that the subcode is attached
400 * at the end of the translated token output
401 */
402 if (lspping_com_header->return_code == 3 ||
403 lspping_com_header->return_code == 4 ||
404 lspping_com_header->return_code == 8 ||
405 lspping_com_header->return_code == 10 ||
406 lspping_com_header->return_code == 11 ||
407 lspping_com_header->return_code == 12 )
408 printf("\n\t Return Code: %s %u (%u), Return Subcode: (%u)",
409 tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
410 lspping_com_header->return_subcode,
411 lspping_com_header->return_code,
412 lspping_com_header->return_subcode);
413 else
414 printf("\n\t Return Code: %s (%u), Return Subcode: (%u)",
415 tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
416 lspping_com_header->return_code,
417 lspping_com_header->return_subcode);
418
419 printf("\n\t Sender Handle: 0x%08x, Sequence: %u" \
420 "\n\t Sender Timestamp %u.%us, Receiver Timestamp %u.%us",
421 EXTRACT_32BITS(lspping_com_header->sender_handle),
422 EXTRACT_32BITS(lspping_com_header->seq_number),
423 EXTRACT_32BITS(lspping_com_header->ts_sent_sec), /* FIXME: replace with ts_print() */
424 EXTRACT_32BITS(lspping_com_header->ts_sent_usec),
425 EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec), /* FIXME: replace with ts_print() */
426 EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec));
427
428 tptr+=sizeof(const struct lspping_common_header);
429 tlen-=sizeof(const struct lspping_common_header);
430
431 while(tlen>0) {
432 /* did we capture enough for fully decoding the tlv header ? */
433 if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
434 goto trunc;
435
436 lspping_tlv_header = (const struct lspping_tlv_header *)tptr;
437 lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type);
438 lspping_tlv_len=EXTRACT_16BITS(lspping_tlv_header->length);
439
440 if (lspping_tlv_len == 0)
441 return;
442
443 if(lspping_tlv_len % 4 || lspping_tlv_len < 4) { /* aligned to four octet boundary */
444 printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len);
445 return;
446 }
447
448 printf("\n\t %s TLV (%u), length: %u",
449 tok2str(lspping_tlv_values,
450 "Unknown",
451 lspping_tlv_type),
452 lspping_tlv_type,
453 lspping_tlv_len);
454
455 tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
456 tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
457
458 /* did we capture enough for fully decoding the tlv ? */
459 if (!TTEST2(*tptr, lspping_tlv_len))
460 goto trunc;
461 tlv_hexdump=FALSE;
462
463 switch(lspping_tlv_type) {
464 case LSPPING_TLV_TARGET_FEC_STACK:
465 while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) {
466
467 /* did we capture enough for fully decoding the subtlv header ? */
468 if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
469 goto trunc;
470 subtlv_hexdump=FALSE;
471
472 lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
473 lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type);
474 lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
475 subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
476
477 if (lspping_subtlv_len == 0)
478 break;
479
480 printf("\n\t %s subTLV (%u), length: %u",
481 tok2str(lspping_tlvtargetfec_subtlv_values,
482 "Unknown",
483 lspping_subtlv_type),
484 lspping_subtlv_type,
485 lspping_subtlv_len);
486
487 switch(lspping_subtlv_type) {
488
489 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
490 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
491 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
492 printf("\n\t %s/%u",
493 ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
494 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len);
495 break;
496
497 #ifdef INET6
498 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
499 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
500 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
501 printf("\n\t %s/%u",
502 ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
503 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len);
504 break;
505 #endif
506
507 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
508 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
509 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
510 printf("\n\t %s/%u, sender-id %s",
511 ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
512 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len,
513 ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id));
514 break;
515
516 #ifdef INET6
517 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
518 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
519 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
520 printf("\n\t %s/%u, sender-id %s",
521 ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
522 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
523 ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id));
524 break;
525 #endif
526
527 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
528 subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
529 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
530 printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
531 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
532 ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
533 ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
534 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
535 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
536 ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id));
537 break;
538
539 #ifdef INET6
540 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
541 subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
542 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
543 printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
544 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
545 ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
546 ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
547 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
548 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
549 ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id));
550 break;
551 #endif
552
553 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
554 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
555 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
556 printf("\n\t RD: %s :%s/%u",
557 bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
558 ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
559 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len);
560 break;
561
562 #ifdef INET6
563 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
564 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
565 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
566 printf("\n\t RD: %s :%s/%u",
567 bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
568 ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
569 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len);
570 break;
571 #endif
572
573
574 /*
575 * FIXME those are the defined subTLVs that lack a decoder
576 * you are welcome to contribute code ;-)
577 */
578
579 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
580 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID:
581
582 default:
583 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
584 break;
585 }
586 /* do we want to see an additionally subtlv hexdump ? */
587 if (vflag > 1 || subtlv_hexdump==TRUE)
588 print_unknown_data(tlv_tptr+sizeof(struct lspping_tlv_header), \
589 "\n\t ",
590 lspping_subtlv_len);
591
592 tlv_tptr+=lspping_subtlv_len;
593 tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header);
594 }
595 break;
596
597 /*
598 * FIXME those are the defined TLVs that lack a decoder
599 * you are welcome to contribute code ;-)
600 */
601
602 case LSPPING_TLV_DOWNSTREAM_MAPPING:
603 case LSPPING_TLV_PAD:
604 case LSPPING_TLV_ERROR_CODE:
605 case LSPPING_TLV_VENDOR_PRIVATE:
606
607 default:
608 if (vflag <= 1)
609 print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen);
610 break;
611 }
612 /* do we want to see an additionally tlv hexdump ? */
613 if (vflag > 1 || tlv_hexdump==TRUE)
614 print_unknown_data(tptr+sizeof(sizeof(struct lspping_tlv_header)),"\n\t ",
615 lspping_tlv_len);
616
617 tptr+=lspping_tlv_len;
618 tlen-=lspping_tlv_len;
619 }
620 return;
621 trunc:
622 printf("\n\t\t packet exceeded snapshot");
623 }