1 /* NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp */
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.
15 * Original code by Hannes Gredler (hannes@juniper.net)
19 static const char rcsid
[] _U_
=
20 "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.34 2007-08-29 02:31:44 mcr Exp $ (LBL)";
22 __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
29 #include <tcpdump-stdinc.h>
34 #include "interface.h"
35 #include "addrtoname.h"
40 #include "ethertype.h"
43 #define JUNIPER_BPF_OUT 0 /* Outgoing packet */
44 #define JUNIPER_BPF_IN 1 /* Incoming packet */
45 #define JUNIPER_BPF_PKT_IN 0x1 /* Incoming packet */
46 #define JUNIPER_BPF_NO_L2 0x2 /* L2 header stripped */
47 #define JUNIPER_BPF_IIF 0x4 /* IIF is valid */
48 #define JUNIPER_BPF_FILTER 0x40 /* BPF filtering is supported */
49 #define JUNIPER_BPF_EXT 0x80 /* extensions present */
50 #define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */
52 #define JUNIPER_LSQ_COOKIE_RE (1 << 3)
53 #define JUNIPER_LSQ_COOKIE_DIR (1 << 2)
54 #define JUNIPER_LSQ_L3_PROTO_SHIFT 4
55 #define JUNIPER_LSQ_L3_PROTO_MASK (0x17 << JUNIPER_LSQ_L3_PROTO_SHIFT)
56 #define JUNIPER_LSQ_L3_PROTO_IPV4 (0 << JUNIPER_LSQ_L3_PROTO_SHIFT)
57 #define JUNIPER_LSQ_L3_PROTO_IPV6 (1 << JUNIPER_LSQ_L3_PROTO_SHIFT)
58 #define JUNIPER_LSQ_L3_PROTO_MPLS (2 << JUNIPER_LSQ_L3_PROTO_SHIFT)
59 #define JUNIPER_LSQ_L3_PROTO_ISO (3 << JUNIPER_LSQ_L3_PROTO_SHIFT)
60 #define AS_PIC_COOKIE_LEN 8
62 #define JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE 1
63 #define JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE 2
64 #define JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE 3
65 #define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4
66 #define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5
68 static const struct tok juniper_ipsec_type_values
[] = {
69 { JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE
, "ESP ENCR-AUTH" },
70 { JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE
, "ESP ENCR-AH AUTH" },
71 { JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE
, "ESP AUTH" },
72 { JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE
, "AH AUTH" },
73 { JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE
, "ESP ENCR" },
77 static const struct tok juniper_direction_values
[] = {
78 { JUNIPER_BPF_IN
, "In"},
79 { JUNIPER_BPF_OUT
, "Out"},
83 /* codepoints for encoding extensions to a .pcap file */
85 JUNIPER_EXT_TLV_IFD_IDX
= 1,
86 JUNIPER_EXT_TLV_IFD_NAME
= 2,
87 JUNIPER_EXT_TLV_IFD_MEDIATYPE
= 3,
88 JUNIPER_EXT_TLV_IFL_IDX
= 4,
89 JUNIPER_EXT_TLV_IFL_UNIT
= 5,
90 JUNIPER_EXT_TLV_IFL_ENCAPS
= 6,
91 JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE
= 7,
92 JUNIPER_EXT_TLV_TTP_IFL_ENCAPS
= 8
95 /* 1 byte type and 1-byte length */
96 #define JUNIPER_EXT_TLV_OVERHEAD 2
98 static const struct tok jnx_ext_tlv_values
[] = {
99 { JUNIPER_EXT_TLV_IFD_IDX
, "Device Interface Index" },
100 { JUNIPER_EXT_TLV_IFD_NAME
,"Device Interface Name" },
101 { JUNIPER_EXT_TLV_IFD_MEDIATYPE
, "Device Media Type" },
102 { JUNIPER_EXT_TLV_IFL_IDX
, "Logical Interface Index" },
103 { JUNIPER_EXT_TLV_IFL_UNIT
,"Logical Unit Number" },
104 { JUNIPER_EXT_TLV_IFL_ENCAPS
, "Logical Interface Encapsulation" },
105 { JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE
, "TTP derived Device Media Type" },
106 { JUNIPER_EXT_TLV_TTP_IFL_ENCAPS
, "TTP derived Logical Interface Encapsulation" },
110 static const struct tok jnx_flag_values
[] = {
111 { JUNIPER_BPF_EXT
, "Ext" },
112 { JUNIPER_BPF_FILTER
, "Filter" },
113 { JUNIPER_BPF_IIF
, "IIF" },
114 { JUNIPER_BPF_NO_L2
, "no-L2" },
115 { JUNIPER_BPF_PKT_IN
, "In" },
119 #define JUNIPER_IFML_ETHER 1
120 #define JUNIPER_IFML_FDDI 2
121 #define JUNIPER_IFML_TOKENRING 3
122 #define JUNIPER_IFML_PPP 4
123 #define JUNIPER_IFML_FRAMERELAY 5
124 #define JUNIPER_IFML_CISCOHDLC 6
125 #define JUNIPER_IFML_SMDSDXI 7
126 #define JUNIPER_IFML_ATMPVC 8
127 #define JUNIPER_IFML_PPP_CCC 9
128 #define JUNIPER_IFML_FRAMERELAY_CCC 10
129 #define JUNIPER_IFML_IPIP 11
130 #define JUNIPER_IFML_GRE 12
131 #define JUNIPER_IFML_PIM 13
132 #define JUNIPER_IFML_PIMD 14
133 #define JUNIPER_IFML_CISCOHDLC_CCC 15
134 #define JUNIPER_IFML_VLAN_CCC 16
135 #define JUNIPER_IFML_MLPPP 17
136 #define JUNIPER_IFML_MLFR 18
137 #define JUNIPER_IFML_ML 19
138 #define JUNIPER_IFML_LSI 20
139 #define JUNIPER_IFML_DFE 21
140 #define JUNIPER_IFML_ATM_CELLRELAY_CCC 22
141 #define JUNIPER_IFML_CRYPTO 23
142 #define JUNIPER_IFML_GGSN 24
143 #define JUNIPER_IFML_LSI_PPP 25
144 #define JUNIPER_IFML_LSI_CISCOHDLC 26
145 #define JUNIPER_IFML_PPP_TCC 27
146 #define JUNIPER_IFML_FRAMERELAY_TCC 28
147 #define JUNIPER_IFML_CISCOHDLC_TCC 29
148 #define JUNIPER_IFML_ETHERNET_CCC 30
149 #define JUNIPER_IFML_VT 31
150 #define JUNIPER_IFML_EXTENDED_VLAN_CCC 32
151 #define JUNIPER_IFML_ETHER_OVER_ATM 33
152 #define JUNIPER_IFML_MONITOR 34
153 #define JUNIPER_IFML_ETHERNET_TCC 35
154 #define JUNIPER_IFML_VLAN_TCC 36
155 #define JUNIPER_IFML_EXTENDED_VLAN_TCC 37
156 #define JUNIPER_IFML_CONTROLLER 38
157 #define JUNIPER_IFML_MFR 39
158 #define JUNIPER_IFML_LS 40
159 #define JUNIPER_IFML_ETHERNET_VPLS 41
160 #define JUNIPER_IFML_ETHERNET_VLAN_VPLS 42
161 #define JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS 43
162 #define JUNIPER_IFML_LT 44
163 #define JUNIPER_IFML_SERVICES 45
164 #define JUNIPER_IFML_ETHER_VPLS_OVER_ATM 46
165 #define JUNIPER_IFML_FR_PORT_CCC 47
166 #define JUNIPER_IFML_FRAMERELAY_EXT_CCC 48
167 #define JUNIPER_IFML_FRAMERELAY_EXT_TCC 49
168 #define JUNIPER_IFML_FRAMERELAY_FLEX 50
169 #define JUNIPER_IFML_GGSNI 51
170 #define JUNIPER_IFML_ETHERNET_FLEX 52
171 #define JUNIPER_IFML_COLLECTOR 53
172 #define JUNIPER_IFML_AGGREGATOR 54
173 #define JUNIPER_IFML_LAPD 55
174 #define JUNIPER_IFML_PPPOE 56
175 #define JUNIPER_IFML_PPP_SUBORDINATE 57
176 #define JUNIPER_IFML_CISCOHDLC_SUBORDINATE 58
177 #define JUNIPER_IFML_DFC 59
178 #define JUNIPER_IFML_PICPEER 60
180 static const struct tok juniper_ifmt_values
[] = {
181 { JUNIPER_IFML_ETHER
, "Ethernet" },
182 { JUNIPER_IFML_FDDI
, "FDDI" },
183 { JUNIPER_IFML_TOKENRING
, "Token-Ring" },
184 { JUNIPER_IFML_PPP
, "PPP" },
185 { JUNIPER_IFML_PPP_SUBORDINATE
, "PPP-Subordinate" },
186 { JUNIPER_IFML_FRAMERELAY
, "Frame-Relay" },
187 { JUNIPER_IFML_CISCOHDLC
, "Cisco-HDLC" },
188 { JUNIPER_IFML_SMDSDXI
, "SMDS-DXI" },
189 { JUNIPER_IFML_ATMPVC
, "ATM-PVC" },
190 { JUNIPER_IFML_PPP_CCC
, "PPP-CCC" },
191 { JUNIPER_IFML_FRAMERELAY_CCC
, "Frame-Relay-CCC" },
192 { JUNIPER_IFML_FRAMERELAY_EXT_CCC
, "Extended FR-CCC" },
193 { JUNIPER_IFML_IPIP
, "IP-over-IP" },
194 { JUNIPER_IFML_GRE
, "GRE" },
195 { JUNIPER_IFML_PIM
, "PIM-Encapsulator" },
196 { JUNIPER_IFML_PIMD
, "PIM-Decapsulator" },
197 { JUNIPER_IFML_CISCOHDLC_CCC
, "Cisco-HDLC-CCC" },
198 { JUNIPER_IFML_VLAN_CCC
, "VLAN-CCC" },
199 { JUNIPER_IFML_EXTENDED_VLAN_CCC
, "Extended-VLAN-CCC" },
200 { JUNIPER_IFML_MLPPP
, "Multilink-PPP" },
201 { JUNIPER_IFML_MLFR
, "Multilink-FR" },
202 { JUNIPER_IFML_MFR
, "Multilink-FR-UNI-NNI" },
203 { JUNIPER_IFML_ML
, "Multilink" },
204 { JUNIPER_IFML_LS
, "LinkService" },
205 { JUNIPER_IFML_LSI
, "LSI" },
206 { JUNIPER_IFML_ATM_CELLRELAY_CCC
, "ATM-CCC-Cell-Relay" },
207 { JUNIPER_IFML_CRYPTO
, "IPSEC-over-IP" },
208 { JUNIPER_IFML_GGSN
, "GGSN" },
209 { JUNIPER_IFML_PPP_TCC
, "PPP-TCC" },
210 { JUNIPER_IFML_FRAMERELAY_TCC
, "Frame-Relay-TCC" },
211 { JUNIPER_IFML_FRAMERELAY_EXT_TCC
, "Extended FR-TCC" },
212 { JUNIPER_IFML_CISCOHDLC_TCC
, "Cisco-HDLC-TCC" },
213 { JUNIPER_IFML_ETHERNET_CCC
, "Ethernet-CCC" },
214 { JUNIPER_IFML_VT
, "VPN-Loopback-tunnel" },
215 { JUNIPER_IFML_ETHER_OVER_ATM
, "Ethernet-over-ATM" },
216 { JUNIPER_IFML_ETHER_VPLS_OVER_ATM
, "Ethernet-VPLS-over-ATM" },
217 { JUNIPER_IFML_MONITOR
, "Monitor" },
218 { JUNIPER_IFML_ETHERNET_TCC
, "Ethernet-TCC" },
219 { JUNIPER_IFML_VLAN_TCC
, "VLAN-TCC" },
220 { JUNIPER_IFML_EXTENDED_VLAN_TCC
, "Extended-VLAN-TCC" },
221 { JUNIPER_IFML_CONTROLLER
, "Controller" },
222 { JUNIPER_IFML_ETHERNET_VPLS
, "VPLS" },
223 { JUNIPER_IFML_ETHERNET_VLAN_VPLS
, "VLAN-VPLS" },
224 { JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS
, "Extended-VLAN-VPLS" },
225 { JUNIPER_IFML_LT
, "Logical-tunnel" },
226 { JUNIPER_IFML_SERVICES
, "General-Services" },
227 { JUNIPER_IFML_PPPOE
, "PPPoE" },
228 { JUNIPER_IFML_ETHERNET_FLEX
, "Flexible-Ethernet-Services" },
229 { JUNIPER_IFML_FRAMERELAY_FLEX
, "Flexible-FrameRelay" },
230 { JUNIPER_IFML_COLLECTOR
, "Flow-collection" },
231 { JUNIPER_IFML_PICPEER
, "PIC Peer" },
232 { JUNIPER_IFML_DFC
, "Dynamic-Flow-Capture" },
236 #define JUNIPER_IFLE_ATM_SNAP 2
237 #define JUNIPER_IFLE_ATM_NLPID 3
238 #define JUNIPER_IFLE_ATM_VCMUX 4
239 #define JUNIPER_IFLE_ATM_LLC 5
240 #define JUNIPER_IFLE_ATM_PPP_VCMUX 6
241 #define JUNIPER_IFLE_ATM_PPP_LLC 7
242 #define JUNIPER_IFLE_ATM_PPP_FUNI 8
243 #define JUNIPER_IFLE_ATM_CCC 9
244 #define JUNIPER_IFLE_FR_NLPID 10
245 #define JUNIPER_IFLE_FR_SNAP 11
246 #define JUNIPER_IFLE_FR_PPP 12
247 #define JUNIPER_IFLE_FR_CCC 13
248 #define JUNIPER_IFLE_ENET2 14
249 #define JUNIPER_IFLE_IEEE8023_SNAP 15
250 #define JUNIPER_IFLE_IEEE8023_LLC 16
251 #define JUNIPER_IFLE_PPP 17
252 #define JUNIPER_IFLE_CISCOHDLC 18
253 #define JUNIPER_IFLE_PPP_CCC 19
254 #define JUNIPER_IFLE_IPIP_NULL 20
255 #define JUNIPER_IFLE_PIM_NULL 21
256 #define JUNIPER_IFLE_GRE_NULL 22
257 #define JUNIPER_IFLE_GRE_PPP 23
258 #define JUNIPER_IFLE_PIMD_DECAPS 24
259 #define JUNIPER_IFLE_CISCOHDLC_CCC 25
260 #define JUNIPER_IFLE_ATM_CISCO_NLPID 26
261 #define JUNIPER_IFLE_VLAN_CCC 27
262 #define JUNIPER_IFLE_MLPPP 28
263 #define JUNIPER_IFLE_MLFR 29
264 #define JUNIPER_IFLE_LSI_NULL 30
265 #define JUNIPER_IFLE_AGGREGATE_UNUSED 31
266 #define JUNIPER_IFLE_ATM_CELLRELAY_CCC 32
267 #define JUNIPER_IFLE_CRYPTO 33
268 #define JUNIPER_IFLE_GGSN 34
269 #define JUNIPER_IFLE_ATM_TCC 35
270 #define JUNIPER_IFLE_FR_TCC 36
271 #define JUNIPER_IFLE_PPP_TCC 37
272 #define JUNIPER_IFLE_CISCOHDLC_TCC 38
273 #define JUNIPER_IFLE_ETHERNET_CCC 39
274 #define JUNIPER_IFLE_VT 40
275 #define JUNIPER_IFLE_ATM_EOA_LLC 41
276 #define JUNIPER_IFLE_EXTENDED_VLAN_CCC 42
277 #define JUNIPER_IFLE_ATM_SNAP_TCC 43
278 #define JUNIPER_IFLE_MONITOR 44
279 #define JUNIPER_IFLE_ETHERNET_TCC 45
280 #define JUNIPER_IFLE_VLAN_TCC 46
281 #define JUNIPER_IFLE_EXTENDED_VLAN_TCC 47
282 #define JUNIPER_IFLE_MFR 48
283 #define JUNIPER_IFLE_ETHERNET_VPLS 49
284 #define JUNIPER_IFLE_ETHERNET_VLAN_VPLS 50
285 #define JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS 51
286 #define JUNIPER_IFLE_SERVICES 52
287 #define JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC 53
288 #define JUNIPER_IFLE_FR_PORT_CCC 54
289 #define JUNIPER_IFLE_ATM_MLPPP_LLC 55
290 #define JUNIPER_IFLE_ATM_EOA_CCC 56
291 #define JUNIPER_IFLE_LT_VLAN 57
292 #define JUNIPER_IFLE_COLLECTOR 58
293 #define JUNIPER_IFLE_AGGREGATOR 59
294 #define JUNIPER_IFLE_LAPD 60
295 #define JUNIPER_IFLE_ATM_PPPOE_LLC 61
296 #define JUNIPER_IFLE_ETHERNET_PPPOE 62
297 #define JUNIPER_IFLE_PPPOE 63
298 #define JUNIPER_IFLE_PPP_SUBORDINATE 64
299 #define JUNIPER_IFLE_CISCOHDLC_SUBORDINATE 65
300 #define JUNIPER_IFLE_DFC 66
301 #define JUNIPER_IFLE_PICPEER 67
303 static const struct tok juniper_ifle_values
[] = {
304 { JUNIPER_IFLE_AGGREGATOR
, "Aggregator" },
305 { JUNIPER_IFLE_ATM_CCC
, "CCC over ATM" },
306 { JUNIPER_IFLE_ATM_CELLRELAY_CCC
, "ATM CCC Cell Relay" },
307 { JUNIPER_IFLE_ATM_CISCO_NLPID
, "CISCO compatible NLPID" },
308 { JUNIPER_IFLE_ATM_EOA_CCC
, "Ethernet over ATM CCC" },
309 { JUNIPER_IFLE_ATM_EOA_LLC
, "Ethernet over ATM LLC" },
310 { JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC
, "Ethernet VPLS over ATM LLC" },
311 { JUNIPER_IFLE_ATM_LLC
, "ATM LLC" },
312 { JUNIPER_IFLE_ATM_MLPPP_LLC
, "MLPPP over ATM LLC" },
313 { JUNIPER_IFLE_ATM_NLPID
, "ATM NLPID" },
314 { JUNIPER_IFLE_ATM_PPPOE_LLC
, "PPPoE over ATM LLC" },
315 { JUNIPER_IFLE_ATM_PPP_FUNI
, "PPP over FUNI" },
316 { JUNIPER_IFLE_ATM_PPP_LLC
, "PPP over ATM LLC" },
317 { JUNIPER_IFLE_ATM_PPP_VCMUX
, "PPP over ATM VCMUX" },
318 { JUNIPER_IFLE_ATM_SNAP
, "ATM SNAP" },
319 { JUNIPER_IFLE_ATM_SNAP_TCC
, "ATM SNAP TCC" },
320 { JUNIPER_IFLE_ATM_TCC
, "ATM VCMUX TCC" },
321 { JUNIPER_IFLE_ATM_VCMUX
, "ATM VCMUX" },
322 { JUNIPER_IFLE_CISCOHDLC
, "C-HDLC" },
323 { JUNIPER_IFLE_CISCOHDLC_CCC
, "C-HDLC CCC" },
324 { JUNIPER_IFLE_CISCOHDLC_SUBORDINATE
, "C-HDLC via dialer" },
325 { JUNIPER_IFLE_CISCOHDLC_TCC
, "C-HDLC TCC" },
326 { JUNIPER_IFLE_COLLECTOR
, "Collector" },
327 { JUNIPER_IFLE_CRYPTO
, "Crypto" },
328 { JUNIPER_IFLE_ENET2
, "Ethernet" },
329 { JUNIPER_IFLE_ETHERNET_CCC
, "Ethernet CCC" },
330 { JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS
, "Extended VLAN VPLS" },
331 { JUNIPER_IFLE_ETHERNET_PPPOE
, "PPPoE over Ethernet" },
332 { JUNIPER_IFLE_ETHERNET_TCC
, "Ethernet TCC" },
333 { JUNIPER_IFLE_ETHERNET_VLAN_VPLS
, "VLAN VPLS" },
334 { JUNIPER_IFLE_ETHERNET_VPLS
, "VPLS" },
335 { JUNIPER_IFLE_EXTENDED_VLAN_CCC
, "Extended VLAN CCC" },
336 { JUNIPER_IFLE_EXTENDED_VLAN_TCC
, "Extended VLAN TCC" },
337 { JUNIPER_IFLE_FR_CCC
, "FR CCC" },
338 { JUNIPER_IFLE_FR_NLPID
, "FR NLPID" },
339 { JUNIPER_IFLE_FR_PORT_CCC
, "FR CCC" },
340 { JUNIPER_IFLE_FR_PPP
, "FR PPP" },
341 { JUNIPER_IFLE_FR_SNAP
, "FR SNAP" },
342 { JUNIPER_IFLE_FR_TCC
, "FR TCC" },
343 { JUNIPER_IFLE_GGSN
, "GGSN" },
344 { JUNIPER_IFLE_GRE_NULL
, "GRE NULL" },
345 { JUNIPER_IFLE_GRE_PPP
, "PPP over GRE" },
346 { JUNIPER_IFLE_IPIP_NULL
, "IPIP" },
347 { JUNIPER_IFLE_LAPD
, "LAPD" },
348 { JUNIPER_IFLE_LSI_NULL
, "LSI Null" },
349 { JUNIPER_IFLE_LT_VLAN
, "LT VLAN" },
350 { JUNIPER_IFLE_MFR
, "MFR" },
351 { JUNIPER_IFLE_MLFR
, "MLFR" },
352 { JUNIPER_IFLE_MLPPP
, "MLPPP" },
353 { JUNIPER_IFLE_MONITOR
, "Monitor" },
354 { JUNIPER_IFLE_PIMD_DECAPS
, "PIMd" },
355 { JUNIPER_IFLE_PIM_NULL
, "PIM Null" },
356 { JUNIPER_IFLE_PPP
, "PPP" },
357 { JUNIPER_IFLE_PPPOE
, "PPPoE" },
358 { JUNIPER_IFLE_PPP_CCC
, "PPP CCC" },
359 { JUNIPER_IFLE_PPP_SUBORDINATE
, "" },
360 { JUNIPER_IFLE_PPP_TCC
, "PPP TCC" },
361 { JUNIPER_IFLE_SERVICES
, "General Services" },
362 { JUNIPER_IFLE_VLAN_CCC
, "VLAN CCC" },
363 { JUNIPER_IFLE_VLAN_TCC
, "VLAN TCC" },
364 { JUNIPER_IFLE_VT
, "VT" },
368 struct juniper_cookie_table_t
{
369 u_int32_t pictype
; /* pic type */
370 u_int8_t cookie_len
; /* cookie len */
371 const char *s
; /* pic name */
374 static const struct juniper_cookie_table_t juniper_cookie_table
[] = {
375 #ifdef DLT_JUNIPER_ATM1
376 { DLT_JUNIPER_ATM1
, 4, "ATM1"},
378 #ifdef DLT_JUNIPER_ATM2
379 { DLT_JUNIPER_ATM2
, 8, "ATM2"},
381 #ifdef DLT_JUNIPER_MLPPP
382 { DLT_JUNIPER_MLPPP
, 2, "MLPPP"},
384 #ifdef DLT_JUNIPER_MLFR
385 { DLT_JUNIPER_MLFR
, 2, "MLFR"},
387 #ifdef DLT_JUNIPER_MFR
388 { DLT_JUNIPER_MFR
, 4, "MFR"},
390 #ifdef DLT_JUNIPER_PPPOE
391 { DLT_JUNIPER_PPPOE
, 0, "PPPoE"},
393 #ifdef DLT_JUNIPER_PPPOE_ATM
394 { DLT_JUNIPER_PPPOE_ATM
, 0, "PPPoE ATM"},
396 #ifdef DLT_JUNIPER_GGSN
397 { DLT_JUNIPER_GGSN
, 8, "GGSN"},
399 #ifdef DLT_JUNIPER_MONITOR
400 { DLT_JUNIPER_MONITOR
, 8, "MONITOR"},
402 #ifdef DLT_JUNIPER_SERVICES
403 { DLT_JUNIPER_SERVICES
, 8, "AS"},
405 #ifdef DLT_JUNIPER_ES
406 { DLT_JUNIPER_ES
, 0, "ES"},
411 struct juniper_l2info_t
{
418 u_int8_t cookie_type
;
425 #define LS_COOKIE_ID 0x54
426 #define AS_COOKIE_ID 0x47
427 #define LS_MLFR_COOKIE_LEN 4
428 #define ML_MLFR_COOKIE_LEN 2
429 #define LS_MFR_COOKIE_LEN 6
430 #define ATM1_COOKIE_LEN 4
431 #define ATM2_COOKIE_LEN 8
433 #define ATM2_PKT_TYPE_MASK 0x70
434 #define ATM2_GAP_COUNT_MASK 0x3F
436 #define JUNIPER_PROTO_NULL 1
437 #define JUNIPER_PROTO_IPV4 2
438 #define JUNIPER_PROTO_IPV6 6
440 #define MFR_BE_MASK 0xc0
442 static const struct tok juniper_protocol_values
[] = {
443 { JUNIPER_PROTO_NULL
, "Null" },
444 { JUNIPER_PROTO_IPV4
, "IPv4" },
445 { JUNIPER_PROTO_IPV6
, "IPv6" },
449 int ip_heuristic_guess(register const u_char
*, u_int
);
450 int juniper_ppp_heuristic_guess(register const u_char
*, u_int
);
451 int juniper_read_tlv_value(const u_char
*, u_int
, u_int
);
452 static int juniper_parse_header (const u_char
*, const struct pcap_pkthdr
*, struct juniper_l2info_t
*);
454 #ifdef DLT_JUNIPER_GGSN
456 juniper_ggsn_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
458 struct juniper_l2info_t l2info
;
459 struct juniper_ggsn_header
{
467 const struct juniper_ggsn_header
*gh
;
469 l2info
.pictype
= DLT_JUNIPER_GGSN
;
470 if(juniper_parse_header(p
, h
, &l2info
) == 0)
471 return l2info
.header_len
;
473 p
+=l2info
.header_len
;
474 gh
= (struct juniper_ggsn_header
*)&l2info
.cookie
;
477 printf("proto %s (%u), vlan %u: ",
478 tok2str(juniper_protocol_values
,"Unknown",gh
->proto
),
480 EXTRACT_16BITS(&gh
->vlan_id
[0]));
484 case JUNIPER_PROTO_IPV4
:
485 ip_print(gndo
, p
, l2info
.length
);
488 case JUNIPER_PROTO_IPV6
:
489 ip6_print(gndo
, p
, l2info
.length
);
494 printf("unknown GGSN proto (%u)", gh
->proto
);
497 return l2info
.header_len
;
501 #ifdef DLT_JUNIPER_ES
503 juniper_es_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
505 struct juniper_l2info_t l2info
;
506 struct juniper_ipsec_header
{
507 u_int8_t sa_index
[2];
514 u_int rewrite_len
,es_type_bundle
;
515 const struct juniper_ipsec_header
*ih
;
517 l2info
.pictype
= DLT_JUNIPER_ES
;
518 if(juniper_parse_header(p
, h
, &l2info
) == 0)
519 return l2info
.header_len
;
521 p
+=l2info
.header_len
;
522 ih
= (struct juniper_ipsec_header
*)p
;
525 case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE
:
526 case JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE
:
530 case JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE
:
531 case JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE
:
532 case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE
:
536 printf("ES Invalid type %u, length %u",
539 return l2info
.header_len
;
542 l2info
.length
-=rewrite_len
;
546 if (!es_type_bundle
) {
547 printf("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
548 EXTRACT_16BITS(&ih
->sa_index
),
550 tok2str(juniper_ipsec_type_values
,"Unknown",ih
->type
),
552 EXTRACT_32BITS(&ih
->spi
),
553 ipaddr_string(&ih
->src_ip
),
554 ipaddr_string(&ih
->dst_ip
),
557 printf("ES SA, index %u, ttl %u type %s (%u), length %u\n",
558 EXTRACT_16BITS(&ih
->sa_index
),
560 tok2str(juniper_ipsec_type_values
,"Unknown",ih
->type
),
566 ip_print(gndo
, p
, l2info
.length
);
567 return l2info
.header_len
;
571 #ifdef DLT_JUNIPER_MONITOR
573 juniper_monitor_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
575 struct juniper_l2info_t l2info
;
576 struct juniper_monitor_header
{
580 u_int8_t service_id
[4];
582 const struct juniper_monitor_header
*mh
;
584 l2info
.pictype
= DLT_JUNIPER_MONITOR
;
585 if(juniper_parse_header(p
, h
, &l2info
) == 0)
586 return l2info
.header_len
;
588 p
+=l2info
.header_len
;
589 mh
= (struct juniper_monitor_header
*)p
;
592 printf("service-id %u, iif %u, pkt-type %u: ",
593 EXTRACT_32BITS(&mh
->service_id
),
594 EXTRACT_16BITS(&mh
->iif
),
597 /* no proto field - lets guess by first byte of IP header*/
598 ip_heuristic_guess(p
, l2info
.length
);
600 return l2info
.header_len
;
604 #ifdef DLT_JUNIPER_SERVICES
606 juniper_services_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
608 struct juniper_l2info_t l2info
;
609 struct juniper_services_header
{
612 u_int8_t svc_set_id
[2];
615 const struct juniper_services_header
*sh
;
617 l2info
.pictype
= DLT_JUNIPER_SERVICES
;
618 if(juniper_parse_header(p
, h
, &l2info
) == 0)
619 return l2info
.header_len
;
621 p
+=l2info
.header_len
;
622 sh
= (struct juniper_services_header
*)p
;
625 printf("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
628 EXTRACT_16BITS(&sh
->svc_set_id
),
629 EXTRACT_24BITS(&sh
->dir_iif
[1]));
631 /* no proto field - lets guess by first byte of IP header*/
632 ip_heuristic_guess(p
, l2info
.length
);
634 return l2info
.header_len
;
638 #ifdef DLT_JUNIPER_PPPOE
640 juniper_pppoe_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
642 struct juniper_l2info_t l2info
;
644 l2info
.pictype
= DLT_JUNIPER_PPPOE
;
645 if(juniper_parse_header(p
, h
, &l2info
) == 0)
646 return l2info
.header_len
;
648 p
+=l2info
.header_len
;
649 /* this DLT contains nothing but raw ethernet frames */
650 ether_print(gndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
651 return l2info
.header_len
;
655 #ifdef DLT_JUNIPER_ETHER
657 juniper_ether_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
659 struct juniper_l2info_t l2info
;
661 l2info
.pictype
= DLT_JUNIPER_ETHER
;
662 if(juniper_parse_header(p
, h
, &l2info
) == 0)
663 return l2info
.header_len
;
665 p
+=l2info
.header_len
;
666 /* this DLT contains nothing but raw Ethernet frames */
667 ether_print(gndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
668 return l2info
.header_len
;
672 #ifdef DLT_JUNIPER_PPP
674 juniper_ppp_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
676 struct juniper_l2info_t l2info
;
678 l2info
.pictype
= DLT_JUNIPER_PPP
;
679 if(juniper_parse_header(p
, h
, &l2info
) == 0)
680 return l2info
.header_len
;
682 p
+=l2info
.header_len
;
683 /* this DLT contains nothing but raw ppp frames */
684 ppp_print(p
, l2info
.length
);
685 return l2info
.header_len
;
689 #ifdef DLT_JUNIPER_FRELAY
691 juniper_frelay_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
693 struct juniper_l2info_t l2info
;
695 l2info
.pictype
= DLT_JUNIPER_FRELAY
;
696 if(juniper_parse_header(p
, h
, &l2info
) == 0)
697 return l2info
.header_len
;
699 p
+=l2info
.header_len
;
700 /* this DLT contains nothing but raw frame-relay frames */
701 fr_print(p
, l2info
.length
);
702 return l2info
.header_len
;
706 #ifdef DLT_JUNIPER_CHDLC
708 juniper_chdlc_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
710 struct juniper_l2info_t l2info
;
712 l2info
.pictype
= DLT_JUNIPER_CHDLC
;
713 if(juniper_parse_header(p
, h
, &l2info
) == 0)
714 return l2info
.header_len
;
716 p
+=l2info
.header_len
;
717 /* this DLT contains nothing but raw c-hdlc frames */
718 chdlc_print(p
, l2info
.length
);
719 return l2info
.header_len
;
723 #ifdef DLT_JUNIPER_PPPOE_ATM
725 juniper_pppoe_atm_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
727 struct juniper_l2info_t l2info
;
728 u_int16_t extracted_ethertype
;
730 l2info
.pictype
= DLT_JUNIPER_PPPOE_ATM
;
731 if(juniper_parse_header(p
, h
, &l2info
) == 0)
732 return l2info
.header_len
;
734 p
+=l2info
.header_len
;
736 extracted_ethertype
= EXTRACT_16BITS(p
);
737 /* this DLT contains nothing but raw PPPoE frames,
738 * prepended with a type field*/
739 if (ethertype_print(gndo
, extracted_ethertype
,
741 l2info
.length
-ETHERTYPE_LEN
,
742 l2info
.caplen
-ETHERTYPE_LEN
) == 0)
743 /* ether_type not known, probably it wasn't one */
744 printf("unknown ethertype 0x%04x", extracted_ethertype
);
746 return l2info
.header_len
;
750 #ifdef DLT_JUNIPER_MLPPP
752 juniper_mlppp_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
754 struct juniper_l2info_t l2info
;
756 l2info
.pictype
= DLT_JUNIPER_MLPPP
;
757 if(juniper_parse_header(p
, h
, &l2info
) == 0)
758 return l2info
.header_len
;
760 /* suppress Bundle-ID if frame was captured on a child-link
761 * best indicator if the cookie looks like a proto */
763 EXTRACT_16BITS(&l2info
.cookie
) != PPP_OSI
&&
764 EXTRACT_16BITS(&l2info
.cookie
) != (PPP_ADDRESS
<< 8 | PPP_CONTROL
))
765 printf("Bundle-ID %u: ",l2info
.bundle
);
767 p
+=l2info
.header_len
;
769 /* first try the LSQ protos */
770 switch(l2info
.proto
) {
771 case JUNIPER_LSQ_L3_PROTO_IPV4
:
772 /* IP traffic going to the RE would not have a cookie
773 * -> this must be incoming IS-IS over PPP
775 if (l2info
.cookie
[4] == (JUNIPER_LSQ_COOKIE_RE
|JUNIPER_LSQ_COOKIE_DIR
))
776 ppp_print(p
, l2info
.length
);
778 ip_print(gndo
, p
, l2info
.length
);
779 return l2info
.header_len
;
781 case JUNIPER_LSQ_L3_PROTO_IPV6
:
782 ip6_print(gndo
, p
,l2info
.length
);
783 return l2info
.header_len
;
785 case JUNIPER_LSQ_L3_PROTO_MPLS
:
786 mpls_print(p
,l2info
.length
);
787 return l2info
.header_len
;
788 case JUNIPER_LSQ_L3_PROTO_ISO
:
789 isoclns_print(p
,l2info
.length
,l2info
.caplen
);
790 return l2info
.header_len
;
795 /* zero length cookie ? */
796 switch (EXTRACT_16BITS(&l2info
.cookie
)) {
798 ppp_print(p
-2,l2info
.length
+2);
800 case (PPP_ADDRESS
<< 8 | PPP_CONTROL
): /* fall through */
802 ppp_print(p
,l2info
.length
);
806 return l2info
.header_len
;
811 #ifdef DLT_JUNIPER_MFR
813 juniper_mfr_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
815 struct juniper_l2info_t l2info
;
817 l2info
.pictype
= DLT_JUNIPER_MFR
;
818 if(juniper_parse_header(p
, h
, &l2info
) == 0)
819 return l2info
.header_len
;
821 p
+=l2info
.header_len
;
824 if (l2info
.cookie_len
== 0) {
825 mfr_print(p
,l2info
.length
);
826 return l2info
.header_len
;
829 /* first try the LSQ protos */
830 if (l2info
.cookie_len
== AS_PIC_COOKIE_LEN
) {
831 switch(l2info
.proto
) {
832 case JUNIPER_LSQ_L3_PROTO_IPV4
:
833 ip_print(gndo
, p
, l2info
.length
);
834 return l2info
.header_len
;
836 case JUNIPER_LSQ_L3_PROTO_IPV6
:
837 ip6_print(gndo
, p
,l2info
.length
);
838 return l2info
.header_len
;
840 case JUNIPER_LSQ_L3_PROTO_MPLS
:
841 mpls_print(p
,l2info
.length
);
842 return l2info
.header_len
;
843 case JUNIPER_LSQ_L3_PROTO_ISO
:
844 isoclns_print(p
,l2info
.length
,l2info
.caplen
);
845 return l2info
.header_len
;
849 return l2info
.header_len
;
852 /* suppress Bundle-ID if frame was captured on a child-link */
853 if (eflag
&& EXTRACT_32BITS(l2info
.cookie
) != 1) printf("Bundle-ID %u, ",l2info
.bundle
);
854 switch (l2info
.proto
) {
855 case (LLCSAP_ISONS
<<8 | LLCSAP_ISONS
):
856 isoclns_print(p
+1, l2info
.length
-1, l2info
.caplen
-1);
858 case (LLC_UI
<<8 | NLPID_Q933
):
859 case (LLC_UI
<<8 | NLPID_IP
):
860 case (LLC_UI
<<8 | NLPID_IP6
):
861 /* pass IP{4,6} to the OSI layer for proper link-layer printing */
862 isoclns_print(p
-1, l2info
.length
+1, l2info
.caplen
+1);
865 printf("unknown protocol 0x%04x, length %u",l2info
.proto
, l2info
.length
);
868 return l2info
.header_len
;
872 #ifdef DLT_JUNIPER_MLFR
874 juniper_mlfr_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
876 struct juniper_l2info_t l2info
;
878 l2info
.pictype
= DLT_JUNIPER_MLFR
;
879 if(juniper_parse_header(p
, h
, &l2info
) == 0)
880 return l2info
.header_len
;
882 p
+=l2info
.header_len
;
884 /* suppress Bundle-ID if frame was captured on a child-link */
885 if (eflag
&& EXTRACT_32BITS(l2info
.cookie
) != 1) printf("Bundle-ID %u, ",l2info
.bundle
);
886 switch (l2info
.proto
) {
889 isoclns_print(p
, l2info
.length
, l2info
.caplen
);
891 case (LLC_UI
<<8 | NLPID_Q933
):
892 case (LLC_UI
<<8 | NLPID_IP
):
893 case (LLC_UI
<<8 | NLPID_IP6
):
894 /* pass IP{4,6} to the OSI layer for proper link-layer printing */
895 isoclns_print(p
-1, l2info
.length
+1, l2info
.caplen
+1);
898 printf("unknown protocol 0x%04x, length %u",l2info
.proto
, l2info
.length
);
901 return l2info
.header_len
;
906 * ATM1 PIC cookie format
908 * +-----+-------------------------+-------------------------------+
909 * |fmtid| vc index | channel ID |
910 * +-----+-------------------------+-------------------------------+
913 #ifdef DLT_JUNIPER_ATM1
915 juniper_atm1_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
917 u_int16_t extracted_ethertype
;
919 struct juniper_l2info_t l2info
;
921 l2info
.pictype
= DLT_JUNIPER_ATM1
;
922 if(juniper_parse_header(p
, h
, &l2info
) == 0)
923 return l2info
.header_len
;
925 p
+=l2info
.header_len
;
927 if (l2info
.cookie
[0] == 0x80) { /* OAM cell ? */
928 oam_print(p
,l2info
.length
,ATM_OAM_NOHEC
);
929 return l2info
.header_len
;
932 if (EXTRACT_24BITS(p
) == 0xfefe03 || /* NLPID encaps ? */
933 EXTRACT_24BITS(p
) == 0xaaaa03) { /* SNAP encaps ? */
935 if (llc_print(p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
,
936 &extracted_ethertype
) != 0)
937 return l2info
.header_len
;
940 if (p
[0] == 0x03) { /* Cisco style NLPID encaps ? */
941 isoclns_print(p
+ 1, l2info
.length
- 1, l2info
.caplen
- 1);
942 /* FIXME check if frame was recognized */
943 return l2info
.header_len
;
946 if(ip_heuristic_guess(p
, l2info
.length
) != 0) /* last try - vcmux encaps ? */
947 return l2info
.header_len
;
949 return l2info
.header_len
;
954 * ATM2 PIC cookie format
956 * +-------------------------------+---------+---+-----+-----------+
957 * | channel ID | reserv |AAL| CCRQ| gap cnt |
958 * +-------------------------------+---------+---+-----+-----------+
961 #ifdef DLT_JUNIPER_ATM2
963 juniper_atm2_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
965 u_int16_t extracted_ethertype
;
967 struct juniper_l2info_t l2info
;
969 l2info
.pictype
= DLT_JUNIPER_ATM2
;
970 if(juniper_parse_header(p
, h
, &l2info
) == 0)
971 return l2info
.header_len
;
973 p
+=l2info
.header_len
;
975 if (l2info
.cookie
[7] & ATM2_PKT_TYPE_MASK
) { /* OAM cell ? */
976 oam_print(p
,l2info
.length
,ATM_OAM_NOHEC
);
977 return l2info
.header_len
;
980 if (EXTRACT_24BITS(p
) == 0xfefe03 || /* NLPID encaps ? */
981 EXTRACT_24BITS(p
) == 0xaaaa03) { /* SNAP encaps ? */
983 if (llc_print(p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
,
984 &extracted_ethertype
) != 0)
985 return l2info
.header_len
;
988 if (l2info
.direction
!= JUNIPER_BPF_PKT_IN
&& /* ether-over-1483 encaps ? */
989 (EXTRACT_32BITS(l2info
.cookie
) & ATM2_GAP_COUNT_MASK
)) {
990 ether_print(gndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
991 return l2info
.header_len
;
994 if (p
[0] == 0x03) { /* Cisco style NLPID encaps ? */
995 isoclns_print(p
+ 1, l2info
.length
- 1, l2info
.caplen
- 1);
996 /* FIXME check if frame was recognized */
997 return l2info
.header_len
;
1000 if(juniper_ppp_heuristic_guess(p
, l2info
.length
) != 0) /* PPPoA vcmux encaps ? */
1001 return l2info
.header_len
;
1003 if(ip_heuristic_guess(p
, l2info
.length
) != 0) /* last try - vcmux encaps ? */
1004 return l2info
.header_len
;
1006 return l2info
.header_len
;
1011 /* try to guess, based on all PPP protos that are supported in
1012 * a juniper router if the payload data is encapsulated using PPP */
1014 juniper_ppp_heuristic_guess(register const u_char
*p
, u_int length
) {
1016 switch(EXTRACT_16BITS(p
)) {
1019 case PPP_MPLS_UCAST
:
1020 case PPP_MPLS_MCAST
:
1032 ppp_print(p
, length
);
1036 return 0; /* did not find a ppp header */
1039 return 1; /* we printed a ppp packet */
1043 ip_heuristic_guess(register const u_char
*p
, u_int length
) {
1057 ip_print(gndo
, p
, length
);
1076 ip6_print(gndo
, p
, length
);
1080 return 0; /* did not find a ip header */
1083 return 1; /* we printed an v4/v6 packet */
1087 juniper_read_tlv_value(const u_char
*p
, u_int tlv_type
, u_int tlv_len
) {
1091 /* TLVs < 128 are little endian encoded */
1092 if (tlv_type
< 128) {
1098 tlv_value
= EXTRACT_LE_16BITS(p
);
1101 tlv_value
= EXTRACT_LE_24BITS(p
);
1104 tlv_value
= EXTRACT_LE_32BITS(p
);
1111 /* TLVs >= 128 are big endian encoded */
1117 tlv_value
= EXTRACT_16BITS(p
);
1120 tlv_value
= EXTRACT_24BITS(p
);
1123 tlv_value
= EXTRACT_32BITS(p
);
1134 juniper_parse_header (const u_char
*p
, const struct pcap_pkthdr
*h
, struct juniper_l2info_t
*l2info
) {
1136 const struct juniper_cookie_table_t
*lp
= juniper_cookie_table
;
1137 u_int idx
, jnx_ext_len
, jnx_header_len
= 0;
1138 u_int8_t tlv_type
,tlv_len
;
1139 u_int32_t control_word
;
1144 l2info
->header_len
= 0;
1145 l2info
->cookie_len
= 0;
1149 l2info
->length
= h
->len
;
1150 l2info
->caplen
= h
->caplen
;
1152 l2info
->flags
= p
[3];
1153 l2info
->direction
= p
[3]&JUNIPER_BPF_PKT_IN
;
1155 if (EXTRACT_24BITS(p
) != JUNIPER_MGC_NUMBER
) { /* magic number found ? */
1156 printf("no magic-number found!");
1160 if (eflag
) /* print direction */
1161 printf("%3s ",tok2str(juniper_direction_values
,"---",l2info
->direction
));
1163 /* magic number + flags */
1167 printf("\n\tJuniper PCAP Flags [%s]",
1168 bittok2str(jnx_flag_values
, "none", l2info
->flags
));
1170 /* extensions present ? - calculate how much bytes to skip */
1171 if ((l2info
->flags
& JUNIPER_BPF_EXT
) == JUNIPER_BPF_EXT
) {
1173 tptr
= p
+jnx_header_len
;
1175 /* ok to read extension length ? */
1176 TCHECK2(tptr
[0], 2);
1177 jnx_ext_len
= EXTRACT_16BITS(tptr
);
1178 jnx_header_len
+= 2;
1181 /* nail up the total length -
1182 * just in case something goes wrong
1183 * with TLV parsing */
1184 jnx_header_len
+= jnx_ext_len
;
1187 printf(", PCAP Extension(s) total length %u",
1190 TCHECK2(tptr
[0], jnx_ext_len
);
1191 while (jnx_ext_len
> JUNIPER_EXT_TLV_OVERHEAD
) {
1192 tlv_type
= *(tptr
++);
1193 tlv_len
= *(tptr
++);
1197 if (tlv_type
== 0 || tlv_len
== 0)
1201 printf("\n\t %s Extension TLV #%u, length %u, value ",
1202 tok2str(jnx_ext_tlv_values
,"Unknown",tlv_type
),
1206 tlv_value
= juniper_read_tlv_value(tptr
, tlv_type
, tlv_len
);
1208 case JUNIPER_EXT_TLV_IFD_NAME
:
1211 case JUNIPER_EXT_TLV_IFD_MEDIATYPE
:
1212 case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE
:
1213 if (tlv_value
!= -1) {
1216 tok2str(juniper_ifmt_values
, "Unknown", tlv_value
),
1220 case JUNIPER_EXT_TLV_IFL_ENCAPS
:
1221 case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS
:
1222 if (tlv_value
!= -1) {
1225 tok2str(juniper_ifle_values
, "Unknown", tlv_value
),
1229 case JUNIPER_EXT_TLV_IFL_IDX
: /* fall through */
1230 case JUNIPER_EXT_TLV_IFL_UNIT
:
1231 case JUNIPER_EXT_TLV_IFD_IDX
:
1233 if (tlv_value
!= -1) {
1235 printf("%u",tlv_value
);
1241 jnx_ext_len
-= tlv_len
+JUNIPER_EXT_TLV_OVERHEAD
;
1245 printf("\n\t-----original packet-----\n\t");
1248 if ((l2info
->flags
& JUNIPER_BPF_NO_L2
) == JUNIPER_BPF_NO_L2
) {
1250 printf("no-L2-hdr, ");
1252 /* there is no link-layer present -
1253 * perform the v4/v6 heuristics
1254 * to figure out what it is
1256 TCHECK2(p
[jnx_header_len
+4],1);
1257 if(ip_heuristic_guess(p
+jnx_header_len
+4,l2info
->length
-(jnx_header_len
+4)) == 0)
1258 printf("no IP-hdr found!");
1260 l2info
->header_len
=jnx_header_len
+4;
1261 return 0; /* stop parsing the output further */
1264 l2info
->header_len
= jnx_header_len
;
1265 p
+=l2info
->header_len
;
1266 l2info
->length
-= l2info
->header_len
;
1267 l2info
->caplen
-= l2info
->header_len
;
1269 /* search through the cookie table and copy values matching for our PIC type */
1270 while (lp
->s
!= NULL
) {
1271 if (lp
->pictype
== l2info
->pictype
) {
1273 l2info
->cookie_len
+= lp
->cookie_len
;
1277 l2info
->cookie_type
= LS_COOKIE_ID
;
1278 l2info
->cookie_len
+= 2;
1281 l2info
->cookie_type
= AS_COOKIE_ID
;
1282 l2info
->cookie_len
= 8;
1286 l2info
->bundle
= l2info
->cookie
[0];
1291 #ifdef DLT_JUNIPER_MFR
1292 /* MFR child links don't carry cookies */
1293 if (l2info
->pictype
== DLT_JUNIPER_MFR
&&
1294 (p
[0] & MFR_BE_MASK
) == MFR_BE_MASK
) {
1295 l2info
->cookie_len
= 0;
1299 l2info
->header_len
+= l2info
->cookie_len
;
1300 l2info
->length
-= l2info
->cookie_len
;
1301 l2info
->caplen
-= l2info
->cookie_len
;
1304 printf("%s-PIC, cookie-len %u",
1306 l2info
->cookie_len
);
1308 if (l2info
->cookie_len
> 0) {
1309 TCHECK2(p
[0],l2info
->cookie_len
);
1311 printf(", cookie 0x");
1312 for (idx
= 0; idx
< l2info
->cookie_len
; idx
++) {
1313 l2info
->cookie
[idx
] = p
[idx
]; /* copy cookie data */
1314 if (eflag
) printf("%02x",p
[idx
]);
1318 if (eflag
) printf(": "); /* print demarc b/w L2/L3*/
1321 l2info
->proto
= EXTRACT_16BITS(p
+l2info
->cookie_len
);
1326 p
+=l2info
->cookie_len
;
1328 /* DLT_ specific parsing */
1329 switch(l2info
->pictype
) {
1330 #ifdef DLT_JUNIPER_MLPPP
1331 case DLT_JUNIPER_MLPPP
:
1332 switch (l2info
->cookie_type
) {
1334 l2info
->bundle
= l2info
->cookie
[1];
1337 l2info
->bundle
= (EXTRACT_16BITS(&l2info
->cookie
[6])>>3)&0xfff;
1338 l2info
->proto
= (l2info
->cookie
[5])&JUNIPER_LSQ_L3_PROTO_MASK
;
1341 l2info
->bundle
= l2info
->cookie
[0];
1346 #ifdef DLT_JUNIPER_MLFR
1347 case DLT_JUNIPER_MLFR
:
1348 switch (l2info
->cookie_type
) {
1350 l2info
->bundle
= l2info
->cookie
[1];
1351 l2info
->proto
= EXTRACT_16BITS(p
);
1352 l2info
->header_len
+= 2;
1353 l2info
->length
-= 2;
1354 l2info
->caplen
-= 2;
1357 l2info
->bundle
= (EXTRACT_16BITS(&l2info
->cookie
[6])>>3)&0xfff;
1358 l2info
->proto
= (l2info
->cookie
[5])&JUNIPER_LSQ_L3_PROTO_MASK
;
1361 l2info
->bundle
= l2info
->cookie
[0];
1362 l2info
->header_len
+= 2;
1363 l2info
->length
-= 2;
1364 l2info
->caplen
-= 2;
1369 #ifdef DLT_JUNIPER_MFR
1370 case DLT_JUNIPER_MFR
:
1371 switch (l2info
->cookie_type
) {
1373 l2info
->bundle
= l2info
->cookie
[1];
1374 l2info
->proto
= EXTRACT_16BITS(p
);
1375 l2info
->header_len
+= 2;
1376 l2info
->length
-= 2;
1377 l2info
->caplen
-= 2;
1380 l2info
->bundle
= (EXTRACT_16BITS(&l2info
->cookie
[6])>>3)&0xfff;
1381 l2info
->proto
= (l2info
->cookie
[5])&JUNIPER_LSQ_L3_PROTO_MASK
;
1384 l2info
->bundle
= l2info
->cookie
[0];
1389 #ifdef DLT_JUNIPER_ATM2
1390 case DLT_JUNIPER_ATM2
:
1392 /* ATM cell relay control word present ? */
1393 if (l2info
->cookie
[7] & ATM2_PKT_TYPE_MASK
) {
1394 control_word
= EXTRACT_32BITS(p
);
1395 /* some control word heuristics */
1396 switch(control_word
) {
1397 case 0: /* zero control word */
1398 case 0x08000000: /* < JUNOS 7.4 control-word */
1399 case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/
1400 l2info
->header_len
+= 4;
1407 printf("control-word 0x%08x ", control_word
);
1411 #ifdef DLT_JUNIPER_GGSN
1412 case DLT_JUNIPER_GGSN
:
1415 #ifdef DLT_JUNIPER_ATM1
1416 case DLT_JUNIPER_ATM1
:
1419 #ifdef DLT_JUNIPER_PPP
1420 case DLT_JUNIPER_PPP
:
1423 #ifdef DLT_JUNIPER_CHDLC
1424 case DLT_JUNIPER_CHDLC
:
1427 #ifdef DLT_JUNIPER_ETHER
1428 case DLT_JUNIPER_ETHER
:
1431 #ifdef DLT_JUNIPER_FRELAY
1432 case DLT_JUNIPER_FRELAY
:
1437 printf("Unknown Juniper DLT_ type %u: ", l2info
->pictype
);
1442 printf("hlen %u, proto 0x%04x, ",l2info
->header_len
,l2info
->proto
);
1444 return 1; /* everything went ok so far. continue parsing */
1446 printf("[|juniper_hdr], length %u",h
->len
);
1453 * c-style: whitesmith