summaryrefslogtreecommitdiff
path: root/epan/ftypes
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-04-12 15:26:34 -0700
committerGuy Harris <guy@alum.mit.edu>2014-04-12 22:27:22 +0000
commitcb16dff992c3844936bf5829f19e5a5247458503 (patch)
tree901b7be3379f5b94f150de71d1c0f3e2fa2d12e4 /epan/ftypes
parentef8a0a2ce172810d48371eb65c73b1bd4a6303ca (diff)
downloadwireshark-cb16dff992c3844936bf5829f19e5a5247458503.tar.gz
Get rid of more tvb_get_nstringz* calls.
Add an FT_STRINGZPAD type, for null-padded strings (typically fixed-length fields, where the string can be up to the length of the field, and is null-padded if it's shorter than that), and use it. Use IS_FT_STRING() in more cases, so that less code needs to know what types are string types. Add a tvb_get_stringzpad() routine, which gets null-padded strings. Currently, it does the same thing that tvb_get_string_enc() does, but that might change if we don't store string values as null-terminated strings. Change-Id: I46f56e130de8f419a19b56ded914e24cc7518a66 Reviewed-on: https://code.wireshark.org/review/1082 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/ftypes')
-rw-r--r--epan/ftypes/ftype-string.c43
-rw-r--r--epan/ftypes/ftypes.h3
2 files changed, 45 insertions, 1 deletions
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c
index b2e0c63ef0..3893823b28 100644
--- a/epan/ftypes/ftype-string.c
+++ b/epan/ftypes/ftype-string.c
@@ -356,8 +356,51 @@ ftype_register_string(void)
len,
slice,
};
+ static ftype_t stringzpad_type = {
+ FT_STRINGZPAD, /* ftype */
+ "FT_STRINGZPAD", /* name */
+ "Character string", /* pretty name */
+ 0, /* wire_size */
+ string_fvalue_new, /* new_value */
+ string_fvalue_free, /* free_value */
+ val_from_unparsed, /* val_from_unparsed */
+ val_from_string, /* val_from_string */
+ string_to_repr, /* val_to_string_repr */
+ string_repr_len, /* len_string_repr */
+
+ NULL, /* set_value_byte_array */
+ NULL, /* set_value_bytes */
+ NULL, /* set_value_guid */
+ NULL, /* set_value_time */
+ string_fvalue_set_string, /* set_value_string */
+ NULL, /* set_value_tvbuff */
+ NULL, /* set_value_uinteger */
+ NULL, /* set_value_sinteger */
+ NULL, /* set_value_integer64 */
+ NULL, /* set_value_floating */
+
+ value_get, /* get_value */
+ NULL, /* get_value_uinteger */
+ NULL, /* get_value_sinteger */
+ NULL, /* get_value_integer64 */
+ NULL, /* get_value_floating */
+
+ cmp_eq,
+ cmp_ne,
+ cmp_gt,
+ cmp_ge,
+ cmp_lt,
+ cmp_le,
+ NULL, /* cmp_bitwise_and */
+ cmp_contains, /* cmp_contains */
+ CMP_MATCHES,
+
+ len,
+ slice,
+ };
ftype_register(FT_STRING, &string_type);
ftype_register(FT_STRINGZ, &stringz_type);
ftype_register(FT_UINT_STRING, &uint_string_type);
+ ftype_register(FT_STRINGZPAD, &stringzpad_type);
}
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index 1e238838b2..53042778f2 100644
--- a/epan/ftypes/ftypes.h
+++ b/epan/ftypes/ftypes.h
@@ -68,13 +68,14 @@ enum ftenum {
FT_VINES,
FT_REL_OID, /* RELATIVE-OID */
FT_SYSTEM_ID,
+ FT_STRINGZPAD, /* for use with proto_tree_add_item() */
FT_NUM_TYPES /* last item number plus one */
};
#define IS_FT_INT(ft) ((ft)==FT_INT8||(ft)==FT_INT16||(ft)==FT_INT24||(ft)==FT_INT32||(ft)==FT_INT64)
#define IS_FT_UINT(ft) ((ft)==FT_UINT8||(ft)==FT_UINT16||(ft)==FT_UINT24||(ft)==FT_UINT32||(ft)==FT_UINT64||(ft)==FT_FRAMENUM)
#define IS_FT_TIME(ft) ((ft)==FT_ABSOLUTE_TIME||(ft)==FT_RELATIVE_TIME)
-#define IS_FT_STRING(ft) ((ft)==FT_STRING||(ft)==FT_STRINGZ)
+#define IS_FT_STRING(ft) ((ft)==FT_STRING||(ft)==FT_STRINGZ||(ft)==FT_STRINGZPAD)
/* field types lengths */
#define FT_ETHER_LEN 6