summaryrefslogtreecommitdiff
path: root/wiretap/wtap_opttypes.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-06-05 18:04:23 -0700
committerGuy Harris <guy@alum.mit.edu>2016-06-06 01:04:55 +0000
commitf9be95c4c8ab3484e6cf396e0cf4242b18ff8841 (patch)
treede6b8561e7ed4519aab54e029fc15d84a5fb1885 /wiretap/wtap_opttypes.c
parentadee6850898a5469850a157c5816996691855ed2 (diff)
downloadwireshark-f9be95c4c8ab3484e6cf396e0cf4242b18ff8841.tar.gz
Add a routine to get an array of all instances of a string option.
Use it for OPT_COMMENT in the SHB, as there may be ore than one instance of OPT_COMMENT in an SHB. Also, use wtap_optionblock_get_option_string for OPT_SHB_HARDWARE, OPT_SHB_OS, and OPT_SHB_USERAPPL; they're specified as "only one instance allowed". Change-Id: I23ad87e41e40b7ae1155e96c0523a6f8caad5204 Reviewed-on: https://code.wireshark.org/review/15750 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/wtap_opttypes.c')
-rw-r--r--wiretap/wtap_opttypes.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/wiretap/wtap_opttypes.c b/wiretap/wtap_opttypes.c
index d87fd3b805..296a6fb29d 100644
--- a/wiretap/wtap_opttypes.c
+++ b/wiretap/wtap_opttypes.c
@@ -374,6 +374,36 @@ wtap_opttype_return_val wtap_optionblock_get_option_string(wtap_optionblock_t bl
return WTAP_OPTTYPE_SUCCESS;
}
+wtap_opttype_return_val wtap_optionblock_get_string_options(wtap_optionblock_t block, guint option_id, GArray **value)
+{
+ guint n_options;
+ guint i;
+ wtap_optblock_value_t* opt_value;
+ GArray *opt_values;
+
+ n_options = 0;
+ for (i = 0; i < block->option_values->len; i++)
+ {
+ opt_value = g_array_index(block->option_values, wtap_optblock_value_t*, i);
+ if (opt_value->info->number == option_id) {
+ if (opt_value->info->type != WTAP_OPTTYPE_STRING)
+ return WTAP_OPTTYPE_TYPE_MISMATCH;
+ n_options++;
+ }
+ }
+
+ opt_values = g_array_sized_new(FALSE, FALSE, sizeof (char *), n_options);
+ for (i = 0; i < block->option_values->len; i++)
+ {
+ opt_value = g_array_index(block->option_values, wtap_optblock_value_t*, i);
+ if (opt_value->info->number == option_id)
+ g_array_append_val(opt_values, opt_value->option.stringval);
+ }
+
+ *value = opt_values;
+ return WTAP_OPTTYPE_SUCCESS;
+}
+
wtap_opttype_return_val wtap_optionblock_set_option_uint64(wtap_optionblock_t block, guint option_id, guint64 value)
{
wtap_optblock_value_t* opt_value = wtap_optionblock_get_option(block, option_id);