forked from osmocom/wireshark
Third try. This time pipes and stdin are supported and the
test scripts are passed. Use a global list containing all interfaces and only change properties of the entries when changes are made in the GUI. Do not misuse the list of interfaces specified on the command line anymore. This patch does not provide any new functionality, it just provides the base for future extensions like removing remote interface, mulitple airpcap devices and multiple pipes. This patch was provided by Irene Ruengeler. svn path=/trunk/; revision=40715
This commit is contained in:
parent
93ac5f499e
commit
14b1a44c0f
437
capture.c
437
capture.c
|
@ -81,49 +81,49 @@ static GList *capture_callbacks = NULL;
|
||||||
static void
|
static void
|
||||||
capture_callback_invoke(int event, capture_options *capture_opts)
|
capture_callback_invoke(int event, capture_options *capture_opts)
|
||||||
{
|
{
|
||||||
capture_callback_data_t *cb;
|
capture_callback_data_t *cb;
|
||||||
GList *cb_item = capture_callbacks;
|
GList *cb_item = capture_callbacks;
|
||||||
|
|
||||||
/* there should be at least one interested */
|
/* there should be at least one interested */
|
||||||
g_assert(cb_item != NULL);
|
g_assert(cb_item != NULL);
|
||||||
|
|
||||||
while(cb_item != NULL) {
|
while(cb_item != NULL) {
|
||||||
cb = cb_item->data;
|
cb = cb_item->data;
|
||||||
cb->cb_fct(event, capture_opts, cb->user_data);
|
cb->cb_fct(event, capture_opts, cb->user_data);
|
||||||
cb_item = g_list_next(cb_item);
|
cb_item = g_list_next(cb_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
capture_callback_add(capture_callback_t func, gpointer user_data)
|
capture_callback_add(capture_callback_t func, gpointer user_data)
|
||||||
{
|
{
|
||||||
capture_callback_data_t *cb;
|
capture_callback_data_t *cb;
|
||||||
|
|
||||||
cb = g_malloc(sizeof(capture_callback_data_t));
|
cb = g_malloc(sizeof(capture_callback_data_t));
|
||||||
cb->cb_fct = func;
|
cb->cb_fct = func;
|
||||||
cb->user_data = user_data;
|
cb->user_data = user_data;
|
||||||
|
|
||||||
capture_callbacks = g_list_append(capture_callbacks, cb);
|
capture_callbacks = g_list_append(capture_callbacks, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
capture_callback_remove(capture_callback_t func)
|
capture_callback_remove(capture_callback_t func)
|
||||||
{
|
{
|
||||||
capture_callback_data_t *cb;
|
capture_callback_data_t *cb;
|
||||||
GList *cb_item = capture_callbacks;
|
GList *cb_item = capture_callbacks;
|
||||||
|
|
||||||
while(cb_item != NULL) {
|
while(cb_item != NULL) {
|
||||||
cb = cb_item->data;
|
cb = cb_item->data;
|
||||||
if(cb->cb_fct == func) {
|
if(cb->cb_fct == func) {
|
||||||
capture_callbacks = g_list_remove(capture_callbacks, cb);
|
capture_callbacks = g_list_remove(capture_callbacks, cb);
|
||||||
g_free(cb);
|
g_free(cb);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
cb_item = g_list_next(cb_item);
|
|
||||||
}
|
}
|
||||||
|
cb_item = g_list_next(cb_item);
|
||||||
|
}
|
||||||
|
|
||||||
g_assert_not_reached();
|
g_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,9 +144,8 @@ capture_start(capture_options *capture_opts)
|
||||||
|
|
||||||
/* close the currently loaded capture file */
|
/* close the currently loaded capture file */
|
||||||
cf_close(capture_opts->cf);
|
cf_close(capture_opts->cf);
|
||||||
|
collect_ifaces(capture_opts);
|
||||||
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (capture_opts->ifaces->len < 2) {
|
if (capture_opts->ifaces->len < 2) {
|
||||||
#else
|
#else
|
||||||
|
@ -176,7 +175,6 @@ capture_start(capture_options *capture_opts)
|
||||||
}
|
}
|
||||||
cf_set_tempfile_source(capture_opts->cf, source->str);
|
cf_set_tempfile_source(capture_opts->cf, source->str);
|
||||||
g_string_free(source, TRUE);
|
g_string_free(source, TRUE);
|
||||||
|
|
||||||
/* try to start the capture child process */
|
/* try to start the capture child process */
|
||||||
ret = sync_pipe_start(capture_opts);
|
ret = sync_pipe_start(capture_opts);
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
|
@ -548,239 +546,242 @@ capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char
|
||||||
void
|
void
|
||||||
capture_input_closed(capture_options *capture_opts, gchar *msg)
|
capture_input_closed(capture_options *capture_opts, gchar *msg)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
int packet_count_save;
|
int packet_count_save;
|
||||||
|
|
||||||
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture stopped!");
|
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture stopped!");
|
||||||
g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
|
g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
|
||||||
|
|
||||||
if (msg != NULL)
|
if (msg != NULL)
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", msg);
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", msg);
|
||||||
|
|
||||||
/* if we didn't start the capture, do a fake start. */
|
|
||||||
/* (happens if we got an error message - we won't get a filename then). */
|
|
||||||
if(capture_opts->state == CAPTURE_PREPARING) {
|
|
||||||
if(capture_opts->real_time_mode) {
|
|
||||||
capture_callback_invoke(capture_cb_capture_update_started, capture_opts);
|
|
||||||
} else {
|
|
||||||
capture_callback_invoke(capture_cb_capture_fixed_started, capture_opts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* if we didn't start the capture, do a fake start. */
|
||||||
|
/* (happens if we got an error message - we won't get a filename then). */
|
||||||
|
if(capture_opts->state == CAPTURE_PREPARING) {
|
||||||
if(capture_opts->real_time_mode) {
|
if(capture_opts->real_time_mode) {
|
||||||
cf_read_status_t status;
|
capture_callback_invoke(capture_cb_capture_update_started, capture_opts);
|
||||||
|
} else {
|
||||||
|
capture_callback_invoke(capture_cb_capture_fixed_started, capture_opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Read what remains of the capture file. */
|
if(capture_opts->real_time_mode) {
|
||||||
status = cf_finish_tail(capture_opts->cf, &err);
|
cf_read_status_t status;
|
||||||
|
|
||||||
/* XXX: If -Q (quit-after-cap) then cf->count clr'd below so save it first */
|
/* Read what remains of the capture file. */
|
||||||
packet_count_save = cf_get_packet_count(capture_opts->cf);
|
status = cf_finish_tail(capture_opts->cf, &err);
|
||||||
/* Tell the GUI we are not doing a capture any more.
|
|
||||||
Must be done after the cf_finish_tail(), so file lengths are
|
|
||||||
correctly displayed */
|
|
||||||
capture_callback_invoke(capture_cb_capture_update_finished, capture_opts);
|
|
||||||
|
|
||||||
/* Finish the capture. */
|
/* XXX: If -Q (quit-after-cap) then cf->count clr'd below so save it first */
|
||||||
switch (status) {
|
packet_count_save = cf_get_packet_count(capture_opts->cf);
|
||||||
|
/* Tell the GUI we are not doing a capture any more.
|
||||||
|
Must be done after the cf_finish_tail(), so file lengths are
|
||||||
|
correctly displayed */
|
||||||
|
capture_callback_invoke(capture_cb_capture_update_finished, capture_opts);
|
||||||
|
|
||||||
case CF_READ_OK:
|
/* Finish the capture. */
|
||||||
if ((packet_count_save == 0) && !capture_opts->restart) {
|
switch (status) {
|
||||||
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
|
||||||
"%sNo packets captured!%s\n"
|
case CF_READ_OK:
|
||||||
"\n"
|
if ((packet_count_save == 0) && !capture_opts->restart) {
|
||||||
"As no data was captured, closing the %scapture file!\n"
|
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
||||||
"\n"
|
"%sNo packets captured!%s\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Help about capturing can be found at:\n"
|
"As no data was captured, closing the %scapture file!\n"
|
||||||
"\n"
|
"\n"
|
||||||
" http://wiki.wireshark.org/CaptureSetup"
|
"\n"
|
||||||
|
"Help about capturing can be found at:\n"
|
||||||
|
"\n"
|
||||||
|
" http://wiki.wireshark.org/CaptureSetup"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
"\n\n"
|
"\n\n"
|
||||||
"Wireless (Wi-Fi/WLAN):\n"
|
"Wireless (Wi-Fi/WLAN):\n"
|
||||||
"Try to switch off promiscuous mode in the Capture Options!"
|
"Try to switch off promiscuous mode in the Capture Options!"
|
||||||
#endif
|
#endif
|
||||||
"",
|
"",
|
||||||
simple_dialog_primary_start(), simple_dialog_primary_end(),
|
simple_dialog_primary_start(), simple_dialog_primary_end(),
|
||||||
cf_is_tempfile(capture_opts->cf) ? "temporary " : "");
|
cf_is_tempfile(capture_opts->cf) ? "temporary " : "");
|
||||||
cf_close(capture_opts->cf);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CF_READ_ERROR:
|
|
||||||
/* Just because we got an error, that doesn't mean we were unable
|
|
||||||
to read any of the file; we handle what we could get from the
|
|
||||||
file. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CF_READ_ABORTED:
|
|
||||||
/* Exit by leaving the main loop, so that any quit functions
|
|
||||||
we registered get called. */
|
|
||||||
main_window_quit();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* first of all, we are not doing a capture any more */
|
|
||||||
capture_callback_invoke(capture_cb_capture_fixed_finished, capture_opts);
|
|
||||||
|
|
||||||
/* this is a normal mode capture and if no error happened, read in the capture file data */
|
|
||||||
if(capture_opts->save_file != NULL) {
|
|
||||||
capture_input_read_all(capture_opts, cf_is_tempfile(capture_opts->cf),
|
|
||||||
cf_get_drops_known(capture_opts->cf), cf_get_drops(capture_opts->cf));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(capture_opts->show_info)
|
|
||||||
capture_info_close();
|
|
||||||
|
|
||||||
capture_opts->state = CAPTURE_STOPPED;
|
|
||||||
|
|
||||||
/* if we couldn't open a capture file, there's nothing more for us to do */
|
|
||||||
if(capture_opts->save_file == NULL) {
|
|
||||||
cf_close(capture_opts->cf);
|
cf_close(capture_opts->cf);
|
||||||
return;
|
}
|
||||||
|
break;
|
||||||
|
case CF_READ_ERROR:
|
||||||
|
/* Just because we got an error, that doesn't mean we were unable
|
||||||
|
to read any of the file; we handle what we could get from the
|
||||||
|
file. */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CF_READ_ABORTED:
|
||||||
|
/* Exit by leaving the main loop, so that any quit functions
|
||||||
|
we registered get called. */
|
||||||
|
main_window_quit();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* does the user wants to restart the current capture? */
|
} else {
|
||||||
if(capture_opts->restart) {
|
/* first of all, we are not doing a capture any more */
|
||||||
capture_opts->restart = FALSE;
|
capture_callback_invoke(capture_cb_capture_fixed_finished, capture_opts);
|
||||||
|
|
||||||
ws_unlink(capture_opts->save_file);
|
/* this is a normal mode capture and if no error happened, read in the capture file data */
|
||||||
|
if(capture_opts->save_file != NULL) {
|
||||||
/* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */
|
capture_input_read_all(capture_opts, cf_is_tempfile(capture_opts->cf),
|
||||||
if(cf_is_tempfile(capture_opts->cf)) {
|
cf_get_drops_known(capture_opts->cf), cf_get_drops(capture_opts->cf));
|
||||||
g_free(capture_opts->save_file);
|
|
||||||
capture_opts->save_file = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ... and start the capture again */
|
|
||||||
capture_start(capture_opts);
|
|
||||||
} else {
|
|
||||||
/* We're not doing a capture any more, so we don't have a save file. */
|
|
||||||
g_free(capture_opts->save_file);
|
|
||||||
capture_opts->save_file = NULL;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(capture_opts->show_info)
|
||||||
|
capture_info_close();
|
||||||
|
|
||||||
|
capture_opts->state = CAPTURE_STOPPED;
|
||||||
|
|
||||||
|
/* if we couldn't open a capture file, there's nothing more for us to do */
|
||||||
|
if(capture_opts->save_file == NULL) {
|
||||||
|
cf_close(capture_opts->cf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* does the user wants to restart the current capture? */
|
||||||
|
if(capture_opts->restart) {
|
||||||
|
capture_opts->restart = FALSE;
|
||||||
|
|
||||||
|
ws_unlink(capture_opts->save_file);
|
||||||
|
|
||||||
|
/* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */
|
||||||
|
if(cf_is_tempfile(capture_opts->cf)) {
|
||||||
|
g_free(capture_opts->save_file);
|
||||||
|
capture_opts->save_file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ... and start the capture again */
|
||||||
|
if (capture_opts->ifaces->len == 0) {
|
||||||
|
collect_ifaces(capture_opts);
|
||||||
|
}
|
||||||
|
capture_start(capture_opts);
|
||||||
|
} else {
|
||||||
|
/* We're not doing a capture any more, so we don't have a save file. */
|
||||||
|
g_free(capture_opts->save_file);
|
||||||
|
capture_opts->save_file = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if_stat_cache_t *
|
if_stat_cache_t *
|
||||||
capture_stat_start(GList *if_list) {
|
capture_stat_start(capture_options *capture_opts) {
|
||||||
int stat_fd, fork_child;
|
int stat_fd, fork_child;
|
||||||
gchar *msg;
|
gchar *msg;
|
||||||
if_stat_cache_t *sc = NULL;
|
if_stat_cache_t *sc = NULL;
|
||||||
GList *if_entry;
|
if_stat_cache_item_t *sc_item;
|
||||||
if_info_t *if_info;
|
guint i;
|
||||||
if_stat_cache_item_t *sc_item;
|
interface_t device;
|
||||||
|
|
||||||
/* Fire up dumpcap. */
|
/* Fire up dumpcap. */
|
||||||
/*
|
/*
|
||||||
* XXX - on systems with BPF, the number of BPF devices limits the
|
* XXX - on systems with BPF, the number of BPF devices limits the
|
||||||
* number of devices on which you can capture simultaneously.
|
* number of devices on which you can capture simultaneously.
|
||||||
*
|
*
|
||||||
* This means that
|
* This means that
|
||||||
*
|
*
|
||||||
* 1) this might fail if you run out of BPF devices
|
* 1) this might fail if you run out of BPF devices
|
||||||
*
|
*
|
||||||
* and
|
* and
|
||||||
*
|
*
|
||||||
* 2) opening every interface could leave too few BPF devices
|
* 2) opening every interface could leave too few BPF devices
|
||||||
* for *other* programs.
|
* for *other* programs.
|
||||||
*
|
*
|
||||||
* It also means the system could end up getting a lot of traffic
|
* It also means the system could end up getting a lot of traffic
|
||||||
* that it has to pass through the networking stack and capture
|
* that it has to pass through the networking stack and capture
|
||||||
* mechanism, so opening all the devices and presenting packet
|
* mechanism, so opening all the devices and presenting packet
|
||||||
* counts might not always be a good idea.
|
* counts might not always be a good idea.
|
||||||
*/
|
*/
|
||||||
if (sync_interface_stats_open(&stat_fd, &fork_child, &msg) == 0) {
|
if (sync_interface_stats_open(&stat_fd, &fork_child, &msg) == 0) {
|
||||||
sc = g_malloc(sizeof(if_stat_cache_t));
|
sc = g_malloc(sizeof(if_stat_cache_t));
|
||||||
sc->stat_fd = stat_fd;
|
sc->stat_fd = stat_fd;
|
||||||
sc->fork_child = fork_child;
|
sc->fork_child = fork_child;
|
||||||
sc->cache_list = NULL;
|
sc->cache_list = NULL;
|
||||||
|
|
||||||
/* Initialize the cache */
|
/* Initialize the cache */
|
||||||
for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
|
for (i = 0; i < capture_opts->all_ifaces->len; i++) {
|
||||||
if_info = if_entry->data;
|
device = g_array_index(capture_opts->all_ifaces, interface_t, i);
|
||||||
if (if_info) {
|
if (&(device.if_info)) {
|
||||||
sc_item = g_malloc0(sizeof(if_stat_cache_item_t));
|
sc_item = g_malloc0(sizeof(if_stat_cache_item_t));
|
||||||
sc_item->name = g_strdup(if_info->name);
|
sc_item->name = g_strdup(device.if_info.name);
|
||||||
sc->cache_list = g_list_append(sc->cache_list, sc_item);
|
sc->cache_list = g_list_append(sc->cache_list, sc_item);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return sc;
|
}
|
||||||
|
return sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_STAT_LINE_LEN 500
|
#define MAX_STAT_LINE_LEN 500
|
||||||
|
|
||||||
static void
|
static void
|
||||||
capture_stat_cache_update(if_stat_cache_t *sc) {
|
capture_stat_cache_update(if_stat_cache_t *sc) {
|
||||||
gchar stat_line[MAX_STAT_LINE_LEN];
|
gchar stat_line[MAX_STAT_LINE_LEN];
|
||||||
gchar **stat_parts;
|
gchar **stat_parts;
|
||||||
GList *sc_entry;
|
GList *sc_entry;
|
||||||
if_stat_cache_item_t *sc_item;
|
if_stat_cache_item_t *sc_item;
|
||||||
|
|
||||||
if (!sc)
|
if (!sc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (sync_pipe_gets_nonblock(sc->stat_fd, stat_line, MAX_STAT_LINE_LEN) > 0) {
|
while (sync_pipe_gets_nonblock(sc->stat_fd, stat_line, MAX_STAT_LINE_LEN) > 0) {
|
||||||
g_strstrip(stat_line);
|
g_strstrip(stat_line);
|
||||||
stat_parts = g_strsplit(stat_line, "\t", 3);
|
stat_parts = g_strsplit(stat_line, "\t", 3);
|
||||||
if (stat_parts[0] == NULL || stat_parts[1] == NULL ||
|
if (stat_parts[0] == NULL || stat_parts[1] == NULL ||
|
||||||
stat_parts[2] == NULL) {
|
stat_parts[2] == NULL) {
|
||||||
g_strfreev(stat_parts);
|
g_strfreev(stat_parts);
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
|
|
||||||
sc_item = sc_entry->data;
|
|
||||||
if (strcmp(sc_item->name, stat_parts[0]) == 0) {
|
|
||||||
sc_item->ps.ps_recv = (u_int) strtoul(stat_parts[1], NULL, 10);
|
|
||||||
sc_item->ps.ps_drop = (u_int) strtoul(stat_parts[2], NULL, 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_strfreev(stat_parts);
|
|
||||||
}
|
}
|
||||||
|
for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
|
||||||
|
sc_item = sc_entry->data;
|
||||||
|
if (strcmp(sc_item->name, stat_parts[0]) == 0) {
|
||||||
|
sc_item->ps.ps_recv = (u_int) strtoul(stat_parts[1], NULL, 10);
|
||||||
|
sc_item->ps.ps_drop = (u_int) strtoul(stat_parts[2], NULL, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_strfreev(stat_parts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
capture_stats(if_stat_cache_t *sc, char *ifname, struct pcap_stat *ps) {
|
capture_stats(if_stat_cache_t *sc, char *ifname, struct pcap_stat *ps) {
|
||||||
GList *sc_entry;
|
GList *sc_entry;
|
||||||
if_stat_cache_item_t *sc_item;
|
if_stat_cache_item_t *sc_item;
|
||||||
|
|
||||||
if (!sc || !ifname || !ps) {
|
if (!sc || !ifname || !ps) {
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
capture_stat_cache_update(sc);
|
|
||||||
for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
|
|
||||||
sc_item = sc_entry->data;
|
|
||||||
if (strcmp(sc_item->name, ifname) == 0) {
|
|
||||||
memcpy(ps, &sc_item->ps, sizeof(struct pcap_stat));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
capture_stat_cache_update(sc);
|
||||||
|
for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
|
||||||
|
sc_item = sc_entry->data;
|
||||||
|
if (strcmp(sc_item->name, ifname) == 0) {
|
||||||
|
memcpy(ps, &sc_item->ps, sizeof(struct pcap_stat));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
capture_stat_stop(if_stat_cache_t *sc) {
|
capture_stat_stop(if_stat_cache_t *sc) {
|
||||||
GList *sc_entry;
|
GList *sc_entry;
|
||||||
if_stat_cache_item_t *sc_item;
|
if_stat_cache_item_t *sc_item;
|
||||||
int ret;
|
int ret;
|
||||||
gchar *msg;
|
gchar *msg;
|
||||||
|
|
||||||
if (!sc)
|
if (!sc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = sync_interface_stats_close(&sc->stat_fd, &sc->fork_child, &msg);
|
ret = sync_interface_stats_close(&sc->stat_fd, &sc->fork_child, &msg);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
/* XXX - report failure? */
|
/* XXX - report failure? */
|
||||||
g_free(msg);
|
g_free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
|
for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
|
||||||
sc_item = sc_entry->data;
|
sc_item = sc_entry->data;
|
||||||
g_free(sc_item->name);
|
g_free(sc_item->name);
|
||||||
g_free(sc_item);
|
g_free(sc_item);
|
||||||
}
|
}
|
||||||
g_free(sc);
|
g_free(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_LIBPCAP */
|
#endif /* HAVE_LIBPCAP */
|
||||||
|
|
|
@ -114,7 +114,7 @@ typedef struct if_stat_cache_s if_stat_cache_t;
|
||||||
* @param if_list A GList of if_info_t items
|
* @param if_list A GList of if_info_t items
|
||||||
* @return A pointer to the statistics state data.
|
* @return A pointer to the statistics state data.
|
||||||
*/
|
*/
|
||||||
extern if_stat_cache_t * capture_stat_start(GList *if_list);
|
extern if_stat_cache_t * capture_stat_start(capture_options *capture_opts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch capture statistics, similar to pcap_stats().
|
* Fetch capture statistics, similar to pcap_stats().
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
|
#include <epan/prefs.h>
|
||||||
|
#include "ui/simple_dialog.h"
|
||||||
|
#include "capture_ui_utils.h"
|
||||||
|
|
||||||
#include "capture_opts.h"
|
#include "capture_opts.h"
|
||||||
#include "ringbuffer.h"
|
#include "ringbuffer.h"
|
||||||
|
@ -57,6 +60,8 @@ capture_opts_init(capture_options *capture_opts, void *cf)
|
||||||
{
|
{
|
||||||
capture_opts->cf = cf;
|
capture_opts->cf = cf;
|
||||||
capture_opts->ifaces = g_array_new(FALSE, FALSE, sizeof(interface_options));
|
capture_opts->ifaces = g_array_new(FALSE, FALSE, sizeof(interface_options));
|
||||||
|
capture_opts->all_ifaces = g_array_new(FALSE, FALSE, sizeof(interface_t));
|
||||||
|
capture_opts->num_selected = 0;
|
||||||
capture_opts->default_options.name = NULL;
|
capture_opts->default_options.name = NULL;
|
||||||
capture_opts->default_options.descr = NULL;
|
capture_opts->default_options.descr = NULL;
|
||||||
capture_opts->default_options.cfilter = NULL;
|
capture_opts->default_options.cfilter = NULL;
|
||||||
|
@ -431,7 +436,7 @@ get_auth_arguments(capture_options *capture_opts, const char *arg)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
int
|
||||||
capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str_p)
|
capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str_p)
|
||||||
{
|
{
|
||||||
long adapter_index;
|
long adapter_index;
|
||||||
|
@ -527,6 +532,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_str_p, gboolean *start_capture)
|
capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_str_p, gboolean *start_capture)
|
||||||
{
|
{
|
||||||
|
@ -827,7 +833,7 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
|
||||||
|
|
||||||
|
|
||||||
/* Did the user specify an interface to use? */
|
/* Did the user specify an interface to use? */
|
||||||
if (capture_opts->ifaces->len == 0) {
|
if (capture_opts->num_selected == 0 && capture_opts->ifaces->len == 0) {
|
||||||
/* No - is a default specified in the preferences file? */
|
/* No - is a default specified in the preferences file? */
|
||||||
if (capture_device != NULL) {
|
if (capture_device != NULL) {
|
||||||
/* Yes - use it. */
|
/* Yes - use it. */
|
||||||
|
@ -959,4 +965,49 @@ static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
collect_ifaces(capture_options *capture_opts)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
interface_t device;
|
||||||
|
interface_options interface_opts;
|
||||||
|
for (i = 0; i < capture_opts->all_ifaces->len; i++) {
|
||||||
|
device = g_array_index(capture_opts->all_ifaces, interface_t, i);
|
||||||
|
if (!device.hidden && device.selected) {
|
||||||
|
interface_opts.name = g_strdup(device.name);
|
||||||
|
interface_opts.descr = g_strdup(device.display_name);
|
||||||
|
interface_opts.monitor_mode = device.monitor_mode_enabled;
|
||||||
|
interface_opts.linktype = device.active_dlt;
|
||||||
|
interface_opts.cfilter = g_strdup(device.cfilter);
|
||||||
|
interface_opts.snaplen = device.snaplen;
|
||||||
|
interface_opts.has_snaplen = device.has_snaplen;
|
||||||
|
interface_opts.promisc_mode = device.pmode;
|
||||||
|
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||||
|
interface_opts.buffer_size = device.buffer;
|
||||||
|
#endif
|
||||||
|
if (!device.local) {
|
||||||
|
#ifdef HAVE_PCAP_REMOTE
|
||||||
|
interface_opts.src_type = CAPTURE_IFREMOTE;
|
||||||
|
interface_opts.remote_host = g_strdup(device.remote_opts.remote_host_opts.remote_host);
|
||||||
|
interface_opts.remote_port = g_strdup(device.remote_opts.remote_host_opts.remote_port);
|
||||||
|
interface_opts.auth_type = device.remote_opts.remote_host_opts.auth_type;
|
||||||
|
interface_opts.auth_username = g_strdup(device.remote_opts.remote_host_opts.auth_username);
|
||||||
|
interface_opts.auth_password = g_strdup(device.remote_opts.remote_host_opts.auth_password);
|
||||||
|
interface_opts.datatx_udp = device.remote_opts.remote_host_opts.datatx_udp;
|
||||||
|
interface_opts.nocap_rpcap = device.remote_opts.remote_host_opts.nocap_rpcap;
|
||||||
|
interface_opts.nocap_local = device.remote_opts.remote_host_opts.nocap_local;
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_PCAP_SETSAMPLING
|
||||||
|
interface_opts.sampling_method = device.remote_opts.sampling_method;
|
||||||
|
interface_opts.sampling_param = device.remote_opts.sampling_param;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
g_array_append_val(capture_opts->ifaces, interface_opts);
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* HAVE_LIBPCAP */
|
#endif /* HAVE_LIBPCAP */
|
||||||
|
|
|
@ -77,6 +77,73 @@ typedef enum {
|
||||||
} capture_sampling;
|
} capture_sampling;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
IF_WIRED,
|
||||||
|
IF_AIRPCAP,
|
||||||
|
IF_PIPE,
|
||||||
|
IF_STDIN,
|
||||||
|
IF_BLUETOOTH,
|
||||||
|
IF_WIRELESS,
|
||||||
|
IF_DIALUP,
|
||||||
|
IF_USB,
|
||||||
|
IF_VIRTUAL
|
||||||
|
} interface_type;
|
||||||
|
|
||||||
|
#ifdef HAVE_PCAP_REMOTE
|
||||||
|
struct remote_host {
|
||||||
|
gchar *remote_host; /**< Host name or network address for remote capturing */
|
||||||
|
gchar *remote_port; /**< TCP port of remote RPCAP server */
|
||||||
|
gint auth_type; /**< Authentication type */
|
||||||
|
gchar *auth_username; /**< Remote authentication parameters */
|
||||||
|
gchar *auth_password; /**< Remote authentication parameters */
|
||||||
|
gboolean datatx_udp;
|
||||||
|
gboolean nocap_rpcap;
|
||||||
|
gboolean nocap_local;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct remote_options_tag {
|
||||||
|
capture_source src_type;
|
||||||
|
struct remote_host remote_host_opts;
|
||||||
|
#ifdef HAVE_PCAP_SETSAMPLING
|
||||||
|
capture_sampling sampling_method;
|
||||||
|
int sampling_param;
|
||||||
|
#endif
|
||||||
|
} remote_options;
|
||||||
|
#endif /* HAVE_PCAP_REMOTE */
|
||||||
|
|
||||||
|
typedef struct interface_tag {
|
||||||
|
gchar *name;
|
||||||
|
gchar *display_name;
|
||||||
|
guint type;
|
||||||
|
gchar *addresses;
|
||||||
|
gint no_addresses;
|
||||||
|
gchar *cfilter;
|
||||||
|
GList *links;
|
||||||
|
gint active_dlt;
|
||||||
|
gboolean pmode;
|
||||||
|
gboolean has_snaplen;
|
||||||
|
guint snaplen;
|
||||||
|
gboolean local;
|
||||||
|
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||||
|
gint buffer;
|
||||||
|
gboolean monitor_mode_enabled;
|
||||||
|
gboolean monitor_mode_supported;
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_PCAP_REMOTE
|
||||||
|
remote_options remote_opts;
|
||||||
|
#endif
|
||||||
|
guint32 last_packets;
|
||||||
|
if_info_t if_info;
|
||||||
|
gboolean selected;
|
||||||
|
gboolean hidden;
|
||||||
|
gboolean locked;
|
||||||
|
} interface_t;
|
||||||
|
|
||||||
|
typedef struct link_row_tag {
|
||||||
|
gchar *name;
|
||||||
|
gint dlt;
|
||||||
|
} link_row;
|
||||||
|
|
||||||
typedef struct interface_options_tag {
|
typedef struct interface_options_tag {
|
||||||
gchar *name;
|
gchar *name;
|
||||||
gchar *descr;
|
gchar *descr;
|
||||||
|
@ -112,6 +179,8 @@ typedef struct capture_options_tag {
|
||||||
void *cf; /**< handle to cfile (note: untyped handle) */
|
void *cf; /**< handle to cfile (note: untyped handle) */
|
||||||
GArray *ifaces; /**< array of interfaces.
|
GArray *ifaces; /**< array of interfaces.
|
||||||
Currently only used by dumpcap. */
|
Currently only used by dumpcap. */
|
||||||
|
GArray *all_ifaces;
|
||||||
|
guint num_selected;
|
||||||
interface_options default_options;
|
interface_options default_options;
|
||||||
gboolean saving_to_file; /**< TRUE if capture is writing to a file */
|
gboolean saving_to_file; /**< TRUE if capture is writing to a file */
|
||||||
gchar *save_file; /**< the capture file name */
|
gchar *save_file; /**< the capture file name */
|
||||||
|
@ -169,6 +238,9 @@ capture_opts_init(capture_options *capture_opts, void *cf);
|
||||||
extern int
|
extern int
|
||||||
capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, gboolean *start_capture);
|
capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, gboolean *start_capture);
|
||||||
|
|
||||||
|
extern int
|
||||||
|
capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str_p);
|
||||||
|
|
||||||
/* log content of capture_opts */
|
/* log content of capture_opts */
|
||||||
extern void
|
extern void
|
||||||
capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts);
|
capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts);
|
||||||
|
@ -194,6 +266,24 @@ capture_opts_trim_ring_num_files(capture_options *capture_opts);
|
||||||
extern gboolean
|
extern gboolean
|
||||||
capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device);
|
capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device);
|
||||||
|
|
||||||
|
extern void
|
||||||
|
collect_ifaces(capture_options *capture_opts);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
gboolean monitor_mode;
|
||||||
|
int linktype;
|
||||||
|
} cap_settings_t;
|
||||||
|
|
||||||
|
/** Get capture settings for interface
|
||||||
|
*
|
||||||
|
* @param if_name interface name
|
||||||
|
*/
|
||||||
|
cap_settings_t
|
||||||
|
capture_get_cap_settings (gchar *if_name);
|
||||||
|
|
||||||
|
extern void
|
||||||
|
scan_local_interfaces(capture_options* capture_opts, int *error);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
|
@ -463,9 +463,11 @@ sync_pipe_start(capture_options *capture_opts) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_PCAP_CREATE
|
||||||
if (interface_opts.monitor_mode) {
|
if (interface_opts.monitor_mode) {
|
||||||
argv = sync_pipe_add_arg(argv, &argc, "-I");
|
argv = sync_pipe_add_arg(argv, &argc, "-I");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
#ifdef HAVE_PCAP_REMOTE
|
||||||
if (interface_opts.datatx_udp)
|
if (interface_opts.datatx_udp)
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#include "epan/ex-opt.h"
|
#include "epan/ex-opt.h"
|
||||||
#include "capture_ifinfo.h"
|
#include "capture_ifinfo.h"
|
||||||
#include "capture_ui_utils.h"
|
#include "capture_ui_utils.h"
|
||||||
|
#include "ui/simple_dialog.h"
|
||||||
|
#include "wiretap/wtap.h"
|
||||||
|
#include "epan/to_str.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find user-specified capture device description that matches interface
|
* Find user-specified capture device description that matches interface
|
||||||
|
|
1
tshark.c
1
tshark.c
|
@ -95,6 +95,7 @@
|
||||||
#endif /* HAVE_LIBPCAP */
|
#endif /* HAVE_LIBPCAP */
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include <epan/funnel.h>
|
#include <epan/funnel.h>
|
||||||
|
#include "capture_opts.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the template for the decode as option; it is shared between the
|
* This is the template for the decode as option; it is shared between the
|
||||||
|
|
1294
ui/gtk/capture_dlg.c
1294
ui/gtk/capture_dlg.c
File diff suppressed because it is too large
Load Diff
|
@ -32,60 +32,12 @@
|
||||||
* @ingroup dialog_group
|
* @ingroup dialog_group
|
||||||
*/
|
*/
|
||||||
#include "capture_opts.h"
|
#include "capture_opts.h"
|
||||||
|
#include <gtk/gtk.h>
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
|
||||||
struct remote_host {
|
|
||||||
gchar *remote_host; /**< Host name or network address for remote capturing */
|
|
||||||
gchar *remote_port; /**< TCP port of remote RPCAP server */
|
|
||||||
gint auth_type; /**< Authentication type */
|
|
||||||
gchar *auth_username; /**< Remote authentication parameters */
|
|
||||||
gchar *auth_password; /**< Remote authentication parameters */
|
|
||||||
gboolean datatx_udp;
|
|
||||||
gboolean nocap_rpcap;
|
|
||||||
gboolean nocap_local;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct remote_options_tag {
|
|
||||||
capture_source src_type;
|
|
||||||
struct remote_host remote_host_opts;
|
|
||||||
#ifdef HAVE_PCAP_SETSAMPLING
|
|
||||||
capture_sampling sampling_method;
|
|
||||||
int sampling_param;
|
|
||||||
#endif
|
|
||||||
} remote_options;
|
|
||||||
#endif /* HAVE_PCAP_REMOTE */
|
|
||||||
|
|
||||||
typedef struct row_options_tag {
|
|
||||||
gchar *name;
|
|
||||||
gchar *display_name;
|
|
||||||
gchar *addresses;
|
|
||||||
gint no_addresses;
|
|
||||||
gchar *cfilter;
|
|
||||||
GList *links;
|
|
||||||
gint active_dlt;
|
|
||||||
gboolean pmode;
|
|
||||||
#ifdef HAVE_PCAP_CREATE
|
|
||||||
gboolean monitor_mode_enabled;
|
|
||||||
gboolean monitor_mode_supported;
|
|
||||||
#endif
|
|
||||||
gboolean has_snaplen;
|
|
||||||
guint snaplen;
|
|
||||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
|
||||||
gint buffer;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
|
||||||
remote_options remote_opts;
|
|
||||||
#endif
|
|
||||||
} interface_row;
|
|
||||||
|
|
||||||
typedef struct link_row_tag {
|
|
||||||
gchar *name;
|
|
||||||
gint dlt;
|
|
||||||
} link_row;
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
CAPTURE = 0,
|
CAPTURE = 0,
|
||||||
|
IFACE_HIDDEN_NAME,
|
||||||
INTERFACE,
|
INTERFACE,
|
||||||
LINK,
|
LINK,
|
||||||
PMODE,
|
PMODE,
|
||||||
|
@ -143,6 +95,7 @@ void capture_start_confirmed(void);
|
||||||
void
|
void
|
||||||
capture_air_cb(GtkWidget *widget, gpointer data);
|
capture_air_cb(GtkWidget *widget, gpointer data);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* We remember the capture settings for each interface when a capture
|
* We remember the capture settings for each interface when a capture
|
||||||
* is started on it; the next time we select that interface we start
|
* is started on it; the next time we select that interface we start
|
||||||
|
@ -163,6 +116,7 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
cap_settings_t
|
cap_settings_t
|
||||||
capture_get_cap_settings (gchar *if_name);
|
capture_get_cap_settings (gchar *if_name);
|
||||||
|
#endif
|
||||||
|
|
||||||
GtkTreeModel*
|
GtkTreeModel*
|
||||||
create_and_fill_model (GtkTreeView *view);
|
create_and_fill_model (GtkTreeView *view);
|
||||||
|
@ -183,9 +137,12 @@ gboolean
|
||||||
dlg_window_present(void);
|
dlg_window_present(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
enable_selected_interface(gchar *name, gboolean enable);
|
enable_selected_interface(gchar *name, gboolean selected);
|
||||||
|
|
||||||
void
|
void
|
||||||
options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata);
|
options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata);
|
||||||
|
|
||||||
|
void
|
||||||
|
update_all_rows(void);
|
||||||
|
|
||||||
#endif /* capture_dlg.h */
|
#endif /* capture_dlg.h */
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "ui/gtk/capture_if_details_dlg_win32.h"
|
#include "ui/gtk/capture_if_details_dlg_win32.h"
|
||||||
|
#include "../../capture-wpcap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ui/gtk/stock_icons.h"
|
#include "ui/gtk/stock_icons.h"
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
#include "ui/gtk/webbrowser.h"
|
#include "ui/gtk/webbrowser.h"
|
||||||
#include "ui/gtk/capture_globals.h"
|
#include "ui/gtk/capture_globals.h"
|
||||||
#include "ui/gtk/network_icons.h"
|
#include "ui/gtk/network_icons.h"
|
||||||
|
#include "ui/gtk/pipe_icon.h"
|
||||||
#include "ui/gtk/main_welcome.h"
|
#include "ui/gtk/main_welcome.h"
|
||||||
#include "ui/gtk/menus.h"
|
#include "ui/gtk/menus.h"
|
||||||
|
|
||||||
|
@ -109,15 +111,13 @@
|
||||||
*/
|
*/
|
||||||
static GtkWidget *cap_if_w;
|
static GtkWidget *cap_if_w;
|
||||||
|
|
||||||
static GList *if_data_list = NULL;
|
|
||||||
|
|
||||||
static guint timer_id;
|
static guint timer_id;
|
||||||
|
|
||||||
static GtkWidget *stop_bt, *capture_bt, *options_bt;
|
static GtkWidget *stop_bt, *capture_bt, *options_bt;
|
||||||
|
|
||||||
static GList *if_list;
|
static GList *if_list;
|
||||||
|
|
||||||
static guint currently_selected = 0;
|
static GArray *gtk_list;
|
||||||
|
|
||||||
static if_stat_cache_t *sc;
|
static if_stat_cache_t *sc;
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ static if_stat_cache_t *sc;
|
||||||
|
|
||||||
/* the "runtime" data of one interface */
|
/* the "runtime" data of one interface */
|
||||||
typedef struct if_dlg_data_s {
|
typedef struct if_dlg_data_s {
|
||||||
|
gchar *device;
|
||||||
GtkWidget *device_lb;
|
GtkWidget *device_lb;
|
||||||
GtkWidget *descr_lb;
|
GtkWidget *descr_lb;
|
||||||
GtkWidget *ip_lb;
|
GtkWidget *ip_lb;
|
||||||
|
@ -138,125 +139,62 @@ typedef struct if_dlg_data_s {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
GtkWidget *details_bt;
|
GtkWidget *details_bt;
|
||||||
#endif
|
#endif
|
||||||
guint32 last_packets;
|
|
||||||
gchar *device;
|
|
||||||
if_info_t if_info;
|
|
||||||
gboolean selected;
|
|
||||||
} if_dlg_data_t;
|
} if_dlg_data_t;
|
||||||
|
|
||||||
static gboolean gbl_capture_in_progress = FALSE;
|
static gboolean gbl_capture_in_progress = FALSE;
|
||||||
|
|
||||||
void
|
void
|
||||||
update_selected_interface(gchar *name, gboolean activate)
|
update_selected_interface(gchar *name)
|
||||||
{
|
{
|
||||||
guint ifs;
|
guint i;
|
||||||
GList *curr;
|
interface_t device;
|
||||||
if_dlg_data_t *temp;
|
if_dlg_data_t data;
|
||||||
|
|
||||||
for (ifs = 0; ifs < g_list_length(if_data_list); ifs++) {
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||||
curr = g_list_nth(if_data_list, ifs);
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||||
temp = (if_dlg_data_t *)(curr->data);
|
data = g_array_index(gtk_list, if_dlg_data_t, i);
|
||||||
if (strcmp(name, temp->if_info.name) == 0) {
|
if (strcmp(name, device.name) == 0) {
|
||||||
if (activate) {
|
gtk_toggle_button_set_active((GtkToggleButton *)data.choose_bt, device.selected);
|
||||||
gtk_toggle_button_set_active((GtkToggleButton *)temp->choose_bt, TRUE);
|
|
||||||
} else {
|
|
||||||
gtk_toggle_button_set_active((GtkToggleButton *)temp->choose_bt, FALSE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
store_selected(GtkWidget *choose_bt, gpointer if_data)
|
store_selected(GtkWidget *choose_bt, gpointer name)
|
||||||
{
|
{
|
||||||
if_dlg_data_t *if_dlg_data = (if_dlg_data_t *)if_data, *temp;
|
interface_t device;
|
||||||
GList *curr;
|
guint i;
|
||||||
unsigned int ifs, i;
|
|
||||||
gboolean found;
|
gboolean found;
|
||||||
cap_settings_t cap_settings;
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||||
interface_options interface_opts;
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||||
|
|
||||||
for (ifs = 0; ifs < g_list_length(if_data_list); ifs++) {
|
|
||||||
curr = g_list_nth(if_data_list, ifs);
|
|
||||||
temp = (if_dlg_data_t *)(curr->data);
|
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
if (strcmp(if_dlg_data->if_info.name, temp->if_info.name) == 0) {
|
if (strcmp(name, device.if_info.name) == 0) {
|
||||||
temp->selected ^=1;
|
found = TRUE;
|
||||||
if_data_list = g_list_remove(if_data_list, curr->data);
|
if (!device.locked) {
|
||||||
if_data_list = g_list_insert(if_data_list, temp, ifs);
|
device.selected ^= 1;
|
||||||
|
if (device.selected) {
|
||||||
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
|
global_capture_opts.num_selected++;
|
||||||
if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, temp->if_info.name) == 0) {
|
} else {
|
||||||
found = TRUE;
|
global_capture_opts.num_selected--;
|
||||||
if (!temp->selected) {
|
|
||||||
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
|
|
||||||
global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
|
|
||||||
if (gtk_widget_is_focus(choose_bt) && get_welcome_window()) {
|
|
||||||
change_interface_selection(interface_opts.name, FALSE);
|
|
||||||
}
|
|
||||||
if (gtk_widget_is_focus(choose_bt) && dlg_window_present()) {
|
|
||||||
enable_selected_interface(interface_opts.name, FALSE);
|
|
||||||
}
|
|
||||||
g_free(interface_opts.name);
|
|
||||||
g_free(interface_opts.descr);
|
|
||||||
g_free(interface_opts.cfilter);
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
|
||||||
g_free(interface_opts.remote_host);
|
|
||||||
g_free(interface_opts.remote_port);
|
|
||||||
g_free(interface_opts.auth_username);
|
|
||||||
g_free(interface_opts.auth_password);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
|
||||||
if (!found && temp->selected) {
|
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
|
||||||
interface_opts.name = g_strdup(temp->if_info.name);
|
if (gtk_widget_is_focus(choose_bt) && get_welcome_window()) {
|
||||||
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
|
change_interface_selection(device.name, device.selected);
|
||||||
interface_opts.linktype = capture_dev_user_linktype_find(interface_opts.name);
|
|
||||||
interface_opts.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
|
|
||||||
interface_opts.has_snaplen = global_capture_opts.default_options.has_snaplen;
|
|
||||||
interface_opts.snaplen = global_capture_opts.default_options.snaplen;
|
|
||||||
cap_settings = capture_get_cap_settings (interface_opts.name);;
|
|
||||||
interface_opts.promisc_mode = global_capture_opts.default_options.promisc_mode;
|
|
||||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
|
||||||
interface_opts.buffer_size = global_capture_opts.default_options.buffer_size;
|
|
||||||
#endif
|
|
||||||
interface_opts.monitor_mode = cap_settings.monitor_mode;
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
|
||||||
interface_opts.src_type = global_capture_opts.default_options.src_type;
|
|
||||||
interface_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host);
|
|
||||||
interface_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port);
|
|
||||||
interface_opts.auth_type = global_capture_opts.default_options.auth_type;
|
|
||||||
interface_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username);
|
|
||||||
interface_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password);
|
|
||||||
interface_opts.datatx_udp = global_capture_opts.default_options.datatx_udp;
|
|
||||||
interface_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap;
|
|
||||||
interface_opts.nocap_local = global_capture_opts.default_options.nocap_local;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_PCAP_SETSAMPLING
|
|
||||||
interface_opts.sampling_method = global_capture_opts.default_options.sampling_method;
|
|
||||||
interface_opts.sampling_param = global_capture_opts.default_options.sampling_param;
|
|
||||||
#endif
|
|
||||||
g_array_append_val(global_capture_opts.ifaces, interface_opts);
|
|
||||||
if (gtk_widget_is_focus(choose_bt) && get_welcome_window() != NULL) {
|
|
||||||
change_interface_selection(g_strdup(temp->if_info.name), TRUE);
|
|
||||||
}
|
}
|
||||||
if (gtk_widget_is_focus(choose_bt) && dlg_window_present()) {
|
if (gtk_widget_is_focus(choose_bt) && dlg_window_present()) {
|
||||||
enable_selected_interface(interface_opts.name, TRUE);
|
enable_selected_interface(device.name, device.selected);
|
||||||
}
|
}
|
||||||
|
device.locked = FALSE;
|
||||||
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
|
||||||
|
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temp->selected)
|
|
||||||
currently_selected += 1;
|
|
||||||
else
|
|
||||||
currently_selected -= 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cap_if_w) {
|
if (cap_if_w) {
|
||||||
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (currently_selected > 0));
|
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (global_capture_opts.num_selected > 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,19 +206,18 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
|
||||||
capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data _U_)
|
capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data _U_)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if_dlg_data_t *temp;
|
if_dlg_data_t data;
|
||||||
GList *curr;
|
guint ifs;
|
||||||
int ifs;
|
|
||||||
|
for (ifs = 0; ifs < gtk_list->len; ifs++) {
|
||||||
|
data = g_array_index(gtk_list, if_dlg_data_t, ifs);
|
||||||
|
gtk_widget_set_sensitive(data.choose_bt, FALSE);
|
||||||
|
gtk_list = g_array_remove_index(gtk_list, ifs);
|
||||||
|
g_array_insert_val(gtk_list, ifs, data);
|
||||||
#ifdef HAVE_AIRPCAP
|
#ifdef HAVE_AIRPCAP
|
||||||
if_dlg_data_t *if_dlg_data = if_data;
|
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, gtk_label_get_text(GTK_LABEL(data.device_lb)));
|
||||||
|
airpcap_if_selected = airpcap_if_active;
|
||||||
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, if_dlg_data->if_info.name);
|
|
||||||
airpcap_if_selected = airpcap_if_active;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (ifs = 0; (curr = g_list_nth(if_data_list, ifs)); ifs++) {
|
|
||||||
temp = (if_dlg_data_t *)(curr->data);
|
|
||||||
gtk_widget_set_sensitive(temp->choose_bt, FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX - remove this? */
|
/* XXX - remove this? */
|
||||||
|
@ -326,11 +263,14 @@ capture_details_cb(GtkWidget *details_bt _U_, gpointer if_data)
|
||||||
|
|
||||||
/* update a single interface */
|
/* update a single interface */
|
||||||
static void
|
static void
|
||||||
update_if(if_dlg_data_t *if_dlg_data, if_stat_cache_t *sc)
|
update_if(gchar *name, if_stat_cache_t *sc)
|
||||||
{
|
{
|
||||||
struct pcap_stat stats;
|
struct pcap_stat stats;
|
||||||
gchar *str;
|
gchar *str;
|
||||||
guint diff;
|
guint diff, ifs;
|
||||||
|
interface_t device;
|
||||||
|
if_dlg_data_t data;
|
||||||
|
gboolean found = FALSE;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -341,23 +281,40 @@ update_if(if_dlg_data_t *if_dlg_data, if_stat_cache_t *sc)
|
||||||
* That's a bug, and should be fixed; "pcap_stats()" is supposed
|
* That's a bug, and should be fixed; "pcap_stats()" is supposed
|
||||||
* to work the same way on all platforms.
|
* to work the same way on all platforms.
|
||||||
*/
|
*/
|
||||||
|
device.last_packets = 0;
|
||||||
|
data.curr_lb = NULL;
|
||||||
|
data.last_lb = NULL;
|
||||||
if (sc) {
|
if (sc) {
|
||||||
if (capture_stats(sc, if_dlg_data->device, &stats)) {
|
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||||
diff = stats.ps_recv - if_dlg_data->last_packets;
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||||
if_dlg_data->last_packets = stats.ps_recv;
|
data = g_array_index(gtk_list, if_dlg_data_t, ifs);
|
||||||
|
if (!device.hidden && strcmp(name, device.name) == 0) {
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
if (capture_stats(sc, name, &stats)) {
|
||||||
|
diff = stats.ps_recv - device.last_packets;
|
||||||
|
device.last_packets = stats.ps_recv;
|
||||||
|
|
||||||
str = g_strdup_printf("%u", if_dlg_data->last_packets);
|
str = g_strdup_printf("%u", device.last_packets);
|
||||||
gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), str);
|
gtk_label_set_text(GTK_LABEL(data.curr_lb), str);
|
||||||
g_free(str);
|
g_free(str);
|
||||||
str = g_strdup_printf("%u", diff);
|
str = g_strdup_printf("%u", diff);
|
||||||
gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), str);
|
gtk_label_set_text(GTK_LABEL(data.last_lb), str);
|
||||||
g_free(str);
|
g_free(str);
|
||||||
|
|
||||||
gtk_widget_set_sensitive(if_dlg_data->curr_lb, diff);
|
gtk_widget_set_sensitive(data.curr_lb, diff);
|
||||||
gtk_widget_set_sensitive(if_dlg_data->last_lb, diff);
|
gtk_widget_set_sensitive(data.last_lb, diff);
|
||||||
} else {
|
} else {
|
||||||
gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error");
|
gtk_label_set_text(GTK_LABEL(data.curr_lb), "error");
|
||||||
gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error");
|
gtk_label_set_text(GTK_LABEL(data.last_lb), "error");
|
||||||
|
}
|
||||||
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, ifs);
|
||||||
|
g_array_insert_val(global_capture_opts.all_ifaces, ifs, device);
|
||||||
|
gtk_list = g_array_remove_index(gtk_list, ifs);
|
||||||
|
g_array_insert_val(gtk_list, ifs, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,19 +323,20 @@ update_if(if_dlg_data_t *if_dlg_data, if_stat_cache_t *sc)
|
||||||
static gboolean
|
static gboolean
|
||||||
update_all(gpointer data)
|
update_all(gpointer data)
|
||||||
{
|
{
|
||||||
GList *curr;
|
interface_t device;
|
||||||
int ifs;
|
guint ifs;
|
||||||
if_stat_cache_t *sc = (if_stat_cache_t *)data;
|
if_stat_cache_t *sc = data;
|
||||||
|
|
||||||
if (!cap_if_w) {
|
if (!cap_if_w) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ifs = 0; (curr = g_list_nth(if_data_list, ifs)); ifs++) {
|
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||||
update_if((if_dlg_data_t *)curr->data, sc);
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||||
}
|
update_if(device.name, sc);
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a live capture has started or stopped */
|
/* a live capture has started or stopped */
|
||||||
|
@ -388,7 +346,7 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
|
||||||
gbl_capture_in_progress = capture_in_progress;
|
gbl_capture_in_progress = capture_in_progress;
|
||||||
if (cap_if_w) {
|
if (cap_if_w) {
|
||||||
gtk_widget_set_sensitive(stop_bt, capture_in_progress);
|
gtk_widget_set_sensitive(stop_bt, capture_in_progress);
|
||||||
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (currently_selected > 0));
|
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (global_capture_opts.num_selected > 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,26 +355,17 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
|
||||||
static void
|
static void
|
||||||
capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||||
{
|
{
|
||||||
GList *curr;
|
g_source_remove(timer_id);
|
||||||
int ifs;
|
|
||||||
|
|
||||||
g_source_remove(timer_id);
|
free_interface_list(if_list);
|
||||||
|
|
||||||
for (ifs = 0; (curr = g_list_nth(if_data_list, ifs)); ifs++) {
|
/* Note that we no longer have a "Capture Options" dialog box. */
|
||||||
g_free(curr->data);
|
cap_if_w = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if_data_list = NULL;
|
capture_stat_stop(sc);
|
||||||
|
|
||||||
free_interface_list(if_list);
|
|
||||||
|
|
||||||
/* Note that we no longer have a "Capture Options" dialog box. */
|
|
||||||
cap_if_w = NULL;
|
|
||||||
|
|
||||||
capture_stat_stop(sc);
|
|
||||||
|
|
||||||
#ifdef HAVE_AIRPCAP
|
#ifdef HAVE_AIRPCAP
|
||||||
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,127 +389,38 @@ gint if_list_comparator_alph (const void *first_arg, const void *second_arg){
|
||||||
* Used to retrieve the interface icon.
|
* Used to retrieve the interface icon.
|
||||||
* This is hideously platform-dependent.
|
* This is hideously platform-dependent.
|
||||||
*/
|
*/
|
||||||
GtkWidget * capture_get_if_icon(const if_info_t* if_info)
|
GtkWidget * capture_get_if_icon(interface_t *device)
|
||||||
{
|
{
|
||||||
#if defined(__linux__)
|
|
||||||
ws_statb64 statb;
|
|
||||||
char *wireless_path;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
#ifdef HAVE_PCAP_REMOTE
|
||||||
if (if_info->description && strstr(if_info->description, "on remote node") != NULL ) {
|
if (!device->local) {
|
||||||
return pixbuf_to_widget(remote_sat_pb_data);
|
return pixbuf_to_widget(remote_sat_pb_data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32)
|
switch (device->type) {
|
||||||
/*
|
#ifdef _WIN32
|
||||||
* Much digging failed to reveal any obvious way to get something such
|
case IF_DIALUP:
|
||||||
* as the SNMP MIB-II ifType value for an interface:
|
|
||||||
*
|
|
||||||
* http://www.iana.org/assignments/ianaiftype-mib
|
|
||||||
*
|
|
||||||
* by making some NDIS request.
|
|
||||||
*/
|
|
||||||
if ( if_info->description && ( strstr(if_info->description,"generic dialup") != NULL ||
|
|
||||||
strstr(if_info->description,"PPP/SLIP") != NULL ) ) {
|
|
||||||
return xpm_to_widget(modem_16_xpm);
|
return xpm_to_widget(modem_16_xpm);
|
||||||
}
|
|
||||||
|
|
||||||
if ( if_info->description && ( strstr(if_info->description,"Wireless") != NULL ||
|
|
||||||
strstr(if_info->description,"802.11") != NULL || strstr(if_info->description,"AirPcap") != NULL ) ) {
|
|
||||||
return pixbuf_to_widget(network_wireless_pb_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( strstr(if_info->name,"airpcap") != NULL ) {
|
|
||||||
return pixbuf_to_widget(network_wireless_pb_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( if_info->description && strstr(if_info->description, "Bluetooth") != NULL ) {
|
|
||||||
return pixbuf_to_widget(network_bluetooth_pb_data);
|
|
||||||
}
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
/*
|
|
||||||
* XXX - yes, fetching all the network addresses for an interface
|
|
||||||
* gets you an AF_LINK address, of type "struct sockaddr_dl", and,
|
|
||||||
* yes, that includes an SNMP MIB-II ifType value.
|
|
||||||
*
|
|
||||||
* However, it's IFT_ETHER, i.e. Ethernet, for AirPort interfaces,
|
|
||||||
* not IFT_IEEE80211 (which isn't defined in OS X in any case).
|
|
||||||
*
|
|
||||||
* Perhaps some other BSD-flavored OSes won't make this mistake;
|
|
||||||
* however, FreeBSD 7.0 and OpenBSD 4.2, at least, appear to have
|
|
||||||
* made the same mistake, at least for my Belkin ZyDAS stick.
|
|
||||||
*
|
|
||||||
* On Mac OS X, one might be able to get the information one wants from
|
|
||||||
* IOKit.
|
|
||||||
*/
|
|
||||||
if ( strcmp(if_info->name, "en1") == 0) {
|
|
||||||
return pixbuf_to_widget(network_wireless_pb_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX - PPP devices have names beginning with "ppp" and an IFT_ of
|
|
||||||
* IFT_PPP, but they could be dial-up, or PPPoE, or mobile phone modem,
|
|
||||||
* or VPN, or... devices. One might have to dive into the bowels of
|
|
||||||
* IOKit to find out.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX - there's currently no support for raw Bluetooth capture,
|
|
||||||
* and IP-over-Bluetooth devices just look like fake Ethernet
|
|
||||||
* devices. There's also Bluetooth modem support, but that'll
|
|
||||||
* probably just give you a device that looks like a PPP device.
|
|
||||||
*/
|
|
||||||
#elif defined(__linux__)
|
|
||||||
/*
|
|
||||||
* Look for /sys/class/net/{device}/wireless.
|
|
||||||
*/
|
|
||||||
wireless_path = g_strdup_printf("/sys/class/net/%s/wireless", if_info->name);
|
|
||||||
if (wireless_path != NULL) {
|
|
||||||
if (ws_stat64(wireless_path, &statb) == 0) {
|
|
||||||
g_free(wireless_path);
|
|
||||||
return pixbuf_to_widget(network_wireless_pb_data);
|
|
||||||
}
|
|
||||||
g_free(wireless_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Bluetooth devices.
|
|
||||||
*
|
|
||||||
* XXX - this is for raw Bluetooth capture; what about IP-over-Bluetooth
|
|
||||||
* devices?
|
|
||||||
*/
|
|
||||||
if ( strstr(if_info->name,"bluetooth") != NULL) {
|
|
||||||
return pixbuf_to_widget(network_bluetooth_pb_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* USB devices.
|
|
||||||
*/
|
|
||||||
if ( strstr(if_info->name,"usbmon") != NULL ) {
|
|
||||||
return pixbuf_to_widget(network_usb_pb_data);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
case IF_WIRELESS:
|
||||||
/*
|
return pixbuf_to_widget(network_wireless_pb_data);
|
||||||
* TODO: find a better icon!
|
#ifdef HAVE_AIRPCAP
|
||||||
* Bridge, NAT, or host-only interfaces on VMWare hosts have the name
|
case IF_AIRPCAP:
|
||||||
* vmnet[0-9]+ or VMnet[0-9+ on Windows. Guests might use a native
|
return xpm_to_widget(capture_airpcap_16_xpm);
|
||||||
* (LANCE or E1000) driver or the vmxnet driver. These devices have an
|
#endif
|
||||||
* IFT_ of IFT_ETHER, so we have to check the name.
|
case IF_BLUETOOTH:
|
||||||
*/
|
return pixbuf_to_widget(network_bluetooth_pb_data);
|
||||||
if ( g_ascii_strncasecmp(if_info->name, "vmnet", 5) == 0) {
|
case IF_USB:
|
||||||
|
return pixbuf_to_widget(network_usb_pb_data);
|
||||||
|
case IF_VIRTUAL:
|
||||||
return xpm_to_widget(network_virtual_16_xpm);
|
return xpm_to_widget(network_virtual_16_xpm);
|
||||||
|
case IF_WIRED:
|
||||||
|
return pixbuf_to_widget(network_wired_pb_data);
|
||||||
|
case IF_PIPE:
|
||||||
|
case IF_STDIN:
|
||||||
|
return pixbuf_to_widget(pipe_pb_data);
|
||||||
|
default:
|
||||||
|
printf("unknown device type\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( g_ascii_strncasecmp(if_info->name, "vmxnet", 6) == 0) {
|
|
||||||
return xpm_to_widget(network_virtual_16_xpm);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( if_info->description && strstr(if_info->description, "VMware") != NULL ) {
|
|
||||||
return xpm_to_widget(network_virtual_16_xpm);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pixbuf_to_widget(network_wired_pb_data);
|
return pixbuf_to_widget(network_wired_pb_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,17 +552,40 @@ static void
|
||||||
capture_if_stop_cb(GtkWidget *w _U_, gpointer d _U_)
|
capture_if_stop_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
{
|
{
|
||||||
guint ifs;
|
guint ifs;
|
||||||
GList *curr;
|
if_dlg_data_t data;
|
||||||
if_dlg_data_t *if_data;
|
|
||||||
|
|
||||||
for (ifs = 0; ifs < g_list_length(if_data_list); ifs++) {
|
for (ifs = 0; ifs < gtk_list->len; ifs++) {
|
||||||
curr = g_list_nth(if_data_list, ifs);
|
data = g_array_index(gtk_list, if_dlg_data_t, ifs);
|
||||||
if_data = (if_dlg_data_t *)(curr->data);
|
gtk_widget_set_sensitive(data.choose_bt, TRUE);
|
||||||
gtk_widget_set_sensitive(if_data->choose_bt, TRUE);
|
gtk_list = g_array_remove_index(gtk_list, ifs);
|
||||||
|
g_array_insert_val(gtk_list, ifs, data);
|
||||||
}
|
}
|
||||||
capture_stop_cb(NULL, NULL);
|
capture_stop_cb(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
make_gtk_array(void)
|
||||||
|
{
|
||||||
|
interface_t device;
|
||||||
|
if_dlg_data_t data;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
gtk_list = g_array_new(FALSE, FALSE, sizeof(if_dlg_data_t));
|
||||||
|
|
||||||
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||||
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||||
|
data.device_lb = NULL;
|
||||||
|
data.descr_lb = NULL;
|
||||||
|
data.ip_lb = NULL;
|
||||||
|
data.curr_lb = NULL;
|
||||||
|
data.last_lb = NULL;
|
||||||
|
data.choose_bt = NULL;
|
||||||
|
#ifdef _WIN32
|
||||||
|
data.details_bt = NULL;
|
||||||
|
#endif
|
||||||
|
g_array_append_val(gtk_list, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* start getting capture stats from all interfaces */
|
/* start getting capture stats from all interfaces */
|
||||||
void
|
void
|
||||||
|
@ -712,75 +595,53 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
*main_sw,
|
*main_sw,
|
||||||
*bbox,
|
*bbox,
|
||||||
*close_bt,
|
*close_bt,
|
||||||
*help_bt,
|
*help_bt;
|
||||||
*icon;
|
|
||||||
|
|
||||||
#ifdef HAVE_AIRPCAP
|
#ifdef HAVE_AIRPCAP
|
||||||
GtkWidget *decryption_cb;
|
GtkWidget *decryption_cb;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GtkWidget *if_tb;
|
GtkWidget *if_tb, *icon;
|
||||||
GtkWidget *if_lb;
|
GtkWidget *if_lb;
|
||||||
GtkWidget *eb;
|
GtkWidget *eb;
|
||||||
int err;
|
|
||||||
gchar *err_str;
|
|
||||||
GtkRequisition requisition;
|
GtkRequisition requisition;
|
||||||
int row, height;
|
int row, height;
|
||||||
if_dlg_data_t *if_dlg_data = NULL;
|
guint ifs;
|
||||||
int ifs;
|
interface_t device;
|
||||||
GList *curr;
|
|
||||||
if_info_t *if_info;
|
|
||||||
GString *if_tool_str = g_string_new("");
|
GString *if_tool_str = g_string_new("");
|
||||||
const gchar *addr_str;
|
const gchar *addr_str;
|
||||||
gchar *user_descr;
|
gchar *user_descr;
|
||||||
int preselected = 0, i;
|
if_dlg_data_t data;
|
||||||
interface_options interface_opts;
|
|
||||||
gboolean found = FALSE;
|
|
||||||
|
|
||||||
if (cap_if_w != NULL) {
|
if (cap_if_w != NULL) {
|
||||||
/* There's already a "Capture Interfaces" dialog box; reactivate it. */
|
/* There's already a "Capture Interfaces" dialog box; reactivate it. */
|
||||||
reactivate_window(cap_if_w);
|
reactivate_window(cap_if_w);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
preselected = global_capture_opts.ifaces->len;
|
if (global_capture_opts.all_ifaces->len == 0) {
|
||||||
/* LOAD THE INTERFACES */
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||||
if_list = capture_interface_list(&err, &err_str);
|
"There are no interfaces on which a capture can be done.");
|
||||||
if_list = g_list_sort (if_list, if_list_comparator_alph);
|
|
||||||
if (if_list == NULL) {
|
|
||||||
switch (err) {
|
|
||||||
|
|
||||||
case CANT_GET_INTERFACE_LIST:
|
|
||||||
case DONT_HAVE_PCAP:
|
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
|
||||||
g_free(err_str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NO_INTERFACES_FOUND:
|
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
||||||
"There are no interfaces on which a capture can be done.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* Is WPcap loaded? */
|
||||||
|
if (!has_wpcap) {
|
||||||
|
char *detailed_err;
|
||||||
|
|
||||||
|
detailed_err = cant_load_winpcap_err("Wireshark");
|
||||||
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", detailed_err);
|
||||||
|
g_free(detailed_err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_AIRPCAP
|
#ifdef HAVE_AIRPCAP
|
||||||
/* LOAD AIRPCAP INTERFACES */
|
/* LOAD AIRPCAP INTERFACES */
|
||||||
airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
|
|
||||||
if (airpcap_if_list == NULL)
|
|
||||||
airpcap_if_active = airpcap_if_selected = NULL;
|
|
||||||
|
|
||||||
decryption_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
decryption_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
||||||
update_decryption_mode_list(decryption_cb);
|
update_decryption_mode_list(decryption_cb);
|
||||||
|
|
||||||
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
|
|
||||||
#if 0
|
|
||||||
/* XXX - Do we need to show an error here? */
|
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
|
||||||
#endif
|
|
||||||
g_free(err_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If no airpcap interface is present, gray everything */
|
/* If no airpcap interface is present, gray everything */
|
||||||
if (airpcap_if_active == NULL) {
|
if (airpcap_if_active == NULL) {
|
||||||
if (airpcap_if_list == NULL) {
|
if (airpcap_if_list == NULL) {
|
||||||
|
@ -796,6 +657,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
make_gtk_array();
|
||||||
cap_if_w = dlg_window_new("Wireshark: Capture Interfaces"); /* transient_for top_level */
|
cap_if_w = dlg_window_new("Wireshark: Capture Interfaces"); /* transient_for top_level */
|
||||||
gtk_window_set_destroy_with_parent (GTK_WINDOW(cap_if_w), TRUE);
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(cap_if_w), TRUE);
|
||||||
|
|
||||||
|
@ -843,144 +705,111 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
|
|
||||||
height += 30;
|
height += 30;
|
||||||
/* Start gathering statistics (using dumpcap) */
|
/* Start gathering statistics (using dumpcap) */
|
||||||
sc = capture_stat_start(if_list);
|
sc = capture_stat_start(&global_capture_opts);
|
||||||
|
|
||||||
/* List the interfaces */
|
/* List the interfaces */
|
||||||
currently_selected = 0;
|
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||||
for (ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) {
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||||
|
data = g_array_index(gtk_list, if_dlg_data_t, ifs);
|
||||||
g_string_assign(if_tool_str, "");
|
g_string_assign(if_tool_str, "");
|
||||||
if_info = (if_info_t *)curr->data;
|
|
||||||
|
|
||||||
/* Continue if capture device is hidden */
|
/* Continue if capture device is hidden */
|
||||||
if (prefs_is_capture_device_hidden(if_info->name)) {
|
if (device.hidden) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
data.choose_bt = gtk_check_button_new();
|
||||||
if_dlg_data = g_new0(if_dlg_data_t,1);
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.choose_bt, 0, 1, row, row+1);
|
||||||
|
|
||||||
if (preselected > 0) {
|
|
||||||
found = FALSE;
|
|
||||||
for (i = 0; i < (gint)global_capture_opts.ifaces->len; i++) {
|
|
||||||
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
|
|
||||||
if ((interface_opts.name == NULL) ||
|
|
||||||
(strcmp(interface_opts.name, (char*)if_info->name) != 0)) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
found = TRUE;
|
|
||||||
currently_selected++;
|
|
||||||
preselected--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if_dlg_data->selected = found;
|
|
||||||
} else {
|
|
||||||
if_dlg_data->selected = FALSE;
|
|
||||||
}
|
|
||||||
if_dlg_data->if_info = *if_info;
|
|
||||||
|
|
||||||
if_dlg_data->choose_bt = gtk_check_button_new();
|
|
||||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->choose_bt, 0, 1, row, row+1);
|
|
||||||
if (gbl_capture_in_progress) {
|
if (gbl_capture_in_progress) {
|
||||||
gtk_widget_set_sensitive(if_dlg_data->choose_bt, FALSE);
|
gtk_widget_set_sensitive(data.choose_bt, FALSE);
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_set_sensitive(if_dlg_data->choose_bt, TRUE);
|
gtk_widget_set_sensitive(data.choose_bt, TRUE);
|
||||||
}
|
}
|
||||||
gtk_toggle_button_set_active((GtkToggleButton *)if_dlg_data->choose_bt, if_dlg_data->selected);
|
gtk_toggle_button_set_active((GtkToggleButton *)data.choose_bt, device.selected);
|
||||||
g_signal_connect(if_dlg_data->choose_bt, "toggled", G_CALLBACK(store_selected), if_dlg_data);
|
g_signal_connect(data.choose_bt, "toggled", G_CALLBACK(store_selected), device.name);
|
||||||
/* Kind of adaptor (icon) */
|
/* Kind of adaptor (icon) */
|
||||||
#ifdef HAVE_AIRPCAP
|
icon = capture_get_if_icon(&(device));
|
||||||
if (get_airpcap_if_from_name(airpcap_if_list,if_info->name) != NULL)
|
|
||||||
icon = xpm_to_widget(capture_airpcap_16_xpm);
|
|
||||||
else
|
|
||||||
icon = capture_get_if_icon(if_info);
|
|
||||||
#else
|
|
||||||
icon = capture_get_if_icon(if_info);
|
|
||||||
#endif
|
|
||||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 1, 2, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 1, 2, row, row+1);
|
||||||
|
|
||||||
/* device name */
|
/* device name */
|
||||||
if_dlg_data->device_lb = gtk_label_new(if_info->name);
|
data.device_lb = gtk_label_new(device.name);
|
||||||
if_dlg_data->device = if_info->name;
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
gtk_misc_set_alignment(GTK_MISC(if_dlg_data->device_lb), 0.0f, 0.5f);
|
gtk_misc_set_alignment(GTK_MISC(data.device_lb), 0.0f, 0.5f);
|
||||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 2, 4, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.device_lb, 2, 4, row, row+1);
|
||||||
#endif
|
#endif
|
||||||
g_string_append(if_tool_str, "Device: ");
|
g_string_append(if_tool_str, "Device: ");
|
||||||
g_string_append(if_tool_str, if_info->name);
|
g_string_append(if_tool_str, device.name);
|
||||||
g_string_append(if_tool_str, "\n");
|
g_string_append(if_tool_str, "\n");
|
||||||
|
|
||||||
/* description */
|
/* description */
|
||||||
user_descr = capture_dev_user_descr_find(if_info->name);
|
user_descr = capture_dev_user_descr_find(device.name);
|
||||||
if (user_descr) {
|
if (user_descr) {
|
||||||
if_dlg_data->descr_lb = gtk_label_new(user_descr);
|
data.descr_lb = gtk_label_new(user_descr);
|
||||||
g_free (user_descr);
|
g_free (user_descr);
|
||||||
} else {
|
} else {
|
||||||
if (if_info->description)
|
if (device.if_info.description)
|
||||||
if_dlg_data->descr_lb = gtk_label_new(if_info->description);
|
data.descr_lb = gtk_label_new(device.if_info.description);
|
||||||
else
|
else
|
||||||
if_dlg_data->descr_lb = gtk_label_new("");
|
data.descr_lb = gtk_label_new("");
|
||||||
}
|
}
|
||||||
gtk_misc_set_alignment(GTK_MISC(if_dlg_data->descr_lb), 0.0f, 0.5f);
|
gtk_misc_set_alignment(GTK_MISC(data.descr_lb), 0.0f, 0.5f);
|
||||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 4, 5, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.descr_lb, 4, 5, row, row+1);
|
||||||
|
if (device.if_info.description) {
|
||||||
if (if_info->description) {
|
|
||||||
g_string_append(if_tool_str, "Description: ");
|
g_string_append(if_tool_str, "Description: ");
|
||||||
g_string_append(if_tool_str, if_info->description);
|
g_string_append(if_tool_str, device.if_info.description);
|
||||||
g_string_append(if_tool_str, "\n");
|
g_string_append(if_tool_str, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IP address */
|
/* IP address */
|
||||||
/* Only one IP address will be shown, start with the first */
|
/* Only one IP address will be shown, start with the first */
|
||||||
g_string_append(if_tool_str, "IP: ");
|
g_string_append(if_tool_str, "IP: ");
|
||||||
if_dlg_data->ip_lb = gtk_label_new("");
|
data.ip_lb = gtk_label_new("");
|
||||||
addr_str = set_ip_addr_label (if_info->addrs, if_dlg_data->ip_lb, 0);
|
addr_str = set_ip_addr_label (device.if_info.addrs, data.ip_lb, 0);
|
||||||
if (addr_str) {
|
if (addr_str) {
|
||||||
gtk_widget_set_sensitive(if_dlg_data->ip_lb, TRUE);
|
gtk_widget_set_sensitive(data.ip_lb, TRUE);
|
||||||
g_string_append(if_tool_str, addr_str);
|
g_string_append(if_tool_str, addr_str);
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
|
gtk_widget_set_sensitive(data.ip_lb, FALSE);
|
||||||
g_string_append(if_tool_str, "none");
|
g_string_append(if_tool_str, "none");
|
||||||
}
|
}
|
||||||
eb = gtk_event_box_new ();
|
eb = gtk_event_box_new ();
|
||||||
gtk_container_add(GTK_CONTAINER(eb), if_dlg_data->ip_lb);
|
gtk_container_add(GTK_CONTAINER(eb), data.ip_lb);
|
||||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), eb, 5, 6, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), eb, 5, 6, row, row+1);
|
||||||
if (get_ip_addr_count(if_info->addrs) > 1) {
|
if (get_ip_addr_count(device.if_info.addrs) > 1) {
|
||||||
/* More than one IP address, make it possible to toggle */
|
/* More than one IP address, make it possible to toggle */
|
||||||
g_object_set_data(G_OBJECT(eb), CAPTURE_IF_IP_ADDR_LABEL, if_dlg_data->ip_lb);
|
g_object_set_data(G_OBJECT(eb), CAPTURE_IF_IP_ADDR_LABEL, data.ip_lb);
|
||||||
g_signal_connect(eb, "enter-notify-event", G_CALLBACK(ip_label_enter_cb), NULL);
|
g_signal_connect(eb, "enter-notify-event", G_CALLBACK(ip_label_enter_cb), NULL);
|
||||||
g_signal_connect(eb, "leave-notify-event", G_CALLBACK(ip_label_leave_cb), NULL);
|
g_signal_connect(eb, "leave-notify-event", G_CALLBACK(ip_label_leave_cb), NULL);
|
||||||
g_signal_connect(eb, "button-press-event", G_CALLBACK(ip_label_press_cb), if_info->addrs);
|
g_signal_connect(eb, "button-press-event", G_CALLBACK(ip_label_press_cb), device.if_info.addrs);
|
||||||
}
|
}
|
||||||
g_string_append(if_tool_str, "\n");
|
g_string_append(if_tool_str, "\n");
|
||||||
|
|
||||||
/* packets */
|
/* packets */
|
||||||
if_dlg_data->curr_lb = gtk_label_new("-");
|
data.curr_lb = gtk_label_new("-");
|
||||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 6, 7, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.curr_lb, 6, 7, row, row+1);
|
||||||
|
|
||||||
/* packets/s */
|
/* packets/s */
|
||||||
if_dlg_data->last_lb = gtk_label_new("-");
|
data.last_lb = gtk_label_new("-");
|
||||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 7, 8, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.last_lb, 7, 8, row, row+1);
|
||||||
|
|
||||||
/* details button */
|
/* details button */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if_dlg_data->details_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_DETAILS);
|
data.details_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_DETAILS);
|
||||||
gtk_widget_set_tooltip_text(if_dlg_data->details_bt, "Open the capture details dialog of this interface.");
|
gtk_widget_set_tooltip_text(data.details_bt, "Open the capture details dialog of this interface.");
|
||||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->details_bt, 8, 9, row, row+1);
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.details_bt, 8, 9, row, row+1);
|
||||||
if (capture_if_has_details(if_dlg_data->device)) {
|
if (capture_if_has_details(device.name)) {
|
||||||
g_signal_connect(if_dlg_data->details_bt, "clicked", G_CALLBACK(capture_details_cb), if_dlg_data);
|
g_signal_connect(data.details_bt, "clicked", G_CALLBACK(capture_details_cb), device.name);
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_set_sensitive(if_dlg_data->details_bt, FALSE);
|
gtk_widget_set_sensitive(data.details_bt, FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
gtk_list = g_array_remove_index(gtk_list, ifs);
|
||||||
if_data_list = g_list_append(if_data_list, if_dlg_data);
|
g_array_insert_val(gtk_list, ifs, data);
|
||||||
|
|
||||||
row++;
|
row++;
|
||||||
if (row <= 10) {
|
if (row <= 10) {
|
||||||
/* Lets add up 10 rows of interfaces, otherwise the window may become too high */
|
/* Lets add up 10 rows of interfaces, otherwise the window may become too high */
|
||||||
gtk_widget_get_preferred_size(GTK_WIDGET(if_dlg_data->choose_bt), &requisition, NULL);
|
gtk_widget_get_preferred_size(GTK_WIDGET(data.choose_bt), &requisition, NULL);
|
||||||
height += requisition.height;
|
height += requisition.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_free(if_tool_str, TRUE);
|
g_string_free(if_tool_str, TRUE);
|
||||||
|
@ -998,9 +827,9 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||||
window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb);
|
window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb);
|
||||||
gtk_widget_set_tooltip_text(close_bt, "Close this window.");
|
gtk_widget_set_tooltip_text(close_bt, "Close this window.");
|
||||||
options_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_OPTIONS);
|
options_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_OPTIONS);
|
||||||
g_signal_connect(options_bt, "clicked", G_CALLBACK(capture_prepare_cb), if_dlg_data);
|
g_signal_connect(options_bt, "clicked", G_CALLBACK(capture_prepare_cb), device.name);
|
||||||
capture_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
|
capture_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
|
||||||
g_signal_connect(capture_bt, "clicked", G_CALLBACK(capture_do_cb), if_dlg_data);
|
g_signal_connect(capture_bt, "clicked", G_CALLBACK(capture_do_cb), device.name);
|
||||||
gtk_widget_get_preferred_size(GTK_WIDGET(close_bt), &requisition, NULL);
|
gtk_widget_get_preferred_size(GTK_WIDGET(close_bt), &requisition, NULL);
|
||||||
/* height + static offset + what the GTK MS Windows Engine needs in addition per interface */
|
/* height + static offset + what the GTK MS Windows Engine needs in addition per interface */
|
||||||
height += requisition.height + 40 + ifs;
|
height += requisition.height + 40 + ifs;
|
||||||
|
@ -1031,17 +860,15 @@ void refresh_if_window(void)
|
||||||
capture_if_cb(NULL, NULL);
|
capture_if_cb(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void select_all_interfaces(gboolean enable)
|
void select_all_interfaces(gboolean enable _U_)
|
||||||
{
|
{
|
||||||
if_dlg_data_t *temp;
|
|
||||||
guint ifs;
|
guint ifs;
|
||||||
GList *curr;
|
interface_t device;
|
||||||
|
|
||||||
for (ifs = 0; ifs < g_list_length(if_data_list); ifs++) {
|
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||||
curr = g_list_nth(if_data_list, ifs);
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||||
temp = (if_dlg_data_t *)(curr->data);
|
update_selected_interface(device.if_info.name);
|
||||||
update_selected_interface(temp->if_info.name, enable);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy_if_window(void)
|
void destroy_if_window(void)
|
||||||
|
|
|
@ -48,10 +48,10 @@ capture_if_cb(GtkWidget *widget, gpointer data);
|
||||||
* Used to retrieve the interface icon
|
* Used to retrieve the interface icon
|
||||||
*/
|
*/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
capture_get_if_icon(const if_info_t* if_info);
|
capture_get_if_icon(interface_t *device);
|
||||||
|
|
||||||
void
|
void
|
||||||
update_selected_interface(gchar *name, gboolean activate);
|
update_selected_interface(gchar *name);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
interfaces_dialog_window_present(void);
|
interfaces_dialog_window_present(void);
|
||||||
|
@ -65,6 +65,9 @@ select_all_interfaces(gboolean enable);
|
||||||
void
|
void
|
||||||
destroy_if_window(void);
|
destroy_if_window(void);
|
||||||
|
|
||||||
|
gint
|
||||||
|
if_list_comparator_alph (const void *first_arg, const void *second_arg);
|
||||||
|
|
||||||
#endif /* HAVE_LIBPCAP */
|
#endif /* HAVE_LIBPCAP */
|
||||||
|
|
||||||
#endif /* capture_if_dlg.h */
|
#endif /* capture_if_dlg.h */
|
||||||
|
|
1186
ui/gtk/main.c
1186
ui/gtk/main.c
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,7 @@
|
||||||
#define __MAIN_H__
|
#define __MAIN_H__
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "capture_opts.h"
|
||||||
|
|
||||||
/** @defgroup main_window_group Main window
|
/** @defgroup main_window_group Main window
|
||||||
* The main window has the following submodules:
|
* The main window has the following submodules:
|
||||||
|
@ -332,10 +333,10 @@ extern gboolean main_filter_packets(capture_file *cf, const gchar *dftext,
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/** Win32 only: Create a console. Beware: cannot be closed again. */
|
/** Win32 only: Create a console. Beware: cannot be closed again. */
|
||||||
extern void create_console(void);
|
extern void create_console(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Restart the tap update display timer with new configured interval */
|
/** Restart the tap update display timer with new configured interval */
|
||||||
extern void reset_tap_update_timer(void);
|
extern void reset_tap_update_timer(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Fill in capture options with values from the preferences */
|
/** Fill in capture options with values from the preferences */
|
||||||
extern void prefs_to_capture_opts(void);
|
extern void prefs_to_capture_opts(void);
|
||||||
|
@ -351,4 +352,7 @@ extern GList *get_ip_address_list_from_packet_list_row(gpointer data);
|
||||||
|
|
||||||
extern GtkWidget *pkt_scrollw;
|
extern GtkWidget *pkt_scrollw;
|
||||||
|
|
||||||
|
void hide_interface(gchar* new_hide);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __MAIN_H__ */
|
#endif /* __MAIN_H__ */
|
||||||
|
|
|
@ -86,8 +86,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* XXX */
|
/* XXX */
|
||||||
extern gint if_list_comparator_alph (const void *first_arg, const void *second_arg);
|
|
||||||
|
|
||||||
static GtkWidget *welcome_hb = NULL;
|
static GtkWidget *welcome_hb = NULL;
|
||||||
static GtkWidget *header_lb = NULL;
|
static GtkWidget *header_lb = NULL;
|
||||||
/* Foreground colors are set using Pango markup */
|
/* Foreground colors are set using Pango markup */
|
||||||
|
@ -108,10 +106,8 @@ static GdkColor topic_item_entered_bg = { 0, 0xd3d3, 0xd8d8, 0xdada };
|
||||||
#endif
|
#endif
|
||||||
static GtkWidget *welcome_file_panel_vb = NULL;
|
static GtkWidget *welcome_file_panel_vb = NULL;
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
static GtkWidget *welcome_if_panel_vb = NULL;
|
|
||||||
static GtkWidget *if_view = NULL;
|
static GtkWidget *if_view = NULL;
|
||||||
static GtkWidget *swindow;
|
static GtkWidget *swindow;
|
||||||
static GArray *interfaces = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static GSList *status_messages = NULL;
|
static GSList *status_messages = NULL;
|
||||||
|
@ -214,9 +210,9 @@ static gboolean
|
||||||
welcome_item_enter_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
|
welcome_item_enter_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_entered_bg);
|
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_entered_bg);
|
||||||
#else
|
#else
|
||||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_entered_bg);
|
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_entered_bg);
|
||||||
#endif
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +223,7 @@ static gboolean
|
||||||
welcome_item_leave_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
|
welcome_item_leave_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
|
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
|
||||||
#else
|
#else
|
||||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
|
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -254,12 +250,12 @@ welcome_button(const gchar *stock_item,
|
||||||
eb = gtk_event_box_new();
|
eb = gtk_event_box_new();
|
||||||
gtk_container_add(GTK_CONTAINER(eb), item_hb);
|
gtk_container_add(GTK_CONTAINER(eb), item_hb);
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
|
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
|
||||||
#else
|
#else
|
||||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
|
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
|
||||||
#endif
|
#endif
|
||||||
if(tooltip != NULL) {
|
if(tooltip != NULL) {
|
||||||
gtk_widget_set_tooltip_text(eb, tooltip);
|
gtk_widget_set_tooltip_text(eb, tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect(eb, "enter-notify-event", G_CALLBACK(welcome_item_enter_cb), NULL);
|
g_signal_connect(eb, "enter-notify-event", G_CALLBACK(welcome_item_enter_cb), NULL);
|
||||||
|
@ -352,7 +348,7 @@ welcome_header_new(void)
|
||||||
eb = gtk_event_box_new();
|
eb = gtk_event_box_new();
|
||||||
gtk_container_add(GTK_CONTAINER(eb), item_vb);
|
gtk_container_add(GTK_CONTAINER(eb), item_vb);
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_header_bar_bg);
|
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_header_bar_bg);
|
||||||
#else
|
#else
|
||||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &header_bar_bg);
|
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &header_bar_bg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -360,7 +356,7 @@ welcome_header_new(void)
|
||||||
gtk_box_pack_start(GTK_BOX(item_vb), item_hb, FALSE, FALSE, 10);
|
gtk_box_pack_start(GTK_BOX(item_vb), item_hb, FALSE, FALSE, 10);
|
||||||
|
|
||||||
/*icon = xpm_to_widget_from_parent(top_level, wssplash_xpm);*/
|
/*icon = xpm_to_widget_from_parent(top_level, wssplash_xpm);*/
|
||||||
icon = xpm_to_widget(wssplash_xpm);
|
icon = xpm_to_widget(wssplash_xpm);
|
||||||
gtk_box_pack_start(GTK_BOX(item_hb), icon, FALSE, FALSE, 10);
|
gtk_box_pack_start(GTK_BOX(item_hb), icon, FALSE, FALSE, 10);
|
||||||
|
|
||||||
header_lb = gtk_label_new(NULL);
|
header_lb = gtk_label_new(NULL);
|
||||||
|
@ -426,7 +422,7 @@ welcome_topic_header_new(const char *header)
|
||||||
eb = gtk_event_box_new();
|
eb = gtk_event_box_new();
|
||||||
gtk_container_add(GTK_CONTAINER(eb), w);
|
gtk_container_add(GTK_CONTAINER(eb), w);
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_header_bg);
|
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_header_bg);
|
||||||
#else
|
#else
|
||||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_header_bg);
|
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_header_bg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -457,7 +453,7 @@ welcome_topic_new(const char *header, GtkWidget **to_fill)
|
||||||
topic_eb = gtk_event_box_new();
|
topic_eb = gtk_event_box_new();
|
||||||
gtk_container_add(GTK_CONTAINER(topic_eb), topic_vb);
|
gtk_container_add(GTK_CONTAINER(topic_eb), topic_vb);
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_override_background_color(topic_eb, GTK_STATE_NORMAL, &rgba_topic_content_bg);
|
gtk_widget_override_background_color(topic_eb, GTK_STATE_NORMAL, &rgba_topic_content_bg);
|
||||||
#else
|
#else
|
||||||
gtk_widget_modify_bg(topic_eb, GTK_STATE_NORMAL, &topic_content_bg);
|
gtk_widget_modify_bg(topic_eb, GTK_STATE_NORMAL, &topic_content_bg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -572,16 +568,16 @@ static void welcome_filename_destroy_cb(GtkWidget *w _U_, gpointer data) {
|
||||||
|
|
||||||
g_mutex_lock(recent_mtx);
|
g_mutex_lock(recent_mtx);
|
||||||
if (ri_stat->timer) {
|
if (ri_stat->timer) {
|
||||||
g_source_remove(ri_stat->timer);
|
g_source_remove(ri_stat->timer);
|
||||||
ri_stat->timer = 0;
|
ri_stat->timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref(ri_stat->menu_item);
|
g_object_unref(ri_stat->menu_item);
|
||||||
|
|
||||||
if (ri_stat->stat_done) {
|
if (ri_stat->stat_done) {
|
||||||
g_free(ri_stat->filename);
|
g_free(ri_stat->filename);
|
||||||
g_string_free(ri_stat->str, TRUE);
|
g_string_free(ri_stat->str, TRUE);
|
||||||
g_free(ri_stat);
|
g_free(ri_stat);
|
||||||
} else {
|
} else {
|
||||||
ri_stat->label = NULL;
|
ri_stat->label = NULL;
|
||||||
}
|
}
|
||||||
|
@ -709,22 +705,22 @@ static gboolean select_current_ifaces(GtkTreeModel *model,
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
gchar *if_name;
|
gchar *if_name;
|
||||||
gboolean found = FALSE;
|
interface_t device;
|
||||||
|
|
||||||
GtkTreeSelection *selection = (GtkTreeSelection *)userdata;
|
GtkTreeSelection *selection = (GtkTreeSelection *)userdata;
|
||||||
|
device.name = NULL;
|
||||||
gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
|
gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
|
||||||
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||||
if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, if_name) == 0) {
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||||
if (!gtk_tree_selection_path_is_selected(selection, path)) {
|
if (strcmp(device.name, if_name) == 0) {
|
||||||
gtk_tree_selection_select_iter(selection, iter);
|
if (device.selected && !gtk_tree_selection_path_is_selected(selection, path)) {
|
||||||
|
gtk_tree_selection_select_iter(selection, iter);
|
||||||
|
} else {
|
||||||
|
gtk_tree_selection_unselect_iter(selection, iter);
|
||||||
}
|
}
|
||||||
found = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
|
||||||
gtk_tree_selection_unselect_iter(selection, iter);
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,127 +732,69 @@ gboolean on_selection_changed(GtkTreeSelection *selection _U_,
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gchar *if_name;
|
gchar *if_name;
|
||||||
interface_options interface_opts;
|
guint i;
|
||||||
guint i, j;
|
interface_t device;
|
||||||
cap_settings_t cap_settings;
|
|
||||||
gboolean found = FALSE;
|
|
||||||
displayed_interface d_interface;
|
|
||||||
|
|
||||||
d_interface.name = NULL;
|
|
||||||
d_interface.descr = NULL;
|
|
||||||
gtk_tree_model_get_iter (model, &iter, path);
|
gtk_tree_model_get_iter (model, &iter, path);
|
||||||
gtk_tree_model_get (model, &iter, IFACE_NAME, &if_name, -1);
|
gtk_tree_model_get (model, &iter, IFACE_NAME, &if_name, -1);
|
||||||
if (global_capture_opts.ifaces->len > 0) {
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||||
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||||
if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, if_name) == 0) {
|
if (strcmp(device.name, if_name) == 0) {
|
||||||
found = TRUE;
|
if (!device.locked) {
|
||||||
if (path_currently_selected) {
|
if (path_currently_selected) {
|
||||||
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
|
if (device.selected) {
|
||||||
global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
|
device.selected = FALSE;
|
||||||
if (gtk_widget_is_focus(g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES)) && interfaces_dialog_window_present()) {
|
device.locked = TRUE;
|
||||||
update_selected_interface(g_strdup(interface_opts.name), FALSE);
|
global_capture_opts.num_selected--;
|
||||||
}
|
}
|
||||||
if (gtk_widget_is_focus(g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES)) && dlg_window_present()) {
|
|
||||||
enable_selected_interface(interface_opts.name, FALSE);
|
|
||||||
}
|
|
||||||
g_free(interface_opts.name);
|
|
||||||
g_free(interface_opts.descr);
|
|
||||||
g_free(interface_opts.cfilter);
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
|
||||||
g_free(interface_opts.remote_host);
|
|
||||||
g_free(interface_opts.remote_port);
|
|
||||||
g_free(interface_opts.auth_username);
|
|
||||||
g_free(interface_opts.auth_password);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found && !path_currently_selected) {
|
|
||||||
for (j = 0; j < interfaces->len; j++) {
|
|
||||||
d_interface = g_array_index(interfaces, displayed_interface, j);
|
|
||||||
if (strcmp(d_interface.name, if_name) == 0) {
|
|
||||||
interface_opts.name = g_strdup(d_interface.name);
|
|
||||||
interface_opts.descr = g_strdup(d_interface.descr);
|
|
||||||
interface_opts.linktype = capture_dev_user_linktype_find(interface_opts.name);
|
|
||||||
interface_opts.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
|
|
||||||
interface_opts.has_snaplen = global_capture_opts.default_options.has_snaplen;
|
|
||||||
interface_opts.snaplen = global_capture_opts.default_options.snaplen;
|
|
||||||
cap_settings = capture_get_cap_settings (interface_opts.name);;
|
|
||||||
interface_opts.promisc_mode = global_capture_opts.default_options.promisc_mode;
|
|
||||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
|
||||||
interface_opts.buffer_size = global_capture_opts.default_options.buffer_size;
|
|
||||||
#endif
|
|
||||||
interface_opts.monitor_mode = cap_settings.monitor_mode;
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
|
||||||
if (d_interface.remote_opts.src_type == CAPTURE_IFREMOTE) {
|
|
||||||
interface_opts.src_type = d_interface.remote_opts.src_type;
|
|
||||||
interface_opts.remote_host = g_strdup(d_interface.remote_opts.remote_host_opts.remote_host);
|
|
||||||
interface_opts.remote_port = g_strdup(d_interface.remote_opts.remote_host_opts.remote_port);
|
|
||||||
interface_opts.auth_type = d_interface.remote_opts.remote_host_opts.auth_type;
|
|
||||||
interface_opts.auth_username = g_strdup(d_interface.remote_opts.remote_host_opts.auth_username);
|
|
||||||
interface_opts.auth_password = g_strdup(d_interface.remote_opts.remote_host_opts.auth_password);
|
|
||||||
interface_opts.datatx_udp = d_interface.remote_opts.remote_host_opts.datatx_udp;
|
|
||||||
interface_opts.nocap_rpcap = d_interface.remote_opts.remote_host_opts.nocap_rpcap;
|
|
||||||
interface_opts.nocap_local = d_interface.remote_opts.remote_host_opts.nocap_local;
|
|
||||||
#ifdef HAVE_PCAP_SETSAMPLING
|
|
||||||
interface_opts.sampling_method = d_interface.remote_opts.sampling_method;
|
|
||||||
interface_opts.sampling_param = d_interface.remote_opts.sampling_param;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
interface_opts.src_type = global_capture_opts.default_options.src_type;
|
if (!device.selected) {
|
||||||
interface_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host);
|
device.selected = TRUE;
|
||||||
interface_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port);
|
device.locked = TRUE;
|
||||||
interface_opts.auth_type = global_capture_opts.default_options.auth_type;
|
global_capture_opts.num_selected++;
|
||||||
interface_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username);
|
}
|
||||||
interface_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password);
|
|
||||||
interface_opts.datatx_udp = global_capture_opts.default_options.datatx_udp;
|
|
||||||
interface_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap;
|
|
||||||
interface_opts.nocap_local = global_capture_opts.default_options.nocap_local;
|
|
||||||
#ifdef HAVE_PCAP_SETSAMPLING
|
|
||||||
interface_opts.sampling_method = global_capture_opts.default_options.sampling_method;
|
|
||||||
interface_opts.sampling_param = global_capture_opts.default_options.sampling_param;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
|
||||||
|
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
|
||||||
|
|
||||||
g_array_append_val(global_capture_opts.ifaces, interface_opts);
|
if (dlg_window_present()) {
|
||||||
if (gtk_widget_is_focus(g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES)) && interfaces_dialog_window_present()) {
|
enable_selected_interface(g_strdup(if_name), device.selected);
|
||||||
update_selected_interface(g_strdup(interface_opts.name), TRUE);
|
|
||||||
}
|
}
|
||||||
if (gtk_widget_is_focus(g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES)) && dlg_window_present()) {
|
if (interfaces_dialog_window_present()) {
|
||||||
enable_selected_interface(interface_opts.name, TRUE);
|
update_selected_interface(g_strdup(if_name));
|
||||||
}
|
}
|
||||||
break;
|
device.locked = FALSE;
|
||||||
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
|
||||||
|
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean activate_ifaces(GtkTreeModel *model,
|
static gboolean activate_ifaces(GtkTreeModel *model,
|
||||||
GtkTreePath *path _U_,
|
GtkTreePath *path _U_,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
gpointer userdata)
|
gpointer userdata)
|
||||||
{
|
{
|
||||||
gchar *if_name;
|
gchar *if_name;
|
||||||
GtkWidget *view;
|
GtkWidget *view;
|
||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
selected_name_t *entry = (selected_name_t *)userdata;
|
selected_name_t *entry = (selected_name_t *)userdata;
|
||||||
|
|
||||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||||
gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
|
gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
|
||||||
if (strcmp(if_name, entry->name) == 0) {
|
if (strcmp(if_name, entry->name) == 0) {
|
||||||
if (entry->activate) {
|
if (entry->activate) {
|
||||||
gtk_tree_selection_select_iter(selection, iter);
|
gtk_tree_selection_select_iter(selection, iter);
|
||||||
} else {
|
} else {
|
||||||
gtk_tree_selection_unselect_iter(selection, iter);
|
gtk_tree_selection_unselect_iter(selection, iter);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void change_interface_selection(gchar* name, gboolean activate)
|
void change_interface_selection(gchar* name, gboolean activate)
|
||||||
|
@ -874,13 +812,11 @@ void change_interface_selection(gchar* name, gboolean activate)
|
||||||
|
|
||||||
void change_selection_for_all(gboolean enable)
|
void change_selection_for_all(gboolean enable)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (interfaces) {
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||||
for (i = 0; i < interfaces->len; i++) {
|
change_interface_selection(g_array_index(global_capture_opts.all_ifaces, interface_t, i).name, enable);
|
||||||
change_interface_selection(g_array_index(interfaces, displayed_interface, i).name, enable);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -892,7 +828,7 @@ select_ifaces(void)
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeSelection *entry;
|
GtkTreeSelection *entry;
|
||||||
|
|
||||||
if (global_capture_opts.ifaces->len > 0 && swindow) {
|
if (global_capture_opts.num_selected > 0 && swindow) {
|
||||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
|
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
|
||||||
entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||||
|
@ -904,40 +840,24 @@ select_ifaces(void)
|
||||||
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
#ifdef HAVE_PCAP_REMOTE
|
||||||
void
|
void
|
||||||
add_interface_to_list(gchar *name, gchar *descr, remote_options *remote_opts)
|
add_interface_to_list(guint index)
|
||||||
{
|
{
|
||||||
GtkWidget *view, *icon;
|
GtkWidget *view, *icon;
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gint size;
|
gint size;
|
||||||
gchar *lines;
|
gchar *lines;
|
||||||
displayed_interface d_interface;
|
interface_t device;
|
||||||
|
|
||||||
d_interface.name = g_strdup(name);
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, index);
|
||||||
d_interface.descr = g_strdup(descr);
|
|
||||||
d_interface.remote_opts.src_type = remote_opts->src_type;
|
|
||||||
d_interface.remote_opts.remote_host_opts.remote_host = g_strdup(remote_opts->remote_host_opts.remote_host);
|
|
||||||
d_interface.remote_opts.remote_host_opts.remote_port = g_strdup(remote_opts->remote_host_opts.remote_port);
|
|
||||||
d_interface.remote_opts.remote_host_opts.auth_type = remote_opts->remote_host_opts.auth_type;
|
|
||||||
d_interface.remote_opts.remote_host_opts.auth_username = g_strdup(remote_opts->remote_host_opts.auth_username);
|
|
||||||
d_interface.remote_opts.remote_host_opts.auth_password = g_strdup(remote_opts->remote_host_opts.auth_password);
|
|
||||||
d_interface.remote_opts.remote_host_opts.datatx_udp = remote_opts->remote_host_opts.datatx_udp;
|
|
||||||
d_interface.remote_opts.remote_host_opts.nocap_rpcap = remote_opts->remote_host_opts.nocap_rpcap;
|
|
||||||
d_interface.remote_opts.remote_host_opts.nocap_local = remote_opts->remote_host_opts.nocap_local;
|
|
||||||
#ifdef HAVE_PCAP_SETSAMPLING
|
|
||||||
d_interface.remote_opts.sampling_method = remote_opts->sampling_method;
|
|
||||||
d_interface.remote_opts.sampling_param = remote_opts->sampling_param;
|
|
||||||
#endif
|
|
||||||
icon = pixbuf_to_widget(remote_sat_pb_data);
|
icon = pixbuf_to_widget(remote_sat_pb_data);
|
||||||
d_interface.icon = icon;
|
|
||||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
|
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
|
||||||
size = gtk_tree_model_iter_n_children(model, NULL);
|
size = gtk_tree_model_iter_n_children(model, NULL);
|
||||||
lines = g_strdup_printf("%d", size-1);
|
lines = g_strdup_printf("%d", size-1);
|
||||||
g_array_append_val(interfaces, d_interface);
|
|
||||||
if (gtk_tree_model_get_iter_from_string(model, &iter, lines)) {
|
if (gtk_tree_model_get_iter_from_string(model, &iter, lines)) {
|
||||||
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
|
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
|
||||||
gtk_list_store_set(GTK_LIST_STORE(model), &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, descr, IFACE_NAME, name, -1);
|
gtk_list_store_set(GTK_LIST_STORE(model), &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, device.display_name, IFACE_NAME, device.name, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -947,92 +867,41 @@ void
|
||||||
welcome_if_tree_load(void)
|
welcome_if_tree_load(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
if_info_t *if_info;
|
|
||||||
GList *if_list;
|
|
||||||
int err;
|
|
||||||
guint i;
|
guint i;
|
||||||
gchar *err_str = NULL;
|
|
||||||
GList *curr;
|
|
||||||
gchar *user_descr;
|
|
||||||
GtkListStore *store = NULL;
|
GtkListStore *store = NULL;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkWidget *icon, *view;
|
GtkWidget *view;
|
||||||
GtkTreeSelection *entry;
|
GtkTreeSelection *entry;
|
||||||
displayed_interface d_interface;
|
interface_t device;
|
||||||
|
gboolean changed = FALSE;
|
||||||
|
int error;
|
||||||
|
|
||||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||||
entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||||
gtk_tree_selection_unselect_all(entry);
|
gtk_tree_selection_unselect_all(entry);
|
||||||
store = gtk_list_store_new(NUMCOLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
|
store = gtk_list_store_new(NUMCOLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
|
||||||
|
|
||||||
|
gtk_list_store_clear(store);
|
||||||
|
gtk_tree_view_set_model(GTK_TREE_VIEW(if_view), GTK_TREE_MODEL (store));
|
||||||
/* LOAD THE INTERFACES */
|
/* LOAD THE INTERFACES */
|
||||||
if (interfaces && interfaces->len > 0) {
|
if (global_capture_opts.all_ifaces->len == 0) {
|
||||||
for (i = 0; i < interfaces->len; i++) {
|
scan_local_interfaces(&global_capture_opts, &error);
|
||||||
d_interface = g_array_index(interfaces, displayed_interface, i);
|
|
||||||
gtk_list_store_append (store, &iter);
|
|
||||||
gtk_list_store_set (store, &iter, ICON, d_interface.icon, IFACE_DESCR, d_interface.descr, IFACE_NAME, d_interface.name, -1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
interfaces = g_array_new(TRUE, TRUE, sizeof(displayed_interface));
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||||
if_list = capture_interface_list(&err, &err_str);
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||||
if_list = g_list_sort (if_list, if_list_comparator_alph);
|
if (!device.hidden) {
|
||||||
if (if_list == NULL &&
|
|
||||||
(err == CANT_GET_INTERFACE_LIST || err == DONT_HAVE_PCAP)) {
|
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
|
||||||
g_free(err_str);
|
|
||||||
return;
|
|
||||||
} else if (err_str) {
|
|
||||||
g_free(err_str);
|
|
||||||
}
|
|
||||||
if (g_list_length(if_list) > 0) {
|
|
||||||
/* List the interfaces */
|
|
||||||
for (curr = g_list_first(if_list); curr; curr = g_list_next(curr)) {
|
|
||||||
if_info = curr->data;
|
|
||||||
/* Continue if capture device is hidden */
|
|
||||||
if (prefs_is_capture_device_hidden(if_info->name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
gtk_list_store_append (store, &iter);
|
gtk_list_store_append (store, &iter);
|
||||||
d_interface.name = g_strdup(if_info->name);
|
gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(capture_get_if_icon(&device))), IFACE_DESCR, device.display_name, IFACE_NAME, device.name, -1);
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
if (device.selected) {
|
||||||
d_interface.remote_opts.src_type = CAPTURE_IFLOCAL;
|
gtk_tree_selection_select_iter(entry, &iter);
|
||||||
#endif
|
|
||||||
#ifdef HAVE_AIRPCAP
|
|
||||||
if (get_airpcap_if_from_name(airpcap_if_list,if_info->name) != NULL)
|
|
||||||
icon = xpm_to_widget(capture_airpcap_16_xpm);
|
|
||||||
else
|
|
||||||
icon = capture_get_if_icon(if_info);
|
|
||||||
#else
|
|
||||||
icon = capture_get_if_icon(if_info);
|
|
||||||
#endif
|
|
||||||
d_interface.icon = icon;
|
|
||||||
user_descr = capture_dev_user_descr_find(if_info->name);
|
|
||||||
if (user_descr) {
|
|
||||||
#ifndef _WIN32
|
|
||||||
gchar *comment = user_descr;
|
|
||||||
user_descr = g_strdup_printf("%s (%s)", comment, if_info->name);
|
|
||||||
g_free (comment);
|
|
||||||
#endif
|
|
||||||
gtk_list_store_set(store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, user_descr, IFACE_NAME, if_info->name, -1);
|
|
||||||
d_interface.descr = g_strdup(user_descr);
|
|
||||||
g_free (user_descr);
|
|
||||||
} else if (if_info->description) {
|
|
||||||
gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, if_info->description, IFACE_NAME, if_info->name, -1);
|
|
||||||
d_interface.descr = g_strdup(if_info->description);
|
|
||||||
} else {
|
|
||||||
gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, if_info->name, IFACE_NAME, if_info->name, -1);
|
|
||||||
d_interface.descr = g_strdup(if_info->name);
|
|
||||||
}
|
}
|
||||||
g_array_append_val(interfaces, d_interface);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free_interface_list(if_list);
|
changed = TRUE;
|
||||||
gtk_tree_view_set_model(GTK_TREE_VIEW(if_view), GTK_TREE_MODEL (store));
|
}
|
||||||
if (global_capture_opts.ifaces->len > 0) {
|
gtk_tree_selection_set_select_function(entry, on_selection_changed, (gpointer)&changed, NULL);
|
||||||
gtk_tree_model_foreach(GTK_TREE_MODEL(store), select_current_ifaces, (gpointer) entry);
|
if (gtk_widget_is_focus(view) && dlg_window_present()) {
|
||||||
gtk_widget_grab_focus(view);
|
update_all_rows();
|
||||||
}
|
|
||||||
gtk_tree_selection_set_select_function(entry, on_selection_changed, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBPCAP */
|
#endif /* HAVE_LIBPCAP */
|
||||||
}
|
}
|
||||||
|
@ -1043,23 +912,9 @@ void
|
||||||
welcome_if_panel_reload(void)
|
welcome_if_panel_reload(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
GtkWidget *child_box;
|
if (welcome_hb) {
|
||||||
GList* child_list;
|
|
||||||
GList* child_list_item;
|
|
||||||
|
|
||||||
if(welcome_if_panel_vb) {
|
|
||||||
child_box = scroll_box_dynamic_reset(welcome_if_panel_vb);
|
|
||||||
child_list = gtk_container_get_children(GTK_CONTAINER(child_box));
|
|
||||||
child_list_item = child_list;
|
|
||||||
|
|
||||||
while(child_list_item) {
|
|
||||||
gtk_container_remove(GTK_CONTAINER(child_box), child_list_item->data);
|
|
||||||
child_list_item = g_list_next(child_list_item);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free(child_list);
|
|
||||||
welcome_if_tree_load();
|
welcome_if_tree_load();
|
||||||
gtk_widget_show_all(welcome_if_panel_vb);
|
gtk_widget_show_all(welcome_hb);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBPCAP */
|
#endif /* HAVE_LIBPCAP */
|
||||||
}
|
}
|
||||||
|
@ -1068,27 +923,32 @@ welcome_if_panel_reload(void)
|
||||||
static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
|
static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_AIRPCAP
|
#ifdef HAVE_AIRPCAP
|
||||||
interface_options interface_opts;
|
interface_t device;
|
||||||
|
guint i;
|
||||||
#endif
|
#endif
|
||||||
|
if (global_capture_opts.num_selected == 0) {
|
||||||
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||||
|
"You didn't specify an interface on which to capture packets.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (global_capture_opts.ifaces->len == 0) {
|
/* XXX - remove this? */
|
||||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
if (global_capture_opts.save_file) {
|
||||||
"You didn't specify an interface on which to capture packets.");
|
g_free(global_capture_opts.save_file);
|
||||||
return;
|
global_capture_opts.save_file = NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_AIRPCAP /* TODO: don't let it depend on interface_opts */
|
||||||
/* XXX - remove this? */
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||||
if (global_capture_opts.save_file) {
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||||
g_free(global_capture_opts.save_file);
|
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, device.name);
|
||||||
global_capture_opts.save_file = NULL;
|
airpcap_if_selected = airpcap_if_active;
|
||||||
}
|
if (airpcap_if_selected) {
|
||||||
#ifdef HAVE_AIRPCAP
|
break;
|
||||||
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, 0);
|
}
|
||||||
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, interface_opts.name);
|
}
|
||||||
airpcap_if_selected = airpcap_if_active;
|
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
||||||
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
|
||||||
#endif
|
#endif
|
||||||
capture_start_cb(NULL, NULL);
|
capture_start_cb(NULL, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1097,7 +957,7 @@ static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
|
||||||
static gboolean
|
static gboolean
|
||||||
activate_link_cb(GtkLabel *label _U_, gchar *uri, gpointer user_data _U_)
|
activate_link_cb(GtkLabel *label _U_, gchar *uri, gpointer user_data _U_)
|
||||||
{
|
{
|
||||||
return browser_open_url(uri);
|
return browser_open_url(uri);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -1116,7 +976,8 @@ welcome_new(void)
|
||||||
GtkWidget *topic_vb;
|
GtkWidget *topic_vb;
|
||||||
GtkWidget *topic_to_fill;
|
GtkWidget *topic_to_fill;
|
||||||
GtkWidget *file_child_box;
|
GtkWidget *file_child_box;
|
||||||
gchar *label_text;
|
gchar *label_text;
|
||||||
|
int error;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
LONG reg_ret;
|
LONG reg_ret;
|
||||||
DWORD chimney_enabled = 0;
|
DWORD chimney_enabled = 0;
|
||||||
|
@ -1126,9 +987,6 @@ welcome_new(void)
|
||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
GtkTreeViewColumn *column;
|
GtkTreeViewColumn *column;
|
||||||
GList *if_list;
|
|
||||||
int err;
|
|
||||||
gchar *err_str = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* prepare colors */
|
/* prepare colors */
|
||||||
|
@ -1153,7 +1011,7 @@ welcome_new(void)
|
||||||
topic_item_idle_bg = topic_content_bg;
|
topic_item_idle_bg = topic_content_bg;
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
/* Allocating collor isn't necessary? */
|
/* Allocating collor isn't necessary? */
|
||||||
/* topic item entered color */
|
/* topic item entered color */
|
||||||
get_color(&topic_item_entered_bg);
|
get_color(&topic_item_entered_bg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1164,9 +1022,9 @@ welcome_new(void)
|
||||||
welcome_eb = gtk_event_box_new();
|
welcome_eb = gtk_event_box_new();
|
||||||
gtk_container_add(GTK_CONTAINER(welcome_eb), welcome_vb);
|
gtk_container_add(GTK_CONTAINER(welcome_eb), welcome_vb);
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_override_background_color(welcome_eb, GTK_STATE_NORMAL, &rgba_welcome_bg);
|
gtk_widget_override_background_color(welcome_eb, GTK_STATE_NORMAL, &rgba_welcome_bg);
|
||||||
#else
|
#else
|
||||||
gtk_widget_modify_bg(welcome_eb, GTK_STATE_NORMAL, &welcome_bg);
|
gtk_widget_modify_bg(welcome_eb, GTK_STATE_NORMAL, &welcome_bg);
|
||||||
#endif
|
#endif
|
||||||
/* header */
|
/* header */
|
||||||
header = welcome_header_new();
|
header = welcome_header_new();
|
||||||
|
@ -1181,7 +1039,7 @@ welcome_new(void)
|
||||||
/* column capture */
|
/* column capture */
|
||||||
column_vb = gtk_vbox_new(FALSE, 10);
|
column_vb = gtk_vbox_new(FALSE, 10);
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
gtk_widget_override_background_color(column_vb, GTK_STATE_NORMAL, &rgba_welcome_bg);
|
gtk_widget_override_background_color(column_vb, GTK_STATE_NORMAL, &rgba_welcome_bg);
|
||||||
#else
|
#else
|
||||||
gtk_widget_modify_bg(column_vb, GTK_STATE_NORMAL, &welcome_bg);
|
gtk_widget_modify_bg(column_vb, GTK_STATE_NORMAL, &welcome_bg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1192,8 +1050,10 @@ welcome_new(void)
|
||||||
gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
|
||||||
|
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
if_list = capture_interface_list(&err, &err_str);
|
if (global_capture_opts.all_ifaces->len == 0) {
|
||||||
if (g_list_length(if_list) > 0) {
|
scan_local_interfaces(&global_capture_opts, &error);
|
||||||
|
}
|
||||||
|
if (global_capture_opts.all_ifaces->len > 0) {
|
||||||
item_hb = welcome_button(WIRESHARK_STOCK_CAPTURE_INTERFACES,
|
item_hb = welcome_button(WIRESHARK_STOCK_CAPTURE_INTERFACES,
|
||||||
"Interface List",
|
"Interface List",
|
||||||
"Live list of the capture interfaces\n(counts incoming packets)",
|
"Live list of the capture interfaces\n(counts incoming packets)",
|
||||||
|
@ -1210,17 +1070,13 @@ welcome_new(void)
|
||||||
g_object_set(G_OBJECT(if_view), "headers-visible", FALSE, NULL);
|
g_object_set(G_OBJECT(if_view), "headers-visible", FALSE, NULL);
|
||||||
g_signal_connect(if_view, "row-activated", G_CALLBACK(options_interface_cb), (gpointer)welcome_hb);
|
g_signal_connect(if_view, "row-activated", G_CALLBACK(options_interface_cb), (gpointer)welcome_hb);
|
||||||
g_object_set_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES, if_view);
|
g_object_set_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES, if_view);
|
||||||
|
column = gtk_tree_view_column_new();
|
||||||
renderer = gtk_cell_renderer_pixbuf_new();
|
renderer = gtk_cell_renderer_pixbuf_new();
|
||||||
column = gtk_tree_view_column_new_with_attributes ("",
|
gtk_tree_view_column_pack_start(column, renderer, FALSE);
|
||||||
GTK_CELL_RENDERER(renderer),
|
gtk_tree_view_column_set_attributes(column, renderer, "pixbuf", ICON, NULL);
|
||||||
"pixbuf", ICON,
|
|
||||||
NULL);
|
|
||||||
gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
|
|
||||||
renderer = gtk_cell_renderer_text_new();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
column = gtk_tree_view_column_new_with_attributes ("",
|
gtk_tree_view_column_pack_start(column, renderer, TRUE);
|
||||||
GTK_CELL_RENDERER(renderer),
|
gtk_tree_view_column_set_attributes(column, renderer, "text", IFACE_DESCR, NULL);
|
||||||
"text", IFACE_DESCR,
|
|
||||||
NULL);
|
|
||||||
gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
|
gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
|
||||||
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(if_view), 0), TRUE);
|
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(if_view), 0), TRUE);
|
||||||
renderer = gtk_cell_renderer_text_new();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
@ -1263,9 +1119,8 @@ welcome_new(void)
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
} else {
|
} else {
|
||||||
if (if_list == NULL && err != NO_INTERFACES_FOUND) {
|
if (error != NO_INTERFACES_FOUND) {
|
||||||
g_free(err_str);
|
if (error == CANT_GET_INTERFACE_LIST) {
|
||||||
if (err == CANT_GET_INTERFACE_LIST) {
|
|
||||||
label_text = g_strdup("No interface can be used for capturing in "
|
label_text = g_strdup("No interface can be used for capturing in "
|
||||||
"this system with the current configuration.\n"
|
"this system with the current configuration.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -1318,8 +1173,6 @@ welcome_new(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
free_interface_list(if_list);
|
|
||||||
|
|
||||||
/* capture help topic */
|
/* capture help topic */
|
||||||
topic_vb = welcome_topic_new("Capture Help", &topic_to_fill);
|
topic_vb = welcome_topic_new("Capture Help", &topic_to_fill);
|
||||||
gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
|
||||||
|
@ -1460,12 +1313,7 @@ welcome_new(void)
|
||||||
|
|
||||||
GtkWidget* get_welcome_window(void)
|
GtkWidget* get_welcome_window(void)
|
||||||
{
|
{
|
||||||
return welcome_hb;
|
return welcome_hb;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBPCAP
|
|
||||||
displayed_interface get_interface_data(gint index)
|
|
||||||
{
|
|
||||||
return g_array_index(interfaces, displayed_interface, index);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -40,15 +40,6 @@ typedef struct selected_name_s {
|
||||||
gboolean activate;
|
gboolean activate;
|
||||||
} selected_name_t;
|
} selected_name_t;
|
||||||
|
|
||||||
typedef struct displayed_interface_s {
|
|
||||||
gchar *name;
|
|
||||||
gchar *descr;
|
|
||||||
GtkWidget *icon;
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
|
||||||
remote_options remote_opts;
|
|
||||||
#endif
|
|
||||||
} displayed_interface;
|
|
||||||
|
|
||||||
GtkWidget *welcome_new(void);
|
GtkWidget *welcome_new(void);
|
||||||
|
|
||||||
/* reset the list of recently used files */
|
/* reset the list of recently used files */
|
||||||
|
@ -60,6 +51,8 @@ void main_welcome_add_recent_capture_file(const char *widget_cf_name, GObject *m
|
||||||
/* reload the list of interfaces */
|
/* reload the list of interfaces */
|
||||||
void welcome_if_panel_reload(void);
|
void welcome_if_panel_reload(void);
|
||||||
|
|
||||||
|
void welcome_if_tree_load(void);
|
||||||
|
|
||||||
/** Push a status message into the welcome screen header similar to
|
/** Push a status message into the welcome screen header similar to
|
||||||
* statusbar_push_*_msg(). This hides everything under the header.
|
* statusbar_push_*_msg(). This hides everything under the header.
|
||||||
* If msg is dynamically allocated, it is up to the caller to free
|
* If msg is dynamically allocated, it is up to the caller to free
|
||||||
|
@ -85,10 +78,10 @@ void change_interface_selection(gchar* name, gboolean activate);
|
||||||
|
|
||||||
void change_selection_for_all(gboolean enable);
|
void change_selection_for_all(gboolean enable);
|
||||||
|
|
||||||
|
void update_welcome_list(void);
|
||||||
|
|
||||||
#ifdef HAVE_PCAP_REMOTE
|
#ifdef HAVE_PCAP_REMOTE
|
||||||
void add_interface_to_list(gchar *name, gchar *descr, remote_options *remote_opts);
|
void add_interface_to_list(guint index);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
displayed_interface get_interface_data(gint index);
|
|
||||||
|
|
||||||
#endif /* __MAIN_WELCOME_H__ */
|
#endif /* __MAIN_WELCOME_H__ */
|
||||||
|
|
|
@ -1424,6 +1424,7 @@ ifopts_write_new_hide(void)
|
||||||
g_free(new_hide);
|
g_free(new_hide);
|
||||||
prefs.capture_devices_hide = NULL;
|
prefs.capture_devices_hide = NULL;
|
||||||
}
|
}
|
||||||
|
hide_interface(g_strdup(new_hide));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,9 @@ stats_prefs_fetch(GtkWidget *w _U_)
|
||||||
void
|
void
|
||||||
stats_prefs_apply(GtkWidget *w _U_)
|
stats_prefs_apply(GtkWidget *w _U_)
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
reset_tap_update_timer();
|
reset_tap_update_timer();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue