diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-02-26 17:04:05 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-02-27 01:04:33 +0000 |
commit | 842a9b510074c896e54735e2e3a575ea802f23ea (patch) | |
tree | e8243fc0a53911a9e8759d308a7cef3c4ec36438 | |
parent | 60f87ca919a6bfedfdb8b4728f7f221eb6b8af15 (diff) |
Replace extcap_interface_list() with append_extcap_interface_list().
Pull the "rebuild the list of extcap interfaces and, optionally, return
a list of if_infos for them" into a separate
extcap_reload_interface_list() routine, call it in the cases where we
don't want the if_infos list, and have append_extcap_interface_list()
call it, asking it for the if_infos list, and then append the interfaces
to that list.
Change-Id: I07478ab133859484b3e0916144971639f961224b
Reviewed-on: https://code.wireshark.org/review/14189
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | capchild/capture_ifinfo.c | 2 | ||||
-rw-r--r-- | extcap.c | 75 | ||||
-rw-r--r-- | extcap.h | 4 |
3 files changed, 43 insertions, 38 deletions
diff --git a/capchild/capture_ifinfo.c b/capchild/capture_ifinfo.c index 5c4f299415..3d848814d9 100644 --- a/capchild/capture_ifinfo.c +++ b/capchild/capture_ifinfo.c @@ -200,7 +200,7 @@ capture_interface_list(int *err, char **err_str, void (*update_cb)(void)) #ifdef HAVE_EXTCAP /* Add the extcap interfaces after the native and remote interfaces */ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Loading External Capture Interface List ..."); - extcap_interface_list(&if_list, err_str); + if_list = append_extcap_interface_list(if_list, err_str); #endif return if_list; @@ -117,6 +117,16 @@ extcap_if_add(const gchar *ifname, const gchar *extcap) } static void +extcap_free_info (gpointer data) { + extcap_info * info = (extcap_info *)data; + + g_free (info->basename); + g_free (info->full_path); + g_free (info->version); + g_free (info); +} + +static void extcap_tool_add(const gchar *extcap, const extcap_interface *interface) { char *toolname; @@ -369,31 +379,9 @@ if_info_compare(gconstpointer a, gconstpointer b) return comp; } -GHashTable * -extcap_tools_list(void) { - if ( tools == NULL || g_hash_table_size(tools) == 0 ) - extcap_interface_list(NULL, NULL); - - return tools; -} - static void -extcap_free_info (gpointer data) { - extcap_info * info = (extcap_info *)data; - - g_free (info->basename); - g_free (info->full_path); - g_free (info->version); - g_free (info); -} - -void -extcap_interface_list(GList **listp, char **err_str) { +extcap_reload_interface_list(GList **retp, char **err_str) { gchar *argv; - /* gint i; */ - GList *ret = NULL; - GList *entry; - void *data; if (err_str != NULL) *err_str = NULL; @@ -412,22 +400,39 @@ extcap_interface_list(GList **listp, char **err_str) { argv = g_strdup(EXTCAP_ARGUMENT_LIST_INTERFACES); - extcap_foreach(1, &argv, interfaces_cb, (listp != NULL) ? &ret : NULL, err_str, NULL); + extcap_foreach(1, &argv, interfaces_cb, retp, err_str, NULL); g_free(argv); +} + +GHashTable * +extcap_tools_list(void) { + if ( tools == NULL || g_hash_table_size(tools) == 0 ) + extcap_reload_interface_list(NULL, NULL); - if (listp != NULL) { - /* Sort the list */ - ret = g_list_sort(ret, if_info_compare); + return tools; +} - /* Append the interfaces to the list. */ - while (ret != NULL) { - entry = g_list_first(ret); - data = entry->data; - ret = g_list_delete_link(ret, entry); - *listp = g_list_append(*listp, data); - } +GList * +append_extcap_interface_list(GList *list, char **err_str) { + GList *ret = NULL; + GList *entry; + void *data; + + /* Update the extcap interfaces and get a list of their if_infos */ + extcap_reload_interface_list(&ret, err_str); + + /* Sort that list */ + ret = g_list_sort(ret, if_info_compare); + + /* Append the interfaces in that list to the list we're handed. */ + while (ret != NULL) { + entry = g_list_first(ret); + data = entry->data; + ret = g_list_delete_link(ret, entry); + list = g_list_append(list, data); } + return list; } static void extcap_free_arg_elem(gpointer data, gpointer user_data _U_) { @@ -445,7 +450,7 @@ void extcap_register_preferences(void) return; if ( ! ifaces || g_hash_table_size(ifaces) == 0 ) - extcap_interface_list(NULL, NULL); + extcap_reload_interface_list(NULL, NULL); interfaces = g_hash_table_get_keys(ifaces); @@ -72,8 +72,8 @@ if_capabilities_t * extcap_get_if_dlts(const gchar * ifname, char ** err_str); /* append a list of all extcap capture interfaces to the specified list */ -void -extcap_interface_list(GList **listp, char **err_str); +GList * +append_extcap_interface_list(GList *list, char **err_str); /* get a list of all available extcap tools */ GHashTable * |