diff options
Diffstat (limited to 'epan/ftypes/ftype-guid.c')
-rw-r--r-- | epan/ftypes/ftype-guid.c | 92 |
1 files changed, 62 insertions, 30 deletions
diff --git a/epan/ftypes/ftype-guid.c b/epan/ftypes/ftype-guid.c index 648757b161..3b7a18d47a 100644 --- a/epan/ftypes/ftype-guid.c +++ b/epan/ftypes/ftype-guid.c @@ -21,13 +21,13 @@ guid_fvalue_set_guid(fvalue_t *fv, const e_guid_t *value) fv->value.guid = *value; } -static gpointer +static const e_guid_t * value_get(fvalue_t *fv) { return &(fv->value.guid); } -static gboolean +static bool get_guid(const char *s, e_guid_t *guid) { size_t i, n; @@ -38,65 +38,66 @@ get_guid(const char *s, e_guid_t *guid) n = strnlen(s, fmtchars); if (n != fmtchars) - return FALSE; + return false; for (i=0; i<n; i++) { if (fmt[i] == 'X') { if (!g_ascii_isxdigit(s[i])) - return FALSE; + return false; } else { if (s[i] != fmt[i]) - return FALSE; + return false; } } p = s; - guid->data1 = (guint32)strtoul(p, NULL, 16); + guid->data1 = (uint32_t)strtoul(p, NULL, 16); p += 9; - guid->data2 = (guint16)strtoul(p, NULL, 16); + guid->data2 = (uint16_t)strtoul(p, NULL, 16); p += 5; - guid->data3 = (guint16)strtoul(p, NULL, 16); + guid->data3 = (uint16_t)strtoul(p, NULL, 16); p += 5; for (i=0; i < sizeof(guid->data4); i++) { if (*p == '-') p++; digits[0] = *(p++); digits[1] = *(p++); digits[2] = '\0'; - guid->data4[i] = (guint8)strtoul(digits, NULL, 16); + guid->data4[i] = (uint8_t)strtoul(digits, NULL, 16); } - return TRUE; + return true; } -static gboolean -guid_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, gchar **err_msg) +static bool +guid_from_literal(fvalue_t *fv, const char *s, bool allow_partial_value _U_, char **err_msg) { e_guid_t guid; if (!get_guid(s, &guid)) { if (err_msg != NULL) - *err_msg = g_strdup_printf("\"%s\" is not a valid GUID.", s); - return FALSE; + *err_msg = ws_strdup_printf("\"%s\" is not a valid GUID.", s); + return false; } fv->value.guid = guid; - return TRUE; + return true; } -static int -guid_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_) +static char * +guid_to_repr(wmem_allocator_t *scope, const fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_) { - return GUID_STR_LEN; + return guid_to_str(scope, &fv->value.guid); } -static void -guid_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf, unsigned int size) +static enum ft_result +cmp_order(const fvalue_t *a, const fvalue_t *b, int *cmp) { - guid_to_str_buf(&fv->value.guid, buf, size); + *cmp = memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)); + return FT_OK; } -static int -cmp_order(const fvalue_t *a, const fvalue_t *b) +static unsigned +value_hash(const fvalue_t *fv) { - return memcmp(&a->value.guid, &b->value.guid, sizeof(e_guid_t)); + return guid_hash(&fv->value.guid); } void @@ -105,31 +106,62 @@ ftype_register_guid(void) static ftype_t guid_type = { FT_GUID, /* ftype */ - "FT_GUID", /* name */ - "Globally Unique Identifier", /* pretty_name */ GUID_LEN, /* wire_size */ NULL, /* new_value */ + NULL, /* copy_value */ NULL, /* free_value */ - guid_from_unparsed, /* val_from_unparsed */ + guid_from_literal, /* val_from_literal */ NULL, /* val_from_string */ + NULL, /* val_from_charconst */ + NULL, /* val_from_uinteger64 */ + NULL, /* val_from_sinteger64 */ + NULL, /* val_from_double */ guid_to_repr, /* val_to_string_repr */ - guid_repr_len, /* len_string_repr */ + + NULL, /* val_to_uinteger64 */ + NULL, /* val_to_sinteger64 */ + NULL, /* val_to_double */ { .set_value_guid = guid_fvalue_set_guid }, /* union set_value */ - { .get_value_ptr = value_get }, /* union get_value */ + { .get_value_guid = value_get }, /* union get_value */ cmp_order, NULL, - NULL, NULL, /* cmp_matches */ + value_hash, /* hash */ + NULL, + NULL, + NULL, NULL, NULL, + NULL, /* unary_minus */ + NULL, /* add */ + NULL, /* subtract */ + NULL, /* multiply */ + NULL, /* divide */ + NULL, /* modulo */ }; ftype_register(FT_GUID, &guid_type); } +void +ftype_register_pseudofields_guid(int proto) +{ + static int hf_ft_guid; + + static hf_register_info hf_ftypes[] = { + { &hf_ft_guid, + { "FT_GUID", "_ws.ftypes.guid", + FT_GUID, BASE_NONE, NULL, 0x00, + NULL, HFILL } + }, + }; + + proto_register_field_array(proto, hf_ftypes, array_length(hf_ftypes)); +} + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * |