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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
33 #include <epan/xdlc.h>
34 #include <epan/etypes.h>
35 #include <epan/llcsaps.h>
36 #include <epan/bridged_pids.h>
37 #include <epan/ppptypes.h>
38 #include <epan/arcnet_pids.h>
39 #include <epan/conversation.h>
40 #include "packet-scsi.h"
41 #include "packet-fc.h"
42 #include "packet-ip.h"
43 #include "packet-ipx.h"
44 #include "packet-netbios.h"
45 #include "packet-vines.h"
46 #include "packet-sll.h"
47 #include <epan/sna-utils.h>
49 #include "packet-llc.h"
51 #define UDP_PORT_LLC1 12000
52 #define UDP_PORT_LLC2 12001
53 #define UDP_PORT_LLC3 12002
54 #define UDP_PORT_LLC4 12003
55 #define UDP_PORT_LLC5 12004
57 static int proto_llc = -1;
58 static int hf_llc_dsap = -1;
59 static int hf_llc_ssap = -1;
60 static int hf_llc_dsap_ig = -1;
61 static int hf_llc_ssap_cr = -1;
62 static int hf_llc_ctrl = -1;
63 static int hf_llc_n_r = -1;
64 static int hf_llc_n_s = -1;
65 static int hf_llc_p = -1;
66 static int hf_llc_p_ext = -1;
67 static int hf_llc_f = -1;
68 static int hf_llc_f_ext = -1;
69 static int hf_llc_s_ftype = -1;
70 static int hf_llc_u_modifier_cmd = -1;
71 static int hf_llc_u_modifier_resp = -1;
72 static int hf_llc_ftype_i = -1;
73 static int hf_llc_ftype_s_u = -1;
74 static int hf_llc_ftype_s_u_ext = -1;
75 static int hf_llc_type = -1;
76 static int hf_llc_oui = -1;
77 static int hf_llc_pid = -1;
79 static int proto_basicxid = -1;
80 static int hf_llc_xid_format = -1;
81 static int hf_llc_xid_types = -1;
82 static int hf_llc_xid_wsize = -1;
84 static gint ett_llc = -1;
85 static gint ett_llc_ctrl = -1;
86 static gint ett_llc_basicxid = -1;
88 static dissector_table_t dsap_subdissector_table;
89 static dissector_table_t xid_subdissector_table;
91 static dissector_table_t ethertype_subdissector_table;
92 static dissector_table_t hpteam_subdissector_table;
94 static dissector_handle_t bpdu_handle;
95 static dissector_handle_t eth_withoutfcs_handle;
96 static dissector_handle_t eth_withfcs_handle;
97 static dissector_handle_t fddi_handle;
98 static dissector_handle_t tr_handle;
99 static dissector_handle_t turbo_handle;
100 static dissector_handle_t mesh_handle;
101 static dissector_handle_t data_handle;
104 * Group/Individual bit, in the DSAP.
106 #define DSAP_GI_BIT 0x01
109 * Command/Response bit, in the SSAP.
111 * The low-order bit of the SSAP apparently determines whether this
112 * is a request or a response. (RFC 1390, "Transmission of IP and
113 * ARP over FDDI Networks", says
115 * Command frames are identified by having the low order
116 * bit of the SSAP address reset to zero. Response frames
117 * have the low order bit of the SSAP address set to one.
119 * and a page I've seen seems to imply that's part of 802.2.)
121 #define SSAP_CR_BIT 0x01
124 * Mask to extrace the SAP number from the DSAP or the SSAP.
126 #define SAP_MASK 0xFE
129 * These are for SSAP and DSAP, wth last bit always zero.
130 * XXX - some DSAPs come in separate "individual" and "group" versions,
131 * with the last bit 0 and 1, respectively (e.g., LLC Sub-layer Management,
132 * IBM SNA Path Control, IBM Net Management), but, whilst 0xFE is
133 * the ISO Network Layer Protocol, 0xFF is the Global LSAP.
135 const value_string sap_vals[] = {
136 { SAP_NULL, "NULL LSAP" },
137 { SAP_LLC_SLMGMT, "LLC Sub-Layer Management" },
138 { SAP_SNA_PATHCTRL, "SNA Path Control" },
139 { SAP_IP, "TCP/IP" },
142 { SAP_PROWAY_NM_INIT, "PROWAY (IEC955) Network Management and Initialization" },
143 { SAP_NETWARE1, "NetWare (unofficial?)" },
144 { SAP_OSINL1, "ISO Network Layer (OSLAN 1)" },
145 { SAP_TI, "Texas Instruments" },
146 { SAP_OSINL2, "ISO Network Layer (unofficial?)" },
147 { SAP_OSINL3, "ISO Network Layer (unofficial?)" },
148 { SAP_BPDU, "Spanning Tree BPDU" },
149 { SAP_RS511, "EIA RS-511 Manufacturing Message Service" },
150 { SAP_OSINL4, "ISO Network Layer (OSLAN 2)" },
151 { SAP_X25, "ISO 8208 (X.25 over 802.2)" },
153 * XXX - setting the group bit of SAP_X25 make 0x7F; is this just
154 * a group version of that?
156 { 0x7F, "ISO 802.2" },
158 { SAP_BACNET, "BACnet" },
159 { SAP_NESTAR, "Nestar" },
160 { SAP_PROWAY_ASLM, "PROWAY (IEC955) Active Station List Maintenance" },
161 { SAP_ARP, "ARP" }, /* XXX - hand to "dissect_arp()"? */
162 { SAP_HPJD, "HP JetDirect Printer" },
163 { SAP_SNAP, "SNAP" },
164 { SAP_VINES1, "Banyan Vines" },
165 { SAP_VINES2, "Banyan Vines" },
166 { SAP_NETWARE2, "NetWare" },
167 { SAP_NETBIOS, "NetBIOS" },
168 { SAP_IBMNM, "IBM Net Management" },
169 { SAP_HPEXT, "HP Extended LLC" },
170 { SAP_UB, "Ungermann-Bass" },
171 { SAP_RPL, "Remote Program Load" },
172 { SAP_OSINL5, "ISO Network Layer" },
173 { SAP_GLOBAL, "Global LSAP" },
180 * http://standards.ieee.org/regauth/oui/oui.txt
182 * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/vlan.htm
184 * for the PIDs for VTP and DRiP that go with an OUI of OUI_CISCO.
186 const value_string oui_vals[] = {
187 { OUI_ENCAP_ETHER, "Encapsulated Ethernet" },
188 { OUI_XEROX, "Xerox" },
190 http://www.cisco.com/univercd/cc/td/doc/product/software/ios113ed/113ed_cr/ibm_r/brprt1/brsrb.htm
192 { OUI_CISCO, "Cisco" },
193 { OUI_NORTEL, "Nortel Discovery Protocol" },
194 { OUI_CISCO_90, "Cisco IOS 9.0 Compatible" },
195 { OUI_FORCE10, "Force10 Networks" },
196 { OUI_ERICSSON, "Ericsson Group" },
197 { OUI_CATENA, "Catena Networks" },
198 { OUI_SONY_ERICSSON, "Sony Ericsson Mobile Communications AB" },
199 { OUI_SONY_ERICSSON_2, "Sony Ericsson Mobile Communications AB" },
200 { OUI_PROFINET, "PROFIBUS Nutzerorganisation e.V." },
201 { OUI_SONY_ERICSSON_3, "Sony Ericsson Mobile Communications AB" },
202 { OUI_CIMETRICS, "Cimetrics" },
203 { OUI_IEEE_802_3, "IEEE 802.3" },
204 { OUI_MEDIA_ENDPOINT, "Media (TIA TR-41 Committee)" },
205 { OUI_SONY_ERICSSON_4, "Sony Ericsson Mobile Communications AB" },
206 { OUI_ERICSSON_MOBILE, "Ericsson Mobile Platforms" },
207 { OUI_SONY_ERICSSON_5, "Sony Ericsson Mobile Communications AB" },
208 { OUI_SONY_ERICSSON_6, "Sony Ericsson Mobile Communications AB" },
209 { OUI_SONY_ERICSSON_7, "Sony Ericsson Mobile Communications AB" },
210 { OUI_SONY_ERICSSON_8, "Sony Ericsson Mobile Communications AB" },
211 { OUI_TURBOCELL, "Karlnet (Turbocell)" },
212 { OUI_CISCOWL, "Cisco Wireless (Aironet) L2" },
213 { OUI_MARVELL, "Marvell Semiconductor" },
214 { OUI_BRIDGED, "Frame Relay or ATM bridged frames" },
215 { OUI_IEEE_802_1, "IEEE 802.1 Committee" },
216 { OUI_ATM_FORUM, "ATM Forum" },
217 { OUI_EXTREME, "Extreme Networks" },
218 /* RFC 2427, RFC 2684 */
219 { OUI_CABLE_BPDU, "DOCSIS Spanning Tree" }, /* DOCSIS spanning tree BPDU */
220 { OUI_SIEMENS, "Siemens AG" },
221 { OUI_APPLE_ATALK, "Apple (AppleTalk)" },
222 { OUI_HP, "Hewlett-Packard" },
223 { OUI_HP_2, "Hewlett-Packard" },
224 /* Registry Name: PPP Vendor Specific OUI Options */
225 { OUI_3GPP2, "3GPP2 Vendor specific packet ID" },
226 { OUI_ERICSSON_2, "Ericsson Group" },
230 static const value_string format_vals[] = {
231 { 0x81, "LLC basic format" },
236 * Mask to extract the type from XID frame.
238 #define TYPES_MASK 0x1F
240 static const value_string type_vals[] = {
241 { 1, "Type 1 LLC (Class I LLC)" },
243 { 3, "Type 1 and Type 2 LLCs (Class II LLC)" },
245 { 5, "Type 1 and Type 3 LLCs (Class III LLC)" },
246 { 6, "Type 2 and Type 3 LLCs" },
247 { 7, "Type 1 and Type 2 and Type 3 LLCs (Class IV LLC)" },
252 * Hash table for translating OUIs to an oui_info_t.
254 static GHashTable *oui_info_table = NULL;
257 * Add an entry for a new OUI.
260 llc_add_oui(guint32 oui, const char *table_name, const char *table_ui_name,
261 hf_register_info *hf_item)
263 oui_info_t *new_info;
265 new_info = g_malloc(sizeof (oui_info_t));
266 new_info->table = register_dissector_table(table_name,
267 table_ui_name, FT_UINT16, BASE_HEX);
268 new_info->field_info = hf_item;
271 * Create the hash table for OUI information, if it doesn't
274 if (oui_info_table == NULL) {
275 oui_info_table = g_hash_table_new(g_direct_hash,
278 g_hash_table_insert(oui_info_table, GUINT_TO_POINTER(oui), new_info);
282 capture_llc(const guchar *pd, int offset, int len, packet_counts *ld) {
288 if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
292 is_snap = (pd[offset] == SAP_SNAP) && (pd[offset+1] == SAP_SNAP);
293 llc_header_len = 2; /* DSAP + SSAP */
296 * XXX - the page referred to in the comment above about the
297 * Command/Response bit also implies that LLC Type 2 always
298 * uses extended operation, so we don't need to determine
299 * whether it's basic or extended operation; is that the case?
301 control = get_xdlc_control(pd, offset+2, pd[offset+1] & SSAP_CR_BIT);
302 llc_header_len += XDLC_CONTROL_LEN(control, TRUE);
303 if (!BYTES_ARE_IN_FRAME(offset, len, llc_header_len)) {
308 if (!XDLC_IS_INFORMATION(control)) {
313 capture_snap(pd, offset+llc_header_len, len, ld);
316 switch (pd[offset]) {
319 capture_ip(pd, offset + llc_header_len, len, ld);
344 capture_snap(const guchar *pd, int offset, int len, packet_counts *ld)
349 if (!BYTES_ARE_IN_FRAME(offset, len, 5)) {
354 oui = pd[offset] << 16 | pd[offset+1] << 8 | pd[offset+2];
355 etype = pntohs(&pd[offset+3]);
358 case OUI_ENCAP_ETHER:
360 case OUI_APPLE_ATALK:
361 /* No, I have no idea why Apple used
362 one of their own OUIs, rather than
363 OUI_ENCAP_ETHER, and an Ethernet
364 packet type as protocol ID, for
365 AppleTalk data packets - but used
366 OUI_ENCAP_ETHER and an Ethernet
367 packet type for AARP packets. */
368 capture_ethertype(etype, pd, offset+5, len, ld);
372 capture_ethertype(etype, pd, offset+5, len, ld);
377 * OLPC packet. The PID is an Ethertype, but
378 * there's a mesh header between the PID and
379 * the payload. (We assume the header is
382 capture_ethertype(etype, pd, offset+5+5, len, ld);
391 /* Used only for U frames */
392 static const xdlc_cf_items llc_cf_items = {
398 &hf_llc_u_modifier_cmd,
399 &hf_llc_u_modifier_resp,
404 /* Used only for I and S frames */
405 static const xdlc_cf_items llc_cf_items_ext = {
414 &hf_llc_ftype_s_u_ext
418 dissect_basicxid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
420 proto_tree *xid_tree = NULL;
421 proto_item *ti = NULL;
422 guint8 format, types, wsize;
424 col_set_str(pinfo->cinfo, COL_PROTOCOL, "XID");
425 col_clear(pinfo->cinfo, COL_INFO);
427 format = tvb_get_guint8(tvb, 0);
429 ti = proto_tree_add_item(tree, proto_basicxid, tvb, 0, -1, ENC_NA);
430 xid_tree = proto_item_add_subtree(ti, ett_llc_basicxid);
431 proto_tree_add_uint(xid_tree, hf_llc_xid_format, tvb, 0,
435 col_append_str(pinfo->cinfo, COL_INFO,
438 types = tvb_get_guint8(tvb, 1);
440 proto_tree_add_uint(xid_tree, hf_llc_xid_types, tvb, 1,
441 1, types & TYPES_MASK);
443 if (check_col(pinfo->cinfo, COL_INFO)) {
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 if (check_col(pinfo->cinfo, COL_INFO)) {
454 col_append_fstr(pinfo->cinfo, COL_INFO,
455 "; Window Size %d", (wsize & 0xFE) >> 1);
460 dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
462 proto_tree *llc_tree = NULL;
463 proto_item *ti = NULL;
467 guint8 dsap, ssap, format;
470 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LLC");
471 col_clear(pinfo->cinfo, COL_INFO);
473 dsap = tvb_get_guint8(tvb, 0);
475 ti = proto_tree_add_item(tree, proto_llc, tvb, 0, -1, ENC_NA);
476 llc_tree = proto_item_add_subtree(ti, ett_llc);
477 proto_tree_add_uint(llc_tree, hf_llc_dsap, tvb, 0,
479 proto_tree_add_boolean(llc_tree, hf_llc_dsap_ig, tvb, 0,
480 1, dsap & DSAP_GI_BIT);
484 ssap = tvb_get_guint8(tvb, 1);
486 proto_tree_add_uint(llc_tree, hf_llc_ssap, tvb, 1,
488 proto_tree_add_boolean(llc_tree, hf_llc_ssap_cr, tvb, 1,
489 1, ssap & SSAP_CR_BIT);
493 is_snap = (dsap == SAP_SNAP) && (ssap == SAP_SNAP);
494 llc_header_len = 2; /* DSAP + SSAP */
497 * XXX - the page referred to in the comment above about the
498 * Command/Response bit also implies that LLC Type 2 always
499 * uses extended operation, so we don't need to determine
500 * whether it's basic or extended operation; is that the case?
502 control = dissect_xdlc_control(tvb, 2, pinfo, llc_tree,
503 hf_llc_ctrl, ett_llc_ctrl,
504 &llc_cf_items, &llc_cf_items_ext,
505 NULL, NULL, ssap & SSAP_CR_BIT, TRUE, FALSE);
506 llc_header_len += XDLC_CONTROL_LEN(control, TRUE);
508 llc_header_len += 5; /* 3 bytes of OUI, 2 bytes of protocol ID */
511 proto_item_set_len(ti, llc_header_len);
514 dissect_snap(tvb, 2+XDLC_CONTROL_LEN(control, TRUE), pinfo, tree, llc_tree, control,
515 hf_llc_oui, hf_llc_type, hf_llc_pid, 2);
518 if (check_col(pinfo->cinfo, COL_INFO)) {
519 col_append_fstr(pinfo->cinfo, COL_INFO,
520 "; DSAP %s %s, SSAP %s %s",
521 val_to_str(dsap & SAP_MASK, sap_vals, "0x%02x"),
523 "Group" : "Individual",
524 val_to_str(ssap & SAP_MASK, sap_vals, "0x%02x"),
526 "Response" : "Command"
530 if (tvb_length_remaining(tvb, llc_header_len) > 0) {
531 next_tvb = tvb_new_subset_remaining(tvb, llc_header_len);
532 if (XDLC_IS_INFORMATION(control)) {
534 * Non-SNAP I or UI frame.
535 * Try the regular LLC subdissector table
538 if (!dissector_try_uint(dsap_subdissector_table,
539 dsap, next_tvb, pinfo, tree)) {
540 call_dissector(data_handle, next_tvb,
543 } else if ((control & (XDLC_U_MODIFIER_MASK|XDLC_U))
544 == (XDLC_XID|XDLC_U)) {
546 * Non-SNAP XID frame.
547 * Test for LLC basic format first
549 format = tvb_get_guint8(next_tvb, 0);
550 if (format == 0x81) {
551 dissect_basicxid(next_tvb, pinfo, tree);
554 * Try the XID LLC subdissector table
557 if (!dissector_try_uint(
558 xid_subdissector_table, dsap, next_tvb,
560 call_dissector(data_handle,
561 next_tvb, pinfo, tree);
565 call_dissector(data_handle, next_tvb, pinfo,
573 * Dissect SNAP header; used elsewhere, e.g. in the Frame Relay dissector.
576 dissect_snap(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,
577 proto_tree *snap_tree, int control, int hf_oui, int hf_type, int hf_pid,
583 oui_info_t *oui_info;
584 dissector_table_t subdissector_table;
589 * XXX - what about non-UI frames?
591 oui = tvb_get_ntoh24(tvb, offset);
592 etype = tvb_get_ntohs(tvb, offset+3);
594 if (check_col(pinfo->cinfo, COL_INFO)) {
595 col_append_fstr(pinfo->cinfo, COL_INFO,
596 "; SNAP, OUI 0x%06X (%s), PID 0x%04X",
597 oui, val_to_str(oui, oui_vals, "Unknown"), etype);
600 proto_tree_add_uint(snap_tree, hf_oui, tvb, offset, 3, oui);
606 oui_info = get_snap_oui_info(oui);
607 hf = *oui_info->field_info->p_id;
608 subdissector_table = oui_info->table;
609 proto_tree_add_uint(snap_tree, hf, tvb, offset+3, 2, etype);
610 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
612 if(!dissector_try_uint(hpteam_subdissector_table,etype, next_tvb, pinfo, tree))
613 call_dissector(data_handle, next_tvb, pinfo, tree);
616 case OUI_ENCAP_ETHER:
618 case OUI_APPLE_ATALK:
619 /* No, I have no idea why Apple used
620 one of their own OUIs, rather than
621 OUI_ENCAP_ETHER, and an Ethernet
622 packet type as protocol ID, for
623 AppleTalk data packets - but used
624 OUI_ENCAP_ETHER and an Ethernet
625 packet type for AARP packets. */
626 if (XDLC_IS_INFORMATION(control)) {
628 proto_tree_add_uint(snap_tree, hf_type,
629 tvb, offset+3, 2, etype);
631 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
632 if (!dissector_try_uint(ethertype_subdissector_table,
633 etype, next_tvb, pinfo, tree))
634 call_dissector(data_handle, next_tvb, pinfo,
637 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
638 call_dissector(data_handle, next_tvb, pinfo, tree);
644 * MAC frames bridged over ATM (RFC 2684) or Frame Relay
647 * We have to figure out how much padding to put
648 * into the frame. We were handed a "bridge_pad"
649 * argument which should be 0 for Frame Relay and
650 * 2 for ATM; we add to that the amount of padding
651 * common to both bridging types.
654 proto_tree_add_uint(snap_tree, hf_pid, tvb, offset+3, 2,
660 case BPID_ETH_WITH_FCS:
661 next_tvb = tvb_new_subset_remaining(tvb, offset+5+bridge_pad);
662 call_dissector(eth_withfcs_handle, next_tvb, pinfo,
666 case BPID_ETH_WITHOUT_FCS:
667 next_tvb = tvb_new_subset_remaining(tvb, offset+5+bridge_pad);
668 call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
671 case BPID_802_5_WITH_FCS:
672 case BPID_802_5_WITHOUT_FCS:
674 * We treat the last padding byte as the Access
675 * Control byte, as that's what the Token
676 * Ring dissector expects the first byte to
679 next_tvb = tvb_new_subset_remaining(tvb, offset+5+bridge_pad);
680 call_dissector(tr_handle, next_tvb, pinfo, tree);
683 case BPID_FDDI_WITH_FCS:
684 case BPID_FDDI_WITHOUT_FCS:
685 next_tvb = tvb_new_subset_remaining(tvb, offset+5+1+bridge_pad);
686 call_dissector(fddi_handle, next_tvb, pinfo, tree);
690 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
691 call_dissector(bpdu_handle, next_tvb, pinfo, tree);
695 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
696 call_dissector(data_handle, next_tvb, pinfo, tree);
701 case OUI_CABLE_BPDU: /* DOCSIS cable modem spanning tree BPDU */
703 proto_tree_add_uint(snap_tree, hf_pid, tvb, offset+3, 2,
706 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
707 call_dissector(bpdu_handle, next_tvb, pinfo, tree);
711 next_tvb = tvb_new_subset_remaining(tvb, offset+3);
712 call_dissector(turbo_handle, next_tvb, pinfo, tree);
717 * OLPC packet. The PID is an Ethertype, but
718 * there's a mesh header between the PID and
721 if (XDLC_IS_INFORMATION(control)) {
723 proto_tree_add_uint(snap_tree, hf_type,
724 tvb, offset+3, 2, etype);
726 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
727 mesh_header_len = call_dissector(mesh_handle,
728 next_tvb, pinfo, tree);
729 next_tvb = tvb_new_subset_remaining(tvb, offset+5+mesh_header_len);
730 if (!dissector_try_uint(ethertype_subdissector_table,
731 etype, next_tvb, pinfo, tree))
732 call_dissector(data_handle, next_tvb, pinfo,
735 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
736 call_dissector(data_handle, next_tvb, pinfo, tree);
742 * Do we have information for this OUI?
744 oui_info = get_snap_oui_info(oui);
745 if (oui_info != NULL) {
749 hf = *oui_info->field_info->p_id;
750 subdissector_table = oui_info->table;
753 * No, use hf_pid for the PID and just dissect
754 * the payload as data.
757 subdissector_table = NULL;
760 proto_tree_add_uint(snap_tree, hf, tvb, offset+3, 2,
763 next_tvb = tvb_new_subset_remaining(tvb, offset+5);
764 if (XDLC_IS_INFORMATION(control)) {
765 if (subdissector_table != NULL) {
766 /* do lookup with the subdissector table */
767 if (dissector_try_uint(subdissector_table,
768 etype, next_tvb, pinfo, tree))
772 call_dissector(data_handle, next_tvb, pinfo, tree);
778 * Return the oui_info_t for the PID for a particular OUI value, or NULL
779 * if there isn't one.
782 get_snap_oui_info(guint32 oui)
784 if (oui_info_table != NULL) {
785 return g_hash_table_lookup(oui_info_table,
786 GUINT_TO_POINTER(oui));
792 proto_register_llc(void)
794 static struct true_false_string ig_bit = { "Group", "Individual" };
795 static struct true_false_string cr_bit = { "Response", "Command" };
797 static hf_register_info hf[] = {
799 { "DSAP", "llc.dsap", FT_UINT8, BASE_HEX,
800 VALS(sap_vals), 0x0, "DSAP - 7 Most Significant Bits only", HFILL }},
803 { "IG Bit", "llc.dsap.ig", FT_BOOLEAN, BASE_NONE,
804 TFS(&ig_bit), 0x0, "Individual/Group - Least Significant Bit only", HFILL }},
807 { "SSAP", "llc.ssap", FT_UINT8, BASE_HEX,
808 VALS(sap_vals), 0x0, "SSAP - 7 Most Significant Bits only", HFILL }},
811 { "CR Bit", "llc.ssap.cr", FT_BOOLEAN, BASE_NONE,
812 TFS(&cr_bit), 0x0, "Command/Response - Least Significant Bit only", HFILL }},
815 { "Control", "llc.control", FT_UINT16, BASE_HEX,
816 NULL, 0x0, NULL, HFILL }},
819 { "N(R)", "llc.control.n_r", FT_UINT16, BASE_DEC,
820 NULL, XDLC_N_R_EXT_MASK, NULL, HFILL }},
823 { "N(S)", "llc.control.n_s", FT_UINT16, BASE_DEC,
824 NULL, XDLC_N_S_EXT_MASK, NULL, HFILL }},
827 { "Poll", "llc.control.p", FT_BOOLEAN, 8,
828 TFS(&tfs_set_notset), XDLC_P_F, NULL, HFILL }},
831 { "Poll", "llc.control.p", FT_BOOLEAN, 16,
832 TFS(&tfs_set_notset), XDLC_P_F_EXT, NULL, HFILL }},
835 { "Final", "llc.control.f", FT_BOOLEAN, 8,
836 TFS(&tfs_set_notset), XDLC_P_F, NULL, HFILL }},
839 { "Final", "llc.control.f", FT_BOOLEAN, 16,
840 TFS(&tfs_set_notset), XDLC_P_F_EXT, NULL, HFILL }},
843 { "Supervisory frame type", "llc.control.s_ftype", FT_UINT16, BASE_HEX,
844 VALS(stype_vals), XDLC_S_FTYPE_MASK, NULL, HFILL }},
846 { &hf_llc_u_modifier_cmd,
847 { "Command", "llc.control.u_modifier_cmd", FT_UINT8, BASE_HEX,
848 VALS(modifier_vals_cmd), XDLC_U_MODIFIER_MASK, NULL, HFILL }},
850 { &hf_llc_u_modifier_resp,
851 { "Response", "llc.control.u_modifier_resp", FT_UINT8, BASE_HEX,
852 VALS(modifier_vals_resp), XDLC_U_MODIFIER_MASK, NULL, HFILL }},
855 { "Frame type", "llc.control.ftype", FT_UINT16, BASE_HEX,
856 VALS(ftype_vals), XDLC_I_MASK, NULL, HFILL }},
859 { "Frame type", "llc.control.ftype", FT_UINT8, BASE_HEX,
860 VALS(ftype_vals), XDLC_S_U_MASK, NULL, HFILL }},
862 { &hf_llc_ftype_s_u_ext,
863 { "Frame type", "llc.control.ftype", FT_UINT16, BASE_HEX,
864 VALS(ftype_vals), XDLC_S_U_MASK, NULL, HFILL }},
866 /* registered here but handled in ethertype.c */
868 { "Type", "llc.type", FT_UINT16, BASE_HEX,
869 VALS(etype_vals), 0x0, NULL, HFILL }},
872 { "Organization Code", "llc.oui", FT_UINT24, BASE_HEX,
873 VALS(oui_vals), 0x0, NULL, HFILL }},
876 { "Protocol ID", "llc.pid", FT_UINT16, BASE_HEX,
877 NULL, 0x0, NULL, HFILL }}
879 static gint *ett[] = {
884 proto_llc = proto_register_protocol("Logical-Link Control", "LLC", "llc");
885 proto_register_field_array(proto_llc, hf, array_length(hf));
886 proto_register_subtree_array(ett, array_length(ett));
888 /* subdissector code */
889 dsap_subdissector_table = register_dissector_table("llc.dsap",
890 "LLC SAP", FT_UINT8, BASE_HEX);
891 xid_subdissector_table = register_dissector_table("llc.xid_dsap",
892 "LLC XID SAP", FT_UINT8, BASE_HEX);
894 register_dissector("llc", dissect_llc, proto_llc);
898 proto_register_basicxid(void)
900 static hf_register_info hf[] = {
901 { &hf_llc_xid_format,
902 { "XID Format", "basicxid.llc.xid.format", FT_UINT8, BASE_HEX,
903 VALS(format_vals), 0x0, NULL, HFILL }},
906 { "LLC Types/Classes", "basicxid.llc.xid.types", FT_UINT8, BASE_HEX,
907 VALS(type_vals), 0x0, NULL, HFILL }},
910 { "Receive Window Size", "basicxid.llc.xid.wsize", FT_UINT8, BASE_DEC,
911 NULL, 0x0, NULL, HFILL }}
913 static gint *ett[] = {
917 proto_basicxid = proto_register_protocol("Logical-Link Control Basic Format XID", "Basic Format XID", "basicxid");
918 proto_register_field_array(proto_basicxid, hf, array_length(hf));
919 proto_register_subtree_array(ett, array_length(ett));
921 register_dissector("basicxid", dissect_basicxid, proto_basicxid);
925 register_hf(gpointer key _U_, gpointer value, gpointer user_data _U_)
927 oui_info_t *info = value;
929 proto_register_field_array(proto_llc, info->field_info, 1);
933 proto_reg_handoff_llc(void)
935 dissector_handle_t llc_handle;
938 * Get handles for the BPDU, Ethernet, FDDI, Token Ring and
939 * Turbocell dissectors.
941 bpdu_handle = find_dissector("bpdu");
942 eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
943 eth_withfcs_handle = find_dissector("eth_withfcs");
944 fddi_handle = find_dissector("fddi");
945 tr_handle = find_dissector("tr");
946 turbo_handle = find_dissector("turbocell");
947 mesh_handle = find_dissector("mesh");
948 data_handle = find_dissector("data");
951 * Get the Ethertype dissector table.
953 ethertype_subdissector_table = find_dissector_table("ethertype");
954 hpteam_subdissector_table = find_dissector_table("llc.hpteam_pid");
956 llc_handle = find_dissector("llc");
957 dissector_add_uint("wtap_encap", WTAP_ENCAP_ATM_RFC1483, llc_handle);
958 dissector_add_uint("sll.ltype", LINUX_SLL_P_802_2, llc_handle);
960 dissector_add_uint("ppp.protocol", PPP_LLC, llc_handle);
962 dissector_add_uint("udp.port", UDP_PORT_LLC1, llc_handle);
963 dissector_add_uint("udp.port", UDP_PORT_LLC2, llc_handle);
964 dissector_add_uint("udp.port", UDP_PORT_LLC3, llc_handle);
965 dissector_add_uint("udp.port", UDP_PORT_LLC4, llc_handle);
966 dissector_add_uint("udp.port", UDP_PORT_LLC5, llc_handle);
967 /* IP-over-FC when we have the full FC frame */
968 dissector_add_uint("fc.ftype", FC_FTYPE_IP, llc_handle);
971 * BACNET-over-ARCNET is really BACNET-over-802.2 LLC-over-ARCNET,
974 dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_BACNET, llc_handle);
975 dissector_add_uint("ethertype", ETHERTYPE_JUMBO_LLC, llc_handle);
978 * Register all the fields for PIDs for various OUIs.
980 if (oui_info_table != NULL)
981 g_hash_table_foreach(oui_info_table, register_hf, NULL);