2 * Routines for IEEE 802.2 LLC layer
3 * Gilbert Ramirez <gramirez@tivoli.com>
5 * $Id: packet-llc.c,v 1.25 1999/10/08 20:50:38 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@unicom.net>
9 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
39 static int proto_llc = -1;
40 static int hf_llc_dsap = -1;
41 static int hf_llc_ssap = -1;
42 static int hf_llc_ctrl = -1;
43 static int hf_llc_type = -1;
44 static int hf_llc_oui = -1;
46 typedef void (capture_func_t)(const u_char *, int, guint32, packet_counts *);
47 typedef void (dissect_func_t)(const u_char *, int, frame_data *, proto_tree *);
49 /* The SAP info is split into two tables, one value_string table and one table of sap_info. This is
50 * so that the value_string can be used in the header field registration.
54 capture_func_t *capture_func;
55 dissect_func_t *dissect_func;
58 static const value_string sap_vals[] = {
59 { 0x00, "NULL LSAP" },
60 { 0x02, "LLC Sub-Layer Management Individual" },
61 { 0x03, "LLC Sub-Layer Management Group" },
62 { 0x04, "SNA Path Control Individual" },
63 { 0x05, "SNA Path Control Group" },
67 { 0x42, "Spanning Tree BPDU" },
68 { 0x7F, "ISO 802.2" },
71 { 0xBA, "Banyan Vines" },
72 { 0xBC, "Banyan Vines" },
75 { 0xF4, "IBM Net Management Individual" },
76 { 0xF5, "IBM Net Management Group" },
77 { 0xF8, "Remote Program Load" },
78 { 0xFC, "Remote Program Load" },
79 { 0xFE, "ISO Network Layer" },
80 { 0xFF, "Global LSAP" },
84 static struct sap_info saps[] = {
90 { 0x06, capture_ip, dissect_ip },
93 { 0x42, NULL, dissect_bpdu },
99 { 0xE0, NULL, dissect_ipx },
100 { 0xF0, capture_netbios, dissect_netbios },
101 { 0xF4, NULL, NULL },
102 { 0xF5, NULL, NULL },
103 { 0xF8, NULL, NULL },
104 { 0xFC, NULL, NULL },
105 { 0xFE, NULL, dissect_osi },
106 { 0xFF, NULL, NULL },
110 static const value_string llc_ctrl_vals[] = {
111 { 0, "Information Transfer" },
112 { 1, "Supervisory" },
114 { 3, "Unnumbered Information" },
118 static const value_string llc_oui_vals[] = {
119 { 0x000000, "Encapsulated Ethernet" },
121 http://www.cisco.com/univercd/cc/td/doc/product/software/ios113ed/113ed_cr/ibm_r/brprt1/brsrb.htm
123 { 0x0000f8, "Cisco 90-Compatible" },
124 { 0x0000c0, "Cisco" },
125 { 0x0080c2, "Bridged Frame-Relay" }, /* RFC 2427 */
129 static capture_func_t *
130 sap_capture_func(u_char sap) {
133 /* look for the second record where sap == 0, which should
136 while (saps[i].sap > 0 || i == 0) {
137 if (saps[i].sap == sap) {
138 return saps[i].capture_func;
145 static dissect_func_t *
146 sap_dissect_func(u_char sap) {
149 /* look for the second record where sap == 0, which should
152 while (saps[i].sap > 0 || i == 0) {
153 if (saps[i].sap == sap) {
154 return saps[i].dissect_func;
163 capture_llc(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
169 capture_func_t *capture;
171 is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
174 * The low-order bit of the SSAP apparently determines whether this
175 * is a request or a response. (RFC 1390, "Transmission of IP and
176 * ARP over FDDI Networks", says
178 * Command frames are identified by having the low order
179 * bit of the SSAP address reset to zero. Response frames
180 * have the low order bit of the SSAP address set to one.
182 * and a page I've seen seems to imply that's part of 802.2.)
184 * XXX - that page also implies that LLC Type 2 always uses
185 * extended operation, so we don't need to determine whether
186 * it's basic or extended operation; is that the case?
188 control = get_xdlc_control(pd, offset+2, pd[offset+1] & 0x01, TRUE);
189 control_len = XDLC_CONTROL_LEN(control, TRUE);
191 control_len += 5; /* 3 bytes of OUI, 2 bytes of ethertype */
194 if (XDLC_HAS_PAYLOAD(control)) {
196 * This frame has a payload to be analyzed.
198 etype = (pd[offset+6] << 8) | pd[offset+7];
199 offset += control_len;
200 capture_ethertype(etype, offset, pd, cap_len, ld);
204 if (XDLC_HAS_PAYLOAD(control)) {
206 * This frame has a payload to be analyzed.
208 capture = sap_capture_func(pd[offset]);
211 offset += control_len;
214 capture(pd, offset, cap_len, ld);
224 dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
226 proto_tree *llc_tree = NULL;
227 proto_item *ti = NULL;
232 dissect_func_t *dissect;
234 is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
236 if (check_col(fd, COL_PROTOCOL)) {
237 col_add_str(fd, COL_PROTOCOL, "LLC");
241 ti = proto_tree_add_item(tree, proto_llc, offset, 0, NULL);
242 llc_tree = proto_item_add_subtree(ti, ETT_LLC);
243 proto_tree_add_item(llc_tree, hf_llc_dsap, offset, 1, pd[offset]);
244 proto_tree_add_item(llc_tree, hf_llc_ssap, offset+1, 1, pd[offset+1]);
249 * The low-order bit of the SSAP apparently determines whether this
250 * is a request or a response. (RFC 1390, "Transmission of IP and
251 * ARP over FDDI Networks", says
253 * Command frames are identified by having the low order
254 * bit of the SSAP address reset to zero. Response frames
255 * have the low order bit of the SSAP address set to one.
257 * and a page I've seen seems to imply that's part of 802.2.)
259 * XXX - that page also implies that LLC Type 2 always uses
260 * extended operation, so we don't need to determine whether
261 * it's basic or extended operation; is that the case?
263 control = dissect_xdlc_control(pd, offset+2, fd, llc_tree,
264 hf_llc_ctrl, pd[offset+1] & 0x01, TRUE);
265 control_len = XDLC_CONTROL_LEN(control, TRUE);
267 control_len += 5; /* 3 bytes of OUI, 2 bytes of ethertype */
269 proto_item_set_len(ti, control_len);
272 * XXX - do we want to append the SAP information to the stuff
273 * "dissect_xdlc_control()" put in the COL_INFO column, rather
274 * than overwriting it?
277 if (check_col(fd, COL_INFO)) {
278 col_add_str(fd, COL_INFO, "802.2 LLC (SNAP)");
281 proto_tree_add_item(llc_tree, hf_llc_oui, offset+3, 3,
282 pd[offset+3] << 16 | pd[offset+4] << 8 | pd[offset+5]);
284 if (XDLC_HAS_PAYLOAD(control)) {
286 * This frame has a payload to be analyzed.
288 etype = pntohs(&pd[offset+6]);
289 offset += control_len;
290 /* w/o even checking, assume OUI is ethertype */
291 ethertype(etype, offset, pd, fd, tree, llc_tree,
296 if (check_col(fd, COL_INFO)) {
297 col_add_fstr(fd, COL_INFO, "802.2 LLC (%s)",
298 val_to_str(pd[offset], sap_vals, "%02x"));
301 if (XDLC_HAS_PAYLOAD(control)) {
303 * This frame has a payload to be analyzed.
305 dissect = sap_dissect_func(pd[offset]);
308 offset += control_len;
311 dissect(pd, offset, fd, tree);
314 dissect_data(pd, offset, fd, tree);
321 proto_register_llc(void)
323 static hf_register_info hf[] = {
325 { "DSAP", "llc.dsap", FT_VALS_UINT8, VALS(sap_vals) }},
328 { "SSAP", "llc.ssap", FT_VALS_UINT8, VALS(sap_vals) }},
331 { "Control", "llc.control", FT_VALS_UINT8, VALS(llc_ctrl_vals) }},
333 /* registered here but handled in ethertype.c */
335 { "Type", "llc.type", FT_VALS_UINT16, VALS(etype_vals) }},
338 { "Organization Code", "llc.oui", FT_VALS_UINT24, VALS(llc_oui_vals) }}
341 proto_llc = proto_register_protocol ("Logical-Link Control", "llc" );
342 proto_register_field_array(proto_llc, hf, array_length(hf));