2 * Routines for NetBIOS over IPX packet disassembly
3 * Gilbert Ramirez <gram@verdict.uthscsa.edu>
5 * $Id: packet-nbipx.c,v 1.5 1998/11/17 04:28:57 gerald Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@zing.org>
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.
36 #ifdef HAVE_SYS_TYPES_H
37 # include <sys/types.h>
40 #ifdef HAVE_NETINET_IN_H
41 # include <netinet/in.h>
46 #include "packet-ipx.h" /* for ipxnet_to_string() */
54 nbipx_ns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree,
55 enum nbipx_protocol nbipx);
57 /* There is no RFC or public specification of Netware or Microsoft
58 * NetBIOS over IPX packets. I have had to decode the protocol myself,
59 * so there are holes and perhaps errors in this code. (gram)
68 /* Netware & NT NetBIOS over IPX */
75 /* NT NetBIOS over IPX */
84 dissect_nbipx_ns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
86 nbipx_ns(pd, offset, fd, tree, NETBIOS_NETWARE);
90 dissect_nwlink_dg(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
92 nbipx_ns(pd, offset, fd, tree, NETBIOS_NWLINK);
97 nbipx_ns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree,
98 enum nbipx_protocol nbipx)
100 GtkWidget *nbipx_tree, *ti;
101 struct nbipx_header header;
105 if (nbipx == NETBIOS_NETWARE) {
113 header.name_type = pd[offset+32];
114 header.packet_type = pd[offset+33];
115 memcpy(header.name, &pd[offset+name_offset], 16);
116 header.name[16] = 0; /* null-terminate the string */
118 if (nbipx == NETBIOS_NWLINK) {
119 memcpy(header.node_name, &pd[offset+52], 16);
120 header.node_name[17] = 0; /* null-terminate the string */
123 if (check_col(fd, COL_PROTOCOL)) {
124 if (nbipx == NETBIOS_NETWARE) {
125 col_add_str(fd, COL_PROTOCOL, "NetBIOS");
128 col_add_str(fd, COL_PROTOCOL, "NWLink");
132 if (check_col(fd, COL_INFO)) {
133 switch (header.packet_type) {
135 col_add_fstr(fd, COL_INFO, "Name Query for %s", header.name);
139 col_add_str(fd, COL_INFO, "NetBIOS over IPX");
144 ti = add_item_to_tree(GTK_WIDGET(tree), offset, END_OF_FRAME,
146 nbipx_tree = gtk_tree_new();
147 add_subtree(ti, nbipx_tree, ETT_NBIPX);
149 if (header.packet_type <= 1) {
150 add_item_to_tree(nbipx_tree, offset+33, 1,
151 "Packet Type: %s (%02X)", packet_type[header.packet_type],
155 add_item_to_tree(nbipx_tree, offset+33, 1,
156 "Packet Type: Unknown (%02X)", header.packet_type);
159 /* Eight routers are listed */
160 for (i = 0; i < 8; i++) {
161 rtr_offset = offset + (i << 2);
162 memcpy(&header.router[i], &pd[rtr_offset], 4);
163 if (header.router[i] != 0) {
164 add_item_to_tree(nbipx_tree, rtr_offset, 4, "IPX Network: %s",
165 ipxnet_to_string((guint8*)&header.router[i]));
169 add_item_to_tree(nbipx_tree, offset+32, 1, "Name Type: %02X",
172 if (nbipx == NETBIOS_NETWARE) {
173 add_item_to_tree(nbipx_tree, offset+name_offset, 16,
174 "Name String: %s", header.name);
177 add_item_to_tree(nbipx_tree, offset+name_offset, 16,
178 "Group Name String: %s", header.name);
179 add_item_to_tree(nbipx_tree, offset+52, 16,
180 "Node Name String: %s", header.node_name);
185 if (nbipx == NETBIOS_NWLINK) {
186 dissect_data(pd, offset + 68, fd, tree);