2 * Routines for IEEE 802.2 LLC layer
3 * Gilbert Ramirez <gram@verdict.uthscsa.edu>
5 * $Id: packet-llc.c,v 1.8 1998/10/10 03:32:12 gerald 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>
47 void (*func) (const u_char *, int, frame_data *, GtkTree *);
51 static struct sap_info saps[] = {
52 { 0x00, NULL, "NULL LSAP" },
53 { 0x02, NULL, "LLC Sub-Layer Management Individual" },
54 { 0x03, NULL, "LLC Sub-Layer Management Group" },
55 { 0x04, NULL, "SNA Path Control Individual" },
56 { 0x05, NULL, "SNA Path Control Group" },
57 { 0x06, dissect_ip, "TCP/IP" },
58 { 0x08, NULL, "SNA" },
59 { 0x0C, NULL, "SNA" },
60 { 0x42, NULL, "Spanning Tree BPDU" },
61 { 0x7F, NULL, "ISO 802.2" },
62 { 0x80, NULL, "XNS" },
63 { 0xAA, NULL, "SNAP" },
64 /*{ 0xBA, dissect_vines, "Banyan Vines" },
65 { 0xBC, dissect_vines, "Banyan Vines" },*/
66 { 0xBA, NULL, "Banyan Vines" },
67 { 0xBC, NULL, "Banyan Vines" },
68 { 0xE0, dissect_ipx, "NetWare" },
69 { 0xF0, NULL, "NetBIOS" },
70 { 0xF4, NULL, "IBM Net Management Individual" },
71 { 0xF5, NULL, "IBM Net Management Group" },
72 { 0xF8, NULL, "Remote Program Load" },
73 { 0xFC, NULL, "Remote Program Load" },
74 { 0xFE, dissect_osi, "ISO Network Layer" },
75 { 0xFF, NULL, "Global LSAP" },
81 sap_text(u_char sap) {
84 while (saps[i].text != NULL) {
85 if (saps[i].sap == sap) {
94 sap_func(u_char sap) {
97 while (saps[i].text != NULL) {
98 if (saps[i].sap == sap) {
107 llc_org(const u_char *ptr) {
109 unsigned long org = (ptr[0] << 16) | (ptr[1] << 8) | ptr[2];
111 "Encapsulated Ethernet"};
122 dissect_llc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
124 GtkWidget *llc_tree = NULL, *ti;
127 void (*dissect) (const u_char *, int, frame_data *, GtkTree *);
130 char *llc_ctrl[4] = {
131 "Information Transfer", "Supervisory",
132 "", "Unnumbered Information" };
134 is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
136 if (fd->win_info[COL_NUM]) {
137 strcpy(fd->win_info[COL_PROTOCOL], "LLC");
141 ti = add_item_to_tree(GTK_WIDGET(tree), offset, (is_snap ? 8 : 3),
142 "Logical-Link Control");
143 llc_tree = gtk_tree_new();
144 add_subtree(ti, llc_tree, ETT_LLC);
145 add_item_to_tree(llc_tree, offset, 1, "DSAP: %s (0x%02X)",
146 sap_text(pd[offset]), pd[offset]);
147 add_item_to_tree(llc_tree, offset+1, 1, "SSAP: %s (0x%02X)",
148 sap_text(pd[offset+1]), pd[offset+1]);
149 add_item_to_tree(llc_tree, offset+2, 1, "Control: %s",
150 llc_ctrl[pd[offset+2] & 3]);
154 if (fd->win_info[COL_NUM]) {
155 strcpy(fd->win_info[COL_INFO], "802.2 LLC (SNAP)");
158 add_item_to_tree(llc_tree, offset+3, 3,
159 "Organization Code: %s (%02X-%02X-%02X)",
160 llc_org(&pd[offset+3]),
161 pd[offset+3], pd[offset+4], pd[offset+5]);
163 etype = (pd[offset+6] << 8) | pd[offset+7];
165 ethertype(etype, offset, pd, fd, tree, llc_tree);
168 if (fd->win_info[COL_NUM]) {
169 sprintf(fd->win_info[COL_INFO], "802.2 LLC (%s)", sap_text(pd[offset]));
172 dissect = sap_func(pd[offset]);
178 dissect(pd, offset, fd, tree);
181 dissect_data(pd, offset, fd, tree);