int hfinfo_bitwidth(header_field_info *hfinfo);
static const char* hfinfo_uint_vals_format(header_field_info *hfinfo);
static const char* hfinfo_uint_format(header_field_info *hfinfo);
+static const char* hfinfo_uint_value_format(header_field_info *hfinfo);
static const char* hfinfo_uint64_format(header_field_info *hfinfo);
static const char* hfinfo_int_vals_format(header_field_info *hfinfo);
static const char* hfinfo_int_format(header_field_info *hfinfo);
+static const char* hfinfo_int_value_format(header_field_info *hfinfo);
static const char* hfinfo_int64_format(header_field_info *hfinfo);
static proto_item*
if (length > 0) {
g_byte_array_append(bytes, start_ptr, length);
}
+ col_custom_set_fstr(fi->hfinfo, "%s", bytes_to_str(bytes->data,
+ length));
fvalue_set(&fi->value, bytes, TRUE);
}
static void
proto_tree_set_time(field_info *fi, nstime_t *value_ptr)
{
+ header_field_info *hfinfo;
+
DISSECTOR_ASSERT(value_ptr != NULL);
+ hfinfo = fi->hfinfo;
+
+ if (hfinfo->type == FT_ABSOLUTE_TIME) {
+ col_custom_set_fstr(fi->hfinfo, "%s", abs_time_to_str(value_ptr));
+ } else if (hfinfo->type == FT_RELATIVE_TIME) {
+ col_custom_set_fstr(fi->hfinfo, "%s", rel_time_to_secs_str(value_ptr));
+ }
fvalue_set(&fi->value, value_ptr, FALSE);
}
static void
proto_tree_set_ipxnet(field_info *fi, guint32 value)
{
- col_custom_set_fstr(fi->hfinfo->abbrev, "%u", value);
fvalue_set_uinteger(&fi->value, value);
}
static void
proto_tree_set_ipv4(field_info *fi, guint32 value)
{
+ col_custom_set_fstr(fi->hfinfo, "%s",
+ ip_to_str((guint8 *)&value));
fvalue_set_uinteger(&fi->value, value);
}
proto_tree_set_guid(field_info *fi, const e_guid_t *value_ptr)
{
DISSECTOR_ASSERT(value_ptr != NULL);
+ col_custom_set_fstr(fi->hfinfo, "%s",
+ guid_to_str(value_ptr));
fvalue_set(&fi->value, (gpointer) value_ptr, FALSE);
}
if (length > 0) {
g_byte_array_append(bytes, value_ptr, length);
}
+ col_custom_set_fstr(fi->hfinfo, "%s",
+ oid_resolved_from_encoded(value_ptr, length));
fvalue_set(&fi->value, bytes, TRUE);
}
static void
proto_tree_set_uint64(field_info *fi, guint64 value)
{
+ col_custom_set_fstr(fi->hfinfo, "%" G_GINT64_MODIFIER "u",
+ value);
fvalue_set_integer64(&fi->value, value);
}
proto_tree_set_string(field_info *fi, const char* value)
{
if (value) {
- col_custom_set_fstr(fi->hfinfo->abbrev, "%s", value);
+ col_custom_set_fstr(fi->hfinfo, "%s",
+ format_text(value, strlen(value)));
fvalue_set(&fi->value, (gpointer) value, FALSE);
} else {
- col_custom_set_fstr(fi->hfinfo->abbrev, "[ Null ]");
+ col_custom_set_fstr(fi->hfinfo, "[ Null ]");
fvalue_set(&fi->value, (gpointer) "[ Null ]", FALSE);
}
}
static void
proto_tree_set_ether(field_info *fi, const guint8* value)
{
- col_custom_set_fstr(fi->hfinfo->abbrev, "%s", value);
+ col_custom_set_fstr(fi->hfinfo, "%s", bytes_to_str_punct(value, 6, ':'));
fvalue_set(&fi->value, (gpointer) value, FALSE);
}
static void
proto_tree_set_float(field_info *fi, float value)
{
+ col_custom_set_fstr(fi->hfinfo, "%." STRINGIFY(FLT_DIG) "f",
+ value);
fvalue_set_floating(&fi->value, value);
}
static void
proto_tree_set_double(field_info *fi, double value)
{
+ col_custom_set_fstr(fi->hfinfo, "%." STRINGIFY(DBL_DIG) "g",
+ value);
fvalue_set_floating(&fi->value, value);
}
integer >>= hfinfo->bitshift;
}
}
- col_custom_set_fstr(hfinfo->abbrev, "%u", value);
+
+ if (hfinfo->type == FT_BOOLEAN) {
+ const true_false_string *tfstring = &tfs_true_false;
+ if (hfinfo->strings) {
+ tfstring = (const struct true_false_string*) hfinfo->strings;
+ }
+ col_custom_set_fstr(fi->hfinfo, "%s", value ? tfstring->true_string : tfstring->false_string);
+ } else if (hfinfo->strings) {
+ col_custom_set_fstr(fi->hfinfo, "%s", val_to_str(integer, cVALS(hfinfo->strings), "%d"));
+ } else if (IS_BASE_DUAL(hfinfo->display)) {
+ col_custom_set_fstr(fi->hfinfo, hfinfo_uint_value_format(hfinfo), integer, integer);
+ } else {
+ col_custom_set_fstr(fi->hfinfo, hfinfo_uint_value_format(hfinfo), integer);
+ }
fvalue_set_uinteger(&fi->value, integer);
}
}
}
- col_custom_set_fstr(hfinfo->abbrev, "%u", value);
+ if (hfinfo->strings) {
+ col_custom_set_fstr(fi->hfinfo, "%s", val_to_str(integer, cVALS(hfinfo->strings), "%d"));
+ } else if (IS_BASE_DUAL(hfinfo->display)) {
+ col_custom_set_fstr(fi->hfinfo, hfinfo_int_value_format(hfinfo), integer, integer);
+ } else {
+ col_custom_set_fstr(fi->hfinfo, hfinfo_int_value_format(hfinfo), integer);
+ }
fvalue_set_sinteger(&fi->value, integer);
}
return format;
}
+static const char*
+hfinfo_uint_value_format(header_field_info *hfinfo)
+{
+ const char *format = NULL;
+
+ /* Pick the proper format string */
+ if (hfinfo->type == FT_FRAMENUM) {
+ /*
+ * Frame numbers are always displayed in decimal.
+ */
+ format = "%u";
+ } else {
+ switch(hfinfo->display) {
+ case BASE_DEC:
+ format = "%u";
+ break;
+ case BASE_DEC_HEX:
+ switch(hfinfo->type) {
+ case FT_UINT8:
+ format = "%u (0x%02x)";
+ break;
+ case FT_UINT16:
+ format = "%u (0x%04x)";
+ break;
+ case FT_UINT24:
+ format = "%u (0x%06x)";
+ break;
+ case FT_UINT32:
+ format = "%u (0x%08x)";
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ ;
+ }
+ break;
+ case BASE_OCT:
+ format = "%o";
+ break;
+ case BASE_HEX:
+ switch(hfinfo->type) {
+ case FT_UINT8:
+ format = "0x%02x";
+ break;
+ case FT_UINT16:
+ format = "0x%04x";
+ break;
+ case FT_UINT24:
+ format = "0x%06x";
+ break;
+ case FT_UINT32:
+ format = "0x%08x";
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ ;
+ }
+ break;
+ case BASE_HEX_DEC:
+ switch(hfinfo->type) {
+ case FT_UINT8:
+ format = "0x%02x (%u)";
+ break;
+ case FT_UINT16:
+ format = "0x%04x (%u)";
+ break;
+ case FT_UINT24:
+ format = "0x%06x (%u)";
+ break;
+ case FT_UINT32:
+ format = "0x%08x (%u)";
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ ;
+ }
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ ;
+ }
+ }
+ return format;
+}
+
static const char*
hfinfo_int_vals_format(header_field_info *hfinfo)
{
return format;
}
+static const char*
+hfinfo_int_value_format(header_field_info *hfinfo)
+{
+ const char *format = NULL;
+
+ /* Pick the proper format string */
+ switch(hfinfo->display) {
+ case BASE_DEC:
+ format = "%d";
+ break;
+ case BASE_DEC_HEX:
+ switch(hfinfo->type) {
+ case FT_INT8:
+ format = "%d (0x%02x)";
+ break;
+ case FT_INT16:
+ format = "%d (0x%04x)";
+ break;
+ case FT_INT24:
+ format = "%d (0x%06x)";
+ break;
+ case FT_INT32:
+ format = "%d (0x%08x)";
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ ;
+ }
+ break;
+ case BASE_OCT:
+ format = "%o";
+ break;
+ case BASE_HEX:
+ switch(hfinfo->type) {
+ case FT_INT8:
+ format = "0x%02x";
+ break;
+ case FT_INT16:
+ format = "0x%04x";
+ break;
+ case FT_INT24:
+ format = "0x%06x";
+ break;
+ case FT_INT32:
+ format = "0x%08x";
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ ;
+ }
+ break;
+ case BASE_HEX_DEC:
+ switch(hfinfo->type) {
+ case FT_INT8:
+ format = "0x%02x (%d)";
+ break;
+ case FT_INT16:
+ format = "0x%04x (%d)";
+ break;
+ case FT_INT24:
+ format = "0x%06x (%d)";
+ break;
+ case FT_INT32:
+ format = "0x%08x (%d)";
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ ;
+ }
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ ;
+ }
+ return format;
+}
+
static const char*
hfinfo_int64_format(header_field_info *hfinfo)
{