Make sure the keysym list is present before allocating a buffer to hold
[obnox/wireshark/wip.git] / packet-nbipx.c
index d43008c33feb8f0a96aacd7a0e370bd64e2b6147..d21f08d5b7833c5a7982ac74c7ecf441e2cd4bed 100644 (file)
@@ -1,23 +1,23 @@
 /* packet-nbipx.c
  * Routines for NetBIOS over IPX packet disassembly
- * Gilbert Ramirez <gram@xiexie.org>
+ * Gilbert Ramirez <gram@alumni.rice.edu>
  *
- * $Id: packet-nbipx.c,v 1.41 2001/09/29 01:19:00 guy Exp $
+ * $Id: packet-nbipx.c,v 1.48 2002/08/28 21:00:22 jmayer Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 # include "config.h"
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
 #include <string.h>
 #include <glib.h>
-#include "packet.h"
+#include <epan/packet.h>
 #include "packet-ipx.h"
 #include "packet-netbios.h"
 
@@ -223,10 +219,10 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        gboolean        has_payload;
        tvbuff_t        *next_tvb;
 
-       if (check_col(pinfo->fd, COL_PROTOCOL))
-               col_set_str(pinfo->fd, COL_PROTOCOL, "NBIPX");
-       if (check_col(pinfo->fd, COL_INFO))
-               col_clear(pinfo->fd, COL_INFO);
+       if (check_col(pinfo->cinfo, COL_PROTOCOL))
+               col_set_str(pinfo->cinfo, COL_PROTOCOL, "NBIPX");
+       if (check_col(pinfo->cinfo, COL_INFO))
+               col_clear(pinfo->cinfo, COL_INFO);
 
        if (pinfo->ipxptype == IPX_PACKET_TYPE_WANBCAST) {
                /*
@@ -267,7 +263,7 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        if (tree) {
                ti = proto_tree_add_item(tree, proto_nbipx, tvb, 0,
-                   0, FALSE);
+                   -1, FALSE);
                nbipx_tree = proto_item_add_subtree(ti, ett_nbipx);
        }
 
@@ -288,8 +284,8 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        case NBIPX_DEREGISTER_NAME:
                name_type_flag = tvb_get_guint8(tvb, offset);
                name_type = get_netbios_name(tvb, offset+2, name);
-               if (check_col(pinfo->fd, COL_INFO)) {
-                       col_add_fstr(pinfo->fd, COL_INFO, "%s %s<%02x>",
+               if (check_col(pinfo->cinfo, COL_INFO)) {
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s<%02x>",
                                val_to_str(packet_type, nbipx_data_stream_type_vals, "Unknown"),
                                name, name_type);
                }
@@ -337,8 +333,8 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        case NBIPX_SESSION_DATA:
        case NBIPX_SESSION_END:
        case NBIPX_SESSION_END_ACK:
-               if (check_col(pinfo->fd, COL_INFO)) {
-                       col_add_fstr(pinfo->fd, COL_INFO, "%s",
+               if (check_col(pinfo->cinfo, COL_INFO)) {
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
                                val_to_str(packet_type, nbipx_data_stream_type_vals, "Unknown"));
                }
                dissect_conn_control(tvb, offset, nbipx_tree);
@@ -410,8 +406,8 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                break;
 
        case NBIPX_DIRECTED_DATAGRAM:
-               if (check_col(pinfo->fd, COL_INFO)) {
-                       col_add_fstr(pinfo->fd, COL_INFO, "%s",
+               if (check_col(pinfo->cinfo, COL_INFO)) {
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
                                val_to_str(packet_type, nbipx_data_stream_type_vals, "Unknown"));
                }
                dissect_conn_control(tvb, offset, nbipx_tree);
@@ -437,8 +433,8 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                break;
 
        default:
-               if (check_col(pinfo->fd, COL_INFO)) {
-                       col_add_fstr(pinfo->fd, COL_INFO, "%s",
+               if (check_col(pinfo->cinfo, COL_INFO)) {
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
                                val_to_str(packet_type, nbipx_data_stream_type_vals, "Unknown"));
                }
 
@@ -536,8 +532,10 @@ proto_register_nbipx(void)
 void
 proto_reg_handoff_nbipx(void)
 {
-       dissector_add("ipx.socket", IPX_SOCKET_NETBIOS, dissect_nbipx,
-           proto_nbipx);
+       dissector_handle_t nbipx_handle;
+
+       nbipx_handle = create_dissector_handle(dissect_nbipx, proto_nbipx);
+       dissector_add("ipx.socket", IPX_SOCKET_NETBIOS, nbipx_handle);
 }
 
 /*
@@ -591,7 +589,7 @@ proto_reg_handoff_nbipx(void)
  *     MAILSLOT_SOCKET (0x553) - used by the redirector and browser
  *             for mailslot datagrams
  *     MESSENGER_SOCKET (0x554) - used by the redirector to send
- *             messages from client to client          
+ *             messages from client to client
  *
  * Name claim/query packets, and mailslot datagrams, are:
  *
@@ -676,10 +674,10 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        int             node_name_type = 0;
        tvbuff_t        *next_tvb;
 
-       if (check_col(pinfo->fd, COL_PROTOCOL))
-               col_set_str(pinfo->fd, COL_PROTOCOL, "NMPI");
-       if (check_col(pinfo->fd, COL_INFO))
-               col_clear(pinfo->fd, COL_INFO);
+       if (check_col(pinfo->cinfo, COL_PROTOCOL))
+               col_set_str(pinfo->cinfo, COL_PROTOCOL, "NMPI");
+       if (check_col(pinfo->cinfo, COL_INFO))
+               col_clear(pinfo->cinfo, COL_INFO);
 
        if (tree) {
                ti = proto_tree_add_item(tree, proto_nmpi, tvb, offset, 68,
@@ -698,51 +696,51 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        name_type = get_netbios_name(tvb, offset+4, name);
        node_name_type = get_netbios_name(tvb, offset+20, node_name);
 
-       if (check_col(pinfo->fd, COL_INFO)) {
+       if (check_col(pinfo->cinfo, COL_INFO)) {
                switch (opcode) {
 
                case INAME_CLAIM:
-                       col_add_fstr(pinfo->fd, COL_INFO, "Claim name %s<%02x>",
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "Claim name %s<%02x>",
                                        name, name_type);
                        break;
 
                case INAME_DELETE:
-                       col_add_fstr(pinfo->fd, COL_INFO, "Delete name %s<%02x>",
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "Delete name %s<%02x>",
                                        name, name_type);
                        break;
 
                case INAME_QUERY:
-                       col_add_fstr(pinfo->fd, COL_INFO, "Query name %s<%02x>",
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "Query name %s<%02x>",
                                        name, name_type);
                        break;
 
                case INAME_FOUND:
-                       col_add_fstr(pinfo->fd, COL_INFO, "Name %s<%02x> found",
+                       col_add_fstr(pinfo->cinfo, COL_INFO, "Name %s<%02x> found",
                                        name, name_type);
                        break;
 
                case IMSG_HANGUP:
-                       col_add_fstr(pinfo->fd, COL_INFO,
+                       col_add_fstr(pinfo->cinfo, COL_INFO,
                            "Messenger hangup on %s<%02x>", name, name_type);
                        break;
 
                case IMSLOT_SEND:
-                       col_add_fstr(pinfo->fd, COL_INFO,
+                       col_add_fstr(pinfo->cinfo, COL_INFO,
                            "Mailslot write to %s<%02x>", name, name_type);
                        break;
 
                case IMSLOT_FIND:
-                       col_add_fstr(pinfo->fd, COL_INFO,
+                       col_add_fstr(pinfo->cinfo, COL_INFO,
                            "Find mailslot name %s<%02x>", name, name_type);
                        break;
 
                case IMSLOT_NAME:
-                       col_add_fstr(pinfo->fd, COL_INFO,
+                       col_add_fstr(pinfo->cinfo, COL_INFO,
                            "Mailslot name %s<%02x> found", name, name_type);
                        break;
 
                default:
-                       col_add_fstr(pinfo->fd, COL_INFO,
+                       col_add_fstr(pinfo->cinfo, COL_INFO,
                            "Unknown NMPI op 0x%02x: name %s<%02x>",
                            opcode, name, name_type);
                        break;
@@ -794,8 +792,11 @@ proto_register_nmpi(void)
 void
 proto_reg_handoff_nmpi(void)
 {
+       dissector_handle_t nmpi_handle;
+
+       nmpi_handle = create_dissector_handle(dissect_nmpi, proto_nmpi);
        dissector_add("ipx.socket", IPX_SOCKET_NWLINK_SMB_NAMEQUERY,
-           dissect_nmpi, proto_nmpi);
+           nmpi_handle);
        dissector_add("ipx.socket", IPX_SOCKET_NWLINK_SMB_MAILSLOT,
-           dissect_nmpi, proto_nmpi);
+           nmpi_handle);
 }