From Graeme Lunt
[obnox/wireshark/wip.git] / epan / dissectors / packet-socks.c
index 84c79d18f131e9719716d73637de3cd18a8d4607..eeba019bd4453afc4d940fb441b2ae0f0adec2d3 100644 (file)
@@ -80,6 +80,7 @@
 #include "packet-tcp.h"
 #include "packet-udp.h"
 #include <epan/strutil.h>
+#include <epan/emem.h>
 
 
 #define compare_packet(X) (X == (pinfo->fd->num))
@@ -226,11 +227,6 @@ static const value_string cmd_strings[] = {
        {0, NULL}
 };
 
-#define socks_hash_init_count 20
-#define socks_hash_val_length (sizeof(socks_hash_entry_t))
-
-static GMemChunk *socks_vals = NULL;
-
 
 /************************* Support routines ***************************/
 
@@ -346,8 +342,7 @@ static int get_address_v5(tvbuff_t *tvb, int offset,
        if ( a_type == 1){              /* IPv4 address */
 
                if ( hash_info)
-                       tvb_memcpy(tvb, (guint8 *)&hash_info->dst_addr,
-                           offset, 4);
+                       hash_info->dst_addr = tvb_get_ipv4(tvb, offset);
                offset += 4;
        }
 
@@ -556,7 +551,7 @@ display_socks_v5(tvbuff_t *tvb, int offset, packet_info *pinfo,
 
        unsigned int i, command;
        guint temp;
-       char *AuthMethodStr;
+       const char *AuthMethodStr;
        guint8 auth_status;
 
        proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, FALSE);
@@ -676,7 +671,7 @@ state_machine_v4( socks_hash_entry_t *hash_info, tvbuff_t *tvb,
                        hash_info->port =  tvb_get_ntohs(tvb, offset + 2);
                                                /* get remote address   */
 
-               tvb_memcpy(tvb, (guint8 *)&hash_info->dst_addr, offset + 4, 4);
+               hash_info->dst_addr = tvb_get_ipv4(tvb, offset + 4);
 
                                                /* save the packet pointer */
                hash_info->connect_row = get_packet_ptr;
@@ -1009,7 +1004,7 @@ dissect_socks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
        }
        hash_info = conversation_get_proto_data(conversation,proto_socks);
        if ( !hash_info){
-               hash_info = g_mem_chunk_alloc(socks_vals);
+               hash_info = se_alloc(sizeof(socks_hash_entry_t));
                hash_info->start_done_row = G_MAXINT;
                hash_info->state = None;
                hash_info->port = 0;
@@ -1115,21 +1110,6 @@ dissect_socks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
 
 
 
-static void socks_reinit( void){
-
-/* Do the cleanup work when a new pass through the packet list is      */
-/* performed. Reset the highest row seen counter and re-initialize the */
-/* conversation memory chunks.                                         */
-
-       if (socks_vals)
-               g_mem_chunk_destroy(socks_vals);
-
-       socks_vals = g_mem_chunk_new("socks_vals", socks_hash_val_length,
-               socks_hash_init_count * socks_hash_val_length,
-               G_ALLOC_AND_FREE);
-}
-
-
 void
 proto_register_socks( void){
 
@@ -1208,8 +1188,6 @@ proto_register_socks( void){
        proto_register_field_array(proto_socks, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
 
-       register_init_routine( &socks_reinit);  /* register re-init routine */
-
        socks_udp_handle = create_dissector_handle(socks_udp_dissector,
            proto_socks);
        socks_handle = create_dissector_handle(dissect_socks, proto_socks);