2 * Routines for NetBIOS over IPX packet disassembly
3 * Gilbert Ramirez <gram@verdict.uthscsa.edu>
5 * $Id: packet-nbipx.c,v 1.7 1999/05/10 19:01:32 gram 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.
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
35 /*#include <memory.h>*/
38 #include "packet-ipx.h" /* for ipxnet_to_string() */
46 nbipx_ns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
47 enum nbipx_protocol nbipx, int max_data);
49 /* There is no RFC or public specification of Netware or Microsoft
50 * NetBIOS over IPX packets. I have had to decode the protocol myself,
51 * so there are holes and perhaps errors in this code. (gram)
60 /* Netware & NT NetBIOS over IPX */
67 /* NT NetBIOS over IPX */
76 dissect_nbipx_ns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
79 nbipx_ns(pd, offset, fd, tree, NETBIOS_NETWARE, max_data);
83 dissect_nwlink_dg(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
86 nbipx_ns(pd, offset, fd, tree, NETBIOS_NWLINK, max_data);
91 nbipx_ns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
92 enum nbipx_protocol nbipx, int max_data)
94 proto_tree *nbipx_tree;
96 struct nbipx_header header;
100 if (nbipx == NETBIOS_NETWARE) {
108 header.name_type = pd[offset+32];
109 header.packet_type = pd[offset+33];
110 memcpy(header.name, &pd[offset+name_offset], 16);
111 header.name[16] = 0; /* null-terminate the string */
113 if (nbipx == NETBIOS_NWLINK) {
114 memcpy(header.node_name, &pd[offset+52], 16);
115 header.node_name[17] = 0; /* null-terminate the string */
118 if (check_col(fd, COL_PROTOCOL)) {
119 if (nbipx == NETBIOS_NETWARE) {
120 col_add_str(fd, COL_PROTOCOL, "NetBIOS");
123 col_add_str(fd, COL_PROTOCOL, "NWLink");
127 if (check_col(fd, COL_INFO)) {
128 switch (header.packet_type) {
130 col_add_fstr(fd, COL_INFO, "Name Query for %s", header.name);
134 col_add_fstr(fd, COL_INFO, "SMB over NBIPX");
139 col_add_str(fd, COL_INFO, "NetBIOS over IPX");
144 ti = proto_tree_add_item(tree, offset, 68,
146 nbipx_tree = proto_tree_new();
147 proto_item_add_subtree(ti, nbipx_tree, ETT_NBIPX);
149 if (header.packet_type <= 1) {
150 proto_tree_add_item(nbipx_tree, offset+33, 1,
151 "Packet Type: %s (%02X)", packet_type[header.packet_type],
155 proto_tree_add_item(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 proto_tree_add_item(nbipx_tree, rtr_offset, 4, "IPX Network: %s",
165 ipxnet_to_string((guint8*)&header.router[i]));
169 proto_tree_add_item(nbipx_tree, offset+32, 1, "Name Type: %02X",
172 if (nbipx == NETBIOS_NETWARE) {
173 proto_tree_add_item(nbipx_tree, offset+name_offset, 16,
174 "Name String: %s", header.name);
177 proto_tree_add_item(nbipx_tree, offset+name_offset, 16,
178 "Group Name String: %s", header.name);
179 proto_tree_add_item(nbipx_tree, offset+52, 16,
180 "Node Name String: %s", header.node_name);
185 if (nbipx == NETBIOS_NWLINK) {
186 switch (header.packet_type) {
188 dissect_smb(pd, offset + 68, fd, tree, max_data - 68);
192 dissect_data(pd, offset + 68, fd, tree);