Follow-up to r50935: add support for 64-bit value strings in more places that

need it, I think this is all of them.

svn path=/trunk/; revision=50941
This commit is contained in:
Evan Huus 2013-07-26 23:51:00 +00:00
parent d22919194a
commit 5ede3bcde0
4 changed files with 50 additions and 2 deletions

View File

@ -144,6 +144,18 @@ mk_uint32_fvalue(guint32 val)
return fv;
}
/* Creates a FT_UINT64 fvalue with a given value. */
static fvalue_t*
mk_uint64_fvalue(guint64 val)
{
fvalue_t *fv;
fv = fvalue_new(FT_UINT64);
fvalue_set_integer64(fv, val);
return fv;
}
/* Try to make an fvalue from a string using a value_string or true_false_string.
* This works only for ftypes that are integers. Returns the created fvalue_t*
* or NULL if impossible. */
@ -171,8 +183,6 @@ mk_fvalue_from_val_string(header_field_info *hfinfo, char *s)
case FT_STRING:
case FT_STRINGZ:
case FT_UINT_STRING:
case FT_UINT64:
case FT_INT64:
case FT_EUI64:
case FT_PCRE:
case FT_GUID:
@ -185,10 +195,12 @@ mk_fvalue_from_val_string(header_field_info *hfinfo, char *s)
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
case FT_UINT64:
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
case FT_INT64:
break;
case FT_NUM_TYPES:
@ -231,6 +243,18 @@ mk_fvalue_from_val_string(header_field_info *hfinfo, char *s)
dfilter_fail("\"%s\" cannot accept [range] strings as values.",
hfinfo->abbrev);
}
else if (hfinfo->display & BASE_VAL64_STRING) {
const val64_string *vals = (const val64_string *)hfinfo->strings;
while (vals->strptr != NULL) {
if (g_ascii_strcasecmp(s, vals->strptr) == 0) {
return mk_uint64_fvalue(vals->value);
}
vals++;
}
dfilter_fail("\"%s\" cannot be found among the possible values for %s.",
s, hfinfo->abbrev);
}
else if (hfinfo->display == BASE_CUSTOM) {
/* If a user wants to match against a custom string, we would
* somehow have to have the integer value here to pass it in

View File

@ -4764,6 +4764,13 @@ static const value_string hf_display[] = {
{ BASE_DEC_HEX|BASE_RANGE_STRING, "BASE_DEC_HEX|BASE_RANGE_STRING" },
{ BASE_HEX_DEC|BASE_RANGE_STRING, "BASE_HEX_DEC|BASE_RANGE_STRING" },
{ BASE_CUSTOM|BASE_RANGE_STRING, "BASE_CUSTOM|BASE_RANGE_STRING" },
{ BASE_NONE|BASE_VAL64_STRING, "BASE_NONE|BASE_VAL64_STRING" },
{ BASE_DEC|BASE_VAL64_STRING, "BASE_DEC|BASE_VAL64_STRING" },
{ BASE_HEX|BASE_VAL64_STRING, "BASE_HEX|BASE_VAL64_STRING" },
{ BASE_OCT|BASE_VAL64_STRING, "BASE_OCT|BASE_VAL64_STRING" },
{ BASE_DEC_HEX|BASE_VAL64_STRING, "BASE_DEC_HEX|BASE_VAL64_STRING" },
{ BASE_HEX_DEC|BASE_VAL64_STRING, "BASE_HEX_DEC|BASE_VAL64_STRING" },
{ BASE_CUSTOM|BASE_VAL64_STRING, "BASE_CUSTOM|BASE_VAL64_STRING" },
{ ABSOLUTE_TIME_LOCAL, "ABSOLUTE_TIME_LOCAL" },
{ ABSOLUTE_TIME_UTC, "ABSOLUTE_TIME_UTC" },
{ ABSOLUTE_TIME_DOY_UTC, "ABSOLUTE_TIME_DOY_UTC" },

View File

@ -1276,6 +1276,8 @@ static gboolean print_field_value(field_info *finfo, int cmd_line_index)
string_fmt_t *sf;
guint32 uvalue;
gint32 svalue;
guint64 uvalue64;
gint64 svalue64;
const true_false_string *tfstring = &tfs_true_false;
hfinfo = finfo->hfinfo;
@ -1347,6 +1349,13 @@ static gboolean print_field_value(field_info *finfo, int cmd_line_index)
g_string_append(label_s, val_to_str(svalue, cVALS(hfinfo->strings), "Unknown"));
}
break;
case FT_INT64:
DISSECTOR_ASSERT(!hfinfo->bitmask);
svalue64 = (gint64)fvalue_get_integer64(&finfo->value);
if (hfinfo->display & BASE_VAL64_STRING) {
g_string_append(label_s, val64_to_str(svalue64, (const val64_string *)(hfinfo->strings), "Unknown"));
}
break;
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
@ -1360,6 +1369,13 @@ static gboolean print_field_value(field_info *finfo, int cmd_line_index)
g_string_append(label_s, val_to_str(uvalue, cVALS(hfinfo->strings), "Unknown"));
}
break;
case FT_UINT64:
DISSECTOR_ASSERT(!hfinfo->bitmask);
uvalue64 = fvalue_get_integer64(&finfo->value);
if (hfinfo->display & BASE_VAL64_STRING) {
g_string_append(label_s, val64_to_str(uvalue64, (const val64_string *)(hfinfo->strings), "Unknown"));
}
break;
default:
break;
}

View File

@ -189,6 +189,7 @@ field_select_row_cb(GtkTreeSelection *sel, gpointer tree)
/* XXX: ToDo: Implement "range-string" filter ? */
if ((hfinfo->strings != NULL) &&
! (hfinfo->display & BASE_RANGE_STRING) &&
! (hfinfo->display & BASE_VAL64_STRING) &&
! ((hfinfo->display & BASE_DISPLAY_E_MASK) == BASE_CUSTOM)) {
const value_string *vals = (const value_string *)hfinfo->strings;
if (hfinfo->display & BASE_EXT_STRING)