2 * Routines for IEEE 802.2 LLC layer
3 * Gilbert Ramirez <gram@verdict.uthscsa.edu>
5 * $Id: packet-llc.c,v 1.9 1998/11/12 00:06:30 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.
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
46 void (*func) (const u_char *, int, frame_data *, GtkTree *);
50 static struct sap_info saps[] = {
51 { 0x00, NULL, "NULL LSAP" },
52 { 0x02, NULL, "LLC Sub-Layer Management Individual" },
53 { 0x03, NULL, "LLC Sub-Layer Management Group" },
54 { 0x04, NULL, "SNA Path Control Individual" },
55 { 0x05, NULL, "SNA Path Control Group" },
56 { 0x06, dissect_ip, "TCP/IP" },
57 { 0x08, NULL, "SNA" },
58 { 0x0C, NULL, "SNA" },
59 { 0x42, NULL, "Spanning Tree BPDU" },
60 { 0x7F, NULL, "ISO 802.2" },
61 { 0x80, NULL, "XNS" },
62 { 0xAA, NULL, "SNAP" },
63 /*{ 0xBA, dissect_vines, "Banyan Vines" },
64 { 0xBC, dissect_vines, "Banyan Vines" },*/
65 { 0xBA, NULL, "Banyan Vines" },
66 { 0xBC, NULL, "Banyan Vines" },
67 { 0xE0, dissect_ipx, "NetWare" },
68 { 0xF0, NULL, "NetBIOS" },
69 { 0xF4, NULL, "IBM Net Management Individual" },
70 { 0xF5, NULL, "IBM Net Management Group" },
71 { 0xF8, NULL, "Remote Program Load" },
72 { 0xFC, NULL, "Remote Program Load" },
73 { 0xFE, dissect_osi, "ISO Network Layer" },
74 { 0xFF, NULL, "Global LSAP" },
80 sap_text(u_char sap) {
83 while (saps[i].text != NULL) {
84 if (saps[i].sap == sap) {
93 sap_func(u_char sap) {
96 while (saps[i].text != NULL) {
97 if (saps[i].sap == sap) {
106 llc_org(const u_char *ptr) {
108 unsigned long org = (ptr[0] << 16) | (ptr[1] << 8) | ptr[2];
110 "Encapsulated Ethernet"};
121 dissect_llc(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
123 GtkWidget *llc_tree = NULL, *ti;
126 void (*dissect) (const u_char *, int, frame_data *, GtkTree *);
129 char *llc_ctrl[4] = {
130 "Information Transfer", "Supervisory",
131 "", "Unnumbered Information" };
133 is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
135 if (fd->win_info[COL_NUM]) {
136 strcpy(fd->win_info[COL_PROTOCOL], "LLC");
140 ti = add_item_to_tree(GTK_WIDGET(tree), offset, (is_snap ? 8 : 3),
141 "Logical-Link Control");
142 llc_tree = gtk_tree_new();
143 add_subtree(ti, llc_tree, ETT_LLC);
144 add_item_to_tree(llc_tree, offset, 1, "DSAP: %s (0x%02X)",
145 sap_text(pd[offset]), pd[offset]);
146 add_item_to_tree(llc_tree, offset+1, 1, "SSAP: %s (0x%02X)",
147 sap_text(pd[offset+1]), pd[offset+1]);
148 add_item_to_tree(llc_tree, offset+2, 1, "Control: %s",
149 llc_ctrl[pd[offset+2] & 3]);
153 if (fd->win_info[COL_NUM]) {
154 strcpy(fd->win_info[COL_INFO], "802.2 LLC (SNAP)");
157 add_item_to_tree(llc_tree, offset+3, 3,
158 "Organization Code: %s (%02X-%02X-%02X)",
159 llc_org(&pd[offset+3]),
160 pd[offset+3], pd[offset+4], pd[offset+5]);
162 etype = (pd[offset+6] << 8) | pd[offset+7];
164 ethertype(etype, offset, pd, fd, tree, llc_tree);
167 if (fd->win_info[COL_NUM]) {
168 sprintf(fd->win_info[COL_INFO], "802.2 LLC (%s)", sap_text(pd[offset]));
171 dissect = sap_func(pd[offset]);
177 dissect(pd, offset, fd, tree);
180 dissect_data(pd, offset, fd, tree);