Eliminate proto_tree_add_text from some dissectors.

"file" dissectors are now rid of proto_tree_add_text.

Change-Id: I4e0f7248135e6ce194fcafde47e538db84b964aa
Reviewed-on: https://code.wireshark.org/review/8828
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Michael Mann 2015-06-06 23:01:39 -04:00 committed by Anders Broman
parent 2c56c6fa76
commit 639fd7d60d
5 changed files with 432 additions and 279 deletions

View File

@ -43,8 +43,6 @@
void proto_register_jfif(void);
void proto_reg_handoff_jfif(void);
static expert_field ei_file_jpeg_first_identifier_not_jfif = EI_INIT;
/* General-purpose debug logger.
* Requires double parentheses because of variable arguments of printf().
*
@ -346,16 +344,32 @@ static gint hf_sos_al = -1;
static gint hf_comment_header = -1;
static gint hf_comment = -1;
static gint hf_remain_seg_data = -1;
static gint hf_endianness = -1;
static gint hf_start_ifd_offset = -1;
static gint hf_next_ifd_offset = -1;
static gint hf_exif_flashpix_marker = -1;
static gint hf_entropy_coded_segment = -1;
static gint hf_fill_bytes = -1;
static gint hf_skipped_tiff_data = -1;
static gint hf_ifd_num_fields = -1;
static gint hf_idf_tag = -1;
static gint hf_idf_type = -1;
static gint hf_idf_count = -1;
static gint hf_idf_offset = -1;
/* Initialize the subtree pointers */
static gint ett_jfif = -1;
static gint ett_marker_segment = -1;
static gint ett_details = -1;
static expert_field ei_file_jpeg_first_identifier_not_jfif = EI_INIT;
static expert_field ei_start_ifd_offset = EI_INIT;
static expert_field ei_next_ifd_offset = EI_INIT;
/****************** JFIF protocol dissection functions ******************/
#define ErrorInvalidJFIF "This is not a valid JFIF (JPEG) object"
/*
* Process a marker segment (with length).
@ -379,8 +393,7 @@ process_marker_segment(proto_tree *tree, tvbuff_t *tvb, guint32 len,
proto_tree_add_item(subtree, hf_len, tvb, 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_text(subtree, tvb, 4, -1,
"Remaining segment data (%u bytes)", len - 2);
proto_tree_add_bytes_format_value(subtree, hf_remain_seg_data, tvb, 4, -1, NULL, "%u bytes", len - 2);
}
/*
@ -569,8 +582,7 @@ process_app0_segment(proto_tree *tree, tvbuff_t *tvb, guint32 len,
proto_item_append_text(ti, " (unknown identifier)");
offset = 4 + str_size;
proto_tree_add_text(subtree, tvb, offset, -1,
"Remaining segment data (%u bytes)", len - 2 - str_size);
proto_tree_add_bytes_format_value(subtree, hf_remain_seg_data, tvb, offset, -1, NULL, "%u bytes", len - 2 - str_size);
}
return offset;
}
@ -590,9 +602,6 @@ process_app1_segment(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint3
int offset = 0;
int tiff_start;
if (!tree)
return 0;
ti = proto_tree_add_item(tree, hf_marker_segment,
tvb, 0, -1, ENC_NA);
subtree = proto_item_add_subtree(ti, ett_marker_segment);
@ -609,33 +618,32 @@ process_app1_segment(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint3
offset += str_size;
if (show_first_identifier_not_jfif && strcmp(str, "JFIF") != 0) {
expert_add_info_format(pinfo, ti, &ei_file_jpeg_first_identifier_not_jfif,
"Initial App0 segment with \"JFIF\" Identifier not found");
expert_add_info(pinfo, ti, &ei_file_jpeg_first_identifier_not_jfif);
}
if (strcmp(str, "Exif") == 0) {
/*
* Endianness
*/
gboolean is_little_endian;
int encoding;
guint16 val_16;
guint32 val_32;
guint16 num_fields;
guint32 val_32, num_fields;
proto_item* tiff_item;
offset++; /* Skip a byte supposed to be 0x00 */
tiff_start = offset;
val_16 = tvb_get_ntohs(tvb, offset);
if (val_16 == 0x4949) {
is_little_endian = TRUE;
proto_tree_add_text(subtree, tvb, offset, 2, "Endianness: little endian");
encoding = ENC_LITTLE_ENDIAN;
proto_tree_add_uint_format_value(subtree, hf_endianness, tvb, offset, 2, val_16, "little endian");
} else if (val_16 == 0x4D4D) {
is_little_endian = FALSE;
proto_tree_add_text(subtree, tvb, offset, 2, "Endianness: big endian");
encoding = ENC_BIG_ENDIAN;
proto_tree_add_uint_format_value(subtree, hf_endianness, tvb, offset, 2, val_16, "big endian");
} else {
/* Error: invalid endianness encoding */
proto_tree_add_text(subtree, tvb, offset, 2,
"Incorrect endianness encoding - skipping the remainder of this application marker");
proto_tree_add_uint_format_value(subtree, hf_endianness, tvb, offset, 2, val_16,
"Incorrect encoding 0x%04x- skipping the remainder of this application marker", val_16);
return offset;
}
offset += 2;
@ -646,11 +654,10 @@ process_app1_segment(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint3
/*
* Offset to IFD
*/
if (is_little_endian) {
val_32 = tvb_get_letohl(tvb, offset);
} else {
val_32 = tvb_get_ntohl(tvb, offset);
}
val_32 = tvb_get_guint32(tvb, offset, encoding);
tiff_item = proto_tree_add_uint_format_value(subtree, hf_start_ifd_offset, tvb, offset, 4, val_32, "%u bytes",
val_32);
offset += 4;
/*
* Check for a bogus val_32 value.
* XXX - bogus value message should also deal with a
@ -658,22 +665,16 @@ process_app1_segment(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint3
* Or should it just check against the segment length,
* which is 16 bits?
*/
if (val_32 + tiff_start < (guint32)offset + 4) {
proto_tree_add_text(subtree, tvb, offset, 4,
"Start offset of IFD starting from the TIFF header start: %u bytes (bogus, should be >= %u",
val_32, offset + 4 - tiff_start);
if (val_32 + tiff_start < (guint32)offset) {
expert_add_info_format(pinfo, tiff_item, &ei_start_ifd_offset, " (bogus, should be >= %u)",
offset- tiff_start);
return offset;
}
proto_tree_add_text(subtree, tvb, offset, 4,
"Start offset of IFD starting from the TIFF header start: %u bytes",
val_32);
offset += 4;
/*
* Skip the following portion
*/
if (val_32 + tiff_start > (guint32)offset) {
proto_tree_add_text(subtree, tvb, offset, val_32 + tiff_start - offset,
"Skipped data between end of TIFF header and start of IFD (%u bytes)",
proto_tree_add_bytes_format_value(subtree, hf_skipped_tiff_data, tvb, offset, val_32 + tiff_start - offset, NULL, "%u bytes",
val_32 + tiff_start - offset);
}
for (;;) {
@ -681,62 +682,35 @@ process_app1_segment(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint3
/*
* Process the IFD
*/
if (is_little_endian) {
num_fields = tvb_get_letohs(tvb, offset);
} else {
num_fields = tvb_get_ntohs(tvb, offset);
}
proto_tree_add_text(subtree, tvb, offset, 2, "Number of fields in this IFD: %u", num_fields);
proto_tree_add_item_ret_uint(subtree, hf_ifd_num_fields, tvb, offset, 2, encoding, &num_fields);
offset += 2;
while (num_fields-- > 0) {
guint16 tag, type;
guint32 count, off;
if (is_little_endian) {
tag = tvb_get_letohs(tvb, offset);
type = tvb_get_letohs(tvb, offset + 2);
count = tvb_get_letohl(tvb, offset + 4);
off = tvb_get_letohl(tvb, offset + 8);
} else {
tag = tvb_get_ntohs(tvb, offset);
type = tvb_get_ntohs(tvb, offset + 2);
count = tvb_get_ntohl(tvb, offset + 4);
off = tvb_get_ntohl(tvb, offset + 8);
}
/* TODO - refine this */
proto_tree_add_text(subtree, tvb, offset, 2,
"Exif Tag: 0x%04X (%s), Type: %u (%s), Count: %u, "
"Value offset from start of TIFF header: %u",
tag, val_to_str_const(tag, vals_exif_tags, "Unknown Exif tag"),
type, val_to_str_const(type, vals_exif_types, "Unknown Exif type"),
count, off);
offset += 12;
proto_tree_add_item(subtree, hf_idf_tag, tvb, offset, 2, encoding);
offset += 2;
proto_tree_add_item(subtree, hf_idf_type, tvb, offset, 2, encoding);
offset += 2;
proto_tree_add_item(subtree, hf_idf_count, tvb, offset, 4, encoding);
offset += 4;
proto_tree_add_item(subtree, hf_idf_offset, tvb, offset, 4, encoding);
offset += 4;
}
/*
* Offset to the next IFD
*/
if (is_little_endian) {
val_32 = tvb_get_letohl(tvb, offset);
} else {
val_32 = tvb_get_ntohl(tvb, offset);
}
if (val_32 != 0 &&
val_32 + tiff_start < (guint32)offset + 4) {
proto_tree_add_text(subtree, tvb, offset, 4,
"Offset to next IFD from start of TIFF header: %u bytes (bogus, should be >= %u)",
val_32, offset + 4 - tiff_start);
return offset;
}
proto_tree_add_text(subtree, tvb, offset, 4,
"Offset to next IFD from start of TIFF header: %u bytes",
val_32 = tvb_get_guint32(tvb, offset, encoding);
tiff_item = proto_tree_add_uint_format_value(subtree, hf_next_ifd_offset, tvb, offset, 4, val_32, "%u bytes",
val_32);
offset += 4;
if (val_32 != 0 &&
val_32 + tiff_start < (guint32)offset) {
expert_add_info_format(pinfo, tiff_item, &ei_next_ifd_offset, " (bogus, should be >= %u)", offset + tiff_start);
return offset;
}
if (val_32 == 0)
break;
}
} else {
proto_tree_add_text(subtree, tvb, offset, -1,
"Remaining segment data (%u bytes)", len - 2 - str_size);
proto_tree_add_bytes_format_value(subtree, hf_remain_seg_data, tvb, offset, -1, NULL, "%u bytes", len - 2 - str_size);
proto_item_append_text(ti, " (Unknown identifier)");
}
return offset;
@ -770,10 +744,9 @@ process_app2_segment(proto_tree *tree, tvbuff_t *tvb, guint32 len,
str = tvb_get_stringz_enc(wmem_packet_scope(), tvb, 4, &str_size, ENC_ASCII);
ti = proto_tree_add_item(subtree, hf_identifier, tvb, 4, str_size, ENC_ASCII|ENC_NA);
if (strcmp(str, "FPXR") == 0) {
proto_tree_add_text(tree, tvb, 0, -1, "Exif FlashPix APP2 application marker");
proto_tree_add_item(tree, hf_exif_flashpix_marker, tvb, 0, -1, ENC_NA);
} else {
proto_tree_add_text(subtree, tvb, 4 + str_size, -1,
"Remaining segment data (%u bytes)", len - 2 - str_size);
proto_tree_add_bytes_format_value(subtree, hf_remain_seg_data, tvb, 4 + str_size, -1, NULL, "%u bytes", len - 2 - str_size);
proto_item_append_text(ti, " (Unknown identifier)");
}
}
@ -829,8 +802,7 @@ dissect_jfif(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
if (start_fill == -1) start_fill = tvb_len;
if (start_fill != start_entropy)
proto_tree_add_text(subtree, tvb, start_entropy, start_fill - start_entropy,
"Entropy-coded segment (dissection is not yet implemented)");
proto_tree_add_item(subtree, hf_entropy_coded_segment, tvb, start_entropy, start_fill - start_entropy, ENC_NA);
if (start_fill == tvb_len) break;
@ -840,8 +812,7 @@ dissect_jfif(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
++start_marker;
if (start_marker != start_fill)
proto_tree_add_text(subtree, tvb, start_fill, start_marker - start_fill,
"Fill bytes");
proto_tree_add_item(subtree, hf_fill_bytes, tvb, start_fill, start_marker - start_fill, ENC_NA);
marker = tvb_get_ntohs(tvb, start_marker);
str = try_val_to_str(marker, vals_marker);
@ -1218,6 +1189,110 @@ proto_register_jfif(void)
HFILL
}
},
{ &hf_remain_seg_data,
{ "Remaining segment data",
IMG_JFIF ".remain_seg_data",
FT_BYTES, BASE_NONE, NULL, 0x00,
NULL,
HFILL
}
},
{ &hf_endianness,
{ "Endianness",
IMG_JFIF ".endianness",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL,
HFILL
}
},
{ &hf_start_ifd_offset,
{ "Start offset of IFD starting from the TIFF header start",
IMG_JFIF ".start_ifd_offset",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL,
HFILL
}
},
{ &hf_next_ifd_offset,
{ "Offset to next IFD from start of TIFF header",
IMG_JFIF ".next_ifd_offset",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL,
HFILL
}
},
{ &hf_exif_flashpix_marker,
{ "Exif FlashPix APP2 application marker",
IMG_JFIF ".exif_flashpix_marker",
FT_NONE, BASE_NONE, NULL, 0x00,
NULL,
HFILL
}
},
{ &hf_entropy_coded_segment,
{ "Entropy-coded segment (dissection is not yet implemented)",
IMG_JFIF ".entropy_coded_segment",
FT_BYTES, BASE_NONE, NULL, 0x00,
NULL,
HFILL
}
},
{ &hf_fill_bytes,
{ "Fill bytes",
IMG_JFIF ".fill_bytes",
FT_BYTES, BASE_NONE, NULL, 0x00,
NULL,
HFILL
}
},
{ &hf_skipped_tiff_data,
{ "Skipped data between end of TIFF header and start of IFD",
IMG_JFIF ".skipped_tiff_data",
FT_BYTES, BASE_NONE, NULL, 0x00,
NULL,
HFILL
}
},
{ &hf_ifd_num_fields,
{ "Number of fields in this IFD",
IMG_JFIF ".ifd.num_fields",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL,
HFILL
}
},
{ &hf_idf_tag,
{ "Exif Tag",
IMG_JFIF ".ifd.tag",
FT_UINT16, BASE_DEC, VALS(vals_exif_tags), 0x0,
NULL,
HFILL
}
},
{ &hf_idf_type,
{ "Type",
IMG_JFIF ".ifd.type",
FT_UINT16, BASE_DEC, VALS(vals_exif_types), 0x0,
NULL,
HFILL
}
},
{ &hf_idf_count,
{ "Count",
IMG_JFIF ".ifd.count",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL,
HFILL
}
},
{ &hf_idf_offset,
{ "Value offset from start of TIFF header",
IMG_JFIF ".ifd.offset",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL,
HFILL
}
},
};
/* Setup protocol subtree array */
@ -1230,7 +1305,13 @@ proto_register_jfif(void)
static ei_register_info ei[] = {
{ &ei_file_jpeg_first_identifier_not_jfif,
{ IMG_JFIF ".app0-identifier-not-jfif", PI_MALFORMED, PI_WARN,
NULL, EXPFILL }},
"Initial App0 segment with \"JFIF\" Identifier not found", EXPFILL }},
{ &ei_start_ifd_offset,
{ IMG_JFIF ".start_ifd_offset.invalid", PI_PROTOCOL, PI_WARN,
"Invalid value", EXPFILL }},
{ &ei_next_ifd_offset,
{ IMG_JFIF ".next_ifd_offset.invalid", PI_PROTOCOL, PI_WARN,
"Invalid value", EXPFILL }},
};
expert_module_t* expert_jfif;

View File

@ -36,6 +36,7 @@
#include <epan/exceptions.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
#include <epan/expert.h>
#include "packet-tcp.h"
#define TCP_PORT_PVFS2 3334
@ -60,7 +61,7 @@ static int hf_pvfs_gid = -1;
static int hf_pvfs_mode = -1;
static int hf_pvfs_tag = -1;
static int hf_pvfs_size = -1;
/* static int hf_pvfs_release_number = -1; */
static int hf_pvfs_release_number = -1;
static int hf_pvfs_encoding = -1;
static int hf_pvfs_server_op = -1;
/* static int hf_pvfs_handle = -1; */
@ -169,6 +170,13 @@ static int hf_pvfs_mgmt_event_mon_response_value = -1;
static int hf_pvfs_mgmt_event_mon_response_flags = -1;
static int hf_pvfs_mgmt_event_mon_response_tv_sec = -1;
static int hf_pvfs_mgmt_event_mon_response_tv_usec = -1;
static int hf_pvfs_fill_bytes = -1;
static int hf_pvfs_target_path_len = -1;
static int hf_pvfs_version2 = -1;
static int hf_pvfs_flow_data = -1;
static int hf_pvfs_getconfig_response_entry = -1;
static int hf_fhandle_data = -1;
static int hf_pvfs_opaque_length = -1;
/* Initialize the subtree pointers */
static gint ett_pvfs = -1;
@ -188,6 +196,8 @@ static gint ett_pvfs_mgmt_dspace_info = -1;
static gint ett_pvfs_attr = -1;
static gint ett_pvfs_fh = -1;
static expert_field ei_pvfs_malformed = EI_INIT;
#define BMI_MAGIC_NR 51903
static const value_string names_pvfs_mode[] =
@ -925,24 +935,21 @@ dissect_pvfs_opaque_data(tvbuff_t *tvb, int offset,
ett_pvfs_string);
if (!fixed_length) {
if (string_tree)
proto_tree_add_text(string_tree, tvb,offset+0,4,
"length: %u (excl. NULL terminator)", string_length - 1);
proto_tree_add_uint_format_value(string_tree, hf_pvfs_opaque_length, tvb, offset, 4,
string_length - 1, "%u (excl. NULL terminator)", string_length - 1);
offset += 4;
}
if (string_tree) {
if (string_data) {
proto_tree_add_string_format(string_tree,
hfindex, tvb, offset, string_length_copy,
string_buffer,
"contents: %s", string_buffer_print);
} else {
proto_tree_add_bytes_format(string_tree,
hfindex, tvb, offset, string_length_copy,
(guint8 *) string_buffer,
"contents: %s", string_buffer_print);
}
if (string_data) {
proto_tree_add_string_format(string_tree,
hfindex, tvb, offset, string_length_copy,
string_buffer,
"contents: %s", string_buffer_print);
} else {
proto_tree_add_bytes_format(string_tree,
hfindex, tvb, offset, string_length_copy,
(guint8 *) string_buffer,
"contents: %s", string_buffer_print);
}
offset += string_length_copy;
@ -950,14 +957,14 @@ dissect_pvfs_opaque_data(tvbuff_t *tvb, int offset,
if (fill_length) {
if (string_tree) {
if (fill_truncated) {
proto_tree_add_text(string_tree, tvb,
offset,fill_length_copy,
"fill bytes: opaque data<TRUNCATED>");
proto_tree_add_bytes_format_value(string_tree, hf_pvfs_fill_bytes, tvb,
offset, fill_length_copy, NULL,
"opaque data <TRUNCATED>");
}
else {
proto_tree_add_text(string_tree, tvb,
offset,fill_length_copy,
"fill bytes: opaque data");
proto_tree_add_bytes_format_value(string_tree, hf_pvfs_fill_bytes, tvb,
offset, fill_length_copy, NULL,
"opaque data");
}
}
offset += fill_length_copy;
@ -990,25 +997,9 @@ dissect_pvfs_string(tvbuff_t *tvb, proto_tree *tree, int hfindex,
static void
dissect_fhandle_data_unknown(tvbuff_t *tvb, int offset, proto_tree *tree)
{
guint sublen;
guint bytes_left;
gboolean first_line;
guint bytes_left = PVFS2_FH_LENGTH;
bytes_left = PVFS2_FH_LENGTH;
first_line = TRUE;
while (bytes_left != 0) {
sublen = 16;
if (sublen > bytes_left)
sublen = bytes_left;
proto_tree_add_text(tree, tvb, offset, sublen,
"%s%s",
first_line ? "data: " :
" ",
tvb_bytes_to_str(wmem_packet_scope(), tvb,offset,sublen));
bytes_left -= sublen;
offset += sublen;
first_line = FALSE;
}
proto_tree_add_item(tree, hf_fhandle_data, tvb, offset, bytes_left, ENC_NA);
}
static void
@ -1290,8 +1281,7 @@ dissect_pvfs_object_attr(tvbuff_t *tvb, proto_tree *tree, int offset,
if (attrmask & PVFS_ATTR_SYMLNK_TARGET)
{
/* target_path_len */
proto_tree_add_text(attr_tree, tvb, offset, 4,
"target_path_len: %d", tvb_get_letohl(tvb, offset));
proto_tree_add_item(attr_tree, hf_pvfs_target_path_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
offset += 4;
@ -1978,27 +1968,22 @@ dissect_pvfs2_deleattr_request(tvbuff_t *tvb, proto_tree *tree,
return offset;
}
static int
dissect_pvfs2_release_number(tvbuff_t *tvb, proto_tree *tree, int offset)
static void
pvfc_fmt_release_num(gchar *result, guint32 release_nr)
{
guint32 release_nr = tvb_get_letohl(tvb, offset);
proto_tree_add_text(tree, tvb, offset, 4,
"PVFS2 Release Number: %d (%d.%d.%d)",
g_snprintf( result, ITEM_LABEL_LENGTH, "%d (%d.%d.%d)",
release_nr,
release_nr / 10000,
(release_nr % 10000) / 100,
(release_nr % 10000) % 100);
offset += 4;
return offset;
}
static int
dissect_pvfs2_common_header(tvbuff_t *tvb, proto_tree *tree, int offset)
{
/* PVFS release number */
offset = dissect_pvfs2_release_number(tvb, tree, offset);
proto_tree_add_item(tree, hf_pvfs_release_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* wire encoding type */
proto_tree_add_item(tree, hf_pvfs_encoding, tvb, offset, 4, ENC_LITTLE_ENDIAN);
@ -2308,7 +2293,7 @@ dissect_pvfs2_readdir_response(tvbuff_t *tvb, proto_tree *tree, int offset,
*/
static int
dissect_pvfs2_getconfig_response(tvbuff_t *tvb, proto_tree *parent_tree,
int offset)
int offset, packet_info *pinfo)
{
guint32 i;
guint32 total_bytes = 0, total_config_bytes = 0, total_lines = 0;
@ -2440,8 +2425,8 @@ dissect_pvfs2_getconfig_response(tvbuff_t *tvb, proto_tree *parent_tree,
if (tmp_entry_length > 0)
{
proto_tree_add_text(config_tree, tvb, offset, tmp_entry_length,
"%s", tmp_entry);
proto_tree_add_string_format(config_tree, hf_pvfs_getconfig_response_entry, tvb, offset, tmp_entry_length,
tmp_entry, "%s", tmp_entry);
}
}
@ -2454,8 +2439,7 @@ dissect_pvfs2_getconfig_response(tvbuff_t *tvb, proto_tree *parent_tree,
if (bytes_processed < total_config_bytes)
{
/* We ran out of server config data */
proto_tree_add_text(config_tree, tvb, offset, -1,
"<MALFORMED OR TRUNCATED DATA>");
proto_tree_add_expert(config_tree, pinfo, &ei_pvfs_malformed, tvb, offset, -1);
}
return offset;
@ -2795,7 +2779,7 @@ dissect_pvfs2_response(tvbuff_t *tvb, proto_tree *tree, int offset,
break;
case PVFS_SERV_GETCONFIG:
offset = dissect_pvfs2_getconfig_response(tvb, tree, offset);
offset = dissect_pvfs2_getconfig_response(tvb, tree, offset, pinfo);
break;
case PVFS_SERV_WRITE_COMPLETION:
@ -2976,7 +2960,7 @@ dissect_pvfs_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
item = proto_tree_add_item(parent_tree, proto_pvfs, tvb, 0, -1, ENC_NA);
pvfs_tree = proto_item_add_subtree(item, ett_pvfs);
proto_tree_add_text(pvfs_tree, tvb, 0, -1, "Version: 2");
proto_tree_add_item(pvfs_tree, hf_pvfs_version2, tvb, 0, -1, ENC_NA);
/* PVFS packet header is 24 bytes */
pvfs_htree = proto_tree_add_subtree(pvfs_tree, tvb, 0, BMI_HEADER_SIZE,
@ -3035,7 +3019,7 @@ dissect_pvfs_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
/* This frame is marked as being flow data */
col_set_str(pinfo->cinfo, COL_INFO, "PVFS flow data");
proto_tree_add_text(pvfs_tree, tvb, offset, -1, "<data>");
proto_tree_add_item(pvfs_tree, hf_pvfs_flow_data, tvb, offset, -1, ENC_NA);
return TRUE;
}
@ -3110,11 +3094,9 @@ proto_register_pvfs(void)
{ "Size", "pvfs.size", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
#if 0
{ &hf_pvfs_release_number,
{ "Release Number", "pvfs.release_number", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
#endif
{ "Release Number", "pvfs.release_number", FT_UINT32, BASE_CUSTOM,
CF_FUNC(pvfc_fmt_release_num), 0, NULL, HFILL }},
{ &hf_pvfs_encoding,
{ "Encoding", "pvfs.encoding", FT_UINT32, BASE_DEC,
@ -3557,6 +3539,34 @@ proto_register_pvfs(void)
{ &hf_pvfs_mgmt_event_mon_response_tv_usec,
{ "tv_usec", "pvfs.mgmt_event_mon_response.tv_usec", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_pvfs_fill_bytes,
{ "fill_bytes", "pvfs.fill_bytes", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_pvfs_target_path_len,
{ "target_path_len", "pvfs.target_path_len", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_pvfs_version2,
{ "Version 2", "pvfs.version2", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_pvfs_flow_data,
{ "PVFC Flow Data", "pvfs.flow_data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_pvfs_getconfig_response_entry,
{ "GETCONFIG Response entry", "pvfs.getconfig_response_entry", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_fhandle_data,
{ "data", "pvfs.fhandle_data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_pvfs_opaque_length,
{ "length", "pvfs.opaque_length", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
};
/* Setup protocol subtree array */
@ -3578,7 +3588,13 @@ proto_register_pvfs(void)
&ett_pvfs_attr,
&ett_pvfs_fh
};
static ei_register_info ei[] = {
{ &ei_pvfs_malformed, { "pvfs.malformed", PI_MALFORMED, PI_ERROR, "MALFORMED OR TRUNCATED DATA", EXPFILL }},
};
module_t *pvfs_module;
expert_module_t* expert_pvfs;
/* Register the protocol name and description */
proto_pvfs = proto_register_protocol("Parallel Virtual File System",
@ -3591,6 +3607,8 @@ proto_register_pvfs(void)
proto_register_field_array(proto_pvfs, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_pvfs = expert_register_protocol(proto_pvfs);
expert_register_field_array(expert_pvfs, ei, array_length(ei));
register_init_routine(pvfs2_io_tracking_init);

View File

@ -54,6 +54,17 @@ static int hf_slimp3_data_ack_write_pointer = -1;
static int hf_slimp3_data_ack_read_pointer = -1;
static int hf_slimp3_data_ack_sequence = -1;
static int hf_slimp3_data_req_offset = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_slimp3_display_delay = -1;
static int hf_slimp3_display_string = -1;
static int hf_slimp3_display_command = -1;
static int hf_slimp3_display_unknown = -1;
static int hf_slimp3_hello_response_client_server = -1;
static int hf_slimp3_hello_request_server_client = -1;
static int hf_slimp3_i2c_response_client_server = -1;
static int hf_slimp3_i2c_request_server_client = -1;
static int hf_slimp3_data_length = -1;
static int hf_slimp3_data_data = -1;
static gint ett_slimp3 = -1;
@ -335,6 +346,8 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
case SLIMP3_DISPLAY:
if (tree) {
guint8 value;
/* Loop through the commands */
i1 = 18;
in_str = FALSE;
@ -344,8 +357,9 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
case 0:
in_str = FALSE;
lcd_strlen = 0;
proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
"Delay (%u ms)", tvb_get_guint8(tvb, offset + i1 + 1));
value = tvb_get_guint8(tvb, offset + i1 + 1);
proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_display_delay, tvb, offset + i1, 2,
value, "%u ms", value);
i1 += 2;
break;
case 3:
@ -357,8 +371,8 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
proto_item_append_text(ti, "%c", lcd_char);
proto_item_set_len(ti, lcd_strlen);
} else {
ti = proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
"String: %c", lcd_char);
ti = proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_display_string, tvb, offset + i1, 2,
lcd_char, "%c", lcd_char);
in_str = TRUE;
lcd_strlen = 2;
}
@ -368,11 +382,8 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
case 2:
in_str = FALSE;
lcd_strlen = 0;
ti = proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
"Command: %s",
val_to_str(tvb_get_guint8(tvb, offset + i1 + 1),
slimp3_display_commands,
"Unknown (0x%0x)"));
value = tvb_get_guint8(tvb, offset + i1 + 1);
ti = proto_tree_add_uint(slimp3_tree, hf_slimp3_display_command, tvb, offset + i1, 2, value);
if ((tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30) {
proto_item_append_text(ti, ": %s",
val_to_str(tvb_get_guint8(tvb, offset + i1 + 2),
@ -384,10 +395,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
break;
default:
proto_tree_add_text(slimp3_tree, tvb, offset + i1, 2,
"Unknown 0x%0x, 0x%0x",
tvb_get_guint8(tvb, offset + i1),
tvb_get_guint8(tvb, offset + i1 + 1));
proto_tree_add_item(slimp3_tree, hf_slimp3_display_unknown, tvb, offset + i1, 2, ENC_NA);
i1 += 2;
break;
}
@ -441,14 +449,14 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
if (to_server) {
guint8 fw_ver;
/* Hello response; client->server */
proto_tree_add_text(slimp3_tree, tvb, offset, 1, "Hello Response (Client --> Server)");
proto_tree_add_item(slimp3_tree, hf_slimp3_hello_response_client_server, tvb, offset, 1, ENC_NA);
proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
fw_ver = tvb_get_guint8(tvb, offset+2);
proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver,
"%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver);
} else {
/* Hello request; server->client */
proto_tree_add_text(slimp3_tree, tvb, offset, 1, "Hello Request (Server --> Client)");
proto_tree_add_item(slimp3_tree, hf_slimp3_hello_request_server_client, tvb, offset, 1, ENC_NA);
}
}
break;
@ -456,13 +464,11 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
case SLIMP3_I2C:
if (to_server) {
/* Hello response; client->server */
proto_tree_add_text(slimp3_tree, tvb, offset, -1,
"I2C Response (Client --> Server)");
proto_tree_add_item(slimp3_tree, hf_slimp3_i2c_response_client_server, tvb, offset, -1, ENC_NA);
col_append_str(pinfo->cinfo, COL_INFO, ", Response");
} else {
/* Hello request; server->client */
proto_tree_add_text(slimp3_tree, tvb, offset, -1,
"I2C Request (Server --> Client)");
proto_tree_add_item(slimp3_tree, hf_slimp3_i2c_request_server_client, tvb, offset, -1, ENC_NA);
col_append_str(pinfo->cinfo, COL_INFO, ", Request");
}
break;
@ -486,8 +492,8 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
*/
if (old_protocol) {
guint offset_buffer;
proto_tree_add_text(slimp3_tree, tvb, offset, -1,
"Length: %d bytes",
proto_tree_add_bytes_format(slimp3_tree, hf_slimp3_data_length, tvb, offset, -1,
NULL, "Length: %d bytes",
tvb_reported_length_remaining(tvb, offset+18));
offset_buffer = tvb_get_ntohs(tvb, offset+2) * 2;
proto_tree_add_uint(slimp3_tree, hf_slimp3_data_offset, tvb, offset+2, 2, offset_buffer);
@ -500,8 +506,8 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
else {
guint write_pointer;
proto_tree_add_item(slimp3_tree, hf_slimp3_data_command, tvb, offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_text(slimp3_tree, tvb, offset, -1,
"Length: %d bytes",
proto_tree_add_bytes_format(slimp3_tree, hf_slimp3_data_length, tvb, offset, -1,
NULL, "Length: %d bytes",
tvb_reported_length_remaining(tvb, offset+18));
write_pointer = tvb_get_ntohs(tvb, offset+6) * 2;
proto_tree_add_uint(slimp3_tree, hf_slimp3_data_write_pointer, tvb, offset+6, 2, write_pointer);
@ -566,8 +572,7 @@ dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
default:
if (tree) {
proto_tree_add_text(slimp3_tree, tvb, offset, -1,
"Data (%d bytes)", tvb_reported_length_remaining(tvb, offset));
proto_tree_add_item(slimp3_tree, hf_slimp3_data_data, tvb, offset, -1, ENC_NA);
}
break;
}
@ -678,6 +683,18 @@ proto_register_slimp3(void)
{ "Requested offset", "slimp3.data_req.offset",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
/* Generated from convert_proto_tree_add_text.pl */
{ &hf_slimp3_display_delay, { "Delay", "slimp3.display_delay", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_display_string, { "String", "slimp3.display_string", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_display_command, { "Command", "slimp3.display_command", FT_UINT8, BASE_DEC, VALS(slimp3_display_commands), 0x0, NULL, HFILL }},
{ &hf_slimp3_display_unknown, { "Unknown", "slimp3.display_unknown", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_hello_response_client_server, { "Hello Response (Client --> Server)", "slimp3.hello_response_client_server", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_hello_request_server_client, { "Hello Request (Server --> Client)", "slimp3.hello_request_server_client", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_i2c_response_client_server, { "I2C Response (Client --> Server)", "slimp3.i2c_response_client_server", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_i2c_request_server_client, { "I2C Request (Server --> Client)", "slimp3.i2c_request_server_client", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_data_length, { "Length", "slimp3.data.length", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_data_data, { "Data", "slimp3.data.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
};
static gint *ett[] = {

View File

@ -106,6 +106,9 @@ static int hf_send_buf_len = -1;
/* static int hf_continuation_from = -1; */
static int hf_status = -1;
static int hf_convert = -1;
static int hf_param_no_descriptor = -1;
static int hf_data_no_descriptor = -1;
static int hf_data_no_recv_buffer = -1;
static int hf_ecount = -1;
static int hf_acount = -1;
static int hf_share_name = -1;
@ -176,6 +179,9 @@ static int hf_code_page = -1;
static int hf_new_password = -1;
static int hf_old_password = -1;
static int hf_reserved = -1;
static int hf_share = -1;
static int hf_server = -1;
static int hf_aux_data_struct_count = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_smb_pipe_stringz_param = -1;
@ -792,8 +798,8 @@ static proto_item *
netshareenum_share_entry(tvbuff_t *tvb, proto_tree *tree, int offset)
{
if (tree) {
return proto_tree_add_text(tree, tvb, offset, -1,
"Share %.13s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 13, ENC_ASCII));
return proto_tree_add_string(tree, hf_share, tvb, offset, -1,
tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 13, ENC_ASCII));
} else
return NULL;
}
@ -992,8 +998,8 @@ static proto_item *
netserverenum2_server_entry(tvbuff_t *tvb, proto_tree *tree, int offset)
{
if (tree) {
return proto_tree_add_text(tree, tvb, offset, -1,
"Server %.16s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII));
return proto_tree_add_string(tree, hf_server, tvb, offset, -1,
tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII));
} else
return NULL;
}
@ -2167,9 +2173,7 @@ dissect_transact_data(tvbuff_t *tvb, int offset, int convert,
* XXX - hf_acount?
*/
WParam = tvb_get_letohs(tvb, offset);
proto_tree_add_text(tree, tvb, offset, 2,
"Auxiliary data structure count: %u (0x%04X)",
WParam, WParam);
proto_tree_add_uint(tree, hf_aux_data_struct_count, tvb, offset, 2, WParam);
offset += 2;
if (aux_count_p != NULL)
*aux_count_p = WParam; /* Save this for later retrieval */
@ -2516,8 +2520,7 @@ dissect_response_data(tvbuff_t *tvb, packet_info *pinfo, int convert,
" (No descriptor available)");
}
} else {
proto_tree_add_text(data_tree, tvb, offset, -1,
"Data (no descriptor available)");
proto_tree_add_item(data_tree, hf_data_no_descriptor, tvb, offset, -1, ENC_NA);
}
offset += tvb_length_remaining(tvb, offset);
} else {
@ -2812,8 +2815,7 @@ dissect_pipe_lanman(tvbuff_t *pd_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
* We can't dissect the parameters; just show them
* as raw data.
*/
proto_tree_add_text(tree, p_tvb, offset, -1,
"Parameters (no descriptor available)");
proto_tree_add_item(tree, hf_param_no_descriptor, p_tvb, offset, -1, ENC_NA);
/*
* We don't know whether we have a receive buffer,
@ -2821,8 +2823,7 @@ dissect_pipe_lanman(tvbuff_t *pd_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
* bytes purport to be data.
*/
if (d_tvb && tvb_reported_length(d_tvb) > 0) {
proto_tree_add_text(tree, d_tvb, 0, -1,
"Data (no descriptor available)");
proto_tree_add_item(tree, hf_data_no_descriptor, d_tvb, 0, -1, ENC_NA);
}
} else {
/* rest of the parameters */
@ -2851,8 +2852,7 @@ dissect_pipe_lanman(tvbuff_t *pd_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
* but we do have data, so just
* show what bytes are data.
*/
proto_tree_add_text(tree, d_tvb, 0, -1,
"Data (no receive buffer)");
proto_tree_add_item(tree, hf_data_no_recv_buffer, d_tvb, 0, -1, ENC_NA);
}
}
}
@ -2911,6 +2911,18 @@ proto_register_pipe_lanman(void)
{ "Convert", "lanman.convert", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Convert", HFILL }},
{ &hf_param_no_descriptor,
{ "Parameters (no descriptor available)", "lanman.param_no_descriptor", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_data_no_descriptor,
{ "Data (no descriptor available)", "lanman.data_no_descriptor", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_data_no_recv_buffer,
{ "Data (no receive buffer)", "lanman.data_no_recv_buffer", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_ecount,
{ "Entry Count", "lanman.entry_count", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Number of Entries", HFILL }},
@ -3192,6 +3204,18 @@ proto_register_pipe_lanman(void)
{ "Reserved", "lanman.reserved", FT_UINT32, BASE_HEX,
NULL, 0, "LANMAN Reserved", HFILL }},
{ &hf_share,
{ "Share", "lanman.share", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_server,
{ "Server", "lanman.server", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_aux_data_struct_count,
{ "Auxiliary data structure count", "lanman.aux_data_struct_count", FT_UINT16, BASE_DEC_HEX,
NULL, 0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_lanman,

View File

@ -35,6 +35,8 @@ void proto_reg_handoff_wccp(void);
static int proto_wccp = -1;
static int hf_wccp_message_type = -1; /* the message type */
static int hf_wccp_version = -1; /* protocol version */
static int hf_bucket = -1;
static int hf_bucket_bit = -1;
static int hf_message_header_version = -1;
static int hf_hash_revision = -1; /* the version of the hash */
static int hf_change_num = -1; /* change number */
@ -52,7 +54,9 @@ static int hf_security_info_option = -1;
static int hf_security_info_md5_checksum = -1;
static int hf_command_element_type = -1;
static int hf_command_element_length = -1;
static int hf_command_length = -1;
static int hf_command_element_shutdown_ip = -1;
static int hf_command_unknown = -1;
static int hf_service_info_type = -1;
static int hf_service_info_id_standard = -1;
static int hf_service_info_id_dynamic = -1;
@ -89,6 +93,7 @@ static int hf_assignment_weight = -1;
static int hf_assignment_status = -1;
static int hf_assignment_key_ip = -1;
static int hf_assignment_key_change_num = -1;
static int hf_assignment_no_data = -1;
static int hf_router_view_member_change_num = -1;
static int hf_router_router_num = -1;
static int hf_router_identity_router_ip = -1;
@ -125,6 +130,8 @@ static int hf_capability_timer_scale_timeout_scale_upper_limit = -1;
static int hf_capability_timer_scale_timeout_scale_lower_limit = -1;
static int hf_capability_timer_scale_ra_scale_upper_limit = -1;
static int hf_capability_timer_scale_ra_scale_lower_limit = -1;
static int hf_capability_value = -1;
static int hf_reserved_zero = -1;
static int hf_value_element_src_ip = -1;
static int hf_value_element_dest_ip = -1;
static int hf_value_element_src_port = -1;
@ -145,6 +152,7 @@ static int hf_alt_assignment_info_num_routers = -1;
static int hf_alt_assignment_mask_value_set_element_num_wc_value_elements = -1;
static int hf_web_cache_value_element_wc_address = -1;
static int hf_web_cache_value_element_num_values = -1;
static int hf_web_cache_value_seq_num = -1;
static int hf_alt_assignment_mask_value_set_list_num_elements = -1;
static int hf_address_table_family = -1;
static int hf_address_table_address_length = -1;
@ -227,6 +235,9 @@ static expert_field ei_wccp_router_identity_receive_id_zero = EI_INIT;
static expert_field ei_wccp_web_cache_identity_hash_rev_zero = EI_INIT;
static expert_field ei_wccp_address_table_family_unknown = EI_INIT;
static expert_field ei_wccp_capability_element_length = EI_INIT;
static expert_field ei_wccp_port_fields_not_used = EI_INIT;
static expert_field ei_wccp_a_zero_not_c = EI_INIT;
static expert_field ei_wccp_c_zero_not_a = EI_INIT;
/*
* At
@ -405,7 +416,6 @@ static guint dissect_web_cache_list_entry(tvbuff_t *tvb, int offset,
int idx, proto_tree *wccp_tree);
static int wccp_bucket_info(guint8 bucket_info, proto_tree *bucket_tree,
guint32 start, tvbuff_t *tvb, int offset);
static const gchar *bucket_name(guint8 bucket);
static void dissect_wccp2_info(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *wccp_tree, guint32 wccp_message_type);
@ -482,7 +492,6 @@ static gint dissect_wccp2_alternate_mask_value_set_list(tvbuff_t *tvb, int offse
static gint dissect_wccp2_alternate_mask_value_set_element(tvbuff_t *tvb, int offset, gint length, guint el_index, packet_info *pinfo, proto_tree *info_tree);
static gint dissect_wccp2_web_cache_value_element(tvbuff_t *tvb, int offset,
gint length, packet_info *pinfo, proto_tree *info_tree);
static const gchar *assignment_bucket_name(guint8 bucket);
static void dissect_32_bit_capability_flags(tvbuff_t *tvb, int curr_offset,
guint16 capability_val_len, gint ett, const capability_flag *flags,
proto_tree *element_tree, proto_item *header,
@ -684,6 +693,7 @@ dissect_wccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
guint32 cache_count;
guint32 ipaddr;
guint i;
guint8 bucket;
wccp_message_type = tvb_get_ntohl(tvb, offset);
@ -757,15 +767,17 @@ dissect_wccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
tvb_ip_to_str(tvb, offset));
offset += 4;
}
for (i = 0; i < 256; i += 4) {
proto_tree_add_text(wccp_tree, tvb, offset, 4,
"Buckets %d - %d: %10s %10s %10s %10s",
i, i + 3,
bucket_name(tvb_get_guint8(tvb, offset)),
bucket_name(tvb_get_guint8(tvb, offset+1)),
bucket_name(tvb_get_guint8(tvb, offset+2)),
bucket_name(tvb_get_guint8(tvb, offset+3)));
offset += 4;
for (i = 0; i < 256; i++) {
bucket = tvb_get_guint8(tvb, offset);
if (bucket == 0xff) {
proto_tree_add_uint_format(wccp_tree, hf_bucket, tvb, offset, 1,
bucket, "Bucket %d: Unassigned", i);
} else {
proto_tree_add_uint_format(wccp_tree, hf_bucket, tvb, offset, 1,
bucket, "Bucket %d: %d", i, bucket);
}
offset++;
}
break;
@ -859,22 +871,13 @@ wccp_bucket_info(guint8 bucket_info, proto_tree *bucket_tree, guint32 start,
guint32 i;
for(i = 0; i < 8; i++) {
proto_tree_add_text(bucket_tree, tvb, offset, sizeof(bucket_info), "Bucket %3d: %s", start, (bucket_info & 1<<i ? "Assigned" : "Not Assigned") );
proto_tree_add_uint_format(bucket_tree, hf_bucket_bit, tvb, offset, 1, bucket_info & 1<<i,
"Bucket %3d: %s", start, (bucket_info & 1<<i ? "Assigned" : "Not Assigned") );
start++;
}
return(start);
}
static const gchar *
bucket_name(guint8 bucket)
{
if (bucket == 0xff) {
return "Unassigned";
} else {
return wmem_strdup_printf(wmem_packet_scope(), "%u", bucket);
}
}
static void
dissect_wccp2_info(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *wccp_tree,
@ -1318,8 +1321,7 @@ dissect_wccp2_service_info(tvbuff_t *tvb, int offset, gint length,
else {
/* just use up the space if there is */
if (offset + 8 * 2 <= max_offset) {
proto_tree_add_text(info_tree, tvb, offset, 8*2,
"Ports fields not used");
proto_tree_add_expert(info_tree, pinfo, &ei_wccp_port_fields_not_used, tvb, offset, 8*2);
/*offset += 8*2;*/
}
}
@ -1429,8 +1431,7 @@ dissect_wccp2_web_cache_identity_element(tvbuff_t *tvb, int offset, gint length,
return dissect_wccp2_mask_assignment_data_element(tvb,offset,length,pinfo,info_tree);
case WCCP2_WEB_CACHE_ASSIGNMENT_DATA_TYPE_NOT_PRESENT:
proto_tree_add_text(info_tree, tvb, offset, 2,
"No Assignment Data Present");
proto_tree_add_item(info_tree, hf_assignment_no_data, tvb, offset, 2, ENC_NA);
return length;
break;
case WCCP2_WEB_CACHE_ASSIGNMENT_DATA_TYPE_EXTENDED:
@ -1688,12 +1689,12 @@ static gint dissect_wccp2_hash_buckets_assignment_element(tvbuff_t *tvb, int off
guint32 i,n_web_caches;
proto_item *te;
proto_tree *element_tree;
guint8 bucket;
if (length < 4)
return length - 4;
n_web_caches = tvb_get_ntohl(tvb, offset);
te = proto_tree_add_uint(info_tree, hf_hash_buckets_assignment_wc_num, tvb, offset, 4, n_web_caches);
te = proto_tree_add_item_ret_uint(info_tree, hf_hash_buckets_assignment_wc_num, tvb, offset, 4, ENC_BIG_ENDIAN, &n_web_caches);
EAT(4);
element_tree = proto_item_add_subtree(te,ett_hash_buckets_assignment_wc_element);
@ -1709,21 +1710,15 @@ static gint dissect_wccp2_hash_buckets_assignment_element(tvbuff_t *tvb, int off
EAT(4);
}
te = proto_tree_add_text(info_tree,tvb, offset,256, "Buckets");
element_tree = proto_item_add_subtree(te,ett_hash_buckets_assignment_buckets);
element_tree = proto_tree_add_subtree(info_tree,tvb, offset, 256, ett_hash_buckets_assignment_buckets, NULL, "Buckets");
for (i = 0; i < 256; i += 4) {
if (length < 4)
for (i = 0; i < 256; i++, offset++, length--) {
if (length < 1)
return length - (256-i);
proto_tree_add_text(element_tree, tvb, offset, 4,
"Buckets %3d - %3d: %10s %10s %10s %10s",
i, i + 3,
assignment_bucket_name(tvb_get_guint8(tvb, offset)),
assignment_bucket_name(tvb_get_guint8(tvb, offset+1)),
assignment_bucket_name(tvb_get_guint8(tvb, offset+2)),
assignment_bucket_name(tvb_get_guint8(tvb, offset+3)));
EAT(4);
bucket = tvb_get_guint8(tvb, offset);
proto_tree_add_uint_format(element_tree, hf_bucket, tvb, offset, 1,
bucket, "Bucket %3d: %10s",
i, assignment_bucket_name(bucket));
}
return length;
}
@ -1793,7 +1788,7 @@ dissect_wccp2_command_extension(tvbuff_t *tvb, int offset,
int length, packet_info *pinfo _U_, proto_tree *info_tree)
{
guint16 command_type;
guint16 command_length;
guint32 command_length;
for (;;) {
if (length == 0)
@ -1806,11 +1801,8 @@ dissect_wccp2_command_extension(tvbuff_t *tvb, int offset,
proto_tree_add_item(info_tree, hf_command_element_type, tvb, offset, 2, ENC_BIG_ENDIAN);
EAT_AND_CHECK(2,2);
command_length = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(info_tree, hf_command_element_length, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_text(info_tree, tvb, offset, 2,
"Command length: %u", command_length);
proto_tree_add_item_ret_uint(info_tree, hf_command_element_length, tvb, offset, 2, ENC_BIG_ENDIAN, &command_length);
proto_tree_add_item(info_tree, hf_command_length, tvb, offset, 2, ENC_BIG_ENDIAN);
EAT(2);
if (((command_type == WCCP2_COMMAND_TYPE_SHUTDOWN) ||
@ -1820,11 +1812,10 @@ dissect_wccp2_command_extension(tvbuff_t *tvb, int offset,
return length - 4;
proto_tree_add_item(info_tree, hf_command_element_shutdown_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
} else {
if (length < command_length)
if (length < (int)command_length)
return length - command_length;
proto_tree_add_text(info_tree, tvb, offset, command_length,
"Unknown command");
proto_tree_add_item(info_tree, hf_command_unknown, tvb, offset, command_length, ENC_NA);
}
EAT(command_length);
}
@ -1945,38 +1936,34 @@ static gint
dissect_wccp2_hash_assignment_info(tvbuff_t *tvb, int offset, gint length,
packet_info *pinfo, proto_tree *info_tree)
{
guint32 n_web_caches;
guint32 n_web_caches, host_addr;
guint i;
guint8 bucket;
if (length < HASH_ASSIGNMENT_INFO_MIN_LEN)
return length - ASSIGNMENT_INFO_MIN_LEN;
n_web_caches = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(info_tree, hf_wc_view_wc_num, tvb, offset, 4, n_web_caches);
proto_tree_add_item_ret_uint(info_tree, hf_wc_view_wc_num, tvb, offset, 4, ENC_BIG_ENDIAN, &n_web_caches);
EAT(4);
for (i = 0; i < n_web_caches; i++) {
if (length < 4)
return length - 4*(n_web_caches-i)-256;
proto_tree_add_text(info_tree, tvb, offset, 4,
"Web-Cache %d: IP address %s", i,
host_addr = tvb_get_ntohl(tvb,offset);
proto_tree_add_uint_format(info_tree, hf_cache_ip, tvb, offset, 4, host_addr, "Web-Cache %d: IP address %s", i,
decode_wccp_encoded_address(tvb, offset, pinfo, info_tree));
EAT(4);
}
for (i = 0; i < 256; i += 4) {
if (length < 4)
return length - (256-i);
proto_tree_add_text(info_tree, tvb, offset, 4,
"Buckets %d - %d: %10s %10s %10s %10s",
i, i + 3,
assignment_bucket_name(tvb_get_guint8(tvb, offset)),
assignment_bucket_name(tvb_get_guint8(tvb, offset+1)),
assignment_bucket_name(tvb_get_guint8(tvb, offset+2)),
assignment_bucket_name(tvb_get_guint8(tvb, offset+3)));
EAT(4);
for (i = 0; i < 256; i++, offset++, length--) {
if (length < 1)
return length - (256-i);
bucket = tvb_get_guint8(tvb, offset);
proto_tree_add_uint_format(info_tree, hf_bucket, tvb, offset, 1,
bucket, "Bucket %3d: %10s",
i, assignment_bucket_name(bucket));
}
return length;
}
@ -2304,10 +2291,7 @@ dissect_wccp2_capability_element(tvbuff_t *tvb, int offset, gint length,
tf, pinfo);
break;
default:
proto_tree_add_text(element_tree, tvb,
offset, capability_val_len,
"Value: %s",
tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, capability_val_len));
proto_tree_add_item(element_tree, hf_capability_value, tvb, offset, capability_val_len, ENC_NA);
break;
}
return length - 4 - capability_val_len;
@ -2453,7 +2437,7 @@ dissect_wccp2_alternate_mask_value_set_element(tvbuff_t *tvb, int offset, gint l
static gint
dissect_wccp2_web_cache_value_element(tvbuff_t *tvb, int offset, gint length, packet_info *pinfo _U_, proto_tree *info_tree)
{
guint number_of_elements;
guint number_of_elements, seq_num;
proto_item *tl;
proto_tree *element_tree;
guint i;
@ -2474,10 +2458,9 @@ dissect_wccp2_web_cache_value_element(tvbuff_t *tvb, int offset, gint length, p
if (length < 4)
return length - 4*(number_of_elements-i);
proto_tree_add_text(element_tree, tvb, offset, 4,
"Value Sequence Number %d: %x",
i+1,
tvb_get_ntohl(tvb, offset));
seq_num = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint_format(element_tree, hf_web_cache_value_seq_num, tvb, offset, 4,
seq_num, "Value Sequence Number %d: %x", i+1, seq_num);
EAT(4);
}
@ -2555,8 +2538,7 @@ dissect_transmit_t_capability(tvbuff_t *tvb, proto_item *te, int curr_offset,
if ( upper_limit == 0) {
method_tree = proto_tree_add_subtree(element_tree, tvb, curr_offset, 2,
ett, NULL, "Only accepting one value");
proto_tree_add_text(method_tree, tvb, curr_offset, 2,
"Reserved, must be 0: %d", upper_limit);
proto_tree_add_uint(method_tree, hf_reserved_zero, tvb, curr_offset, 2, upper_limit);
proto_tree_add_item(method_tree, hf_capability_transmit_t , tvb, curr_offset+2, 2, ENC_BIG_ENDIAN);
proto_item_append_text(te, " %d ms", lower_limit);
@ -2595,23 +2577,19 @@ dissect_timer_scale_capability(tvbuff_t *tvb, int curr_offset,
method_tree = proto_tree_add_subtree(element_tree, tvb, curr_offset, 2,
ett, NULL, "Only accepting one value");
proto_tree_add_text(method_tree, tvb, curr_offset, 1,
"Reserved, must be 0: %d", a);
proto_tree_add_uint(method_tree, hf_reserved_zero, tvb, curr_offset, 1, a);
proto_tree_add_item(method_tree, hf_capability_timer_scale_timeout_scale,
tvb, curr_offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_text(method_tree, tvb, curr_offset+2, 1,
"Reserved, must be 0: %d", c);
proto_tree_add_uint(method_tree, hf_reserved_zero, tvb, curr_offset+2, 1, c);
proto_tree_add_item(method_tree, hf_capability_timer_scale_ra_timer_scale,
tvb, curr_offset+3, 1, ENC_BIG_ENDIAN);
} else {
proto_tree_add_text(element_tree, tvb, curr_offset, 1,
"Error A is 0, but C is not");
proto_tree_add_expert(element_tree, pinfo, &ei_wccp_a_zero_not_c, tvb, curr_offset, 1);
}
} else {
if ( c == 0) {
proto_tree_add_text(element_tree, tvb, curr_offset, 1,
"Error C is 0, but A is not");
proto_tree_add_expert(element_tree, pinfo, &ei_wccp_a_zero_not_c, tvb, curr_offset, 1);
} else {
method_tree = proto_tree_add_subtree(element_tree, tvb, curr_offset, 2,
ett, NULL, "Accepting a range");
@ -2787,6 +2765,14 @@ proto_register_wccp(void)
{ "WCCP Version", "wccp.version", FT_UINT32, BASE_HEX, VALS(wccp_version_val), 0x0,
"The WCCP version", HFILL }
},
{ &hf_bucket,
{ "Bucket", "wccp.bucket", FT_UINT8, BASE_DEC, 0x0, 0x0,
NULL, HFILL }
},
{ &hf_bucket_bit,
{ "Bucket", "wccp.bucket_bit", FT_UINT8, BASE_DEC, 0x0, 0x0,
NULL, HFILL }
},
{ &hf_message_header_version,
{ "WCCP Version (>=2)", "wccp.message_header_version", FT_UINT16, BASE_HEX, NULL, 0x0,
"The WCCP version for version 2 and above", HFILL }
@ -2851,10 +2837,18 @@ proto_register_wccp(void)
{"Command Extension Length", "wccp.command_element_length", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_command_length,
{"Command Length", "wccp.command_length", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_command_element_shutdown_ip,
{"Command Extension Length", "wccp.command_element_shudown_ip", FT_UINT32, BASE_CUSTOM, CF_FUNC(wccp_fmt_ipadddress), 0x0,
NULL, HFILL }
},
{ &hf_command_unknown,
{"Unknown Command", "wccp.command_unknown", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_service_info_type,
{ "Service Type", "wccp.service_info_type", FT_UINT8, BASE_DEC, VALS(service_type_vals), 0x0,
NULL, HFILL }
@ -3003,6 +2997,10 @@ proto_register_wccp(void)
{ "Assignment Key Change Number", "wccp.assignment_key.change_num", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_assignment_no_data,
{ "No Assignment Data Present", "wccp.assignment_no_data", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_router_view_member_change_num,
{ "Member Change Number", "wccp.router_view.member_change_num", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
@ -3151,6 +3149,14 @@ proto_register_wccp(void)
{ "RA Timer scale lower limit", "wccp.capability.timer_scale.ra_timer_scale.lower_limit", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_capability_value,
{ "Value", "wccp.capability.value", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_reserved_zero,
{ "Reserved, must be 0", "wccp.reserved_zero", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_value_element_src_ip,
{ "Source Address", "wccp.value_element.src_ip", FT_UINT32, BASE_CUSTOM, CF_FUNC(wccp_fmt_ipadddress), 0x0,
NULL, HFILL }
@ -3228,7 +3234,11 @@ proto_register_wccp(void)
NULL, HFILL }
},
{ &hf_web_cache_value_element_num_values,
{ "Number of Valye Sequence Numbers", "wccp.web_cache_value_element.num_values", FT_UINT32, BASE_DEC, NULL, 0x0,
{ "Number of Value Sequence Numbers", "wccp.web_cache_value_element.num_values", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_web_cache_value_seq_num,
{ "Value Sequence Number", "wccp.web_cache_value_element.value_seq_num", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_alt_assignment_mask_value_set_list_num_elements,
@ -3333,6 +3343,9 @@ proto_register_wccp(void)
{ &ei_wccp_web_cache_identity_hash_rev_zero, { "wccp.web_cache_identity.hash_rev.zero", PI_PROTOCOL, PI_WARN, "Should be 0 (6.4)", EXPFILL }},
{ &ei_wccp_address_table_family_unknown, { "wccp.address_table.family_type.unknown", PI_PROTOCOL, PI_ERROR, "Unknown address family", EXPFILL }},
{ &ei_wccp_capability_element_length, { "wccp.capability_element.length.invalid", PI_PROTOCOL, PI_WARN, "Value Length invalid", EXPFILL }},
{ &ei_wccp_port_fields_not_used, { "wccp.port_fields_not_used", PI_PROTOCOL, PI_NOTE, "Ports fields not used", EXPFILL }},
{ &ei_wccp_a_zero_not_c, { "wccp.a_zero_not_c", PI_PROTOCOL, PI_WARN, "Error A is 0, but C is not", EXPFILL }},
{ &ei_wccp_c_zero_not_a, { "wccp.c_zero_not_a", PI_PROTOCOL, PI_WARN, "Error C is 0, but A is not", EXPFILL }},
};
expert_module_t* expert_wccp;