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