2014-02-25 13:05:11 +00:00
|
|
|
/* extcap.h
|
|
|
|
*
|
|
|
|
* Routines for extcap external capture
|
|
|
|
* Copyright 2013, Mike Ryan <mikeryan@lacklustre.net>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2014-08-22 21:13:05 +00:00
|
|
|
#include <config.h>
|
2014-02-25 13:05:11 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2014-02-25 13:05:11 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <process.h>
|
|
|
|
#include <time.h>
|
|
|
|
#else
|
|
|
|
/* Include for unlink */
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <log.h>
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
#include <epan/prefs.h>
|
|
|
|
#include <epan/prefs-int.h>
|
|
|
|
|
2014-02-25 13:05:11 +00:00
|
|
|
#include <wsutil/file_util.h>
|
|
|
|
#include <wsutil/filesystem.h>
|
|
|
|
#include <wsutil/tempfile.h>
|
|
|
|
|
|
|
|
#include "capture_opts.h"
|
|
|
|
|
|
|
|
#include "extcap.h"
|
|
|
|
#include "extcap_parser.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
static HANDLE pipe_h = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* internal container, for all the extcap interfaces that have been found.
|
|
|
|
* will be resetted by every call to extcap_interface_list() and is being
|
2016-01-12 09:47:19 +00:00
|
|
|
* used in extcap_get_if_* as well as extcap_init_interfaces to ensure,
|
2014-02-25 13:05:11 +00:00
|
|
|
* that only extcap interfaces are being given to underlying extcap programs
|
|
|
|
*/
|
|
|
|
static GHashTable *ifaces = NULL;
|
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
/* internal container, for all the extcap executables that have been found.
|
|
|
|
* will be resetted by every call to extcap_interface_list() and is being
|
|
|
|
* used for printing information about all extcap interfaces found
|
|
|
|
*/
|
|
|
|
static GHashTable *tools = NULL;
|
|
|
|
|
2014-02-25 13:05:11 +00:00
|
|
|
/* Callback definition for extcap_foreach */
|
2015-12-29 06:57:36 +00:00
|
|
|
typedef gboolean (*extcap_cb_t)(const gchar *extcap, const gchar *ifname, gchar *output, void *data,
|
2014-10-06 18:03:47 +00:00
|
|
|
gchar **err_str);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
|
|
|
/* #define ARG_DEBUG */
|
|
|
|
#if ARG_DEBUG
|
|
|
|
static void extcap_debug_arguments ( extcap_arg *arg_iter );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static gboolean
|
2016-01-15 12:00:09 +00:00
|
|
|
extcap_if_exists(const gchar *ifname)
|
2014-02-25 13:05:11 +00:00
|
|
|
{
|
2016-01-15 12:00:09 +00:00
|
|
|
if ( !ifname || !ifaces )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ( g_hash_table_lookup(ifaces, ifname) )
|
|
|
|
return TRUE;
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return FALSE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-01-15 12:00:09 +00:00
|
|
|
extcap_if_exists_for_extcap(const gchar *ifname, const gchar *extcap)
|
2014-02-25 13:05:11 +00:00
|
|
|
{
|
2016-01-15 12:00:09 +00:00
|
|
|
gchar *entry = (gchar *)g_hash_table_lookup(ifaces, ifname);
|
2014-10-06 18:03:47 +00:00
|
|
|
|
2016-01-15 12:00:09 +00:00
|
|
|
if ( entry && strcmp(entry, extcap) == 0 )
|
|
|
|
return TRUE;
|
2014-10-06 18:03:47 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2016-01-15 12:00:09 +00:00
|
|
|
extcap_if_executable(const gchar *ifname)
|
2014-02-25 13:05:11 +00:00
|
|
|
{
|
2016-01-15 12:00:09 +00:00
|
|
|
return (gchar *)g_hash_table_lookup(ifaces, ifname);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-01-15 12:00:09 +00:00
|
|
|
extcap_if_add(const gchar *ifname, const gchar *extcap)
|
2014-02-25 13:05:11 +00:00
|
|
|
{
|
2016-01-15 12:00:09 +00:00
|
|
|
if ( !g_hash_table_lookup(ifaces, ifname) )
|
|
|
|
g_hash_table_insert(ifaces, g_strdup(ifname), g_strdup(extcap));
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2016-02-27 01:04:05 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
static void
|
2016-01-15 12:00:09 +00:00
|
|
|
extcap_tool_add(const gchar *extcap, const extcap_interface *interface)
|
2016-01-12 12:45:20 +00:00
|
|
|
{
|
2016-01-15 12:00:09 +00:00
|
|
|
char *toolname;
|
2016-01-12 12:45:20 +00:00
|
|
|
|
2016-01-15 12:00:09 +00:00
|
|
|
if ( !extcap || !interface )
|
2016-01-12 12:45:20 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
toolname = g_path_get_basename(extcap);
|
|
|
|
|
2016-01-15 12:00:09 +00:00
|
|
|
if ( !g_hash_table_lookup(tools, toolname) ) {
|
2016-01-12 12:45:20 +00:00
|
|
|
extcap_info * store = (extcap_info *)g_new0(extcap_info, 1);
|
2016-01-15 12:00:09 +00:00
|
|
|
store->version = g_strdup(interface->version);
|
|
|
|
store->full_path = g_strdup(extcap);
|
|
|
|
store->basename = g_strdup(toolname);
|
2016-01-12 12:45:20 +00:00
|
|
|
|
|
|
|
g_hash_table_insert(tools, g_strdup(toolname), store);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free(toolname);
|
|
|
|
}
|
|
|
|
|
2015-12-11 10:42:28 +00:00
|
|
|
/* Note: args does not need to be NULL-terminated. */
|
2014-02-25 13:05:11 +00:00
|
|
|
static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb,
|
2014-10-06 18:03:47 +00:00
|
|
|
void *cb_data, char **err_str, const char * ifname _U_) {
|
|
|
|
const char *dirname = get_extcap_dir();
|
|
|
|
GDir *dir;
|
|
|
|
const gchar *file;
|
|
|
|
gboolean keep_going;
|
2015-12-11 10:42:28 +00:00
|
|
|
gint i;
|
2014-10-06 18:03:47 +00:00
|
|
|
gchar **argv;
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2015-04-14 00:11:15 +00:00
|
|
|
gchar **dll_search_envp;
|
|
|
|
gchar *progfile_dir;
|
|
|
|
#endif
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
keep_going = TRUE;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
argv = (gchar **) g_malloc0(sizeof(gchar *) * (argc + 2));
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2015-04-14 00:11:15 +00:00
|
|
|
/*
|
|
|
|
* Make sure executables can find dependent DLLs and that they're *our*
|
|
|
|
* DLLs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586.aspx
|
|
|
|
* Alternatively we could create a simple wrapper exe similar to Create
|
|
|
|
* Hidden Process (http://www.commandline.co.uk/chp/).
|
|
|
|
*/
|
|
|
|
dll_search_envp = g_get_environ();
|
|
|
|
progfile_dir = g_strdup_printf("%s;%s", get_progfile_dir(), g_environ_getenv(dll_search_envp, "Path"));
|
|
|
|
dll_search_envp = g_environ_setenv(dll_search_envp, "Path", progfile_dir, TRUE);
|
|
|
|
g_free(progfile_dir);
|
|
|
|
#endif
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ((dir = g_dir_open(dirname, 0, NULL)) != NULL) {
|
2015-12-11 10:42:28 +00:00
|
|
|
GString *extcap_path = NULL;
|
|
|
|
|
|
|
|
extcap_path = g_string_new("");
|
2014-10-06 18:03:47 +00:00
|
|
|
while (keep_going && (file = g_dir_read_name(dir)) != NULL ) {
|
|
|
|
gchar *command_output = NULL;
|
|
|
|
gboolean status = FALSE;
|
|
|
|
gint exit_status = 0;
|
2015-04-14 00:11:15 +00:00
|
|
|
gchar **envp = NULL;
|
2014-10-06 18:03:47 +00:00
|
|
|
|
|
|
|
/* full path to extcap binary */
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2015-12-11 10:42:28 +00:00
|
|
|
g_string_printf(extcap_path, "%s\\%s", dirname, file);
|
2015-04-14 00:11:15 +00:00
|
|
|
envp = dll_search_envp;
|
2014-02-25 13:05:11 +00:00
|
|
|
#else
|
2015-12-11 10:42:28 +00:00
|
|
|
g_string_printf(extcap_path, "%s/%s", dirname, file);
|
2014-02-25 13:05:11 +00:00
|
|
|
#endif
|
2015-12-11 10:42:28 +00:00
|
|
|
if ( extcap_if_exists(ifname) && !extcap_if_exists_for_extcap(ifname, extcap_path->str ) )
|
2014-10-06 18:03:47 +00:00
|
|
|
continue;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2015-12-11 10:42:28 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
argv[0] = g_strescape(extcap_path->str, NULL);
|
|
|
|
#else
|
|
|
|
argv[0] = g_strdup(extcap_path->str);
|
|
|
|
#endif
|
2014-10-06 18:03:47 +00:00
|
|
|
for (i = 0; i < argc; ++i)
|
|
|
|
argv[i+1] = args[i];
|
|
|
|
argv[argc+1] = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2015-04-14 00:11:15 +00:00
|
|
|
status = g_spawn_sync(dirname, argv, envp,
|
2014-10-06 18:03:47 +00:00
|
|
|
(GSpawnFlags) 0, NULL, NULL,
|
2016-01-31 19:55:55 +00:00
|
|
|
&command_output, NULL, &exit_status, NULL);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (status && exit_status == 0)
|
2015-11-24 22:03:13 +00:00
|
|
|
keep_going = cb(extcap_path->str, ifname, command_output, cb_data, err_str);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2015-12-11 10:42:28 +00:00
|
|
|
g_free(argv[0]);
|
2014-10-06 18:03:47 +00:00
|
|
|
g_free(command_output);
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_dir_close(dir);
|
2015-12-11 10:42:28 +00:00
|
|
|
g_string_free(extcap_path, TRUE);
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2015-04-14 00:11:15 +00:00
|
|
|
g_strfreev(dll_search_envp);
|
|
|
|
#endif
|
2014-10-06 18:03:47 +00:00
|
|
|
g_free(argv);
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
static gboolean dlt_cb(const gchar *extcap _U_, const gchar *ifname _U_, gchar *output, void *data,
|
2014-10-06 18:03:47 +00:00
|
|
|
char **err_str) {
|
|
|
|
extcap_token_sentence *tokens;
|
|
|
|
extcap_dlt *dlts, *dlt_iter, *next;
|
|
|
|
if_capabilities_t *caps;
|
|
|
|
GList *linktype_list = NULL;
|
|
|
|
data_link_info_t *data_link_info;
|
|
|
|
|
|
|
|
tokens = extcap_tokenize_sentences(output);
|
|
|
|
extcap_parse_dlts(tokens, &dlts);
|
|
|
|
|
|
|
|
extcap_free_tokenized_sentence_list(tokens);
|
|
|
|
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Extcap pipe %s ", extcap);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the interface capabilities structure.
|
|
|
|
*/
|
|
|
|
caps = (if_capabilities_t *) g_malloc(sizeof *caps);
|
|
|
|
caps->can_set_rfmon = FALSE;
|
|
|
|
|
|
|
|
dlt_iter = dlts;
|
|
|
|
while (dlt_iter != NULL ) {
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
|
|
|
|
" DLT %d name=\"%s\" display=\"%s\" ", dlt_iter->number,
|
|
|
|
dlt_iter->name, dlt_iter->display);
|
|
|
|
|
|
|
|
data_link_info = g_new(data_link_info_t, 1);
|
|
|
|
data_link_info->dlt = dlt_iter->number;
|
|
|
|
data_link_info->name = g_strdup(dlt_iter->name);
|
|
|
|
data_link_info->description = g_strdup(dlt_iter->display);
|
|
|
|
linktype_list = g_list_append(linktype_list, data_link_info);
|
|
|
|
dlt_iter = dlt_iter->next_dlt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check to see if we built a list */
|
|
|
|
if (linktype_list != NULL && data != NULL) {
|
|
|
|
caps->data_link_types = linktype_list;
|
|
|
|
*(if_capabilities_t **) data = caps;
|
|
|
|
} else {
|
|
|
|
if (err_str) {
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, " returned no DLTs");
|
|
|
|
*err_str = g_strdup("Extcap returned no DLTs");
|
|
|
|
}
|
|
|
|
g_free(caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
dlt_iter = dlts;
|
|
|
|
while (dlt_iter != NULL ) {
|
|
|
|
next = dlt_iter->next_dlt;
|
|
|
|
extcap_free_dlt(dlt_iter);
|
|
|
|
dlt_iter = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if_capabilities_t *
|
|
|
|
extcap_get_if_dlts(const gchar *ifname, char **err_str) {
|
2014-10-06 18:03:47 +00:00
|
|
|
gchar *argv[3];
|
|
|
|
gint i;
|
|
|
|
if_capabilities_t *caps = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-02-26 23:18:18 +00:00
|
|
|
if (err_str != NULL)
|
2014-10-06 18:03:47 +00:00
|
|
|
*err_str = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ( extcap_if_exists(ifname) )
|
|
|
|
{
|
|
|
|
argv[0] = g_strdup(EXTCAP_ARGUMENT_LIST_DLTS);
|
|
|
|
argv[1] = g_strdup(EXTCAP_ARGUMENT_INTERFACE);
|
|
|
|
argv[2] = g_strdup(ifname);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_foreach(3, argv, dlt_cb, &caps, err_str, ifname);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
for (i = 0; i < 3; ++i)
|
|
|
|
g_free(argv[i]);
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return caps;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
static gboolean interfaces_cb(const gchar *extcap, const gchar *ifname _U_, gchar *output, void *data,
|
2014-10-06 18:03:47 +00:00
|
|
|
char **err_str _U_) {
|
|
|
|
GList **il = (GList **) data;
|
|
|
|
extcap_token_sentence *tokens;
|
|
|
|
extcap_interface *interfaces, *int_iter; /*, *next; */
|
|
|
|
if_info_t *if_info;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
tokens = extcap_tokenize_sentences(output);
|
|
|
|
extcap_parse_interfaces(tokens, &interfaces);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_free_tokenized_sentence_list(tokens);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Extcap pipe %s ", extcap);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
int_iter = interfaces;
|
|
|
|
while (int_iter != NULL ) {
|
2016-01-12 12:45:20 +00:00
|
|
|
if ( int_iter->if_type == EXTCAP_SENTENCE_INTERFACE && extcap_if_exists(int_iter->call) )
|
2014-10-06 18:03:47 +00:00
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_WARNING, "Extcap interface \"%s\" is already provided by \"%s\" ",
|
|
|
|
int_iter->call, (gchar *)extcap_if_executable(int_iter->call) );
|
|
|
|
int_iter = int_iter->next_interface;
|
|
|
|
continue;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
if ( int_iter->if_type == EXTCAP_SENTENCE_INTERFACE )
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, " Interface [%s] \"%s\" ",
|
|
|
|
int_iter->call, int_iter->display);
|
|
|
|
else if ( int_iter->if_type == EXTCAP_SENTENCE_EXTCAP )
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, " Extcap [%s] ", int_iter->call);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
if ( int_iter->if_type == EXTCAP_SENTENCE_INTERFACE ) {
|
2016-02-27 00:35:17 +00:00
|
|
|
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);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-02-27 00:35:17 +00:00
|
|
|
if_info->type = IF_EXTCAP;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-02-27 00:35:17 +00:00
|
|
|
if_info->extcap = g_strdup(extcap);
|
|
|
|
*il = g_list_append(*il, if_info);
|
|
|
|
}
|
2016-01-12 12:45:20 +00:00
|
|
|
|
2016-01-15 12:00:09 +00:00
|
|
|
extcap_if_add(int_iter->call, extcap);
|
2016-01-12 12:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Call for interfaces and tools alike. Multiple calls (because a tool has multiple
|
|
|
|
* interfaces) are handled internally */
|
2016-01-15 12:00:09 +00:00
|
|
|
extcap_tool_add(extcap, int_iter);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
int_iter = int_iter->next_interface;
|
|
|
|
}
|
2015-12-11 10:42:28 +00:00
|
|
|
extcap_free_interface(interfaces);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return TRUE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2016-01-12 09:47:19 +00:00
|
|
|
static gint
|
|
|
|
if_info_compare(gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
gint comp = 0;
|
2016-04-06 13:04:53 +00:00
|
|
|
const if_info_t * if_a = (const if_info_t *)a;
|
|
|
|
const if_info_t * if_b = (const if_info_t *)b;
|
2016-01-12 09:47:19 +00:00
|
|
|
|
|
|
|
if ( (comp = g_strcmp0(if_a->name, if_b->name)) == 0 )
|
|
|
|
return g_strcmp0(if_a->friendly_name, if_b->friendly_name);
|
|
|
|
|
|
|
|
return comp;
|
|
|
|
}
|
|
|
|
|
2016-01-12 12:45:20 +00:00
|
|
|
static void
|
2016-02-27 01:04:05 +00:00
|
|
|
extcap_reload_interface_list(GList **retp, char **err_str) {
|
2014-10-06 18:03:47 +00:00
|
|
|
gchar *argv;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (err_str != NULL)
|
2016-02-26 22:56:01 +00:00
|
|
|
*err_str = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2015-12-11 10:42:28 +00:00
|
|
|
/* ifaces is used as cache, do not destroy its contents when
|
|
|
|
* returning or no extcap interfaces can be queried for options */
|
2016-01-12 12:45:20 +00:00
|
|
|
if (ifaces == NULL)
|
|
|
|
ifaces = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
|
|
|
else
|
|
|
|
g_hash_table_remove_all(ifaces);
|
|
|
|
|
|
|
|
if (tools == NULL)
|
|
|
|
tools = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, extcap_free_info);
|
|
|
|
else
|
|
|
|
g_hash_table_remove_all(tools);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
argv = g_strdup(EXTCAP_ARGUMENT_LIST_INTERFACES);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-02-27 01:04:05 +00:00
|
|
|
extcap_foreach(1, &argv, interfaces_cb, retp, err_str, NULL);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_free(argv);
|
2016-02-27 01:04:05 +00:00
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2016-02-27 01:04:05 +00:00
|
|
|
GHashTable *
|
|
|
|
extcap_tools_list(void) {
|
|
|
|
if ( tools == NULL || g_hash_table_size(tools) == 0 )
|
|
|
|
extcap_reload_interface_list(NULL, NULL);
|
2016-02-27 00:35:17 +00:00
|
|
|
|
2016-02-27 01:04:05 +00:00
|
|
|
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);
|
2016-02-27 00:35:17 +00:00
|
|
|
}
|
2016-02-27 01:04:05 +00:00
|
|
|
return list;
|
2014-10-13 16:08:43 +00:00
|
|
|
}
|
|
|
|
|
Fix memleaks on interface refresh when extcap configs exists
If there are extcap interfaces present then each time the capture
interfaces list is displayed or refreshed a number of extcap related
allocations are leaked.
Valgrind reports leaks like these:
2,007 (144 direct, 1,863 indirect) bytes in 6 blocks are definitely lost in loss record 64,328 of 65,138
at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0x44C9AF: search_cb (extcap.c:451)
by 0x44C6FC: extcap_foreach (extcap.c:204)
by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
by 0x44CE3C: extcap_has_configuration (extcap.c:489)
by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
by 0x6547DF: InterfaceTree::getInterfaceList() (interface_tree.cpp:252)
by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
by 0x563F9A: WiresharkApplication::allSystemsGo() (wireshark_application.cpp:914)
by 0x4478D9: main (wireshark-qt.cpp:1373)
9,126 (432 direct, 8,694 indirect) bytes in 18 blocks are definitely lost in loss record 58,524 of 58,638
at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0x44C9AF: search_cb (extcap.c:451)
by 0x44C6FC: extcap_foreach (extcap.c:204)
by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
by 0x44CE3C: extcap_has_configuration (extcap.c:489)
by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
by 0x4A3214: MainWindow::on_actionCaptureRefreshInterfaces_triggered() (main_window_slots.cpp:3605)
...
Change-Id: I9433b8e36813cbef9dca5ab08074e985793f4d0d
Reviewed-on: https://code.wireshark.org/review/13617
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-31 06:40:33 +00:00
|
|
|
static void extcap_free_arg_elem(gpointer data, gpointer user_data _U_) {
|
|
|
|
extcap_free_arg((extcap_arg *) data);
|
|
|
|
g_free(data);
|
|
|
|
}
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
void extcap_register_preferences(void)
|
|
|
|
{
|
|
|
|
GList * interfaces = NULL;
|
|
|
|
|
|
|
|
module_t * dev_module = prefs_find_module("extcap");
|
|
|
|
|
|
|
|
if ( !dev_module )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( ! ifaces || g_hash_table_size(ifaces) == 0 )
|
2016-02-27 01:04:05 +00:00
|
|
|
extcap_reload_interface_list(NULL, NULL);
|
2015-12-29 06:57:36 +00:00
|
|
|
|
|
|
|
interfaces = g_hash_table_get_keys(ifaces);
|
|
|
|
|
|
|
|
while ( interfaces ) {
|
|
|
|
extcap_get_if_configuration((gchar *)interfaces->data);
|
|
|
|
|
|
|
|
interfaces = g_list_next(interfaces);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-12 15:26:04 +00:00
|
|
|
static void extcap_free_if_configuration(GList *list)
|
|
|
|
{
|
2016-01-12 20:08:14 +00:00
|
|
|
GList *elem, *sl;
|
2014-10-12 15:26:04 +00:00
|
|
|
|
|
|
|
for (elem = g_list_first(list); elem; elem = elem->next)
|
|
|
|
{
|
2016-01-12 20:08:14 +00:00
|
|
|
if (elem->data != NULL) {
|
|
|
|
/* g_list_free_full() only exists since 2.28. */
|
|
|
|
sl = g_list_first((GList *)elem->data);
|
Fix memleaks on interface refresh when extcap configs exists
If there are extcap interfaces present then each time the capture
interfaces list is displayed or refreshed a number of extcap related
allocations are leaked.
Valgrind reports leaks like these:
2,007 (144 direct, 1,863 indirect) bytes in 6 blocks are definitely lost in loss record 64,328 of 65,138
at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0x44C9AF: search_cb (extcap.c:451)
by 0x44C6FC: extcap_foreach (extcap.c:204)
by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
by 0x44CE3C: extcap_has_configuration (extcap.c:489)
by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
by 0x6547DF: InterfaceTree::getInterfaceList() (interface_tree.cpp:252)
by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
by 0x563F9A: WiresharkApplication::allSystemsGo() (wireshark_application.cpp:914)
by 0x4478D9: main (wireshark-qt.cpp:1373)
9,126 (432 direct, 8,694 indirect) bytes in 18 blocks are definitely lost in loss record 58,524 of 58,638
at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0x44C9AF: search_cb (extcap.c:451)
by 0x44C6FC: extcap_foreach (extcap.c:204)
by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
by 0x44CE3C: extcap_has_configuration (extcap.c:489)
by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
by 0x4A3214: MainWindow::on_actionCaptureRefreshInterfaces_triggered() (main_window_slots.cpp:3605)
...
Change-Id: I9433b8e36813cbef9dca5ab08074e985793f4d0d
Reviewed-on: https://code.wireshark.org/review/13617
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-31 06:40:33 +00:00
|
|
|
g_list_foreach(sl, (GFunc)extcap_free_arg_elem, NULL);
|
2016-01-12 20:08:14 +00:00
|
|
|
g_list_free(sl);
|
2016-01-12 12:45:20 +00:00
|
|
|
}
|
2014-10-12 15:26:04 +00:00
|
|
|
}
|
|
|
|
g_list_free(list);
|
|
|
|
}
|
|
|
|
|
2016-02-03 11:14:15 +00:00
|
|
|
gchar * extcap_settings_key(const gchar * ifname, const gchar * setting)
|
|
|
|
{
|
|
|
|
gchar * setting_nohyphen;
|
|
|
|
gchar * ifname_underscore;
|
|
|
|
gchar * ifname_lower;
|
|
|
|
gchar * key;
|
|
|
|
GRegex * regex = g_regex_new ("(?![a-zA-Z1-9_]).", (GRegexCompileFlags) 0, (GRegexMatchFlags) 0, NULL );
|
|
|
|
|
|
|
|
if (!regex)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
setting_nohyphen =
|
|
|
|
g_regex_replace_literal(regex, setting, strlen(setting), 0,
|
|
|
|
"", (GRegexMatchFlags) 0, NULL );
|
|
|
|
ifname_underscore =
|
|
|
|
g_regex_replace_literal(regex, ifname, strlen(ifname), 0,
|
|
|
|
"_", (GRegexMatchFlags) 0, NULL );
|
|
|
|
ifname_lower = g_utf8_strdown(ifname_underscore, -1);
|
|
|
|
key = g_strconcat(ifname_lower, ".", setting_nohyphen, NULL);
|
|
|
|
|
|
|
|
g_free(setting_nohyphen);
|
|
|
|
g_free(ifname_underscore);
|
|
|
|
g_free(ifname_lower);
|
|
|
|
g_regex_unref(regex);
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
static gboolean search_cb(const gchar *extcap _U_, const gchar *ifname _U_, gchar *output, void *data,
|
2014-10-06 18:03:47 +00:00
|
|
|
char **err_str _U_) {
|
|
|
|
extcap_token_sentence *tokens = NULL;
|
|
|
|
GList *arguments = NULL;
|
|
|
|
GList **il = (GList **) data;
|
2015-12-29 06:57:36 +00:00
|
|
|
module_t * dev_module = NULL;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
tokens = extcap_tokenize_sentences(output);
|
|
|
|
arguments = extcap_parse_args(tokens);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_free_tokenized_sentence_list(tokens);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
|
|
|
#if ARG_DEBUG
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_debug_arguments ( arguments );
|
2014-02-25 13:05:11 +00:00
|
|
|
#endif
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
dev_module = prefs_find_module("extcap");
|
|
|
|
|
|
|
|
if ( dev_module ) {
|
|
|
|
GList * walker = arguments;
|
|
|
|
|
2016-02-03 11:14:15 +00:00
|
|
|
while ( walker != NULL ) {
|
|
|
|
extcap_arg * arg = (extcap_arg *)walker->data;
|
2015-12-29 06:57:36 +00:00
|
|
|
|
2016-02-03 11:14:15 +00:00
|
|
|
if ( arg->save ) {
|
|
|
|
struct preference * pref = NULL;
|
|
|
|
gchar * pref_ifname = extcap_settings_key(ifname, arg->call);
|
2015-12-29 06:57:36 +00:00
|
|
|
|
2016-02-03 11:14:15 +00:00
|
|
|
if ( ( pref = prefs_find_preference(dev_module, pref_ifname) ) == NULL ) {
|
|
|
|
/* Set an initial value */
|
|
|
|
if ( ! arg->storeval && arg->default_complex )
|
|
|
|
arg->storeval = g_strdup(arg->default_complex->_val);
|
2015-12-29 06:57:36 +00:00
|
|
|
|
2016-02-03 11:14:15 +00:00
|
|
|
prefs_register_string_preference(dev_module, g_strdup(pref_ifname),
|
2016-04-06 13:04:53 +00:00
|
|
|
arg->display, arg->display, (const gchar **)(void*)(&arg->storeval));
|
2016-02-03 11:14:15 +00:00
|
|
|
} else {
|
|
|
|
/* Been here before, restore stored value */
|
|
|
|
if (! arg->storeval && pref->varp.string)
|
|
|
|
arg->storeval = g_strdup(*(pref->varp.string));
|
2015-12-29 06:57:36 +00:00
|
|
|
}
|
2016-02-03 11:14:15 +00:00
|
|
|
g_free(pref_ifname);
|
2015-12-29 06:57:36 +00:00
|
|
|
}
|
2016-02-03 11:14:15 +00:00
|
|
|
|
|
|
|
walker = g_list_next(walker);
|
2015-12-29 06:57:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
*il = g_list_append(*il, arguments);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
/* By returning false, extcap_foreach will break on first found */
|
|
|
|
return TRUE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
extcap_get_if_configuration(const char * ifname) {
|
2015-12-11 10:42:28 +00:00
|
|
|
gchar *argv[3];
|
2014-10-06 18:03:47 +00:00
|
|
|
GList *ret = NULL;
|
|
|
|
gchar **err_str = NULL;
|
2015-12-11 10:42:28 +00:00
|
|
|
int i;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ( extcap_if_exists(ifname) )
|
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Extcap path %s",
|
|
|
|
get_extcap_dir());
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
argv[0] = g_strdup(EXTCAP_ARGUMENT_CONFIG);
|
|
|
|
argv[1] = g_strdup(EXTCAP_ARGUMENT_INTERFACE);
|
|
|
|
argv[2] = g_strdup(ifname);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2015-12-11 10:42:28 +00:00
|
|
|
extcap_foreach(3, argv, search_cb, &ret, err_str, ifname);
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
g_free(argv[i]);
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return ret;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 08:26:46 +00:00
|
|
|
gboolean
|
2015-12-29 14:35:43 +00:00
|
|
|
extcap_has_configuration(const char * ifname, gboolean is_required) {
|
2015-04-28 08:26:46 +00:00
|
|
|
GList * arguments = 0;
|
|
|
|
GList * walker = 0, * item = 0;
|
|
|
|
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
arguments = extcap_get_if_configuration((const char *)( ifname ) );
|
|
|
|
walker = g_list_first(arguments);
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
while ( walker != NULL && ! found ) {
|
2015-04-28 08:26:46 +00:00
|
|
|
item = g_list_first((GList *)(walker->data));
|
2015-12-29 06:57:36 +00:00
|
|
|
while ( item != NULL && ! found ) {
|
|
|
|
if ( (extcap_arg *)(item->data) != NULL ) {
|
|
|
|
extcap_arg * arg = (extcap_arg *)(item->data);
|
2015-12-29 14:35:43 +00:00
|
|
|
/* Should required options be present, or any kind of options */
|
2015-12-29 06:57:36 +00:00
|
|
|
if ( ! is_required )
|
2015-12-29 14:35:43 +00:00
|
|
|
found = TRUE;
|
2015-12-29 06:57:36 +00:00
|
|
|
else if ( arg->is_required ) {
|
|
|
|
gchar * stored = NULL;
|
|
|
|
gchar * defval = NULL;
|
|
|
|
|
|
|
|
if ( arg->storeval != NULL )
|
|
|
|
stored = arg->storeval;
|
|
|
|
|
|
|
|
if ( arg->default_complex != NULL && arg->default_complex->_val != NULL )
|
|
|
|
defval = arg->default_complex->_val;
|
|
|
|
|
|
|
|
if ( arg->is_required ) {
|
|
|
|
/* If stored and defval is identical and the argument is required,
|
|
|
|
* configuration is needed */
|
|
|
|
if ( defval && stored && g_strcmp0(stored, defval) == 0 )
|
|
|
|
found = TRUE;
|
|
|
|
else if ( ! defval && (!stored || strlen(g_strchomp(stored)) <= (size_t)0) )
|
|
|
|
found = TRUE;
|
|
|
|
}
|
2016-02-01 08:53:31 +00:00
|
|
|
|
|
|
|
if ( arg->arg_type == EXTCAP_ARG_FILESELECT ) {
|
|
|
|
if ( arg->fileexists && ! ( file_exists(defval) || file_exists(stored) ) )
|
|
|
|
found = TRUE;
|
|
|
|
}
|
2015-12-29 06:57:36 +00:00
|
|
|
}
|
2015-12-29 14:35:43 +00:00
|
|
|
}
|
2015-04-28 08:26:46 +00:00
|
|
|
|
|
|
|
item = item->next;
|
|
|
|
}
|
|
|
|
walker = walker->next;
|
|
|
|
}
|
Fix memleaks on interface refresh when extcap configs exists
If there are extcap interfaces present then each time the capture
interfaces list is displayed or refreshed a number of extcap related
allocations are leaked.
Valgrind reports leaks like these:
2,007 (144 direct, 1,863 indirect) bytes in 6 blocks are definitely lost in loss record 64,328 of 65,138
at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0x44C9AF: search_cb (extcap.c:451)
by 0x44C6FC: extcap_foreach (extcap.c:204)
by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
by 0x44CE3C: extcap_has_configuration (extcap.c:489)
by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
by 0x6547DF: InterfaceTree::getInterfaceList() (interface_tree.cpp:252)
by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
by 0x563F9A: WiresharkApplication::allSystemsGo() (wireshark_application.cpp:914)
by 0x4478D9: main (wireshark-qt.cpp:1373)
9,126 (432 direct, 8,694 indirect) bytes in 18 blocks are definitely lost in loss record 58,524 of 58,638
at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
by 0x44C9AF: search_cb (extcap.c:451)
by 0x44C6FC: extcap_foreach (extcap.c:204)
by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
by 0x44CE3C: extcap_has_configuration (extcap.c:489)
by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
by 0x4A3214: MainWindow::on_actionCaptureRefreshInterfaces_triggered() (main_window_slots.cpp:3605)
...
Change-Id: I9433b8e36813cbef9dca5ab08074e985793f4d0d
Reviewed-on: https://code.wireshark.org/review/13617
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-31 06:40:33 +00:00
|
|
|
extcap_free_if_configuration(arguments);
|
2015-04-28 08:26:46 +00:00
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2014-02-25 13:05:11 +00:00
|
|
|
void extcap_cleanup(capture_options * capture_opts) {
|
2014-10-06 18:03:47 +00:00
|
|
|
interface_options interface_opts;
|
|
|
|
guint icnt = 0;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
for (icnt = 0; icnt < capture_opts->ifaces->len; icnt++) {
|
|
|
|
interface_opts = g_array_index(capture_opts->ifaces, interface_options,
|
|
|
|
icnt);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
/* skip native interfaces */
|
|
|
|
if (interface_opts.if_type != IF_EXTCAP)
|
|
|
|
continue;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
|
|
|
|
"Extcap [%s] - Cleaning up fifo: %s; PID: %d", interface_opts.name,
|
|
|
|
interface_opts.extcap_fifo, interface_opts.extcap_pid);
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2014-10-06 18:03:47 +00:00
|
|
|
if (pipe_h)
|
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
|
|
|
|
"Extcap [%s] - Closing pipe", interface_opts.name);
|
|
|
|
FlushFileBuffers(pipe_h);
|
|
|
|
DisconnectNamedPipe(pipe_h);
|
|
|
|
CloseHandle(pipe_h);
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
#else
|
2014-10-06 18:03:47 +00:00
|
|
|
if (interface_opts.extcap_fifo != NULL && file_exists(interface_opts.extcap_fifo))
|
|
|
|
{
|
|
|
|
/* the fifo will not be freed here, but with the other capture_opts in capture_sync */
|
|
|
|
ws_unlink(interface_opts.extcap_fifo);
|
|
|
|
interface_opts.extcap_fifo = NULL;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
#endif
|
2014-10-06 18:03:47 +00:00
|
|
|
/* Maybe the client closed and removed fifo, but ws should check if
|
|
|
|
* pid should be closed */
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
|
|
|
|
"Extcap [%s] - Closing spawned PID: %d", interface_opts.name,
|
|
|
|
interface_opts.extcap_pid);
|
|
|
|
|
|
|
|
if (interface_opts.extcap_pid != INVALID_EXTCAP_PID)
|
|
|
|
{
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2014-10-06 18:03:47 +00:00
|
|
|
TerminateProcess(interface_opts.extcap_pid, 0);
|
2014-10-03 17:27:04 +00:00
|
|
|
#endif
|
2014-10-06 18:03:47 +00:00
|
|
|
g_spawn_close_pid(interface_opts.extcap_pid);
|
|
|
|
interface_opts.extcap_pid = INVALID_EXTCAP_PID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure modified interface_opts is saved in capture_opts. */
|
|
|
|
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, icnt);
|
|
|
|
g_array_insert_val(capture_opts->ifaces, icnt, interface_opts);
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
static gboolean
|
|
|
|
extcap_add_arg_and_remove_cb(gpointer key, gpointer value, gpointer data) {
|
2014-10-06 18:03:47 +00:00
|
|
|
GPtrArray *args = (GPtrArray *)data;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ( key != NULL )
|
|
|
|
{
|
2014-10-12 19:07:48 +00:00
|
|
|
g_ptr_array_add(args, g_strdup((const gchar*)key));
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ( value != NULL )
|
2014-10-12 19:07:48 +00:00
|
|
|
g_ptr_array_add(args, g_strdup((const gchar*)value));
|
2015-12-29 06:57:36 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
2015-12-29 06:57:36 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 16:35:07 +00:00
|
|
|
static void extcap_child_watch_cb(GPid pid, gint status _U_, gpointer user_data)
|
|
|
|
{
|
2014-10-06 18:03:47 +00:00
|
|
|
guint i;
|
|
|
|
interface_options interface_opts;
|
|
|
|
capture_options *capture_opts = (capture_options *)user_data;
|
|
|
|
|
|
|
|
/* Close handle to child process. */
|
|
|
|
g_spawn_close_pid(pid);
|
|
|
|
|
|
|
|
/* Update extcap_pid in interface options structure. */
|
|
|
|
for (i = 0; i < capture_opts->ifaces->len; i++)
|
|
|
|
{
|
|
|
|
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
|
|
|
|
if (interface_opts.extcap_pid == pid)
|
|
|
|
{
|
|
|
|
interface_opts.extcap_pid = INVALID_EXTCAP_PID;
|
2016-02-11 06:48:54 +00:00
|
|
|
g_source_remove(interface_opts.extcap_child_watch);
|
2014-10-06 18:03:47 +00:00
|
|
|
interface_opts.extcap_child_watch = 0;
|
2016-02-11 06:48:54 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, i);
|
|
|
|
g_array_insert_val(capture_opts->ifaces, i, interface_opts);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-10-02 16:35:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 13:05:11 +00:00
|
|
|
/* call mkfifo for each extcap,
|
|
|
|
* returns FALSE if there's an error creating a FIFO */
|
|
|
|
gboolean
|
2016-01-12 09:47:19 +00:00
|
|
|
extcap_init_interfaces(capture_options *capture_opts)
|
2014-02-25 13:05:11 +00:00
|
|
|
{
|
2014-10-06 18:03:47 +00:00
|
|
|
guint i;
|
|
|
|
interface_options interface_opts;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
for (i = 0; i < capture_opts->ifaces->len; i++)
|
|
|
|
{
|
|
|
|
GPtrArray *args = NULL;
|
|
|
|
GPid pid = INVALID_EXTCAP_PID;
|
|
|
|
gchar **tmp;
|
|
|
|
int tmp_i;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
/* skip native interfaces */
|
|
|
|
if (interface_opts.if_type != IF_EXTCAP )
|
|
|
|
continue;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
/* create pipe for fifo */
|
|
|
|
if ( ! extcap_create_pipe ( &interface_opts.extcap_fifo ) )
|
|
|
|
return FALSE;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
/* Create extcap call */
|
|
|
|
args = g_ptr_array_new();
|
2014-02-25 13:05:11 +00:00
|
|
|
#define add_arg(X) g_ptr_array_add(args, g_strdup(X))
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
add_arg(interface_opts.extcap);
|
|
|
|
add_arg(EXTCAP_ARGUMENT_RUN_CAPTURE);
|
|
|
|
add_arg(EXTCAP_ARGUMENT_INTERFACE);
|
|
|
|
add_arg(interface_opts.name);
|
2015-11-17 10:32:01 +00:00
|
|
|
if (interface_opts.cfilter && strlen(interface_opts.cfilter) > 0) {
|
2015-10-30 09:48:13 +00:00
|
|
|
add_arg(EXTCAP_ARGUMENT_CAPTURE_FILTER);
|
|
|
|
add_arg(interface_opts.cfilter);
|
|
|
|
}
|
2014-10-06 18:03:47 +00:00
|
|
|
add_arg(EXTCAP_ARGUMENT_RUN_PIPE);
|
|
|
|
add_arg(interface_opts.extcap_fifo);
|
2015-12-29 06:57:36 +00:00
|
|
|
if (interface_opts.extcap_args == NULL || g_hash_table_size(interface_opts.extcap_args) == 0)
|
2014-10-12 15:26:04 +00:00
|
|
|
{
|
|
|
|
/* User did not perform interface configuration.
|
|
|
|
*
|
|
|
|
* Check if there are any boolean flags that are set by default
|
|
|
|
* and hence their argument should be added.
|
|
|
|
*/
|
|
|
|
GList *arglist;
|
|
|
|
GList *elem;
|
|
|
|
|
|
|
|
arglist = extcap_get_if_configuration(interface_opts.name);
|
|
|
|
for (elem = g_list_first(arglist); elem; elem = elem->next)
|
|
|
|
{
|
|
|
|
GList * arg_list;
|
|
|
|
extcap_arg *arg_iter;
|
|
|
|
|
|
|
|
if (elem->data == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
arg_list = g_list_first((GList *)elem->data);
|
2015-12-29 06:57:36 +00:00
|
|
|
while (arg_list != NULL) {
|
|
|
|
gchar * stored = NULL, * defval = NULL;
|
2014-10-12 15:26:04 +00:00
|
|
|
/* In case of boolflags only first element in arg_list is relevant. */
|
|
|
|
arg_iter = (extcap_arg*) (arg_list->data);
|
2015-12-29 06:57:36 +00:00
|
|
|
if ( arg_iter->storeval != NULL )
|
|
|
|
stored = arg_iter->storeval;
|
|
|
|
|
|
|
|
if ( arg_iter->default_complex != NULL && arg_iter->default_complex->_val != NULL )
|
|
|
|
defval = arg_iter->default_complex->_val;
|
|
|
|
|
|
|
|
/* Different data in storage then set for default */
|
|
|
|
if ( g_strcmp0(stored, defval) != 0 ) {
|
|
|
|
if ( arg_iter->arg_type == EXTCAP_ARG_BOOLFLAG ) {
|
|
|
|
if ( g_strcmp0(stored, "true") == 0 )
|
|
|
|
add_arg(arg_iter->call);
|
|
|
|
} else {
|
|
|
|
gchar * call = g_strconcat(arg_iter->call, " ", stored, NULL);
|
|
|
|
add_arg(call);
|
|
|
|
g_free(call);
|
2014-10-12 15:26:04 +00:00
|
|
|
}
|
2015-12-29 06:57:36 +00:00
|
|
|
} else if (arg_iter->arg_type == EXTCAP_ARG_BOOLFLAG) {
|
|
|
|
if (extcap_complex_get_bool(arg_iter->default_complex))
|
|
|
|
add_arg(arg_iter->call);
|
2014-10-12 15:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
arg_list = arg_list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extcap_free_if_configuration(arglist);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-29 06:57:36 +00:00
|
|
|
g_hash_table_foreach_remove(interface_opts.extcap_args, extcap_add_arg_and_remove_cb, args);
|
2014-10-12 15:26:04 +00:00
|
|
|
}
|
2014-10-06 18:03:47 +00:00
|
|
|
add_arg(NULL);
|
2014-02-25 13:05:11 +00:00
|
|
|
#undef add_arg
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
/* Dump commandline parameters sent to extcap. */
|
|
|
|
for (tmp = (gchar **)args->pdata, tmp_i = 0; *tmp && **tmp; ++tmp_i, ++tmp)
|
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "argv[%d]: %s", tmp_i, *tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wireshark for windows crashes here sometimes *
|
|
|
|
* Access violation reading location 0x... */
|
|
|
|
g_spawn_async(NULL, (gchar **)args->pdata, NULL,
|
|
|
|
(GSpawnFlags) G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL,
|
|
|
|
&pid,NULL);
|
|
|
|
|
|
|
|
g_ptr_array_foreach(args, (GFunc)g_free, NULL);
|
|
|
|
g_ptr_array_free(args, TRUE);
|
|
|
|
interface_opts.extcap_pid = pid;
|
|
|
|
interface_opts.extcap_child_watch =
|
|
|
|
g_child_watch_add(pid, extcap_child_watch_cb, (gpointer)capture_opts);
|
|
|
|
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, i);
|
|
|
|
g_array_insert_val(capture_opts->ifaces, i, interface_opts);
|
2014-10-02 16:35:07 +00:00
|
|
|
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2014-10-06 18:03:47 +00:00
|
|
|
/* On Windows, wait for extcap to connect to named pipe.
|
|
|
|
* Some extcaps will present UAC screen to user.
|
|
|
|
* 30 second timeout should be reasonable timeout for extcap to
|
|
|
|
* connect to named pipe (including user interaction).
|
|
|
|
* Wait on multiple object in case of extcap termination
|
|
|
|
* without opening pipe.
|
|
|
|
*
|
|
|
|
* Minimum supported version of Windows: XP / Server 2003.
|
|
|
|
*/
|
|
|
|
if (pid != INVALID_EXTCAP_PID)
|
|
|
|
{
|
|
|
|
DWORD dw;
|
|
|
|
HANDLE handles[2];
|
|
|
|
OVERLAPPED ov;
|
|
|
|
ov.Pointer = 0;
|
|
|
|
ov.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
|
|
|
|
|
|
|
ConnectNamedPipe(pipe_h, &ov);
|
|
|
|
handles[0] = ov.hEvent;
|
|
|
|
handles[1] = pid;
|
|
|
|
|
|
|
|
if (GetLastError() == ERROR_PIPE_CONNECTED)
|
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "extcap connected to pipe");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dw = WaitForMultipleObjects(2, handles, FALSE, 30000);
|
|
|
|
if (dw == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
/* ConnectNamedPipe finished. */
|
|
|
|
DWORD code;
|
|
|
|
|
|
|
|
code = GetLastError();
|
|
|
|
if (code == ERROR_IO_PENDING)
|
|
|
|
{
|
|
|
|
DWORD dummy;
|
|
|
|
if (!GetOverlappedResult(ov.hEvent, &ov, &dummy, TRUE))
|
|
|
|
{
|
|
|
|
code = GetLastError();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
code = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "ConnectNamedPipe code: %d", code);
|
|
|
|
}
|
|
|
|
else if (dw == (WAIT_OBJECT_0 + 1))
|
|
|
|
{
|
|
|
|
/* extcap process terminated. */
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "extcap terminated without connecting to pipe!");
|
|
|
|
}
|
|
|
|
else if (dw == WAIT_TIMEOUT)
|
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "extcap didn't connect to pipe within 30 seconds!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "WaitForMultipleObjects returned 0x%08X. Error %d", dw, GetLastError());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(ov.hEvent);
|
|
|
|
}
|
2014-10-02 16:35:07 +00:00
|
|
|
#endif
|
2014-10-06 18:03:47 +00:00
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return TRUE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2014-02-25 13:05:11 +00:00
|
|
|
/* called by capture_sync to get the CreatNamedPipe handle*/
|
|
|
|
HANDLE
|
|
|
|
extcap_get_win32_handle()
|
|
|
|
{
|
2014-10-06 18:03:47 +00:00
|
|
|
return pipe_h;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gboolean extcap_create_pipe(char ** fifo)
|
|
|
|
{
|
2015-09-02 21:35:37 +00:00
|
|
|
#ifdef _WIN32
|
2014-10-06 18:03:47 +00:00
|
|
|
gchar timestr[ 14+1 ];
|
|
|
|
time_t current_time;
|
|
|
|
|
|
|
|
gchar *pipename = NULL;
|
|
|
|
|
|
|
|
SECURITY_ATTRIBUTES security;
|
|
|
|
/* create pipename */
|
|
|
|
current_time = time(NULL);
|
|
|
|
strftime(timestr, sizeof(timestr), "%Y%m%d%H%M%S", localtime(¤t_time));
|
|
|
|
pipename = g_strconcat ( "\\\\.\\pipe\\", EXTCAP_PIPE_PREFIX, "_", timestr, NULL );
|
|
|
|
|
|
|
|
/* Security struct to enable Inheritable HANDLE */
|
|
|
|
memset(&security, 0, sizeof(SECURITY_ATTRIBUTES));
|
|
|
|
security.nLength = sizeof(SECURITY_ATTRIBUTES);
|
|
|
|
security.bInheritHandle = TRUE;
|
|
|
|
security.lpSecurityDescriptor = NULL;
|
|
|
|
|
|
|
|
/* create a namedPipe*/
|
|
|
|
pipe_h = CreateNamedPipe(
|
|
|
|
utf_8to16(pipename),
|
|
|
|
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
|
|
|
PIPE_TYPE_MESSAGE| PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
|
|
|
5, 65536, 65536,
|
|
|
|
300,
|
|
|
|
&security);
|
|
|
|
|
|
|
|
if (pipe_h == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,"\nError creating pipe => (%d)", GetLastError());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,"\nWireshark Created pipe =>(%s)",pipename);
|
|
|
|
*fifo = g_strdup(pipename);
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
#else
|
2014-10-06 18:03:47 +00:00
|
|
|
gchar *temp_name = NULL;
|
|
|
|
int fd = 0;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2015-10-10 22:07:33 +00:00
|
|
|
if ((fd = create_tempfile(&temp_name, EXTCAP_PIPE_PREFIX)) < 0 )
|
2014-10-06 18:03:47 +00:00
|
|
|
return FALSE;
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
ws_close(fd);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
|
|
|
|
"Extcap - Creating fifo: %s", temp_name);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if ( file_exists(temp_name) )
|
|
|
|
ws_unlink(temp_name);
|
2014-02-25 13:05:11 +00:00
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
if (mkfifo(temp_name, 0600) == 0)
|
|
|
|
*fifo = g_strdup(temp_name);
|
2014-02-25 13:05:11 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-06 18:03:47 +00:00
|
|
|
return TRUE;
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if ARG_DEBUG
|
|
|
|
void extcap_debug_arguments ( extcap_arg *arg_iter )
|
|
|
|
{
|
2014-10-06 18:03:47 +00:00
|
|
|
extcap_value *v = NULL;
|
|
|
|
GList *walker = NULL;
|
|
|
|
|
|
|
|
printf("debug - parser dump\n");
|
|
|
|
while (arg_iter != NULL) {
|
|
|
|
printf("ARG %d call=%s display=\"%s\" type=", arg_iter->arg_num, arg_iter->call, arg_iter->display);
|
|
|
|
|
|
|
|
switch (arg_iter->arg_type) {
|
|
|
|
case EXTCAP_ARG_INTEGER:
|
|
|
|
printf("int\n");
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_UNSIGNED:
|
|
|
|
printf("unsigned\n");
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_LONG:
|
|
|
|
printf("long\n");
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_DOUBLE:
|
|
|
|
printf("double\n");
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_BOOLEAN:
|
|
|
|
printf("boolean\n");
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_MENU:
|
|
|
|
printf("menu\n");
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_RADIO:
|
|
|
|
printf("radio\n");
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_SELECTOR:
|
|
|
|
printf("selctor\n");
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_STRING:
|
|
|
|
printf ( "string\n" );
|
|
|
|
break;
|
2016-01-18 11:01:14 +00:00
|
|
|
case EXTCAP_ARG_PASSWORD:
|
|
|
|
printf ( "PASSWORD\n" );
|
|
|
|
break;
|
2014-10-06 18:03:47 +00:00
|
|
|
case EXTCAP_ARG_MULTICHECK:
|
|
|
|
printf ( "unknown\n" );
|
|
|
|
break;
|
|
|
|
case EXTCAP_ARG_UNKNOWN:
|
|
|
|
printf ( "unknown\n" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg_iter->range_start != NULL && arg_iter->range_end != NULL) {
|
|
|
|
printf("\tRange: ");
|
|
|
|
extcap_printf_complex(arg_iter->range_start);
|
|
|
|
printf(" - ");
|
|
|
|
extcap_printf_complex(arg_iter->range_end);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( walker = g_list_first ( arg_iter->value_list ); walker; walker = walker->next )
|
|
|
|
{
|
|
|
|
v = (extcap_value *)walker->data;
|
2015-12-29 14:35:43 +00:00
|
|
|
if (v->is_default)
|
2014-10-06 18:03:47 +00:00
|
|
|
printf("*");
|
|
|
|
printf("\tcall=\"%p\" display=\"%p\"\n", v->call, v->display);
|
|
|
|
printf("\tcall=\"%s\" display=\"%s\"\n", v->call, v->display);
|
|
|
|
}
|
|
|
|
|
|
|
|
arg_iter = arg_iter->next_arg;
|
|
|
|
}
|
2014-02-25 13:05:11 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
2014-10-06 18:03:47 +00:00
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
2014-02-25 13:05:11 +00:00
|
|
|
* End:
|
|
|
|
*
|
2014-10-06 18:03:47 +00:00
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
2014-02-25 13:05:11 +00:00
|
|
|
*/
|