2 * Routines for IEEE 802.2 LLC layer
3 * Gilbert Ramirez <gram@alumni.rice.edu>
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 <wsutil/pint.h>
32 #include <epan/xdlc.h>
33 #include <epan/etypes.h>
34 #include <epan/llcsaps.h>
35 #include <epan/bridged_pids.h>
36 #include <epan/ppptypes.h>
37 #include <epan/arcnet_pids.h>
38 #include <epan/conversation.h>
39 #include "packet-scsi.h"
40 #include "packet-fc.h"
41 #include "packet-ip.h"
42 #include "packet-ipx.h"
43 #include "packet-netbios.h"
44 #include "packet-vines.h"
45 #include "packet-sll.h"
46 #include <epan/sna-utils.h>
48 #include "packet-llc.h"
50 #define UDP_PORT_LLC1 12000
51 #define UDP_PORT_LLC2 12001
52 #define UDP_PORT_LLC3 12002
53 #define UDP_PORT_LLC4 12003
54 #define UDP_PORT_LLC5 12004
56 static int proto_llc
= -1;
57 static int hf_llc_dsap
= -1;
58 static int hf_llc_ssap
= -1;
59 static int hf_llc_dsap_ig
= -1;
60 static int hf_llc_ssap_cr
= -1;
61 static int hf_llc_ctrl
= -1;
62 static int hf_llc_n_r
= -1;
63 static int hf_llc_n_s
= -1;
64 static int hf_llc_p
= -1;
65 static int hf_llc_p_ext
= -1;
66 static int hf_llc_f
= -1;
67 static int hf_llc_f_ext
= -1;
68 static int hf_llc_s_ftype
= -1;
69 static int hf_llc_u_modifier_cmd
= -1;
70 static int hf_llc_u_modifier_resp
= -1;
71 static int hf_llc_ftype_i
= -1;
72 static int hf_llc_ftype_s_u
= -1;
73 static int hf_llc_ftype_s_u_ext
= -1;
74 static int hf_llc_type
= -1;
75 static int hf_llc_oui
= -1;
76 static int hf_llc_pid
= -1;
78 static int proto_basicxid
= -1;
79 static int hf_llc_xid_format
= -1;
80 static int hf_llc_xid_types
= -1;
81 static int hf_llc_xid_wsize
= -1;
83 static gint ett_llc
= -1;
84 static gint ett_llc_ctrl
= -1;
85 static gint ett_llc_basicxid
= -1;
87 static dissector_table_t dsap_subdissector_table
;
88 static dissector_table_t xid_subdissector_table
;
90 static dissector_table_t ethertype_subdissector_table
;
91 static dissector_table_t hpteam_subdissector_table
;
93 static dissector_handle_t bpdu_handle
;
94 static dissector_handle_t eth_withoutfcs_handle
;
95 static dissector_handle_t eth_withfcs_handle
;
96 static dissector_handle_t fddi_handle
;
97 static dissector_handle_t tr_handle
;
98 static dissector_handle_t turbo_handle
;
99 static dissector_handle_t mesh_handle
;
100 static dissector_handle_t data_handle
;
103 * Group/Individual bit, in the DSAP.
105 #define DSAP_GI_BIT 0x01
108 * Command/Response bit, in the SSAP.
110 * The low-order bit of the SSAP apparently determines whether this
111 * is a request or a response. (RFC 1390, "Transmission of IP and
112 * ARP over FDDI Networks", says
114 * Command frames are identified by having the low order
115 * bit of the SSAP address reset to zero. Response frames
116 * have the low order bit of the SSAP address set to one.
118 * and a page I've seen seems to imply that's part of 802.2.)
120 #define SSAP_CR_BIT 0x01
123 * Mask to extrace the SAP number from the DSAP or the SSAP.
125 #define SAP_MASK 0xFE
128 * These are for SSAP and DSAP, wth last bit always zero.
129 * XXX - some DSAPs come in separate "individual" and "group" versions,
130 * with the last bit 0 and 1, respectively (e.g., LLC Sub-layer Management,
131 * IBM SNA Path Control, IBM Net Management), but, whilst 0xFE is
132 * the ISO Network Layer Protocol, 0xFF is the Global LSAP.
134 const value_string sap_vals
[] = {
135 { SAP_NULL
, "NULL LSAP" },
136 { SAP_LLC_SLMGMT
, "LLC Sub-Layer Management" },
137 { SAP_SNA_PATHCTRL
, "SNA Path Control" },
138 { SAP_IP
, "TCP/IP" },
141 { SAP_PROWAY_NM_INIT
, "PROWAY (IEC955) Network Management and Initialization" },
142 { SAP_NETWARE1
, "NetWare (unofficial?)" },
143 { SAP_OSINL1
, "ISO Network Layer (OSLAN 1)" },
144 { SAP_TI
, "Texas Instruments" },
145 { SAP_OSINL2
, "ISO Network Layer (unofficial?)" },
146 { SAP_OSINL3
, "ISO Network Layer (unofficial?)" },
147 { SAP_BPDU
, "Spanning Tree BPDU" },
148 { SAP_RS511
, "EIA RS-511 Manufacturing Message Service" },
149 { SAP_OSINL4
, "ISO Network Layer (OSLAN 2)" },
150 { SAP_X25
, "ISO 8208 (X.25 over 802.2)" },
152 * XXX - setting the group bit of SAP_X25 make 0x7F; is this just
153 * a group version of that?
155 { 0x7F, "ISO 802.2" },
157 { SAP_BACNET
, "BACnet" },
158 { SAP_NESTAR
, "Nestar" },
159 { SAP_PROWAY_ASLM
, "PROWAY (IEC955) Active Station List Maintenance" },
160 { SAP_ARP
, "ARP" }, /* XXX - hand to "dissect_arp()"? */
161 { SAP_HPJD
, "HP JetDirect Printer" },
162 { SAP_SNAP
, "SNAP" },
163 { SAP_VINES1
, "Banyan Vines" },
164 { SAP_VINES2
, "Banyan Vines" },
165 { SAP_NETWARE2
, "NetWare" },
166 { SAP_NETBIOS
, "NetBIOS" },
167 { SAP_IBMNM
, "IBM Net Management" },
168 { SAP_HPEXT
, "HP Extended LLC" },
169 { SAP_UB
, "Ungermann-Bass" },
170 { SAP_RPL
, "Remote Program Load" },
171 { SAP_OSINL5
, "ISO Network Layer" },
172 { SAP_GLOBAL
, "Global LSAP" },
179 * http://standards.ieee.org/regauth/oui/oui.txt
181 * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/vlan.htm
183 * for the PIDs for VTP and DRiP that go with an OUI of OUI_CISCO.
185 const value_string oui_vals
[] = {
186 { OUI_ENCAP_ETHER
, "Encapsulated Ethernet" },
187 { OUI_XEROX
, "Xerox" },
189 http://www.cisco.com/univercd/cc/td/doc/product/software/ios113ed/113ed_cr/ibm_r/brprt1/brsrb.htm
191 { OUI_CISCO
, "Cisco" },
192 { OUI_NORTEL
, "Nortel Discovery Protocol" },
193 { OUI_CISCO_90
, "Cisco IOS 9.0 Compatible" },
194 { OUI_FORCE10
, "Force10 Networks" },
195 { OUI_ERICSSON
, "Ericsson Group" },
196 { OUI_CATENA
, "Catena Networks" },
197 { OUI_SONY_ERICSSON
, "Sony Ericsson Mobile Communications AB" },
198 { OUI_SONY_ERICSSON_2
, "Sony Ericsson Mobile Communications AB" },
199 { OUI_PROFINET
, "PROFIBUS Nutzerorganisation e.V." },
200 { OUI_SONY_ERICSSON_3
, "Sony Ericsson Mobile Communications AB" },
201 { OUI_CIMETRICS
, "Cimetrics" },
202 { OUI_IEEE_802_3
, "IEEE 802.3" },
203 { OUI_MEDIA_ENDPOINT
, "Media (TIA TR-41 Committee)" },
204 { OUI_SONY_ERICSSON_4
, "Sony Ericsson Mobile Communications AB" },
205 { OUI_ERICSSON_MOBILE
, "Ericsson Mobile Platforms" },
206 { OUI_SONY_ERICSSON_5
, "Sony Ericsson Mobile Communications AB" },
207 { OUI_SONY_ERICSSON_6
, "Sony Ericsson Mobile Communications AB" },
208 { OUI_SONY_ERICSSON_7
, "Sony Ericsson Mobile Communications AB" },
209 { OUI_BLUETOOTH
, "Bluetooth SIG, Inc." },
210 { OUI_SONY_ERICSSON_8
, "Sony Ericsson Mobile Communications AB" },
211 { OUI_IEEE_802_1QBG
, "IEEE 802.1Qbg" },
212 { OUI_TURBOCELL
, "Karlnet (Turbocell)" },
213 { OUI_CISCOWL
, "Cisco Wireless (Aironet) L2" },
214 { OUI_MARVELL
, "Marvell Semiconductor" },
215 { OUI_BRIDGED
, "Frame Relay or ATM bridged frames" },
216 { OUI_IEEE_802_1
, "IEEE 802.1 Committee" },
217 { OUI_ATM_FORUM
, "ATM Forum" },
218 { OUI_EXTREME
, "Extreme Networks" },
219 /* RFC 2427, RFC 2684 */
220 { OUI_CABLE_BPDU
, "DOCSIS Spanning Tree" }, /* DOCSIS spanning tree BPDU */
221 { OUI_SIEMENS
, "Siemens AG" },
222 { OUI_APPLE_ATALK
, "Apple (AppleTalk)" },
223 { OUI_HP
, "Hewlett-Packard" },
224 { OUI_HP_2
, "Hewlett-Packard" },
225 /* Registry Name: PPP Vendor Specific OUI Options */
226 { OUI_3GPP2
, "3GPP2 Vendor specific packet ID" },
227 { OUI_ERICSSON_2
, "Ericsson Group" },
231 static const value_string format_vals
[] = {
232 { 0x81, "LLC basic format" },
237 * Mask to extract the type from XID frame.
239 #define TYPES_MASK 0x1F
241 static const value_string type_vals
[] = {
242 { 1, "Type 1 LLC (Class I LLC)" },
244 { 3, "Type 1 and Type 2 LLCs (Class II LLC)" },
246 { 5, "Type 1 and Type 3 LLCs (Class III LLC)" },
247 { 6, "Type 2 and Type 3 LLCs" },
248 { 7, "Type 1 and Type 2 and Type 3 LLCs (Class IV LLC)" },
253 * Hash table for translating OUIs to an oui_info_t.
255 static GHashTable
*oui_info_table
= NULL
;
258 * Add an entry for a new OUI.
261 llc_add_oui(guint32 oui
, const char *table_name
, const char *table_ui_name
,
262 hf_register_info
*hf_item
)
264 oui_info_t
*new_info
;
266 new_info
= (oui_info_t
*)g_malloc(sizeof (oui_info_t
));
267 new_info
->table
= register_dissector_table(table_name
,
268 table_ui_name
, FT_UINT16
, BASE_HEX
);
269 new_info
->field_info
= hf_item
;
272 * Create the hash table for OUI information, if it doesn't
275 if (oui_info_table
== NULL
) {
276 oui_info_table
= g_hash_table_new(g_direct_hash
,
279 g_hash_table_insert(oui_info_table
, GUINT_TO_POINTER(oui
), new_info
);
283 capture_llc(const guchar
*pd
, int offset
, int len
, packet_counts
*ld
) {
289 if (!BYTES_ARE_IN_FRAME(offset
, len
, 2)) {
293 is_snap
= (pd
[offset
] == SAP_SNAP
) && (pd
[offset
+1] == SAP_SNAP
);
294 llc_header_len
= 2; /* DSAP + SSAP */
297 * XXX - the page referred to in the comment above about the
298 * Command/Response bit also implies that LLC Type 2 always
299 * uses extended operation, so we don't need to determine
300 * whether it's basic or extended operation; is that the case?
302 control
= get_xdlc_control(pd
, offset
+2, pd
[offset
+1] & SSAP_CR_BIT
);
303 llc_header_len
+= XDLC_CONTROL_LEN(control
, TRUE
);
304 if (!BYTES_ARE_IN_FRAME(offset
, len
, llc_header_len
)) {
309 if (!XDLC_IS_INFORMATION(control
)) {
314 capture_snap(pd
, offset
+llc_header_len
, len
, ld
);
317 switch (pd
[offset
]) {
320 capture_ip(pd
, offset
+ llc_header_len
, len
, ld
);
345 capture_snap(const guchar
*pd
, int offset
, int len
, packet_counts
*ld
)
350 if (!BYTES_ARE_IN_FRAME(offset
, len
, 5)) {
355 oui
= pd
[offset
] << 16 | pd
[offset
+1] << 8 | pd
[offset
+2];
356 etype
= pntohs(&pd
[offset
+3]);
359 case OUI_ENCAP_ETHER
:
361 case OUI_APPLE_ATALK
:
362 /* No, I have no idea why Apple used
363 one of their own OUIs, rather than
364 OUI_ENCAP_ETHER, and an Ethernet
365 packet type as protocol ID, for
366 AppleTalk data packets - but used
367 OUI_ENCAP_ETHER and an Ethernet
368 packet type for AARP packets. */
369 capture_ethertype(etype
, pd
, offset
+5, len
, ld
);
373 capture_ethertype(etype
, pd
, offset
+5, len
, ld
);
378 * OLPC packet. The PID is an Ethertype, but
379 * there's a mesh header between the PID and
380 * the payload. (We assume the header is
383 capture_ethertype(etype
, pd
, offset
+5+5, len
, ld
);
392 /* Used only for U frames */
393 static const xdlc_cf_items llc_cf_items
= {
399 &hf_llc_u_modifier_cmd
,
400 &hf_llc_u_modifier_resp
,
405 /* Used only for I and S frames */
406 static const xdlc_cf_items llc_cf_items_ext
= {
415 &hf_llc_ftype_s_u_ext
419 dissect_basicxid(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
421 proto_tree
*xid_tree
= NULL
;
422 proto_item
*ti
= NULL
;
423 guint8 format
, types
, wsize
;
425 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "XID");
426 col_clear(pinfo
->cinfo
, COL_INFO
);
428 format
= tvb_get_guint8(tvb
, 0);
430 ti
= proto_tree_add_item(tree
, proto_basicxid
, tvb
, 0, -1, ENC_NA
);
431 xid_tree
= proto_item_add_subtree(ti
, ett_llc_basicxid
);
432 proto_tree_add_uint(xid_tree
, hf_llc_xid_format
, tvb
, 0,
436 col_append_str(pinfo
->cinfo
, COL_INFO
,
439 types
= tvb_get_guint8(tvb
, 1);
441 proto_tree_add_uint(xid_tree
, hf_llc_xid_types
, tvb
, 1,
442 1, types
& TYPES_MASK
);
444 col_append_fstr(pinfo
->cinfo
, COL_INFO
,
445 "; %s", val_to_str(types
& TYPES_MASK
, type_vals
, "0x%02x")
448 wsize
= tvb_get_guint8(tvb
, 2);
450 proto_tree_add_uint(xid_tree
, hf_llc_xid_wsize
, tvb
, 2,
451 1, (wsize
& 0xFE) >> 1);
453 col_append_fstr(pinfo
->cinfo
, COL_INFO
,
454 "; Window Size %d", (wsize
& 0xFE) >> 1);
458 dissect_llc(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
460 proto_tree
*llc_tree
= NULL
;
461 proto_item
*ti
= NULL
;
465 guint8 dsap
, ssap
, format
;
468 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "LLC");
469 col_clear(pinfo
->cinfo
, COL_INFO
);
471 dsap
= tvb_get_guint8(tvb
, 0);
473 ti
= proto_tree_add_item(tree
, proto_llc
, tvb
, 0, -1, ENC_NA
);
474 llc_tree
= proto_item_add_subtree(ti
, ett_llc
);
475 proto_tree_add_uint(llc_tree
, hf_llc_dsap
, tvb
, 0,
477 proto_tree_add_boolean(llc_tree
, hf_llc_dsap_ig
, tvb
, 0,
478 1, dsap
& DSAP_GI_BIT
);
482 ssap
= tvb_get_guint8(tvb
, 1);
484 proto_tree_add_uint(llc_tree
, hf_llc_ssap
, tvb
, 1,
486 proto_tree_add_boolean(llc_tree
, hf_llc_ssap_cr
, tvb
, 1,
487 1, ssap
& SSAP_CR_BIT
);
491 is_snap
= (dsap
== SAP_SNAP
) && (ssap
== SAP_SNAP
);
492 llc_header_len
= 2; /* DSAP + SSAP */
495 * XXX - the page referred to in the comment above about the
496 * Command/Response bit also implies that LLC Type 2 always
497 * uses extended operation, so we don't need to determine
498 * whether it's basic or extended operation; is that the case?
500 control
= dissect_xdlc_control(tvb
, 2, pinfo
, llc_tree
,
501 hf_llc_ctrl
, ett_llc_ctrl
,
502 &llc_cf_items
, &llc_cf_items_ext
,
503 NULL
, NULL
, ssap
& SSAP_CR_BIT
, TRUE
, FALSE
);
504 llc_header_len
+= XDLC_CONTROL_LEN(control
, TRUE
);
506 llc_header_len
+= 5; /* 3 bytes of OUI, 2 bytes of protocol ID */
509 proto_item_set_len(ti
, llc_header_len
);
512 dissect_snap(tvb
, 2+XDLC_CONTROL_LEN(control
, TRUE
), pinfo
, tree
, llc_tree
, control
,
513 hf_llc_oui
, hf_llc_type
, hf_llc_pid
, 2);
516 col_append_fstr(pinfo
->cinfo
, COL_INFO
,
517 "; DSAP %s %s, SSAP %s %s",
518 val_to_str(dsap
& SAP_MASK
, sap_vals
, "0x%02x"),
520 "Group" : "Individual",
521 val_to_str(ssap
& SAP_MASK
, sap_vals
, "0x%02x"),
523 "Response" : "Command"
526 if (tvb_length_remaining(tvb
, llc_header_len
) > 0) {
527 next_tvb
= tvb_new_subset_remaining(tvb
, llc_header_len
);
528 if (XDLC_IS_INFORMATION(control
)) {
530 * Non-SNAP I or UI frame.
531 * Try the regular LLC subdissector table
534 if (!dissector_try_uint(dsap_subdissector_table
,
535 dsap
, next_tvb
, pinfo
, tree
)) {
536 call_dissector(data_handle
, next_tvb
,
539 } else if ((control
& (XDLC_U_MODIFIER_MASK
|XDLC_U
))
540 == (XDLC_XID
|XDLC_U
)) {
542 * Non-SNAP XID frame.
543 * Test for LLC basic format first
545 format
= tvb_get_guint8(next_tvb
, 0);
546 if (format
== 0x81) {
547 dissect_basicxid(next_tvb
, pinfo
, tree
);
550 * Try the XID LLC subdissector table
553 if (!dissector_try_uint(
554 xid_subdissector_table
, dsap
, next_tvb
,
556 call_dissector(data_handle
,
557 next_tvb
, pinfo
, tree
);
561 call_dissector(data_handle
, next_tvb
, pinfo
,
569 * Dissect SNAP header; used elsewhere, e.g. in the Frame Relay dissector.
572 dissect_snap(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo
, proto_tree
*tree
,
573 proto_tree
*snap_tree
, int control
, int hf_oui
, int hf_type
, int hf_pid
,
579 oui_info_t
*oui_info
;
580 dissector_table_t subdissector_table
;
585 * XXX - what about non-UI frames?
587 oui
= tvb_get_ntoh24(tvb
, offset
);
588 etype
= tvb_get_ntohs(tvb
, offset
+3);
590 col_append_fstr(pinfo
->cinfo
, COL_INFO
,
591 "; SNAP, OUI 0x%06X (%s), PID 0x%04X",
592 oui
, val_to_str_const(oui
, oui_vals
, "Unknown"), etype
);
594 proto_tree_add_uint(snap_tree
, hf_oui
, tvb
, offset
, 3, oui
);
599 oui_info
= get_snap_oui_info(oui
);
600 hf
= *oui_info
->field_info
->p_id
;
601 proto_tree_add_uint(snap_tree
, hf
, tvb
, offset
+3, 2, etype
);
602 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
604 if(!dissector_try_uint(hpteam_subdissector_table
,etype
, next_tvb
, pinfo
, tree
))
605 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
608 case OUI_ENCAP_ETHER
:
610 case OUI_APPLE_ATALK
:
611 /* No, I have no idea why Apple used
612 one of their own OUIs, rather than
613 OUI_ENCAP_ETHER, and an Ethernet
614 packet type as protocol ID, for
615 AppleTalk data packets - but used
616 OUI_ENCAP_ETHER and an Ethernet
617 packet type for AARP packets. */
618 if (XDLC_IS_INFORMATION(control
)) {
620 proto_tree_add_uint(snap_tree
, hf_type
,
621 tvb
, offset
+3, 2, etype
);
623 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
624 if (!dissector_try_uint(ethertype_subdissector_table
,
625 etype
, next_tvb
, pinfo
, tree
))
626 call_dissector(data_handle
, next_tvb
, pinfo
,
629 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
630 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
636 * MAC frames bridged over ATM (RFC 2684) or Frame Relay
639 * We have to figure out how much padding to put
640 * into the frame. We were handed a "bridge_pad"
641 * argument which should be 0 for Frame Relay and
642 * 2 for ATM; we add to that the amount of padding
643 * common to both bridging types.
646 proto_tree_add_uint(snap_tree
, hf_pid
, tvb
, offset
+3, 2,
652 case BPID_ETH_WITH_FCS
:
653 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5+bridge_pad
);
654 call_dissector(eth_withfcs_handle
, next_tvb
, pinfo
,
658 case BPID_ETH_WITHOUT_FCS
:
659 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5+bridge_pad
);
660 call_dissector(eth_withoutfcs_handle
, next_tvb
, pinfo
, tree
);
663 case BPID_802_5_WITH_FCS
:
664 case BPID_802_5_WITHOUT_FCS
:
666 * We treat the last padding byte as the Access
667 * Control byte, as that's what the Token
668 * Ring dissector expects the first byte to
671 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5+bridge_pad
);
672 call_dissector(tr_handle
, next_tvb
, pinfo
, tree
);
675 case BPID_FDDI_WITH_FCS
:
676 case BPID_FDDI_WITHOUT_FCS
:
677 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5+1+bridge_pad
);
678 call_dissector(fddi_handle
, next_tvb
, pinfo
, tree
);
682 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
683 call_dissector(bpdu_handle
, next_tvb
, pinfo
, tree
);
687 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
688 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
693 case OUI_CABLE_BPDU
: /* DOCSIS cable modem spanning tree BPDU */
695 proto_tree_add_uint(snap_tree
, hf_pid
, tvb
, offset
+3, 2,
698 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
699 call_dissector(bpdu_handle
, next_tvb
, pinfo
, tree
);
703 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+3);
704 call_dissector(turbo_handle
, next_tvb
, pinfo
, tree
);
709 * OLPC packet. The PID is an Ethertype, but
710 * there's a mesh header between the PID and
713 if (XDLC_IS_INFORMATION(control
)) {
715 proto_tree_add_uint(snap_tree
, hf_type
,
716 tvb
, offset
+3, 2, etype
);
718 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
719 mesh_header_len
= call_dissector(mesh_handle
,
720 next_tvb
, pinfo
, tree
);
721 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5+mesh_header_len
);
722 if (!dissector_try_uint(ethertype_subdissector_table
,
723 etype
, next_tvb
, pinfo
, tree
))
724 call_dissector(data_handle
, next_tvb
, pinfo
,
727 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
728 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
734 * Do we have information for this OUI?
736 oui_info
= get_snap_oui_info(oui
);
737 if (oui_info
!= NULL
) {
741 hf
= *oui_info
->field_info
->p_id
;
742 subdissector_table
= oui_info
->table
;
745 * No, use hf_pid for the PID and just dissect
746 * the payload as data.
749 subdissector_table
= NULL
;
752 proto_tree_add_uint(snap_tree
, hf
, tvb
, offset
+3, 2,
755 next_tvb
= tvb_new_subset_remaining(tvb
, offset
+5);
756 if (XDLC_IS_INFORMATION(control
)) {
757 if (subdissector_table
!= NULL
) {
758 /* do lookup with the subdissector table */
759 if (dissector_try_uint(subdissector_table
,
760 etype
, next_tvb
, pinfo
, tree
))
764 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
770 * Return the oui_info_t for the PID for a particular OUI value, or NULL
771 * if there isn't one.
774 get_snap_oui_info(guint32 oui
)
776 if (oui_info_table
!= NULL
) {
777 return (oui_info_t
*)g_hash_table_lookup(oui_info_table
,
778 GUINT_TO_POINTER(oui
));
784 proto_register_llc(void)
786 static struct true_false_string ig_bit
= { "Group", "Individual" };
787 static struct true_false_string cr_bit
= { "Response", "Command" };
789 static hf_register_info hf
[] = {
791 { "DSAP", "llc.dsap", FT_UINT8
, BASE_HEX
,
792 VALS(sap_vals
), 0x0, "DSAP - 7 Most Significant Bits only", HFILL
}},
795 { "IG Bit", "llc.dsap.ig", FT_BOOLEAN
, BASE_NONE
,
796 TFS(&ig_bit
), 0x0, "Individual/Group - Least Significant Bit only", HFILL
}},
799 { "SSAP", "llc.ssap", FT_UINT8
, BASE_HEX
,
800 VALS(sap_vals
), 0x0, "SSAP - 7 Most Significant Bits only", HFILL
}},
803 { "CR Bit", "llc.ssap.cr", FT_BOOLEAN
, BASE_NONE
,
804 TFS(&cr_bit
), 0x0, "Command/Response - Least Significant Bit only", HFILL
}},
807 { "Control", "llc.control", FT_UINT16
, BASE_HEX
,
808 NULL
, 0x0, NULL
, HFILL
}},
811 { "N(R)", "llc.control.n_r", FT_UINT16
, BASE_DEC
,
812 NULL
, XDLC_N_R_EXT_MASK
, NULL
, HFILL
}},
815 { "N(S)", "llc.control.n_s", FT_UINT16
, BASE_DEC
,
816 NULL
, XDLC_N_S_EXT_MASK
, NULL
, HFILL
}},
819 { "Poll", "llc.control.p", FT_BOOLEAN
, 8,
820 TFS(&tfs_set_notset
), XDLC_P_F
, NULL
, HFILL
}},
823 { "Poll", "llc.control.p", FT_BOOLEAN
, 16,
824 TFS(&tfs_set_notset
), XDLC_P_F_EXT
, NULL
, HFILL
}},
827 { "Final", "llc.control.f", FT_BOOLEAN
, 8,
828 TFS(&tfs_set_notset
), XDLC_P_F
, NULL
, HFILL
}},
831 { "Final", "llc.control.f", FT_BOOLEAN
, 16,
832 TFS(&tfs_set_notset
), XDLC_P_F_EXT
, NULL
, HFILL
}},
835 { "Supervisory frame type", "llc.control.s_ftype", FT_UINT16
, BASE_HEX
,
836 VALS(stype_vals
), XDLC_S_FTYPE_MASK
, NULL
, HFILL
}},
838 { &hf_llc_u_modifier_cmd
,
839 { "Command", "llc.control.u_modifier_cmd", FT_UINT8
, BASE_HEX
,
840 VALS(modifier_vals_cmd
), XDLC_U_MODIFIER_MASK
, NULL
, HFILL
}},
842 { &hf_llc_u_modifier_resp
,
843 { "Response", "llc.control.u_modifier_resp", FT_UINT8
, BASE_HEX
,
844 VALS(modifier_vals_resp
), XDLC_U_MODIFIER_MASK
, NULL
, HFILL
}},
847 { "Frame type", "llc.control.ftype", FT_UINT16
, BASE_HEX
,
848 VALS(ftype_vals
), XDLC_I_MASK
, NULL
, HFILL
}},
851 { "Frame type", "llc.control.ftype", FT_UINT8
, BASE_HEX
,
852 VALS(ftype_vals
), XDLC_S_U_MASK
, NULL
, HFILL
}},
854 { &hf_llc_ftype_s_u_ext
,
855 { "Frame type", "llc.control.ftype", FT_UINT16
, BASE_HEX
,
856 VALS(ftype_vals
), XDLC_S_U_MASK
, NULL
, HFILL
}},
858 /* registered here but handled in ethertype.c */
860 { "Type", "llc.type", FT_UINT16
, BASE_HEX
,
861 VALS(etype_vals
), 0x0, NULL
, HFILL
}},
864 { "Organization Code", "llc.oui", FT_UINT24
, BASE_HEX
,
865 VALS(oui_vals
), 0x0, NULL
, HFILL
}},
868 { "Protocol ID", "llc.pid", FT_UINT16
, BASE_HEX
,
869 NULL
, 0x0, NULL
, HFILL
}}
871 static gint
*ett
[] = {
876 proto_llc
= proto_register_protocol("Logical-Link Control", "LLC", "llc");
877 proto_register_field_array(proto_llc
, hf
, array_length(hf
));
878 proto_register_subtree_array(ett
, array_length(ett
));
880 /* subdissector code */
881 dsap_subdissector_table
= register_dissector_table("llc.dsap",
882 "LLC SAP", FT_UINT8
, BASE_HEX
);
883 xid_subdissector_table
= register_dissector_table("llc.xid_dsap",
884 "LLC XID SAP", FT_UINT8
, BASE_HEX
);
886 register_dissector("llc", dissect_llc
, proto_llc
);
890 proto_register_basicxid(void)
892 static hf_register_info hf
[] = {
893 { &hf_llc_xid_format
,
894 { "XID Format", "basicxid.llc.xid.format", FT_UINT8
, BASE_HEX
,
895 VALS(format_vals
), 0x0, NULL
, HFILL
}},
898 { "LLC Types/Classes", "basicxid.llc.xid.types", FT_UINT8
, BASE_HEX
,
899 VALS(type_vals
), 0x0, NULL
, HFILL
}},
902 { "Receive Window Size", "basicxid.llc.xid.wsize", FT_UINT8
, BASE_DEC
,
903 NULL
, 0x0, NULL
, HFILL
}}
905 static gint
*ett
[] = {
909 proto_basicxid
= proto_register_protocol("Logical-Link Control Basic Format XID", "Basic Format XID", "basicxid");
910 proto_register_field_array(proto_basicxid
, hf
, array_length(hf
));
911 proto_register_subtree_array(ett
, array_length(ett
));
913 register_dissector("basicxid", dissect_basicxid
, proto_basicxid
);
917 register_hf(gpointer key _U_
, gpointer value
, gpointer user_data _U_
)
919 oui_info_t
*info
= (oui_info_t
*)value
;
921 proto_register_field_array(proto_llc
, info
->field_info
, 1);
925 proto_reg_handoff_llc(void)
927 dissector_handle_t llc_handle
;
930 * Get handles for the BPDU, Ethernet, FDDI, Token Ring and
931 * Turbocell dissectors.
933 bpdu_handle
= find_dissector("bpdu");
934 eth_withoutfcs_handle
= find_dissector("eth_withoutfcs");
935 eth_withfcs_handle
= find_dissector("eth_withfcs");
936 fddi_handle
= find_dissector("fddi");
937 tr_handle
= find_dissector("tr");
938 turbo_handle
= find_dissector("turbocell");
939 mesh_handle
= find_dissector("mesh");
940 data_handle
= find_dissector("data");
943 * Get the Ethertype dissector table.
945 ethertype_subdissector_table
= find_dissector_table("ethertype");
946 hpteam_subdissector_table
= find_dissector_table("llc.hpteam_pid");
948 llc_handle
= find_dissector("llc");
949 dissector_add_uint("wtap_encap", WTAP_ENCAP_ATM_RFC1483
, llc_handle
);
950 dissector_add_uint("sll.ltype", LINUX_SLL_P_802_2
, llc_handle
);
952 dissector_add_uint("ppp.protocol", PPP_LLC
, llc_handle
);
954 dissector_add_uint("udp.port", UDP_PORT_LLC1
, llc_handle
);
955 dissector_add_uint("udp.port", UDP_PORT_LLC2
, llc_handle
);
956 dissector_add_uint("udp.port", UDP_PORT_LLC3
, llc_handle
);
957 dissector_add_uint("udp.port", UDP_PORT_LLC4
, llc_handle
);
958 dissector_add_uint("udp.port", UDP_PORT_LLC5
, llc_handle
);
959 /* IP-over-FC when we have the full FC frame */
960 dissector_add_uint("fc.ftype", FC_FTYPE_IP
, llc_handle
);
963 * BACNET-over-ARCNET is really BACNET-over-802.2 LLC-over-ARCNET,
966 dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_BACNET
, llc_handle
);
967 dissector_add_uint("ethertype", ETHERTYPE_JUMBO_LLC
, llc_handle
);
970 * Register all the fields for PIDs for various OUIs.
972 if (oui_info_table
!= NULL
)
973 g_hash_table_foreach(oui_info_table
, register_hf
, NULL
);