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@gredler.at)
18 /* \summary: DLT_JUNIPER_* printers */
22 __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
29 #include "netdissect-stdinc.h"
33 #include "netdissect.h"
34 #include "addrtoname.h"
39 #include "ethertype.h"
43 * If none of the Juniper DLT_s are defined, there's nothing to do.
45 #if defined(DLT_JUNIPER_GGSN) || defined(DLT_JUNIPER_ES) || \
46 defined(DLT_JUNIPER_MONITOR) || defined(DLT_JUNIPER_SERVICES) || \
47 defined(DLT_JUNIPER_PPPOE) || defined(DLT_JUNIPER_ETHER) || \
48 defined(DLT_JUNIPER_PPP) || defined(DLT_JUNIPER_FRELAY) || \
49 defined(DLT_JUNIPER_CHDLC) || defined(DLT_JUNIPER_PPPOE_ATM) || \
50 defined(DLT_JUNIPER_MLPPP) || defined(DLT_JUNIPER_MFR) || \
51 defined(DLT_JUNIPER_MLFR) || defined(DLT_JUNIPER_ATM1) || \
52 defined(DLT_JUNIPER_ATM2)
53 #define JUNIPER_BPF_OUT 0 /* Outgoing packet */
54 #define JUNIPER_BPF_IN 1 /* Incoming packet */
55 #define JUNIPER_BPF_PKT_IN 0x1 /* Incoming packet */
56 #define JUNIPER_BPF_NO_L2 0x2 /* L2 header stripped */
57 #define JUNIPER_BPF_IIF 0x4 /* IIF is valid */
58 #define JUNIPER_BPF_FILTER 0x40 /* BPF filtering is supported */
59 #define JUNIPER_BPF_EXT 0x80 /* extensions present */
60 #define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */
62 #define JUNIPER_LSQ_COOKIE_RE (1 << 3)
63 #define JUNIPER_LSQ_COOKIE_DIR (1 << 2)
64 #define JUNIPER_LSQ_L3_PROTO_SHIFT 4
65 #define JUNIPER_LSQ_L3_PROTO_MASK (0x17 << JUNIPER_LSQ_L3_PROTO_SHIFT)
66 #define JUNIPER_LSQ_L3_PROTO_IPV4 (0 << JUNIPER_LSQ_L3_PROTO_SHIFT)
67 #define JUNIPER_LSQ_L3_PROTO_IPV6 (1 << JUNIPER_LSQ_L3_PROTO_SHIFT)
68 #define JUNIPER_LSQ_L3_PROTO_MPLS (2 << JUNIPER_LSQ_L3_PROTO_SHIFT)
69 #define JUNIPER_LSQ_L3_PROTO_ISO (3 << JUNIPER_LSQ_L3_PROTO_SHIFT)
70 #define AS_PIC_COOKIE_LEN 8
72 #define JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE 1
73 #define JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE 2
74 #define JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE 3
75 #define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4
76 #define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5
79 static const struct tok juniper_ipsec_type_values
[] = {
80 { JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE
, "ESP ENCR-AUTH" },
81 { JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE
, "ESP ENCR-AH AUTH" },
82 { JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE
, "ESP AUTH" },
83 { JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE
, "AH AUTH" },
84 { JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE
, "ESP ENCR" },
89 static const struct tok juniper_direction_values
[] = {
90 { JUNIPER_BPF_IN
, "In"},
91 { JUNIPER_BPF_OUT
, "Out"},
95 /* codepoints for encoding extensions to a .pcap file */
97 JUNIPER_EXT_TLV_IFD_IDX
= 1,
98 JUNIPER_EXT_TLV_IFD_NAME
= 2,
99 JUNIPER_EXT_TLV_IFD_MEDIATYPE
= 3,
100 JUNIPER_EXT_TLV_IFL_IDX
= 4,
101 JUNIPER_EXT_TLV_IFL_UNIT
= 5,
102 JUNIPER_EXT_TLV_IFL_ENCAPS
= 6,
103 JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE
= 7,
104 JUNIPER_EXT_TLV_TTP_IFL_ENCAPS
= 8
107 /* 1 byte type and 1-byte length */
108 #define JUNIPER_EXT_TLV_OVERHEAD 2U
110 static const struct tok jnx_ext_tlv_values
[] = {
111 { JUNIPER_EXT_TLV_IFD_IDX
, "Device Interface Index" },
112 { JUNIPER_EXT_TLV_IFD_NAME
,"Device Interface Name" },
113 { JUNIPER_EXT_TLV_IFD_MEDIATYPE
, "Device Media Type" },
114 { JUNIPER_EXT_TLV_IFL_IDX
, "Logical Interface Index" },
115 { JUNIPER_EXT_TLV_IFL_UNIT
,"Logical Unit Number" },
116 { JUNIPER_EXT_TLV_IFL_ENCAPS
, "Logical Interface Encapsulation" },
117 { JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE
, "TTP derived Device Media Type" },
118 { JUNIPER_EXT_TLV_TTP_IFL_ENCAPS
, "TTP derived Logical Interface Encapsulation" },
122 static const struct tok jnx_flag_values
[] = {
123 { JUNIPER_BPF_EXT
, "Ext" },
124 { JUNIPER_BPF_FILTER
, "Filter" },
125 { JUNIPER_BPF_IIF
, "IIF" },
126 { JUNIPER_BPF_NO_L2
, "no-L2" },
127 { JUNIPER_BPF_PKT_IN
, "In" },
131 #define JUNIPER_IFML_ETHER 1
132 #define JUNIPER_IFML_FDDI 2
133 #define JUNIPER_IFML_TOKENRING 3
134 #define JUNIPER_IFML_PPP 4
135 #define JUNIPER_IFML_FRAMERELAY 5
136 #define JUNIPER_IFML_CISCOHDLC 6
137 #define JUNIPER_IFML_SMDSDXI 7
138 #define JUNIPER_IFML_ATMPVC 8
139 #define JUNIPER_IFML_PPP_CCC 9
140 #define JUNIPER_IFML_FRAMERELAY_CCC 10
141 #define JUNIPER_IFML_IPIP 11
142 #define JUNIPER_IFML_GRE 12
143 #define JUNIPER_IFML_PIM 13
144 #define JUNIPER_IFML_PIMD 14
145 #define JUNIPER_IFML_CISCOHDLC_CCC 15
146 #define JUNIPER_IFML_VLAN_CCC 16
147 #define JUNIPER_IFML_MLPPP 17
148 #define JUNIPER_IFML_MLFR 18
149 #define JUNIPER_IFML_ML 19
150 #define JUNIPER_IFML_LSI 20
151 #define JUNIPER_IFML_DFE 21
152 #define JUNIPER_IFML_ATM_CELLRELAY_CCC 22
153 #define JUNIPER_IFML_CRYPTO 23
154 #define JUNIPER_IFML_GGSN 24
155 #define JUNIPER_IFML_LSI_PPP 25
156 #define JUNIPER_IFML_LSI_CISCOHDLC 26
157 #define JUNIPER_IFML_PPP_TCC 27
158 #define JUNIPER_IFML_FRAMERELAY_TCC 28
159 #define JUNIPER_IFML_CISCOHDLC_TCC 29
160 #define JUNIPER_IFML_ETHERNET_CCC 30
161 #define JUNIPER_IFML_VT 31
162 #define JUNIPER_IFML_EXTENDED_VLAN_CCC 32
163 #define JUNIPER_IFML_ETHER_OVER_ATM 33
164 #define JUNIPER_IFML_MONITOR 34
165 #define JUNIPER_IFML_ETHERNET_TCC 35
166 #define JUNIPER_IFML_VLAN_TCC 36
167 #define JUNIPER_IFML_EXTENDED_VLAN_TCC 37
168 #define JUNIPER_IFML_CONTROLLER 38
169 #define JUNIPER_IFML_MFR 39
170 #define JUNIPER_IFML_LS 40
171 #define JUNIPER_IFML_ETHERNET_VPLS 41
172 #define JUNIPER_IFML_ETHERNET_VLAN_VPLS 42
173 #define JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS 43
174 #define JUNIPER_IFML_LT 44
175 #define JUNIPER_IFML_SERVICES 45
176 #define JUNIPER_IFML_ETHER_VPLS_OVER_ATM 46
177 #define JUNIPER_IFML_FR_PORT_CCC 47
178 #define JUNIPER_IFML_FRAMERELAY_EXT_CCC 48
179 #define JUNIPER_IFML_FRAMERELAY_EXT_TCC 49
180 #define JUNIPER_IFML_FRAMERELAY_FLEX 50
181 #define JUNIPER_IFML_GGSNI 51
182 #define JUNIPER_IFML_ETHERNET_FLEX 52
183 #define JUNIPER_IFML_COLLECTOR 53
184 #define JUNIPER_IFML_AGGREGATOR 54
185 #define JUNIPER_IFML_LAPD 55
186 #define JUNIPER_IFML_PPPOE 56
187 #define JUNIPER_IFML_PPP_SUBORDINATE 57
188 #define JUNIPER_IFML_CISCOHDLC_SUBORDINATE 58
189 #define JUNIPER_IFML_DFC 59
190 #define JUNIPER_IFML_PICPEER 60
192 static const struct tok juniper_ifmt_values
[] = {
193 { JUNIPER_IFML_ETHER
, "Ethernet" },
194 { JUNIPER_IFML_FDDI
, "FDDI" },
195 { JUNIPER_IFML_TOKENRING
, "Token-Ring" },
196 { JUNIPER_IFML_PPP
, "PPP" },
197 { JUNIPER_IFML_PPP_SUBORDINATE
, "PPP-Subordinate" },
198 { JUNIPER_IFML_FRAMERELAY
, "Frame-Relay" },
199 { JUNIPER_IFML_CISCOHDLC
, "Cisco-HDLC" },
200 { JUNIPER_IFML_SMDSDXI
, "SMDS-DXI" },
201 { JUNIPER_IFML_ATMPVC
, "ATM-PVC" },
202 { JUNIPER_IFML_PPP_CCC
, "PPP-CCC" },
203 { JUNIPER_IFML_FRAMERELAY_CCC
, "Frame-Relay-CCC" },
204 { JUNIPER_IFML_FRAMERELAY_EXT_CCC
, "Extended FR-CCC" },
205 { JUNIPER_IFML_IPIP
, "IP-over-IP" },
206 { JUNIPER_IFML_GRE
, "GRE" },
207 { JUNIPER_IFML_PIM
, "PIM-Encapsulator" },
208 { JUNIPER_IFML_PIMD
, "PIM-Decapsulator" },
209 { JUNIPER_IFML_CISCOHDLC_CCC
, "Cisco-HDLC-CCC" },
210 { JUNIPER_IFML_VLAN_CCC
, "VLAN-CCC" },
211 { JUNIPER_IFML_EXTENDED_VLAN_CCC
, "Extended-VLAN-CCC" },
212 { JUNIPER_IFML_MLPPP
, "Multilink-PPP" },
213 { JUNIPER_IFML_MLFR
, "Multilink-FR" },
214 { JUNIPER_IFML_MFR
, "Multilink-FR-UNI-NNI" },
215 { JUNIPER_IFML_ML
, "Multilink" },
216 { JUNIPER_IFML_LS
, "LinkService" },
217 { JUNIPER_IFML_LSI
, "LSI" },
218 { JUNIPER_IFML_ATM_CELLRELAY_CCC
, "ATM-CCC-Cell-Relay" },
219 { JUNIPER_IFML_CRYPTO
, "IPSEC-over-IP" },
220 { JUNIPER_IFML_GGSN
, "GGSN" },
221 { JUNIPER_IFML_PPP_TCC
, "PPP-TCC" },
222 { JUNIPER_IFML_FRAMERELAY_TCC
, "Frame-Relay-TCC" },
223 { JUNIPER_IFML_FRAMERELAY_EXT_TCC
, "Extended FR-TCC" },
224 { JUNIPER_IFML_CISCOHDLC_TCC
, "Cisco-HDLC-TCC" },
225 { JUNIPER_IFML_ETHERNET_CCC
, "Ethernet-CCC" },
226 { JUNIPER_IFML_VT
, "VPN-Loopback-tunnel" },
227 { JUNIPER_IFML_ETHER_OVER_ATM
, "Ethernet-over-ATM" },
228 { JUNIPER_IFML_ETHER_VPLS_OVER_ATM
, "Ethernet-VPLS-over-ATM" },
229 { JUNIPER_IFML_MONITOR
, "Monitor" },
230 { JUNIPER_IFML_ETHERNET_TCC
, "Ethernet-TCC" },
231 { JUNIPER_IFML_VLAN_TCC
, "VLAN-TCC" },
232 { JUNIPER_IFML_EXTENDED_VLAN_TCC
, "Extended-VLAN-TCC" },
233 { JUNIPER_IFML_CONTROLLER
, "Controller" },
234 { JUNIPER_IFML_ETHERNET_VPLS
, "VPLS" },
235 { JUNIPER_IFML_ETHERNET_VLAN_VPLS
, "VLAN-VPLS" },
236 { JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS
, "Extended-VLAN-VPLS" },
237 { JUNIPER_IFML_LT
, "Logical-tunnel" },
238 { JUNIPER_IFML_SERVICES
, "General-Services" },
239 { JUNIPER_IFML_PPPOE
, "PPPoE" },
240 { JUNIPER_IFML_ETHERNET_FLEX
, "Flexible-Ethernet-Services" },
241 { JUNIPER_IFML_FRAMERELAY_FLEX
, "Flexible-FrameRelay" },
242 { JUNIPER_IFML_COLLECTOR
, "Flow-collection" },
243 { JUNIPER_IFML_PICPEER
, "PIC Peer" },
244 { JUNIPER_IFML_DFC
, "Dynamic-Flow-Capture" },
248 #define JUNIPER_IFLE_ATM_SNAP 2
249 #define JUNIPER_IFLE_ATM_NLPID 3
250 #define JUNIPER_IFLE_ATM_VCMUX 4
251 #define JUNIPER_IFLE_ATM_LLC 5
252 #define JUNIPER_IFLE_ATM_PPP_VCMUX 6
253 #define JUNIPER_IFLE_ATM_PPP_LLC 7
254 #define JUNIPER_IFLE_ATM_PPP_FUNI 8
255 #define JUNIPER_IFLE_ATM_CCC 9
256 #define JUNIPER_IFLE_FR_NLPID 10
257 #define JUNIPER_IFLE_FR_SNAP 11
258 #define JUNIPER_IFLE_FR_PPP 12
259 #define JUNIPER_IFLE_FR_CCC 13
260 #define JUNIPER_IFLE_ENET2 14
261 #define JUNIPER_IFLE_IEEE8023_SNAP 15
262 #define JUNIPER_IFLE_IEEE8023_LLC 16
263 #define JUNIPER_IFLE_PPP 17
264 #define JUNIPER_IFLE_CISCOHDLC 18
265 #define JUNIPER_IFLE_PPP_CCC 19
266 #define JUNIPER_IFLE_IPIP_NULL 20
267 #define JUNIPER_IFLE_PIM_NULL 21
268 #define JUNIPER_IFLE_GRE_NULL 22
269 #define JUNIPER_IFLE_GRE_PPP 23
270 #define JUNIPER_IFLE_PIMD_DECAPS 24
271 #define JUNIPER_IFLE_CISCOHDLC_CCC 25
272 #define JUNIPER_IFLE_ATM_CISCO_NLPID 26
273 #define JUNIPER_IFLE_VLAN_CCC 27
274 #define JUNIPER_IFLE_MLPPP 28
275 #define JUNIPER_IFLE_MLFR 29
276 #define JUNIPER_IFLE_LSI_NULL 30
277 #define JUNIPER_IFLE_AGGREGATE_UNUSED 31
278 #define JUNIPER_IFLE_ATM_CELLRELAY_CCC 32
279 #define JUNIPER_IFLE_CRYPTO 33
280 #define JUNIPER_IFLE_GGSN 34
281 #define JUNIPER_IFLE_ATM_TCC 35
282 #define JUNIPER_IFLE_FR_TCC 36
283 #define JUNIPER_IFLE_PPP_TCC 37
284 #define JUNIPER_IFLE_CISCOHDLC_TCC 38
285 #define JUNIPER_IFLE_ETHERNET_CCC 39
286 #define JUNIPER_IFLE_VT 40
287 #define JUNIPER_IFLE_ATM_EOA_LLC 41
288 #define JUNIPER_IFLE_EXTENDED_VLAN_CCC 42
289 #define JUNIPER_IFLE_ATM_SNAP_TCC 43
290 #define JUNIPER_IFLE_MONITOR 44
291 #define JUNIPER_IFLE_ETHERNET_TCC 45
292 #define JUNIPER_IFLE_VLAN_TCC 46
293 #define JUNIPER_IFLE_EXTENDED_VLAN_TCC 47
294 #define JUNIPER_IFLE_MFR 48
295 #define JUNIPER_IFLE_ETHERNET_VPLS 49
296 #define JUNIPER_IFLE_ETHERNET_VLAN_VPLS 50
297 #define JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS 51
298 #define JUNIPER_IFLE_SERVICES 52
299 #define JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC 53
300 #define JUNIPER_IFLE_FR_PORT_CCC 54
301 #define JUNIPER_IFLE_ATM_MLPPP_LLC 55
302 #define JUNIPER_IFLE_ATM_EOA_CCC 56
303 #define JUNIPER_IFLE_LT_VLAN 57
304 #define JUNIPER_IFLE_COLLECTOR 58
305 #define JUNIPER_IFLE_AGGREGATOR 59
306 #define JUNIPER_IFLE_LAPD 60
307 #define JUNIPER_IFLE_ATM_PPPOE_LLC 61
308 #define JUNIPER_IFLE_ETHERNET_PPPOE 62
309 #define JUNIPER_IFLE_PPPOE 63
310 #define JUNIPER_IFLE_PPP_SUBORDINATE 64
311 #define JUNIPER_IFLE_CISCOHDLC_SUBORDINATE 65
312 #define JUNIPER_IFLE_DFC 66
313 #define JUNIPER_IFLE_PICPEER 67
315 static const struct tok juniper_ifle_values
[] = {
316 { JUNIPER_IFLE_AGGREGATOR
, "Aggregator" },
317 { JUNIPER_IFLE_ATM_CCC
, "CCC over ATM" },
318 { JUNIPER_IFLE_ATM_CELLRELAY_CCC
, "ATM CCC Cell Relay" },
319 { JUNIPER_IFLE_ATM_CISCO_NLPID
, "CISCO compatible NLPID" },
320 { JUNIPER_IFLE_ATM_EOA_CCC
, "Ethernet over ATM CCC" },
321 { JUNIPER_IFLE_ATM_EOA_LLC
, "Ethernet over ATM LLC" },
322 { JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC
, "Ethernet VPLS over ATM LLC" },
323 { JUNIPER_IFLE_ATM_LLC
, "ATM LLC" },
324 { JUNIPER_IFLE_ATM_MLPPP_LLC
, "MLPPP over ATM LLC" },
325 { JUNIPER_IFLE_ATM_NLPID
, "ATM NLPID" },
326 { JUNIPER_IFLE_ATM_PPPOE_LLC
, "PPPoE over ATM LLC" },
327 { JUNIPER_IFLE_ATM_PPP_FUNI
, "PPP over FUNI" },
328 { JUNIPER_IFLE_ATM_PPP_LLC
, "PPP over ATM LLC" },
329 { JUNIPER_IFLE_ATM_PPP_VCMUX
, "PPP over ATM VCMUX" },
330 { JUNIPER_IFLE_ATM_SNAP
, "ATM SNAP" },
331 { JUNIPER_IFLE_ATM_SNAP_TCC
, "ATM SNAP TCC" },
332 { JUNIPER_IFLE_ATM_TCC
, "ATM VCMUX TCC" },
333 { JUNIPER_IFLE_ATM_VCMUX
, "ATM VCMUX" },
334 { JUNIPER_IFLE_CISCOHDLC
, "C-HDLC" },
335 { JUNIPER_IFLE_CISCOHDLC_CCC
, "C-HDLC CCC" },
336 { JUNIPER_IFLE_CISCOHDLC_SUBORDINATE
, "C-HDLC via dialer" },
337 { JUNIPER_IFLE_CISCOHDLC_TCC
, "C-HDLC TCC" },
338 { JUNIPER_IFLE_COLLECTOR
, "Collector" },
339 { JUNIPER_IFLE_CRYPTO
, "Crypto" },
340 { JUNIPER_IFLE_ENET2
, "Ethernet" },
341 { JUNIPER_IFLE_ETHERNET_CCC
, "Ethernet CCC" },
342 { JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS
, "Extended VLAN VPLS" },
343 { JUNIPER_IFLE_ETHERNET_PPPOE
, "PPPoE over Ethernet" },
344 { JUNIPER_IFLE_ETHERNET_TCC
, "Ethernet TCC" },
345 { JUNIPER_IFLE_ETHERNET_VLAN_VPLS
, "VLAN VPLS" },
346 { JUNIPER_IFLE_ETHERNET_VPLS
, "VPLS" },
347 { JUNIPER_IFLE_EXTENDED_VLAN_CCC
, "Extended VLAN CCC" },
348 { JUNIPER_IFLE_EXTENDED_VLAN_TCC
, "Extended VLAN TCC" },
349 { JUNIPER_IFLE_FR_CCC
, "FR CCC" },
350 { JUNIPER_IFLE_FR_NLPID
, "FR NLPID" },
351 { JUNIPER_IFLE_FR_PORT_CCC
, "FR CCC" },
352 { JUNIPER_IFLE_FR_PPP
, "FR PPP" },
353 { JUNIPER_IFLE_FR_SNAP
, "FR SNAP" },
354 { JUNIPER_IFLE_FR_TCC
, "FR TCC" },
355 { JUNIPER_IFLE_GGSN
, "GGSN" },
356 { JUNIPER_IFLE_GRE_NULL
, "GRE NULL" },
357 { JUNIPER_IFLE_GRE_PPP
, "PPP over GRE" },
358 { JUNIPER_IFLE_IPIP_NULL
, "IPIP" },
359 { JUNIPER_IFLE_LAPD
, "LAPD" },
360 { JUNIPER_IFLE_LSI_NULL
, "LSI Null" },
361 { JUNIPER_IFLE_LT_VLAN
, "LT VLAN" },
362 { JUNIPER_IFLE_MFR
, "MFR" },
363 { JUNIPER_IFLE_MLFR
, "MLFR" },
364 { JUNIPER_IFLE_MLPPP
, "MLPPP" },
365 { JUNIPER_IFLE_MONITOR
, "Monitor" },
366 { JUNIPER_IFLE_PIMD_DECAPS
, "PIMd" },
367 { JUNIPER_IFLE_PIM_NULL
, "PIM Null" },
368 { JUNIPER_IFLE_PPP
, "PPP" },
369 { JUNIPER_IFLE_PPPOE
, "PPPoE" },
370 { JUNIPER_IFLE_PPP_CCC
, "PPP CCC" },
371 { JUNIPER_IFLE_PPP_SUBORDINATE
, "" },
372 { JUNIPER_IFLE_PPP_TCC
, "PPP TCC" },
373 { JUNIPER_IFLE_SERVICES
, "General Services" },
374 { JUNIPER_IFLE_VLAN_CCC
, "VLAN CCC" },
375 { JUNIPER_IFLE_VLAN_TCC
, "VLAN TCC" },
376 { JUNIPER_IFLE_VT
, "VT" },
380 struct juniper_cookie_table_t
{
381 uint32_t pictype
; /* pic type */
382 uint8_t cookie_len
; /* cookie len */
383 const char *s
; /* pic name */
386 static const struct juniper_cookie_table_t juniper_cookie_table
[] = {
387 #ifdef DLT_JUNIPER_ATM1
388 { DLT_JUNIPER_ATM1
, 4, "ATM1"},
390 #ifdef DLT_JUNIPER_ATM2
391 { DLT_JUNIPER_ATM2
, 8, "ATM2"},
393 #ifdef DLT_JUNIPER_MLPPP
394 { DLT_JUNIPER_MLPPP
, 2, "MLPPP"},
396 #ifdef DLT_JUNIPER_MLFR
397 { DLT_JUNIPER_MLFR
, 2, "MLFR"},
399 #ifdef DLT_JUNIPER_MFR
400 { DLT_JUNIPER_MFR
, 4, "MFR"},
402 #ifdef DLT_JUNIPER_PPPOE
403 { DLT_JUNIPER_PPPOE
, 0, "PPPoE"},
405 #ifdef DLT_JUNIPER_PPPOE_ATM
406 { DLT_JUNIPER_PPPOE_ATM
, 0, "PPPoE ATM"},
408 #ifdef DLT_JUNIPER_GGSN
409 { DLT_JUNIPER_GGSN
, 8, "GGSN"},
411 #ifdef DLT_JUNIPER_MONITOR
412 { DLT_JUNIPER_MONITOR
, 8, "MONITOR"},
414 #ifdef DLT_JUNIPER_SERVICES
415 { DLT_JUNIPER_SERVICES
, 8, "AS"},
417 #ifdef DLT_JUNIPER_ES
418 { DLT_JUNIPER_ES
, 0, "ES"},
423 struct juniper_l2info_t
{
437 #define LS_COOKIE_ID 0x54
438 #define AS_COOKIE_ID 0x47
439 #define LS_MLFR_COOKIE_LEN 4
440 #define ML_MLFR_COOKIE_LEN 2
441 #define LS_MFR_COOKIE_LEN 6
442 #define ATM1_COOKIE_LEN 4
443 #define ATM2_COOKIE_LEN 8
445 #define ATM2_PKT_TYPE_MASK 0x70
446 #define ATM2_GAP_COUNT_MASK 0x3F
448 #define JUNIPER_PROTO_NULL 1
449 #define JUNIPER_PROTO_IPV4 2
450 #define JUNIPER_PROTO_IPV6 6
452 #define MFR_BE_MASK 0xc0
454 #ifdef DLT_JUNIPER_GGSN
455 static const struct tok juniper_protocol_values
[] = {
456 { JUNIPER_PROTO_NULL
, "Null" },
457 { JUNIPER_PROTO_IPV4
, "IPv4" },
458 { JUNIPER_PROTO_IPV6
, "IPv6" },
463 static int ip_heuristic_guess(netdissect_options
*, const u_char
*, u_int
);
464 #ifdef DLT_JUNIPER_ATM2
465 static int juniper_ppp_heuristic_guess(netdissect_options
*, const u_char
*, u_int
);
467 static int juniper_parse_header(netdissect_options
*, const u_char
*, const struct pcap_pkthdr
*, struct juniper_l2info_t
*);
469 #ifdef DLT_JUNIPER_GGSN
471 juniper_ggsn_if_print(netdissect_options
*ndo
,
472 const struct pcap_pkthdr
*h
, const u_char
*p
)
474 struct juniper_l2info_t l2info
;
475 struct juniper_ggsn_header
{
477 nd_uint8_t flags_len
;
483 const struct juniper_ggsn_header
*gh
;
486 ndo
->ndo_protocol
= "juniper_ggsn";
487 l2info
.pictype
= DLT_JUNIPER_GGSN
;
488 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
489 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
493 p
+=l2info
.header_len
;
494 gh
= (struct juniper_ggsn_header
*)&l2info
.cookie
;
497 proto
= GET_U_1(gh
->proto
);
498 if (ndo
->ndo_eflag
) {
499 ND_PRINT("proto %s (%u), vlan %u: ",
500 tok2str(juniper_protocol_values
,"Unknown",proto
),
502 GET_BE_U_2(gh
->vlan_id
));
506 case JUNIPER_PROTO_IPV4
:
507 ip_print(ndo
, p
, l2info
.length
);
509 case JUNIPER_PROTO_IPV6
:
510 ip6_print(ndo
, p
, l2info
.length
);
514 ND_PRINT("unknown GGSN proto (%u)", proto
);
517 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
522 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
526 #ifdef DLT_JUNIPER_ES
528 juniper_es_if_print(netdissect_options
*ndo
,
529 const struct pcap_pkthdr
*h
, const u_char
*p
)
531 struct juniper_l2info_t l2info
;
532 struct juniper_ipsec_header
{
533 nd_uint16_t sa_index
;
540 u_int rewrite_len
,es_type_bundle
;
541 const struct juniper_ipsec_header
*ih
;
543 ndo
->ndo_protocol
= "juniper_es";
544 l2info
.pictype
= DLT_JUNIPER_ES
;
545 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
546 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
550 p
+=l2info
.header_len
;
551 ih
= (const struct juniper_ipsec_header
*)p
;
554 switch (GET_U_1(ih
->type
)) {
555 case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE
:
556 case JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE
:
560 case JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE
:
561 case JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE
:
562 case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE
:
567 ND_PRINT("ES Invalid type %u, length %u",
570 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
574 l2info
.length
-=rewrite_len
;
577 if (ndo
->ndo_eflag
) {
578 if (!es_type_bundle
) {
579 ND_PRINT("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
580 GET_BE_U_2(ih
->sa_index
),
582 tok2str(juniper_ipsec_type_values
,"Unknown",GET_U_1(ih
->type
)),
585 GET_IPADDR_STRING(ih
->src_ip
),
586 GET_IPADDR_STRING(ih
->dst_ip
),
589 ND_PRINT("ES SA, index %u, ttl %u type %s (%u), length %u\n",
590 GET_BE_U_2(ih
->sa_index
),
592 tok2str(juniper_ipsec_type_values
,"Unknown",GET_U_1(ih
->type
)),
598 ip_print(ndo
, p
, l2info
.length
);
599 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
604 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
608 #ifdef DLT_JUNIPER_MONITOR
610 juniper_monitor_if_print(netdissect_options
*ndo
,
611 const struct pcap_pkthdr
*h
, const u_char
*p
)
613 struct juniper_l2info_t l2info
;
614 struct juniper_monitor_header
{
618 nd_uint32_t service_id
;
620 const struct juniper_monitor_header
*mh
;
622 ndo
->ndo_protocol
= "juniper_monitor";
623 l2info
.pictype
= DLT_JUNIPER_MONITOR
;
624 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
625 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
629 p
+=l2info
.header_len
;
630 mh
= (const struct juniper_monitor_header
*)p
;
634 ND_PRINT("service-id %u, iif %u, pkt-type %u: ",
635 GET_BE_U_4(mh
->service_id
),
637 GET_U_1(mh
->pkt_type
));
639 /* no proto field - lets guess by first byte of IP header*/
640 ip_heuristic_guess (ndo
, p
, l2info
.length
);
642 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
647 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
651 #ifdef DLT_JUNIPER_SERVICES
653 juniper_services_if_print(netdissect_options
*ndo
,
654 const struct pcap_pkthdr
*h
, const u_char
*p
)
656 struct juniper_l2info_t l2info
;
657 struct juniper_services_header
{
659 nd_uint8_t flags_len
;
660 nd_uint16_t svc_set_id
;
664 const struct juniper_services_header
*sh
;
666 ndo
->ndo_protocol
= "juniper_services";
667 l2info
.pictype
= DLT_JUNIPER_SERVICES
;
668 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
669 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
673 p
+=l2info
.header_len
;
674 sh
= (const struct juniper_services_header
*)p
;
678 ND_PRINT("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
680 GET_U_1(sh
->flags_len
),
681 GET_BE_U_2(sh
->svc_set_id
),
682 GET_BE_U_3(sh
->dir_iif
));
684 /* no proto field - lets guess by first byte of IP header*/
685 ip_heuristic_guess (ndo
, p
, l2info
.length
);
687 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
692 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
696 #ifdef DLT_JUNIPER_PPPOE
698 juniper_pppoe_if_print(netdissect_options
*ndo
,
699 const struct pcap_pkthdr
*h
, const u_char
*p
)
701 struct juniper_l2info_t l2info
;
703 ndo
->ndo_protocol
= "juniper_pppoe";
704 l2info
.pictype
= DLT_JUNIPER_PPPOE
;
705 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
706 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
710 p
+=l2info
.header_len
;
711 /* this DLT contains nothing but raw ethernet frames */
712 ether_print(ndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
713 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
717 #ifdef DLT_JUNIPER_ETHER
719 juniper_ether_if_print(netdissect_options
*ndo
,
720 const struct pcap_pkthdr
*h
, const u_char
*p
)
722 struct juniper_l2info_t l2info
;
724 ndo
->ndo_protocol
= "juniper_ether";
725 l2info
.pictype
= DLT_JUNIPER_ETHER
;
726 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
727 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
731 p
+=l2info
.header_len
;
732 /* this DLT contains nothing but raw Ethernet frames */
733 ndo
->ndo_ll_hdr_len
+=
735 ether_print(ndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
739 #ifdef DLT_JUNIPER_PPP
741 juniper_ppp_if_print(netdissect_options
*ndo
,
742 const struct pcap_pkthdr
*h
, const u_char
*p
)
744 struct juniper_l2info_t l2info
;
746 ndo
->ndo_protocol
= "juniper_ppp";
747 l2info
.pictype
= DLT_JUNIPER_PPP
;
748 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
749 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
753 p
+=l2info
.header_len
;
754 /* this DLT contains nothing but raw ppp frames */
755 ppp_print(ndo
, p
, l2info
.length
);
756 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
760 #ifdef DLT_JUNIPER_FRELAY
762 juniper_frelay_if_print(netdissect_options
*ndo
,
763 const struct pcap_pkthdr
*h
, const u_char
*p
)
765 struct juniper_l2info_t l2info
;
767 ndo
->ndo_protocol
= "juniper_frelay";
768 l2info
.pictype
= DLT_JUNIPER_FRELAY
;
769 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
770 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
774 p
+=l2info
.header_len
;
775 /* this DLT contains nothing but raw frame-relay frames */
776 fr_print(ndo
, p
, l2info
.length
);
777 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
781 #ifdef DLT_JUNIPER_CHDLC
783 juniper_chdlc_if_print(netdissect_options
*ndo
,
784 const struct pcap_pkthdr
*h
, const u_char
*p
)
786 struct juniper_l2info_t l2info
;
788 ndo
->ndo_protocol
= "juniper_chdlc";
789 l2info
.pictype
= DLT_JUNIPER_CHDLC
;
790 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
791 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
795 p
+=l2info
.header_len
;
796 /* this DLT contains nothing but raw c-hdlc frames */
797 chdlc_print(ndo
, p
, l2info
.length
);
798 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
802 #ifdef DLT_JUNIPER_PPPOE_ATM
804 juniper_pppoe_atm_if_print(netdissect_options
*ndo
,
805 const struct pcap_pkthdr
*h
, const u_char
*p
)
807 struct juniper_l2info_t l2info
;
808 uint16_t extracted_ethertype
;
810 ndo
->ndo_protocol
= "juniper_pppoe_atm";
811 l2info
.pictype
= DLT_JUNIPER_PPPOE_ATM
;
812 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
813 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
817 p
+=l2info
.header_len
;
819 extracted_ethertype
= GET_BE_U_2(p
);
820 /* this DLT contains nothing but raw PPPoE frames,
821 * prepended with a type field*/
822 if (ethertype_print(ndo
, extracted_ethertype
,
824 l2info
.length
-ETHERTYPE_LEN
,
825 l2info
.caplen
-ETHERTYPE_LEN
,
827 /* ether_type not known, probably it wasn't one */
828 ND_PRINT("unknown ethertype 0x%04x", extracted_ethertype
);
830 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
834 #ifdef DLT_JUNIPER_MLPPP
836 juniper_mlppp_if_print(netdissect_options
*ndo
,
837 const struct pcap_pkthdr
*h
, const u_char
*p
)
839 struct juniper_l2info_t l2info
;
841 ndo
->ndo_protocol
= "juniper_mlppp";
842 l2info
.pictype
= DLT_JUNIPER_MLPPP
;
843 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
844 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
848 /* suppress Bundle-ID if frame was captured on a child-link
849 * best indicator if the cookie looks like a proto */
850 if (ndo
->ndo_eflag
&&
851 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
852 EXTRACT_BE_U_2(&l2info
.cookie
) != PPP_OSI
&&
853 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
854 EXTRACT_BE_U_2(&l2info
.cookie
) != (PPP_ADDRESS
<< 8 | PPP_CONTROL
))
855 ND_PRINT("Bundle-ID %u: ", l2info
.bundle
);
857 p
+=l2info
.header_len
;
859 /* first try the LSQ protos */
860 switch(l2info
.proto
) {
861 case JUNIPER_LSQ_L3_PROTO_IPV4
:
862 /* IP traffic going to the RE would not have a cookie
863 * -> this must be incoming IS-IS over PPP
865 if (l2info
.cookie
[4] == (JUNIPER_LSQ_COOKIE_RE
|JUNIPER_LSQ_COOKIE_DIR
))
866 ppp_print(ndo
, p
, l2info
.length
);
868 ip_print(ndo
, p
, l2info
.length
);
869 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
871 case JUNIPER_LSQ_L3_PROTO_IPV6
:
872 ip6_print(ndo
, p
,l2info
.length
);
873 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
875 case JUNIPER_LSQ_L3_PROTO_MPLS
:
876 mpls_print(ndo
, p
, l2info
.length
);
877 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
879 case JUNIPER_LSQ_L3_PROTO_ISO
:
880 isoclns_print(ndo
, p
, l2info
.length
);
881 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
887 /* zero length cookie ? */
888 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
889 switch (EXTRACT_BE_U_2(&l2info
.cookie
)) {
891 ppp_print(ndo
, p
- 2, l2info
.length
+ 2);
893 case (PPP_ADDRESS
<< 8 | PPP_CONTROL
): /* fall through */
895 ppp_print(ndo
, p
, l2info
.length
);
899 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
904 #ifdef DLT_JUNIPER_MFR
906 juniper_mfr_if_print(netdissect_options
*ndo
,
907 const struct pcap_pkthdr
*h
, const u_char
*p
)
909 struct juniper_l2info_t l2info
;
911 ndo
->ndo_protocol
= "juniper_mfr";
912 memset(&l2info
, 0, sizeof(l2info
));
913 l2info
.pictype
= DLT_JUNIPER_MFR
;
914 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
915 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
919 p
+=l2info
.header_len
;
922 if (l2info
.cookie_len
== 0) {
923 mfr_print(ndo
, p
, l2info
.length
);
924 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
928 /* first try the LSQ protos */
929 if (l2info
.cookie_len
== AS_PIC_COOKIE_LEN
) {
930 switch(l2info
.proto
) {
931 case JUNIPER_LSQ_L3_PROTO_IPV4
:
932 ip_print(ndo
, p
, l2info
.length
);
933 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
935 case JUNIPER_LSQ_L3_PROTO_IPV6
:
936 ip6_print(ndo
, p
,l2info
.length
);
937 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
939 case JUNIPER_LSQ_L3_PROTO_MPLS
:
940 mpls_print(ndo
, p
, l2info
.length
);
941 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
943 case JUNIPER_LSQ_L3_PROTO_ISO
:
944 isoclns_print(ndo
, p
, l2info
.length
);
945 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
950 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
954 /* suppress Bundle-ID if frame was captured on a child-link */
955 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
956 if (ndo
->ndo_eflag
&& EXTRACT_BE_U_4(l2info
.cookie
) != 1)
957 ND_PRINT("Bundle-ID %u, ", l2info
.bundle
);
958 switch (l2info
.proto
) {
959 case (LLCSAP_ISONS
<<8 | LLCSAP_ISONS
):
960 isoclns_print(ndo
, p
+ 1, l2info
.length
- 1);
962 case (LLC_UI
<<8 | NLPID_Q933
):
963 case (LLC_UI
<<8 | NLPID_IP
):
964 case (LLC_UI
<<8 | NLPID_IP6
):
965 /* pass IP{4,6} to the OSI layer for proper link-layer printing */
966 isoclns_print(ndo
, p
- 1, l2info
.length
+ 1);
969 ND_PRINT("unknown protocol 0x%04x, length %u", l2info
.proto
, l2info
.length
);
972 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
976 #ifdef DLT_JUNIPER_MLFR
978 juniper_mlfr_if_print(netdissect_options
*ndo
,
979 const struct pcap_pkthdr
*h
, const u_char
*p
)
981 struct juniper_l2info_t l2info
;
983 ndo
->ndo_protocol
= "juniper_mlfr";
984 l2info
.pictype
= DLT_JUNIPER_MLFR
;
985 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
986 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
990 p
+=l2info
.header_len
;
992 /* suppress Bundle-ID if frame was captured on a child-link */
993 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
994 if (ndo
->ndo_eflag
&& EXTRACT_BE_U_4(l2info
.cookie
) != 1)
995 ND_PRINT("Bundle-ID %u, ", l2info
.bundle
);
996 switch (l2info
.proto
) {
999 isoclns_print(ndo
, p
, l2info
.length
);
1001 case (LLC_UI
<<8 | NLPID_Q933
):
1002 case (LLC_UI
<<8 | NLPID_IP
):
1003 case (LLC_UI
<<8 | NLPID_IP6
):
1004 /* pass IP{4,6} to the OSI layer for proper link-layer printing */
1005 isoclns_print(ndo
, p
- 1, l2info
.length
+ 1);
1008 ND_PRINT("unknown protocol 0x%04x, length %u", l2info
.proto
, l2info
.length
);
1011 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1016 * ATM1 PIC cookie format
1018 * +-----+-------------------------+-------------------------------+
1019 * |fmtid| vc index | channel ID |
1020 * +-----+-------------------------+-------------------------------+
1023 #ifdef DLT_JUNIPER_ATM1
1025 juniper_atm1_if_print(netdissect_options
*ndo
,
1026 const struct pcap_pkthdr
*h
, const u_char
*p
)
1030 struct juniper_l2info_t l2info
;
1032 ndo
->ndo_protocol
= "juniper_atm1";
1033 l2info
.pictype
= DLT_JUNIPER_ATM1
;
1034 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
1035 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1039 p
+=l2info
.header_len
;
1041 if (l2info
.cookie
[0] == 0x80) { /* OAM cell ? */
1042 oam_print(ndo
, p
, l2info
.length
, ATM_OAM_NOHEC
);
1043 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1047 if (GET_BE_U_3(p
) == 0xfefe03 || /* NLPID encaps ? */
1048 GET_BE_U_3(p
) == 0xaaaa03) { /* SNAP encaps ? */
1050 llc_hdrlen
= llc_print(ndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
1051 if (llc_hdrlen
> 0) {
1052 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1057 if (GET_U_1(p
) == 0x03) { /* Cisco style NLPID encaps ? */
1058 isoclns_print(ndo
, p
+ 1, l2info
.length
- 1);
1059 /* FIXME check if frame was recognized */
1060 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1064 if (ip_heuristic_guess(ndo
, p
, l2info
.length
) != 0) { /* last try - vcmux encaps ? */
1065 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1069 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1074 * ATM2 PIC cookie format
1076 * +-------------------------------+---------+---+-----+-----------+
1077 * | channel ID | reserv |AAL| CCRQ| gap cnt |
1078 * +-------------------------------+---------+---+-----+-----------+
1081 #ifdef DLT_JUNIPER_ATM2
1083 juniper_atm2_if_print(netdissect_options
*ndo
,
1084 const struct pcap_pkthdr
*h
, const u_char
*p
)
1088 struct juniper_l2info_t l2info
;
1090 ndo
->ndo_protocol
= "juniper_atm2";
1091 l2info
.pictype
= DLT_JUNIPER_ATM2
;
1092 if (juniper_parse_header(ndo
, p
, h
, &l2info
) == 0) {
1093 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1097 p
+=l2info
.header_len
;
1099 if (l2info
.cookie
[7] & ATM2_PKT_TYPE_MASK
) { /* OAM cell ? */
1100 oam_print(ndo
, p
, l2info
.length
, ATM_OAM_NOHEC
);
1101 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1105 if (GET_BE_U_3(p
) == 0xfefe03 || /* NLPID encaps ? */
1106 GET_BE_U_3(p
) == 0xaaaa03) { /* SNAP encaps ? */
1108 llc_hdrlen
= llc_print(ndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
1109 if (llc_hdrlen
> 0) {
1110 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1115 if (l2info
.direction
!= JUNIPER_BPF_PKT_IN
&& /* ether-over-1483 encaps ? */
1116 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
1117 (EXTRACT_BE_U_4(l2info
.cookie
) & ATM2_GAP_COUNT_MASK
)) {
1118 ether_print(ndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
1119 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1123 if (GET_U_1(p
) == 0x03) { /* Cisco style NLPID encaps ? */
1124 isoclns_print(ndo
, p
+ 1, l2info
.length
- 1);
1125 /* FIXME check if frame was recognized */
1126 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1130 if(juniper_ppp_heuristic_guess(ndo
, p
, l2info
.length
) != 0) { /* PPPoA vcmux encaps ? */
1131 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1135 if (ip_heuristic_guess(ndo
, p
, l2info
.length
) != 0) { /* last try - vcmux encaps ? */
1136 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1140 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1143 /* try to guess, based on all PPP protos that are supported in
1144 * a juniper router if the payload data is encapsulated using PPP */
1146 juniper_ppp_heuristic_guess(netdissect_options
*ndo
,
1147 const u_char
*p
, u_int length
)
1149 switch(GET_BE_U_2(p
)) {
1152 case PPP_MPLS_UCAST
:
1153 case PPP_MPLS_MCAST
:
1163 ppp_print(ndo
, p
, length
);
1167 return 0; /* did not find a ppp header */
1170 return 1; /* we printed a ppp packet */
1175 ip_heuristic_guess(netdissect_options
*ndo
,
1176 const u_char
*p
, u_int length
)
1178 switch(GET_U_1(p
)) {
1190 ip_print(ndo
, p
, length
);
1208 ip6_print(ndo
, p
, length
);
1211 return 0; /* did not find a ip header */
1214 return 1; /* we printed an v4/v6 packet */
1218 juniper_read_tlv_value(netdissect_options
*ndo
,
1219 const u_char
*p
, u_int tlv_type
, u_int tlv_len
)
1223 /* TLVs < 128 are little endian encoded */
1224 if (tlv_type
< 128) {
1227 tlv_value
= GET_U_1(p
);
1230 tlv_value
= GET_LE_U_2(p
);
1233 tlv_value
= GET_LE_U_3(p
);
1236 tlv_value
= GET_LE_U_4(p
);
1243 /* TLVs >= 128 are big endian encoded */
1246 tlv_value
= GET_U_1(p
);
1249 tlv_value
= GET_BE_U_2(p
);
1252 tlv_value
= GET_BE_U_3(p
);
1255 tlv_value
= GET_BE_U_4(p
);
1266 juniper_parse_header(netdissect_options
*ndo
,
1267 const u_char
*p
, const struct pcap_pkthdr
*h
, struct juniper_l2info_t
*l2info
)
1269 const struct juniper_cookie_table_t
*lp
= juniper_cookie_table
;
1270 u_int idx
, jnx_ext_len
, jnx_header_len
= 0;
1271 uint8_t tlv_type
,tlv_len
;
1272 #ifdef DLT_JUNIPER_ATM2
1273 uint32_t control_word
;
1279 l2info
->header_len
= 0;
1280 l2info
->cookie_len
= 0;
1284 l2info
->length
= h
->len
;
1285 l2info
->caplen
= h
->caplen
;
1287 l2info
->flags
= GET_U_1(p
+ 3);
1288 l2info
->direction
= GET_U_1(p
+ 3) & JUNIPER_BPF_PKT_IN
;
1290 if (GET_BE_U_3(p
) != JUNIPER_MGC_NUMBER
) { /* magic number found ? */
1291 ND_PRINT("no magic-number found!");
1295 if (ndo
->ndo_eflag
) /* print direction */
1296 ND_PRINT("%3s ", tok2str(juniper_direction_values
, "---", l2info
->direction
));
1298 /* magic number + flags */
1301 if (ndo
->ndo_vflag
> 1)
1302 ND_PRINT("\n\tJuniper PCAP Flags [%s]",
1303 bittok2str(jnx_flag_values
, "none", l2info
->flags
));
1305 /* extensions present ? - calculate how much bytes to skip */
1306 if ((l2info
->flags
& JUNIPER_BPF_EXT
) == JUNIPER_BPF_EXT
) {
1308 tptr
= p
+jnx_header_len
;
1310 /* ok to read extension length ? */
1311 jnx_ext_len
= GET_BE_U_2(tptr
);
1312 jnx_header_len
+= 2;
1315 /* nail up the total length -
1316 * just in case something goes wrong
1317 * with TLV parsing */
1318 jnx_header_len
+= jnx_ext_len
;
1320 if (ndo
->ndo_vflag
> 1)
1321 ND_PRINT(", PCAP Extension(s) total length %u", jnx_ext_len
);
1323 ND_TCHECK_LEN(tptr
, jnx_ext_len
);
1324 while (jnx_ext_len
> JUNIPER_EXT_TLV_OVERHEAD
) {
1325 tlv_type
= GET_U_1(tptr
);
1327 tlv_len
= GET_U_1(tptr
);
1332 if (tlv_type
== 0 || tlv_len
== 0)
1334 if (tlv_len
+JUNIPER_EXT_TLV_OVERHEAD
> jnx_ext_len
)
1337 if (ndo
->ndo_vflag
> 1)
1338 ND_PRINT("\n\t %s Extension TLV #%u, length %u, value ",
1339 tok2str(jnx_ext_tlv_values
,"Unknown",tlv_type
),
1343 tlv_value
= juniper_read_tlv_value(ndo
, tptr
, tlv_type
, tlv_len
);
1345 case JUNIPER_EXT_TLV_IFD_NAME
:
1348 case JUNIPER_EXT_TLV_IFD_MEDIATYPE
:
1349 case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE
:
1350 if (tlv_value
!= -1) {
1351 if (ndo
->ndo_vflag
> 1)
1353 tok2str(juniper_ifmt_values
, "Unknown", tlv_value
),
1357 case JUNIPER_EXT_TLV_IFL_ENCAPS
:
1358 case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS
:
1359 if (tlv_value
!= -1) {
1360 if (ndo
->ndo_vflag
> 1)
1362 tok2str(juniper_ifle_values
, "Unknown", tlv_value
),
1366 case JUNIPER_EXT_TLV_IFL_IDX
: /* fall through */
1367 case JUNIPER_EXT_TLV_IFL_UNIT
:
1368 case JUNIPER_EXT_TLV_IFD_IDX
:
1370 if (tlv_value
!= -1) {
1371 if (ndo
->ndo_vflag
> 1)
1372 ND_PRINT("%u", tlv_value
);
1378 jnx_ext_len
-= tlv_len
+JUNIPER_EXT_TLV_OVERHEAD
;
1381 if (ndo
->ndo_vflag
> 1)
1382 ND_PRINT("\n\t-----original packet-----\n\t");
1385 if ((l2info
->flags
& JUNIPER_BPF_NO_L2
) == JUNIPER_BPF_NO_L2
) {
1387 ND_PRINT("no-L2-hdr, ");
1389 /* there is no link-layer present -
1390 * perform the v4/v6 heuristics
1391 * to figure out what it is
1393 ND_TCHECK_1(p
+ (jnx_header_len
+ 4));
1394 if (ip_heuristic_guess(ndo
, p
+ jnx_header_len
+ 4,
1395 l2info
->length
- (jnx_header_len
+ 4)) == 0)
1396 ND_PRINT("no IP-hdr found!");
1398 l2info
->header_len
=jnx_header_len
+4;
1399 return 0; /* stop parsing the output further */
1402 l2info
->header_len
= jnx_header_len
;
1403 p
+=l2info
->header_len
;
1404 l2info
->length
-= l2info
->header_len
;
1405 l2info
->caplen
-= l2info
->header_len
;
1407 /* search through the cookie table and copy values matching for our PIC type */
1409 while (lp
->s
!= NULL
) {
1410 if (lp
->pictype
== l2info
->pictype
) {
1412 l2info
->cookie_len
+= lp
->cookie_len
;
1414 switch (GET_U_1(p
)) {
1416 l2info
->cookie_type
= LS_COOKIE_ID
;
1417 l2info
->cookie_len
+= 2;
1420 l2info
->cookie_type
= AS_COOKIE_ID
;
1421 l2info
->cookie_len
= 8;
1425 l2info
->bundle
= l2info
->cookie
[0];
1430 #ifdef DLT_JUNIPER_MFR
1431 /* MFR child links don't carry cookies */
1432 if (l2info
->pictype
== DLT_JUNIPER_MFR
&&
1433 (GET_U_1(p
) & MFR_BE_MASK
) == MFR_BE_MASK
) {
1434 l2info
->cookie_len
= 0;
1438 l2info
->header_len
+= l2info
->cookie_len
;
1439 l2info
->length
-= l2info
->cookie_len
;
1440 l2info
->caplen
-= l2info
->cookie_len
;
1443 ND_PRINT("%s-PIC, cookie-len %u",
1445 l2info
->cookie_len
);
1447 if (l2info
->cookie_len
> 8) {
1448 nd_print_invalid(ndo
);
1452 if (l2info
->cookie_len
> 0) {
1453 ND_TCHECK_LEN(p
, l2info
->cookie_len
);
1455 ND_PRINT(", cookie 0x");
1456 for (idx
= 0; idx
< l2info
->cookie_len
; idx
++) {
1457 l2info
->cookie
[idx
] = GET_U_1(p
+ idx
); /* copy cookie data */
1458 if (ndo
->ndo_eflag
) ND_PRINT("%02x", GET_U_1(p
+ idx
));
1462 if (ndo
->ndo_eflag
) ND_PRINT(": "); /* print demarc b/w L2/L3*/
1465 l2info
->proto
= GET_BE_U_2(p
+ l2info
->cookie_len
);
1470 p
+=l2info
->cookie_len
;
1472 /* DLT_ specific parsing */
1473 switch(l2info
->pictype
) {
1474 #ifdef DLT_JUNIPER_MLPPP
1475 case DLT_JUNIPER_MLPPP
:
1476 switch (l2info
->cookie_type
) {
1478 l2info
->bundle
= l2info
->cookie
[1];
1481 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
1482 l2info
->bundle
= (EXTRACT_BE_U_2(&l2info
->cookie
[6])>>3)&0xfff;
1483 l2info
->proto
= (l2info
->cookie
[5])&JUNIPER_LSQ_L3_PROTO_MASK
;
1486 l2info
->bundle
= l2info
->cookie
[0];
1491 #ifdef DLT_JUNIPER_MLFR
1492 case DLT_JUNIPER_MLFR
:
1493 switch (l2info
->cookie_type
) {
1495 l2info
->bundle
= l2info
->cookie
[1];
1496 l2info
->proto
= GET_BE_U_2(p
);
1497 l2info
->header_len
+= 2;
1498 l2info
->length
-= 2;
1499 l2info
->caplen
-= 2;
1502 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
1503 l2info
->bundle
= (EXTRACT_BE_U_2(&l2info
->cookie
[6])>>3)&0xfff;
1504 l2info
->proto
= (l2info
->cookie
[5])&JUNIPER_LSQ_L3_PROTO_MASK
;
1507 l2info
->bundle
= l2info
->cookie
[0];
1508 l2info
->header_len
+= 2;
1509 l2info
->length
-= 2;
1510 l2info
->caplen
-= 2;
1515 #ifdef DLT_JUNIPER_MFR
1516 case DLT_JUNIPER_MFR
:
1517 switch (l2info
->cookie_type
) {
1519 l2info
->bundle
= l2info
->cookie
[1];
1520 l2info
->proto
= GET_BE_U_2(p
);
1521 l2info
->header_len
+= 2;
1522 l2info
->length
-= 2;
1523 l2info
->caplen
-= 2;
1526 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
1527 l2info
->bundle
= (EXTRACT_BE_U_2(&l2info
->cookie
[6])>>3)&0xfff;
1528 l2info
->proto
= (l2info
->cookie
[5])&JUNIPER_LSQ_L3_PROTO_MASK
;
1531 l2info
->bundle
= l2info
->cookie
[0];
1536 #ifdef DLT_JUNIPER_ATM2
1537 case DLT_JUNIPER_ATM2
:
1539 /* ATM cell relay control word present ? */
1540 if (l2info
->cookie
[7] & ATM2_PKT_TYPE_MASK
) {
1541 control_word
= GET_BE_U_4(p
);
1542 /* some control word heuristics */
1543 switch(control_word
) {
1544 case 0: /* zero control word */
1545 case 0x08000000: /* < JUNOS 7.4 control-word */
1546 case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/
1547 l2info
->header_len
+= 4;
1554 ND_PRINT("control-word 0x%08x ", control_word
);
1558 #ifdef DLT_JUNIPER_GGSN
1559 case DLT_JUNIPER_GGSN
:
1562 #ifdef DLT_JUNIPER_ATM1
1563 case DLT_JUNIPER_ATM1
:
1566 #ifdef DLT_JUNIPER_PPP
1567 case DLT_JUNIPER_PPP
:
1570 #ifdef DLT_JUNIPER_CHDLC
1571 case DLT_JUNIPER_CHDLC
:
1574 #ifdef DLT_JUNIPER_ETHER
1575 case DLT_JUNIPER_ETHER
:
1578 #ifdef DLT_JUNIPER_FRELAY
1579 case DLT_JUNIPER_FRELAY
:
1584 ND_PRINT("Unknown Juniper DLT_ type %u: ", l2info
->pictype
);
1588 if (ndo
->ndo_eflag
> 1)
1589 ND_PRINT("hlen %u, proto 0x%04x, ", l2info
->header_len
, l2info
->proto
);
1591 return 1; /* everything went ok so far. continue parsing */
1593 nd_print_trunc(ndo
);
1596 #endif /* defined(DLT_JUNIPER_GGSN) || defined(DLT_JUNIPER_ES) || \
1597 defined(DLT_JUNIPER_MONITOR) || defined(DLT_JUNIPER_SERVICES) || \
1598 defined(DLT_JUNIPER_PPPOE) || defined(DLT_JUNIPER_ETHER) || \
1599 defined(DLT_JUNIPER_PPP) || defined(DLT_JUNIPER_FRELAY) || \
1600 defined(DLT_JUNIPER_CHDLC) || defined(DLT_JUNIPER_PPPOE_ATM) || \
1601 defined(DLT_JUNIPER_MLPPP) || defined(DLT_JUNIPER_MFR) || \
1602 defined(DLT_JUNIPER_MLFR) || defined(DLT_JUNIPER_ATM1) || \
1603 defined(DLT_JUNIPER_ATM2) */