2 * Routines for IEEE 802.2 LLC layer
3 * Gilbert Ramirez <gramirez@tivoli.com>
5 * $Id: packet-llc.c,v 1.20 1999/08/23 22:47:13 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 },
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) {
168 capture_func_t *capture;
170 is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
173 * The low-order bit of the SSAP apparently determines whether this
174 * is a request or a response. (RFC 1390, "Transmission of IP and
175 * ARP over FDDI Networks", says
177 * Command frames are identified by having the low order
178 * bit of the SSAP address reset to zero. Response frames
179 * have the low order bit of the SSAP address set to one.
181 * and a page I've seen seems to imply that's part of 802.2.)
183 * XXX - that page also implies that LLC Type 2 always uses
184 * extended operation, so we don't need to determine whether
185 * it's basic or extended operation; is that the case?
187 control = get_xdlc_control(pd, offset+2, pd[offset+1] & 0x01, TRUE);
190 if (control == XDLC_I || control == (XDLC_U|XDLC_UI)) {
192 * Unnumbered Information - analyze it based on
193 * the Ethernet packet type.
195 etype = (pd[offset+6] << 8) | pd[offset+7];
197 capture_ethertype(etype, offset, pd, cap_len, ld);
201 if (control == XDLC_I || control == (XDLC_U|XDLC_UI)) {
203 * Unnumbered Information - analyze it based on
206 capture = sap_capture_func(pd[offset]);
212 capture(pd, offset, cap_len, ld);
222 dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
224 proto_tree *llc_tree = NULL;
229 dissect_func_t *dissect;
231 is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
233 if (check_col(fd, COL_PROTOCOL)) {
234 col_add_str(fd, COL_PROTOCOL, "LLC");
238 ti = proto_tree_add_item(tree, proto_llc, offset, (is_snap ? 8 : 3), NULL);
239 llc_tree = proto_item_add_subtree(ti, ETT_LLC);
240 proto_tree_add_item(llc_tree, hf_llc_dsap, offset, 1, pd[offset]);
241 proto_tree_add_item(llc_tree, hf_llc_ssap, offset+1, 1, pd[offset+1]);
246 * The low-order bit of the SSAP apparently determines whether this
247 * is a request or a response. (RFC 1390, "Transmission of IP and
248 * ARP over FDDI Networks", says
250 * Command frames are identified by having the low order
251 * bit of the SSAP address reset to zero. Response frames
252 * have the low order bit of the SSAP address set to one.
254 * and a page I've seen seems to imply that's part of 802.2.)
256 * XXX - that page also implies that LLC Type 2 always uses
257 * extended operation, so we don't need to determine whether
258 * it's basic or extended operation; is that the case?
260 control = dissect_xdlc_control(pd, offset+2, fd, llc_tree, hf_llc_ctrl,
261 pd[offset+1] & 0x01, TRUE);
264 * XXX - do we want to append the SAP information to the stuff
265 * "dissect_xdlc_control()" put in the COL_INFO column, rather
266 * than overwriting it?
269 if (check_col(fd, COL_INFO)) {
270 col_add_str(fd, COL_INFO, "802.2 LLC (SNAP)");
273 proto_tree_add_item(llc_tree, hf_llc_oui, offset+3, 3,
274 pd[offset+3] << 16 | pd[offset+4] << 8 | pd[offset+5]);
276 if (control == (XDLC_U|XDLC_UI)) {
278 * Unnumbered Information - dissect it based on
279 * the Ethernet packet type.
281 etype = pntohs(&pd[offset+6]);
283 /* w/o even checking, assume OUI is ethertype */
284 ethertype(etype, offset, pd, fd, tree, llc_tree,
289 if (check_col(fd, COL_INFO)) {
290 col_add_fstr(fd, COL_INFO, "802.2 LLC (%s)",
291 val_to_str(pd[offset], sap_vals, "%02x"));
294 if (control == (XDLC_U|XDLC_UI)) {
296 * Unnumbered Information - dissect it based on
299 dissect = sap_dissect_func(pd[offset]);
305 dissect(pd, offset, fd, tree);
308 dissect_data(pd, offset, fd, tree);
315 proto_register_llc(void)
317 static hf_register_info hf[] = {
319 { "DSAP", "llc.dsap", FT_VALS_UINT8, VALS(sap_vals) }},
322 { "SSAP", "llc.ssap", FT_VALS_UINT8, VALS(sap_vals) }},
325 { "Control", "llc.control", FT_VALS_UINT8, VALS(llc_ctrl_vals) }},
327 /* registered here but handled in ethertype.c */
329 { "Type", "llc.type", FT_VALS_UINT16, VALS(etype_vals) }},
332 { "Organization Code", "llc.oui", FT_VALS_UINT24, VALS(llc_oui_vals) }}
335 proto_llc = proto_register_protocol ("Logical-Link Control", "llc" );
336 proto_register_field_array(proto_llc, hf, array_length(hf));