2 * Routines for IEEE 802.2 LLC layer
3 * Gilbert Ramirez <gram@verdict.uthscsa.edu>
5 * $Id: packet-llc.c,v 1.4 1998/09/17 18:43:11 gram 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.
43 void (*func) (const u_char *, int, frame_data *, GtkTree *);
47 static struct sap_info saps[] = {
48 { 0x00, NULL, "NULL LSAP" },
49 { 0x02, NULL, "LLC Sub-Layer Management Individual" },
50 { 0x03, NULL, "LLC Sub-Layer Management Group" },
51 { 0x04, NULL, "SNA Path Control Individual" },
52 { 0x05, NULL, "SNA Path Control Group" },
53 { 0x06, dissect_ip, "TCP/IP" },
54 { 0x08, NULL, "SNA" },
55 { 0x0C, NULL, "SNA" },
56 { 0x42, NULL, "Spanning Tree BPDU" },
57 { 0x7F, NULL, "ISO 802.2" },
58 { 0x80, NULL, "XNS" },
59 { 0xAA, NULL, "SNAP" },
60 { 0xBA, dissect_vines, "Banyan Vines" },
61 { 0xBC, dissect_vines, "Banyan Vines" },
62 { 0xE0, dissect_ipx, "NetWare" },
63 { 0xF0, NULL, "NetBIOS" },
64 { 0xF4, NULL, "IBM Net Management Individual" },
65 { 0xF5, NULL, "IBM Net Management Group" },
66 { 0xF8, NULL, "Remote Program Load" },
67 { 0xFC, NULL, "Remote Program Load" },
68 { 0xFE, dissect_osi, "ISO Network Layer" },
69 { 0xFF, NULL, "Global LSAP" },
75 sap_text(u_char sap) {
78 while (saps[i].text != NULL) {
79 if (saps[i].sap == sap) {
88 sap_func(u_char sap) {
91 while (saps[i].text != NULL) {
92 if (saps[i].sap == sap) {
101 llc_org(const u_char *ptr) {
103 unsigned long org = (ptr[0] << 16) | (ptr[1] << 8) | ptr[2];
105 "Encapsulated Ethernet"};
116 dissect_llc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
118 GtkWidget *llc_tree, *ti;
121 void (*dissect) (const u_char *, int, frame_data *, GtkTree *);
124 char *llc_ctrl[4] = {
125 "Information Transfer", "Supervisory",
126 "", "Unnumbered Information" };
128 is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
130 if (fd->win_info[0]) {
131 strcpy(fd->win_info[3], "LLC");
135 ti = add_item_to_tree(GTK_WIDGET(tree), offset, (is_snap ? 8 : 3),
136 "Logical-Link Control");
137 llc_tree = gtk_tree_new();
138 add_subtree(ti, llc_tree, ETT_LLC);
139 add_item_to_tree(llc_tree, offset, 1, "DSAP: %s (0x%02X)",
140 sap_text(pd[offset]), pd[offset]);
141 add_item_to_tree(llc_tree, offset+1, 1, "SSAP: %s (0x%02X)",
142 sap_text(pd[offset+1]), pd[offset+1]);
143 add_item_to_tree(llc_tree, offset+2, 1, "Control: %s",
144 llc_ctrl[pd[offset+2] & 3]);
148 if (fd->win_info[0]) {
149 strcpy(fd->win_info[4], "802.2 LLC (SNAP)");
152 add_item_to_tree(llc_tree, offset+3, 3,
153 "Organization Code: %s (%02X-%02X-%02X)",
154 llc_org(&pd[offset+3]),
155 pd[offset+3], pd[offset+4], pd[offset+5]);
157 etype = (pd[offset+6] << 8) | pd[offset+7];
159 ethertype(etype, offset, pd, fd, tree, llc_tree);
162 if (fd->win_info[0]) {
163 sprintf(fd->win_info[4], "802.2 LLC (%s)", sap_text(pd[offset]));
166 dissect = sap_func(pd[offset]);
172 dissect(pd, offset, fd, tree);
175 dissect_data(pd, offset, fd, tree);