2 * Routines for Juniper Networks, Inc. packet disassembly
3 * Copyright 2005 Hannes Gredler <hannes@juniper.net>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/packet.h>
30 #include <epan/etypes.h>
31 #include <epan/prefs.h>
32 #include <epan/addr_resolv.h>
33 #include <epan/ppptypes.h>
34 #include "packet-ppp.h"
35 #include "packet-ip.h"
36 #include <epan/nlpid.h>
38 #define JUNIPER_FLAG_PKT_OUT 0x00 /* Outgoing packet */
39 #define JUNIPER_FLAG_PKT_IN 0x01 /* Incoming packet */
40 #define JUNIPER_FLAG_NO_L2 0x02 /* L2 header stripped */
41 #define JUNIPER_FLAG_EXT 0x80 /* extensions present */
42 #define EXT_TLV_HEADER_SIZE 2
43 #define JUNIPER_ATM2_PKT_TYPE_MASK 0x70
44 #define JUNIPER_ATM2_GAP_COUNT_MASK 0x3F
45 #define JUNIPER_PCAP_MAGIC 0x4d4743
47 #define JUNIPER_PIC_ATM1 1
48 #define JUNIPER_PIC_ATM2 2
49 #define JUNIPER_PIC_MLPPP 3
50 #define JUNIPER_PIC_MLFR 4
52 #define JUNIPER_HDR_SNAP 0xaaaa03
53 #define JUNIPER_HDR_NLPID 0xfefe03
54 #define JUNIPER_HDR_LLC_UI 0x03
55 #define JUNIPER_HDR_PPP 0xff03
57 #define ML_PIC_COOKIE_LEN 2
58 #define LS_PIC_COOKIE_LEN 4
59 #define AS_PIC_COOKIE_LEN 8
61 #define GSP_SVC_REQ_APOLLO 0x40
62 #define GSP_SVC_REQ_LSQ 0x47
64 #define LSQ_COOKIE_RE 0x2
65 #define LSQ_COOKIE_DIR 0x1
66 #define LSQ_L3_PROTO_SHIFT 4
67 #define LSQ_L3_PROTO_MASK 0xf0
68 #define LSQ_L3_PROTO_IPV4 (0 << LSQ_L3_PROTO_SHIFT)
69 #define LSQ_L3_PROTO_IPV6 (1 << LSQ_L3_PROTO_SHIFT)
70 #define LSQ_L3_PROTO_MPLS (2 << LSQ_L3_PROTO_SHIFT)
71 #define LSQ_L3_PROTO_ISO (3 << LSQ_L3_PROTO_SHIFT)
73 #define EXT_TLV_IFD_IDX 1
74 #define EXT_TLV_IFD_NAME 2
75 #define EXT_TLV_IFD_MEDIATYPE 3
76 #define EXT_TLV_IFL_IDX 4
77 #define EXT_TLV_IFL_UNIT 5
78 #define EXT_TLV_IFL_ENCAPS 6
79 #define EXT_TLV_TTP_IFD_MEDIATYPE 7
80 #define EXT_TLV_TTP_IFL_ENCAPS 8
82 static const value_string ext_tlv_vals
[] = {
83 { EXT_TLV_IFD_IDX
, "Device Interface Index" },
84 { EXT_TLV_IFD_NAME
, "Device Interface Name" },
85 { EXT_TLV_IFD_MEDIATYPE
, "Device Media Type" },
86 { EXT_TLV_IFL_IDX
, "Logical Interface Index" },
87 { EXT_TLV_IFL_UNIT
, "Logical Unit Number" },
88 { EXT_TLV_IFL_ENCAPS
, "Logical Interface Encapsulation" },
89 { EXT_TLV_TTP_IFD_MEDIATYPE
, "TTP derived Device Media Type" },
90 { EXT_TLV_TTP_IFL_ENCAPS
, "TTP derived Logical Interface Encapsulation" },
94 static const value_string juniper_direction_vals
[] = {
95 {JUNIPER_FLAG_PKT_OUT
, "Out"},
96 {JUNIPER_FLAG_PKT_IN
, "In"},
100 static const value_string juniper_l2hdr_presence_vals
[] = {
106 #define JUNIPER_IFML_ETHER 1
107 #define JUNIPER_IFML_FDDI 2
108 #define JUNIPER_IFML_TOKENRING 3
109 #define JUNIPER_IFML_PPP 4
110 #define JUNIPER_IFML_FRAMERELAY 5
111 #define JUNIPER_IFML_CISCOHDLC 6
112 #define JUNIPER_IFML_SMDSDXI 7
113 #define JUNIPER_IFML_ATMPVC 8
114 #define JUNIPER_IFML_PPP_CCC 9
115 #define JUNIPER_IFML_FRAMERELAY_CCC 10
116 #define JUNIPER_IFML_IPIP 11
117 #define JUNIPER_IFML_GRE 12
118 #define JUNIPER_IFML_PIM 13
119 #define JUNIPER_IFML_PIMD 14
120 #define JUNIPER_IFML_CISCOHDLC_CCC 15
121 #define JUNIPER_IFML_VLAN_CCC 16
122 #define JUNIPER_IFML_MLPPP 17
123 #define JUNIPER_IFML_MLFR 18
124 #define JUNIPER_IFML_ML 19
125 #define JUNIPER_IFML_LSI 20
126 #define JUNIPER_IFML_DFE 21
127 #define JUNIPER_IFML_ATM_CELLRELAY_CCC 22
128 #define JUNIPER_IFML_CRYPTO 23
129 #define JUNIPER_IFML_GGSN 24
130 #define JUNIPER_IFML_LSI_PPP 25
131 #define JUNIPER_IFML_LSI_CISCOHDLC 26
132 #define JUNIPER_IFML_PPP_TCC 27
133 #define JUNIPER_IFML_FRAMERELAY_TCC 28
134 #define JUNIPER_IFML_CISCOHDLC_TCC 29
135 #define JUNIPER_IFML_ETHERNET_CCC 30
136 #define JUNIPER_IFML_VT 31
137 #define JUNIPER_IFML_EXTENDED_VLAN_CCC 32
138 #define JUNIPER_IFML_ETHER_OVER_ATM 33
139 #define JUNIPER_IFML_MONITOR 34
140 #define JUNIPER_IFML_ETHERNET_TCC 35
141 #define JUNIPER_IFML_VLAN_TCC 36
142 #define JUNIPER_IFML_EXTENDED_VLAN_TCC 37
143 #define JUNIPER_IFML_CONTROLLER 38
144 #define JUNIPER_IFML_MFR 39
145 #define JUNIPER_IFML_LS 40
146 #define JUNIPER_IFML_ETHERNET_VPLS 41
147 #define JUNIPER_IFML_ETHERNET_VLAN_VPLS 42
148 #define JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS 43
149 #define JUNIPER_IFML_LT 44
150 #define JUNIPER_IFML_SERVICES 45
151 #define JUNIPER_IFML_ETHER_VPLS_OVER_ATM 46
152 #define JUNIPER_IFML_FR_PORT_CCC 47
153 #define JUNIPER_IFML_FRAMERELAY_EXT_CCC 48
154 #define JUNIPER_IFML_FRAMERELAY_EXT_TCC 49
155 #define JUNIPER_IFML_FRAMERELAY_FLEX 50
156 #define JUNIPER_IFML_GGSNI 51
157 #define JUNIPER_IFML_ETHERNET_FLEX 52
158 #define JUNIPER_IFML_COLLECTOR 53
159 #define JUNIPER_IFML_AGGREGATOR 54
160 #define JUNIPER_IFML_LAPD 55
161 #define JUNIPER_IFML_PPPOE 56
162 #define JUNIPER_IFML_PPP_SUBORDINATE 57
163 #define JUNIPER_IFML_CISCOHDLC_SUBORDINATE 58
164 #define JUNIPER_IFML_DFC 59
165 #define JUNIPER_IFML_PICPEER 60
167 static const value_string juniper_ifmt_vals
[] = {
168 { JUNIPER_IFML_ETHER
, "Ethernet" },
169 { JUNIPER_IFML_FDDI
, "FDDI" },
170 { JUNIPER_IFML_TOKENRING
, "Token-Ring" },
171 { JUNIPER_IFML_PPP
, "PPP" },
172 { JUNIPER_IFML_PPP_SUBORDINATE
, "PPP-Subordinate" },
173 { JUNIPER_IFML_FRAMERELAY
, "Frame-Relay" },
174 { JUNIPER_IFML_CISCOHDLC
, "Cisco-HDLC" },
175 { JUNIPER_IFML_SMDSDXI
, "SMDS-DXI" },
176 { JUNIPER_IFML_ATMPVC
, "ATM-PVC" },
177 { JUNIPER_IFML_PPP_CCC
, "PPP-CCC" },
178 { JUNIPER_IFML_FRAMERELAY_CCC
, "Frame-Relay-CCC" },
179 { JUNIPER_IFML_FRAMERELAY_EXT_CCC
, "Extended FR-CCC" },
180 { JUNIPER_IFML_IPIP
, "IP-over-IP" },
181 { JUNIPER_IFML_GRE
, "GRE" },
182 { JUNIPER_IFML_PIM
, "PIM-Encapsulator" },
183 { JUNIPER_IFML_PIMD
, "PIM-Decapsulator" },
184 { JUNIPER_IFML_CISCOHDLC_CCC
, "Cisco-HDLC-CCC" },
185 { JUNIPER_IFML_VLAN_CCC
, "VLAN-CCC" },
186 { JUNIPER_IFML_EXTENDED_VLAN_CCC
, "Extended-VLAN-CCC" },
187 { JUNIPER_IFML_MLPPP
, "Multilink-PPP" },
188 { JUNIPER_IFML_MLFR
, "Multilink-FR" },
189 { JUNIPER_IFML_MFR
, "Multilink-FR-UNI-NNI" },
190 { JUNIPER_IFML_ML
, "Multilink" },
191 { JUNIPER_IFML_LS
, "LinkService" },
192 { JUNIPER_IFML_LSI
, "LSI" },
193 { JUNIPER_IFML_ATM_CELLRELAY_CCC
, "ATM-CCC-Cell-Relay" },
194 { JUNIPER_IFML_CRYPTO
, "IPSEC-over-IP" },
195 { JUNIPER_IFML_GGSN
, "GGSN" },
196 { JUNIPER_IFML_PPP_TCC
, "PPP-TCC" },
197 { JUNIPER_IFML_FRAMERELAY_TCC
, "Frame-Relay-TCC" },
198 { JUNIPER_IFML_FRAMERELAY_EXT_TCC
, "Extended FR-TCC" },
199 { JUNIPER_IFML_CISCOHDLC_TCC
, "Cisco-HDLC-TCC" },
200 { JUNIPER_IFML_ETHERNET_CCC
, "Ethernet-CCC" },
201 { JUNIPER_IFML_VT
, "VPN-Loopback-tunnel" },
202 { JUNIPER_IFML_ETHER_OVER_ATM
, "Ethernet-over-ATM" },
203 { JUNIPER_IFML_ETHER_VPLS_OVER_ATM
, "Ethernet-VPLS-over-ATM" },
204 { JUNIPER_IFML_MONITOR
, "Monitor" },
205 { JUNIPER_IFML_ETHERNET_TCC
, "Ethernet-TCC" },
206 { JUNIPER_IFML_VLAN_TCC
, "VLAN-TCC" },
207 { JUNIPER_IFML_EXTENDED_VLAN_TCC
, "Extended-VLAN-TCC" },
208 { JUNIPER_IFML_CONTROLLER
, "Controller" },
209 { JUNIPER_IFML_ETHERNET_VPLS
, "VPLS" },
210 { JUNIPER_IFML_ETHERNET_VLAN_VPLS
, "VLAN-VPLS" },
211 { JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS
, "Extended-VLAN-VPLS" },
212 { JUNIPER_IFML_LT
, "Logical-tunnel" },
213 { JUNIPER_IFML_SERVICES
, "General-Services" },
214 { JUNIPER_IFML_PPPOE
, "PPPoE" },
215 { JUNIPER_IFML_ETHERNET_FLEX
, "Flexible-Ethernet-Services" },
216 { JUNIPER_IFML_FRAMERELAY_FLEX
, "Flexible-FrameRelay" },
217 { JUNIPER_IFML_COLLECTOR
, "Flow-collection" },
218 { JUNIPER_IFML_PICPEER
, "PIC Peer" },
219 { JUNIPER_IFML_DFC
, "Dynamic-Flow-Capture" },
223 #define JUNIPER_IFLE_ATM_SNAP 2
224 #define JUNIPER_IFLE_ATM_NLPID 3
225 #define JUNIPER_IFLE_ATM_VCMUX 4
226 #define JUNIPER_IFLE_ATM_LLC 5
227 #define JUNIPER_IFLE_ATM_PPP_VCMUX 6
228 #define JUNIPER_IFLE_ATM_PPP_LLC 7
229 #define JUNIPER_IFLE_ATM_PPP_FUNI 8
230 #define JUNIPER_IFLE_ATM_CCC 9
231 #define JUNIPER_IFLE_FR_NLPID 10
232 #define JUNIPER_IFLE_FR_SNAP 11
233 #define JUNIPER_IFLE_FR_PPP 12
234 #define JUNIPER_IFLE_FR_CCC 13
235 #define JUNIPER_IFLE_ENET2 14
236 #define JUNIPER_IFLE_IEEE8023_SNAP 15
237 #define JUNIPER_IFLE_IEEE8023_LLC 16
238 #define JUNIPER_IFLE_PPP 17
239 #define JUNIPER_IFLE_CISCOHDLC 18
240 #define JUNIPER_IFLE_PPP_CCC 19
241 #define JUNIPER_IFLE_IPIP_NULL 20
242 #define JUNIPER_IFLE_PIM_NULL 21
243 #define JUNIPER_IFLE_GRE_NULL 22
244 #define JUNIPER_IFLE_GRE_PPP 23
245 #define JUNIPER_IFLE_PIMD_DECAPS 24
246 #define JUNIPER_IFLE_CISCOHDLC_CCC 25
247 #define JUNIPER_IFLE_ATM_CISCO_NLPID 26
248 #define JUNIPER_IFLE_VLAN_CCC 27
249 #define JUNIPER_IFLE_MLPPP 28
250 #define JUNIPER_IFLE_MLFR 29
251 #define JUNIPER_IFLE_LSI_NULL 30
252 #define JUNIPER_IFLE_AGGREGATE_UNUSED 31
253 #define JUNIPER_IFLE_ATM_CELLRELAY_CCC 32
254 #define JUNIPER_IFLE_CRYPTO 33
255 #define JUNIPER_IFLE_GGSN 34
256 #define JUNIPER_IFLE_ATM_TCC 35
257 #define JUNIPER_IFLE_FR_TCC 36
258 #define JUNIPER_IFLE_PPP_TCC 37
259 #define JUNIPER_IFLE_CISCOHDLC_TCC 38
260 #define JUNIPER_IFLE_ETHERNET_CCC 39
261 #define JUNIPER_IFLE_VT 40
262 #define JUNIPER_IFLE_ATM_EOA_LLC 41
263 #define JUNIPER_IFLE_EXTENDED_VLAN_CCC 42
264 #define JUNIPER_IFLE_ATM_SNAP_TCC 43
265 #define JUNIPER_IFLE_MONITOR 44
266 #define JUNIPER_IFLE_ETHERNET_TCC 45
267 #define JUNIPER_IFLE_VLAN_TCC 46
268 #define JUNIPER_IFLE_EXTENDED_VLAN_TCC 47
269 #define JUNIPER_IFLE_MFR 48
270 #define JUNIPER_IFLE_ETHERNET_VPLS 49
271 #define JUNIPER_IFLE_ETHERNET_VLAN_VPLS 50
272 #define JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS 51
273 #define JUNIPER_IFLE_SERVICES 52
274 #define JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC 53
275 #define JUNIPER_IFLE_FR_PORT_CCC 54
276 #define JUNIPER_IFLE_ATM_MLPPP_LLC 55
277 #define JUNIPER_IFLE_ATM_EOA_CCC 56
278 #define JUNIPER_IFLE_LT_VLAN 57
279 #define JUNIPER_IFLE_COLLECTOR 58
280 #define JUNIPER_IFLE_AGGREGATOR 59
281 #define JUNIPER_IFLE_LAPD 60
282 #define JUNIPER_IFLE_ATM_PPPOE_LLC 61
283 #define JUNIPER_IFLE_ETHERNET_PPPOE 62
284 #define JUNIPER_IFLE_PPPOE 63
285 #define JUNIPER_IFLE_PPP_SUBORDINATE 64
286 #define JUNIPER_IFLE_CISCOHDLC_SUBORDINATE 65
287 #define JUNIPER_IFLE_DFC 66
288 #define JUNIPER_IFLE_PICPEER 67
290 static const value_string juniper_ifle_vals
[] = {
291 { JUNIPER_IFLE_AGGREGATOR
, "Aggregator" },
292 { JUNIPER_IFLE_ATM_CCC
, "CCC over ATM" },
293 { JUNIPER_IFLE_ATM_CELLRELAY_CCC
, "ATM CCC Cell Relay" },
294 { JUNIPER_IFLE_ATM_CISCO_NLPID
, "CISCO compatible NLPID" },
295 { JUNIPER_IFLE_ATM_EOA_CCC
, "Ethernet over ATM CCC" },
296 { JUNIPER_IFLE_ATM_EOA_LLC
, "Ethernet over ATM LLC" },
297 { JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC
, "Ethernet VPLS over ATM LLC" },
298 { JUNIPER_IFLE_ATM_LLC
, "ATM LLC" },
299 { JUNIPER_IFLE_ATM_MLPPP_LLC
, "MLPPP over ATM LLC" },
300 { JUNIPER_IFLE_ATM_NLPID
, "ATM NLPID" },
301 { JUNIPER_IFLE_ATM_PPPOE_LLC
, "PPPoE over ATM LLC" },
302 { JUNIPER_IFLE_ATM_PPP_FUNI
, "PPP over FUNI" },
303 { JUNIPER_IFLE_ATM_PPP_LLC
, "PPP over ATM LLC" },
304 { JUNIPER_IFLE_ATM_PPP_VCMUX
, "PPP over ATM VCMUX" },
305 { JUNIPER_IFLE_ATM_SNAP
, "ATM SNAP" },
306 { JUNIPER_IFLE_ATM_SNAP_TCC
, "ATM SNAP TCC" },
307 { JUNIPER_IFLE_ATM_TCC
, "ATM VCMUX TCC" },
308 { JUNIPER_IFLE_ATM_VCMUX
, "ATM VCMUX" },
309 { JUNIPER_IFLE_CISCOHDLC
, "C-HDLC" },
310 { JUNIPER_IFLE_CISCOHDLC_CCC
, "C-HDLC CCC" },
311 { JUNIPER_IFLE_CISCOHDLC_SUBORDINATE
, "C-HDLC via dialer" },
312 { JUNIPER_IFLE_CISCOHDLC_TCC
, "C-HDLC TCC" },
313 { JUNIPER_IFLE_COLLECTOR
, "Collector" },
314 { JUNIPER_IFLE_CRYPTO
, "Crypto" },
315 { JUNIPER_IFLE_ENET2
, "Ethernet" },
316 { JUNIPER_IFLE_ETHERNET_CCC
, "Ethernet CCC" },
317 { JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS
, "Extended VLAN VPLS" },
318 { JUNIPER_IFLE_ETHERNET_PPPOE
, "PPPoE over Ethernet" },
319 { JUNIPER_IFLE_ETHERNET_TCC
, "Ethernet TCC" },
320 { JUNIPER_IFLE_ETHERNET_VLAN_VPLS
, "VLAN VPLS" },
321 { JUNIPER_IFLE_ETHERNET_VPLS
, "VPLS" },
322 { JUNIPER_IFLE_EXTENDED_VLAN_CCC
, "Extended VLAN CCC" },
323 { JUNIPER_IFLE_EXTENDED_VLAN_TCC
, "Extended VLAN TCC" },
324 { JUNIPER_IFLE_FR_CCC
, "FR CCC" },
325 { JUNIPER_IFLE_FR_NLPID
, "FR NLPID" },
326 { JUNIPER_IFLE_FR_PORT_CCC
, "FR CCC" },
327 { JUNIPER_IFLE_FR_PPP
, "FR PPP" },
328 { JUNIPER_IFLE_FR_SNAP
, "FR SNAP" },
329 { JUNIPER_IFLE_FR_TCC
, "FR TCC" },
330 { JUNIPER_IFLE_GGSN
, "GGSN" },
331 { JUNIPER_IFLE_GRE_NULL
, "GRE NULL" },
332 { JUNIPER_IFLE_GRE_PPP
, "PPP over GRE" },
333 { JUNIPER_IFLE_IPIP_NULL
, "IPIP" },
334 { JUNIPER_IFLE_LAPD
, "LAPD" },
335 { JUNIPER_IFLE_LSI_NULL
, "LSI Null" },
336 { JUNIPER_IFLE_LT_VLAN
, "LT VLAN" },
337 { JUNIPER_IFLE_MFR
, "MFR" },
338 { JUNIPER_IFLE_MLFR
, "MLFR" },
339 { JUNIPER_IFLE_MLPPP
, "MLPPP" },
340 { JUNIPER_IFLE_MONITOR
, "Monitor" },
341 { JUNIPER_IFLE_PIMD_DECAPS
, "PIMd" },
342 { JUNIPER_IFLE_PIM_NULL
, "PIM Null" },
343 { JUNIPER_IFLE_PPP
, "PPP" },
344 { JUNIPER_IFLE_PPPOE
, "PPPoE" },
345 { JUNIPER_IFLE_PPP_CCC
, "PPP CCC" },
346 { JUNIPER_IFLE_PPP_SUBORDINATE
, "" },
347 { JUNIPER_IFLE_PPP_TCC
, "PPP TCC" },
348 { JUNIPER_IFLE_SERVICES
, "General Services" },
349 { JUNIPER_IFLE_VLAN_CCC
, "VLAN CCC" },
350 { JUNIPER_IFLE_VLAN_TCC
, "VLAN TCC" },
351 { JUNIPER_IFLE_VT
, "VT" },
356 static int proto_juniper
= -1;
358 /* static int hf_juniper_magic = -1; */
359 static int hf_juniper_direction
= -1;
360 static int hf_juniper_l2hdr_presence
= -1;
361 static int hf_juniper_ext_total_len
= -1;
362 static int hf_juniper_atm1_cookie
= -1;
363 static int hf_juniper_atm2_cookie
= -1;
364 static int hf_juniper_mlpic_cookie
= -1;
365 static int hf_juniper_lspic_cookie
= -1;
366 static int hf_juniper_aspic_cookie
= -1;
367 static int hf_juniper_vlan
= -1;
368 static int hf_juniper_proto
= -1;
369 static int hf_juniper_ext_ifd
= -1;
370 static int hf_juniper_ext_ifl
= -1;
371 static int hf_juniper_ext_unit
= -1;
372 static int hf_juniper_ext_ifmt
= -1;
373 static int hf_juniper_ext_ifle
= -1;
374 static int hf_juniper_ext_ttp_ifmt
= -1;
375 static int hf_juniper_ext_ttp_ifle
= -1;
377 static gint ett_juniper
= -1;
379 static dissector_handle_t ipv4_handle
;
380 static dissector_handle_t ipv6_handle
;
381 static dissector_handle_t mpls_handle
;
382 static dissector_handle_t llc_handle
;
383 static dissector_handle_t eth_handle
;
384 static dissector_handle_t ppp_handle
;
385 static dissector_handle_t q933_handle
;
386 static dissector_handle_t frelay_handle
;
387 static dissector_handle_t chdlc_handle
;
388 static dissector_handle_t data_handle
;
390 static dissector_table_t osinl_incl_subdissector_table
;
391 static dissector_table_t osinl_excl_subdissector_table
;
393 static int dissect_juniper_header(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, proto_item
*ti
, guint8
*flags
);
394 static int dissect_juniper_payload_proto(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,proto_item
*ti
, guint proto
, guint offset
);
395 static void dissect_juniper_atm(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, guint16 atm_pictype
);
396 static gboolean
ppp_heuristic_guess(guint16 proto
);
397 static guint
ip_heuristic_guess(guint8 ip_header_byte
);
398 static guint
juniper_svc_cookie_len (guint64 cookie
);
399 static guint
juniper_svc_cookie_proto (guint64 cookie
, guint16 pictype
, guint8 flags
);
401 /* values < 200 are JUNOS internal proto values
402 * found in frames containing no link-layer header */
413 PROTO_CLNP_MPLS
= 32,
414 PROTO_MPLS_CLNP
= 33,
418 PROTO_LLC_SNAP
= 203,
426 static const value_string juniper_proto_vals
[] = {
428 {PROTO_MPLS_IP
, "MPLS->IPv4"},
429 {PROTO_IP_MPLS
, "IPv4->MPLS"},
431 {PROTO_MPLS_IP6
, "MPLS->IPv6"},
432 {PROTO_IP6_MPLS
, "IPv6->MPLS"},
434 {PROTO_CLNP
, "CLNP"},
435 {PROTO_MPLS_CLNP
, "MPLS->CLNP"},
436 {PROTO_CLNP_MPLS
, "CLNP->MPLS"},
438 {PROTO_MPLS
, "MPLS"},
440 {PROTO_LLC_SNAP
, "LLC/SNAP"},
441 {PROTO_ETHER
, "Ethernet"},
442 {PROTO_OAM
, "ATM OAM Cell"},
443 {PROTO_Q933
, "Q.933"},
444 {PROTO_FRELAY
, "Frame-Relay"},
445 {PROTO_CHDLC
, "C-HDLC"},
449 /* the first subtree is accessed by several routines */
450 static proto_tree
*juniper_subtree
= NULL
;
452 /* return a TLV value based on TLV length and TLV type (host/network order) */
454 juniper_ext_get_tlv_value(tvbuff_t
*tvb
, guint tlv_type
, guint tlv_len
, guint offset
) {
458 if (tlv_type
< 128) {
459 /* TLVs < 128 are little-endian / host order encoded */
462 tlv_value
= tvb_get_guint8(tvb
, offset
);
465 tlv_value
= tvb_get_letohs(tvb
, offset
);
468 tlv_value
= tvb_get_letoh24(tvb
, offset
);
471 tlv_value
= tvb_get_letohl(tvb
, offset
);
478 /* TLVs >= 128 are big-endian / network order encoded */
481 tlv_value
= tvb_get_guint8(tvb
, offset
);
484 tlv_value
= tvb_get_ntohs(tvb
, offset
);
487 tlv_value
= tvb_get_ntoh24(tvb
, offset
);
490 tlv_value
= tvb_get_ntohl(tvb
, offset
);
500 /* generic juniper header dissector */
502 dissect_juniper_header(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, proto_item
*ti
, guint8
*flags
)
505 guint8 l2hdr_presence
,proto
,ext_type
,ext_len
;
506 guint16 ext_total_len
,ext_offset
=6,hdr_len
;
507 guint32 magic_number
,ext_val
;
509 proto_tree
*juniper_ext_subtree
= NULL
, *juniper_ext_subtree_item
= NULL
;
511 magic_number
= tvb_get_ntoh24(tvb
, 0);
512 *flags
= tvb_get_guint8(tvb
, 3);
513 l2hdr_presence
= *flags
& JUNIPER_FLAG_NO_L2
;
515 juniper_subtree
= proto_item_add_subtree(ti
, ett_juniper
);
517 /* be liberal with magic-number detection -
518 * some older JUNOS releases (e.g. 6.4),
519 * which are still in the field do not generate magic-numbers */
520 if (magic_number
!= JUNIPER_PCAP_MAGIC
) {
521 proto_tree_add_text (juniper_subtree
, tvb
, 0, 0, "no Magic-Number found !");
525 proto_tree_add_text (juniper_subtree
, tvb
, 0, 3,
526 "Magic-Number: 0x%06x", magic_number
);
528 proto_tree_add_item(juniper_subtree
, hf_juniper_direction
, tvb
, 3, 1, ENC_NA
);
530 proto_tree_add_uint_format (juniper_subtree
, hf_juniper_l2hdr_presence
, tvb
, 3, 1,
531 l2hdr_presence
, "L2-header: %s",
532 val_to_str_const(l2hdr_presence
,juniper_l2hdr_presence_vals
,"Unknown"));
534 /* calculate hdr_len before cookie, payload */
536 /* meta-info extensions (JUNOS >= 7.5) ? */
537 if ((*flags
& JUNIPER_FLAG_EXT
) == JUNIPER_FLAG_EXT
) {
538 ext_total_len
= tvb_get_ntohs(tvb
,4);
539 hdr_len
= 6 + ext_total_len
; /* MGC,flags,ext_total_len */
541 tisub
= proto_tree_add_uint (juniper_subtree
, hf_juniper_ext_total_len
, tvb
, 4, 2, ext_total_len
);
542 juniper_ext_subtree
= proto_item_add_subtree(tisub
, ett_juniper
);
544 while (ext_total_len
> EXT_TLV_HEADER_SIZE
) {
545 ext_type
= tvb_get_guint8(tvb
, ext_offset
);
546 ext_len
= tvb_get_guint8(tvb
, ext_offset
+1);
548 if (ext_len
== 0 || ext_len
> (ext_total_len
- EXT_TLV_HEADER_SIZE
)) /* a few sanity checks */
551 tisub
= proto_tree_add_text (juniper_ext_subtree
, tvb
, ext_offset
, EXT_TLV_HEADER_SIZE
+ ext_len
,
552 "%s Extension TLV #%u, length: %u",
553 val_to_str_const(ext_type
, ext_tlv_vals
, "Unknown"),
557 ext_val
= juniper_ext_get_tlv_value(tvb
, ext_type
, ext_len
, ext_offset
+EXT_TLV_HEADER_SIZE
);
558 juniper_ext_subtree_item
= proto_item_add_subtree(tisub
, ett_juniper
);
561 case EXT_TLV_IFD_MEDIATYPE
:
562 proto_tree_add_uint(juniper_ext_subtree_item
, hf_juniper_ext_ifmt
,
563 tvb
, ext_offset
+EXT_TLV_HEADER_SIZE
, ext_len
, ext_val
);
565 case EXT_TLV_TTP_IFD_MEDIATYPE
:
566 proto_tree_add_uint(juniper_ext_subtree_item
, hf_juniper_ext_ttp_ifmt
,
567 tvb
, ext_offset
+EXT_TLV_HEADER_SIZE
, ext_len
, ext_val
);
569 case EXT_TLV_IFL_ENCAPS
:
570 proto_tree_add_uint(juniper_ext_subtree_item
, hf_juniper_ext_ifle
,
571 tvb
, ext_offset
+EXT_TLV_HEADER_SIZE
, ext_len
, ext_val
);
573 case EXT_TLV_TTP_IFL_ENCAPS
:
574 proto_tree_add_uint(juniper_ext_subtree_item
, hf_juniper_ext_ttp_ifle
,
575 tvb
, ext_offset
+EXT_TLV_HEADER_SIZE
, ext_len
, ext_val
);
578 case EXT_TLV_IFL_IDX
:
579 proto_tree_add_uint(juniper_ext_subtree_item
, hf_juniper_ext_ifl
,
580 tvb
, ext_offset
+EXT_TLV_HEADER_SIZE
, ext_len
, ext_val
);
583 case EXT_TLV_IFL_UNIT
:
584 proto_tree_add_uint(juniper_ext_subtree_item
, hf_juniper_ext_unit
,
585 tvb
, ext_offset
+EXT_TLV_HEADER_SIZE
, ext_len
, ext_val
);
587 case EXT_TLV_IFD_IDX
:
588 proto_tree_add_uint(juniper_ext_subtree_item
, hf_juniper_ext_ifd
,
589 tvb
, ext_offset
+EXT_TLV_HEADER_SIZE
, ext_len
, ext_val
);
591 case EXT_TLV_IFD_NAME
: /* FIXME print ifname string - lets fall-through for now */
593 proto_item_append_text(tisub
, "Unknown");
597 ext_offset
+= EXT_TLV_HEADER_SIZE
+ ext_len
;
598 ext_total_len
-= EXT_TLV_HEADER_SIZE
+ ext_len
;
602 hdr_len
= 4; /* MGC,flags */
604 if ((*flags
& JUNIPER_FLAG_NO_L2
) == JUNIPER_FLAG_NO_L2
) { /* no link header present ? */
605 proto
= tvb_get_letohl(tvb
,hdr_len
); /* proto is stored in host-order */
606 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, proto
, hdr_len
+ 4);
610 return hdr_len
; /* bytes parsed */
614 /* print the payload protocol */
616 dissect_juniper_payload_proto(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
617 proto_item
*ti _U_
, guint proto
, guint offset
)
623 proto_tree_add_text (juniper_subtree
, tvb
, offset
, 0, "[Payload Type: %s]",
624 val_to_str_const(proto
,juniper_proto_vals
,"Unknown"));
626 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
631 call_dissector(ipv4_handle
, next_tvb
, pinfo
, tree
);
635 call_dissector(ipv6_handle
, next_tvb
, pinfo
, tree
);
640 case PROTO_CLNP_MPLS
:
641 call_dissector(mpls_handle
, next_tvb
, pinfo
, tree
);
644 call_dissector(ppp_handle
, next_tvb
, pinfo
, tree
);
647 call_dissector(eth_handle
, next_tvb
, pinfo
, tree
);
651 call_dissector(llc_handle
, next_tvb
, pinfo
, tree
);
655 case PROTO_MPLS_CLNP
:
656 nlpid
= tvb_get_guint8(tvb
, offset
);
657 if(dissector_try_uint(osinl_incl_subdissector_table
, nlpid
, next_tvb
, pinfo
, tree
))
659 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+1);
660 if(dissector_try_uint(osinl_excl_subdissector_table
, nlpid
, next_tvb
, pinfo
, tree
))
664 call_dissector(q933_handle
, next_tvb
, pinfo
, tree
);
667 call_dissector(frelay_handle
, next_tvb
, pinfo
, tree
);
670 call_dissector(chdlc_handle
, next_tvb
, pinfo
, tree
);
673 proto_tree_add_text (juniper_subtree
, tvb
, offset
, 4,"[Unknown data]");
674 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+4);
675 call_dissector(ipv4_handle
, next_tvb
, pinfo
, tree
);
677 case PROTO_OAM
: /* FIXME call OAM disector without leading HEC byte */
679 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
688 dissect_juniper_mlfr(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
694 guint64 aspic_cookie
;
695 guint32 lspic_cookie
;
696 guint16 mlpic_cookie
;
697 guint proto
,cookie_len
;
699 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper MLFR");
700 col_clear(pinfo
->cinfo
, COL_INFO
);
704 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper Multi-Link Frame-Relay (FRF.15)");
706 /* parse header, match mgc, extract flags and build first tree */
707 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
709 if(bytes_processed
== -1)
712 offset
+=bytes_processed
;
714 aspic_cookie
= tvb_get_ntoh64(tvb
,offset
);
715 proto
= juniper_svc_cookie_proto(aspic_cookie
, JUNIPER_PIC_MLFR
, flags
);
716 cookie_len
= juniper_svc_cookie_len(aspic_cookie
);
718 if (cookie_len
== AS_PIC_COOKIE_LEN
)
719 proto_tree_add_uint64(juniper_subtree
, hf_juniper_aspic_cookie
,
720 tvb
, offset
, AS_PIC_COOKIE_LEN
, aspic_cookie
);
721 if (cookie_len
== LS_PIC_COOKIE_LEN
) {
722 lspic_cookie
= tvb_get_ntohl(tvb
,offset
);
723 proto_tree_add_uint(juniper_subtree
, hf_juniper_lspic_cookie
,
724 tvb
, offset
, LS_PIC_COOKIE_LEN
, lspic_cookie
);
727 offset
+= cookie_len
;
729 mlpic_cookie
= tvb_get_ntohs(tvb
, offset
);
732 if (cookie_len
== AS_PIC_COOKIE_LEN
&&
733 proto
== PROTO_UNKNOWN
&&
734 tvb_get_guint8(tvb
,offset
) == JUNIPER_HDR_LLC_UI
) {
740 if (cookie_len
== LS_PIC_COOKIE_LEN
) {
741 if ( tvb_get_ntohs(tvb
,offset
) == JUNIPER_HDR_LLC_UI
||
742 tvb_get_ntohs(tvb
,offset
) == (JUNIPER_HDR_LLC_UI
<<8)) {
748 if (cookie_len
== LS_PIC_COOKIE_LEN
&& tvb_get_guint8(tvb
,offset
) == JUNIPER_HDR_LLC_UI
) {
752 /* child link of an LS-PIC bundle ? */
753 if (cookie_len
== 0 && tvb_get_ntohs(tvb
,offset
+ML_PIC_COOKIE_LEN
) ==
754 (JUNIPER_HDR_LLC_UI
<<8 | NLPID_Q_933
)) {
755 cookie_len
= ML_PIC_COOKIE_LEN
;
756 proto_tree_add_uint(juniper_subtree
, hf_juniper_mlpic_cookie
,
757 tvb
, offset
, ML_PIC_COOKIE_LEN
, mlpic_cookie
);
762 /* child link of an ML-, LS-, AS-PIC bundle / ML-PIC bundle ? */
763 if (cookie_len
== 0) {
764 if (tvb_get_ntohs(tvb
,offset
+ML_PIC_COOKIE_LEN
) == JUNIPER_HDR_LLC_UI
||
765 tvb_get_ntohs(tvb
,offset
+ML_PIC_COOKIE_LEN
) == (JUNIPER_HDR_LLC_UI
<<8)) {
766 cookie_len
= ML_PIC_COOKIE_LEN
;
767 proto_tree_add_uint(juniper_subtree
, hf_juniper_mlpic_cookie
,
768 tvb
, offset
, ML_PIC_COOKIE_LEN
, mlpic_cookie
);
774 /* ML-PIC bundle ? */
775 if (cookie_len
== 0 && tvb_get_guint8(tvb
,offset
+ML_PIC_COOKIE_LEN
) == JUNIPER_HDR_LLC_UI
) {
776 cookie_len
= ML_PIC_COOKIE_LEN
;
777 proto_tree_add_uint(juniper_subtree
, hf_juniper_mlpic_cookie
,
778 tvb
, offset
, ML_PIC_COOKIE_LEN
, mlpic_cookie
);
783 ti
= proto_tree_add_text (juniper_subtree
, tvb
, offset
, 0, "[Cookie length: %u]",cookie_len
);
784 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, proto
, offset
);
790 /* MLPPP dissector */
792 dissect_juniper_mlppp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
798 guint64 aspic_cookie
;
799 guint32 lspic_cookie
;
800 guint16 mlpic_cookie
;
801 guint proto
,cookie_len
;
803 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper MLPPP");
804 col_clear(pinfo
->cinfo
, COL_INFO
);
808 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper MLPPP");
810 /* parse header, match mgc, extract flags and build first tree */
811 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
813 if(bytes_processed
== -1)
816 offset
+=bytes_processed
;
818 aspic_cookie
= tvb_get_ntoh64(tvb
,offset
);
819 proto
= juniper_svc_cookie_proto(aspic_cookie
, JUNIPER_PIC_MLPPP
, flags
);
820 cookie_len
= juniper_svc_cookie_len(aspic_cookie
);
822 if (cookie_len
== AS_PIC_COOKIE_LEN
)
823 proto_tree_add_uint64(juniper_subtree
, hf_juniper_aspic_cookie
,
824 tvb
, offset
, AS_PIC_COOKIE_LEN
, aspic_cookie
);
825 if (cookie_len
== LS_PIC_COOKIE_LEN
) {
826 lspic_cookie
= tvb_get_ntohl(tvb
,offset
);
827 proto_tree_add_uint(juniper_subtree
, hf_juniper_lspic_cookie
,
828 tvb
, offset
, LS_PIC_COOKIE_LEN
, lspic_cookie
);
831 /* no cookie pattern identified - lets guess from now on */
833 /* child link of an LS-PIC bundle ? */
834 if (cookie_len
== 0 && tvb_get_ntohs(tvb
, offset
) == JUNIPER_HDR_PPP
) {
840 if (cookie_len
== 0 && ppp_heuristic_guess(tvb_get_ntohs(tvb
, offset
+2))) {
843 mlpic_cookie
= tvb_get_ntohs(tvb
, offset
);
844 proto_tree_add_uint(juniper_subtree
, hf_juniper_mlpic_cookie
,
845 tvb
, offset
, ML_PIC_COOKIE_LEN
, mlpic_cookie
);
848 /* child link of an ML-PIC bundle ? */
849 if (cookie_len
== 0 && ppp_heuristic_guess(tvb_get_ntohs(tvb
, offset
))) {
853 ti
= proto_tree_add_text (juniper_subtree
, tvb
, offset
, 0, "[Cookie length: %u]",cookie_len
);
854 offset
+= cookie_len
;
856 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, proto
, offset
);
861 /* PPPoE dissector */
863 dissect_juniper_pppoe(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
870 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper PPPoE");
871 col_clear(pinfo
->cinfo
, COL_INFO
);
875 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper PPPoE PIC");
877 /* parse header, match mgc, extract flags and build first tree */
878 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
880 if(bytes_processed
== -1)
883 offset
+=bytes_processed
;
885 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_ETHER
, offset
);
889 /* Ethernet dissector */
891 dissect_juniper_ether(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
898 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper Ethernet");
899 col_clear(pinfo
->cinfo
, COL_INFO
);
903 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper Ethernet");
905 /* parse header, match mgc, extract flags and build first tree */
906 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
908 if(bytes_processed
== -1)
911 offset
+=bytes_processed
;
913 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_ETHER
, offset
);
919 dissect_juniper_ppp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
926 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper PPP");
927 col_clear(pinfo
->cinfo
, COL_INFO
);
931 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper PPP");
933 /* parse header, match mgc, extract flags and build first tree */
934 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
936 if(bytes_processed
== -1)
939 offset
+=bytes_processed
;
941 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_PPP
, offset
+2);
945 /* Frame-Relay dissector */
947 dissect_juniper_frelay(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
954 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper Frame-Relay");
955 col_clear(pinfo
->cinfo
, COL_INFO
);
959 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper Frame-Relay");
961 /* parse header, match mgc, extract flags and build first tree */
962 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
964 if(bytes_processed
== -1)
967 offset
+=bytes_processed
;
969 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_FRELAY
, offset
);
973 /* C-HDLC dissector */
975 dissect_juniper_chdlc(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
982 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper C-HDLC");
983 col_clear(pinfo
->cinfo
, COL_INFO
);
985 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper C-HDLC");
987 /* parse header, match mgc, extract flags and build first tree */
988 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
990 if(bytes_processed
== -1)
993 offset
+=bytes_processed
;
995 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_CHDLC
, offset
);
1001 /* wrapper for passing the PIC type to the generic ATM dissector */
1003 dissect_juniper_atm1(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
1005 dissect_juniper_atm(tvb
,pinfo
,tree
, JUNIPER_PIC_ATM1
);
1008 /* wrapper for passing the PIC type to the generic ATM dissector */
1010 dissect_juniper_atm2(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
1012 dissect_juniper_atm(tvb
,pinfo
,tree
, JUNIPER_PIC_ATM2
);
1015 /* generic ATM dissector */
1017 dissect_juniper_atm(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, guint16 atm_pictype
)
1020 guint8 next_proto
= PROTO_UNKNOWN
,atm1_header_len
,atm2_header_len
,flags
;
1021 guint32 cookie1
, proto
;
1024 int bytes_processed
;
1027 col_clear(pinfo
->cinfo
, COL_INFO
);
1029 switch (atm_pictype
) {
1030 case JUNIPER_PIC_ATM1
:
1031 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper ATM1");
1032 ti
= proto_tree_add_text (tree
, tvb
, 0, 0 , "Juniper ATM1 PIC");
1034 case JUNIPER_PIC_ATM2
:
1035 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper ATM2");
1036 ti
= proto_tree_add_text (tree
, tvb
, 0, 0 , "Juniper ATM2 PIC");
1038 default: /* should not happen */
1039 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper ATM unknown");
1040 proto_tree_add_text (tree
, tvb
, 0, 0 , "Juniper unknown ATM PIC");
1044 /* parse header, match mgc, extract flags and build first tree */
1045 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
1046 if(bytes_processed
== -1)
1049 offset
+=bytes_processed
;
1051 if ((flags
& JUNIPER_FLAG_NO_L2
) == JUNIPER_FLAG_NO_L2
) {
1052 atm1_header_len
= 4;
1053 atm2_header_len
= 4;
1056 atm1_header_len
= 4;
1057 atm2_header_len
= 8;
1060 cookie1
= tvb_get_ntohl(tvb
, offset
);
1061 cookie2
= tvb_get_ntoh64(tvb
, offset
);
1063 if (atm_pictype
== JUNIPER_PIC_ATM1
) {
1064 proto_tree_add_uint(juniper_subtree
, hf_juniper_atm1_cookie
, tvb
, offset
, 4, cookie1
);
1065 offset
+= atm1_header_len
;
1066 if ((cookie1
>> 24) == 0x80) /* OAM cell ? */
1067 next_proto
= PROTO_OAM
;
1069 else { /* JUNIPER_PIC_ATM2 */
1070 proto_tree_add_uint64(juniper_subtree
, hf_juniper_atm2_cookie
, tvb
, offset
, 8, cookie2
);
1071 offset
+= atm2_header_len
;
1072 if (cookie2
& 0x70) /* OAM cell ? */
1073 next_proto
= PROTO_OAM
;
1076 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
1078 if (next_proto
== PROTO_OAM
) {
1079 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_OAM
, offset
);
1083 proto
= tvb_get_ntoh24(tvb
, offset
); /* first try: 24-Bit guess */
1085 if (proto
== JUNIPER_HDR_NLPID
) {
1087 * This begins with something that appears to be an LLC header for
1088 * OSI; is this LLC-multiplexed traffic?
1090 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_LLC
, offset
);
1094 if (proto
== JUNIPER_HDR_SNAP
) {
1096 * This begins with something that appears to be an LLC header for
1097 * SNAP; is this LLC-multiplexed traffic?
1099 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_LLC_SNAP
, offset
);
1103 if ((flags
& JUNIPER_FLAG_PKT_IN
) != JUNIPER_FLAG_PKT_IN
&& /* ether-over-1483 encaps ? */
1104 (cookie1
& JUNIPER_ATM2_GAP_COUNT_MASK
) &&
1105 atm_pictype
!= JUNIPER_PIC_ATM1
) {
1106 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_ETHER
, offset
);
1110 proto
= tvb_get_ntohs(tvb
, offset
); /* second try: 16-Bit guess */
1112 if ( ppp_heuristic_guess( (guint16
) proto
) &&
1113 atm_pictype
!= JUNIPER_PIC_ATM1
) {
1115 * This begins with something that appears to be a PPP protocol
1116 * type; is this VC-multiplexed PPPoA?
1117 * That's not supported on ATM1 PICs.
1119 ti
= proto_tree_add_text (juniper_subtree
, tvb
, offset
, 0, "Encapsulation Type: VC-MUX");
1120 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_PPP
, offset
);
1124 proto
= tvb_get_guint8(tvb
, offset
); /* third try: 8-Bit guess */
1126 if ( proto
== JUNIPER_HDR_LLC_UI
) {
1128 * Cisco style NLPID encaps?
1129 * Is the 0x03 an LLC UI control field?
1131 ti
= proto_tree_add_text (juniper_subtree
, tvb
, offset
, 1, "Encapsulation Type: Cisco NLPID");
1132 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_ISO
, offset
+1);
1136 next_proto
= ip_heuristic_guess( (guint8
) proto
);
1137 if (next_proto
!= PROTO_UNKNOWN
) { /* last resort: VC-MUX encaps ? */
1139 * This begins with something that might be the first byte of
1140 * an IPv4 or IPv6 packet; is this VC-multiplexed IP?
1142 ti
= proto_tree_add_text (juniper_subtree
, tvb
, offset
, 0, "Encapsulation Type: VC-MUX");
1143 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, next_proto
, offset
);
1147 /* could not figure what it is */
1148 proto_tree_add_text (juniper_subtree
, tvb
, offset
, -1, "Payload Type: unknown");
1149 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
1153 static void dissect_juniper_ggsn(tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* tree
) {
1157 int bytes_processed
;
1161 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper GGSN");
1162 col_clear(pinfo
->cinfo
, COL_INFO
);
1164 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper GGSN");
1166 /* parse header, match mgc, extract flags and build first tree */
1167 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
1169 if(bytes_processed
== -1)
1172 offset
+=bytes_processed
;
1174 proto
= tvb_get_letohs(tvb
, offset
); /* fetch protocol */
1176 proto_tree_add_uint(juniper_subtree
, hf_juniper_proto
, tvb
, offset
, 2, proto
);
1177 proto_tree_add_item(juniper_subtree
, hf_juniper_vlan
, tvb
, offset
+2, 2, ENC_LITTLE_ENDIAN
);
1180 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, proto
, offset
);
1184 static void dissect_juniper_vp(tvbuff_t
* tvb
, packet_info
* pinfo
, proto_tree
* tree
) {
1188 int bytes_processed
;
1191 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper Voice PIC");
1192 col_clear(pinfo
->cinfo
, COL_INFO
);
1194 ti
= proto_tree_add_text (tree
, tvb
, offset
, 4, "Juniper Voice PIC");
1196 /* parse header, match mgc, extract flags and build first tree */
1197 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
1199 if(bytes_processed
== -1)
1202 offset
+=bytes_processed
;
1205 * Right know IPv4 is the only protocol we may encounter.
1206 * For the future there should be sufficient space in the 18-byte
1207 * empty header before payload starts.
1209 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_IP
, offset
+18);
1212 /* Wrapper for Juniper service PIC coookie dissector */
1214 dissect_juniper_svcs(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
1218 int bytes_processed
= 0;
1221 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "Juniper Services");
1222 col_clear(pinfo
->cinfo
, COL_INFO
);
1224 ti
= proto_tree_add_text (tree
, tvb
, 0, 4, "Juniper Services cookie");
1226 /* parse header, match mgc, extract flags and build first tree */
1227 bytes_processed
= dissect_juniper_header(tvb
, pinfo
, tree
, ti
, &flags
);
1229 if (bytes_processed
== -1)
1232 offset
+=bytes_processed
;
1234 if (flags
& JUNIPER_FLAG_PKT_IN
) {
1235 proto_tree_add_uint(juniper_subtree
, hf_juniper_proto
, tvb
, offset
, 2, PROTO_IP
);
1241 dissect_juniper_payload_proto(tvb
, pinfo
, tree
, ti
, PROTO_IP
, offset
);
1244 /* list of Juniper supported PPP proto IDs */
1246 ppp_heuristic_guess(guint16 proto
) {
1252 case PPP_MPLS_MULTI
:
1265 return FALSE
; /* did not find a ppp header */
1270 * return the IP version number based on the first byte of the IP header
1271 * returns 0 if it does not match a valid first IPv4/IPv6 header byte
1274 ip_heuristic_guess(guint8 ip_header_byte
) {
1276 switch(ip_header_byte
) {
1307 return PROTO_UNKNOWN
; /* did not find a ip header */
1311 /* return cookie length dep. on cookie SVC id */
1313 guint
juniper_svc_cookie_len (guint64 cookie
) {
1315 guint8 svc_cookie_id
;
1316 svc_cookie_id
= (guint8
)(cookie
>> 56) & 0xff;
1318 switch(svc_cookie_id
) {
1320 return LS_PIC_COOKIE_LEN
;
1321 case GSP_SVC_REQ_APOLLO
:
1322 case GSP_SVC_REQ_LSQ
:
1323 return AS_PIC_COOKIE_LEN
;
1329 /* return the next-level protocol based on cookie input */
1331 juniper_svc_cookie_proto (guint64 cookie
, guint16 pictype
, guint8 flags
) {
1333 guint8 svc_cookie_id
;
1337 svc_cookie_id
= (guint8
)(cookie
>> 56) & 0xff;
1338 lsq_proto
= (guint16
)((cookie
>> 16) & LSQ_L3_PROTO_MASK
);
1339 lsq_dir
= (guint8
)(cookie
>> 24) & 0x3;
1342 switch (svc_cookie_id
) {
1345 case JUNIPER_PIC_MLPPP
:
1347 case JUNIPER_PIC_MLFR
:
1350 return PROTO_UNKNOWN
;
1352 case GSP_SVC_REQ_APOLLO
:
1353 case GSP_SVC_REQ_LSQ
:
1355 case LSQ_L3_PROTO_IPV4
:
1357 case JUNIPER_PIC_MLPPP
:
1358 /* incoming traffic would have the direction bits set
1359 * -> this must be IS-IS over PPP
1361 if ((flags
& JUNIPER_FLAG_PKT_IN
) == JUNIPER_FLAG_PKT_IN
&&
1362 lsq_dir
!= (LSQ_COOKIE_RE
|LSQ_COOKIE_DIR
))
1366 case JUNIPER_PIC_MLFR
:
1367 if (lsq_dir
== (LSQ_COOKIE_RE
|LSQ_COOKIE_DIR
))
1368 return PROTO_UNKNOWN
;
1372 return PROTO_UNKNOWN
;
1374 case LSQ_L3_PROTO_IPV6
:
1376 case LSQ_L3_PROTO_MPLS
:
1378 case LSQ_L3_PROTO_ISO
:
1381 return PROTO_UNKNOWN
;
1384 return PROTO_UNKNOWN
;
1390 proto_register_juniper(void)
1392 static hf_register_info hf
[] = {
1394 { &hf_juniper_magic
,
1395 { "Magic Number", "juniper.magic-number", FT_UINT24
, BASE_HEX
,
1396 NULL
, 0x0, NULL
, HFILL
}},
1398 { &hf_juniper_direction
,
1399 { "Direction", "juniper.direction", FT_UINT8
, BASE_HEX
,
1400 VALS(juniper_direction_vals
), 0x0, NULL
, HFILL
}},
1401 { &hf_juniper_l2hdr_presence
,
1402 { "L2 header presence", "juniper.l2hdr", FT_UINT8
, BASE_HEX
,
1403 VALS(juniper_l2hdr_presence_vals
), 0x0, NULL
, HFILL
}},
1404 { &hf_juniper_ext_total_len
,
1405 { "Extension(s) Total length", "juniper.ext_total_len", FT_UINT16
, BASE_DEC
,
1406 NULL
, 0x0, NULL
, HFILL
}},
1407 { &hf_juniper_atm2_cookie
,
1408 { "Cookie", "juniper.atm2.cookie", FT_UINT64
, BASE_HEX
,
1409 NULL
, 0x0, NULL
, HFILL
}},
1410 { &hf_juniper_atm1_cookie
,
1411 { "Cookie", "juniper.atm1.cookie", FT_UINT32
, BASE_HEX
,
1412 NULL
, 0x0, NULL
, HFILL
}},
1413 { &hf_juniper_mlpic_cookie
,
1414 { "Cookie", "juniper.mlpic.cookie", FT_UINT16
, BASE_HEX
,
1415 NULL
, 0x0, NULL
, HFILL
}},
1416 { &hf_juniper_lspic_cookie
,
1417 { "Cookie", "juniper.lspic.cookie", FT_UINT32
, BASE_HEX
,
1418 NULL
, 0x0, NULL
, HFILL
}},
1419 { &hf_juniper_aspic_cookie
,
1420 { "Cookie", "juniper.aspic.cookie", FT_UINT64
, BASE_HEX
,
1421 NULL
, 0x0, NULL
, HFILL
}},
1423 { "VLan ID", "juniper.vlan", FT_UINT16
, BASE_DEC
,
1424 NULL
, 0x0, NULL
, HFILL
}},
1425 { &hf_juniper_proto
,
1426 { "Protocol", "juniper.proto", FT_UINT16
, BASE_DEC
,
1427 VALS(juniper_proto_vals
), 0x0, NULL
, HFILL
}},
1428 { &hf_juniper_ext_ifd
,
1429 /* Juniper PCAP extensions */
1430 { "Device Interface Index", "juniper.ext.ifd", FT_UINT32
, BASE_DEC
,
1431 NULL
, 0x0, NULL
, HFILL
}},
1432 { &hf_juniper_ext_ifl
,
1433 { "Logical Interface Index", "juniper.ext.ifl", FT_UINT32
, BASE_DEC
,
1434 NULL
, 0x0, NULL
, HFILL
}},
1435 { &hf_juniper_ext_unit
,
1436 { "Logical Unit Number", "juniper.ext.unit", FT_UINT32
, BASE_DEC
,
1437 NULL
, 0x0, NULL
, HFILL
}},
1438 { &hf_juniper_ext_ifmt
,
1439 { "Device Media Type", "juniper.ext.ifmt", FT_UINT16
, BASE_DEC
,
1440 VALS(juniper_ifmt_vals
), 0x0, NULL
, HFILL
}},
1441 { &hf_juniper_ext_ifle
,
1442 { "Logical Interface Encapsulation", "juniper.ext.ifle", FT_UINT16
, BASE_DEC
,
1443 VALS(juniper_ifle_vals
), 0x0, NULL
, HFILL
}},
1444 { &hf_juniper_ext_ttp_ifmt
,
1445 { "TTP derived Device Media Type", "juniper.ext.ttp_ifmt", FT_UINT16
, BASE_DEC
,
1446 VALS(juniper_ifmt_vals
), 0x0, NULL
, HFILL
}},
1447 { &hf_juniper_ext_ttp_ifle
,
1448 { "TTP derived Logical Interface Encapsulation", "juniper.ext.ttp_ifle", FT_UINT16
, BASE_DEC
,
1449 VALS(juniper_ifle_vals
), 0x0, NULL
, HFILL
}},
1452 static gint
*ett
[] = {
1456 proto_juniper
= proto_register_protocol("Juniper", "Juniper", "juniper");
1457 proto_register_field_array(proto_juniper
, hf
, array_length(hf
));
1458 proto_register_subtree_array(ett
, array_length(ett
));
1463 proto_reg_handoff_juniper(void)
1465 dissector_handle_t juniper_atm1_handle
;
1466 dissector_handle_t juniper_atm2_handle
;
1467 dissector_handle_t juniper_pppoe_handle
;
1468 dissector_handle_t juniper_mlppp_handle
;
1469 dissector_handle_t juniper_mlfr_handle
;
1470 dissector_handle_t juniper_ether_handle
;
1471 dissector_handle_t juniper_ppp_handle
;
1472 dissector_handle_t juniper_frelay_handle
;
1473 dissector_handle_t juniper_chdlc_handle
;
1474 dissector_handle_t juniper_ggsn_handle
;
1475 dissector_handle_t juniper_vp_handle
;
1476 dissector_handle_t juniper_svcs_handle
;
1478 osinl_incl_subdissector_table
= find_dissector_table("osinl.incl");
1479 osinl_excl_subdissector_table
= find_dissector_table("osinl.excl");
1481 eth_handle
= find_dissector("eth_withoutfcs");
1482 ppp_handle
= find_dissector("ppp");
1483 llc_handle
= find_dissector("llc");
1484 ipv4_handle
= find_dissector("ip");
1485 ipv6_handle
= find_dissector("ipv6");
1486 mpls_handle
= find_dissector("mpls");
1487 q933_handle
= find_dissector("q933");
1488 frelay_handle
= find_dissector("fr");
1489 chdlc_handle
= find_dissector("chdlc");
1490 data_handle
= find_dissector("data");
1492 juniper_atm2_handle
= create_dissector_handle(dissect_juniper_atm2
, proto_juniper
);
1493 juniper_atm1_handle
= create_dissector_handle(dissect_juniper_atm1
, proto_juniper
);
1494 juniper_pppoe_handle
= create_dissector_handle(dissect_juniper_pppoe
, proto_juniper
);
1495 juniper_mlppp_handle
= create_dissector_handle(dissect_juniper_mlppp
, proto_juniper
);
1496 juniper_mlfr_handle
= create_dissector_handle(dissect_juniper_mlfr
, proto_juniper
);
1497 juniper_ether_handle
= create_dissector_handle(dissect_juniper_ether
, proto_juniper
);
1498 juniper_ppp_handle
= create_dissector_handle(dissect_juniper_ppp
, proto_juniper
);
1499 juniper_frelay_handle
= create_dissector_handle(dissect_juniper_frelay
, proto_juniper
);
1500 juniper_chdlc_handle
= create_dissector_handle(dissect_juniper_chdlc
, proto_juniper
);
1501 juniper_ggsn_handle
= create_dissector_handle(dissect_juniper_ggsn
, proto_juniper
);
1502 juniper_vp_handle
= create_dissector_handle(dissect_juniper_vp
, proto_juniper
);
1503 juniper_svcs_handle
= create_dissector_handle(dissect_juniper_svcs
, proto_juniper
);
1505 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_ATM2
, juniper_atm2_handle
);
1506 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_ATM1
, juniper_atm1_handle
);
1507 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_PPPOE
, juniper_pppoe_handle
);
1508 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_MLPPP
, juniper_mlppp_handle
);
1509 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_MLFR
, juniper_mlfr_handle
);
1510 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_ETHER
, juniper_ether_handle
);
1511 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_PPP
, juniper_ppp_handle
);
1512 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_FRELAY
, juniper_frelay_handle
);
1513 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_CHDLC
, juniper_chdlc_handle
);
1514 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_GGSN
, juniper_ggsn_handle
);
1515 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_VP
, juniper_vp_handle
);
1516 dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_SVCS
, juniper_svcs_handle
);