Wireshark-dev: [Wireshark-dev] [Patch] DCT2000: treat variant as string
From: Martin Mathieson <martin.mathieson@xxxxxxxxxxxx>
Date: Fri, 09 Jun 2006 13:55:08 +0100
Hi, This patch:- treats the variant field as a variable-length string field. This is needed for some of the more complicated protocols where the variant number of the embedded protocol is also represented
Regards, Martin P.S.- the patch to Makefile.am was not applied from http://www.wireshark.org/lists/wireshark-dev/200606/msg00009.html Is this the correct place (to make sure dtd files get installed on developer builds) ?
Index: wiretap/catapult_dct2000.c =================================================================== --- wiretap/catapult_dct2000.c (revision 18404) +++ wiretap/catapult_dct2000.c (working copy) @@ -42,7 +42,7 @@ #define MAX_CONTEXT_NAME 64 #define MAX_PROTOCOL_NAME 64 #define MAX_PORT_DIGITS 2 -#define MAX_VARIANT_DIGITS 2 +#define MAX_VARIANT_DIGITS 32 #define AAL_HEADER_CHARS 12 /* TODO: @@ -104,7 +104,7 @@ /* The DCT2000 protocol name of the packet, plus variant number */ static gchar protocol_name[MAX_PROTOCOL_NAME+1]; -static gchar variant; +static gchar variant_name[MAX_VARIANT_DIGITS+1]; /*************************************************/ @@ -139,7 +139,7 @@ packet_direction_t *direction, int *encap, gboolean seek_read); -int write_stub_header(guchar *frame_buffer, char *timestamp_string, +static int write_stub_header(guchar *frame_buffer, char *timestamp_string, packet_direction_t direction, int encap); static guchar hex_from_char(gchar c); static gchar char_from_hex(guchar hex); @@ -740,8 +740,6 @@ int port_digits = 0; char port_number_string[MAX_PORT_DIGITS+1]; int variant_digits = 0; - char variant_number_string[MAX_VARIANT_DIGITS+1]; - int protocol_chars = 0; char seconds_buff[MAX_SECONDS_CHARS+1]; @@ -908,7 +906,7 @@ { return FALSE; } - variant_number_string[variant_digits] = linebuff[n]; + variant_name[variant_digits] = linebuff[n]; } if (variant_digits > MAX_VARIANT_DIGITS || (n+1 >= line_length)) { @@ -916,12 +914,11 @@ } if (variant_digits > 0) { - variant_number_string[variant_digits] = '\0'; - variant = atoi(variant_number_string); + variant_name[variant_digits] = '\0'; } else { - variant = 1; + strcpy(variant_name, "1"); } @@ -1106,9 +1103,9 @@ stub_offset += (strlen(protocol_name) + 1); /* Protocol variant number */ - frame_buffer[stub_offset] = variant; - stub_offset++; - + strcpy((void*)&frame_buffer[stub_offset], variant_name); + stub_offset += (strlen(variant_name) + 1); + /* Direction */ frame_buffer[stub_offset] = direction; stub_offset++;
Index: epan/dissectors/packet-catapult-dct2000.c =================================================================== --- epan/dissectors/packet-catapult-dct2000.c (revision 18404) +++ epan/dissectors/packet-catapult-dct2000.c (working copy) @@ -134,11 +134,12 @@ gint offset = 0; gint context_length; guint8 port_number; - guint8 variant; gint protocol_start; gint protocol_length; gint timestamp_start; gint timestamp_length; + gint variant_start; + gint variant_length; guint8 direction; tvbuff_t *next_tvb; int encap; @@ -190,10 +191,11 @@ offset += protocol_length; /* Variant */ - variant = tvb_get_guint8(tvb, offset); + variant_start = offset; + variant_length = tvb_strsize(tvb, offset); proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_variant, tvb, - offset, 1, FALSE); - offset++; + offset, variant_length, FALSE); + offset += variant_length; /* Direction */ direction = tvb_get_guint8(tvb, offset); @@ -210,13 +212,13 @@ proto_item_set_len(dct2000_tree, offset); /* Add useful details to protocol tree label */ - proto_item_append_text(ti, " context=%s.%u t=%s %c prot=%s (v=%d)", + proto_item_append_text(ti, " context=%s.%u t=%s %c prot=%s (v=%s)", tvb_get_ephemeral_string(tvb, 0, context_length), port_number, tvb_get_ephemeral_string(tvb, timestamp_start, timestamp_length), (direction == 0) ? 'S' : 'R', tvb_get_ephemeral_string(tvb, protocol_start, protocol_length), - variant); + tvb_get_ephemeral_string(tvb, variant_start, variant_length)); /* Note that the first item of pinfo->pseudo_header->dct2000 will contain @@ -309,13 +311,13 @@ if (check_col(pinfo->cinfo, COL_INFO)) { col_add_fstr(pinfo->cinfo, COL_INFO, - "Unparsed protocol data (context=%s.%u t=%s %c prot=%s (v=%d))", + "Unparsed protocol data (context=%s.%u t=%s %c prot=%s (v=%s))", tvb_get_ephemeral_string(tvb, 0, context_length), port_number, tvb_get_ephemeral_string(tvb, timestamp_start, timestamp_length), (direction == 0) ? 'S' : 'R', tvb_get_ephemeral_string(tvb, protocol_start, protocol_length), - variant); + tvb_get_ephemeral_string(tvb, variant_start, variant_length)); } } } @@ -365,7 +367,7 @@ }, { &hf_catapult_dct2000_variant, { "Protocol variant", - "dct2000.variant", FT_UINT8, BASE_DEC, NULL, 0x0, + "dct2000.variant", FT_STRING, BASE_NONE, NULL, 0x0, "DCT2000 protocol variant", HFILL } },
- Prev by Date: [Wireshark-dev] first official release?
- Next by Date: Re: [Wireshark-dev] [Wireshark-users] [Ethereal-dev] Major announcement
- Previous by thread: [Wireshark-dev] first official release?
- Next by thread: Re: [Wireshark-dev] [Wireshark-users] [Ethereal-dev] Major announcement
- Index(es):