Use value_string_ext to access several "relatively large" value-strings.

svn path=/trunk/; revision=34689
This commit is contained in:
Bill Meier 2010-10-29 17:48:39 +00:00
parent 46416bddda
commit 4a43e13976
4 changed files with 34 additions and 25 deletions

View File

@ -568,6 +568,8 @@ static const value_string v9_v10_template_types[] = {
{ 0, NULL }
};
static value_string_ext v9_v10_template_types_ext = VALUE_STRING_EXT_INIT(v9_v10_template_types);
static const value_string v9_scope_field_types[] = {
{ 1, "System" },
{ 2, "Interface" },
@ -577,6 +579,8 @@ static const value_string v9_scope_field_types[] = {
{ 0, NULL }
};
static value_string_ext v9_scope_field_types_ext = VALUE_STRING_EXT_INIT(v9_scope_field_types);
static const value_string v9_sampler_mode[] = {
{ 0, "Deterministic" },
{ 1, "Unknown" }, /* "Time-Based" ?? */
@ -3988,7 +3992,7 @@ dissect_v9_v10_pdu_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pdutree,
/* XXX: why showing type ? type not shown if not reverse */
proto_item_append_text(ti, " (Reverse Type %u %s)",
masked_type,
val_to_str_const(masked_type, v9_v10_template_types,"Unknown"));
val_to_str_ext_const(masked_type, &v9_v10_template_types_ext,"Unknown"));
}
offset += length;
@ -4040,12 +4044,12 @@ static const int *v10_template_type_hf_list[TF_NUM] = {
&hf_cflow_template_ipfix_field_type, /* scope */
&hf_cflow_template_ipfix_field_type}; /* entry */
static const value_string *v9_template_type_vs_list[TF_NUM] = {
v9_scope_field_types, /* scope */
v9_v10_template_types }; /* entry */
static const value_string *v10_template_type_vs_list[TF_NUM] = {
v9_v10_template_types, /* scope */
v9_v10_template_types }; /* entry */
static value_string_ext *v9_template_type_vse_list[TF_NUM] = {
&v9_scope_field_types_ext, /* scope */
&v9_v10_template_types_ext }; /* entry */
static value_string_ext *v10_template_type_vse_list[TF_NUM] = {
&v9_v10_template_types_ext, /* scope */
&v9_v10_template_types_ext }; /* entry */
static int
dissect_v9_v10_template_fields(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tplt_tree, int offset,
@ -4102,7 +4106,7 @@ dissect_v9_v10_template_fields(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
proto_tree_add_item(field_tree, *v9_template_type_hf_list[fields_type],
tvb, offset, 2, ENC_BIG_ENDIAN);
proto_item_append_text(field_item, ": %s",
val_to_str(type, v9_template_type_vs_list[fields_type], "Unknown(%d)"));
val_to_str_ext(type, v9_template_type_vse_list[fields_type], "Unknown(%d)"));
} else { /* v10 */
proto_tree_add_item(field_tree, hf_cflow_template_ipfix_pen_provided,
tvb, offset, 2, ENC_BIG_ENDIAN);
@ -4111,7 +4115,7 @@ dissect_v9_v10_template_fields(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
ti = proto_tree_add_item(field_tree, *v10_template_type_hf_list[fields_type],
tvb, offset, 2, ENC_BIG_ENDIAN);
proto_item_append_text(field_item, ": %s",
val_to_str(type&0x7fff, v10_template_type_vs_list[fields_type], "Unknown(%d)"));
val_to_str_ext(type&0x7fff, v10_template_type_vse_list[fields_type], "Unknown(%d)"));
if (pen == REVPEN) {
proto_item_append_text(ti, " [Reverse]");
proto_item_append_text(field_item, " [Reverse]");
@ -4676,7 +4680,7 @@ proto_register_netflow(void)
},
{&hf_cflow_template_field_type,
{"Type", "cflow.template_field_type",
FT_UINT16, BASE_DEC, VALS(v9_v10_template_types), 0x0,
FT_UINT16, BASE_DEC|BASE_EXT_STRING, &v9_v10_template_types_ext, 0x0,
"Template field type", HFILL}
},
{&hf_cflow_template_field_length,
@ -4698,7 +4702,7 @@ proto_register_netflow(void)
},
{&hf_cflow_template_scope_field_type,
{"Scope Type", "cflow.scope_field_type",
FT_UINT16, BASE_DEC, VALS(v9_scope_field_types), 0x0,
FT_UINT16, BASE_DEC|BASE_EXT_STRING, &v9_scope_field_types_ext, 0x0,
"Scope field type", HFILL}
},
{&hf_cflow_icmp_type,
@ -6133,7 +6137,7 @@ proto_register_netflow(void)
},
{&hf_cflow_template_ipfix_field_type,
{"Type", "cflow.template_ipfix_field_type",
FT_UINT16, BASE_DEC, VALS(v9_v10_template_types), 0x7FFF,
FT_UINT16, BASE_DEC|BASE_EXT_STRING, &v9_v10_template_types_ext, 0x7FFF,
"Template field type", HFILL}
},
{&hf_cflow_template_ipfix_field_type_enterprise,

View File

@ -337,8 +337,8 @@ dissect_scsi_smc_element (tvbuff_t *tvb, packet_info *pinfo _U_,
if (flags & EXCEPT) {
proto_tree_add_text (tree, tvb, offset, 2,
"Additional Sense Code+Qualifier: %s",
val_to_str (tvb_get_ntohs (tvb, offset),
scsi_asc_val, "Unknown (0x%04x)"));
val_to_str_ext (tvb_get_ntohs (tvb, offset),
&scsi_asc_val_ext, "Unknown (0x%04x)"));
}
offset += 2;
elem_bytecnt -= 2;

View File

@ -1309,6 +1309,8 @@ static const value_string scsi_verdesc_val[] = {
{0, NULL},
};
static value_string_ext scsi_verdesc_val_ext = VALUE_STRING_EXT_INIT(scsi_verdesc_val);
/* Command Support Data "Support" field definitions */
static const value_string scsi_cmdt_supp_val[] = {
{0, "Data not currently available"},
@ -1517,7 +1519,7 @@ static const value_string scsi_sns_errtype_val[] = {
{0, NULL},
};
const value_string scsi_asc_val[] = {
static const value_string scsi_asc_val[] = {
{0x0000, "No Additional Sense Information"},
{0x0001, "Filemark Detected"},
{0x0002, "End Of Partition/Medium Detected"},
@ -1839,6 +1841,8 @@ const value_string scsi_asc_val[] = {
{0, NULL},
};
value_string_ext scsi_asc_val_ext = VALUE_STRING_EXT_INIT(scsi_asc_val);
/* SCSI Status Codes */
const value_string scsi_status_val[] = {
{0x00, "Good"},
@ -2046,9 +2050,9 @@ dissect_scsi_cmddt (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
val_to_str (tvb_get_guint8 (tvb, offset+1) & 0x7,
scsi_cmdt_supp_val, "Unknown (%d)"));
proto_tree_add_text (cmdt_tree, tvb, offset+2, 1, "Version: %s",
val_to_str (tvb_get_guint8 (tvb, offset+2),
scsi_verdesc_val,
"Unknown (0x%02x)"));
val_to_str_ext (tvb_get_guint8 (tvb, offset+2),
&scsi_verdesc_val_ext,
"Unknown (0x%02x)"));
proto_tree_add_text (cmdt_tree, tvb, offset+5, 1, "CDB Size: %u",
plen);
}
@ -5103,8 +5107,8 @@ proto_register_scsi (void)
{"Reserved", "scsi.inquiry.reserved", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL}},
{ &hf_scsi_inq_version_desc,
{"Version Description", "scsi.inquiry.version_desc", FT_UINT16, BASE_HEX,
VALS(scsi_verdesc_val), 0, NULL, HFILL}},
{"Version Description", "scsi.inquiry.version_desc", FT_UINT16, BASE_HEX|BASE_EXT_STRING,
&scsi_verdesc_val_ext, 0, NULL, HFILL}},
{ &hf_scsi_inq_devtype,
{"Device Type", "scsi.inquiry.devtype", FT_UINT8, BASE_HEX,
VALS (scsi_devtype_val), SCSI_DEV_BITS, NULL, HFILL}},
@ -5230,7 +5234,7 @@ proto_register_scsi (void)
BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_scsi_ascascq,
{"Additional Sense Code+Qualifier", "scsi.sns.ascascq", FT_UINT16,
BASE_HEX, VALS (scsi_asc_val), 0x0, NULL, HFILL}},
BASE_HEX|BASE_EXT_STRING, &scsi_asc_val_ext, 0x0, NULL, HFILL}},
{ &hf_scsi_fru,
{"Field Replaceable Unit Code", "scsi.sns.fru", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL}},

View File

@ -220,12 +220,13 @@ extern int hf_scsi_alloclen16;
#define SHORT_FORM_VENDOR_SPECIFIC 0x01
#define LONG_FORM 0x06
#define EXTENDED_FORM 0x08
#define SERVICE_READ_CAPACITY16 0x10
#define SERVICE_READ_LONG16 0x11
#define SERVICE_READ_CAPACITY16 0x10
#define SERVICE_READ_LONG16 0x11
extern const value_string service_action_vals[];
extern const value_string scsi_asc_val[];
extern const value_string scsi_devid_codeset_val[];
extern const value_string scsi_devid_idtype_val[];
extern value_string_ext scsi_asc_val_ext;
/* These two defines are used to handle cases where data coming back from
* the device is truncated due to a too short allocation_length specified
@ -241,7 +242,7 @@ extern const value_string scsi_devid_idtype_val[];
*/
#define TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb, offset, length) \
{ \
volatile gboolean short_packet; \
volatile gboolean short_packet; \
tvbuff_t *new_tvb; \
guint32 end_data_offset=0; \
\