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