2 * Routines for NetBIOS over IPX packet disassembly
3 * Gilbert Ramirez <gram@verdict.uthscsa.edu>
5 * $Id: packet-nbipx.c,v 1.8 1999/07/07 22:51:47 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_text(tree, offset, 68,
146 nbipx_tree = proto_item_add_subtree(ti, ETT_NBIPX);
148 if (header.packet_type <= 1) {
149 proto_tree_add_text(nbipx_tree, offset+33, 1,
150 "Packet Type: %s (%02X)", packet_type[header.packet_type],
154 proto_tree_add_text(nbipx_tree, offset+33, 1,
155 "Packet Type: Unknown (%02X)", header.packet_type);
158 /* Eight routers are listed */
159 for (i = 0; i < 8; i++) {
160 rtr_offset = offset + (i << 2);
161 memcpy(&header.router[i], &pd[rtr_offset], 4);
162 if (header.router[i] != 0) {
163 proto_tree_add_text(nbipx_tree, rtr_offset, 4, "IPX Network: %s",
164 ipxnet_to_string((guint8*)&header.router[i]));
168 proto_tree_add_text(nbipx_tree, offset+32, 1, "Name Type: %02X",
171 if (nbipx == NETBIOS_NETWARE) {
172 proto_tree_add_text(nbipx_tree, offset+name_offset, 16,
173 "Name String: %s", header.name);
176 proto_tree_add_text(nbipx_tree, offset+name_offset, 16,
177 "Group Name String: %s", header.name);
178 proto_tree_add_text(nbipx_tree, offset+52, 16,
179 "Node Name String: %s", header.node_name);
184 if (nbipx == NETBIOS_NWLINK) {
185 switch (header.packet_type) {
187 dissect_smb(pd, offset + 68, fd, tree, max_data - 68);
191 dissect_data(pd, offset + 68, fd, tree);