af313b49a143077301208db8c02b241995baff70
[obnox/wireshark/wip.git] / packet-ipx.c
1 /* packet-ipx.c
2  * Routines for NetWare's IPX
3  * Gilbert Ramirez <gram@verdict.uthscsa.edu>
4  *
5  * $Id: packet-ipx.c,v 1.28 1999/10/12 06:20:10 gram Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@unicom.net>
9  * Copyright 1998 Gerald Combs
10  *
11  * 
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.
16  * 
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.
21  * 
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.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
33 #endif
34
35 #include <stdio.h>
36 #include <glib.h>
37 #include "packet.h"
38 #include "packet-ipx.h"
39 #include "packet-ncp.h"
40
41 /* The information in this module (IPX, SPX, NCP) comes from:
42         NetWare LAN Analysis, Second Edition
43         Laura A. Chappell and Dan E. Hakes
44         (c) 1994 Novell, Inc.
45         Novell Press, San Jose.
46         ISBN: 0-7821-1362-1
47
48   And from the ncpfs source code by Volker Lendecke
49
50 */
51         
52 static int proto_ipx = -1;
53 static int hf_ipx_checksum = -1;
54 static int hf_ipx_len = -1;
55 static int hf_ipx_hops = -1;
56 static int hf_ipx_packet_type = -1;
57 static int hf_ipx_dnet = -1;
58 static int hf_ipx_dnode = -1;
59 static int hf_ipx_dsocket = -1;
60 static int hf_ipx_snet = -1;
61 static int hf_ipx_snode = -1;
62 static int hf_ipx_ssocket = -1;
63
64 static int proto_spx = -1;
65 static int proto_ipxrip = -1;
66 static int proto_sap = -1;
67
68 static void
69 dissect_spx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
70
71 static void
72 dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
73
74 static void
75 dissect_sap(const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
76
77 typedef void    (dissect_func_t)(const u_char *, int, frame_data *, proto_tree *);
78
79 struct port_info {
80         guint16 port;
81         dissect_func_t *func;
82         char    *text;
83 };
84
85 struct conn_info {
86         guint8  ctrl;
87         char    *text;
88 };
89
90 struct server_info {
91         guint16 type;
92         char    *text;
93 };
94
95 /* ================================================================= */
96 /* IPX                                                               */
97 /* ================================================================= */
98
99 #define IPX_SOCKET_NCP                  0x0451
100 #define IPX_SOCKET_SAP                  0x0452
101 #define IPX_SOCKET_IPXRIP               0x0453
102 #define IPX_SOCKET_NETBIOS              0x0455
103 #define IPX_SOCKET_DIAGNOSTIC           0x0456
104 #define IPX_SOCKET_SERIALIZATION        0x0457
105 #define IPX_SOCKET_NWLINK_SMB_NAMEQUERY 0x0551
106 #define IPX_SOCKET_NWLINK_SMB_DGRAM     0x0553
107 #define IPX_SOCKET_ATTACHMATE_GW        0x055d
108 #define IPX_SOCKET_IPX_MESSAGE          0x4001
109
110 static struct port_info ports[] = {
111         { IPX_SOCKET_NCP,                       dissect_ncp,
112                                 "NCP" },
113         { IPX_SOCKET_SAP,                       dissect_sap,
114                                 "SAP" },
115         { IPX_SOCKET_IPXRIP,                    dissect_ipxrip,
116                                 "RIP" },
117         { IPX_SOCKET_NETBIOS,                   NULL,
118                                 "NetBIOS" },
119         { IPX_SOCKET_DIAGNOSTIC,                NULL,
120                                 "Diagnostic" },
121         { IPX_SOCKET_SERIALIZATION,             NULL,
122                                 "Serialization" },
123         { IPX_SOCKET_NWLINK_SMB_NAMEQUERY,      NULL,
124                                 "NWLink SMB Name Query" },
125         { IPX_SOCKET_NWLINK_SMB_DGRAM,          dissect_nwlink_dg,
126                                 "NWLink SMB Datagram" },
127         { IPX_SOCKET_ATTACHMATE_GW,             NULL,
128                                 "Attachmate Gateway" },
129         { IPX_SOCKET_IPX_MESSAGE,               NULL,
130                                 "IPX Message" },
131         { 0x0000,                               NULL,
132                                 NULL }
133 };
134
135 static char*
136 port_text(guint16 port) {
137         int i=0;
138
139         while (ports[i].text != NULL) {
140                 if (ports[i].port == port) {
141                         return ports[i].text;
142                 }
143                 i++;
144         }
145         return "Unknown";
146 }
147
148 static dissect_func_t*
149 port_func(guint16 port) {
150         int i=0;
151
152         while (ports[i].text != NULL) {
153                 if (ports[i].port == port) {
154                         return ports[i].func;
155                 }
156                 i++;
157         }
158         return NULL;
159 }
160
161 #define IPX_PACKET_TYPE_IPX             0
162 #define IPX_PACKET_TYPE_IPX_4           4
163 #define IPX_PACKET_TYPE_SPX             5
164 #define IPX_PACKET_TYPE_NCP             17
165 #define IPX_PACKET_TYPE_WANBCAST        20
166
167 static const value_string ipx_packet_type_vals[] = {
168         { IPX_PACKET_TYPE_IPX,          "IPX" },
169         { IPX_PACKET_TYPE_IPX_4,        "IPX" },
170                                 /* NetMon calls it "IPX" */
171         { IPX_PACKET_TYPE_SPX,          "SPX" },
172         { 16,                           "Experimental Protocol" },
173         { IPX_PACKET_TYPE_NCP,          "NCP" },
174         { 18,                           "Experimental Protocol" },
175         { 19,                           "Experimental Protocol" },
176         { IPX_PACKET_TYPE_WANBCAST,     "NetBIOS Broadcast" },
177                                 /* NetMon calls it "WAN Broadcast" */
178         { 21,                           "Experimental Protocol" },
179         { 22,                           "Experimental Protocol" },
180         { 23,                           "Experimental Protocol" },
181         { 24,                           "Experimental Protocol" },
182         { 25,                           "Experimental Protocol" },
183         { 26,                           "Experimental Protocol" },
184         { 27,                           "Experimental Protocol" },
185         { 28,                           "Experimental Protocol" },
186         { 29,                           "Experimental Protocol" },
187         { 30,                           "Experimental Protocol" },
188         { 31,                           "Experimental Protocol" },
189         { 0,                            NULL }
190 };
191
192 gchar*
193 ipxnet_to_string(const guint8 *ad)
194 {
195         static gchar    str[3][12];
196         static gchar    *cur;
197
198         if (cur == &str[0][0]) {
199                 cur = &str[1][0];
200         } else if (cur == &str[1][0]) {
201                 cur = &str[2][0];
202         } else {
203                 cur = &str[0][0];
204         }
205
206         sprintf(cur, "%02X %02X %02X %02X", ad[0], ad[1], ad[2], ad[3]);
207         return cur;
208 }
209
210 gchar*
211 ipx_addr_to_str(guint32 net, const guint8 *ad)
212 {
213         static gchar    str[3][22];
214         static gchar    *cur;
215
216         if (cur == &str[0][0]) {
217                 cur = &str[1][0];
218         } else if (cur == &str[1][0]) {
219                 cur = &str[2][0];
220         } else {
221                 cur = &str[0][0];
222         }
223
224         sprintf(cur, "%X.%02x%02x%02x%02x%02x%02x", net, 
225                 ad[0], ad[1], ad[2], ad[3], ad[4], ad[5]);
226         return cur;
227 }
228
229 void
230 dissect_ipx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
231
232         proto_tree      *ipx_tree;
233         proto_item      *ti;
234         guint8          ipx_type, ipx_hops;
235         guint16         ipx_checksum, ipx_length;
236         int             len;
237         guint8          *ipx_snode, *ipx_dnode, *ipx_snet, *ipx_dnet;
238
239         gchar           *str_dnet, *str_snet;
240         guint16         ipx_dsocket, ipx_ssocket;
241         dissect_func_t  *dissect;
242         guint32         ipx_dnet_val, ipx_snet_val;
243
244         /* Calculate here for use in pinfo and in tree */
245         ipx_dnet = (guint8*)&pd[offset+6];
246         ipx_snet = (guint8*)&pd[offset+18];
247         str_dnet = ipxnet_to_string(ipx_dnet);
248         str_snet = ipxnet_to_string(ipx_snet);
249         ipx_dnet_val = pntohl(ipx_dnet);
250         ipx_snet_val = pntohl(ipx_snet);
251         ipx_dsocket = pntohs(&pd[offset+16]);
252         ipx_ssocket = pntohs(&pd[offset+28]);
253         ipx_dnode = (guint8*)&pd[offset+10];
254         ipx_snode = (guint8*)&pd[offset+22];
255         ipx_type = pd[offset+5];
256         ipx_length = pntohs(&pd[offset+2]);
257
258         /* Length of IPX datagram plus headers above it. */
259                 len = ipx_length + offset;
260
261         /* Set the payload and captured-payload lengths to the minima of
262            (the IPX length plus the length of the headers above it) and
263            the frame lengths. */
264         if (pi.len > len)
265                 pi.len = len;
266         if (pi.captured_len > len)
267                 pi.captured_len = len;
268
269         if (check_col(fd, COL_RES_DL_DST))
270                 col_add_str(fd, COL_RES_DL_DST,
271                                 ipx_addr_to_str(pntohl(ipx_dnet), ipx_dnode));
272         if (check_col(fd, COL_RES_DL_SRC))
273                 col_add_str(fd, COL_RES_DL_SRC,
274                                 ipx_addr_to_str(pntohl(ipx_snet), ipx_snode));
275
276         if (check_col(fd, COL_PROTOCOL))
277                 col_add_str(fd, COL_PROTOCOL, "IPX");
278         if (check_col(fd, COL_INFO))
279                 col_add_fstr(fd, COL_INFO, "%s (0x%04X)", port_text(ipx_dsocket),
280                                 ipx_dsocket);
281
282         if (tree) {
283                 ipx_checksum = pntohs(&pd[offset]);
284                 ipx_hops = pd[offset+4];
285
286                 ti = proto_tree_add_item(tree, proto_ipx, offset, 30, NULL);
287                 ipx_tree = proto_item_add_subtree(ti, ETT_IPX);
288                 proto_tree_add_item(ipx_tree, hf_ipx_checksum, offset, 2, ipx_checksum);
289                 proto_tree_add_item_format(ipx_tree, hf_ipx_len, offset+2, 2, ipx_length,
290                         "Length: %d bytes", ipx_length);
291                 proto_tree_add_item_format(ipx_tree, hf_ipx_hops, offset+4, 1, ipx_hops,
292                         "Transport Control: %d hops", ipx_hops);
293                 proto_tree_add_item(ipx_tree, hf_ipx_packet_type, offset+5, 1, ipx_type);
294                 proto_tree_add_item(ipx_tree, hf_ipx_dnet, offset+6, 4, ipx_dnet_val);
295                 proto_tree_add_item(ipx_tree, hf_ipx_dnode, offset+10, 6, ipx_dnode);
296                 proto_tree_add_item_format(ipx_tree, hf_ipx_dsocket, offset+16, 2,
297                         ipx_dsocket, "Destination Socket: %s (0x%04X)",
298                         port_text(ipx_dsocket), ipx_dsocket);
299                 proto_tree_add_item(ipx_tree, hf_ipx_snet, offset+18, 4, ipx_snet_val);
300                 proto_tree_add_item(ipx_tree, hf_ipx_snode, offset+22, 6, ipx_snode);
301                 proto_tree_add_item_format(ipx_tree, hf_ipx_ssocket, offset+28, 2,
302                         ipx_ssocket, "Source Socket: %s (0x%04X)", port_text(ipx_ssocket),
303                         ipx_ssocket);
304         }
305         offset += 30;
306
307         switch (ipx_type) {
308                 case IPX_PACKET_TYPE_SPX:
309                         dissect_spx(pd, offset, fd, tree);
310                         break;
311
312                 case IPX_PACKET_TYPE_NCP:
313                         /* Is the destination node 00:00:00:00:00:01 ? */
314                         if (pntohl(ipx_dnode) == 0 && pntohs(ipx_dnode + 4) == 1)
315                                 nw_server_address = pntohl(ipx_dnet);
316
317                         /* Is the source node 00:00:00:00:00:01 ? */
318                         else if (pntohl(ipx_snode) == 0 && pntohs(ipx_snode + 4) == 1)
319                                 nw_server_address = pntohl(ipx_snet);
320                         else
321                                 nw_server_address = 0;
322
323                         dissect_ncp(pd, offset, fd, tree);
324                         break;
325
326                 case IPX_PACKET_TYPE_WANBCAST:
327                 case IPX_PACKET_TYPE_IPX_4:
328                         if (ipx_dsocket == IPX_SOCKET_NETBIOS) {
329                                 dissect_nbipx(pd, offset, fd, tree);
330                                 break;
331                         }
332                         /* else fall through */
333
334                 case 0: /* IPX, fall through to default */
335                         /* XXX - should type 0's be dissected as NBIPX
336                            if they're aimed at the NetBIOS socket? */
337                 default:
338                         dissect = port_func(ipx_dsocket);
339                         if (dissect) {
340                                 dissect(pd, offset, fd, tree);
341                         }
342                         else {
343                                 dissect = port_func(ipx_ssocket);
344                                 if (dissect) {
345                                         dissect(pd, offset, fd, tree);
346                                 }
347                                 else {
348                                         dissect_data(pd, offset, fd, tree);
349                                 }
350                         }
351                         break;
352         }
353 }
354
355
356 /* ================================================================= */
357 /* SPX                                                               */
358 /* ================================================================= */
359 static char*
360 spx_conn_ctrl(u_char ctrl)
361 {
362         int i=0;
363
364         static struct conn_info conns[] = {
365                 { 0x10, "End-of-Message" },
366                 { 0x20, "Attention" },
367                 { 0x40, "Acknowledgment Required"},
368                 { 0x80, "System Packet"}
369         };
370
371         while (conns[i].text != NULL) {
372                 if (conns[i].ctrl == ctrl) {
373                         return conns[i].text;
374                 }
375                 i++;
376         }
377         return "Unknown";
378 }
379
380 static char*
381 spx_datastream(u_char type)
382 {
383         switch (type) {
384                 case 0xfe:
385                         return "End-of-Connection";
386                 case 0xff:
387                         return "End-of-Connection Acknowledgment";
388                 default:
389                         return "Client-Defined";
390         }
391 }
392
393 static void
394 dissect_spx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
395         proto_tree      *spx_tree;
396         proto_item      *ti;
397
398         if (check_col(fd, COL_PROTOCOL))
399                 col_add_str(fd, COL_PROTOCOL, "SPX");
400         if (check_col(fd, COL_INFO))
401                 col_add_str(fd, COL_INFO, "SPX");
402
403         if (tree) {
404                 ti = proto_tree_add_item(tree, proto_spx, offset, 12, NULL);
405                 spx_tree = proto_item_add_subtree(ti, ETT_SPX);
406
407                 proto_tree_add_text(spx_tree, offset,      1,
408                         "Connection Control: %s (0x%02X)",
409                         spx_conn_ctrl(pd[offset]), pd[offset]);
410
411                 proto_tree_add_text(spx_tree, offset+1,     1,
412                         "Datastream Type: %s (0x%02X)",
413                         spx_datastream(pd[offset+1]), pd[offset+1]);
414
415                 proto_tree_add_text(spx_tree, offset+2,     2,
416                         "Source Connection ID: %d", pntohs( &pd[offset+2] ) );
417
418                 proto_tree_add_text(spx_tree, offset+4,     2,
419                         "Destination Connection ID: %d", pntohs( &pd[offset+4] ) );
420
421                 proto_tree_add_text(spx_tree, offset+6,     2,
422                         "Sequence Number: %d", pntohs( &pd[offset+6] ) );
423
424                 proto_tree_add_text(spx_tree, offset+8,     2,
425                         "Acknowledgment Number: %d", pntohs( &pd[offset+8] ) );
426
427                 proto_tree_add_text(spx_tree, offset+10,     2,
428                         "Allocation Number: %d", pntohs( &pd[offset+10] ) );
429
430                 offset += 12;
431                 dissect_data(pd, offset, fd, tree);
432         }
433 }
434
435 /* ================================================================= */
436 /* IPX RIP                                                           */
437 /* ================================================================= */
438 static void
439 dissect_ipxrip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
440         proto_tree      *rip_tree;
441         proto_item      *ti;
442         guint16         operation;
443         struct ipx_rt_def route;
444         int             cursor;
445
446         char            *rip_type[2] = { "Request", "Response" };
447
448         operation = pntohs(&pd[offset]) - 1;
449
450         if (check_col(fd, COL_PROTOCOL))
451          col_add_str(fd, COL_PROTOCOL, "IPX RIP");
452         if (check_col(fd, COL_PROTOCOL)) {
453          if (operation < 2) {
454                  col_add_str(fd, COL_INFO, rip_type[operation]);
455          }
456          else {
457                  col_add_str(fd, COL_INFO, "Unknown Packet Type");
458          }
459         }
460
461         if (tree) {
462                 ti = proto_tree_add_item(tree, proto_ipxrip, offset, END_OF_FRAME, NULL);
463                 rip_tree = proto_item_add_subtree(ti, ETT_IPXRIP);
464
465                 if (operation < 2) {
466                         proto_tree_add_text(rip_tree, offset, 2,
467                         "RIP packet type: %s", rip_type[operation]);
468                 }
469                 else {
470                         proto_tree_add_text(rip_tree, offset, 2, "Unknown RIP packet type");
471                 }
472
473                 for (cursor = offset + 2; cursor < fd->cap_len; cursor += 8) {
474                         memcpy(&route.network, &pd[cursor], 4);
475                         route.hops = pntohs(&pd[cursor+4]);
476                         route.ticks = pntohs(&pd[cursor+6]);
477
478                         if (operation == IPX_RIP_REQUEST - 1) {
479                                 proto_tree_add_text(rip_tree, cursor,      8,
480                                         "Route Vector: %s, %d hop%s, %d tick%s",
481                                         ipxnet_to_string((guint8*)&route.network),
482                                         route.hops,  route.hops  == 1 ? "" : "s",
483                                         route.ticks, route.ticks == 1 ? "" : "s");
484                         }
485                         else {
486                                 proto_tree_add_text(rip_tree, cursor,      8,
487                                         "Route Vector: %s, %d hop%s, %d tick%s (%d ms)",
488                                         ipxnet_to_string((guint8*)&route.network),
489                                         route.hops,  route.hops  == 1 ? "" : "s",
490                                         route.ticks, route.ticks == 1 ? "" : "s",
491                                         route.ticks * 1000 / 18);
492                         }
493                 }
494         }
495 }
496
497
498
499 /* ================================================================= */
500 /* SAP                                                                                                                           */
501 /* ================================================================= */
502 static char*
503 server_type(guint16 type)
504 {
505         int i=0;
506
507         /* some of these are from ncpfs, others are from the book */
508         static struct server_info       servers[] = {
509                 { 0x0001,       "User" },
510                 { 0x0002,       "User Group" },
511                 { 0x0003,       "Print Queue" },
512                 { 0x0004,       "File server" },
513                 { 0x0005,       "Job server" },
514                 { 0x0007,       "Print server" },
515                 { 0x0008,       "Archive server" },
516                 { 0x0009,       "Archive server" },
517                 { 0x000a,       "Job queue" },
518                 { 0x000b,       "Administration" },
519                 { 0x0021,       "NAS SNA gateway" },
520                 { 0x0024,       "Remote bridge" },
521                 { 0x0026,       "Bridge server" },
522                 { 0x0027,       "TCP/IP gateway" },
523                 { 0x002d,       "Time Synchronization VAP" },
524                 { 0x002e,       "Archive Server Dynamic SAP" },
525                 { 0x0047,       "Advertising print server" },
526                 { 0x004b,       "Btrieve VAP 5.0" },
527                 { 0x004c,       "SQL VAP" },
528                 { 0x0050,       "Btrieve VAP" },
529                 { 0x0053,       "Print Queue VAP" },
530                 { 0x007a,       "TES NetWare for VMS" },
531                 { 0x0098,       "NetWare access server" },
532                 { 0x009a,       "Named Pipes server" },
533                 { 0x009e,       "Portable NetWare Unix" },
534                 { 0x0107,       "NetWare 386" },
535                 { 0x0111,       "Test server" },
536                 { 0x0133,       "NetWare Name Service" },
537                 { 0x0166,       "NetWare management" },
538                 { 0x026a,       "NetWare management" },
539                 { 0x026b,       "Time synchronization" },
540                 { 0x0278,       "NetWare Directory server" },
541                 { 0x055d,       "Attachmate SNA gateway" },
542                 { 0x0000,       NULL }
543         };
544
545         while (servers[i].text != NULL) {
546                 if (servers[i].type == type) {
547                         return servers[i].text;
548                 }
549                 i++;
550         }
551         return "Unknown";
552 }
553
554 static void
555 dissect_sap(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
556
557         proto_tree      *sap_tree, *s_tree;
558         proto_item      *ti;
559         int             cursor;
560         struct sap_query query;
561         struct sap_server_ident server;
562
563         char            *sap_type[4] = { "General Query", "General Response",
564                 "Nearest Query", "Nearest Response" };
565
566         query.query_type = pntohs(&pd[offset]);
567         query.server_type = pntohs(&pd[offset+2]);
568
569         if (check_col(fd, COL_PROTOCOL))
570                 col_add_str(fd, COL_PROTOCOL, "SAP");
571         if (check_col(fd, COL_INFO)) {
572                 if (query.query_type >= 1 && query.query_type <= 4) {
573                         col_add_str(fd, COL_INFO, sap_type[query.query_type - 1]);
574                 }
575                 else {
576                         col_add_str(fd, COL_INFO, "Unknown Packet Type");
577                 }
578         }
579
580         if (tree) {
581                 ti = proto_tree_add_item(tree, proto_sap, offset, END_OF_FRAME, NULL);
582                 sap_tree = proto_item_add_subtree(ti, ETT_IPXSAP);
583
584                 if (query.query_type >= 1 && query.query_type <= 4) {
585                         proto_tree_add_text(sap_tree, offset, 2, sap_type[query.query_type - 1]);
586                 }
587                 else {
588                         proto_tree_add_text(sap_tree, offset, 2,
589                                         "Unknown SAP Packet Type %d", query.query_type);
590                 }
591
592                 if (query.query_type == IPX_SAP_GENERAL_RESPONSE ||
593                                 query.query_type == IPX_SAP_NEAREST_RESPONSE) { /* responses */
594
595                         for (cursor = offset + 2; (cursor + 64) <= fd->cap_len; cursor += 64) {
596                                 server.server_type = pntohs(&pd[cursor]);
597                                 memcpy(server.server_name, &pd[cursor+2], 48);
598                                 memcpy(&server.server_network, &pd[cursor+50], 4);
599                                 memcpy(&server.server_node, &pd[cursor+54], 6);
600                                 server.server_port = pntohs(&pd[cursor+60]);
601                                 server.intermediate_network = pntohs(&pd[cursor+62]);
602
603                                 ti = proto_tree_add_text(sap_tree, cursor+2, 48,
604                                         "Server Name: %s", server.server_name);
605                                 s_tree = proto_item_add_subtree(ti, ETT_IPXSAP_SERVER);
606
607                                 proto_tree_add_text(s_tree, cursor, 2, "Server Type: %s (0x%04X)",
608                                                 server_type(server.server_type), server.server_type);
609                                 proto_tree_add_text(s_tree, cursor+50, 4, "Network: %s",
610                                                 ipxnet_to_string((guint8*)&pd[cursor+50]));
611                                 proto_tree_add_text(s_tree, cursor+54, 6, "Node: %s",
612                                                 ether_to_str((guint8*)&pd[cursor+54]));
613                                 proto_tree_add_text(s_tree, cursor+60, 2, "Socket: %s (0x%04X)",
614                                                 port_text(server.server_port), server.server_port);
615                                 proto_tree_add_text(s_tree, cursor+62, 2,
616                                                 "Intermediate Networks: %d",
617                                                 server.intermediate_network);
618                         }
619                 }
620                 else {  /* queries */
621                         proto_tree_add_text(sap_tree, offset+2, 2, "Server Type: %s (0x%04X)",
622                                         server_type(query.server_type), query.server_type);
623                 }
624         }
625 }
626
627
628 void
629 proto_register_ipx(void)
630 {
631         static hf_register_info hf_ipx[] = {
632                 { &hf_ipx_checksum,
633                 { "Checksum",           "ipx.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
634                         "" }},
635
636                 { &hf_ipx_len,
637                 { "Length",             "ipx.len", FT_UINT16, BASE_DEC, NULL, 0x0,
638                         "" }},
639
640                 { &hf_ipx_hops,
641                 { "Transport Control (Hops)", "ipx.hops", FT_UINT8, BASE_DEC, NULL, 0x0,
642                         "" }},
643
644                 { &hf_ipx_packet_type,
645                 { "Packet Type",        "ipx.packet_type", FT_UINT8, BASE_HEX, VALS(ipx_packet_type_vals),
646                         0x0,
647                         "" }},
648
649                 { &hf_ipx_dnet,
650                 { "Destination Network","ipx.dst.net", FT_IPXNET, BASE_NONE, NULL, 0x0,
651                         "" }},
652
653                 { &hf_ipx_dnode,
654                 { "Destination Node",   "ipx.dst.node", FT_ETHER, BASE_NONE, NULL, 0x0,
655                         "" }},
656
657                 { &hf_ipx_dsocket,
658                 { "Destination Socket", "ipx.dst.socket", FT_UINT16, BASE_HEX, NULL, 0x0,
659                         "" }},
660
661                 { &hf_ipx_snet,
662                 { "Source Network","ipx.src.net", FT_IPXNET, BASE_NONE, NULL, 0x0,
663                         "" }},
664
665                 { &hf_ipx_snode,
666                 { "Source Node",        "ipx.src.node", FT_ETHER, BASE_NONE, NULL, 0x0,
667                         "" }},
668
669                 { &hf_ipx_ssocket,
670                 { "Source Socket",      "ipx.src.socket", FT_UINT16, BASE_HEX, NULL, 0x0,
671                         "" }},
672         };
673                 
674         proto_ipx = proto_register_protocol ("Internetwork Packet eXchange", "ipx");
675         proto_register_field_array(proto_ipx, hf_ipx, array_length(hf_ipx));
676
677         proto_spx = proto_register_protocol ("Sequenced Packet eXchange", "spx");
678         
679         proto_ipxrip = proto_register_protocol ("IPX Routing Information Protocol", "ipxrip");
680
681         proto_sap = proto_register_protocol ("Service Advertisement Protocol", "sap");
682 }