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