#include "capture_opts.h"
-#ifdef HAVE_EXTCAP
-
#include "extcap.h"
#include "extcap_parser.h"
g_hash_table_insert(ifaces, g_strdup(ifname), g_strdup(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)
{
&command_output, NULL, &exit_status, NULL);
if (status && exit_status == 0)
- keep_going = cb(extcap_path->str, ifname, command_output, cb_data, err_str);
+ keep_going = cb(extcap_path->str, ifname, command_output, cb_data, err_str);
g_free(argv[0]);
g_free(command_output);
gint i;
if_capabilities_t *caps = NULL;
- if (ifname != NULL && err_str != NULL)
+ if (err_str != NULL)
*err_str = NULL;
if ( extcap_if_exists(ifname) )
argv[1] = g_strdup(EXTCAP_ARGUMENT_INTERFACE);
argv[2] = g_strdup(ifname);
- if (err_str)
- *err_str = NULL;
extcap_foreach(3, argv, dlt_cb, &caps, err_str, ifname);
for (i = 0; i < 3; ++i)
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, " Extcap [%s] ", int_iter->call);
if ( int_iter->if_type == EXTCAP_SENTENCE_INTERFACE ) {
- if_info = g_new0(if_info_t, 1);
- if_info->name = g_strdup(int_iter->call);
- if_info->friendly_name = g_strdup(int_iter->display);
+ if (il != NULL) {
+ if_info = g_new0(if_info_t, 1);
+ if_info->name = g_strdup(int_iter->call);
+ if_info->friendly_name = g_strdup(int_iter->display);
- if_info->type = IF_EXTCAP;
+ if_info->type = IF_EXTCAP;
- if_info->extcap = g_strdup(extcap);
- *il = g_list_append(*il, if_info);
+ if_info->extcap = g_strdup(extcap);
+ *il = g_list_append(*il, if_info);
+ }
extcap_if_add(int_iter->call, extcap);
}
if_info_compare(gconstpointer a, gconstpointer b)
{
gint comp = 0;
- if_info_t * if_a = (if_info_t *)a;
- if_info_t * if_b = (if_info_t *)b;
+ const if_info_t * if_a = (const if_info_t *)a;
+ const if_info_t * if_b = (const if_info_t *)b;
if ( (comp = g_strcmp0(if_a->name, if_b->name)) == 0 )
return g_strcmp0(if_a->friendly_name, if_b->friendly_name);
return comp;
}
-GHashTable *
-extcap_tools_list(void) {
- if ( tools == NULL || g_hash_table_size(tools) == 0 )
- extcap_interface_list(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);
-}
-
-GList *
-extcap_interface_list(char **err_str) {
+extcap_reload_interface_list(GList **retp, char **err_str) {
gchar *argv;
- /* gint i; */
- GList *ret = NULL;
if (err_str != NULL)
- *err_str = NULL;
+ *err_str = NULL;
/* ifaces is used as cache, do not destroy its contents when
* returning or no extcap interfaces can be queried for options */
argv = g_strdup(EXTCAP_ARGUMENT_LIST_INTERFACES);
- if (err_str)
- *err_str = NULL;
- extcap_foreach(1, &argv, interfaces_cb, &ret, err_str, NULL);
+ extcap_foreach(1, &argv, interfaces_cb, retp, err_str, NULL);
g_free(argv);
+}
- return g_list_sort ( ret, if_info_compare );
+GHashTable *
+extcap_tools_list(void) {
+ if ( tools == NULL || g_hash_table_size(tools) == 0 )
+ extcap_reload_interface_list(NULL, NULL);
+
+ return tools;
+}
+
+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_) {
return;
if ( ! ifaces || g_hash_table_size(ifaces) == 0 )
- extcap_interface_list(NULL);
+ extcap_reload_interface_list(NULL, NULL);
interfaces = g_hash_table_get_keys(ifaces);
arg->storeval = g_strdup(arg->default_complex->_val);
prefs_register_string_preference(dev_module, g_strdup(pref_ifname),
- arg->display, arg->display, (const gchar **)&(arg->storeval));
+ arg->display, arg->display, (const gchar **)(void*)(&arg->storeval));
} else {
/* Been here before, restore stored value */
if (! arg->storeval && pref->varp.string)
gchar *temp_name = NULL;
int fd = 0;
- if ((fd = create_tempfile(&temp_name, EXTCAP_PIPE_PREFIX)) < 0 )
+ if ((fd = create_tempfile(&temp_name, EXTCAP_PIPE_PREFIX, NULL)) < 0 )
return FALSE;
ws_close(fd);
}
}
#endif
-#endif
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html