bugfix to a bug reported by Ian Schorr:
[obnox/wireshark/wip.git] / packet-gnutella.c
index 3d2c6d92d35a193c0eb54eef420472ea988294f7..d425030e394e55487afde1a8306f8d3cd72bfa77 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for gnutella dissection
  * Copyright 2001, B. Johannessen <bob@havoq.com>
  *
- * $Id: packet-gnutella.c,v 1.5 2001/10/25 21:25:51 gram Exp $
+ * $Id: packet-gnutella.c,v 1.15 2002/08/28 21:00:13 jmayer Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
  * 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 <stdlib.h>
 #include <string.h>
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
 #include <glib.h>
 
-#ifdef NEED_SNPRINTF_H
-#include "snprintf.h"
-#endif
-
 
-#include "packet.h"
+#include <epan/packet.h>
 #include "packet-gnutella.h"
 
 static int proto_gnutella = -1;
@@ -94,11 +82,7 @@ static int hf_gnutella_push_port = -1;
 
 static gint ett_gnutella = -1;
 
-static void dissect_gnutella_pong(tvbuff_t *tvb, int offset, proto_tree *tree, int size) {
-
-       int port, ip0, ip1, ip2, ip3;
-       int files, kbytes;
-       unsigned long ip;
+static void dissect_gnutella_pong(tvbuff_t *tvb, guint offset, proto_tree *tree, guint size) {
 
        if(offset + size > tvb_length(tvb)) {
                proto_tree_add_item(tree,
@@ -110,54 +94,37 @@ static void dissect_gnutella_pong(tvbuff_t *tvb, int offset, proto_tree *tree, i
                return;
        }
 
-       port = tvb_get_letohs(tvb, offset + GNUTELLA_PONG_PORT_OFFSET);
-
-       ip  = tvb_get_letohl(tvb, offset + GNUTELLA_PONG_IP_OFFSET);
-
-       ip0 = tvb_get_guint8(tvb, offset + GNUTELLA_PONG_IP_OFFSET);
-       ip1 = tvb_get_guint8(tvb, offset + GNUTELLA_PONG_IP_OFFSET + 1);
-       ip2 = tvb_get_guint8(tvb, offset + GNUTELLA_PONG_IP_OFFSET + 2);
-       ip3 = tvb_get_guint8(tvb, offset + GNUTELLA_PONG_IP_OFFSET + 3);
-
-       files = tvb_get_letohl(tvb, offset + GNUTELLA_PONG_FILES_OFFSET);
-
-       kbytes = tvb_get_letohl(tvb, offset + GNUTELLA_PONG_KBYTES_OFFSET);
-
        proto_tree_add_item(tree,
                hf_gnutella_pong_port,
                tvb,
                offset + GNUTELLA_PONG_PORT_OFFSET,
                GNUTELLA_PORT_LENGTH,
-               port);
+               TRUE);
 
-       proto_tree_add_ipv4_format(tree,
+       proto_tree_add_item(tree,
                hf_gnutella_pong_ip,
                tvb,
                offset + GNUTELLA_PONG_IP_OFFSET,
                GNUTELLA_IP_LENGTH,
-               ip,
-               "IP: %i.%i.%i.%i",
-               ip0, ip1, ip2, ip3);
+        FALSE);
 
        proto_tree_add_item(tree,
                hf_gnutella_pong_files,
                tvb,
                offset + GNUTELLA_PONG_FILES_OFFSET,
                GNUTELLA_LONG_LENGTH,
-               files);
+               TRUE);
 
        proto_tree_add_item(tree,
                hf_gnutella_pong_kbytes,
                tvb,
                offset + GNUTELLA_PONG_KBYTES_OFFSET,
                GNUTELLA_LONG_LENGTH,
-               kbytes);
+               TRUE);
 
 }
 
-static void dissect_gnutella_query(tvbuff_t *tvb, int offset, proto_tree *tree, int size) {
-
-       int min_speed;
+static void dissect_gnutella_query(tvbuff_t *tvb, guint offset, proto_tree *tree, guint size) {
 
        if(offset + size > tvb_length(tvb)) {
                proto_tree_add_item(tree,
@@ -169,14 +136,12 @@ static void dissect_gnutella_query(tvbuff_t *tvb, int offset, proto_tree *tree,
                return;
        }
 
-       min_speed = tvb_get_letohs(tvb, offset + GNUTELLA_QUERY_SPEED_OFFSET);
-
        proto_tree_add_item(tree,
                hf_gnutella_query_min_speed,
                tvb,
                offset + GNUTELLA_QUERY_SPEED_OFFSET,
                GNUTELLA_SHORT_LENGTH,
-               min_speed);
+        TRUE);
 
     if (size > GNUTELLA_SHORT_LENGTH) {
         proto_tree_add_item(tree,
@@ -195,18 +160,16 @@ static void dissect_gnutella_query(tvbuff_t *tvb, int offset, proto_tree *tree,
     }
 }
 
-static void dissect_gnutella_queryhit(tvbuff_t *tvb, int offset, proto_tree *tree, int size) {
+static void dissect_gnutella_queryhit(tvbuff_t *tvb, guint offset, proto_tree *tree, guint size) {
 
        proto_tree *qhi, *hit_tree;
-       int hit_count, port, speed;
-       int ip0, ip1, ip2, ip3, i;
-       int hit_offset, idx, hit_size;
+       int hit_count, i;
+       int hit_offset;
        int name_length, extra_length;
        int idx_at_offset, size_at_offset;
        int servent_id_at_offset;
        int name_at_offset, extra_at_offset;
        int cur_char, remaining, used;
-       unsigned long ip;
 
        if(offset + size > tvb_length(tvb)) {
                proto_tree_add_item(tree,
@@ -220,18 +183,7 @@ static void dissect_gnutella_queryhit(tvbuff_t *tvb, int offset, proto_tree *tre
 
        hit_count = tvb_get_guint8(tvb, offset + GNUTELLA_QUERYHIT_COUNT_OFFSET);
 
-       port = tvb_get_ntohs(tvb, offset + GNUTELLA_QUERYHIT_PORT_OFFSET);
-
-       ip  = tvb_get_letohl(tvb, offset + GNUTELLA_QUERYHIT_IP_OFFSET);
-
-       ip0 = tvb_get_guint8(tvb, offset + GNUTELLA_QUERYHIT_IP_OFFSET);
-       ip1 = tvb_get_guint8(tvb, offset + GNUTELLA_QUERYHIT_IP_OFFSET + 1);
-       ip2 = tvb_get_guint8(tvb, offset + GNUTELLA_QUERYHIT_IP_OFFSET + 2);
-       ip3 = tvb_get_guint8(tvb, offset + GNUTELLA_QUERYHIT_IP_OFFSET + 3);
-
-       speed = tvb_get_letohl(tvb, offset + GNUTELLA_QUERYHIT_SPEED_OFFSET);
-
-       proto_tree_add_item(tree,
+       proto_tree_add_uint(tree,
                hf_gnutella_queryhit_count,
                tvb,
                offset + GNUTELLA_QUERYHIT_COUNT_OFFSET,
@@ -243,30 +195,25 @@ static void dissect_gnutella_queryhit(tvbuff_t *tvb, int offset, proto_tree *tre
                tvb,
                offset + GNUTELLA_QUERYHIT_PORT_OFFSET,
                GNUTELLA_PORT_LENGTH,
-               port);
+               TRUE);
 
-       proto_tree_add_ipv4_format(tree,
+       proto_tree_add_item(tree,
                hf_gnutella_queryhit_ip,
                tvb,
                offset + GNUTELLA_QUERYHIT_IP_OFFSET,
                GNUTELLA_IP_LENGTH,
-               ip,
-               "IP: %i.%i.%i.%i",
-               ip0, ip1, ip2, ip3);
+               FALSE);
 
        proto_tree_add_item(tree,
                hf_gnutella_queryhit_speed,
                tvb,
                offset + GNUTELLA_QUERYHIT_SPEED_OFFSET,
                GNUTELLA_LONG_LENGTH,
-               speed);
+               TRUE);
 
        hit_offset = offset + GNUTELLA_QUERYHIT_FIRST_HIT_OFFSET;
 
        for(i = 0; i < hit_count; i++) {
-               idx  = tvb_get_letohl(tvb, hit_offset + GNUTELLA_QUERYHIT_HIT_INDEX_OFFSET);
-               hit_size = tvb_get_letohl(tvb, hit_offset + GNUTELLA_QUERYHIT_HIT_SIZE_OFFSET);
-
                idx_at_offset  = hit_offset;
                size_at_offset = hit_offset + GNUTELLA_QUERYHIT_HIT_SIZE_OFFSET;
 
@@ -317,14 +264,14 @@ static void dissect_gnutella_queryhit(tvbuff_t *tvb, int offset, proto_tree *tre
                        tvb,
                        idx_at_offset,
                        GNUTELLA_LONG_LENGTH,
-                       idx);
+                       TRUE);
 
                proto_tree_add_item(hit_tree,
                        hf_gnutella_queryhit_hit_size,
                        tvb,
                        size_at_offset,
                        GNUTELLA_LONG_LENGTH,
-                       hit_size);
+                       TRUE);
 
                proto_tree_add_item(hit_tree,
                        hf_gnutella_queryhit_hit_name,
@@ -369,10 +316,7 @@ static void dissect_gnutella_queryhit(tvbuff_t *tvb, int offset, proto_tree *tre
 
 }
 
-static void dissect_gnutella_push(tvbuff_t *tvb, int offset, proto_tree *tree, int size) {
-
-       int idx, ip0, ip1, ip2, ip3, port;
-       unsigned long ip;
+static void dissect_gnutella_push(tvbuff_t *tvb, guint offset, proto_tree *tree, guint size) {
 
        if(offset + size > tvb_length(tvb)) {
                proto_tree_add_item(tree,
@@ -384,14 +328,6 @@ static void dissect_gnutella_push(tvbuff_t *tvb, int offset, proto_tree *tree, i
                return;
        }
 
-       idx  = tvb_get_letohl(tvb, offset + GNUTELLA_PUSH_INDEX_OFFSET);
-       ip   = tvb_get_letohl(tvb, offset + GNUTELLA_PUSH_IP_OFFSET);
-       ip0  = tvb_get_guint8(tvb, offset + GNUTELLA_PUSH_IP_OFFSET);
-       ip1  = tvb_get_guint8(tvb, offset + GNUTELLA_PUSH_IP_OFFSET + 1);
-       ip2  = tvb_get_guint8(tvb, offset + GNUTELLA_PUSH_IP_OFFSET + 2);
-       ip3  = tvb_get_guint8(tvb, offset + GNUTELLA_PUSH_IP_OFFSET + 3);
-       port = tvb_get_letohs(tvb, offset + GNUTELLA_PUSH_PORT_OFFSET);
-
        proto_tree_add_item(tree,
                hf_gnutella_push_servent_id,
                tvb,
@@ -404,23 +340,21 @@ static void dissect_gnutella_push(tvbuff_t *tvb, int offset, proto_tree *tree, i
                tvb,
                offset + GNUTELLA_PUSH_INDEX_OFFSET,
                GNUTELLA_LONG_LENGTH,
-               idx);
+               TRUE);
 
-       proto_tree_add_ipv4_format(tree,
+       proto_tree_add_item(tree,
                hf_gnutella_push_ip,
                tvb,
                offset + GNUTELLA_PUSH_IP_OFFSET,
                GNUTELLA_IP_LENGTH,
-               ip,
-               "IP: %i.%i.%i.%i",
-               ip0, ip1, ip2, ip3);
+               FALSE);
 
        proto_tree_add_item(tree,
                hf_gnutella_push_port,
                tvb,
                offset + GNUTELLA_PUSH_PORT_OFFSET,
                GNUTELLA_PORT_LENGTH,
-               port);
+               TRUE);
 
 }
 
@@ -430,27 +364,27 @@ static void dissect_gnutella(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
        proto_tree *gnutella_tree, *gnutella_header_tree, *gnutella_pong_tree;
        proto_tree *gnutella_queryhit_tree, *gnutella_push_tree;
        proto_tree *gnutella_query_tree;
-       int snap_len, payload_descriptor, ttl, hops, offset;
+       int snap_len, payload_descriptor, offset;
        unsigned int size;
        char *payload_descriptor_text;
 
-       if (check_col(pinfo->fd, COL_PROTOCOL)) 
-               col_set_str(pinfo->fd, COL_PROTOCOL, "Gnutella");
-    
-       if (check_col(pinfo->fd, COL_INFO)) 
-               col_set_str(pinfo->fd, COL_INFO, "Gnutella");
+       if (check_col(pinfo->cinfo, COL_PROTOCOL))
+               col_set_str(pinfo->cinfo, COL_PROTOCOL, "Gnutella");
+
+       if (check_col(pinfo->cinfo, COL_INFO))
+               col_set_str(pinfo->cinfo, COL_INFO, "Gnutella");
 
        snap_len = tvb_length(tvb);
 
        if(snap_len < GNUTELLA_HEADER_LENGTH) {
-               if (check_col(pinfo->fd, COL_INFO)) 
-                       col_append_fstr(pinfo->fd, COL_INFO,
+               if (check_col(pinfo->cinfo, COL_INFO))
+                       col_append_fstr(pinfo->cinfo, COL_INFO,
                                        ", %i bytes [INCOMPLETE]", snap_len);
                return;
        }
        else {
-               if (check_col(pinfo->fd, COL_INFO)) 
-                       col_append_fstr(pinfo->fd, COL_INFO,
+               if (check_col(pinfo->cinfo, COL_INFO))
+                       col_append_fstr(pinfo->cinfo, COL_INFO,
                                        ", %i bytes", snap_len);
        }
 
@@ -459,7 +393,7 @@ static void dissect_gnutella(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
                        proto_gnutella,
                        tvb,
                        0,
-                       tvb_length(tvb),
+                       -1,
                        FALSE);
                gnutella_tree = proto_item_add_subtree(ti, ett_gnutella);
 
@@ -483,12 +417,6 @@ static void dissect_gnutella(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
                                tvb,
                                offset +
                                GNUTELLA_HEADER_PAYLOAD_OFFSET);
-                       ttl = tvb_get_guint8(
-                               tvb,
-                               offset + GNUTELLA_HEADER_TTL_OFFSET);
-                       hops = tvb_get_guint8(
-                               tvb,
-                               offset + GNUTELLA_HEADER_HOPS_OFFSET);
                        size = tvb_get_letohl(
                                tvb,
                                offset + GNUTELLA_HEADER_SIZE_OFFSET);
@@ -544,16 +472,16 @@ static void dissect_gnutella(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
                                tvb,
                                offset + GNUTELLA_HEADER_TTL_OFFSET,
                                GNUTELLA_BYTE_LENGTH,
-                               ttl);
+                               FALSE);
 
                        proto_tree_add_item(gnutella_header_tree,
                                hf_gnutella_header_hops,
                                tvb,
                                offset + GNUTELLA_HEADER_HOPS_OFFSET,
                                GNUTELLA_BYTE_LENGTH,
-                               hops);
+                               FALSE);
 
-                       proto_tree_add_item(gnutella_header_tree,
+                       proto_tree_add_uint(gnutella_header_tree,
                                hf_gnutella_header_size,
                                tvb,
                                offset + GNUTELLA_HEADER_SIZE_OFFSET,
@@ -641,172 +569,172 @@ static void dissect_gnutella(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
 }
 
 
-void proto_register_gnutella(void) {                 
+void proto_register_gnutella(void) {
 
        static hf_register_info hf[] = {
                { &hf_gnutella_header,
                        { "Descriptor Header", "gnutella.header",
-                       FT_NONE, BASE_NONE, NULL, 0,          
+                       FT_NONE, BASE_NONE, NULL, 0,
                        "Gnutella Descriptor Header", HFILL }
                },
                { &hf_gnutella_pong_payload,
                        { "Pong", "gnutella.pong.payload",
-                       FT_NONE, BASE_NONE, NULL, 0,          
+                       FT_NONE, BASE_NONE, NULL, 0,
                        "Gnutella Pong Payload", HFILL }
                },
                { &hf_gnutella_push_payload,
                        { "Push", "gnutella.push.payload",
-                       FT_NONE, BASE_NONE, NULL, 0,          
+                       FT_NONE, BASE_NONE, NULL, 0,
                        "Gnutella Push Payload", HFILL }
                },
                { &hf_gnutella_query_payload,
                        { "Query", "gnutella.query.payload",
-                       FT_NONE, BASE_NONE, NULL, 0,          
+                       FT_NONE, BASE_NONE, NULL, 0,
                        "Gnutella Query Payload", HFILL }
                },
                { &hf_gnutella_queryhit_payload,
                        { "QueryHit", "gnutella.queryhit.payload",
-                       FT_NONE, BASE_NONE, NULL, 0,          
+                       FT_NONE, BASE_NONE, NULL, 0,
                        "Gnutella QueryHit Payload", HFILL }
                },
                { &hf_gnutella_truncated,
                        { "Truncated Frame", "gnutella.truncated",
-                       FT_NONE, BASE_NONE, NULL, 0,          
+                       FT_NONE, BASE_NONE, NULL, 0,
                        "The Gnutella Frame Was Truncated", HFILL }
                },
                { &hf_gnutella_stream,
                        { "Gnutella Upload / Download Stream", "gnutella.stream",
-                       FT_NONE, BASE_NONE, NULL, 0,          
+                       FT_NONE, BASE_NONE, NULL, 0,
                        "Gnutella Upload / Download Stream", HFILL }
                },
                { &hf_gnutella_header_id,
                        { "ID", "gnutella.header.id",
-                       FT_BYTES, BASE_HEX, NULL, 0,          
+                       FT_BYTES, BASE_HEX, NULL, 0,
                        "Gnutella Descriptor ID", HFILL }
                },
                { &hf_gnutella_header_payload,
                        { "Payload", "gnutella.header.payload",
-                       FT_UINT8, BASE_DEC, NULL, 0,          
+                       FT_UINT8, BASE_DEC, NULL, 0,
                        "Gnutella Descriptor Payload", HFILL }
                },
                { &hf_gnutella_header_ttl,
                        { "TTL", "gnutella.header.ttl",
-                       FT_UINT8, BASE_DEC, NULL, 0,          
+                       FT_UINT8, BASE_DEC, NULL, 0,
                        "Gnutella Descriptor Time To Live", HFILL }
                },
                { &hf_gnutella_header_hops,
                        { "Hops", "gnutella.header.hops",
-                       FT_UINT8, BASE_DEC, NULL, 0,          
+                       FT_UINT8, BASE_DEC, NULL, 0,
                        "Gnutella Descriptor Hop Count", HFILL }
                },
                { &hf_gnutella_header_size,
                        { "Length", "gnutella.header.size",
-                       FT_UINT8, BASE_DEC, NULL, 0,          
+                       FT_UINT8, BASE_DEC, NULL, 0,
                        "Gnutella Descriptor Payload Length", HFILL }
                },
                { &hf_gnutella_pong_port,
                        { "Port", "gnutella.pong.port",
-                       FT_UINT16, BASE_DEC, NULL, 0,          
+                       FT_UINT16, BASE_DEC, NULL, 0,
                        "Gnutella Pong TCP Port", HFILL }
                },
                { &hf_gnutella_pong_ip,
                        { "IP", "gnutella.pong.ip",
-                       FT_IPv4, BASE_DEC, NULL, 0,          
+                       FT_IPv4, BASE_DEC, NULL, 0,
                        "Gnutella Pong IP Address", HFILL }
                },
                { &hf_gnutella_pong_files,
                        { "Files Shared", "gnutella.pong.files",
-                       FT_UINT32, BASE_DEC, NULL, 0,          
+                       FT_UINT32, BASE_DEC, NULL, 0,
                        "Gnutella Pong Files Shared", HFILL }
                },
                { &hf_gnutella_pong_kbytes,
                        { "KBytes Shared", "gnutella.pong.kbytes",
-                       FT_UINT32, BASE_DEC, NULL, 0,          
+                       FT_UINT32, BASE_DEC, NULL, 0,
                        "Gnutella Pong KBytes Shared", HFILL }
                },
                { &hf_gnutella_query_min_speed,
                        { "Min Speed", "gnutella.query.min_speed",
-                       FT_UINT32, BASE_DEC, NULL, 0,          
+                       FT_UINT32, BASE_DEC, NULL, 0,
                        "Gnutella Query Minimum Speed", HFILL }
                },
                { &hf_gnutella_query_search,
                        { "Search", "gnutella.query.search",
-                       FT_STRINGZ, BASE_NONE, NULL, 0,          
+                       FT_STRINGZ, BASE_NONE, NULL, 0,
                        "Gnutella Query Search", HFILL }
                },
                { &hf_gnutella_queryhit_hit,
                        { "Hit", "gnutella.queryhit.hit",
-                       FT_NONE, BASE_NONE, NULL, 0,          
+                       FT_NONE, BASE_NONE, NULL, 0,
                        "Gnutella QueryHit", HFILL }
                },
                { &hf_gnutella_queryhit_hit_index,
                        { "Index", "gnutella.queryhit.hit.index",
-                       FT_UINT32, BASE_DEC, NULL, 0,          
+                       FT_UINT32, BASE_DEC, NULL, 0,
                        "Gnutella QueryHit Index", HFILL }
                },
                { &hf_gnutella_queryhit_hit_size,
                        { "Size", "gnutella.queryhit.hit.size",
-                       FT_UINT32, BASE_DEC, NULL, 0,          
+                       FT_UINT32, BASE_DEC, NULL, 0,
                        "Gnutella QueryHit Size", HFILL }
                },
                { &hf_gnutella_queryhit_hit_name,
                        { "Name", "gnutella.queryhit.hit.name",
-                       FT_STRING, BASE_NONE, NULL, 0,          
+                       FT_STRING, BASE_NONE, NULL, 0,
                        "Gnutella Query Name", HFILL }
                },
                { &hf_gnutella_queryhit_hit_extra,
                        { "Extra", "gnutella.queryhit.hit.extra",
-                       FT_BYTES, BASE_HEX, NULL, 0,          
+                       FT_BYTES, BASE_HEX, NULL, 0,
                        "Gnutella Query Extra", HFILL }
                },
                { &hf_gnutella_queryhit_count,
                        { "Count", "gnutella.queryhit.count",
-                       FT_UINT8, BASE_DEC, NULL, 0,          
+                       FT_UINT8, BASE_DEC, NULL, 0,
                        "Gnutella QueryHit Count", HFILL }
                },
                { &hf_gnutella_queryhit_port,
                        { "Port", "gnutella.queryhit.port",
-                       FT_UINT16, BASE_DEC, NULL, 0,          
+                       FT_UINT16, BASE_DEC, NULL, 0,
                        "Gnutella QueryHit Port", HFILL }
                },
                { &hf_gnutella_queryhit_ip,
                        { "IP", "gnutella.queryhit.ip",
-                       FT_IPv4, BASE_DEC, NULL, 0,          
+                       FT_IPv4, BASE_DEC, NULL, 0,
                        "Gnutella QueryHit IP Address", HFILL }
                },
                { &hf_gnutella_queryhit_speed,
                        { "Speed", "gnutella.queryhit.speed",
-                       FT_UINT32, BASE_DEC, NULL, 0,          
+                       FT_UINT32, BASE_DEC, NULL, 0,
                        "Gnutella QueryHit Speed", HFILL }
                },
                { &hf_gnutella_queryhit_extra,
                        { "Extra", "gnutella.queryhit.extra",
-                       FT_BYTES, BASE_HEX, NULL, 0,          
+                       FT_BYTES, BASE_HEX, NULL, 0,
                        "Gnutella QueryHit Extra", HFILL }
                },
                { &hf_gnutella_queryhit_servent_id,
                        { "Servent ID", "gnutella.queryhit.servent_id",
-                       FT_BYTES, BASE_HEX, NULL, 0,          
+                       FT_BYTES, BASE_HEX, NULL, 0,
                        "Gnutella QueryHit Servent ID", HFILL }
                },
                { &hf_gnutella_push_servent_id,
                        { "Servent ID", "gnutella.push.servent_id",
-                       FT_BYTES, BASE_HEX, NULL, 0,          
+                       FT_BYTES, BASE_HEX, NULL, 0,
                        "Gnutella Push Servent ID", HFILL }
                },
                { &hf_gnutella_push_ip,
                        { "IP", "gnutella.push.ip",
-                       FT_IPv4, BASE_DEC, NULL, 0,          
+                       FT_IPv4, BASE_DEC, NULL, 0,
                        "Gnutella Push IP Address", HFILL }
                },
                { &hf_gnutella_push_index,
                        { "Index", "gnutella.push.index",
-                       FT_UINT32, BASE_DEC, NULL, 0,          
+                       FT_UINT32, BASE_DEC, NULL, 0,
                        "Gnutella Push Index", HFILL }
                },
                { &hf_gnutella_push_port,
                        { "Port", "gnutella.push.port",
-                       FT_UINT16, BASE_DEC, NULL, 0,          
+                       FT_UINT16, BASE_DEC, NULL, 0,
                        "Gnutella Push Port", HFILL }
                },
        };
@@ -825,8 +753,9 @@ void proto_register_gnutella(void) {
 }
 
 void proto_reg_handoff_gnutella(void) {
-       dissector_add("tcp.port",
-                       GNUTELLA_TCP_PORT,
-                       dissect_gnutella,
+       dissector_handle_t gnutella_handle;
+
+       gnutella_handle = create_dissector_handle(dissect_gnutella,
                        proto_gnutella);
+       dissector_add("tcp.port", GNUTELLA_TCP_PORT, gnutella_handle);
 }