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