diff options
author | Peter Wu <peter@lekensteyn.nl> | 2017-03-04 01:40:51 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2017-03-08 23:04:12 +0000 |
commit | 540b5557291ad0960ce566adc3f24100aac946de (patch) | |
tree | 6c5aac3a5e7cce9c17f12980a6d22c0007375f15 /epan/value_string.h | |
parent | 2b06c17592e792224779355c2e47d776ba2f9af6 (diff) |
Introduce "bytes_string" type, similar to "value_string"
In order to map arbitrary byte buffers to strings, introduce a new
"bytes_string" type. Since "bytes_to_str" is already used for other
purposes, name the generic function "bytesval_to_str" instead similar to
the name( "val_to_str").
Accept "size_t" as length parameter since this is what is returned by
the "sizeof" operator. Do not add a "try_bytesval_to_str_idx" variant
since this pattern is not needed for now. Add a variant to match the
prefix since this is currently expected by the ISAKMP dissector.
Change-Id: I6d790325e85d9fb1384330f28a8c36e2057fdf30
Reviewed-on: https://code.wireshark.org/review/20386
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/value_string.h')
-rw-r--r-- | epan/value_string.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/epan/value_string.h b/epan/value_string.h index 90b40f51b0..92d24deb97 100644 --- a/epan/value_string.h +++ b/epan/value_string.h @@ -274,6 +274,32 @@ WS_DLL_PUBLIC const gchar * try_rval64_to_str_idx(const guint64 val, const range_string *rs, gint *idx); +/* BYTES TO STRING MATCHING */ + +typedef struct _bytes_string { + const guint8 *value; + const size_t value_length; + const gchar *strptr; +} bytes_string; + +WS_DLL_PUBLIC +const gchar * +bytesval_to_str(const guint8 *val, const size_t val_len, const bytes_string *bs, const char *fmt) +G_GNUC_PRINTF(4, 0); + +WS_DLL_PUBLIC +const gchar * +try_bytesval_to_str(const guint8 *val, const size_t val_len, const bytes_string *bs); + +WS_DLL_PUBLIC +const gchar * +bytesprefix_to_str(const guint8 *prefix, const size_t prefix_len, const bytes_string *bs, const char *fmt) +G_GNUC_PRINTF(4, 0); + +WS_DLL_PUBLIC +const gchar * +try_bytesprefix_to_str(const guint8 *prefix, const size_t prefix_len, const bytes_string *bs); + /* MISC (generally do not use) */ WS_DLL_LOCAL |