* Routines for Wellfleet Compression frame disassembly
* Copyright 2001, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet-wcp.c,v 1.17 2001/11/30 04:39:45 guy Exp $
+ * $Id: packet-wcp.c,v 1.27 2002/08/02 23:36:04 jmayer Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
# include "config.h"
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
#include <stdio.h>
#include <glib.h>
#include <string.h>
-#include "packet.h"
+#include <epan/packet.h>
#include "packet-frame.h"
-#include "conversation.h"
+#include <epan/conversation.h>
#include "etypes.h"
#include "nlpid.h"
static gint ett_wcp = -1;
static gint ett_wcp_field = -1;
-static dissector_handle_t fr_handle;
+static dissector_handle_t fr_uncompressed_handle;
/*
* Bits in the address field.
static wcp_window_t *get_wcp_window_ptr( packet_info *pinfo);
static void
-dissect_wcp_con_req(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) {
+dissect_wcp_con_req(tvbuff_t *tvb, int offset, proto_tree *tree) {
/* WCP connector request message */
}
static void
-dissect_wcp_con_ack( tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree){
+dissect_wcp_con_ack( tvbuff_t *tvb, int offset, proto_tree *tree){
/* WCP connector ack message */
}
static void
-dissect_wcp_init( tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree){
+dissect_wcp_init( tvbuff_t *tvb, int offset, proto_tree *tree){
/* WCP Initiate Request/Ack message */
static void
-dissect_wcp_reset( tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree){
+dissect_wcp_reset( tvbuff_t *tvb, int offset, proto_tree *tree){
/* Process WCP Reset Request/Ack message */
guint16 temp, cmd, ext_cmd, seq;
tvbuff_t *next_tvb;
- if (check_col(pinfo->fd, COL_PROTOCOL))
- col_set_str(pinfo->fd, COL_PROTOCOL, "WCP");
- 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, "WCP");
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_clear(pinfo->cinfo, COL_INFO);
temp =tvb_get_ntohs(tvb, 0);
/*XXX should test seq to be sure it the last + 1 !! */
- if (check_col(pinfo->fd, COL_INFO)){
- col_add_str(pinfo->fd, COL_INFO, val_to_str(cmd, cmd_string, "Unknown"));
+ if (check_col(pinfo->cinfo, COL_INFO)){
+ col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, cmd_string, "Unknown"));
if ( cmd == 0xf)
- col_append_fstr(pinfo->fd, COL_INFO, ", %s",
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str(ext_cmd, ext_cmd_string, "Unknown"));
}
tvb_get_guint8( tvb, 0));
switch (ext_cmd){
case CONNECT_REQ:
- dissect_wcp_con_req( tvb, 1, pinfo, wcp_tree);
+ dissect_wcp_con_req( tvb, 1, wcp_tree);
break;
case CONNECT_ACK:
- dissect_wcp_con_ack( tvb, 1, pinfo, wcp_tree);
+ dissect_wcp_con_ack( tvb, 1, wcp_tree);
break;
case INIT_REQ:
case INIT_ACK:
- dissect_wcp_init( tvb, 1, pinfo, wcp_tree);
+ dissect_wcp_init( tvb, 1, wcp_tree);
break;
case RESET_REQ:
case RESET_ACK:
- dissect_wcp_reset( tvb, 1, pinfo, wcp_tree);
+ dissect_wcp_reset( tvb, 1, wcp_tree);
break;
default:
break;
tvb_reported_length( tvb)-1, 1,
tvb_get_guint8( tvb, tvb_reported_length(tvb)-1));
- call_dissector(fr_handle, next_tvb, pinfo, tree);
+ call_dissector(fr_uncompressed_handle, next_tvb, pinfo, tree);
return;
}
-guint8 *decompressed_entry( guint8 *src, guint8 *dst, int *len, guint8 * buf_start, guint8 *buf_end){
+static guint8 *decompressed_entry( guint8 *src, guint8 *dst, int *len, guint8 * buf_start, guint8 *buf_end){
/* do the decompression for one field */
buf_end = buf_start + MAX_WIN_BUF_LEN;
tmp = buf_ptr->buf_cur;
+ if (cnt - offset > MAX_WCP_BUF_LEN) {
+ if (tree)
+ proto_tree_add_text( tree, src_tvb, offset, -1,
+ "Compressed data exceeds maximum buffer length (%d > %d)",
+ cnt - offset, MAX_WCP_BUF_LEN);
+ return NULL;
+ }
+
src = tvb_memcpy(src_tvb, src_buf, offset, cnt - offset);
dst = buf_ptr->buf_cur;
TRY {
- tvb = tvb_new_real_data( pdata_ptr->buffer, pdata_ptr->len, pdata_ptr->len, "uncompressed");
+ tvb = tvb_new_real_data( pdata_ptr->buffer, pdata_ptr->len, pdata_ptr->len);
}
CATCH(BoundsError) {
- g_assert_not_reached();
+ g_assert_not_reached();
g_free(buf);
return NULL;
}
CATCH(ReportedBoundsError) {
- g_free(buf);
- return NULL;
+ g_free(buf);
+ return NULL;
}
ENDTRY;
tvb_set_child_real_data_tvbuff( src_tvb, tvb);
/* Add new data to the data source list */
- pinfo->fd->data_src = g_slist_append( pinfo->fd->data_src, tvb);
+ add_new_data_source( pinfo, tvb, "Uncompressed WCP");
return tvb;
}
void
proto_reg_handoff_wcp(void) {
+ dissector_handle_t wcp_handle;
/*
* Get handle for the Frame Relay (uncompressed) dissector.
*/
- fr_handle = find_dissector("fr");
+ fr_uncompressed_handle = find_dissector("fr_uncompressed");
- dissector_add("fr.ietf", NLPID_COMPRESSED, dissect_wcp, proto_wcp);
- dissector_add("ethertype", ETHERTYPE_WCP, dissect_wcp, proto_wcp);
+ wcp_handle = create_dissector_handle(dissect_wcp, proto_wcp);
+ dissector_add("fr.ietf", NLPID_COMPRESSED, wcp_handle);
+ dissector_add("ethertype", ETHERTYPE_WCP, wcp_handle);
}