* Routines for Wellfleet Compression frame disassembly
* Copyright 2001, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet-wcp.c,v 1.8 2001/03/30 10:51:50 guy Exp $
+ * $Id: packet-wcp.c,v 1.18 2001/12/03 03:59:42 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998
- *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
#include <string.h>
#include "packet.h"
#include "packet-frame.h"
-#include "packet-fr.h"
#include "conversation.h"
#include "etypes.h"
#include "nlpid.h"
static GMemChunk *wcp_window = NULL;
static GMemChunk *wcp_pdata = NULL;
-extern dissector_table_t fr_subdissector_table;
-
static int proto_wcp = -1;
static int hf_wcp_cmd = -1;
static int hf_wcp_ext_cmd = -1;
static gint ett_wcp = -1;
static gint ett_wcp_field = -1;
+static dissector_handle_t fr_handle;
+
/*
* Bits in the address field.
*/
}
-void wcp_save_data( tvbuff_t *tvb, packet_info *pinfo){
+static void wcp_save_data( tvbuff_t *tvb, packet_info *pinfo){
wcp_window_t *buf_ptr = 0;
int len;
}
-void dissect_wcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
+static void dissect_wcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
proto_tree *wcp_tree;
proto_item *ti;
guint16 temp, cmd, ext_cmd, seq;
tvbuff_t *next_tvb;
- pinfo->current_proto = "WCP";
-
if (check_col(pinfo->fd, COL_PROTOCOL))
col_set_str(pinfo->fd, COL_PROTOCOL, "WCP");
if (check_col(pinfo->fd, COL_INFO))
tvb_reported_length( tvb)-1, 1,
tvb_get_guint8( tvb, tvb_reported_length(tvb)-1));
- dissect_fr_uncompressed(next_tvb, pinfo, tree);
+ call_dissector(fr_handle, next_tvb, pinfo, tree);
return;
}
/* find the conversation for this side of the DLCI, create one if needed */
/* and return the wcp_window data structure pointer */
- conversation_t *conv = find_conversation( &pinfo->dl_src, &pinfo->dl_src, PT_NONE,
+ conversation_t *conv;
+ wcp_window_t *wcp_win_data;
+
+ conv = find_conversation( &pinfo->dl_src, &pinfo->dl_src, PT_NONE,
((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0),
((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0), 0);
-
if ( !conv){
-
conv = conversation_new( &pinfo->dl_src, &pinfo->dl_src, PT_NONE,
((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0),
((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0),
- g_mem_chunk_alloc( wcp_window), 0);
-
- ((wcp_window_t*)conv->data)->buf_cur = ((wcp_window_t*)conv->data)->buffer;
+ 0);
+ }
+ wcp_win_data = conversation_get_proto_data(conv, proto_wcp);
+ if ( !wcp_win_data){
+ wcp_win_data = g_mem_chunk_alloc( wcp_window);
+ wcp_win_data->buf_cur = wcp_win_data->buffer;
+ conversation_add_proto_data(conv, proto_wcp, wcp_win_data);
}
- return (wcp_window_t*)conv->data;
+ return wcp_win_data;
}
static hf_register_info hf[] = {
{ &hf_wcp_cmd,
{ "Command", "wcp.cmd", FT_UINT8, BASE_HEX, VALS(cmd_string), WCP_CMD,
- "Compression Command" }},
+ "Compression Command", HFILL }},
{ &hf_wcp_ext_cmd,
{ "Extended Command", "wcp.ext_cmd", FT_UINT8, BASE_HEX, VALS(ext_cmd_string), WCP_EXT_CMD,
- "Extended Compression Command" }},
+ "Extended Compression Command", HFILL }},
{ &hf_wcp_seq,
{ "SEQ", "wcp.seq", FT_UINT16, BASE_HEX, NULL, WCP_SEQ,
- "Sequence Number" }},
+ "Sequence Number", HFILL }},
{ &hf_wcp_chksum,
{ "Checksum", "wcp.checksum", FT_UINT8, BASE_DEC, NULL, 0,
- "Packet Checksum" }},
+ "Packet Checksum", HFILL }},
{ &hf_wcp_tid,
{ "TID", "wcp.tid", FT_UINT16, BASE_DEC, NULL, 0,
- "TID" }},
+ "TID", HFILL }},
{ &hf_wcp_rev,
{ "Revision", "wcp.rev", FT_UINT8, BASE_DEC, NULL, 0,
- "Revision" }},
+ "Revision", HFILL }},
{ &hf_wcp_init,
{ "Initiator", "wcp.init", FT_UINT8, BASE_DEC, NULL, 0,
- "Initiator" }},
+ "Initiator", HFILL }},
{ &hf_wcp_seq_size,
{ "Seq Size", "wcp.seq_size", FT_UINT8, BASE_DEC, NULL, 0,
- "Sequence Size"}},
+ "Sequence Size", HFILL }},
{ &hf_wcp_alg_cnt,
{ "Alg Count", "wcp.alg_cnt", FT_UINT8, BASE_DEC, NULL, 0,
- "Algorithm Count"}},
+ "Algorithm Count", HFILL }},
{ &hf_wcp_alg_a,
{ "Alg 1", "wcp.alg1", FT_UINT8, BASE_DEC, NULL, 0,
- "Algorithm #1"}},
+ "Algorithm #1", HFILL }},
{ &hf_wcp_alg_b,
{ "Alg 2", "wcp.alg2", FT_UINT8, BASE_DEC, NULL, 0,
- "Algorithm #2"}},
+ "Algorithm #2", HFILL }},
{ &hf_wcp_alg_c,
{ "Alg 3", "wcp.alg3", FT_UINT8, BASE_DEC, NULL, 0,
- "Algorithm #3"}},
+ "Algorithm #3", HFILL }},
{ &hf_wcp_alg_d,
{ "Alg 4", "wcp.alg4", FT_UINT8, BASE_DEC, NULL, 0,
- "Algorithm #4"}},
+ "Algorithm #4", HFILL }},
{ &hf_wcp_alg,
{ "Alg", "wcp.alg", FT_UINT8, BASE_DEC, NULL, 0,
- "Algorithm"}},
+ "Algorithm", HFILL }},
{ &hf_wcp_rexmit,
{ "Rexmit", "wcp.rexmit", FT_UINT8, BASE_DEC, NULL, 0,
- "Retransmit"}},
+ "Retransmit", HFILL }},
{ &hf_wcp_hist_size,
{ "History", "wcp.hist", FT_UINT8, BASE_DEC, NULL, 0,
- "History Size"}},
+ "History Size", HFILL }},
{ &hf_wcp_ppc,
{ "PerPackComp", "wcp.ppc", FT_UINT8, BASE_DEC, NULL, 0,
- "Per Packet Compression"}},
+ "Per Packet Compression", HFILL }},
{ &hf_wcp_pib,
{ "PIB", "wcp.pib", FT_UINT8, BASE_DEC, NULL, 0,
- "PIB"}},
+ "PIB", HFILL }},
{ &hf_wcp_comp_bits,
{ "Compress Flag", "wcp.flag", FT_UINT8, BASE_HEX, NULL, 0,
- "Compressed byte flag"}},
+ "Compressed byte flag", HFILL }},
{ &hf_wcp_comp_marker,
{ "Compress Marker", "wcp.mark", FT_UINT8, BASE_BIN, NULL, 0,
- "Compressed marker"}},
+ "Compressed marker", HFILL }},
{ &hf_wcp_offset,
{ "Source offset", "wcp.off", FT_UINT16, BASE_HEX, NULL, WCP_OFFSET_MASK,
- "Data source offset"}},
+ "Data source offset", HFILL }},
{ &hf_wcp_short_len,
{ "Compress Length", "wcp.short_len", FT_UINT8, BASE_HEX, NULL, 0xf0,
- "Compressed length"}},
+ "Compressed length", HFILL }},
{ &hf_wcp_long_len,
{ "Compress Length", "wcp.long_len", FT_UINT8, BASE_HEX, NULL, 0,
- "Compressed length"}},
+ "Compressed length", HFILL }},
{ &hf_wcp_long_run,
{ "Long Compression", "wcp.long_comp", FT_UINT16, BASE_HEX, NULL, 0,
- "Long Compression type"}},
+ "Long Compression type", HFILL }},
{ &hf_wcp_short_run,
{ "Short Compression", "wcp.short_comp", FT_UINT8, BASE_HEX, NULL, 0,
- "Short Compression type"}},
+ "Short Compression type", HFILL }},
};
void
proto_reg_handoff_wcp(void) {
+ dissector_handle_t wcp_handle;
+
+ /*
+ * Get handle for the Frame Relay (uncompressed) dissector.
+ */
+ fr_handle = find_dissector("fr");
- 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);
}