aboutsummaryrefslogtreecommitdiffstats
path: root/extcap.c
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2018-03-02 15:41:00 +0100
committerRoland Knall <rknall@gmail.com>2018-04-05 09:31:23 +0000
commit6124ee2a1c06ccc96c3e9aa62c136f34085bfa61 (patch)
treea54fe1c4247e3f4519f71940d74c6a3f665d8a07 /extcap.c
parentc2422d78281e10beb6ce4ebda1d61c9d0ca63a09 (diff)
extcap: Reload values on request
Allow certaing elements to be reloaded upon request. The way this works is, certain elements can be configured to be reloadable. By doing so, the extcap is asked once more just for the values list of this item, together with all already set options, and reloads the available options depending on the response. Only supported for selector. Radio and Multiselect will need additional patches, also moving those parts outside of extcap_argument.cpp might make sense before hand. Change-Id: I2e9e3d109b334bf878835a7cc9354f468bc22dee Reviewed-on: https://code.wireshark.org/review/26223 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/extcap.c b/extcap.c
index df5c3a726c..a6a34544f2 100644
--- a/extcap.c
+++ b/extcap.c
@@ -807,6 +807,69 @@ extcap_get_if_configuration(const char *ifname)
return ret;
}
+static gboolean cb_reload_preference(extcap_callback_info_t cb_info)
+{
+ GList *arguments = NULL, * walker = NULL;
+ GList **il = (GList **) cb_info.data;
+
+ arguments = extcap_parse_values(cb_info.output);
+
+ walker = g_list_first((GList *)(arguments));
+ while (walker != NULL)
+ {
+ extcap_value * val = (extcap_value *)walker->data;
+ *il = g_list_append(*il, val);
+ walker = g_list_next(walker);
+ }
+ g_list_free(arguments);
+
+ /* By returning false, extcap_foreach will break on first found */
+ return FALSE;
+}
+
+GList *
+extcap_get_if_configuration_values(const char * ifname, const char * argname, GHashTable *arguments)
+{
+ GList * args = NULL;
+ GList *ret = NULL;
+ gchar **err_str = NULL;
+
+ if (extcap_if_exists(ifname))
+ {
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Extcap path %s",
+ get_extcap_dir());
+
+ args = g_list_append(args, g_strdup(EXTCAP_ARGUMENT_CONFIG) );
+ args = g_list_append(args, g_strdup(EXTCAP_ARGUMENT_INTERFACE) );
+ args = g_list_append(args, g_strdup(ifname) );
+ args = g_list_append(args, g_strdup(EXTCAP_ARGUMENT_RELOAD_OPTION) );
+ args = g_list_append(args, g_strdup(argname) );
+
+ if ( arguments )
+ {
+ GList * keys = g_hash_table_get_keys(arguments);
+ while ( keys )
+ {
+ const gchar * key_data = (const gchar *)keys->data;
+ args = g_list_append(args, g_strdup(key_data) );
+ args = g_list_append(args, g_strdup((const gchar *)g_hash_table_lookup(arguments, key_data)) );
+ keys = g_list_next(keys);
+ }
+ }
+
+ extcap_callback_info_t cb_info;
+ cb_info.data = &ret;
+ cb_info.err_str = err_str;
+ cb_info.ifname = ifname;
+
+ extcap_foreach(args, cb_reload_preference, cb_info);
+
+ g_list_free_full(args, g_free);
+ }
+
+ return ret;
+}
+
/**
* If is_required is FALSE: returns TRUE if the extcap interface has
* configurable options.