proto.c: proto_registrar_dump_values(): don't skip "same name" fields.

It appears that Wireshark allows (and currently has) fields with the
same name with differing "strings" content.

Change-Id: Iddac5a2c9f456a97ea676f2007f43d786482eebd
Reviewed-on: https://code.wireshark.org/review/5491
Reviewed-by: Bill Meier <wmeier@newsguy.com>
This commit is contained in:
Bill Meier 2014-11-25 12:53:43 -05:00
parent 152b0c92d6
commit 20153980eb
1 changed files with 106 additions and 107 deletions

View File

@ -6853,127 +6853,126 @@ proto_registrar_dump_values(void)
continue;
}
/* process header fields */
else {
/*
* If this field isn't at the head of the list of
* fields with this name, skip this field - all
* fields with the same name are really just versions
* of the same field stored in different bits, and
* should have the same type/radix/value list, and
* just differ in their bit masks. (If a field isn't
* a bitfield, but can be, say, 1 or 2 bytes long,
* it can just be made FT_UINT16, meaning the
* *maximum* length is 2 bytes, and be used
* for all lengths.)
*/
if (hfinfo->same_name_prev_id != -1)
continue;
#if 0 /* XXX: We apparently allow fields with the same name but with differing "strings" content */
/*
* If this field isn't at the head of the list of
* fields with this name, skip this field - all
* fields with the same name are really just versions
* of the same field stored in different bits, and
* should have the same type/radix/value list, and
* just differ in their bit masks. (If a field isn't
* a bitfield, but can be, say, 1 or 2 bytes long,
* it can just be made FT_UINT16, meaning the
* *maximum* length is 2 bytes, and be used
* for all lengths.)
*/
if (hfinfo->same_name_prev_id != -1)
continue;
#endif
vals = NULL;
vals64 = NULL;
range = NULL;
tfs = NULL;
vals = NULL;
vals64 = NULL;
range = NULL;
tfs = NULL;
if (hfinfo->strings != NULL) {
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) != BASE_CUSTOM &&
(hfinfo->type == FT_UINT8 ||
hfinfo->type == FT_UINT16 ||
hfinfo->type == FT_UINT24 ||
hfinfo->type == FT_UINT32 ||
hfinfo->type == FT_UINT64 ||
hfinfo->type == FT_INT8 ||
hfinfo->type == FT_INT16 ||
hfinfo->type == FT_INT24 ||
hfinfo->type == FT_INT32 ||
hfinfo->type == FT_INT64)) {
if (hfinfo->strings != NULL) {
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) != BASE_CUSTOM &&
(hfinfo->type == FT_UINT8 ||
hfinfo->type == FT_UINT16 ||
hfinfo->type == FT_UINT24 ||
hfinfo->type == FT_UINT32 ||
hfinfo->type == FT_UINT64 ||
hfinfo->type == FT_INT8 ||
hfinfo->type == FT_INT16 ||
hfinfo->type == FT_INT24 ||
hfinfo->type == FT_INT32 ||
hfinfo->type == FT_INT64)) {
if (hfinfo->display & BASE_RANGE_STRING) {
range = (const range_string *)hfinfo->strings;
} else if (hfinfo->display & BASE_EXT_STRING) {
vals = VALUE_STRING_EXT_VS_P((value_string_ext *)hfinfo->strings);
} else if (hfinfo->display & BASE_VAL64_STRING) {
vals64 = (const val64_string *)hfinfo->strings;
} else {
vals = (const value_string *)hfinfo->strings;
}
}
else if (hfinfo->type == FT_BOOLEAN) {
tfs = (const struct true_false_string *)hfinfo->strings;
if (hfinfo->display & BASE_RANGE_STRING) {
range = (const range_string *)hfinfo->strings;
} else if (hfinfo->display & BASE_EXT_STRING) {
vals = VALUE_STRING_EXT_VS_P((value_string_ext *)hfinfo->strings);
} else if (hfinfo->display & BASE_VAL64_STRING) {
vals64 = (const val64_string *)hfinfo->strings;
} else {
vals = (const value_string *)hfinfo->strings;
}
}
else if (hfinfo->type == FT_BOOLEAN) {
tfs = (const struct true_false_string *)hfinfo->strings;
}
}
/* Print value strings? */
if (vals) {
if (hfinfo->display & BASE_EXT_STRING) {
value_string_ext *vse_p = (value_string_ext *)hfinfo->strings;
if (!value_string_ext_validate(vse_p)) {
g_warning("Invalid value_string_ext ptr for: %s", hfinfo->abbrev);
continue;
}
try_val_to_str_ext(0, vse_p); /* "prime" the extended value_string */
printf("E\t%s\t%d\t%s\t%s\n",
/* Print value strings? */
if (vals) {
if (hfinfo->display & BASE_EXT_STRING) {
value_string_ext *vse_p = (value_string_ext *)hfinfo->strings;
if (!value_string_ext_validate(vse_p)) {
g_warning("Invalid value_string_ext ptr for: %s", hfinfo->abbrev);
continue;
}
try_val_to_str_ext(0, vse_p); /* "prime" the extended value_string */
printf("E\t%s\t%d\t%s\t%s\n",
hfinfo->abbrev,
VALUE_STRING_EXT_VS_NUM_ENTRIES(vse_p),
VALUE_STRING_EXT_VS_NAME(vse_p),
value_string_ext_match_type_str(vse_p));
}
vi = 0;
while (vals[vi].strptr) {
/* Print in the proper base */
if (hfinfo->display == BASE_HEX) {
printf("V\t%s\t0x%x\t%s\n",
hfinfo->abbrev,
VALUE_STRING_EXT_VS_NUM_ENTRIES(vse_p),
VALUE_STRING_EXT_VS_NAME(vse_p),
value_string_ext_match_type_str(vse_p));
vals[vi].value,
vals[vi].strptr);
}
vi = 0;
while (vals[vi].strptr) {
/* Print in the proper base */
if (hfinfo->display == BASE_HEX) {
printf("V\t%s\t0x%x\t%s\n",
hfinfo->abbrev,
vals[vi].value,
vals[vi].strptr);
}
else {
printf("V\t%s\t%u\t%s\n",
hfinfo->abbrev,
vals[vi].value,
vals[vi].strptr);
}
vi++;
else {
printf("V\t%s\t%u\t%s\n",
hfinfo->abbrev,
vals[vi].value,
vals[vi].strptr);
}
vi++;
}
else if (vals64) {
vi = 0;
while (vals64[vi].strptr) {
printf("V64\t%s\t%" G_GINT64_MODIFIER "u\t%s\n",
hfinfo->abbrev,
vals64[vi].value,
vals64[vi].strptr);
vi++;
}
}
else if (vals64) {
vi = 0;
while (vals64[vi].strptr) {
printf("V64\t%s\t%" G_GINT64_MODIFIER "u\t%s\n",
hfinfo->abbrev,
vals64[vi].value,
vals64[vi].strptr);
vi++;
}
}
/* print range strings? */
else if (range) {
vi = 0;
while (range[vi].strptr) {
/* Print in the proper base */
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_HEX) {
printf("R\t%s\t0x%x\t0x%x\t%s\n",
hfinfo->abbrev,
range[vi].value_min,
range[vi].value_max,
range[vi].strptr);
}
else {
printf("R\t%s\t%u\t%u\t%s\n",
hfinfo->abbrev,
range[vi].value_min,
range[vi].value_max,
range[vi].strptr);
}
vi++;
/* print range strings? */
else if (range) {
vi = 0;
while (range[vi].strptr) {
/* Print in the proper base */
if ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_HEX) {
printf("R\t%s\t0x%x\t0x%x\t%s\n",
hfinfo->abbrev,
range[vi].value_min,
range[vi].value_max,
range[vi].strptr);
}
else {
printf("R\t%s\t%u\t%u\t%s\n",
hfinfo->abbrev,
range[vi].value_min,
range[vi].value_max,
range[vi].strptr);
}
vi++;
}
}
/* Print true/false strings? */
else if (tfs) {
printf("T\t%s\t%s\t%s\n", hfinfo->abbrev,
tfs->true_string, tfs->false_string);
}
/* Print true/false strings? */
else if (tfs) {
printf("T\t%s\t%s\t%s\n", hfinfo->abbrev,
tfs->true_string, tfs->false_string);
}
}
}