/* packet-vj.c
- * Routines for Van Jacobson header decompression.
+ * Routines for Van Jacobson header decompression.
*
- * $Id: packet-vj.c,v 1.15 2002/08/02 23:36:04 jmayer Exp $
+ * $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* This file created by Irfan Khan <ikhan@qualcomm.com>
* Copyright (c) 2001 by QUALCOMM, Incorporated.
* All Rights reserved.
- *
+ *
* Routines to compress and uncompress TCP packets (for transmission
* over low speed serial lines).
*
* Use ip_fast_csum from ip.h
* - July 1995 Christos A. Polyzols
* Spotted bug in tcp option checking
- * - Sep 2001 Irfan Khan
+ * - Sep 2001 Irfan Khan
* Rewrite to make the code work for ethereal.
*/
#include <glib.h>
#include <string.h>
#include <epan/packet.h>
+#include "prefs.h"
#include "packet-ppp.h"
#include "ppptypes.h"
#include "ipproto.h"
/* VJ Mem Chunk defines */
#define VJ_DATA_SIZE 128 /* Max IP hdr(64)+Max TCP hdr(64) */
-#define VJ_ATOM_COUNT 250 /* Number of Atoms per block */
+#define VJ_ATOM_COUNT 250 /* Number of Atoms per block */
/* IP and TCP header types */
typedef struct {
/* State per active tcp conversation */
typedef struct cstate {
- iphdr_type cs_ip;
+ iphdr_type cs_ip;
tcphdr_type cs_tcp;
guint8 cs_ipopt[IP_MAX_OPT_LEN];
guint8 cs_tcpopt[TCP_MAX_OPT_LEN];
/* State repository (Full Duplex) */
#define RX_TX_STATE_COUNT 2
static slcompress *rx_tx_state[RX_TX_STATE_COUNT] = {NULL, NULL};
-
+
/* Mem Chunks for storing decompressed headers */
static GMemChunk *vj_header_memchunk = NULL;
typedef struct {
int offset; /* uppermost bit is "can't dissect" flag */
guint8 data[VJ_DATA_SIZE];
} vj_header_t;
-
+
/* Function prototypes */
static int get_unsigned_delta(tvbuff_t *tvb, int *offsetp, int hf,
proto_tree *tree);
* Copy packet data to a buffer, and replace the connection index with
* the protocol type (which is always TCP), to give the actual IP header.
*/
- buffer = g_malloc(isize);
- tvb_memcpy(tvb, buffer, 0, isize);
+ buffer = tvb_memdup(tvb, 0, isize);
buffer[IP_FIELD_PROTOCOL] = IP_PROTO_TCP;
/* Check IP checksum */
}
}
- /*
+ /*
* Set up tvbuff containing packet with protocol type.
* Neither header checksum is recalculated.
*
{ "IP ID delta", "vj.ip_id_delta", FT_UINT16, BASE_DEC,
NULL, 0x0, "Delta for IP ID", HFILL }},
};
- static gint *ett[] = {
+ static gint *ett[] = {
&ett_vj,
&ett_vj_changes,
};
}
/* Initialization function */
-static void
+static void
vj_init(void)
{
gint i = ZERO;
if(vj_header_memchunk != NULL)
g_mem_chunk_destroy(vj_header_memchunk);
- vj_header_memchunk = g_mem_chunk_new("vj header store", sizeof (vj_header_t),
+ vj_header_memchunk = g_mem_chunk_new("vj header store", sizeof (vj_header_t),
sizeof (vj_header_t) * VJ_ATOM_COUNT,
G_ALLOC_ONLY);
for(i = 0; i < RX_TX_STATE_COUNT; i++) {
for (i = 0; i < TCP_SIMUL_CONV_MAX; i++)
comp->rstate[i].flags |= SLF_TOSS;
return comp;
-}
+}
/* Setup the decompressed packet tvb for VJ compressed packets */
-static gint
-vjc_tvb_setup(tvbuff_t *src_tvb,
- tvbuff_t **dst_tvb,
+static gint
+vjc_tvb_setup(tvbuff_t *src_tvb,
+ tvbuff_t **dst_tvb,
packet_info *pinfo)
{
vj_header_t *hdr_buf;
tvb_set_child_real_data_tvbuff(src_tvb, *dst_tvb);
add_new_data_source(pinfo, *dst_tvb, "VJ Decompressed");
return VJ_OK;
-}
+}
/*
* For VJ compressed packet:
* dissect the relevant fields;
* update the decompressor state on the first pass.
*/
-static gint
+static gint
vjc_process(tvbuff_t *src_tvb, packet_info *pinfo, proto_tree *tree,
slcompress *comp)
{
offset++;
if(comp != NULL)
comp->recv_current = conn_index;
- }
+ }
if(!pinfo->fd->flags.visited) {
/*
}
return VJ_OK;
-}
+}
/*
* Get an unsigned delta for a field, and put it into the protocol tree if
}
/* Wrapper for in_cksum function */
-static guint16
+static guint16
ip_csum(const guint8 * ptr, guint32 len)
{
vec_t cksum_vec[1];