aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-11-28 16:03:11 -0800
committerMichael Mann <mmann78@netscape.net>2017-11-30 00:14:16 +0000
commit3ed5b4fb67edc6829ece7adf542f44e9a75185af (patch)
tree24ad6cc6525ca7af094d8c6d04dccf26d272227d
parentb59dc97dfef3bcce71cd393f4d2493e7ba1a8f82 (diff)
Reformat some top-level ui files.
Make sure each ui/*.[ch] file uses identical (4-space) indentation. Remove ui/.editorconfig. Fix up other formatting where needed. SPDX-abbreviate the license blurb in the files we modify. Change-Id: I5faa1c1eae9a4b6220422ad8e4ba7a341c7deb1f Reviewed-on: https://code.wireshark.org/review/24632 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--ui/.editorconfig29
-rw-r--r--ui/Makefile.am1
-rw-r--r--ui/capture.c1082
-rw-r--r--ui/capture.h38
-rw-r--r--ui/capture_ui_utils.c896
-rw-r--r--ui/capture_ui_utils.h20
-rw-r--r--ui/preference_utils.c162
-rw-r--r--ui/preference_utils.h22
-rw-r--r--ui/proto_hier_stats.c609
-rw-r--r--ui/proto_hier_stats.h46
-rw-r--r--ui/recent.c2179
-rw-r--r--ui/recent.h20
-rw-r--r--ui/tap-rtp-common.c1170
-rw-r--r--ui/tap-rtp-common.h20
-rw-r--r--ui/tap-sctp-analysis.c2303
-rw-r--r--ui/tap-sctp-analysis.h26
16 files changed, 4215 insertions, 4408 deletions
diff --git a/ui/.editorconfig b/ui/.editorconfig
deleted file mode 100644
index 348f355e76..0000000000
--- a/ui/.editorconfig
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Editor configuration
-#
-# http://editorconfig.org/
-#
-
-[capture.[ch]]
-indent_size = 2
-
-[capture_ui_utils.[ch]]
-indent_size = 2
-
-[preference_utils.[ch]]
-indent_size = 2
-
-[proto_hier_stats.[ch]]
-indent_style = tab
-indent_size = tab
-
-[recent.[ch]]
-indent_size = 2
-
-[tap-rtp-common.[ch]]
-indent_style = tab
-indent_size = tab
-
-[tap-sctp-analysis.[ch]]
-indent_style = tab
-indent_size = tab
diff --git a/ui/Makefile.am b/ui/Makefile.am
index 8f278d42d2..4f3ecb24ea 100644
--- a/ui/Makefile.am
+++ b/ui/Makefile.am
@@ -151,7 +151,6 @@ libui_generated_a_SOURCES = $(GENERATED_FILES)
libui_generated_a_CFLAGS = $(GENERATED_CFLAGS)
EXTRA_DIST = \
- .editorconfig \
$(GENERATOR_FILES) \
CMakeLists.txt \
doxygen.cfg.in \
diff --git a/ui/capture.c b/ui/capture.c
index 450bf57ddd..1e1c8374fa 100644
--- a/ui/capture.c
+++ b/ui/capture.c
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -75,49 +63,49 @@ static GList *capture_callbacks = NULL;
static void
capture_callback_invoke(int event, capture_session *cap_session)
{
- capture_callback_data_t *cb;
- GList *cb_item = capture_callbacks;
+ capture_callback_data_t *cb;
+ GList *cb_item = capture_callbacks;
- /* there should be at least one interested */
- g_assert(cb_item != NULL);
+ /* there should be at least one interested */
+ g_assert(cb_item != NULL);
- while(cb_item != NULL) {
- cb = (capture_callback_data_t *)cb_item->data;
- cb->cb_fct(event, cap_session, cb->user_data);
- cb_item = g_list_next(cb_item);
- }
+ while(cb_item != NULL) {
+ cb = (capture_callback_data_t *)cb_item->data;
+ cb->cb_fct(event, cap_session, cb->user_data);
+ cb_item = g_list_next(cb_item);
+ }
}
void
capture_callback_add(capture_callback_t func, gpointer user_data)
{
- capture_callback_data_t *cb;
+ capture_callback_data_t *cb;
- cb = (capture_callback_data_t *)g_malloc(sizeof(capture_callback_data_t));
- cb->cb_fct = func;
- cb->user_data = user_data;
+ cb = (capture_callback_data_t *)g_malloc(sizeof(capture_callback_data_t));
+ cb->cb_fct = func;
+ cb->user_data = user_data;
- capture_callbacks = g_list_append(capture_callbacks, cb);
+ capture_callbacks = g_list_append(capture_callbacks, cb);
}
void
capture_callback_remove(capture_callback_t func, gpointer user_data)
{
- capture_callback_data_t *cb;
- GList *cb_item = capture_callbacks;
-
- while(cb_item != NULL) {
- cb = (capture_callback_data_t *)cb_item->data;
- if(cb->cb_fct == func && cb->user_data == user_data) {
- capture_callbacks = g_list_remove(capture_callbacks, cb);
- g_free(cb);
- return;
+ capture_callback_data_t *cb;
+ GList *cb_item = capture_callbacks;
+
+ while(cb_item != NULL) {
+ cb = (capture_callback_data_t *)cb_item->data;
+ if(cb->cb_fct == func && cb->user_data == user_data) {
+ capture_callbacks = g_list_remove(capture_callbacks, cb);
+ g_free(cb);
+ return;
+ }
+ cb_item = g_list_next(cb_item);
}
- cb_item = g_list_next(cb_item);
- }
- g_assert_not_reached();
+ g_assert_not_reached();
}
/**
@@ -128,50 +116,50 @@ capture_callback_remove(capture_callback_t func, gpointer user_data)
gboolean
capture_start(capture_options *capture_opts, capture_session *cap_session, info_data_t* cap_data, void(*update_cb)(void))
{
- gboolean ret;
- GString *source;
-
- cap_session->state = CAPTURE_PREPARING;
- cap_session->count = 0;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
- source = get_iface_list_string(capture_opts, IFLIST_SHOW_FILTER);
- cf_set_tempfile_source((capture_file *)cap_session->cf, source->str);
- g_string_free(source, TRUE);
- /* try to start the capture child process */
- ret = sync_pipe_start(capture_opts, cap_session, cap_data, update_cb);
- if(!ret) {
- if(capture_opts->save_file != NULL) {
- g_free(capture_opts->save_file);
- capture_opts->save_file = NULL;
- }
-
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start failed.");
- cap_session->state = CAPTURE_STOPPED;
- } else {
- /* the capture child might not respond shortly after bringing it up */
- /* (for example: it will block if no input arrives from an input capture pipe (e.g. mkfifo)) */
-
- /* to prevent problems, bring the main GUI into "capture mode" right after a successful */
- /* spawn/exec of the capture child, without waiting for any response from it */
- capture_callback_invoke(capture_cb_capture_prepared, cap_session);
-
- if(capture_opts->show_info)
- capture_info_open(cap_session, cap_data);
- }
-
- return ret;
+ gboolean ret;
+ GString *source;
+
+ cap_session->state = CAPTURE_PREPARING;
+ cap_session->count = 0;
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
+ source = get_iface_list_string(capture_opts, IFLIST_SHOW_FILTER);
+ cf_set_tempfile_source((capture_file *)cap_session->cf, source->str);
+ g_string_free(source, TRUE);
+ /* try to start the capture child process */
+ ret = sync_pipe_start(capture_opts, cap_session, cap_data, update_cb);
+ if(!ret) {
+ if(capture_opts->save_file != NULL) {
+ g_free(capture_opts->save_file);
+ capture_opts->save_file = NULL;
+ }
+
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start failed.");
+ cap_session->state = CAPTURE_STOPPED;
+ } else {
+ /* the capture child might not respond shortly after bringing it up */
+ /* (for example: it will block if no input arrives from an input capture pipe (e.g. mkfifo)) */
+
+ /* to prevent problems, bring the main GUI into "capture mode" right after a successful */
+ /* spawn/exec of the capture child, without waiting for any response from it */
+ capture_callback_invoke(capture_cb_capture_prepared, cap_session);
+
+ if(capture_opts->show_info)
+ capture_info_open(cap_session, cap_data);
+ }
+
+ return ret;
}
void
capture_stop(capture_session *cap_session)
{
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Stop ...");
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Stop ...");
- capture_callback_invoke(capture_cb_capture_stopping, cap_session);
+ capture_callback_invoke(capture_cb_capture_stopping, cap_session);
- /* stop the capture child gracefully */
- sync_pipe_stop(cap_session);
+ /* stop the capture child gracefully */
+ sync_pipe_stop(cap_session);
}
@@ -190,10 +178,10 @@ capture_restart(capture_session *cap_session)
void
capture_kill_child(capture_session *cap_session)
{
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "Capture Kill");
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "Capture Kill");
- /* kill the capture child */
- sync_pipe_kill(cap_session->fork_child);
+ /* kill the capture child */
+ sync_pipe_kill(cap_session->fork_child);
}
/* We've succeeded in doing a (non real-time) capture; try to read it into a new capture file */
@@ -201,90 +189,90 @@ static gboolean
capture_input_read_all(capture_session *cap_session, gboolean is_tempfile,
gboolean drops_known, guint32 drops)
{
- capture_options *capture_opts = cap_session->capture_opts;
- int err;
+ capture_options *capture_opts = cap_session->capture_opts;
+ int err;
- /* Capture succeeded; attempt to open the capture file. */
- if (cf_open((capture_file *)cap_session->cf, capture_opts->save_file, WTAP_TYPE_AUTO, is_tempfile, &err) != CF_OK) {
- /* We're not doing a capture any more, so we don't have a save file. */
- return FALSE;
- }
-
- /* Set the read filter to NULL. */
- /* XXX - this is odd here; try to put it somewhere where it fits better */
- cf_set_rfcode((capture_file *)cap_session->cf, NULL);
-
- /* Get the packet-drop statistics.
-
- XXX - there are currently no packet-drop statistics stored
- in libpcap captures, and that's what we're reading.
-
- At some point, we will add support in Wiretap to return
- packet-drop statistics for capture file formats that store it,
- and will make "cf_read()" get those statistics from Wiretap.
- We clear the statistics (marking them as "not known") in
- "cf_open()", and "cf_read()" will only fetch them and mark
- them as known if Wiretap supplies them, so if we get the
- statistics now, after calling "cf_open()" but before calling
- "cf_read()", the values we store will be used by "cf_read()".
-
- If a future libpcap capture file format stores the statistics,
- we'll put them into the capture file that we write, and will
- thus not have to set them here - "cf_read()" will get them from
- the file and use them. */
- if (drops_known) {
- cf_set_drops_known((capture_file *)cap_session->cf, TRUE);
+ /* Capture succeeded; attempt to open the capture file. */
+ if (cf_open((capture_file *)cap_session->cf, capture_opts->save_file, WTAP_TYPE_AUTO, is_tempfile, &err) != CF_OK) {
+ /* We're not doing a capture any more, so we don't have a save file. */
+ return FALSE;
+ }
- /* XXX - on some systems, libpcap doesn't bother filling in
- "ps_ifdrop" - it doesn't even set it to zero - so we don't
- bother looking at it.
-
- Ideally, libpcap would have an interface that gave us
- several statistics - perhaps including various interface
- error statistics - and would tell us which of them it
- supplies, allowing us to display only the ones it does. */
- cf_set_drops((capture_file *)cap_session->cf, drops);
- }
-
- /* read in the packet data */
- switch (cf_read((capture_file *)cap_session->cf, FALSE)) {
-
- case CF_READ_OK:
- 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:
- /* User wants to quit program. Exit by leaving the main loop,
- so that any quit functions we registered get called. */
- main_window_nested_quit();
- return FALSE;
- }
-
- /* if we didn't capture even a single packet, close the file again */
- if(cap_session->count == 0 && !capture_opts->restart) {
- simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
-"%sNo packets captured.%s\n"
-"\n"
-"As no data was captured, closing the %scapture file.\n"
-"\n"
-"\n"
-"Help about capturing can be found at\n"
-"\n"
-" https://wiki.wireshark.org/CaptureSetup"
+ /* Set the read filter to NULL. */
+ /* XXX - this is odd here; try to put it somewhere where it fits better */
+ cf_set_rfcode((capture_file *)cap_session->cf, NULL);
+
+ /* Get the packet-drop statistics.
+
+ XXX - there are currently no packet-drop statistics stored
+ in libpcap captures, and that's what we're reading.
+
+ At some point, we will add support in Wiretap to return
+ packet-drop statistics for capture file formats that store it,
+ and will make "cf_read()" get those statistics from Wiretap.
+ We clear the statistics (marking them as "not known") in
+ "cf_open()", and "cf_read()" will only fetch them and mark
+ them as known if Wiretap supplies them, so if we get the
+ statistics now, after calling "cf_open()" but before calling
+ "cf_read()", the values we store will be used by "cf_read()".
+
+ If a future libpcap capture file format stores the statistics,
+ we'll put them into the capture file that we write, and will
+ thus not have to set them here - "cf_read()" will get them from
+ the file and use them. */
+ if (drops_known) {
+ cf_set_drops_known((capture_file *)cap_session->cf, TRUE);
+
+ /* XXX - on some systems, libpcap doesn't bother filling in
+ "ps_ifdrop" - it doesn't even set it to zero - so we don't
+ bother looking at it.
+
+ Ideally, libpcap would have an interface that gave us
+ several statistics - perhaps including various interface
+ error statistics - and would tell us which of them it
+ supplies, allowing us to display only the ones it does. */
+ cf_set_drops((capture_file *)cap_session->cf, drops);
+ }
+
+ /* read in the packet data */
+ switch (cf_read((capture_file *)cap_session->cf, FALSE)) {
+
+ case CF_READ_OK:
+ 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:
+ /* User wants to quit program. Exit by leaving the main loop,
+ so that any quit functions we registered get called. */
+ main_window_nested_quit();
+ return FALSE;
+ }
+
+ /* if we didn't capture even a single packet, close the file again */
+ if(cap_session->count == 0 && !capture_opts->restart) {
+ simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
+ "%sNo packets captured.%s\n"
+ "\n"
+ "As no data was captured, closing the %scapture file.\n"
+ "\n"
+ "\n"
+ "Help about capturing can be found at\n"
+ "\n"
+ " https://wiki.wireshark.org/CaptureSetup"
#ifdef _WIN32
-"\n\n"
-"Wireless (Wi-Fi/WLAN):\n"
-"Try to switch off promiscuous mode in the Capture Options"
+ "\n\n"
+ "Wireless (Wi-Fi/WLAN):\n"
+ "Try to switch off promiscuous mode in the Capture Options"
#endif
-"",
- simple_dialog_primary_start(), simple_dialog_primary_end(),
- (cf_is_tempfile((capture_file *)cap_session->cf)) ? "temporary " : "");
- cf_close((capture_file *)cap_session->cf);
- }
- return TRUE;
+ "",
+ simple_dialog_primary_start(), simple_dialog_primary_end(),
+ (cf_is_tempfile((capture_file *)cap_session->cf)) ? "temporary " : "");
+ cf_close((capture_file *)cap_session->cf);
+ }
+ return TRUE;
}
@@ -292,72 +280,72 @@ capture_input_read_all(capture_session *cap_session, gboolean is_tempfile,
gboolean
capture_input_new_file(capture_session *cap_session, gchar *new_file)
{
- capture_options *capture_opts = cap_session->capture_opts;
- gboolean is_tempfile;
- int err;
-
- if(cap_session->state == CAPTURE_PREPARING) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture started");
- }
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "File: \"%s\"", new_file);
-
- g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
-
- /* free the old filename */
- if(capture_opts->save_file != NULL) {
- /* we start a new capture file, close the old one (if we had one before). */
- /* (we can only have an open capture file in real_time_mode!) */
- if( ((capture_file *) cap_session->cf)->state != FILE_CLOSED) {
- if(capture_opts->real_time_mode) {
- capture_callback_invoke(capture_cb_capture_update_finished, cap_session);
- cf_finish_tail((capture_file *)cap_session->cf, &err);
- cf_close((capture_file *)cap_session->cf);
- } else {
- capture_callback_invoke(capture_cb_capture_fixed_finished, cap_session);
+ capture_options *capture_opts = cap_session->capture_opts;
+ gboolean is_tempfile;
+ int err;
+
+ if(cap_session->state == CAPTURE_PREPARING) {
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture started");
+ }
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "File: \"%s\"", new_file);
+
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
+
+ /* free the old filename */
+ if(capture_opts->save_file != NULL) {
+ /* we start a new capture file, close the old one (if we had one before). */
+ /* (we can only have an open capture file in real_time_mode!) */
+ if( ((capture_file *) cap_session->cf)->state != FILE_CLOSED) {
+ if(capture_opts->real_time_mode) {
+ capture_callback_invoke(capture_cb_capture_update_finished, cap_session);
+ cf_finish_tail((capture_file *)cap_session->cf, &err);
+ cf_close((capture_file *)cap_session->cf);
+ } else {
+ capture_callback_invoke(capture_cb_capture_fixed_finished, cap_session);
+ }
}
+ g_free(capture_opts->save_file);
+ is_tempfile = FALSE;
+ cf_set_tempfile((capture_file *)cap_session->cf, FALSE);
+ } else {
+ /* we didn't have a save_file before; must be a tempfile */
+ is_tempfile = TRUE;
+ cf_set_tempfile((capture_file *)cap_session->cf, TRUE);
}
- g_free(capture_opts->save_file);
- is_tempfile = FALSE;
- cf_set_tempfile((capture_file *)cap_session->cf, FALSE);
- } else {
- /* we didn't have a save_file before; must be a tempfile */
- is_tempfile = TRUE;
- cf_set_tempfile((capture_file *)cap_session->cf, TRUE);
- }
-
- /* save the new filename */
- capture_opts->save_file = g_strdup(new_file);
-
- /* if we are in real-time mode, open the new file now */
- if(capture_opts->real_time_mode) {
- /* Attempt to open the capture file and set up to read from it. */
- switch(cf_open((capture_file *)cap_session->cf, capture_opts->save_file, WTAP_TYPE_AUTO, is_tempfile, &err)) {
- case CF_OK:
- break;
- case CF_ERROR:
- /* Don't unlink (delete) the save file - leave it around,
- for debugging purposes. */
- g_free(capture_opts->save_file);
- capture_opts->save_file = NULL;
- return FALSE;
+
+ /* save the new filename */
+ capture_opts->save_file = g_strdup(new_file);
+
+ /* if we are in real-time mode, open the new file now */
+ if(capture_opts->real_time_mode) {
+ /* Attempt to open the capture file and set up to read from it. */
+ switch(cf_open((capture_file *)cap_session->cf, capture_opts->save_file, WTAP_TYPE_AUTO, is_tempfile, &err)) {
+ case CF_OK:
+ break;
+ case CF_ERROR:
+ /* Don't unlink (delete) the save file - leave it around,
+ for debugging purposes. */
+ g_free(capture_opts->save_file);
+ capture_opts->save_file = NULL;
+ return FALSE;
+ }
+ } else {
+ capture_callback_invoke(capture_cb_capture_prepared, cap_session);
+ }
+
+ if(capture_opts->show_info) {
+ if (!capture_info_new_file(new_file, cap_session->cap_data_info))
+ return FALSE;
+ }
+
+ if(capture_opts->real_time_mode) {
+ capture_callback_invoke(capture_cb_capture_update_started, cap_session);
+ } else {
+ capture_callback_invoke(capture_cb_capture_fixed_started, cap_session);
}
- } else {
- capture_callback_invoke(capture_cb_capture_prepared, cap_session);
- }
-
- if(capture_opts->show_info) {
- if (!capture_info_new_file(new_file, cap_session->cap_data_info))
- return FALSE;
- }
-
- if(capture_opts->real_time_mode) {
- capture_callback_invoke(capture_cb_capture_update_started, cap_session);
- } else {
- capture_callback_invoke(capture_cb_capture_fixed_started, cap_session);
- }
- cap_session->state = CAPTURE_RUNNING;
-
- return TRUE;
+ cap_session->state = CAPTURE_RUNNING;
+
+ return TRUE;
}
@@ -365,39 +353,39 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
void
capture_input_new_packets(capture_session *cap_session, int to_read)
{
- capture_options *capture_opts = cap_session->capture_opts;
- int err;
-
- g_assert(capture_opts->save_file);
-
- if(capture_opts->real_time_mode) {
- /* Read from the capture file the number of records the child told us it added. */
- switch (cf_continue_tail((capture_file *)cap_session->cf, to_read, &err)) {
-
- case CF_READ_OK:
- 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.
-
- XXX - abort on a read error? */
- capture_callback_invoke(capture_cb_capture_update_continue, cap_session);
- break;
-
- case CF_READ_ABORTED:
- /* Kill the child capture process; the user wants to exit, and we
- shouldn't just leave it running. */
- capture_kill_child(cap_session);
- break;
- }
- } else {
- cf_fake_continue_tail((capture_file *)cap_session->cf);
+ capture_options *capture_opts = cap_session->capture_opts;
+ int err;
- capture_callback_invoke(capture_cb_capture_fixed_continue, cap_session);
- }
+ g_assert(capture_opts->save_file);
- if(capture_opts->show_info)
- capture_info_new_packets(to_read, cap_session->cap_data_info);
+ if(capture_opts->real_time_mode) {
+ /* Read from the capture file the number of records the child told us it added. */
+ switch (cf_continue_tail((capture_file *)cap_session->cf, to_read, &err)) {
+
+ case CF_READ_OK:
+ 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.
+
+ XXX - abort on a read error? */
+ capture_callback_invoke(capture_cb_capture_update_continue, cap_session);
+ break;
+
+ case CF_READ_ABORTED:
+ /* Kill the child capture process; the user wants to exit, and we
+ shouldn't just leave it running. */
+ capture_kill_child(cap_session);
+ break;
+ }
+ } else {
+ cf_fake_continue_tail((capture_file *)cap_session->cf);
+
+ capture_callback_invoke(capture_cb_capture_fixed_continue, cap_session);
+ }
+
+ if(capture_opts->show_info)
+ capture_info_new_packets(to_read, cap_session->cap_data_info);
}
@@ -406,12 +394,12 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
void
capture_input_drops(capture_session *cap_session, guint32 dropped)
{
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%u packet%s dropped", dropped, plurality(dropped, "", "s"));
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%u packet%s dropped", dropped, plurality(dropped, "", "s"));
- g_assert(cap_session->state == CAPTURE_RUNNING);
+ g_assert(cap_session->state == CAPTURE_RUNNING);
- cf_set_drops_known((capture_file *)cap_session->cf, TRUE);
- cf_set_drops((capture_file *)cap_session->cf, dropped);
+ cf_set_drops_known((capture_file *)cap_session->cf, TRUE);
+ cf_set_drops((capture_file *)cap_session->cf, dropped);
}
@@ -425,31 +413,31 @@ void
capture_input_error_message(capture_session *cap_session, char *error_msg,
char *secondary_error_msg)
{
- gchar *safe_error_msg;
- gchar *safe_secondary_error_msg;
-
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Error message from child: \"%s\", \"%s\"",
- error_msg, secondary_error_msg);
-
- g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
-
- safe_error_msg = simple_dialog_format_message(error_msg);
- if (*secondary_error_msg != '\0') {
- /* We have both primary and secondary messages. */
- safe_secondary_error_msg = simple_dialog_format_message(secondary_error_msg);
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s%s%s\n\n%s",
- simple_dialog_primary_start(), safe_error_msg,
- simple_dialog_primary_end(), safe_secondary_error_msg);
- g_free(safe_secondary_error_msg);
- } else {
- /* We have only a primary message. */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s%s%s",
- simple_dialog_primary_start(), safe_error_msg,
- simple_dialog_primary_end());
- }
- g_free(safe_error_msg);
-
- /* the capture child will close the sync_pipe if required, nothing to do for now */
+ gchar *safe_error_msg;
+ gchar *safe_secondary_error_msg;
+
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Error message from child: \"%s\", \"%s\"",
+ error_msg, secondary_error_msg);
+
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
+
+ safe_error_msg = simple_dialog_format_message(error_msg);
+ if (*secondary_error_msg != '\0') {
+ /* We have both primary and secondary messages. */
+ safe_secondary_error_msg = simple_dialog_format_message(secondary_error_msg);
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s%s%s\n\n%s",
+ simple_dialog_primary_start(), safe_error_msg,
+ simple_dialog_primary_end(), safe_secondary_error_msg);
+ g_free(safe_secondary_error_msg);
+ } else {
+ /* We have only a primary message. */
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s%s%s",
+ simple_dialog_primary_start(), safe_error_msg,
+ simple_dialog_primary_end());
+ }
+ g_free(safe_error_msg);
+
+ /* the capture child will close the sync_pipe if required, nothing to do for now */
}
/* Capture child told us that an error has occurred while parsing a
@@ -459,305 +447,309 @@ void
capture_input_cfilter_error_message(capture_session *cap_session, guint i,
char *error_message)
{
- capture_options *capture_opts = cap_session->capture_opts;
- dfilter_t *rfcode = NULL;
- gchar *safe_cfilter;
- gchar *safe_descr;
- gchar *safe_cfilter_error_msg;
- interface_options *interface_opts;
-
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture filter error message from child: \"%s\"", error_message);
-
- g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
- g_assert(i < capture_opts->ifaces->len);
-
- interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
- safe_cfilter = simple_dialog_format_message(interface_opts->cfilter);
- safe_descr = simple_dialog_format_message(interface_opts->descr);
- safe_cfilter_error_msg = simple_dialog_format_message(error_message);
- /* Did the user try a display filter? */
- if (dfilter_compile(interface_opts->cfilter, &rfcode, NULL) && rfcode != NULL) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "%sInvalid capture filter \"%s\" for interface %s.%s\n"
- "\n"
- "That string looks like a valid display filter; however, it isn't a valid\n"
- "capture filter (%s).\n"
- "\n"
- "Note that display filters and capture filters don't have the same syntax,\n"
- "so you can't use most display filter expressions as capture filters.\n"
- "\n"
- "See the User's Guide for a description of the capture filter syntax.",
- simple_dialog_primary_start(), safe_cfilter, safe_descr,
- simple_dialog_primary_end(), safe_cfilter_error_msg);
- dfilter_free(rfcode);
- } else {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "%sInvalid capture filter \"%s\" for interface %s.%s\n"
- "\n"
- "That string isn't a valid capture filter (%s).\n"
- "See the User's Guide for a description of the capture filter syntax.",
- simple_dialog_primary_start(), safe_cfilter, safe_descr,
- simple_dialog_primary_end(), safe_cfilter_error_msg);
- }
- g_free(safe_cfilter_error_msg);
- g_free(safe_descr);
- g_free(safe_cfilter);
-
- /* the capture child will close the sync_pipe if required, nothing to do for now */
+ capture_options *capture_opts = cap_session->capture_opts;
+ dfilter_t *rfcode = NULL;
+ gchar *safe_cfilter;
+ gchar *safe_descr;
+ gchar *safe_cfilter_error_msg;
+ interface_options *interface_opts;
+
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture filter error message from child: \"%s\"", error_message);
+
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
+ g_assert(i < capture_opts->ifaces->len);
+
+ interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
+ safe_cfilter = simple_dialog_format_message(interface_opts->cfilter);
+ safe_descr = simple_dialog_format_message(interface_opts->descr);
+ safe_cfilter_error_msg = simple_dialog_format_message(error_message);
+ /* Did the user try a display filter? */
+ if (dfilter_compile(interface_opts->cfilter, &rfcode, NULL) && rfcode != NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "%sInvalid capture filter \"%s\" for interface %s.%s\n"
+ "\n"
+ "That string looks like a valid display filter; however, it isn't a valid\n"
+ "capture filter (%s).\n"
+ "\n"
+ "Note that display filters and capture filters don't have the same syntax,\n"
+ "so you can't use most display filter expressions as capture filters.\n"
+ "\n"
+ "See the User's Guide for a description of the capture filter syntax.",
+ simple_dialog_primary_start(), safe_cfilter, safe_descr,
+ simple_dialog_primary_end(), safe_cfilter_error_msg);
+ dfilter_free(rfcode);
+ } else {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "%sInvalid capture filter \"%s\" for interface %s.%s\n"
+ "\n"
+ "That string isn't a valid capture filter (%s).\n"
+ "See the User's Guide for a description of the capture filter syntax.",
+ simple_dialog_primary_start(), safe_cfilter, safe_descr,
+ simple_dialog_primary_end(), safe_cfilter_error_msg);
+ }
+ g_free(safe_cfilter_error_msg);
+ g_free(safe_descr);
+ g_free(safe_cfilter);
+
+ /* the capture child will close the sync_pipe if required, nothing to do for now */
}
/* capture child closed its side of the pipe, do the required cleanup */
void
capture_input_closed(capture_session *cap_session, gchar *msg)
{
- capture_options *capture_opts = cap_session->capture_opts;
- int err;
-
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture stopped.");
- g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
-
- if (msg != NULL)
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", msg);
-
- if(cap_session->state == CAPTURE_PREPARING) {
- /* We didn't start a capture; note that the attempt to start it
- failed. */
- capture_callback_invoke(capture_cb_capture_failed, cap_session);
- } else {
- /* We started a capture; process what's left of the capture file if
- we were in "update list of packets in real time" mode, or process
- all of it if we weren't. */
- if(capture_opts->real_time_mode) {
- cf_read_status_t status;
-
- /* Read what remains of the capture file. */
- status = cf_finish_tail((capture_file *)cap_session->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, cap_session);
-
- /* Finish the capture. */
- switch (status) {
-
- case CF_READ_OK:
- if (cap_session->count == 0 && !capture_opts->restart) {
- simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
- "%sNo packets captured.%s\n"
- "\n"
- "As no data was captured, closing the %scapture file.\n"
- "\n"
- "\n"
- "Help about capturing can be found at\n"
- "\n"
- " https://wiki.wireshark.org/CaptureSetup"
+ capture_options *capture_opts = cap_session->capture_opts;
+ int err;
+
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture stopped.");
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
+
+ if (msg != NULL)
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", msg);
+
+ if(cap_session->state == CAPTURE_PREPARING) {
+ /* We didn't start a capture; note that the attempt to start it
+ failed. */
+ capture_callback_invoke(capture_cb_capture_failed, cap_session);
+ } else {
+ /* We started a capture; process what's left of the capture file if
+ we were in "update list of packets in real time" mode, or process
+ all of it if we weren't. */
+ if(capture_opts->real_time_mode) {
+ cf_read_status_t status;
+
+ /* Read what remains of the capture file. */
+ status = cf_finish_tail((capture_file *)cap_session->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, cap_session);
+
+ /* Finish the capture. */
+ switch (status) {
+
+ case CF_READ_OK:
+ if (cap_session->count == 0 && !capture_opts->restart) {
+ simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
+ "%sNo packets captured.%s\n"
+ "\n"
+ "As no data was captured, closing the %scapture file.\n"
+ "\n"
+ "\n"
+ "Help about capturing can be found at\n"
+ "\n"
+ " https://wiki.wireshark.org/CaptureSetup"
#ifdef _WIN32
- "\n\n"
- "Wireless (Wi-Fi/WLAN):\n"
- "Try to switch off promiscuous mode in the Capture Options."
+ "\n\n"
+ "Wireless (Wi-Fi/WLAN):\n"
+ "Try to switch off promiscuous mode in the Capture Options."
#endif
- "",
- simple_dialog_primary_start(), simple_dialog_primary_end(),
- cf_is_tempfile((capture_file *)cap_session->cf) ? "temporary " : "");
- cf_close((capture_file *)cap_session->cf);
+ "",
+ simple_dialog_primary_start(), simple_dialog_primary_end(),
+ cf_is_tempfile((capture_file *)cap_session->cf) ? "temporary " : "");
+ cf_close((capture_file *)cap_session->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, cap_session);
+
+ /* 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(cap_session, cf_is_tempfile((capture_file *)cap_session->cf),
+ cf_get_drops_known((capture_file *)cap_session->cf), cf_get_drops((capture_file *)cap_session->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, cap_session);
-
- /* 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(cap_session, cf_is_tempfile((capture_file *)cap_session->cf),
- cf_get_drops_known((capture_file *)cap_session->cf), cf_get_drops((capture_file *)cap_session->cf));
- }
}
- }
- if(capture_opts->show_info)
- capture_info_close(cap_session->cap_data_info);
+ if(capture_opts->show_info)
+ capture_info_close(cap_session->cap_data_info);
- cap_session->state = CAPTURE_STOPPED;
+ cap_session->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_file *)cap_session->cf);
- return;
- }
+ /* 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_file *)cap_session->cf);
+ return;
+ }
- /* does the user wants to restart the current capture? */
- if(capture_opts->restart) {
- capture_opts->restart = FALSE;
+ /* does the user wants to restart the current capture? */
+ if(capture_opts->restart) {
+ capture_opts->restart = FALSE;
- ws_unlink(capture_opts->save_file);
+ ws_unlink(capture_opts->save_file);
- /* If we have a ring buffer, the original save file has been overwritten
- with the "ring filename". Restore it before starting again */
- if ((capture_opts->multi_files_on) && (capture_opts->orig_save_file != NULL)) {
- g_free(capture_opts->save_file);
- capture_opts->save_file = g_strdup(capture_opts->orig_save_file);
- }
+ /* If we have a ring buffer, the original save file has been overwritten
+ with the "ring filename". Restore it before starting again */
+ if ((capture_opts->multi_files_on) && (capture_opts->orig_save_file != NULL)) {
+ g_free(capture_opts->save_file);
+ capture_opts->save_file = g_strdup(capture_opts->orig_save_file);
+ }
- /* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */
- if(cf_is_tempfile((capture_file *)cap_session->cf)) {
- g_free(capture_opts->save_file);
- capture_opts->save_file = NULL;
- }
+ /* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */
+ if(cf_is_tempfile((capture_file *)cap_session->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);
- }
+ /* ... and start the capture again */
+ if (capture_opts->ifaces->len == 0) {
+ collect_ifaces(capture_opts);
+ }
- /* close the currently loaded capture file */
- cf_close((capture_file *)cap_session->cf);
+ /* close the currently loaded capture file */
+ cf_close((capture_file *)cap_session->cf);
- capture_start(capture_opts, cap_session, cap_session->cap_data_info, NULL); /*XXX is this NULL ok or we need an update_cb???*/
- } 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;
- }
+ capture_start(capture_opts, cap_session, cap_session->cap_data_info, NULL); /*XXX is this NULL ok or we need an update_cb???*/
+ } 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 *
-capture_stat_start(capture_options *capture_opts) {
- int stat_fd;
- ws_process_id fork_child;
- gchar *msg;
- if_stat_cache_t *sc = NULL;
- if_stat_cache_item_t *sc_item;
- guint i;
- interface_t *device;
-
- /* Fire up dumpcap. */
- /*
- * XXX - on systems with BPF, the number of BPF devices limits the
- * number of devices on which you can capture simultaneously.
- *
- * This means that
- *
- * 1) this might fail if you run out of BPF devices
- *
- * and
- *
- * 2) opening every interface could leave too few BPF devices
- * for *other* programs.
- *
- * It also means the system could end up getting a lot of traffic
- * that it has to pass through the networking stack and capture
- * mechanism, so opening all the devices and presenting packet
- * counts might not always be a good idea.
- */
- if (sync_interface_stats_open(&stat_fd, &fork_child, &msg, NULL) == 0) {
- sc = (if_stat_cache_t *)g_malloc(sizeof(if_stat_cache_t));
- sc->stat_fd = stat_fd;
- sc->fork_child = fork_child;
- sc->cache_list = NULL;
-
- /* Initialize the cache */
- for (i = 0; i < capture_opts->all_ifaces->len; i++) {
- device = &g_array_index(capture_opts->all_ifaces, interface_t, i);
- if (device->type != IF_PIPE) {
- sc_item = (if_stat_cache_item_t *)g_malloc0(sizeof(if_stat_cache_item_t));
- g_assert(device->if_info.name);
- sc_item->name = g_strdup(device->if_info.name);
- sc->cache_list = g_list_append(sc->cache_list, sc_item);
- }
+capture_stat_start(capture_options *capture_opts)
+{
+ int stat_fd;
+ ws_process_id fork_child;
+ gchar *msg;
+ if_stat_cache_t *sc = NULL;
+ if_stat_cache_item_t *sc_item;
+ guint i;
+ interface_t *device;
+
+ /* Fire up dumpcap. */
+ /*
+ * XXX - on systems with BPF, the number of BPF devices limits the
+ * number of devices on which you can capture simultaneously.
+ *
+ * This means that
+ *
+ * 1) this might fail if you run out of BPF devices
+ *
+ * and
+ *
+ * 2) opening every interface could leave too few BPF devices
+ * for *other* programs.
+ *
+ * It also means the system could end up getting a lot of traffic
+ * that it has to pass through the networking stack and capture
+ * mechanism, so opening all the devices and presenting packet
+ * counts might not always be a good idea.
+ */
+ if (sync_interface_stats_open(&stat_fd, &fork_child, &msg, NULL) == 0) {
+ sc = (if_stat_cache_t *)g_malloc(sizeof(if_stat_cache_t));
+ sc->stat_fd = stat_fd;
+ sc->fork_child = fork_child;
+ sc->cache_list = NULL;
+
+ /* Initialize the cache */
+ for (i = 0; i < capture_opts->all_ifaces->len; i++) {
+ device = &g_array_index(capture_opts->all_ifaces, interface_t, i);
+ if (device->type != IF_PIPE) {
+ sc_item = (if_stat_cache_item_t *)g_malloc0(sizeof(if_stat_cache_item_t));
+ g_assert(device->if_info.name);
+ sc_item->name = g_strdup(device->if_info.name);
+ sc->cache_list = g_list_append(sc->cache_list, sc_item);
+ }
+ }
+ } else {
+ g_free(msg); /* XXX: should we display this to the user ? */
}
- } else {
- g_free(msg); /* XXX: should we display this to the user ? */
- }
- return sc;
+ return sc;
}
#define MAX_STAT_LINE_LEN 500
static void
-capture_stat_cache_update(if_stat_cache_t *sc) {
- gchar stat_line[MAX_STAT_LINE_LEN] = "";
- gchar **stat_parts;
- GList *sc_entry;
- if_stat_cache_item_t *sc_item;
-
- if (!sc)
- return;
-
- while (sync_pipe_gets_nonblock(sc->stat_fd, stat_line, MAX_STAT_LINE_LEN) > 0) {
- g_strstrip(stat_line);
- stat_parts = g_strsplit(stat_line, "\t", 3);
- if (stat_parts[0] == NULL || stat_parts[1] == NULL ||
- stat_parts[2] == NULL) {
- g_strfreev(stat_parts);
- continue;
- }
- for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
- sc_item = (if_stat_cache_item_t *)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);
- }
+capture_stat_cache_update(if_stat_cache_t *sc)
+{
+ gchar stat_line[MAX_STAT_LINE_LEN] = "";
+ gchar **stat_parts;
+ GList *sc_entry;
+ if_stat_cache_item_t *sc_item;
+
+ if (!sc)
+ return;
+
+ while (sync_pipe_gets_nonblock(sc->stat_fd, stat_line, MAX_STAT_LINE_LEN) > 0) {
+ g_strstrip(stat_line);
+ stat_parts = g_strsplit(stat_line, "\t", 3);
+ if (stat_parts[0] == NULL || stat_parts[1] == NULL ||
+ stat_parts[2] == NULL) {
+ g_strfreev(stat_parts);
+ continue;
+ }
+ for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
+ sc_item = (if_stat_cache_item_t *)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);
}
- g_strfreev(stat_parts);
- }
}
gboolean
-capture_stats(if_stat_cache_t *sc, char *ifname, struct pcap_stat *ps) {
- GList *sc_entry;
- if_stat_cache_item_t *sc_item;
+capture_stats(if_stat_cache_t *sc, char *ifname, struct pcap_stat *ps)
+{
+ GList *sc_entry;
+ if_stat_cache_item_t *sc_item;
- 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 = (if_stat_cache_item_t *)sc_entry->data;
- if (strcmp(sc_item->name, ifname) == 0) {
- memcpy(ps, &sc_item->ps, sizeof(struct pcap_stat));
- return TRUE;
+ 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 = (if_stat_cache_item_t *)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;
}
void
-capture_stat_stop(if_stat_cache_t *sc) {
- GList *sc_entry;
- if_stat_cache_item_t *sc_item;
- int ret;
- gchar *msg;
-
- if (!sc)
- return;
-
- ret = sync_interface_stats_close(&sc->stat_fd, &sc->fork_child, &msg);
- if (ret == -1) {
- /* XXX - report failure? */
- g_free(msg);
- }
-
- for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
- sc_item = (if_stat_cache_item_t *)sc_entry->data;
- g_free(sc_item->name);
- g_free(sc_item);
- }
- g_list_free(sc->cache_list);
- g_free(sc);
+capture_stat_stop(if_stat_cache_t *sc)
+{
+ GList *sc_entry;
+ if_stat_cache_item_t *sc_item;
+ int ret;
+ gchar *msg;
+
+ if (!sc)
+ return;
+
+ ret = sync_interface_stats_close(&sc->stat_fd, &sc->fork_child, &msg);
+ if (ret == -1) {
+ /* XXX - report failure? */
+ g_free(msg);
+ }
+
+ for (sc_entry = sc->cache_list; sc_entry != NULL; sc_entry = g_list_next(sc_entry)) {
+ sc_item = (if_stat_cache_item_t *)sc_entry->data;
+ g_free(sc_item->name);
+ g_free(sc_item);
+ }
+ g_list_free(sc->cache_list);
+ g_free(sc);
}
#endif /* HAVE_LIBPCAP */
@@ -766,11 +758,11 @@ capture_stat_stop(if_stat_cache_t *sc) {
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
- * c-basic-offset: 2
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/capture.h b/ui/capture.h
index bc229d90c0..1f0082f816 100644
--- a/ui/capture.h
+++ b/ui/capture.h
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
/* This file should only be included if libpcap is present */
@@ -38,15 +26,15 @@ extern "C" {
#endif /* __cplusplus */
typedef enum {
- capture_cb_capture_prepared,
- capture_cb_capture_update_started,
- capture_cb_capture_update_continue,
- capture_cb_capture_update_finished,
- capture_cb_capture_fixed_started,
- capture_cb_capture_fixed_continue,
- capture_cb_capture_fixed_finished,
- capture_cb_capture_stopping,
- capture_cb_capture_failed
+ capture_cb_capture_prepared,
+ capture_cb_capture_update_started,
+ capture_cb_capture_update_continue,
+ capture_cb_capture_update_finished,
+ capture_cb_capture_fixed_started,
+ capture_cb_capture_fixed_continue,
+ capture_cb_capture_fixed_finished,
+ capture_cb_capture_stopping,
+ capture_cb_capture_failed
} capture_cbs;
typedef void (*capture_callback_t) (gint event, capture_session *cap_session,
@@ -113,11 +101,11 @@ void capture_stat_stop(if_stat_cache_t *sc);
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local Variables:
- * c-basic-offset: 2
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/capture_ui_utils.c b/ui/capture_ui_utils.c
index 88ce9a34d2..7813647421 100644
--- a/ui/capture_ui_utils.c
+++ b/ui/capture_ui_utils.c
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -46,56 +34,56 @@
static char *
capture_dev_get_if_property(const gchar *pref, const gchar *if_name)
{
- gchar **if_tokens;
- gchar *property = NULL;
- int i;
-
- if (if_name == NULL || strlen(if_name) < 1) {
- return NULL;
- }
-
- if (pref == NULL || strlen(pref) < 1) {
- /* There is no interface information list. */
- return NULL;
- }
-
- /*
- * Split the list into a sequence of items.
- *
- * XXX - this relies on the items not themselves containing commas.
- */
- if_tokens = g_strsplit(pref, ",", -1);
- for (i = 0; if_tokens[i] != NULL; i++) {
- gchar *opening_parenp, *closing_parenp;
+ gchar **if_tokens;
+ gchar *property = NULL;
+ int i;
- /*
- * Separate this item into name and property.
- * The first opening parenthesis and the last closing parenthesis
- * surround the property. Any other parentheses are part of
- * the property.
- */
- opening_parenp = strchr(if_tokens[i], '(');
- if (opening_parenp == NULL) {
- /* No opening parenthesis. Give up. */
- break;
+ if (if_name == NULL || strlen(if_name) < 1) {
+ return NULL;
}
- closing_parenp = strrchr(if_tokens[i], ')');
- if (closing_parenp == NULL || closing_parenp <= opening_parenp) {
- /* No closing parenthesis or invalid input. Give up. */
- break;
+
+ if (pref == NULL || strlen(pref) < 1) {
+ /* There is no interface information list. */
+ return NULL;
}
- *opening_parenp = '\0'; /* Split {name} from what follows */
- *closing_parenp = '\0'; /* Terminate {property} */
- if (strcmp(if_tokens[i], if_name) == 0) {
- if (strlen(opening_parenp + 1) > 0) {
- property = g_strdup(opening_parenp + 1);
- }
- break;
+
+ /*
+ * Split the list into a sequence of items.
+ *
+ * XXX - this relies on the items not themselves containing commas.
+ */
+ if_tokens = g_strsplit(pref, ",", -1);
+ for (i = 0; if_tokens[i] != NULL; i++) {
+ gchar *opening_parenp, *closing_parenp;
+
+ /*
+ * Separate this item into name and property.
+ * The first opening parenthesis and the last closing parenthesis
+ * surround the property. Any other parentheses are part of
+ * the property.
+ */
+ opening_parenp = strchr(if_tokens[i], '(');
+ if (opening_parenp == NULL) {
+ /* No opening parenthesis. Give up. */
+ break;
+ }
+ closing_parenp = strrchr(if_tokens[i], ')');
+ if (closing_parenp == NULL || closing_parenp <= opening_parenp) {
+ /* No closing parenthesis or invalid input. Give up. */
+ break;
+ }
+ *opening_parenp = '\0'; /* Split {name} from what follows */
+ *closing_parenp = '\0'; /* Terminate {property} */
+ if (strcmp(if_tokens[i], if_name) == 0) {
+ if (strlen(opening_parenp + 1) > 0) {
+ property = g_strdup(opening_parenp + 1);
+ }
+ break;
+ }
}
- }
- g_strfreev(if_tokens);
+ g_strfreev(if_tokens);
- return property;
+ return property;
}
/*
@@ -105,28 +93,28 @@ capture_dev_get_if_property(const gchar *pref, const gchar *if_name)
static gint
capture_dev_get_if_int_property(const gchar *pref, const gchar *if_name)
{
- gchar *property_string, *next;
- long property;
-
- property_string = capture_dev_get_if_property(pref, if_name);
- if (property_string == NULL) {
- /* No property found for this interface. */
- return -1;
- }
- property = strtol(property_string, &next, 10);
- if (next == property_string || *next != '\0' || property < 0) {
- /* Syntax error */
- g_free(property_string);
- return -1;
- }
- if (property > G_MAXINT) {
- /* Value doesn't fit in a gint */
- g_free(property_string);
- return -1;
- }
+ gchar *property_string, *next;
+ long property;
- g_free(property_string);
- return (gint)property;
+ property_string = capture_dev_get_if_property(pref, if_name);
+ if (property_string == NULL) {
+ /* No property found for this interface. */
+ return -1;
+ }
+ property = strtol(property_string, &next, 10);
+ if (next == property_string || *next != '\0' || property < 0) {
+ /* Syntax error */
+ g_free(property_string);
+ return -1;
+ }
+ if (property > G_MAXINT) {
+ /* Value doesn't fit in a gint */
+ g_free(property_string);
+ return -1;
+ }
+
+ g_free(property_string);
+ return (gint)property;
}
/*
@@ -136,124 +124,124 @@ capture_dev_get_if_int_property(const gchar *pref, const gchar *if_name)
char *
capture_dev_user_descr_find(const gchar *if_name)
{
- return capture_dev_get_if_property(prefs.capture_devices_descr, if_name);
+ return capture_dev_get_if_property(prefs.capture_devices_descr, if_name);
}
gint
capture_dev_user_linktype_find(const gchar *if_name)
{
- return capture_dev_get_if_int_property(prefs.capture_devices_linktypes, if_name);
+ return capture_dev_get_if_int_property(prefs.capture_devices_linktypes, if_name);
}
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
gint
capture_dev_user_buffersize_find(const gchar *if_name)
{
- return capture_dev_get_if_int_property(prefs.capture_devices_buffersize, if_name);
+ return capture_dev_get_if_int_property(prefs.capture_devices_buffersize, if_name);
}
#endif
gboolean
capture_dev_user_snaplen_find(const gchar *if_name, gboolean *hassnap, int *snaplen)
{
- gboolean found = FALSE;
- gchar **if_tokens;
- int i;
-
- if (if_name == NULL || strlen(if_name) < 1) {
- return FALSE;
- }
-
- if ((prefs.capture_devices_snaplen == NULL) ||
- (*prefs.capture_devices_snaplen == '\0')) {
- /* There are no snap lengths defined */
- return FALSE;
- }
-
- /*
- * Split the list into a sequence of items.
- *
- * XXX - this relies on the items not themselves containing commas.
- */
- if_tokens = g_strsplit(prefs.capture_devices_snaplen, ",", -1);
- for (i = 0; if_tokens[i] != NULL; i++) {
- gchar *colonp, *next;
- long value;
+ gboolean found = FALSE;
+ gchar **if_tokens;
+ int i;
+
+ if (if_name == NULL || strlen(if_name) < 1) {
+ return FALSE;
+ }
+
+ if ((prefs.capture_devices_snaplen == NULL) ||
+ (*prefs.capture_devices_snaplen == '\0')) {
+ /* There are no snap lengths defined */
+ return FALSE;
+ }
/*
- * This one's a bit ugly.
- * The syntax of the item is {name}:{hassnap}({snaplen}),
- * where {hassnap} is 0 if the interface shouldn't have a snapshot
- * length and 1 if it should, and {snaplen} is the maximum snapshot
- * length if {hassnap} is 0 and the specified snapshot length if
- * {hassnap} is 1.
+ * Split the list into a sequence of items.
*
- * Sadly, : was a bad choice of separator, given that, on some OSes,
- * an interface can have a colon in its name.
- *
- * So we look for the *last* colon in the string.
+ * XXX - this relies on the items not themselves containing commas.
*/
- colonp = strrchr(if_tokens[i], ':');
- if (colonp == NULL) {
- /* No separating colon. Give up. */
- break;
- }
- *colonp = '\0'; /* Split {name} from what follows */
- if (strcmp(if_tokens[i], if_name) == 0) {
- /* OK, this matches. */
- if (*(colonp + 1) == '0') {
- /* {hassnap} is false, so just set the snaplen to WTAP_MAX_PACKET_SIZE_STANDARD. */
- found = TRUE;
- *hassnap = FALSE;
- *snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
- } else if (*(colonp + 1) == '1') {
- /* {hassnap} is true, so extract {snaplen} */
- if (*(colonp + 2) != '(') {
- /* Not followed by a parenthesis. Give up. */
- break;
- }
- value = strtol(colonp + 3, &next, 10);
- if (next == colonp + 3 || *next != ')' || value < 0) {
- /* Syntax error. Give up. */
- break;
+ if_tokens = g_strsplit(prefs.capture_devices_snaplen, ",", -1);
+ for (i = 0; if_tokens[i] != NULL; i++) {
+ gchar *colonp, *next;
+ long value;
+
+ /*
+ * This one's a bit ugly.
+ * The syntax of the item is {name}:{hassnap}({snaplen}),
+ * where {hassnap} is 0 if the interface shouldn't have a snapshot
+ * length and 1 if it should, and {snaplen} is the maximum snapshot
+ * length if {hassnap} is 0 and the specified snapshot length if
+ * {hassnap} is 1.
+ *
+ * Sadly, : was a bad choice of separator, given that, on some OSes,
+ * an interface can have a colon in its name.
+ *
+ * So we look for the *last* colon in the string.
+ */
+ colonp = strrchr(if_tokens[i], ':');
+ if (colonp == NULL) {
+ /* No separating colon. Give up. */
+ break;
}
- if (value > G_MAXINT) {
- /* Value doesn't fit in a gint. Give up. */
- break;
+ *colonp = '\0'; /* Split {name} from what follows */
+ if (strcmp(if_tokens[i], if_name) == 0) {
+ /* OK, this matches. */
+ if (*(colonp + 1) == '0') {
+ /* {hassnap} is false, so just set the snaplen to WTAP_MAX_PACKET_SIZE_STANDARD. */
+ found = TRUE;
+ *hassnap = FALSE;
+ *snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
+ } else if (*(colonp + 1) == '1') {
+ /* {hassnap} is true, so extract {snaplen} */
+ if (*(colonp + 2) != '(') {
+ /* Not followed by a parenthesis. Give up. */
+ break;
+ }
+ value = strtol(colonp + 3, &next, 10);
+ if (next == colonp + 3 || *next != ')' || value < 0) {
+ /* Syntax error. Give up. */
+ break;
+ }
+ if (value > G_MAXINT) {
+ /* Value doesn't fit in a gint. Give up. */
+ break;
+ }
+ found = TRUE;
+ *hassnap = TRUE;
+ *snaplen = (gint)value;
+ } else {
+ /* Bad {hassnap}. Give up. */
+ break;
+ }
+ break;
}
- found = TRUE;
- *hassnap = TRUE;
- *snaplen = (gint)value;
- } else {
- /* Bad {hassnap}. Give up. */
- break;
- }
- break;
}
- }
- g_strfreev(if_tokens);
+ g_strfreev(if_tokens);
- return found;
+ return found;
}
gboolean
capture_dev_user_pmode_find(const gchar *if_name, gboolean *pmode)
{
- int value;
-
- value = capture_dev_get_if_int_property(prefs.capture_devices_pmode, if_name);
- if (value == -1) {
- /* Not found or bad. */
- return FALSE;
- }
- *pmode = (value != 0);
- return TRUE;
+ int value;
+
+ value = capture_dev_get_if_int_property(prefs.capture_devices_pmode, if_name);
+ if (value == -1) {
+ /* Not found or bad. */
+ return FALSE;
+ }
+ *pmode = (value != 0);
+ return TRUE;
}
gchar*
capture_dev_user_cfilter_find(const gchar *if_name)
{
- return capture_dev_get_if_property(prefs.capture_devices_filter, if_name);
+ return capture_dev_get_if_property(prefs.capture_devices_filter, if_name);
}
/*
@@ -272,126 +260,126 @@ capture_dev_user_cfilter_find(const gchar *if_name)
char *
get_interface_descriptive_name(const char *if_name)
{
- char *descr;
- GList *if_list;
- GList *if_entry;
- if_info_t *if_info;
- int err;
-
- /* Do we have a user-supplied description? */
- descr = capture_dev_user_descr_find(if_name);
- if (descr == NULL) {
- /* No; try to construct a descriptive name. */
- if (strcmp(if_name, "-") == 0) {
- /*
- * Strictly speaking, -X (extension) options are for modules, e.g. Lua
- * and using one here stretches that definition. However, this doesn't
- * waste a single-letter option on something that might be rarely used
- * and is backward-compatible to 1.0.
- */
- descr = g_strdup(ex_opt_get_nth("stdin_descr", 0));
- if (!descr) {
- descr = g_strdup("Standard input");
- }
- } else {
- /* No, we don't have a user-supplied description; did we get
- one from the OS or libpcap? */
- descr = NULL;
- if_list = capture_interface_list(&err, NULL, NULL);
- if (if_list != NULL) {
- if_entry = if_list;
- do {
- if_info = (if_info_t *)if_entry->data;
- if (strcmp(if_info->name, if_name) == 0) {
- if (if_info->friendly_name != NULL) {
- /* We have a "friendly name"; return a copy of that
- as the description - when we free the interface
- list, that'll also free up the strings to which
- it refers. */
- descr = g_strdup(if_info->friendly_name);
- } else if (if_info->vendor_description != NULL) {
- /* We have no "friendly name", but we have a vendor
- description; return a copy of that - when we free
- the interface list, that'll also free up the strings
- to which it refers. */
- descr = g_strdup(if_info->vendor_description);
+ char *descr;
+ GList *if_list;
+ GList *if_entry;
+ if_info_t *if_info;
+ int err;
+
+ /* Do we have a user-supplied description? */
+ descr = capture_dev_user_descr_find(if_name);
+ if (descr == NULL) {
+ /* No; try to construct a descriptive name. */
+ if (strcmp(if_name, "-") == 0) {
+ /*
+ * Strictly speaking, -X (extension) options are for modules, e.g. Lua
+ * and using one here stretches that definition. However, this doesn't
+ * waste a single-letter option on something that might be rarely used
+ * and is backward-compatible to 1.0.
+ */
+ descr = g_strdup(ex_opt_get_nth("stdin_descr", 0));
+ if (!descr) {
+ descr = g_strdup("Standard input");
}
- break;
- }
- } while ((if_entry = g_list_next(if_entry)) != NULL);
- }
- free_interface_list(if_list);
-
- if (descr == NULL) {
- /* The interface name is all we have, so just return a copy of that. */
- descr = g_strdup(if_name);
- }
+ } else {
+ /* No, we don't have a user-supplied description; did we get
+ one from the OS or libpcap? */
+ descr = NULL;
+ if_list = capture_interface_list(&err, NULL, NULL);
+ if (if_list != NULL) {
+ if_entry = if_list;
+ do {
+ if_info = (if_info_t *)if_entry->data;
+ if (strcmp(if_info->name, if_name) == 0) {
+ if (if_info->friendly_name != NULL) {
+ /* We have a "friendly name"; return a copy of that
+ as the description - when we free the interface
+ list, that'll also free up the strings to which
+ it refers. */
+ descr = g_strdup(if_info->friendly_name);
+ } else if (if_info->vendor_description != NULL) {
+ /* We have no "friendly name", but we have a vendor
+ description; return a copy of that - when we free
+ the interface list, that'll also free up the strings
+ to which it refers. */
+ descr = g_strdup(if_info->vendor_description);
+ }
+ break;
+ }
+ } while ((if_entry = g_list_next(if_entry)) != NULL);
+ }
+ free_interface_list(if_list);
+
+ if (descr == NULL) {
+ /* The interface name is all we have, so just return a copy of that. */
+ descr = g_strdup(if_name);
+ }
+ }
}
- }
- return descr;
+ return descr;
}
GList *
build_capture_combo_list(GList *if_list, gboolean do_hide)
{
- GList *combo_list;
- GList *if_entry;
- if_info_t *if_info;
- char *if_string;
- gchar *descr;
-
- combo_list = NULL;
- if (if_list != NULL) {
- /* Scan through the list and build a list of strings to display. */
- for (if_entry = if_list; if_entry != NULL;
- if_entry = g_list_next(if_entry)) {
- if_info = (if_info_t *)if_entry->data;
-
- /* Is this interface hidden and, if so, should we include it
- anyway? */
- if (!prefs_is_capture_device_hidden(if_info->name) || !do_hide) {
- /* It's not hidden, or it is but we should include it in the list. */
-
- /* Do we have a user-supplied description? */
- descr = capture_dev_user_descr_find(if_info->name);
- if (descr != NULL) {
- /* Yes, we have a user-supplied description; use it. */
- if_string = g_strdup_printf("%s: %s", descr, if_info->name);
- g_free(descr);
- } else {
- /* No, we don't have a user-supplied description; did we get
- one from the OS or libpcap? */
- if (if_info->vendor_description != NULL) {
- /* Yes - use it. */
- if_string = g_strdup_printf("%s: %s",
- if_info->vendor_description,
- if_info->name);
- } else {
- /* No. */
- if_string = g_strdup(if_info->name);
- }
- }
- combo_list = g_list_append(combo_list, if_string);
- }
- }/*for*/
- }
- return combo_list;
+ GList *combo_list;
+ GList *if_entry;
+ if_info_t *if_info;
+ char *if_string;
+ gchar *descr;
+
+ combo_list = NULL;
+ if (if_list != NULL) {
+ /* Scan through the list and build a list of strings to display. */
+ for (if_entry = if_list; if_entry != NULL;
+ if_entry = g_list_next(if_entry)) {
+ if_info = (if_info_t *)if_entry->data;
+
+ /* Is this interface hidden and, if so, should we include it
+ anyway? */
+ if (!prefs_is_capture_device_hidden(if_info->name) || !do_hide) {
+ /* It's not hidden, or it is but we should include it in the list. */
+
+ /* Do we have a user-supplied description? */
+ descr = capture_dev_user_descr_find(if_info->name);
+ if (descr != NULL) {
+ /* Yes, we have a user-supplied description; use it. */
+ if_string = g_strdup_printf("%s: %s", descr, if_info->name);
+ g_free(descr);
+ } else {
+ /* No, we don't have a user-supplied description; did we get
+ one from the OS or libpcap? */
+ if (if_info->vendor_description != NULL) {
+ /* Yes - use it. */
+ if_string = g_strdup_printf("%s: %s",
+ if_info->vendor_description,
+ if_info->name);
+ } else {
+ /* No. */
+ if_string = g_strdup(if_info->name);
+ }
+ }
+ combo_list = g_list_append(combo_list, if_string);
+ }
+ }/*for*/
+ }
+ return combo_list;
}
static void
free_if_string(gpointer data, gpointer user_data _U_)
{
- g_free(data);
+ g_free(data);
}
void
free_capture_combo_list(GList *combo_list)
{
- if (combo_list != NULL) {
- g_list_foreach(combo_list, free_if_string, NULL);
- g_list_free(combo_list);
- }
+ if (combo_list != NULL) {
+ g_list_foreach(combo_list, free_if_string, NULL);
+ g_list_free(combo_list);
+ }
}
/*
@@ -401,80 +389,80 @@ free_capture_combo_list(GList *combo_list)
const char *
get_if_name(const char *if_text)
{
- const char *if_name;
+ const char *if_name;
#ifdef _WIN32
- /*
- * We cannot assume that the interface name doesn't contain a space;
- * some names on Windows OT do.
- *
- * We also can't assume it begins with "\Device\", either, as, on
- * Windows OT, WinPcap doesn't put "\Device\" in front of the name.
- *
- * As I remember, we can't assume that the interface description
- * doesn't contain a colon, either; I think some do.
- *
- * We can probably assume that the interface *name* doesn't contain
- * a colon, however; if any interface name does contain a colon on
- * Windows, it'll be time to just get rid of the damn interface
- * descriptions in the drop-down list, have just the names in the
- * drop-down list, and have a "Browse..." button to browse for interfaces,
- * with names, descriptions, IP addresses, blah blah blah available when
- * possible.
- *
- * So we search backwards for a colon. If we don't find it, just
- * return the entire string; otherwise, skip the colon and any blanks
- * after it, and return that string.
- */
- if_name = if_text + strlen(if_text);
- for (;;) {
- if (if_name == if_text) {
- /* We're at the beginning of the string; return it. */
- break;
- }
- if_name--;
- if (*if_name == ':') {
- /*
- * We've found a colon.
- * Unfortunately, a colon is used in the string "rpcap://",
- * which is used in case of a remote capture.
- * So we'll check to make sure the colon isn't followed by "//";
- * it'll be followed by a blank if it separates the description
- * and the interface name. (We don't wire in "rpcap", in case we
- * support other protocols in the same syntax.)
- * Unfortunately, another colon can be used in "rpcap://host:port/"
- * before port. Check if colon is followed by digit.
- */
- if ((strncmp(if_name, "://", 3) != 0) && !g_ascii_isdigit(if_name[1])) {
- /*
- * OK, we've found a colon followed neither by "//" nor by digit.
- * Skip blanks following it.
- */
- if_name++;
- while (*if_name == ' ')
- if_name++;
- break;
- }
- }
- /* Keep looking for a colon not followed by "//". */
- }
+ /*
+ * We cannot assume that the interface name doesn't contain a space;
+ * some names on Windows OT do.
+ *
+ * We also can't assume it begins with "\Device\", either, as, on
+ * Windows OT, WinPcap doesn't put "\Device\" in front of the name.
+ *
+ * As I remember, we can't assume that the interface description
+ * doesn't contain a colon, either; I think some do.
+ *
+ * We can probably assume that the interface *name* doesn't contain
+ * a colon, however; if any interface name does contain a colon on
+ * Windows, it'll be time to just get rid of the damn interface
+ * descriptions in the drop-down list, have just the names in the
+ * drop-down list, and have a "Browse..." button to browse for interfaces,
+ * with names, descriptions, IP addresses, blah blah blah available when
+ * possible.
+ *
+ * So we search backwards for a colon. If we don't find it, just
+ * return the entire string; otherwise, skip the colon and any blanks
+ * after it, and return that string.
+ */
+ if_name = if_text + strlen(if_text);
+ for (;;) {
+ if (if_name == if_text) {
+ /* We're at the beginning of the string; return it. */
+ break;
+ }
+ if_name--;
+ if (*if_name == ':') {
+ /*
+ * We've found a colon.
+ * Unfortunately, a colon is used in the string "rpcap://",
+ * which is used in case of a remote capture.
+ * So we'll check to make sure the colon isn't followed by "//";
+ * it'll be followed by a blank if it separates the description
+ * and the interface name. (We don't wire in "rpcap", in case we
+ * support other protocols in the same syntax.)
+ * Unfortunately, another colon can be used in "rpcap://host:port/"
+ * before port. Check if colon is followed by digit.
+ */
+ if ((strncmp(if_name, "://", 3) != 0) && !g_ascii_isdigit(if_name[1])) {
+ /*
+ * OK, we've found a colon followed neither by "//" nor by digit.
+ * Skip blanks following it.
+ */
+ if_name++;
+ while (*if_name == ' ')
+ if_name++;
+ break;
+ }
+ }
+ /* Keep looking for a colon not followed by "//". */
+ }
#else
- /*
- * There's a space between the interface description and name, and
- * the interface name shouldn't have a space in it (it doesn't, on
- * UNIX systems); look backwards in the string for a space.
- *
- * (An interface name might, however, contain a colon in it, which
- * is why we don't use the colon search on UNIX.)
- */
- if_name = strrchr(if_text, ' ');
- if (if_name == NULL) {
- if_name = if_text;
- } else {
- if_name++;
- }
+ /*
+ * There's a space between the interface description and name, and
+ * the interface name shouldn't have a space in it (it doesn't, on
+ * UNIX systems); look backwards in the string for a space.
+ *
+ * (An interface name might, however, contain a colon in it, which
+ * is why we don't use the colon search on UNIX.)
+ */
+ if_name = strrchr(if_text, ' ');
+ if (if_name == NULL) {
+ if_name = if_text;
+ } else {
+ if_name++;
+ }
#endif
- return if_name;
+ return if_name;
}
/* Return interface_opts->descr (after setting it if it is not set)
@@ -484,17 +472,17 @@ get_if_name(const char *if_text)
const char *
get_iface_description_for_interface(capture_options *capture_opts, guint i)
{
- interface_options *interface_opts;
+ interface_options *interface_opts;
- if (i < capture_opts->ifaces->len) {
- interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
- if (!interface_opts->descr && interface_opts->name) {
- interface_opts->descr = get_interface_descriptive_name(interface_opts->name);
+ if (i < capture_opts->ifaces->len) {
+ interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
+ if (!interface_opts->descr && interface_opts->name) {
+ interface_opts->descr = get_interface_descriptive_name(interface_opts->name);
+ }
+ return (interface_opts->descr);
+ } else {
+ return (NULL);
}
- return (interface_opts->descr);
- } else {
- return (NULL);
- }
}
/*
@@ -503,140 +491,140 @@ get_iface_description_for_interface(capture_options *capture_opts, guint i)
void
set_active_dlt(interface_t *device, int global_default_dlt)
{
- GList *list;
- gboolean found_active_dlt;
- link_row *link;
-
- /*
- * If there's a preference for the link-layer header type for
- * this interface, use it. If not, use the all-interface
- * default; if that's not set on the command line, that will
- * be -1, meaning "use per-interface defaults", otherwise
- * we'll fail if it's not one of the types the interface
- * supports.
- */
- if ((device->active_dlt = capture_dev_user_linktype_find(device->name)) == -1) {
- device->active_dlt = global_default_dlt;
- }
-
- /*
- * Is that one of the supported link-layer header types?
- * If not, set it to -1, so we'll fall back on the first supported
- * link-layer header type.
- */
- found_active_dlt = FALSE;
- for (list = device->links; list != NULL; list = g_list_next(list)) {
- link = (link_row *)(list->data);
- if (link->dlt != -1 && link->dlt == device->active_dlt) {
- found_active_dlt = TRUE;
- break;
+ GList *list;
+ gboolean found_active_dlt;
+ link_row *link;
+
+ /*
+ * If there's a preference for the link-layer header type for
+ * this interface, use it. If not, use the all-interface
+ * default; if that's not set on the command line, that will
+ * be -1, meaning "use per-interface defaults", otherwise
+ * we'll fail if it's not one of the types the interface
+ * supports.
+ */
+ if ((device->active_dlt = capture_dev_user_linktype_find(device->name)) == -1) {
+ device->active_dlt = global_default_dlt;
}
- }
- if (!found_active_dlt) {
- device->active_dlt = -1;
- }
- if (device->active_dlt == -1) {
- /* Fall back on the first supported DLT, if we have one. */
+
+ /*
+ * Is that one of the supported link-layer header types?
+ * If not, set it to -1, so we'll fall back on the first supported
+ * link-layer header type.
+ */
+ found_active_dlt = FALSE;
for (list = device->links; list != NULL; list = g_list_next(list)) {
- link = (link_row *)(list->data);
- if (link->dlt != -1) {
- device->active_dlt = link->dlt;
- break;
- }
+ link = (link_row *)(list->data);
+ if (link->dlt != -1 && link->dlt == device->active_dlt) {
+ found_active_dlt = TRUE;
+ break;
+ }
+ }
+ if (!found_active_dlt) {
+ device->active_dlt = -1;
+ }
+ if (device->active_dlt == -1) {
+ /* Fall back on the first supported DLT, if we have one. */
+ for (list = device->links; list != NULL; list = g_list_next(list)) {
+ link = (link_row *)(list->data);
+ if (link->dlt != -1) {
+ device->active_dlt = link->dlt;
+ break;
+ }
+ }
}
- }
}
GString *
get_iface_list_string(capture_options *capture_opts, guint32 style)
{
- GString *iface_list_string = g_string_new("");
- guint i;
-
- /*
- * If we have a descriptive name for the interface, show that,
- * rather than its raw name. On NT 5.x (2K/XP/Server2K3), the
- * interface name is something like "\Device\NPF_{242423..."
- * which is pretty useless to the normal user. On other platforms,
- * it might be less cryptic, but if a more descriptive name is
- * available, we should still use that.
- */
+ GString *iface_list_string = g_string_new("");
+ guint i;
+
+ /*
+ * If we have a descriptive name for the interface, show that,
+ * rather than its raw name. On NT 5.x (2K/XP/Server2K3), the
+ * interface name is something like "\Device\NPF_{242423..."
+ * which is pretty useless to the normal user. On other platforms,
+ * it might be less cryptic, but if a more descriptive name is
+ * available, we should still use that.
+ */
#ifdef _WIN32
- if (capture_opts->ifaces->len < 2) {
+ if (capture_opts->ifaces->len < 2) {
#else
- if (capture_opts->ifaces->len < 4) {
+ if (capture_opts->ifaces->len < 4) {
#endif
- for (i = 0; i < capture_opts->ifaces->len; i++) {
- if (i > 0) {
- if (capture_opts->ifaces->len > 2) {
- g_string_append_printf(iface_list_string, ",");
- }
- g_string_append_printf(iface_list_string, " ");
- if (i == capture_opts->ifaces->len - 1) {
- g_string_append_printf(iface_list_string, "and ");
- }
- }
- if (style & IFLIST_QUOTE_IF_DESCRIPTION)
- g_string_append_printf(iface_list_string, "'");
- g_string_append_printf(iface_list_string, "%s", get_iface_description_for_interface(capture_opts, i));
- if (style & IFLIST_QUOTE_IF_DESCRIPTION)
- g_string_append_printf(iface_list_string, "'");
- if (style & IFLIST_SHOW_FILTER) {
- interface_options *interface_opts;
-
- interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
- if (interface_opts->cfilter != NULL &&
- strlen(interface_opts->cfilter) > 0) {
- g_string_append_printf(iface_list_string, " (%s)", interface_opts->cfilter);
+ for (i = 0; i < capture_opts->ifaces->len; i++) {
+ if (i > 0) {
+ if (capture_opts->ifaces->len > 2) {
+ g_string_append_printf(iface_list_string, ",");
+ }
+ g_string_append_printf(iface_list_string, " ");
+ if (i == capture_opts->ifaces->len - 1) {
+ g_string_append_printf(iface_list_string, "and ");
+ }
+ }
+ if (style & IFLIST_QUOTE_IF_DESCRIPTION)
+ g_string_append_printf(iface_list_string, "'");
+ g_string_append_printf(iface_list_string, "%s", get_iface_description_for_interface(capture_opts, i));
+ if (style & IFLIST_QUOTE_IF_DESCRIPTION)
+ g_string_append_printf(iface_list_string, "'");
+ if (style & IFLIST_SHOW_FILTER) {
+ interface_options *interface_opts;
+
+ interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
+ if (interface_opts->cfilter != NULL &&
+ strlen(interface_opts->cfilter) > 0) {
+ g_string_append_printf(iface_list_string, " (%s)", interface_opts->cfilter);
+ }
+ }
+ }
+ } else {
+ g_string_append_printf(iface_list_string, "%u interfaces", capture_opts->ifaces->len);
}
- }
- }
- } else {
- g_string_append_printf(iface_list_string, "%u interfaces", capture_opts->ifaces->len);
- }
- return iface_list_string;
+ return iface_list_string;
}
gchar *
get_iface_display_name(const gchar *description, const if_info_t *if_info)
{
- if (description && description[0]) {
- /* We have a user-supplied description. */
+ if (description && description[0]) {
+ /* We have a user-supplied description. */
#ifdef _WIN32
- gchar *if_string = if_info->friendly_name ? if_info->friendly_name : if_info->name;
- return g_strdup_printf("%s: %s", description, if_string);
+ gchar *if_string = if_info->friendly_name ? if_info->friendly_name : if_info->name;
+ return g_strdup_printf("%s: %s", description, if_string);
#else
- return g_strdup_printf("%s: %s", description, if_info->name);
+ return g_strdup_printf("%s: %s", description, if_info->name);
#endif
- }
+ }
- if (if_info->friendly_name) {
- /* We have a friendly name from the OS. */
+ if (if_info->friendly_name) {
+ /* We have a friendly name from the OS. */
#ifdef _WIN32
- /*
- * On Windows, if we have a friendly name, just show it,
- * don't show the name, as that's a string made out of
- * the device GUID, and not at all friendly.
- */
- return g_strdup_printf("%s", if_info->friendly_name);
+ /*
+ * On Windows, if we have a friendly name, just show it,
+ * don't show the name, as that's a string made out of
+ * the device GUID, and not at all friendly.
+ */
+ return g_strdup_printf("%s", if_info->friendly_name);
#else
- /*
- * On UN*X, if we have a friendly name, show it along
- * with the interface name; the interface name is short
- * and somewhat friendly, and many UN*X users are used
- * to interface names, so we should show it.
- */
- return g_strdup_printf("%s: %s", if_info->friendly_name, if_info->name);
+ /*
+ * On UN*X, if we have a friendly name, show it along
+ * with the interface name; the interface name is short
+ * and somewhat friendly, and many UN*X users are used
+ * to interface names, so we should show it.
+ */
+ return g_strdup_printf("%s: %s", if_info->friendly_name, if_info->name);
#endif
- }
+ }
- if (if_info->vendor_description) {
- /* We have a device description from libpcap. */
- return g_strdup_printf("%s: %s", if_info->vendor_description, if_info->name);
- }
+ if (if_info->vendor_description) {
+ /* We have a device description from libpcap. */
+ return g_strdup_printf("%s: %s", if_info->vendor_description, if_info->name);
+ }
- /* No additional descriptions found. */
- return g_strdup(if_info->name);
+ /* No additional descriptions found. */
+ return g_strdup(if_info->name);
}
#endif /* HAVE_LIBPCAP */
@@ -645,11 +633,11 @@ get_iface_display_name(const gchar *description, const if_info_t *if_info)
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local Variables:
- * c-basic-offset: 2
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/capture_ui_utils.h b/ui/capture_ui_utils.h
index 8e7ef65b30..dfedebd9c1 100644
--- a/ui/capture_ui_utils.h
+++ b/ui/capture_ui_utils.h
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __CAPTURE_UI_UTILS_H__
@@ -196,11 +184,11 @@ extern gchar *get_iface_display_name(const gchar *description, const if_info_t *
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local Variables:
- * c-basic-offset: 2
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/preference_utils.c b/ui/preference_utils.c
index 95be0c692c..b532060e94 100644
--- a/ui/preference_utils.c
+++ b/ui/preference_utils.c
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -46,8 +34,8 @@ void
prefs_to_capture_opts(void)
{
#ifdef HAVE_LIBPCAP
- /* Set promiscuous mode from the preferences setting. */
- /* the same applies to other preferences settings as well. */
+ /* Set promiscuous mode from the preferences setting. */
+ /* the same applies to other preferences settings as well. */
global_capture_opts.default_options.promisc_mode = prefs.capture_prom_mode;
global_capture_opts.use_pcapng = prefs.capture_pcap_ng;
global_capture_opts.show_info = prefs.capture_show_info; /* GTK+ only */
@@ -59,106 +47,106 @@ prefs_to_capture_opts(void)
void
prefs_main_write(void)
{
- int err;
- char *pf_dir_path;
- char *pf_path;
-
- /* Create the directory that holds personal configuration files, if
- necessary. */
- if (create_persconffile_dir(&pf_dir_path) == -1) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_dir_path,
- g_strerror(errno));
- g_free(pf_dir_path);
- } else {
- /* Write the preferencs out. */
- err = write_prefs(&pf_path);
- if (err != 0) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ int err;
+ char *pf_dir_path;
+ char *pf_path;
+
+ /* Create the directory that holds personal configuration files, if
+ necessary. */
+ if (create_persconffile_dir(&pf_dir_path) == -1) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_dir_path,
+ g_strerror(errno));
+ g_free(pf_dir_path);
+ } else {
+ /* Write the preferencs out. */
+ err = write_prefs(&pf_path);
+ if (err != 0) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't open preferences file\n\"%s\": %s.", pf_path,
g_strerror(err));
- g_free(pf_path);
+ g_free(pf_path);
+ }
}
- }
}
static gboolean
prefs_store_ext_helper(const char * module_name, const char *pref_name, const char *pref_value)
{
- module_t * module = NULL;
- pref_t * pref = NULL;
- gboolean pref_changed = TRUE;
+ module_t * module = NULL;
+ pref_t * pref = NULL;
+ gboolean pref_changed = TRUE;
- if ( ! prefs_is_registered_protocol(module_name))
- return FALSE;
+ if ( ! prefs_is_registered_protocol(module_name))
+ return FALSE;
- module = prefs_find_module(module_name);
- if ( ! module )
- return FALSE;
+ module = prefs_find_module(module_name);
+ if ( ! module )
+ return FALSE;
- pref = prefs_find_preference(module, pref_name);
+ pref = prefs_find_preference(module, pref_name);
- if (!pref)
- return FALSE;
+ if (!pref)
+ return FALSE;
- if (prefs_get_type(pref) == PREF_STRING )
- {
- pref_changed = prefs_set_string_value(pref, pref_value, pref_stashed);
- if ( ! pref_changed || prefs_get_string_value(pref, pref_stashed) != 0 )
- pref_changed = prefs_set_string_value(pref, pref_value, pref_current);
- }
+ if (prefs_get_type(pref) == PREF_STRING )
+ {
+ pref_changed = prefs_set_string_value(pref, pref_value, pref_stashed);
+ if ( ! pref_changed || prefs_get_string_value(pref, pref_stashed) != 0 )
+ pref_changed = prefs_set_string_value(pref, pref_value, pref_current);
+ }
- return pref_changed;
+ return pref_changed;
}
gboolean
prefs_store_ext(const char * module_name, const char *pref_name, const char *pref_value)
{
- if ( prefs_store_ext_helper(module_name, pref_name, pref_value) )
- {
- prefs_main_write();
- prefs_apply_all();
- prefs_to_capture_opts();
- return TRUE;
- }
+ if ( prefs_store_ext_helper(module_name, pref_name, pref_value) )
+ {
+ prefs_main_write();
+ prefs_apply_all();
+ prefs_to_capture_opts();
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
gboolean
prefs_store_ext_multiple(const char * module, GHashTable * pref_values)
{
- gboolean pref_changed = FALSE;
- GList * keys = NULL;
+ gboolean pref_changed = FALSE;
+ GList * keys = NULL;
- if ( ! prefs_is_registered_protocol(module))
- return pref_changed;
-
- keys = g_hash_table_get_keys(pref_values);
- if ( ! keys )
- return pref_changed;
+ if ( ! prefs_is_registered_protocol(module))
+ return pref_changed;
- while ( keys != NULL )
- {
- gchar * pref_name = (gchar *)keys->data;
- gchar * pref_value = (gchar *) g_hash_table_lookup(pref_values, keys->data);
+ keys = g_hash_table_get_keys(pref_values);
+ if ( ! keys )
+ return pref_changed;
- if ( pref_name && pref_value )
+ while ( keys != NULL )
{
- if ( prefs_store_ext_helper(module, pref_name, pref_value) )
- pref_changed = TRUE;
+ gchar * pref_name = (gchar *)keys->data;
+ gchar * pref_value = (gchar *) g_hash_table_lookup(pref_values, keys->data);
+
+ if ( pref_name && pref_value )
+ {
+ if ( prefs_store_ext_helper(module, pref_name, pref_value) )
+ pref_changed = TRUE;
+ }
+ keys = g_list_next(keys);
}
- keys = g_list_next(keys);
- }
- if ( pref_changed )
- {
- prefs_main_write();
- prefs_apply_all();
- prefs_to_capture_opts();
- }
+ if ( pref_changed )
+ {
+ prefs_main_write();
+ prefs_apply_all();
+ prefs_to_capture_opts();
+ }
- return TRUE;
+ return TRUE;
}
gint
@@ -223,14 +211,14 @@ column_prefs_remove_nth(gint col)
}
/*
- * Editor modelines
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
- * c-basic-offset: 2
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/preference_utils.h b/ui/preference_utils.h
index 4cfa3df4f7..aafbc1b1a2 100644
--- a/ui/preference_utils.h
+++ b/ui/preference_utils.h
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __PREFRENCE_UTILS_H__
@@ -103,14 +91,14 @@ void column_prefs_remove_nth(gint col);
#endif /* __PREFRENCE_UTILS_H__ */
/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
- * c-basic-offset: 2
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/proto_hier_stats.c b/ui/proto_hier_stats.c
index 5722a264d8..ec9f9653c4 100644
--- a/ui/proto_hier_stats.c
+++ b/ui/proto_hier_stats.c
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -42,336 +30,335 @@ static int pc_proto_id = -1;
static GNode*
find_stat_node(GNode *parent_stat_node, header_field_info *needle_hfinfo)
{
- GNode *needle_stat_node, *up_parent_stat_node;
- header_field_info *hfinfo;
- ph_stats_node_t *stats;
-
- /* Look down the tree */
- needle_stat_node = g_node_first_child(parent_stat_node);
-
- while (needle_stat_node) {
- hfinfo = STAT_NODE_HFINFO(needle_stat_node);
- if (hfinfo && hfinfo->id == needle_hfinfo->id) {
- return needle_stat_node;
- }
- needle_stat_node = g_node_next_sibling(needle_stat_node);
- }
-
- /* Look up the tree */
- up_parent_stat_node = parent_stat_node;
- while (up_parent_stat_node && up_parent_stat_node->parent)
- {
- needle_stat_node = g_node_first_child(up_parent_stat_node->parent);
- while (needle_stat_node) {
- hfinfo = STAT_NODE_HFINFO(needle_stat_node);
- if (hfinfo && hfinfo->id == needle_hfinfo->id) {
- return needle_stat_node;
- }
- needle_stat_node = g_node_next_sibling(needle_stat_node);
- }
-
- up_parent_stat_node = up_parent_stat_node->parent;
- }
-
- /* None found. Create one. */
- stats = g_new(ph_stats_node_t, 1);
-
- /* Intialize counters */
- stats->hfinfo = needle_hfinfo;
- stats->num_pkts_total = 0;
- stats->num_pkts_last = 0;
- stats->num_bytes_total = 0;
- stats->num_bytes_last = 0;
-
- needle_stat_node = g_node_new(stats);
- g_node_append(parent_stat_node, needle_stat_node);
- return needle_stat_node;
+ GNode *needle_stat_node, *up_parent_stat_node;
+ header_field_info *hfinfo;
+ ph_stats_node_t *stats;
+
+ /* Look down the tree */
+ needle_stat_node = g_node_first_child(parent_stat_node);
+
+ while (needle_stat_node) {
+ hfinfo = STAT_NODE_HFINFO(needle_stat_node);
+ if (hfinfo && hfinfo->id == needle_hfinfo->id) {
+ return needle_stat_node;
+ }
+ needle_stat_node = g_node_next_sibling(needle_stat_node);
+ }
+
+ /* Look up the tree */
+ up_parent_stat_node = parent_stat_node;
+ while (up_parent_stat_node && up_parent_stat_node->parent)
+ {
+ needle_stat_node = g_node_first_child(up_parent_stat_node->parent);
+ while (needle_stat_node) {
+ hfinfo = STAT_NODE_HFINFO(needle_stat_node);
+ if (hfinfo && hfinfo->id == needle_hfinfo->id) {
+ return needle_stat_node;
+ }
+ needle_stat_node = g_node_next_sibling(needle_stat_node);
+ }
+
+ up_parent_stat_node = up_parent_stat_node->parent;
+ }
+
+ /* None found. Create one. */
+ stats = g_new(ph_stats_node_t, 1);
+
+ /* Intialize counters */
+ stats->hfinfo = needle_hfinfo;
+ stats->num_pkts_total = 0;
+ stats->num_pkts_last = 0;
+ stats->num_bytes_total = 0;
+ stats->num_bytes_last = 0;
+
+ needle_stat_node = g_node_new(stats);
+ g_node_append(parent_stat_node, needle_stat_node);
+ return needle_stat_node;
}
-static void
+ static void
process_node(proto_node *ptree_node, GNode *parent_stat_node, ph_stats_t *ps)
{
- field_info *finfo;
- ph_stats_node_t *stats;
- proto_node *proto_sibling_node;
- GNode *stat_node;
-
- finfo = PNODE_FINFO(ptree_node);
- /* We don't fake protocol nodes we expect them to have a field_info.
- * Dissection with faked proto tree? */
- g_assert(finfo);
-
- /* If the field info isn't related to a protocol but to a field,
- * don't count them, as they don't belong to any protocol.
- * (happens e.g. for toplevel tree item of desegmentation "[Reassembled TCP Segments]") */
- if (finfo->hfinfo->parent != -1) {
- /* Skip this element, use parent status node */
- stat_node = parent_stat_node;
- stats = STAT_NODE_STATS(stat_node);
- } else {
- stat_node = find_stat_node(parent_stat_node, finfo->hfinfo);
-
- stats = STAT_NODE_STATS(stat_node);
- stats->num_pkts_total++;
- stats->num_bytes_total += finfo->length;
- }
-
- proto_sibling_node = ptree_node->next;
-
- if (proto_sibling_node) {
- /* If the name does not exist for this proto_sibling_node, then it is
- * not a normal protocol in the top-level tree. It was instead
- * added as a normal tree such as IPv6's Hop-by-hop Option Header and
- * should be skipped when creating the protocol hierarchy display. */
- if(strlen(PNODE_FINFO(proto_sibling_node)->hfinfo->name) == 0 && ptree_node->next)
- proto_sibling_node = proto_sibling_node->next;
-
- process_node(proto_sibling_node, stat_node, ps);
- } else {
- stats->num_pkts_last++;
- stats->num_bytes_last += finfo->length;
- }
+ field_info *finfo;
+ ph_stats_node_t *stats;
+ proto_node *proto_sibling_node;
+ GNode *stat_node;
+
+ finfo = PNODE_FINFO(ptree_node);
+ /* We don't fake protocol nodes we expect them to have a field_info.
+ * Dissection with faked proto tree? */
+ g_assert(finfo);
+
+ /* If the field info isn't related to a protocol but to a field,
+ * don't count them, as they don't belong to any protocol.
+ * (happens e.g. for toplevel tree item of desegmentation "[Reassembled TCP Segments]") */
+ if (finfo->hfinfo->parent != -1) {
+ /* Skip this element, use parent status node */
+ stat_node = parent_stat_node;
+ stats = STAT_NODE_STATS(stat_node);
+ } else {
+ stat_node = find_stat_node(parent_stat_node, finfo->hfinfo);
+
+ stats = STAT_NODE_STATS(stat_node);
+ stats->num_pkts_total++;
+ stats->num_bytes_total += finfo->length;
+ }
+
+ proto_sibling_node = ptree_node->next;
+
+ if (proto_sibling_node) {
+ /* If the name does not exist for this proto_sibling_node, then it is
+ * not a normal protocol in the top-level tree. It was instead
+ * added as a normal tree such as IPv6's Hop-by-hop Option Header and
+ * should be skipped when creating the protocol hierarchy display. */
+ if(strlen(PNODE_FINFO(proto_sibling_node)->hfinfo->name) == 0 && ptree_node->next)
+ proto_sibling_node = proto_sibling_node->next;
+
+ process_node(proto_sibling_node, stat_node, ps);
+ } else {
+ stats->num_pkts_last++;
+ stats->num_bytes_last += finfo->length;
+ }
}
-static void
+ static void
process_tree(proto_tree *protocol_tree, ph_stats_t* ps)
{
- proto_node *ptree_node;
-
- /*
- * If our first item is a comment, skip over it. This keeps
- * us from having a top-level "Packet comments" item that
- * steals items from "Frame".
- */
- ptree_node = ((proto_node *)protocol_tree)->first_child;
- if (ptree_node && ptree_node->finfo->hfinfo->id == pc_proto_id) {
- ptree_node = ptree_node->next;
- }
-
- if (!ptree_node) {
- return;
- }
-
- process_node(ptree_node, ps->stats_tree, ps);
+ proto_node *ptree_node;
+
+ /*
+ * If our first item is a comment, skip over it. This keeps
+ * us from having a top-level "Packet comments" item that
+ * steals items from "Frame".
+ */
+ ptree_node = ((proto_node *)protocol_tree)->first_child;
+ if (ptree_node && ptree_node->finfo->hfinfo->id == pc_proto_id) {
+ ptree_node = ptree_node->next;
+ }
+
+ if (!ptree_node) {
+ return;
+ }
+
+ process_node(ptree_node, ps->stats_tree, ps);
}
-static gboolean
+ static gboolean
process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats_t* ps)
{
- epan_dissect_t edt;
- struct wtap_pkthdr phdr;
- Buffer buf;
- double cur_time;
-
- wtap_phdr_init(&phdr);
-
- /* Load the record from the capture file */
- ws_buffer_init(&buf, 1500);
- if (!cf_read_record_r(cf, frame, &phdr, &buf))
- return FALSE; /* failure */
-
- /* Dissect the record tree not visible */
- epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
- /* Don't fake protocols. We need them for the protocol hierarchy */
- epan_dissect_fake_protocols(&edt, FALSE);
- epan_dissect_run(&edt, cf->cd_t, &phdr, frame_tvbuff_new_buffer(frame, &buf), frame, cinfo);
-
- /* Get stats from this protocol tree */
- process_tree(edt.tree, ps);
-
- if (frame->flags.has_ts) {
- /* Update times */
- cur_time = nstime_to_sec(&frame->abs_ts);
- if (cur_time < ps->first_time)
- ps->first_time = cur_time;
- if (cur_time > ps->last_time)
- ps->last_time = cur_time;
- }
-
- /* Free our memory. */
- epan_dissect_cleanup(&edt);
- wtap_phdr_cleanup(&phdr);
- ws_buffer_free(&buf);
-
- return TRUE; /* success */
+ epan_dissect_t edt;
+ struct wtap_pkthdr phdr;
+ Buffer buf;
+ double cur_time;
+
+ wtap_phdr_init(&phdr);
+
+ /* Load the record from the capture file */
+ ws_buffer_init(&buf, 1500);
+ if (!cf_read_record_r(cf, frame, &phdr, &buf))
+ return FALSE; /* failure */
+
+ /* Dissect the record tree not visible */
+ epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
+ /* Don't fake protocols. We need them for the protocol hierarchy */
+ epan_dissect_fake_protocols(&edt, FALSE);
+ epan_dissect_run(&edt, cf->cd_t, &phdr, frame_tvbuff_new_buffer(frame, &buf), frame, cinfo);
+
+ /* Get stats from this protocol tree */
+ process_tree(edt.tree, ps);
+
+ if (frame->flags.has_ts) {
+ /* Update times */
+ cur_time = nstime_to_sec(&frame->abs_ts);
+ if (cur_time < ps->first_time)
+ ps->first_time = cur_time;
+ if (cur_time > ps->last_time)
+ ps->last_time = cur_time;
+ }
+
+ /* Free our memory. */
+ epan_dissect_cleanup(&edt);
+ wtap_phdr_cleanup(&phdr);
+ ws_buffer_free(&buf);
+
+ return TRUE; /* success */
}
-ph_stats_t*
+ ph_stats_t*
ph_stats_new(capture_file *cf)
{
- ph_stats_t *ps;
- guint32 framenum;
- frame_data *frame;
- guint tot_packets, tot_bytes;
- progdlg_t *progbar = NULL;
- gboolean stop_flag;
- int count;
- float progbar_val;
- GTimeVal start_time;
- gchar status_str[100];
- int progbar_nextstep;
- int progbar_quantum;
-
- if (!cf) return NULL;
-
- pc_proto_id = proto_registrar_get_id_byname("pkt_comment");
-
- /* Initialize the data */
- ps = g_new(ph_stats_t, 1);
- ps->tot_packets = 0;
- ps->tot_bytes = 0;
- ps->stats_tree = g_node_new(NULL);
- ps->first_time = 0.0;
- ps->last_time = 0.0;
-
- /* Update the progress bar when it gets to this value. */
- progbar_nextstep = 0;
- /* When we reach the value that triggers a progress bar update,
- bump that value by this amount. */
- progbar_quantum = cf->count/N_PROGBAR_UPDATES;
- /* Count of packets at which we've looked. */
- count = 0;
- /* Progress so far. */
- progbar_val = 0.0f;
-
- stop_flag = FALSE;
- g_get_current_time(&start_time);
-
- tot_packets = 0;
- tot_bytes = 0;
-
- for (framenum = 1; framenum <= cf->count; framenum++) {
- frame = frame_data_sequence_find(cf->frames, framenum);
-
- /* Create the progress bar if necessary.
- We check on every iteration of the loop, so that
- it takes no longer than the standard time to create
- it (otherwise, for a large file, we might take
- considerably longer than that standard time in order
- to get to the next progress bar step). */
- if (progbar == NULL)
- progbar = delayed_create_progress_dlg(
- cf->window, "Computing",
- "protocol hierarchy statistics",
- TRUE, &stop_flag, &start_time, progbar_val);
-
- /* Update the progress bar, but do it only N_PROGBAR_UPDATES
- times; when we update it, we have to run the GTK+ main
- loop to get it to repaint what's pending, and doing so
- may involve an "ioctl()" to see if there's any pending
- input from an X server, and doing that for every packet
- can be costly, especially on a big file. */
- if (count >= progbar_nextstep) {
- /* let's not divide by zero. I should never be started
- * with count == 0, so let's assert that
- */
- g_assert(cf->count > 0);
-
- progbar_val = (gfloat) count / cf->count;
-
- if (progbar != NULL) {
- g_snprintf(status_str, sizeof(status_str),
- "%4u of %u frames", count, cf->count);
- update_progress_dlg(progbar, progbar_val, status_str);
- }
-
- progbar_nextstep += progbar_quantum;
- }
-
- if (stop_flag) {
- /* Well, the user decided to abort the statistics.
- computation process Just stop. */
- break;
- }
-
- /* Skip frames that are hidden due to the display filter.
- XXX - should the progress bar count only packets that
- passed the display filter? If so, it should
- probably do so for other loops (see "file.c") that
- look only at those packets. */
- if (frame->flags.passed_dfilter) {
-
- if (frame->flags.has_ts) {
- if (tot_packets == 0) {
- double cur_time = nstime_to_sec(&frame->abs_ts);
- ps->first_time = cur_time;
- ps->last_time = cur_time;
- }
- }
-
- /* we don't care about colinfo */
- if (!process_record(cf, frame, NULL, ps)) {
- /*
- * Give up, and set "stop_flag" so we
- * just abort rather than popping up
- * the statistics window.
- */
- stop_flag = TRUE;
- break;
- }
-
- tot_packets++;
- tot_bytes += frame->pkt_len;
- }
-
- count++;
- }
-
- /* We're done calculating the statistics; destroy the progress bar
- if it was created. */
- if (progbar != NULL)
- destroy_progress_dlg(progbar);
-
- if (stop_flag) {
- /*
- * We quit in the middle; throw away the statistics
- * and return NULL, so our caller doesn't pop up a
- * window with the incomplete statistics.
- */
- ph_stats_free(ps);
- return NULL;
- }
-
- ps->tot_packets = tot_packets;
- ps->tot_bytes = tot_bytes;
-
- return ps;
+ ph_stats_t *ps;
+ guint32 framenum;
+ frame_data *frame;
+ guint tot_packets, tot_bytes;
+ progdlg_t *progbar = NULL;
+ gboolean stop_flag;
+ int count;
+ float progbar_val;
+ GTimeVal start_time;
+ gchar status_str[100];
+ int progbar_nextstep;
+ int progbar_quantum;
+
+ if (!cf) return NULL;
+
+ pc_proto_id = proto_registrar_get_id_byname("pkt_comment");
+
+ /* Initialize the data */
+ ps = g_new(ph_stats_t, 1);
+ ps->tot_packets = 0;
+ ps->tot_bytes = 0;
+ ps->stats_tree = g_node_new(NULL);
+ ps->first_time = 0.0;
+ ps->last_time = 0.0;
+
+ /* Update the progress bar when it gets to this value. */
+ progbar_nextstep = 0;
+ /* When we reach the value that triggers a progress bar update,
+ bump that value by this amount. */
+ progbar_quantum = cf->count/N_PROGBAR_UPDATES;
+ /* Count of packets at which we've looked. */
+ count = 0;
+ /* Progress so far. */
+ progbar_val = 0.0f;
+
+ stop_flag = FALSE;
+ g_get_current_time(&start_time);
+
+ tot_packets = 0;
+ tot_bytes = 0;
+
+ for (framenum = 1; framenum <= cf->count; framenum++) {
+ frame = frame_data_sequence_find(cf->frames, framenum);
+
+ /* Create the progress bar if necessary.
+ We check on every iteration of the loop, so that
+ it takes no longer than the standard time to create
+ it (otherwise, for a large file, we might take
+ considerably longer than that standard time in order
+ to get to the next progress bar step). */
+ if (progbar == NULL)
+ progbar = delayed_create_progress_dlg(
+ cf->window, "Computing",
+ "protocol hierarchy statistics",
+ TRUE, &stop_flag, &start_time, progbar_val);
+
+ /* Update the progress bar, but do it only N_PROGBAR_UPDATES
+ times; when we update it, we have to run the GTK+ main
+ loop to get it to repaint what's pending, and doing so
+ may involve an "ioctl()" to see if there's any pending
+ input from an X server, and doing that for every packet
+ can be costly, especially on a big file. */
+ if (count >= progbar_nextstep) {
+ /* let's not divide by zero. I should never be started
+ * with count == 0, so let's assert that
+ */
+ g_assert(cf->count > 0);
+
+ progbar_val = (gfloat) count / cf->count;
+
+ if (progbar != NULL) {
+ g_snprintf(status_str, sizeof(status_str),
+ "%4u of %u frames", count, cf->count);
+ update_progress_dlg(progbar, progbar_val, status_str);
+ }
+
+ progbar_nextstep += progbar_quantum;
+ }
+
+ if (stop_flag) {
+ /* Well, the user decided to abort the statistics.
+ computation process Just stop. */
+ break;
+ }
+
+ /* Skip frames that are hidden due to the display filter.
+ XXX - should the progress bar count only packets that
+ passed the display filter? If so, it should
+ probably do so for other loops (see "file.c") that
+ look only at those packets. */
+ if (frame->flags.passed_dfilter) {
+
+ if (frame->flags.has_ts) {
+ if (tot_packets == 0) {
+ double cur_time = nstime_to_sec(&frame->abs_ts);
+ ps->first_time = cur_time;
+ ps->last_time = cur_time;
+ }
+ }
+
+ /* we don't care about colinfo */
+ if (!process_record(cf, frame, NULL, ps)) {
+ /*
+ * Give up, and set "stop_flag" so we
+ * just abort rather than popping up
+ * the statistics window.
+ */
+ stop_flag = TRUE;
+ break;
+ }
+
+ tot_packets++;
+ tot_bytes += frame->pkt_len;
+ }
+
+ count++;
+ }
+
+ /* We're done calculating the statistics; destroy the progress bar
+ if it was created. */
+ if (progbar != NULL)
+ destroy_progress_dlg(progbar);
+
+ if (stop_flag) {
+ /*
+ * We quit in the middle; throw away the statistics
+ * and return NULL, so our caller doesn't pop up a
+ * window with the incomplete statistics.
+ */
+ ph_stats_free(ps);
+ return NULL;
+ }
+
+ ps->tot_packets = tot_packets;
+ ps->tot_bytes = tot_bytes;
+
+ return ps;
}
-static gboolean
+ static gboolean
stat_node_free(GNode *node, gpointer data _U_)
{
- ph_stats_node_t *stats = (ph_stats_node_t *)node->data;
- g_free(stats);
- return FALSE;
+ ph_stats_node_t *stats = (ph_stats_node_t *)node->data;
+ g_free(stats);
+ return FALSE;
}
-void
+ void
ph_stats_free(ph_stats_t *ps)
{
-
- if (ps->stats_tree) {
- g_node_traverse(ps->stats_tree, G_IN_ORDER,
- G_TRAVERSE_ALL, -1,
- stat_node_free, NULL);
- g_node_destroy(ps->stats_tree);
- }
-
- g_free(ps);
+ if (ps->stats_tree) {
+ g_node_traverse(ps->stats_tree, G_IN_ORDER,
+ G_TRAVERSE_ALL, -1,
+ stat_node_free, NULL);
+ g_node_destroy(ps->stats_tree);
+ }
+
+ g_free(ps);
}
/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
- * Local variables:
- * c-basic-offset: 8
+ * Local Variables:
+ * c-basic-offset: 4
* tab-width: 8
- * indent-tabs-mode: t
+ * indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=8 tabstop=8 noexpandtab:
- * :indentSize=8:tabSize=8:noTabs=false:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/proto_hier_stats.h b/ui/proto_hier_stats.h
index 6bfdadb540..6594e8c9af 100644
--- a/ui/proto_hier_stats.h
+++ b/ui/proto_hier_stats.h
@@ -4,19 +4,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __UI_PROTO_HIER_STATS_H__
@@ -33,20 +21,20 @@ extern "C" {
#include <epan/proto.h>
typedef struct {
- header_field_info *hfinfo;
- guint num_pkts_total;
- guint num_pkts_last;
- guint num_bytes_total;
- guint num_bytes_last;
+ header_field_info *hfinfo;
+ guint num_pkts_total;
+ guint num_pkts_last;
+ guint num_bytes_total;
+ guint num_bytes_last;
} ph_stats_node_t;
typedef struct {
- guint tot_packets;
- guint tot_bytes;
- GNode *stats_tree;
- double first_time; /* seconds (msec resolution) of first packet */
- double last_time; /* seconds (msec resolution) of last packet */
+ guint tot_packets;
+ guint tot_bytes;
+ GNode *stats_tree;
+ double first_time; /* seconds (msec resolution) of first packet */
+ double last_time; /* seconds (msec resolution) of last packet */
} ph_stats_t;
struct _capture_file;
@@ -61,14 +49,14 @@ void ph_stats_free(ph_stats_t *ps);
#endif /* __UI_PROTO_HIER_STATS_H__ */
/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
- * Local variables:
- * c-basic-offset: 8
+ * Local Variables:
+ * c-basic-offset: 4
* tab-width: 8
- * indent-tabs-mode: t
+ * indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=8 tabstop=8 noexpandtab:
- * :indentSize=8:tabSize=8:noTabs=false:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/recent.c b/ui/recent.c
index 7aab5e3470..0b7562621e 100644
--- a/ui/recent.c
+++ b/ui/recent.c
@@ -6,19 +6,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -88,52 +76,52 @@
recent_settings_t recent;
static const value_string ts_type_values[] = {
- { TS_RELATIVE, "RELATIVE" },
- { TS_ABSOLUTE, "ABSOLUTE" },
- { TS_ABSOLUTE_WITH_YMD, "ABSOLUTE_WITH_YMD" },
- { TS_ABSOLUTE_WITH_YDOY, "ABSOLUTE_WITH_YDOY" },
- { TS_ABSOLUTE_WITH_YMD, "ABSOLUTE_WITH_DATE" }, /* Backward compability */
- { TS_DELTA, "DELTA" },
- { TS_DELTA_DIS, "DELTA_DIS" },
- { TS_EPOCH, "EPOCH" },
- { TS_UTC, "UTC" },
- { TS_UTC_WITH_YMD, "UTC_WITH_YMD" },
- { TS_UTC_WITH_YDOY, "UTC_WITH_YDOY" },
- { TS_UTC_WITH_YMD, "UTC_WITH_DATE" }, /* Backward compability */
- { 0, NULL }
+ { TS_RELATIVE, "RELATIVE" },
+ { TS_ABSOLUTE, "ABSOLUTE" },
+ { TS_ABSOLUTE_WITH_YMD, "ABSOLUTE_WITH_YMD" },
+ { TS_ABSOLUTE_WITH_YDOY, "ABSOLUTE_WITH_YDOY" },
+ { TS_ABSOLUTE_WITH_YMD, "ABSOLUTE_WITH_DATE" }, /* Backward compability */
+ { TS_DELTA, "DELTA" },
+ { TS_DELTA_DIS, "DELTA_DIS" },
+ { TS_EPOCH, "EPOCH" },
+ { TS_UTC, "UTC" },
+ { TS_UTC_WITH_YMD, "UTC_WITH_YMD" },
+ { TS_UTC_WITH_YDOY, "UTC_WITH_YDOY" },
+ { TS_UTC_WITH_YMD, "UTC_WITH_DATE" }, /* Backward compability */
+ { 0, NULL }
};
static const value_string ts_precision_values[] = {
- { TS_PREC_AUTO, "AUTO" },
- { TS_PREC_FIXED_SEC, "SEC" },
- { TS_PREC_FIXED_DSEC, "DSEC" },
- { TS_PREC_FIXED_CSEC, "CSEC" },
- { TS_PREC_FIXED_MSEC, "MSEC" },
- { TS_PREC_FIXED_USEC, "USEC" },
- { TS_PREC_FIXED_NSEC, "NSEC" },
- { 0, NULL }
+ { TS_PREC_AUTO, "AUTO" },
+ { TS_PREC_FIXED_SEC, "SEC" },
+ { TS_PREC_FIXED_DSEC, "DSEC" },
+ { TS_PREC_FIXED_CSEC, "CSEC" },
+ { TS_PREC_FIXED_MSEC, "MSEC" },
+ { TS_PREC_FIXED_USEC, "USEC" },
+ { TS_PREC_FIXED_NSEC, "NSEC" },
+ { 0, NULL }
};
static const value_string ts_seconds_values[] = {
- { TS_SECONDS_DEFAULT, "SECONDS" },
- { TS_SECONDS_HOUR_MIN_SEC, "HOUR_MIN_SEC" },
- { 0, NULL }
+ { TS_SECONDS_DEFAULT, "SECONDS" },
+ { TS_SECONDS_HOUR_MIN_SEC, "HOUR_MIN_SEC" },
+ { 0, NULL }
};
static void
free_col_width_data(gpointer data, gpointer user_data _U_)
{
- col_width_data *cfmt = (col_width_data *)data;
- g_free(cfmt->cfield);
- g_free(cfmt);
+ col_width_data *cfmt = (col_width_data *)data;
+ g_free(cfmt->cfield);
+ g_free(cfmt);
}
static void
free_col_width_info(recent_settings_t *rs)
{
- g_list_foreach(rs->col_width_list, free_col_width_data, NULL);
- g_list_free(rs->col_width_list);
- rs->col_width_list = NULL;
+ g_list_foreach(rs->col_width_list, free_col_width_data, NULL);
+ g_list_free(rs->col_width_list);
+ rs->col_width_list = NULL;
}
/** Write the geometry values of a single window to the recent file.
@@ -145,21 +133,21 @@ free_col_width_info(recent_settings_t *rs)
static void
write_recent_geom(gpointer key _U_, gpointer value, gpointer rfh)
{
- window_geometry_t *geom = (window_geometry_t *)value;
- FILE *rf = (FILE *)rfh;
-
- fprintf(rf, "\n# Geometry and maximized state of %s window.\n", geom->key);
- fprintf(rf, "# Decimal integers.\n");
- fprintf(rf, RECENT_GUI_GEOMETRY "%s.x: %d\n", geom->key, geom->x);
- fprintf(rf, RECENT_GUI_GEOMETRY "%s.y: %d\n", geom->key, geom->y);
- fprintf(rf, RECENT_GUI_GEOMETRY "%s.width: %d\n", geom->key,
- geom->width);
- fprintf(rf, RECENT_GUI_GEOMETRY "%s.height: %d\n", geom->key,
- geom->height);
-
- fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
- fprintf(rf, RECENT_GUI_GEOMETRY "%s.maximized: %s\n", geom->key,
- geom->maximized == TRUE ? "TRUE" : "FALSE");
+ window_geometry_t *geom = (window_geometry_t *)value;
+ FILE *rf = (FILE *)rfh;
+
+ fprintf(rf, "\n# Geometry and maximized state of %s window.\n", geom->key);
+ fprintf(rf, "# Decimal integers.\n");
+ fprintf(rf, RECENT_GUI_GEOMETRY "%s.x: %d\n", geom->key, geom->x);
+ fprintf(rf, RECENT_GUI_GEOMETRY "%s.y: %d\n", geom->key, geom->y);
+ fprintf(rf, RECENT_GUI_GEOMETRY "%s.width: %d\n", geom->key,
+ geom->width);
+ fprintf(rf, RECENT_GUI_GEOMETRY "%s.height: %d\n", geom->key,
+ geom->height);
+
+ fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
+ fprintf(rf, RECENT_GUI_GEOMETRY "%s.maximized: %s\n", geom->key,
+ geom->maximized == TRUE ? "TRUE" : "FALSE");
}
@@ -171,27 +159,27 @@ static GHashTable *window_geom_hash = NULL;
void
window_geom_save(const gchar *name, window_geometry_t *geom)
{
- gchar *key;
- window_geometry_t *work;
-
- /* init hashtable, if not already done */
- if (!window_geom_hash) {
- window_geom_hash = g_hash_table_new(g_str_hash, g_str_equal);
- }
- /* if we have an old one, remove and free it first */
- work = (window_geometry_t *)g_hash_table_lookup(window_geom_hash, name);
- if (work) {
- g_hash_table_remove(window_geom_hash, name);
- g_free(work->key);
- g_free(work);
- }
-
- /* g_malloc and insert the new one */
- work = (window_geometry_t *)g_malloc(sizeof(window_geometry_t));
- *work = *geom;
- key = g_strdup(name);
- work->key = key;
- g_hash_table_insert(window_geom_hash, key, work);
+ gchar *key;
+ window_geometry_t *work;
+
+ /* init hashtable, if not already done */
+ if (!window_geom_hash) {
+ window_geom_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ }
+ /* if we have an old one, remove and free it first */
+ work = (window_geometry_t *)g_hash_table_lookup(window_geom_hash, name);
+ if (work) {
+ g_hash_table_remove(window_geom_hash, name);
+ g_free(work->key);
+ g_free(work);
+ }
+
+ /* g_malloc and insert the new one */
+ work = (window_geometry_t *)g_malloc(sizeof(window_geometry_t));
+ *work = *geom;
+ key = g_strdup(name);
+ work->key = key;
+ g_hash_table_insert(window_geom_hash, key, work);
}
/* load the desired geometry for this window from the geometry hashtable */
@@ -199,20 +187,20 @@ gboolean
window_geom_load(const gchar *name,
window_geometry_t *geom)
{
- window_geometry_t *p;
+ window_geometry_t *p;
- /* init hashtable, if not already done */
- if (!window_geom_hash) {
- window_geom_hash = g_hash_table_new(g_str_hash, g_str_equal);
- }
+ /* init hashtable, if not already done */
+ if (!window_geom_hash) {
+ window_geom_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ }
- p = (window_geometry_t *)g_hash_table_lookup(window_geom_hash, name);
- if (p) {
- *geom = *p;
- return TRUE;
- } else {
- return FALSE;
- }
+ p = (window_geometry_t *)g_hash_table_lookup(window_geom_hash, name);
+ if (p) {
+ *geom = *p;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
/* parse values of particular types */
@@ -238,50 +226,50 @@ window_geom_recent_read_pair(const char *name,
const char *key,
const char *value)
{
- window_geometry_t geom;
-
- /* find window geometry maybe already in hashtable */
- if (!window_geom_load(name, &geom)) {
- /* not in table, init geom with "basic" values */
- geom.key = NULL; /* Will be set in window_geom_save() */
- geom.set_pos = FALSE;
- geom.x = -1;
- geom.y = -1;
- geom.set_size = FALSE;
- geom.width = -1;
- geom.height = -1;
-
- geom.set_maximized = FALSE;/* this is valid in GTK2 only */
- geom.maximized = FALSE; /* this is valid in GTK2 only */
- }
-
- if (strcmp(key, "x") == 0) {
- geom.x = (gint)strtol(value, NULL, 10);
- geom.set_pos = TRUE;
- } else if (strcmp(key, "y") == 0) {
- geom.y = (gint)strtol(value, NULL, 10);
- geom.set_pos = TRUE;
- } else if (strcmp(key, "width") == 0) {
- geom.width = (gint)strtol(value, NULL, 10);
- geom.set_size = TRUE;
- } else if (strcmp(key, "height") == 0) {
- geom.height = (gint)strtol(value, NULL, 10);
- geom.set_size = TRUE;
- } else if (strcmp(key, "maximized") == 0) {
- parse_recent_boolean(value, &geom.maximized);
- geom.set_maximized = TRUE;
- } else {
- /*
- * Silently ignore the bogus key. We shouldn't abort here,
- * as this could be due to a corrupt recent file.
- *
- * XXX - should we print a message about this?
- */
- return;
- }
+ window_geometry_t geom;
+
+ /* find window geometry maybe already in hashtable */
+ if (!window_geom_load(name, &geom)) {
+ /* not in table, init geom with "basic" values */
+ geom.key = NULL; /* Will be set in window_geom_save() */
+ geom.set_pos = FALSE;
+ geom.x = -1;
+ geom.y = -1;
+ geom.set_size = FALSE;
+ geom.width = -1;
+ geom.height = -1;
+
+ geom.set_maximized = FALSE;/* this is valid in GTK2 only */
+ geom.maximized = FALSE; /* this is valid in GTK2 only */
+ }
- /* save / replace geometry in hashtable */
- window_geom_save(name, &geom);
+ if (strcmp(key, "x") == 0) {
+ geom.x = (gint)strtol(value, NULL, 10);
+ geom.set_pos = TRUE;
+ } else if (strcmp(key, "y") == 0) {
+ geom.y = (gint)strtol(value, NULL, 10);
+ geom.set_pos = TRUE;
+ } else if (strcmp(key, "width") == 0) {
+ geom.width = (gint)strtol(value, NULL, 10);
+ geom.set_size = TRUE;
+ } else if (strcmp(key, "height") == 0) {
+ geom.height = (gint)strtol(value, NULL, 10);
+ geom.set_size = TRUE;
+ } else if (strcmp(key, "maximized") == 0) {
+ parse_recent_boolean(value, &geom.maximized);
+ geom.set_maximized = TRUE;
+ } else {
+ /*
+ * Silently ignore the bogus key. We shouldn't abort here,
+ * as this could be due to a corrupt recent file.
+ *
+ * XXX - should we print a message about this?
+ */
+ return;
+ }
+
+ /* save / replace geometry in hashtable */
+ window_geom_save(name, &geom);
}
/** Write all geometry values of all windows to the recent file.
@@ -292,12 +280,12 @@ window_geom_recent_read_pair(const char *name,
static void
window_geom_recent_write_all(FILE *rf)
{
- /* init hashtable, if not already done */
- if (!window_geom_hash) {
- window_geom_hash = g_hash_table_new(g_str_hash, g_str_equal);
- }
+ /* init hashtable, if not already done */
+ if (!window_geom_hash) {
+ window_geom_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ }
- g_hash_table_foreach(window_geom_hash, write_recent_geom, rf);
+ g_hash_table_foreach(window_geom_hash, write_recent_geom, rf);
}
/* Global list of recent capture filters. */
@@ -320,13 +308,13 @@ static guint cfilter_combo_max_recent = 20;
GList *
recent_get_cfilter_list(const gchar *ifname)
{
- if (ifname == NULL)
- return recent_cfilter_list;
- if (per_interface_cfilter_lists_hash == NULL) {
- /* No such lists exist. */
- return NULL;
- }
- return (GList *)g_hash_table_lookup(per_interface_cfilter_lists_hash, ifname);
+ if (ifname == NULL)
+ return recent_cfilter_list;
+ if (per_interface_cfilter_lists_hash == NULL) {
+ /* No such lists exist. */
+ return NULL;
+ }
+ return (GList *)g_hash_table_lookup(per_interface_cfilter_lists_hash, ifname);
}
/**
@@ -339,48 +327,48 @@ recent_get_cfilter_list(const gchar *ifname)
void
recent_add_cfilter(const gchar *ifname, const gchar *s)
{
- GList *cfilter_list;
- GList *li;
- gchar *li_filter, *newfilter = NULL;
-
- /* Don't add empty filters to the list. */
- if (s[0] == '\0')
- return;
-
- if (ifname == NULL)
- cfilter_list = recent_cfilter_list;
- else {
- /* If we don't yet have a hash table for per-interface recent
- capture filter lists, create one. Have it free the new key
- if we're updating an entry rather than creating it below. */
- if (per_interface_cfilter_lists_hash == NULL)
- per_interface_cfilter_lists_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
- cfilter_list = (GList *)g_hash_table_lookup(per_interface_cfilter_lists_hash, ifname);
- }
-
- li = g_list_first(cfilter_list);
- while (li) {
- /* If the filter is already in the list, remove the old one and
- * append the new one at the latest position (at g_list_append() below) */
- li_filter = (char *)li->data;
- if (strcmp(s, li_filter) == 0) {
- /* No need to copy the string, we're just moving it. */
- newfilter = li_filter;
- cfilter_list = g_list_remove(cfilter_list, li->data);
- break;
+ GList *cfilter_list;
+ GList *li;
+ gchar *li_filter, *newfilter = NULL;
+
+ /* Don't add empty filters to the list. */
+ if (s[0] == '\0')
+ return;
+
+ if (ifname == NULL)
+ cfilter_list = recent_cfilter_list;
+ else {
+ /* If we don't yet have a hash table for per-interface recent
+ capture filter lists, create one. Have it free the new key
+ if we're updating an entry rather than creating it below. */
+ if (per_interface_cfilter_lists_hash == NULL)
+ per_interface_cfilter_lists_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ cfilter_list = (GList *)g_hash_table_lookup(per_interface_cfilter_lists_hash, ifname);
+ }
+
+ li = g_list_first(cfilter_list);
+ while (li) {
+ /* If the filter is already in the list, remove the old one and
+ * append the new one at the latest position (at g_list_append() below) */
+ li_filter = (char *)li->data;
+ if (strcmp(s, li_filter) == 0) {
+ /* No need to copy the string, we're just moving it. */
+ newfilter = li_filter;
+ cfilter_list = g_list_remove(cfilter_list, li->data);
+ break;
+ }
+ li = li->next;
+ }
+ if (newfilter == NULL) {
+ /* The filter wasn't already in the list; make a copy to add. */
+ newfilter = g_strdup(s);
}
- li = li->next;
- }
- if (newfilter == NULL) {
- /* The filter wasn't already in the list; make a copy to add. */
- newfilter = g_strdup(s);
- }
- cfilter_list = g_list_append(cfilter_list, newfilter);
-
- if (ifname == NULL)
- recent_cfilter_list = cfilter_list;
- else
- g_hash_table_insert(per_interface_cfilter_lists_hash, g_strdup(ifname), cfilter_list);
+ cfilter_list = g_list_append(cfilter_list, newfilter);
+
+ if (ifname == NULL)
+ recent_cfilter_list = cfilter_list;
+ else
+ g_hash_table_insert(per_interface_cfilter_lists_hash, g_strdup(ifname), cfilter_list);
}
#ifdef HAVE_PCAP_REMOTE
@@ -388,158 +376,159 @@ static GHashTable *remote_host_list=NULL;
int recent_get_remote_host_list_size(void)
{
- if (remote_host_list == NULL) {
- /* No entries exist. */
- return 0;
- }
- return g_hash_table_size (remote_host_list);
+ if (remote_host_list == NULL) {
+ /* No entries exist. */
+ return 0;
+ }
+ return g_hash_table_size (remote_host_list);
}
void recent_add_remote_host(gchar *host, struct remote_host *rh)
{
- if (remote_host_list == NULL) {
- remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
- }
- g_hash_table_insert (remote_host_list, g_strdup(host), rh);
+ if (remote_host_list == NULL) {
+ remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+ g_hash_table_insert (remote_host_list, g_strdup(host), rh);
}
static gboolean
free_remote_host (gpointer key _U_, gpointer value, gpointer user _U_)
{
- struct remote_host *rh = (struct remote_host *) value;
+ struct remote_host *rh = (struct remote_host *) value;
- g_free (rh->r_host);
- g_free (rh->remote_port);
- g_free (rh->auth_username);
- g_free (rh->auth_password);
+ g_free (rh->r_host);
+ g_free (rh->remote_port);
+ g_free (rh->auth_username);
+ g_free (rh->auth_password);
- return TRUE;
+ return TRUE;
}
void
recent_remote_host_list_foreach(GHFunc func, gpointer user_data)
{
- if (remote_host_list != NULL)
- g_hash_table_foreach(remote_host_list, func, user_data);
+ if (remote_host_list != NULL) {
+ g_hash_table_foreach(remote_host_list, func, user_data);
+ }
}
static void
recent_print_remote_host (gpointer key _U_, gpointer value, gpointer user)
{
- FILE *rf = (FILE *)user;
- struct remote_host_info *ri = (struct remote_host_info *)value;
+ FILE *rf = (FILE *)user;
+ struct remote_host_info *ri = (struct remote_host_info *)value;
- fprintf (rf, RECENT_KEY_REMOTE_HOST ": %s,%s,%d\n", ri->remote_host, ri->remote_port, ri->auth_type);
+ fprintf (rf, RECENT_KEY_REMOTE_HOST ": %s,%s,%d\n", ri->remote_host, ri->remote_port, ri->auth_type);
}
void
capture_remote_combo_recent_write_all(FILE *rf)
{
- if (remote_host_list && g_hash_table_size (remote_host_list) > 0) {
- /* Write all remote interfaces to the recent file */
- g_hash_table_foreach (remote_host_list, recent_print_remote_host, rf);
- }
+ if (remote_host_list && g_hash_table_size (remote_host_list) > 0) {
+ /* Write all remote interfaces to the recent file */
+ g_hash_table_foreach (remote_host_list, recent_print_remote_host, rf);
+ }
}
void recent_free_remote_host_list(void)
{
- g_hash_table_foreach_remove(remote_host_list, free_remote_host, NULL);
+ g_hash_table_foreach_remove(remote_host_list, free_remote_host, NULL);
}
struct remote_host *
recent_get_remote_host(const gchar *host)
{
- if (host == NULL)
- return NULL;
- if (remote_host_list == NULL) {
- /* No such host exist. */
- return NULL;
- }
- return (struct remote_host *)g_hash_table_lookup(remote_host_list, host);
+ if (host == NULL)
+ return NULL;
+ if (remote_host_list == NULL) {
+ /* No such host exist. */
+ return NULL;
+ }
+ return (struct remote_host *)g_hash_table_lookup(remote_host_list, host);
}
gboolean
capture_remote_combo_add_recent(const gchar *s)
{
- GList *vals = prefs_get_string_list (s);
- GList *valp = vals;
- capture_auth auth_type;
- char *p;
- struct remote_host *rh;
-
- if (valp == NULL)
- return FALSE;
-
- if (remote_host_list == NULL) {
- remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- rh =(struct remote_host *) g_malloc (sizeof (*rh));
-
- /* First value is the host */
- rh->r_host = (gchar *)g_strdup ((const gchar *)valp->data);
- if (strlen(rh->r_host) == 0) {
- /* Empty remote host */
- g_free(rh->r_host);
- g_free(rh);
- return FALSE;
- }
- rh->auth_type = CAPTURE_AUTH_NULL;
- valp = valp->next;
-
- if (valp) {
- /* Found value 2, this is the port number */
- rh->remote_port = (gchar *)g_strdup ((const gchar *)valp->data);
+ GList *vals = prefs_get_string_list (s);
+ GList *valp = vals;
+ capture_auth auth_type;
+ char *p;
+ struct remote_host *rh;
+
+ if (valp == NULL)
+ return FALSE;
+
+ if (remote_host_list == NULL) {
+ remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+
+ rh =(struct remote_host *) g_malloc (sizeof (*rh));
+
+ /* First value is the host */
+ rh->r_host = (gchar *)g_strdup ((const gchar *)valp->data);
+ if (strlen(rh->r_host) == 0) {
+ /* Empty remote host */
+ g_free(rh->r_host);
+ g_free(rh);
+ return FALSE;
+ }
+ rh->auth_type = CAPTURE_AUTH_NULL;
valp = valp->next;
- } else {
- /* Did not find a port number */
- rh->remote_port = g_strdup ("");
- }
-
- if (valp) {
- /* Found value 3, this is the authentication type */
- auth_type = (capture_auth)strtol((const gchar *)valp->data, &p, 0);
- if (p != valp->data && *p == '\0') {
- rh->auth_type = auth_type;
+
+ if (valp) {
+ /* Found value 2, this is the port number */
+ rh->remote_port = (gchar *)g_strdup ((const gchar *)valp->data);
+ valp = valp->next;
+ } else {
+ /* Did not find a port number */
+ rh->remote_port = g_strdup ("");
}
- }
- /* Do not store username and password */
- rh->auth_username = g_strdup ("");
- rh->auth_password = g_strdup ("");
+ if (valp) {
+ /* Found value 3, this is the authentication type */
+ auth_type = (capture_auth)strtol((const gchar *)valp->data, &p, 0);
+ if (p != valp->data && *p == '\0') {
+ rh->auth_type = auth_type;
+ }
+ }
- prefs_clear_string_list(vals);
+ /* Do not store username and password */
+ rh->auth_username = g_strdup ("");
+ rh->auth_password = g_strdup ("");
- g_hash_table_insert (remote_host_list, g_strdup(rh->r_host), rh);
+ prefs_clear_string_list(vals);
- return TRUE;
+ g_hash_table_insert (remote_host_list, g_strdup(rh->r_host), rh);
+
+ return TRUE;
}
#endif
static void
cfilter_recent_write_all_list(FILE *rf, const gchar *ifname, GList *cfilter_list)
{
- guint max_count = 0;
- GList *li;
-
- /* write all non empty capture filter strings to the recent file (until max count) */
- li = g_list_first(cfilter_list);
- while (li && (max_count++ <= cfilter_combo_max_recent) ) {
- if (li->data && strlen((const char *)li->data)) {
- if (ifname == NULL)
- fprintf (rf, RECENT_KEY_CAPTURE_FILTER ": %s\n", (char *)li->data);
- else
- fprintf (rf, RECENT_KEY_CAPTURE_FILTER ".%s: %s\n", ifname, (char *)li->data);
+ guint max_count = 0;
+ GList *li;
+
+ /* write all non empty capture filter strings to the recent file (until max count) */
+ li = g_list_first(cfilter_list);
+ while (li && (max_count++ <= cfilter_combo_max_recent) ) {
+ if (li->data && strlen((const char *)li->data)) {
+ if (ifname == NULL)
+ fprintf (rf, RECENT_KEY_CAPTURE_FILTER ": %s\n", (char *)li->data);
+ else
+ fprintf (rf, RECENT_KEY_CAPTURE_FILTER ".%s: %s\n", ifname, (char *)li->data);
+ }
+ li = li->next;
}
- li = li->next;
- }
}
static void
cfilter_recent_write_all_hash_callback(gpointer key, gpointer value, gpointer user_data)
{
- cfilter_recent_write_all_list((FILE *)user_data, (const gchar *)key, (GList *)value);
+ cfilter_recent_write_all_list((FILE *)user_data, (const gchar *)key, (GList *)value);
}
/** Write all capture filter values to the recent file.
@@ -549,13 +538,13 @@ cfilter_recent_write_all_hash_callback(gpointer key, gpointer value, gpointer us
static void
cfilter_recent_write_all(FILE *rf)
{
- /* Write out the global list. */
- cfilter_recent_write_all_list(rf, NULL, recent_cfilter_list);
+ /* Write out the global list. */
+ cfilter_recent_write_all_list(rf, NULL, recent_cfilter_list);
- /* Write out all the per-interface lists. */
- if (per_interface_cfilter_lists_hash != NULL) {
- g_hash_table_foreach(per_interface_cfilter_lists_hash, cfilter_recent_write_all_hash_callback, (gpointer)rf);
- }
+ /* Write out all the per-interface lists. */
+ if (per_interface_cfilter_lists_hash != NULL) {
+ g_hash_table_foreach(per_interface_cfilter_lists_hash, cfilter_recent_write_all_hash_callback, (gpointer)rf);
+ }
}
/* Write out recent settings of particular types. */
@@ -563,32 +552,32 @@ static void
write_recent_boolean(FILE *rf, const char *description, const char *name,
gboolean value)
{
- fprintf(rf, "\n# %s.\n", description);
- fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
- fprintf(rf, "%s: %s\n", name, value == TRUE ? "TRUE" : "FALSE");
+ fprintf(rf, "\n# %s.\n", description);
+ fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
+ fprintf(rf, "%s: %s\n", name, value == TRUE ? "TRUE" : "FALSE");
}
static void
write_recent_enum(FILE *rf, const char *description, const char *name,
const value_string *values, guint value)
{
- const char *if_invalid = NULL;
- const value_string *valp;
-
- fprintf(rf, "\n# %s.\n", description);
- fprintf(rf, "# One of: ");
- valp = values;
- while (valp->strptr != NULL) {
- if (if_invalid == NULL)
- if_invalid = valp->strptr;
- fprintf(rf, "%s", valp->strptr);
- valp++;
- if (valp->strptr != NULL)
- fprintf(rf, ", ");
- }
- fprintf(rf, "\n");
- fprintf(rf, "%s: %s\n", name,
- val_to_str(value, values, if_invalid != NULL ? if_invalid : "Unknown"));
+ const char *if_invalid = NULL;
+ const value_string *valp;
+
+ fprintf(rf, "\n# %s.\n", description);
+ fprintf(rf, "# One of: ");
+ valp = values;
+ while (valp->strptr != NULL) {
+ if (if_invalid == NULL)
+ if_invalid = valp->strptr;
+ fprintf(rf, "%s", valp->strptr);
+ valp++;
+ if (valp->strptr != NULL)
+ fprintf(rf, ", ");
+ }
+ fprintf(rf, "\n");
+ fprintf(rf, "%s: %s\n", name,
+ val_to_str(value, values, if_invalid != NULL ? if_invalid : "Unknown"));
}
/* Attempt to write out "recent common" to the user's recent common file.
@@ -597,126 +586,126 @@ write_recent_enum(FILE *rf, const char *description, const char *name,
gboolean
write_recent(void)
{
- char *pf_dir_path;
- char *rf_path;
- FILE *rf;
- char *string_list;
-
- /* To do:
- * - Split output lines longer than MAX_VAL_LEN
- * - Create a function for the preference directory check/creation
- * so that duplication can be avoided with filter.c
- */
-
- /* Create the directory that holds personal configuration files, if
- necessary. */
- if (create_persconffile_dir(&pf_dir_path) == -1) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path,
- g_strerror(errno));
- g_free(pf_dir_path);
- return FALSE;
- }
-
- rf_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE);
- if ((rf = ws_fopen(rf_path, "w")) == NULL) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Can't open recent file\n\"%s\": %s.", rf_path,
- g_strerror(errno));
+ char *pf_dir_path;
+ char *rf_path;
+ FILE *rf;
+ char *string_list;
+
+ /* To do:
+ * - Split output lines longer than MAX_VAL_LEN
+ * - Create a function for the preference directory check/creation
+ * so that duplication can be avoided with filter.c
+ */
+
+ /* Create the directory that holds personal configuration files, if
+ necessary. */
+ if (create_persconffile_dir(&pf_dir_path) == -1) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path,
+ g_strerror(errno));
+ g_free(pf_dir_path);
+ return FALSE;
+ }
+
+ rf_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE);
+ if ((rf = ws_fopen(rf_path, "w")) == NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Can't open recent file\n\"%s\": %s.", rf_path,
+ g_strerror(errno));
+ g_free(rf_path);
+ return FALSE;
+ }
g_free(rf_path);
- return FALSE;
- }
- g_free(rf_path);
- fputs("# Recent settings file for Wireshark " VERSION ".\n"
- "#\n"
- "# This file is regenerated each time Wireshark is quit.\n"
- "# So be careful, if you want to make manual changes here.\n"
- "\n"
- "######## Recent capture files (latest last), cannot be altered through command line ########\n"
- "\n", rf);
+ fputs("# Recent settings file for Wireshark " VERSION ".\n"
+ "#\n"
+ "# This file is regenerated each time Wireshark is quit.\n"
+ "# So be careful, if you want to make manual changes here.\n"
+ "\n"
+ "######## Recent capture files (latest last), cannot be altered through command line ########\n"
+ "\n", rf);
- menu_recent_file_write_all(rf);
+ menu_recent_file_write_all(rf);
- fputs("\n"
- "######## Recent capture filters (latest last), cannot be altered through command line ########\n"
- "\n", rf);
+ fputs("\n"
+ "######## Recent capture filters (latest last), cannot be altered through command line ########\n"
+ "\n", rf);
- cfilter_recent_write_all(rf);
+ cfilter_recent_write_all(rf);
- fputs("\n"
- "######## Recent display filters (latest last), cannot be altered through command line ########\n"
- "\n", rf);
+ fputs("\n"
+ "######## Recent display filters (latest last), cannot be altered through command line ########\n"
+ "\n", rf);
- dfilter_recent_combo_write_all(rf);
+ dfilter_recent_combo_write_all(rf);
#ifdef HAVE_PCAP_REMOTE
- fputs("\n"
- "######## Recent remote hosts, cannot be altered through command line ########\n"
- "\n", rf);
+ fputs("\n"
+ "######## Recent remote hosts, cannot be altered through command line ########\n"
+ "\n", rf);
- capture_remote_combo_recent_write_all(rf);
+ capture_remote_combo_recent_write_all(rf);
#endif
- fprintf(rf, "\n# Main window geometry.\n");
- fprintf(rf, "# Decimal numbers.\n");
- fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_X ": %d\n", recent.gui_geometry_main_x);
- fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_Y ": %d\n", recent.gui_geometry_main_y);
- fprintf(rf, RECENT_GUI_GTK_GEOMETRY_MAIN_X ": %d\n", recent.gui_gtk_geometry_main_x);
- fprintf(rf, RECENT_GUI_GTK_GEOMETRY_MAIN_Y ": %d\n", recent.gui_gtk_geometry_main_y);
- fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_WIDTH ": %d\n",
- recent.gui_geometry_main_width);
- fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
- recent.gui_geometry_main_height);
-
- write_recent_boolean(rf, "Main window maximized",
- RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED,
- recent.gui_geometry_main_maximized);
-
- fprintf(rf, "\n# Statusbar left pane size.\n");
- fprintf(rf, "# Decimal number.\n");
- if (recent.gui_geometry_status_pane_left != 0) {
- fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE_LEFT ": %d\n",
- recent.gui_geometry_status_pane_left);
- }
- fprintf(rf, "\n# Statusbar middle pane size.\n");
- fprintf(rf, "# Decimal number.\n");
- if (recent.gui_geometry_status_pane_right != 0) {
- fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE_RIGHT ": %d\n",
- recent.gui_geometry_status_pane_right);
- }
-
- fprintf(rf, "\n# Last used Configuration Profile.\n");
- fprintf(rf, RECENT_LAST_USED_PROFILE ": %s\n", get_profile_name());
-
- fprintf(rf, "\n# WLAN statistics upper pane size.\n");
- fprintf(rf, "# Decimal number.\n");
- fprintf(rf, RECENT_GUI_GEOMETRY_WLAN_STATS_PANE ": %d\n",
- recent.gui_geometry_wlan_stats_pane);
-
- write_recent_boolean(rf, "Warn if running with elevated permissions (e.g. as root)",
- RECENT_KEY_PRIVS_WARN_IF_ELEVATED,
- recent.privs_warn_if_elevated);
-
- write_recent_boolean(rf, "Warn if npf.sys isn't loaded on Windows >= 6.0",
- RECENT_KEY_PRIVS_WARN_IF_NO_NPF,
- recent.privs_warn_if_no_npf);
-
- window_geom_recent_write_all(rf);
-
- fprintf(rf, "\n# Custom colors.\n");
- fprintf(rf, "# List of custom colors selected in Qt color picker.\n");
- string_list = join_string_list(recent.custom_colors);
- fprintf(rf, RECENT_GUI_CUSTOM_COLORS ": %s\n", string_list);
- g_free(string_list);
-
- fclose(rf);
-
- /* XXX - catch I/O errors (e.g. "ran out of disk space") and return
- an error indication, or maybe write to a new recent file and
- rename that file on top of the old one only if there are not I/O
- errors. */
- return TRUE;
+ fprintf(rf, "\n# Main window geometry.\n");
+ fprintf(rf, "# Decimal numbers.\n");
+ fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_X ": %d\n", recent.gui_geometry_main_x);
+ fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_Y ": %d\n", recent.gui_geometry_main_y);
+ fprintf(rf, RECENT_GUI_GTK_GEOMETRY_MAIN_X ": %d\n", recent.gui_gtk_geometry_main_x);
+ fprintf(rf, RECENT_GUI_GTK_GEOMETRY_MAIN_Y ": %d\n", recent.gui_gtk_geometry_main_y);
+ fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_WIDTH ": %d\n",
+ recent.gui_geometry_main_width);
+ fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n",
+ recent.gui_geometry_main_height);
+
+ write_recent_boolean(rf, "Main window maximized",
+ RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED,
+ recent.gui_geometry_main_maximized);
+
+ fprintf(rf, "\n# Statusbar left pane size.\n");
+ fprintf(rf, "# Decimal number.\n");
+ if (recent.gui_geometry_status_pane_left != 0) {
+ fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE_LEFT ": %d\n",
+ recent.gui_geometry_status_pane_left);
+ }
+ fprintf(rf, "\n# Statusbar middle pane size.\n");
+ fprintf(rf, "# Decimal number.\n");
+ if (recent.gui_geometry_status_pane_right != 0) {
+ fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE_RIGHT ": %d\n",
+ recent.gui_geometry_status_pane_right);
+ }
+
+ fprintf(rf, "\n# Last used Configuration Profile.\n");
+ fprintf(rf, RECENT_LAST_USED_PROFILE ": %s\n", get_profile_name());
+
+ fprintf(rf, "\n# WLAN statistics upper pane size.\n");
+ fprintf(rf, "# Decimal number.\n");
+ fprintf(rf, RECENT_GUI_GEOMETRY_WLAN_STATS_PANE ": %d\n",
+ recent.gui_geometry_wlan_stats_pane);
+
+ write_recent_boolean(rf, "Warn if running with elevated permissions (e.g. as root)",
+ RECENT_KEY_PRIVS_WARN_IF_ELEVATED,
+ recent.privs_warn_if_elevated);
+
+ write_recent_boolean(rf, "Warn if npf.sys isn't loaded on Windows >= 6.0",
+ RECENT_KEY_PRIVS_WARN_IF_NO_NPF,
+ recent.privs_warn_if_no_npf);
+
+ window_geom_recent_write_all(rf);
+
+ fprintf(rf, "\n# Custom colors.\n");
+ fprintf(rf, "# List of custom colors selected in Qt color picker.\n");
+ string_list = join_string_list(recent.custom_colors);
+ fprintf(rf, RECENT_GUI_CUSTOM_COLORS ": %s\n", string_list);
+ g_free(string_list);
+
+ fclose(rf);
+
+ /* XXX - catch I/O errors (e.g. "ran out of disk space") and return
+ an error indication, or maybe write to a new recent file and
+ rename that file on top of the old one only if there are not I/O
+ errors. */
+ return TRUE;
}
@@ -726,161 +715,161 @@ write_recent(void)
gboolean
write_profile_recent(void)
{
- char *pf_dir_path;
- char *rf_path;
- char *string_list;
- FILE *rf;
-
- /* To do:
- * - Split output lines longer than MAX_VAL_LEN
- * - Create a function for the preference directory check/creation
- * so that duplication can be avoided with filter.c
- */
-
- /* Create the directory that holds personal configuration files, if
- necessary. */
- if (create_persconffile_dir(&pf_dir_path) == -1) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path,
- g_strerror(errno));
- g_free(pf_dir_path);
- return FALSE;
- }
-
- rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE);
- if ((rf = ws_fopen(rf_path, "w")) == NULL) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "Can't open recent file\n\"%s\": %s.", rf_path,
- g_strerror(errno));
+ char *pf_dir_path;
+ char *rf_path;
+ char *string_list;
+ FILE *rf;
+
+ /* To do:
+ * - Split output lines longer than MAX_VAL_LEN
+ * - Create a function for the preference directory check/creation
+ * so that duplication can be avoided with filter.c
+ */
+
+ /* Create the directory that holds personal configuration files, if
+ necessary. */
+ if (create_persconffile_dir(&pf_dir_path) == -1) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path,
+ g_strerror(errno));
+ g_free(pf_dir_path);
+ return FALSE;
+ }
+
+ rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE);
+ if ((rf = ws_fopen(rf_path, "w")) == NULL) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Can't open recent file\n\"%s\": %s.", rf_path,
+ g_strerror(errno));
+ g_free(rf_path);
+ return FALSE;
+ }
g_free(rf_path);
- return FALSE;
- }
- g_free(rf_path);
- fputs("# Recent settings file for Wireshark " VERSION ".\n"
- "#\n"
- "# This file is regenerated each time Wireshark is quit\n"
- "# and when changing configuration profile.\n"
- "# So be careful, if you want to make manual changes here.\n"
- "\n", rf);
+ fputs("# Recent settings file for Wireshark " VERSION ".\n"
+ "#\n"
+ "# This file is regenerated each time Wireshark is quit\n"
+ "# and when changing configuration profile.\n"
+ "# So be careful, if you want to make manual changes here.\n"
+ "\n", rf);
- write_recent_boolean(rf, "Main Toolbar show (hide)",
- RECENT_KEY_MAIN_TOOLBAR_SHOW,
- recent.main_toolbar_show);
+ write_recent_boolean(rf, "Main Toolbar show (hide)",
+ RECENT_KEY_MAIN_TOOLBAR_SHOW,
+ recent.main_toolbar_show);
- write_recent_boolean(rf, "Filter Toolbar show (hide)",
- RECENT_KEY_FILTER_TOOLBAR_SHOW,
- recent.filter_toolbar_show);
+ write_recent_boolean(rf, "Filter Toolbar show (hide)",
+ RECENT_KEY_FILTER_TOOLBAR_SHOW,
+ recent.filter_toolbar_show);
- write_recent_boolean(rf, "Wireless Settings Toolbar show (hide)",
- RECENT_KEY_WIRELESS_TOOLBAR_SHOW,
- recent.wireless_toolbar_show);
+ write_recent_boolean(rf, "Wireless Settings Toolbar show (hide)",
+ RECENT_KEY_WIRELESS_TOOLBAR_SHOW,
+ recent.wireless_toolbar_show);
#ifdef HAVE_AIRPCAP
- write_recent_boolean(rf, "Show (hide) old AirPcap driver warning dialog box",
- RECENT_KEY_DRIVER_CHECK_SHOW,
- recent.airpcap_driver_check_show);
+ write_recent_boolean(rf, "Show (hide) old AirPcap driver warning dialog box",
+ RECENT_KEY_DRIVER_CHECK_SHOW,
+ recent.airpcap_driver_check_show);
#endif
- write_recent_boolean(rf, "Packet list show (hide)",
- RECENT_KEY_PACKET_LIST_SHOW,
- recent.packet_list_show);
-
- write_recent_boolean(rf, "Tree view show (hide)",
- RECENT_KEY_TREE_VIEW_SHOW,
- recent.tree_view_show);
-
- write_recent_boolean(rf, "Byte view show (hide)",
- RECENT_KEY_BYTE_VIEW_SHOW,
- recent.byte_view_show);
-
- write_recent_boolean(rf, "Statusbar show (hide)",
- RECENT_KEY_STATUSBAR_SHOW,
- recent.statusbar_show);
-
- write_recent_boolean(rf, "Packet list colorize (hide)",
- RECENT_KEY_PACKET_LIST_COLORIZE,
- recent.packet_list_colorize);
-
- write_recent_enum(rf, "Timestamp display format",
- RECENT_GUI_TIME_FORMAT, ts_type_values,
- recent.gui_time_format);
-
- write_recent_enum(rf, "Timestamp display precision",
- RECENT_GUI_TIME_PRECISION, ts_precision_values,
- recent.gui_time_precision);
-
- write_recent_enum(rf, "Seconds display format",
- RECENT_GUI_SECONDS_FORMAT, ts_seconds_values,
- recent.gui_seconds_format);
-
- fprintf(rf, "\n# Zoom level.\n");
- fprintf(rf, "# A decimal number.\n");
- fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n",
- recent.gui_zoom_level);
-
- fprintf(rf, "\n# Bytes view.\n");
- fprintf(rf, "# A decimal number.\n");
- fprintf(rf, RECENT_GUI_BYTES_VIEW ": %d\n",
- recent.gui_bytes_view);
-
- fprintf(rf, "\n# Main window upper (or leftmost) pane size.\n");
- fprintf(rf, "# Decimal number.\n");
- if (recent.gui_geometry_main_upper_pane != 0) {
- fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE ": %d\n",
- recent.gui_geometry_main_upper_pane);
- }
- fprintf(rf, "\n# Main window middle pane size.\n");
- fprintf(rf, "# Decimal number.\n");
- if (recent.gui_geometry_main_lower_pane != 0) {
- fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE ": %d\n",
- recent.gui_geometry_main_lower_pane);
- }
-
- fprintf(rf, "\n# Packet list column pixel widths.\n");
- fprintf(rf, "# Each pair of strings consists of a column format and its pixel width.\n");
- packet_list_recent_write_all(rf);
-
- fprintf(rf, "\n# Open conversation dialog tabs.\n");
- fprintf(rf, "# List of conversation names, e.g. \"TCP\", \"IPv6\".\n");
- string_list = join_string_list(recent.conversation_tabs);
- fprintf(rf, RECENT_GUI_CONVERSATION_TABS ": %s\n", string_list);
- g_free(string_list);
-
- fprintf(rf, "\n# Open endpoint dialog tabs.\n");
- fprintf(rf, "# List of endpoint names, e.g. \"TCP\", \"IPv6\".\n");
- string_list = join_string_list(recent.endpoint_tabs);
- fprintf(rf, RECENT_GUI_ENDPOINT_TABS ": %s\n", string_list);
- g_free(string_list);
-
- write_recent_boolean(rf, "For RLC stats, whether to use RLC PDUs found inside MAC frames",
- RECENT_GUI_RLC_PDUS_FROM_MAC_FRAMES,
- recent.gui_rlc_use_pdus_from_mac);
-
- if (get_last_open_dir() != NULL) {
- fprintf(rf, "\n# Last directory navigated to in File Open dialog.\n");
- fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n", get_last_open_dir());
- }
-
- fprintf(rf, "\n# Additional Toolbars shown\n");
- fprintf(rf, "# List of additional toolbars to show.\n");
- string_list = join_string_list(recent.gui_additional_toolbars);
- fprintf(rf, RECENT_GUI_TOOLBAR_SHOW ": %s\n", string_list);
- g_free(string_list);
-
- fprintf(rf, "\n# Interface Toolbars show.\n");
- fprintf(rf, "# List of interface toolbars to show.\n");
- string_list = join_string_list(recent.interface_toolbars);
- fprintf(rf, RECENT_GUI_INTERFACE_TOOLBAR_SHOW ": %s\n", string_list);
- g_free(string_list);
-
- fclose(rf);
-
- /* XXX - catch I/O errors (e.g. "ran out of disk space") and return
- an error indication, or maybe write to a new recent file and
- rename that file on top of the old one only if there are not I/O
- errors. */
- return TRUE;
+ write_recent_boolean(rf, "Packet list show (hide)",
+ RECENT_KEY_PACKET_LIST_SHOW,
+ recent.packet_list_show);
+
+ write_recent_boolean(rf, "Tree view show (hide)",
+ RECENT_KEY_TREE_VIEW_SHOW,
+ recent.tree_view_show);
+
+ write_recent_boolean(rf, "Byte view show (hide)",
+ RECENT_KEY_BYTE_VIEW_SHOW,
+ recent.byte_view_show);
+
+ write_recent_boolean(rf, "Statusbar show (hide)",
+ RECENT_KEY_STATUSBAR_SHOW,
+ recent.statusbar_show);
+
+ write_recent_boolean(rf, "Packet list colorize (hide)",
+ RECENT_KEY_PACKET_LIST_COLORIZE,
+ recent.packet_list_colorize);
+
+ write_recent_enum(rf, "Timestamp display format",
+ RECENT_GUI_TIME_FORMAT, ts_type_values,
+ recent.gui_time_format);
+
+ write_recent_enum(rf, "Timestamp display precision",
+ RECENT_GUI_TIME_PRECISION, ts_precision_values,
+ recent.gui_time_precision);
+
+ write_recent_enum(rf, "Seconds display format",
+ RECENT_GUI_SECONDS_FORMAT, ts_seconds_values,
+ recent.gui_seconds_format);
+
+ fprintf(rf, "\n# Zoom level.\n");
+ fprintf(rf, "# A decimal number.\n");
+ fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n",
+ recent.gui_zoom_level);
+
+ fprintf(rf, "\n# Bytes view.\n");
+ fprintf(rf, "# A decimal number.\n");
+ fprintf(rf, RECENT_GUI_BYTES_VIEW ": %d\n",
+ recent.gui_bytes_view);
+
+ fprintf(rf, "\n# Main window upper (or leftmost) pane size.\n");
+ fprintf(rf, "# Decimal number.\n");
+ if (recent.gui_geometry_main_upper_pane != 0) {
+ fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE ": %d\n",
+ recent.gui_geometry_main_upper_pane);
+ }
+ fprintf(rf, "\n# Main window middle pane size.\n");
+ fprintf(rf, "# Decimal number.\n");
+ if (recent.gui_geometry_main_lower_pane != 0) {
+ fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE ": %d\n",
+ recent.gui_geometry_main_lower_pane);
+ }
+
+ fprintf(rf, "\n# Packet list column pixel widths.\n");
+ fprintf(rf, "# Each pair of strings consists of a column format and its pixel width.\n");
+ packet_list_recent_write_all(rf);
+
+ fprintf(rf, "\n# Open conversation dialog tabs.\n");
+ fprintf(rf, "# List of conversation names, e.g. \"TCP\", \"IPv6\".\n");
+ string_list = join_string_list(recent.conversation_tabs);
+ fprintf(rf, RECENT_GUI_CONVERSATION_TABS ": %s\n", string_list);
+ g_free(string_list);
+
+ fprintf(rf, "\n# Open endpoint dialog tabs.\n");
+ fprintf(rf, "# List of endpoint names, e.g. \"TCP\", \"IPv6\".\n");
+ string_list = join_string_list(recent.endpoint_tabs);
+ fprintf(rf, RECENT_GUI_ENDPOINT_TABS ": %s\n", string_list);
+ g_free(string_list);
+
+ write_recent_boolean(rf, "For RLC stats, whether to use RLC PDUs found inside MAC frames",
+ RECENT_GUI_RLC_PDUS_FROM_MAC_FRAMES,
+ recent.gui_rlc_use_pdus_from_mac);
+
+ if (get_last_open_dir() != NULL) {
+ fprintf(rf, "\n# Last directory navigated to in File Open dialog.\n");
+ fprintf(rf, RECENT_GUI_FILEOPEN_REMEMBERED_DIR ": %s\n", get_last_open_dir());
+ }
+
+ fprintf(rf, "\n# Additional Toolbars shown\n");
+ fprintf(rf, "# List of additional toolbars to show.\n");
+ string_list = join_string_list(recent.gui_additional_toolbars);
+ fprintf(rf, RECENT_GUI_TOOLBAR_SHOW ": %s\n", string_list);
+ g_free(string_list);
+
+ fprintf(rf, "\n# Interface Toolbars show.\n");
+ fprintf(rf, "# List of interface toolbars to show.\n");
+ string_list = join_string_list(recent.interface_toolbars);
+ fprintf(rf, RECENT_GUI_INTERFACE_TOOLBAR_SHOW ": %s\n", string_list);
+ g_free(string_list);
+
+ fclose(rf);
+
+ /* XXX - catch I/O errors (e.g. "ran out of disk space") and return
+ an error indication, or maybe write to a new recent file and
+ rename that file on top of the old one only if there are not I/O
+ errors. */
+ return TRUE;
}
/* set one user's recent common file key/value pair */
@@ -889,90 +878,90 @@ read_set_recent_common_pair_static(gchar *key, const gchar *value,
void *private_data _U_,
gboolean return_range_errors _U_)
{
- long num;
- char *p;
-
- if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED) == 0) {
- parse_recent_boolean(value, &recent.gui_geometry_main_maximized);
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_X) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- recent.gui_geometry_main_x = (gint)num;
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_Y) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- recent.gui_geometry_main_y = (gint)num;
- } else if (strcmp(key, RECENT_GUI_GTK_GEOMETRY_MAIN_X) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- recent.gui_gtk_geometry_main_x = (gint)num;
- } else if (strcmp(key, RECENT_GUI_GTK_GEOMETRY_MAIN_Y) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- recent.gui_gtk_geometry_main_y = (gint)num;
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_WIDTH) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- if (num <= 0)
- return PREFS_SET_SYNTAX_ERR; /* number must be positive */
- recent.gui_geometry_main_width = (gint)num;
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_HEIGHT) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- if (num <= 0)
- return PREFS_SET_SYNTAX_ERR; /* number must be positive */
- recent.gui_geometry_main_height = (gint)num;
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_STATUS_PANE_RIGHT) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- if (num <= 0)
- return PREFS_SET_SYNTAX_ERR; /* number must be positive */
- recent.gui_geometry_status_pane_right = (gint)num;
- recent.has_gui_geometry_status_pane = TRUE;
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_STATUS_PANE_LEFT) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- if (num <= 0)
- return PREFS_SET_SYNTAX_ERR; /* number must be positive */
- recent.gui_geometry_status_pane_left = (gint)num;
- recent.has_gui_geometry_status_pane = TRUE;
- } else if (strcmp(key, RECENT_LAST_USED_PROFILE) == 0) {
- if ((strcmp(value, DEFAULT_PROFILE) != 0) && profile_exists (value, FALSE)) {
- set_profile_name (value);
- }
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_WLAN_STATS_PANE) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- if (num <= 0)
- return PREFS_SET_SYNTAX_ERR; /* number must be positive */
- recent.gui_geometry_wlan_stats_pane = (gint)num;
- } else if (strncmp(key, RECENT_GUI_GEOMETRY, sizeof(RECENT_GUI_GEOMETRY)-1) == 0) {
- /* now have something like "gui.geom.main.x", split it into win and sub_key */
- char *win = &key[sizeof(RECENT_GUI_GEOMETRY)-1];
- char *sub_key = strchr(win, '.');
- if (sub_key) {
- *sub_key = '\0';
- sub_key++;
- window_geom_recent_read_pair(win, sub_key, value);
+ long num;
+ char *p;
+
+ if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED) == 0) {
+ parse_recent_boolean(value, &recent.gui_geometry_main_maximized);
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_X) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ recent.gui_geometry_main_x = (gint)num;
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_Y) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ recent.gui_geometry_main_y = (gint)num;
+ } else if (strcmp(key, RECENT_GUI_GTK_GEOMETRY_MAIN_X) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ recent.gui_gtk_geometry_main_x = (gint)num;
+ } else if (strcmp(key, RECENT_GUI_GTK_GEOMETRY_MAIN_Y) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ recent.gui_gtk_geometry_main_y = (gint)num;
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_WIDTH) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ if (num <= 0)
+ return PREFS_SET_SYNTAX_ERR; /* number must be positive */
+ recent.gui_geometry_main_width = (gint)num;
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_HEIGHT) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ if (num <= 0)
+ return PREFS_SET_SYNTAX_ERR; /* number must be positive */
+ recent.gui_geometry_main_height = (gint)num;
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_STATUS_PANE_RIGHT) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ if (num <= 0)
+ return PREFS_SET_SYNTAX_ERR; /* number must be positive */
+ recent.gui_geometry_status_pane_right = (gint)num;
+ recent.has_gui_geometry_status_pane = TRUE;
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_STATUS_PANE_LEFT) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ if (num <= 0)
+ return PREFS_SET_SYNTAX_ERR; /* number must be positive */
+ recent.gui_geometry_status_pane_left = (gint)num;
+ recent.has_gui_geometry_status_pane = TRUE;
+ } else if (strcmp(key, RECENT_LAST_USED_PROFILE) == 0) {
+ if ((strcmp(value, DEFAULT_PROFILE) != 0) && profile_exists (value, FALSE)) {
+ set_profile_name (value);
+ }
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_WLAN_STATS_PANE) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ if (num <= 0)
+ return PREFS_SET_SYNTAX_ERR; /* number must be positive */
+ recent.gui_geometry_wlan_stats_pane = (gint)num;
+ } else if (strncmp(key, RECENT_GUI_GEOMETRY, sizeof(RECENT_GUI_GEOMETRY)-1) == 0) {
+ /* now have something like "gui.geom.main.x", split it into win and sub_key */
+ char *win = &key[sizeof(RECENT_GUI_GEOMETRY)-1];
+ char *sub_key = strchr(win, '.');
+ if (sub_key) {
+ *sub_key = '\0';
+ sub_key++;
+ window_geom_recent_read_pair(win, sub_key, value);
+ }
+ } else if (strcmp(key, RECENT_KEY_PRIVS_WARN_IF_ELEVATED) == 0) {
+ parse_recent_boolean(value, &recent.privs_warn_if_elevated);
+ } else if (strcmp(key, RECENT_KEY_PRIVS_WARN_IF_NO_NPF) == 0) {
+ parse_recent_boolean(value, &recent.privs_warn_if_no_npf);
+ } else if (strcmp(key, RECENT_GUI_CUSTOM_COLORS) == 0) {
+ recent.custom_colors = prefs_get_string_list(value);
}
- } else if (strcmp(key, RECENT_KEY_PRIVS_WARN_IF_ELEVATED) == 0) {
- parse_recent_boolean(value, &recent.privs_warn_if_elevated);
- } else if (strcmp(key, RECENT_KEY_PRIVS_WARN_IF_NO_NPF) == 0) {
- parse_recent_boolean(value, &recent.privs_warn_if_no_npf);
- } else if (strcmp(key, RECENT_GUI_CUSTOM_COLORS) == 0) {
- recent.custom_colors = prefs_get_string_list(value);
- }
-
- return PREFS_SET_OK;
+
+ return PREFS_SET_OK;
}
/* set one user's recent file key/value pair */
@@ -981,157 +970,157 @@ read_set_recent_pair_static(gchar *key, const gchar *value,
void *private_data _U_,
gboolean return_range_errors _U_)
{
- long num;
- char *p;
- GList *col_l, *col_l_elt;
- col_width_data *cfmt;
- const gchar *cust_format = col_format_to_string(COL_CUSTOM);
- int cust_format_len = (int) strlen(cust_format);
-
- if (strcmp(key, RECENT_KEY_MAIN_TOOLBAR_SHOW) == 0) {
- parse_recent_boolean(value, &recent.main_toolbar_show);
- } else if (strcmp(key, RECENT_KEY_FILTER_TOOLBAR_SHOW) == 0) {
- parse_recent_boolean(value, &recent.filter_toolbar_show);
- /* check both the old and the new keyword */
- } else if (strcmp(key, RECENT_KEY_WIRELESS_TOOLBAR_SHOW) == 0 || (strcmp(key, "gui.airpcap_toolbar_show") == 0)) {
- parse_recent_boolean(value, &recent.wireless_toolbar_show);
- } else if (strcmp(key, RECENT_KEY_DRIVER_CHECK_SHOW) == 0) {
- parse_recent_boolean(value, &recent.airpcap_driver_check_show);
- } else if (strcmp(key, RECENT_KEY_PACKET_LIST_SHOW) == 0) {
- parse_recent_boolean(value, &recent.packet_list_show);
- } else if (strcmp(key, RECENT_KEY_TREE_VIEW_SHOW) == 0) {
- parse_recent_boolean(value, &recent.tree_view_show);
- } else if (strcmp(key, RECENT_KEY_BYTE_VIEW_SHOW) == 0) {
- parse_recent_boolean(value, &recent.byte_view_show);
- } else if (strcmp(key, RECENT_KEY_STATUSBAR_SHOW) == 0) {
- parse_recent_boolean(value, &recent.statusbar_show);
- } else if (strcmp(key, RECENT_KEY_PACKET_LIST_COLORIZE) == 0) {
- parse_recent_boolean(value, &recent.packet_list_colorize);
- } else if (strcmp(key, RECENT_GUI_TIME_FORMAT) == 0) {
- recent.gui_time_format =
- (ts_type)str_to_val(value, ts_type_values, TS_RELATIVE);
- } else if (strcmp(key, RECENT_GUI_TIME_PRECISION) == 0) {
- recent.gui_time_precision =
- (ts_precision)str_to_val(value, ts_precision_values, TS_PREC_AUTO);
- } else if (strcmp(key, RECENT_GUI_SECONDS_FORMAT) == 0) {
- recent.gui_seconds_format =
- (ts_seconds_type)str_to_val(value, ts_seconds_values, TS_SECONDS_DEFAULT);
- } else if (strcmp(key, RECENT_GUI_ZOOM_LEVEL) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- recent.gui_zoom_level = (gint)num;
- } else if (strcmp(key, RECENT_GUI_BYTES_VIEW) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- recent.gui_bytes_view = (bytes_view_type)num;
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED) == 0) {
- parse_recent_boolean(value, &recent.gui_geometry_main_maximized);
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- if (num <= 0)
- return PREFS_SET_SYNTAX_ERR; /* number must be positive */
- recent.gui_geometry_main_upper_pane = (gint)num;
- recent.has_gui_geometry_main_upper_pane = TRUE;
- } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE) == 0) {
- num = strtol(value, &p, 0);
- if (p == value || *p != '\0')
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- if (num <= 0)
- return PREFS_SET_SYNTAX_ERR; /* number must be positive */
- recent.gui_geometry_main_lower_pane = (gint)num;
- recent.has_gui_geometry_main_lower_pane = TRUE;
- } else if (strcmp(key, RECENT_GUI_CONVERSATION_TABS) == 0) {
- recent.conversation_tabs = prefs_get_string_list(value);
- } else if (strcmp(key, RECENT_GUI_ENDPOINT_TABS) == 0) {
- recent.endpoint_tabs = prefs_get_string_list(value);
- } else if (strcmp(key, RECENT_GUI_RLC_PDUS_FROM_MAC_FRAMES) == 0) {
- parse_recent_boolean(value, &recent.gui_rlc_use_pdus_from_mac);
- } else if (strcmp(key, RECENT_KEY_COL_WIDTH) == 0) {
- col_l = prefs_get_string_list(value);
- if (col_l == NULL)
- return PREFS_SET_SYNTAX_ERR;
- if ((g_list_length(col_l) % 2) != 0) {
- /* A title didn't have a matching width. */
- prefs_clear_string_list(col_l);
- return PREFS_SET_SYNTAX_ERR;
- }
- /* Check to make sure all column formats are valid. */
- col_l_elt = g_list_first(col_l);
- while (col_l_elt) {
- /* Make sure the format isn't empty. */
- if (strcmp((const char *)col_l_elt->data, "") == 0) {
- /* It is. */
- prefs_clear_string_list(col_l);
- return PREFS_SET_SYNTAX_ERR;
- }
-
- /* Check the format. */
- if (strncmp((const char *)col_l_elt->data, cust_format, cust_format_len) != 0) {
- if (get_column_format_from_str((const gchar *)col_l_elt->data) == -1) {
- /* It's not a valid column format. */
- prefs_clear_string_list(col_l);
- return PREFS_SET_SYNTAX_ERR;
+ long num;
+ char *p;
+ GList *col_l, *col_l_elt;
+ col_width_data *cfmt;
+ const gchar *cust_format = col_format_to_string(COL_CUSTOM);
+ int cust_format_len = (int) strlen(cust_format);
+
+ if (strcmp(key, RECENT_KEY_MAIN_TOOLBAR_SHOW) == 0) {
+ parse_recent_boolean(value, &recent.main_toolbar_show);
+ } else if (strcmp(key, RECENT_KEY_FILTER_TOOLBAR_SHOW) == 0) {
+ parse_recent_boolean(value, &recent.filter_toolbar_show);
+ /* check both the old and the new keyword */
+ } else if (strcmp(key, RECENT_KEY_WIRELESS_TOOLBAR_SHOW) == 0 || (strcmp(key, "gui.airpcap_toolbar_show") == 0)) {
+ parse_recent_boolean(value, &recent.wireless_toolbar_show);
+ } else if (strcmp(key, RECENT_KEY_DRIVER_CHECK_SHOW) == 0) {
+ parse_recent_boolean(value, &recent.airpcap_driver_check_show);
+ } else if (strcmp(key, RECENT_KEY_PACKET_LIST_SHOW) == 0) {
+ parse_recent_boolean(value, &recent.packet_list_show);
+ } else if (strcmp(key, RECENT_KEY_TREE_VIEW_SHOW) == 0) {
+ parse_recent_boolean(value, &recent.tree_view_show);
+ } else if (strcmp(key, RECENT_KEY_BYTE_VIEW_SHOW) == 0) {
+ parse_recent_boolean(value, &recent.byte_view_show);
+ } else if (strcmp(key, RECENT_KEY_STATUSBAR_SHOW) == 0) {
+ parse_recent_boolean(value, &recent.statusbar_show);
+ } else if (strcmp(key, RECENT_KEY_PACKET_LIST_COLORIZE) == 0) {
+ parse_recent_boolean(value, &recent.packet_list_colorize);
+ } else if (strcmp(key, RECENT_GUI_TIME_FORMAT) == 0) {
+ recent.gui_time_format =
+ (ts_type)str_to_val(value, ts_type_values, TS_RELATIVE);
+ } else if (strcmp(key, RECENT_GUI_TIME_PRECISION) == 0) {
+ recent.gui_time_precision =
+ (ts_precision)str_to_val(value, ts_precision_values, TS_PREC_AUTO);
+ } else if (strcmp(key, RECENT_GUI_SECONDS_FORMAT) == 0) {
+ recent.gui_seconds_format =
+ (ts_seconds_type)str_to_val(value, ts_seconds_values, TS_SECONDS_DEFAULT);
+ } else if (strcmp(key, RECENT_GUI_ZOOM_LEVEL) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ recent.gui_zoom_level = (gint)num;
+ } else if (strcmp(key, RECENT_GUI_BYTES_VIEW) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ recent.gui_bytes_view = (bytes_view_type)num;
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED) == 0) {
+ parse_recent_boolean(value, &recent.gui_geometry_main_maximized);
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ if (num <= 0)
+ return PREFS_SET_SYNTAX_ERR; /* number must be positive */
+ recent.gui_geometry_main_upper_pane = (gint)num;
+ recent.has_gui_geometry_main_upper_pane = TRUE;
+ } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE) == 0) {
+ num = strtol(value, &p, 0);
+ if (p == value || *p != '\0')
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ if (num <= 0)
+ return PREFS_SET_SYNTAX_ERR; /* number must be positive */
+ recent.gui_geometry_main_lower_pane = (gint)num;
+ recent.has_gui_geometry_main_lower_pane = TRUE;
+ } else if (strcmp(key, RECENT_GUI_CONVERSATION_TABS) == 0) {
+ recent.conversation_tabs = prefs_get_string_list(value);
+ } else if (strcmp(key, RECENT_GUI_ENDPOINT_TABS) == 0) {
+ recent.endpoint_tabs = prefs_get_string_list(value);
+ } else if (strcmp(key, RECENT_GUI_RLC_PDUS_FROM_MAC_FRAMES) == 0) {
+ parse_recent_boolean(value, &recent.gui_rlc_use_pdus_from_mac);
+ } else if (strcmp(key, RECENT_KEY_COL_WIDTH) == 0) {
+ col_l = prefs_get_string_list(value);
+ if (col_l == NULL)
+ return PREFS_SET_SYNTAX_ERR;
+ if ((g_list_length(col_l) % 2) != 0) {
+ /* A title didn't have a matching width. */
+ prefs_clear_string_list(col_l);
+ return PREFS_SET_SYNTAX_ERR;
}
- }
-
- /* Go past the format. */
- col_l_elt = col_l_elt->next;
-
- /* Go past the width. */
- col_l_elt = col_l_elt->next;
- }
- free_col_width_info(&recent);
- recent.col_width_list = NULL;
- col_l_elt = g_list_first(col_l);
- while (col_l_elt) {
- gchar *fmt = g_strdup((const gchar *)col_l_elt->data);
- cfmt = (col_width_data *) g_malloc(sizeof(col_width_data));
- if (strncmp(fmt, cust_format, cust_format_len) != 0) {
- cfmt->cfmt = get_column_format_from_str(fmt);
- cfmt->cfield = NULL;
- } else {
- cfmt->cfmt = COL_CUSTOM;
- cfmt->cfield = g_strdup(&fmt[cust_format_len+1]); /* add 1 for ':' */
- }
- g_free (fmt);
- if (cfmt->cfmt == -1) {
- g_free(cfmt->cfield);
- g_free(cfmt);
- return PREFS_SET_SYNTAX_ERR; /* string was bad */
- }
-
- col_l_elt = col_l_elt->next;
- cfmt->width = (gint)strtol((const char *)col_l_elt->data, &p, 0);
- if (p == col_l_elt->data || (*p != '\0' && *p != ':')) {
- g_free(cfmt->cfield);
- g_free(cfmt);
- return PREFS_SET_SYNTAX_ERR; /* number was bad */
- }
-
- if (*p == ':') {
- cfmt->xalign = *(++p);
- } else {
- cfmt->xalign = COLUMN_XALIGN_DEFAULT;
- }
-
- col_l_elt = col_l_elt->next;
- recent.col_width_list = g_list_append(recent.col_width_list, cfmt);
+ /* Check to make sure all column formats are valid. */
+ col_l_elt = g_list_first(col_l);
+ while (col_l_elt) {
+ /* Make sure the format isn't empty. */
+ if (strcmp((const char *)col_l_elt->data, "") == 0) {
+ /* It is. */
+ prefs_clear_string_list(col_l);
+ return PREFS_SET_SYNTAX_ERR;
+ }
+
+ /* Check the format. */
+ if (strncmp((const char *)col_l_elt->data, cust_format, cust_format_len) != 0) {
+ if (get_column_format_from_str((const gchar *)col_l_elt->data) == -1) {
+ /* It's not a valid column format. */
+ prefs_clear_string_list(col_l);
+ return PREFS_SET_SYNTAX_ERR;
+ }
+ }
+
+ /* Go past the format. */
+ col_l_elt = col_l_elt->next;
+
+ /* Go past the width. */
+ col_l_elt = col_l_elt->next;
+ }
+ free_col_width_info(&recent);
+ recent.col_width_list = NULL;
+ col_l_elt = g_list_first(col_l);
+ while (col_l_elt) {
+ gchar *fmt = g_strdup((const gchar *)col_l_elt->data);
+ cfmt = (col_width_data *) g_malloc(sizeof(col_width_data));
+ if (strncmp(fmt, cust_format, cust_format_len) != 0) {
+ cfmt->cfmt = get_column_format_from_str(fmt);
+ cfmt->cfield = NULL;
+ } else {
+ cfmt->cfmt = COL_CUSTOM;
+ cfmt->cfield = g_strdup(&fmt[cust_format_len+1]); /* add 1 for ':' */
+ }
+ g_free (fmt);
+ if (cfmt->cfmt == -1) {
+ g_free(cfmt->cfield);
+ g_free(cfmt);
+ return PREFS_SET_SYNTAX_ERR; /* string was bad */
+ }
+
+ col_l_elt = col_l_elt->next;
+ cfmt->width = (gint)strtol((const char *)col_l_elt->data, &p, 0);
+ if (p == col_l_elt->data || (*p != '\0' && *p != ':')) {
+ g_free(cfmt->cfield);
+ g_free(cfmt);
+ return PREFS_SET_SYNTAX_ERR; /* number was bad */
+ }
+
+ if (*p == ':') {
+ cfmt->xalign = *(++p);
+ } else {
+ cfmt->xalign = COLUMN_XALIGN_DEFAULT;
+ }
+
+ col_l_elt = col_l_elt->next;
+ recent.col_width_list = g_list_append(recent.col_width_list, cfmt);
+ }
+ prefs_clear_string_list(col_l);
+ } else if (strcmp(key, RECENT_GUI_FILEOPEN_REMEMBERED_DIR) == 0) {
+ g_free(recent.gui_fileopen_remembered_dir);
+ recent.gui_fileopen_remembered_dir = g_strdup(value);
+ } else if (strcmp(key, RECENT_GUI_TOOLBAR_SHOW) == 0) {
+ recent.gui_additional_toolbars = prefs_get_string_list(value);
+ } else if (strcmp(key, RECENT_GUI_INTERFACE_TOOLBAR_SHOW) == 0) {
+ recent.interface_toolbars = prefs_get_string_list(value);
}
- prefs_clear_string_list(col_l);
- } else if (strcmp(key, RECENT_GUI_FILEOPEN_REMEMBERED_DIR) == 0) {
- g_free(recent.gui_fileopen_remembered_dir);
- recent.gui_fileopen_remembered_dir = g_strdup(value);
- } else if (strcmp(key, RECENT_GUI_TOOLBAR_SHOW) == 0) {
- recent.gui_additional_toolbars = prefs_get_string_list(value);
- } else if (strcmp(key, RECENT_GUI_INTERFACE_TOOLBAR_SHOW) == 0) {
- recent.interface_toolbars = prefs_get_string_list(value);
- }
-
- return PREFS_SET_OK;
+
+ return PREFS_SET_OK;
}
@@ -1141,25 +1130,25 @@ read_set_recent_pair_dynamic(gchar *key, const gchar *value,
void *private_data _U_,
gboolean return_range_errors _U_)
{
- if (!g_utf8_validate(value, -1, NULL)) {
- return PREFS_SET_SYNTAX_ERR;
- }
- if (strcmp(key, RECENT_KEY_CAPTURE_FILE) == 0) {
- add_menu_recent_capture_file(value);
- } else if (strcmp(key, RECENT_KEY_DISPLAY_FILTER) == 0) {
- dfilter_combo_add_recent(value);
- } else if (strcmp(key, RECENT_KEY_CAPTURE_FILTER) == 0) {
- recent_add_cfilter(NULL, value);
- } else if (g_str_has_prefix(key, RECENT_KEY_CAPTURE_FILTER ".")) {
- /* strrchr() can't fail - string has a prefix that ends with a "." */
- recent_add_cfilter(strrchr(key, '.') + 1, value);
+ if (!g_utf8_validate(value, -1, NULL)) {
+ return PREFS_SET_SYNTAX_ERR;
+ }
+ if (strcmp(key, RECENT_KEY_CAPTURE_FILE) == 0) {
+ add_menu_recent_capture_file(value);
+ } else if (strcmp(key, RECENT_KEY_DISPLAY_FILTER) == 0) {
+ dfilter_combo_add_recent(value);
+ } else if (strcmp(key, RECENT_KEY_CAPTURE_FILTER) == 0) {
+ recent_add_cfilter(NULL, value);
+ } else if (g_str_has_prefix(key, RECENT_KEY_CAPTURE_FILTER ".")) {
+ /* strrchr() can't fail - string has a prefix that ends with a "." */
+ recent_add_cfilter(strrchr(key, '.') + 1, value);
#ifdef HAVE_PCAP_REMOTE
- } else if (strcmp(key, RECENT_KEY_REMOTE_HOST) == 0) {
- capture_remote_combo_add_recent(value);
+ } else if (strcmp(key, RECENT_KEY_REMOTE_HOST) == 0) {
+ capture_remote_combo_add_recent(value);
#endif
- }
+ }
- return PREFS_SET_OK;
+ return PREFS_SET_OK;
}
@@ -1172,36 +1161,36 @@ read_set_recent_pair_dynamic(gchar *key, const gchar *value,
int
recent_set_arg(char *prefarg)
{
- gchar *p, *colonp;
- int ret;
-
- colonp = strchr(prefarg, ':');
- if (colonp == NULL)
- return PREFS_SET_SYNTAX_ERR;
-
- p = colonp;
- *p++ = '\0';
-
- /*
- * Skip over any white space (there probably won't be any, but
- * as we allow it in the preferences file, we might as well
- * allow it here).
- */
- while (g_ascii_isspace(*p))
- p++;
- if (*p == '\0') {
+ gchar *p, *colonp;
+ int ret;
+
+ colonp = strchr(prefarg, ':');
+ if (colonp == NULL)
+ return PREFS_SET_SYNTAX_ERR;
+
+ p = colonp;
+ *p++ = '\0';
+
/*
- * Put the colon back, so if our caller uses, in an
- * error message, the string they passed us, the message
- * looks correct.
+ * Skip over any white space (there probably won't be any, but
+ * as we allow it in the preferences file, we might as well
+ * allow it here).
*/
- *colonp = ':';
- return PREFS_SET_SYNTAX_ERR;
- }
+ while (g_ascii_isspace(*p))
+ p++;
+ if (*p == '\0') {
+ /*
+ * Put the colon back, so if our caller uses, in an
+ * error message, the string they passed us, the message
+ * looks correct.
+ */
+ *colonp = ':';
+ return PREFS_SET_SYNTAX_ERR;
+ }
- ret = read_set_recent_pair_static(prefarg, p, NULL, TRUE);
- *colonp = ':'; /* put the colon back */
- return ret;
+ ret = read_set_recent_pair_static(prefarg, p, NULL, TRUE);
+ *colonp = ':'; /* put the colon back */
+ return ret;
}
@@ -1209,50 +1198,50 @@ recent_set_arg(char *prefarg)
gboolean
recent_read_static(char **rf_path_return, int *rf_errno_return)
{
- char *rf_path;
- FILE *rf;
-
- /* set defaults */
- recent.gui_geometry_main_x = 20;
- recent.gui_geometry_main_y = 20;
- recent.gui_gtk_geometry_main_x = 20;
- recent.gui_gtk_geometry_main_y = 20;
- recent.gui_geometry_main_width = DEF_WIDTH;
- recent.gui_geometry_main_height = DEF_HEIGHT;
- recent.gui_geometry_main_maximized= FALSE;
-
- recent.gui_geometry_status_pane_left = (DEF_WIDTH/3);
- recent.gui_geometry_status_pane_right = (DEF_WIDTH/3);
- recent.gui_geometry_wlan_stats_pane = 200;
+ char *rf_path;
+ FILE *rf;
- recent.privs_warn_if_elevated = TRUE;
- recent.privs_warn_if_no_npf = TRUE;
+ /* set defaults */
+ recent.gui_geometry_main_x = 20;
+ recent.gui_geometry_main_y = 20;
+ recent.gui_gtk_geometry_main_x = 20;
+ recent.gui_gtk_geometry_main_y = 20;
+ recent.gui_geometry_main_width = DEF_WIDTH;
+ recent.gui_geometry_main_height = DEF_HEIGHT;
+ recent.gui_geometry_main_maximized= FALSE;
- recent.col_width_list = NULL;
- recent.gui_fileopen_remembered_dir = NULL;
+ recent.gui_geometry_status_pane_left = (DEF_WIDTH/3);
+ recent.gui_geometry_status_pane_right = (DEF_WIDTH/3);
+ recent.gui_geometry_wlan_stats_pane = 200;
- /* Construct the pathname of the user's recent common file. */
- rf_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE);
+ recent.privs_warn_if_elevated = TRUE;
+ recent.privs_warn_if_no_npf = TRUE;
- /* Read the user's recent common file, if it exists. */
- *rf_path_return = NULL;
- if ((rf = ws_fopen(rf_path, "r")) != NULL) {
- /* We succeeded in opening it; read it. */
- read_prefs_file(rf_path, rf, read_set_recent_common_pair_static, NULL);
+ recent.col_width_list = NULL;
+ recent.gui_fileopen_remembered_dir = NULL;
- fclose(rf);
- } else {
- /* We failed to open it. If we failed for some reason other than
- "it doesn't exist", return the errno and the pathname, so our
- caller can report the error. */
- if (errno != ENOENT) {
- *rf_errno_return = errno;
- *rf_path_return = rf_path;
- return FALSE;
+ /* Construct the pathname of the user's recent common file. */
+ rf_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE);
+
+ /* Read the user's recent common file, if it exists. */
+ *rf_path_return = NULL;
+ if ((rf = ws_fopen(rf_path, "r")) != NULL) {
+ /* We succeeded in opening it; read it. */
+ read_prefs_file(rf_path, rf, read_set_recent_common_pair_static, NULL);
+
+ fclose(rf);
+ } else {
+ /* We failed to open it. If we failed for some reason other than
+ "it doesn't exist", return the errno and the pathname, so our
+ caller can report the error. */
+ if (errno != ENOENT) {
+ *rf_errno_return = errno;
+ *rf_path_return = rf_path;
+ return FALSE;
+ }
}
- }
- g_free(rf_path);
- return TRUE;
+ g_free(rf_path);
+ return TRUE;
}
@@ -1261,287 +1250,287 @@ recent_read_static(char **rf_path_return, int *rf_errno_return)
gboolean
recent_read_profile_static(char **rf_path_return, int *rf_errno_return)
{
- char *rf_path, *rf_common_path;
- FILE *rf;
-
- /* set defaults */
- recent.main_toolbar_show = TRUE;
- recent.filter_toolbar_show = TRUE;
- recent.wireless_toolbar_show = FALSE;
- recent.airpcap_driver_check_show = TRUE;
- recent.packet_list_show = TRUE;
- recent.tree_view_show = TRUE;
- recent.byte_view_show = TRUE;
- recent.statusbar_show = TRUE;
- recent.packet_list_colorize = TRUE;
- recent.gui_time_format = TS_RELATIVE;
- recent.gui_time_precision = TS_PREC_AUTO;
- recent.gui_seconds_format = TS_SECONDS_DEFAULT;
- recent.gui_zoom_level = 0;
- recent.gui_bytes_view = BYTES_HEX;
-
- /* pane size of zero will autodetect */
- recent.gui_geometry_main_upper_pane = 0;
- recent.gui_geometry_main_lower_pane = 0;
-
- recent.has_gui_geometry_main_upper_pane = TRUE;
- recent.has_gui_geometry_main_lower_pane = TRUE;
- recent.has_gui_geometry_status_pane = TRUE;
-
- if (recent.col_width_list) {
- free_col_width_info(&recent);
- }
+ char *rf_path, *rf_common_path;
+ FILE *rf;
+
+ /* set defaults */
+ recent.main_toolbar_show = TRUE;
+ recent.filter_toolbar_show = TRUE;
+ recent.wireless_toolbar_show = FALSE;
+ recent.airpcap_driver_check_show = TRUE;
+ recent.packet_list_show = TRUE;
+ recent.tree_view_show = TRUE;
+ recent.byte_view_show = TRUE;
+ recent.statusbar_show = TRUE;
+ recent.packet_list_colorize = TRUE;
+ recent.gui_time_format = TS_RELATIVE;
+ recent.gui_time_precision = TS_PREC_AUTO;
+ recent.gui_seconds_format = TS_SECONDS_DEFAULT;
+ recent.gui_zoom_level = 0;
+ recent.gui_bytes_view = BYTES_HEX;
+
+ /* pane size of zero will autodetect */
+ recent.gui_geometry_main_upper_pane = 0;
+ recent.gui_geometry_main_lower_pane = 0;
- if (recent.gui_fileopen_remembered_dir) {
- g_free (recent.gui_fileopen_remembered_dir);
- recent.gui_fileopen_remembered_dir = NULL;
- }
-
- if (recent.gui_additional_toolbars) {
- g_list_free_full (recent.gui_additional_toolbars, g_free);
- recent.gui_additional_toolbars = NULL;
- }
-
- if (recent.interface_toolbars) {
- g_list_free_full (recent.interface_toolbars, g_free);
- recent.interface_toolbars = NULL;
- }
-
- /* Construct the pathname of the user's profile recent file. */
- rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE);
-
- /* Read the user's recent file, if it exists. */
- *rf_path_return = NULL;
- if ((rf = ws_fopen(rf_path, "r")) != NULL) {
- /* We succeeded in opening it; read it. */
- read_prefs_file(rf_path, rf, read_set_recent_pair_static, NULL);
- fclose(rf);
+ recent.has_gui_geometry_main_upper_pane = TRUE;
+ recent.has_gui_geometry_main_lower_pane = TRUE;
+ recent.has_gui_geometry_status_pane = TRUE;
- /* XXX: The following code doesn't actually do anything since
- * the "recent common file" always exists. Presumably the
- * "if (!file_exists())" should actually be "if (file_exists())".
- * However, I've left the code as is because this
- * behaviour has existed for quite some time and I don't
- * know what's supposed to happen at this point.
- * ToDo: Determine if the "recent common file" should be read at this point
- */
- rf_common_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE);
- if (!file_exists(rf_common_path)) {
- /* Read older common settings from recent file */
- rf = ws_fopen(rf_path, "r");
- read_prefs_file(rf_path, rf, read_set_recent_common_pair_static, NULL);
- fclose(rf);
+ if (recent.col_width_list) {
+ free_col_width_info(&recent);
+ }
+
+ if (recent.gui_fileopen_remembered_dir) {
+ g_free (recent.gui_fileopen_remembered_dir);
+ recent.gui_fileopen_remembered_dir = NULL;
+ }
+
+ if (recent.gui_additional_toolbars) {
+ g_list_free_full (recent.gui_additional_toolbars, g_free);
+ recent.gui_additional_toolbars = NULL;
}
- g_free(rf_common_path);
- } else {
- /* We failed to open it. If we failed for some reason other than
- "it doesn't exist", return the errno and the pathname, so our
- caller can report the error. */
- if (errno != ENOENT) {
- *rf_errno_return = errno;
- *rf_path_return = rf_path;
- return FALSE;
+
+ if (recent.interface_toolbars) {
+ g_list_free_full (recent.interface_toolbars, g_free);
+ recent.interface_toolbars = NULL;
+ }
+
+ /* Construct the pathname of the user's profile recent file. */
+ rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE);
+
+ /* Read the user's recent file, if it exists. */
+ *rf_path_return = NULL;
+ if ((rf = ws_fopen(rf_path, "r")) != NULL) {
+ /* We succeeded in opening it; read it. */
+ read_prefs_file(rf_path, rf, read_set_recent_pair_static, NULL);
+ fclose(rf);
+
+ /* XXX: The following code doesn't actually do anything since
+ * the "recent common file" always exists. Presumably the
+ * "if (!file_exists())" should actually be "if (file_exists())".
+ * However, I've left the code as is because this
+ * behaviour has existed for quite some time and I don't
+ * know what's supposed to happen at this point.
+ * ToDo: Determine if the "recent common file" should be read at this point
+ */
+ rf_common_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE);
+ if (!file_exists(rf_common_path)) {
+ /* Read older common settings from recent file */
+ rf = ws_fopen(rf_path, "r");
+ read_prefs_file(rf_path, rf, read_set_recent_common_pair_static, NULL);
+ fclose(rf);
+ }
+ g_free(rf_common_path);
+ } else {
+ /* We failed to open it. If we failed for some reason other than
+ "it doesn't exist", return the errno and the pathname, so our
+ caller can report the error. */
+ if (errno != ENOENT) {
+ *rf_errno_return = errno;
+ *rf_path_return = rf_path;
+ return FALSE;
+ }
}
- }
- g_free(rf_path);
- return TRUE;
+ g_free(rf_path);
+ return TRUE;
}
/* opens the user's recent file and read it out */
gboolean
recent_read_dynamic(char **rf_path_return, int *rf_errno_return)
{
- char *rf_path;
- FILE *rf;
-
-
- /* Construct the pathname of the user's recent common file. */
- rf_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE);
- if (!file_exists (rf_path)) {
- /* Recent common file does not exist, read from default recent */
- g_free (rf_path);
- rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE);
- }
-
- /* Read the user's recent file, if it exists. */
- *rf_path_return = NULL;
- if ((rf = ws_fopen(rf_path, "r")) != NULL) {
- /* We succeeded in opening it; read it. */
- read_prefs_file(rf_path, rf, read_set_recent_pair_dynamic, NULL);
+ char *rf_path;
+ FILE *rf;
+
+
+ /* Construct the pathname of the user's recent common file. */
+ rf_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE);
+ if (!file_exists (rf_path)) {
+ /* Recent common file does not exist, read from default recent */
+ g_free (rf_path);
+ rf_path = get_persconffile_path(RECENT_FILE_NAME, FALSE);
+ }
+
+ /* Read the user's recent file, if it exists. */
+ *rf_path_return = NULL;
+ if ((rf = ws_fopen(rf_path, "r")) != NULL) {
+ /* We succeeded in opening it; read it. */
+ read_prefs_file(rf_path, rf, read_set_recent_pair_dynamic, NULL);
#if 0
- /* set dfilter combobox to have an empty line */
- dfilter_combo_add_empty();
+ /* set dfilter combobox to have an empty line */
+ dfilter_combo_add_empty();
#endif
- fclose(rf);
- } else {
- /* We failed to open it. If we failed for some reason other than
- "it doesn't exist", return the errno and the pathname, so our
- caller can report the error. */
- if (errno != ENOENT) {
- *rf_errno_return = errno;
- *rf_path_return = rf_path;
- return FALSE;
+ fclose(rf);
+ } else {
+ /* We failed to open it. If we failed for some reason other than
+ "it doesn't exist", return the errno and the pathname, so our
+ caller can report the error. */
+ if (errno != ENOENT) {
+ *rf_errno_return = errno;
+ *rf_path_return = rf_path;
+ return FALSE;
+ }
}
- }
- g_free(rf_path);
- return TRUE;
+ g_free(rf_path);
+ return TRUE;
}
gint
recent_get_column_width(gint col)
{
- GList *col_l;
- col_width_data *col_w;
- gint cfmt;
- const gchar *cfield = NULL;
-
- cfmt = get_column_format(col);
- if (cfmt == COL_CUSTOM) {
- cfield = get_column_custom_fields(col);
- }
-
- col_l = g_list_first(recent.col_width_list);
- while (col_l) {
- col_w = (col_width_data *) col_l->data;
- if (col_w->cfmt == cfmt) {
- if (cfmt != COL_CUSTOM || strcmp (cfield, col_w->cfield) == 0) {
- return col_w->width;
- }
+ GList *col_l;
+ col_width_data *col_w;
+ gint cfmt;
+ const gchar *cfield = NULL;
+
+ cfmt = get_column_format(col);
+ if (cfmt == COL_CUSTOM) {
+ cfield = get_column_custom_fields(col);
}
- col_l = col_l->next;
- }
- return -1;
+ col_l = g_list_first(recent.col_width_list);
+ while (col_l) {
+ col_w = (col_width_data *) col_l->data;
+ if (col_w->cfmt == cfmt) {
+ if (cfmt != COL_CUSTOM || strcmp (cfield, col_w->cfield) == 0) {
+ return col_w->width;
+ }
+ }
+ col_l = col_l->next;
+ }
+
+ return -1;
}
void
recent_set_column_width(gint col, gint width)
{
- GList *col_l;
- col_width_data *col_w;
- gint cfmt;
- const gchar *cfield = NULL;
- gboolean found = FALSE;
-
- cfmt = get_column_format(col);
- if (cfmt == COL_CUSTOM) {
- cfield = get_column_custom_fields(col);
- }
-
- col_l = g_list_first(recent.col_width_list);
- while (col_l) {
- col_w = (col_width_data *) col_l->data;
- if (col_w->cfmt == cfmt) {
- if (cfmt != COL_CUSTOM || strcmp (cfield, col_w->cfield) == 0) {
+ GList *col_l;
+ col_width_data *col_w;
+ gint cfmt;
+ const gchar *cfield = NULL;
+ gboolean found = FALSE;
+
+ cfmt = get_column_format(col);
+ if (cfmt == COL_CUSTOM) {
+ cfield = get_column_custom_fields(col);
+ }
+
+ col_l = g_list_first(recent.col_width_list);
+ while (col_l) {
+ col_w = (col_width_data *) col_l->data;
+ if (col_w->cfmt == cfmt) {
+ if (cfmt != COL_CUSTOM || strcmp (cfield, col_w->cfield) == 0) {
+ col_w->width = width;
+ found = TRUE;
+ break;
+ }
+ }
+ col_l = col_l->next;
+ }
+
+ if (!found) {
+ col_w = (col_width_data *) g_malloc(sizeof(col_width_data));
+ col_w->cfmt = cfmt;
+ col_w->cfield = g_strdup(cfield);
col_w->width = width;
- found = TRUE;
- break;
- }
+ col_w->xalign = COLUMN_XALIGN_DEFAULT;
+ recent.col_width_list = g_list_append(recent.col_width_list, col_w);
}
- col_l = col_l->next;
- }
-
- if (!found) {
- col_w = (col_width_data *) g_malloc(sizeof(col_width_data));
- col_w->cfmt = cfmt;
- col_w->cfield = g_strdup(cfield);
- col_w->width = width;
- col_w->xalign = COLUMN_XALIGN_DEFAULT;
- recent.col_width_list = g_list_append(recent.col_width_list, col_w);
- }
}
gchar
recent_get_column_xalign(gint col)
{
- GList *col_l;
- col_width_data *col_w;
- gint cfmt;
- const gchar *cfield = NULL;
-
- cfmt = get_column_format(col);
- if (cfmt == COL_CUSTOM) {
- cfield = get_column_custom_fields(col);
- }
-
- col_l = g_list_first(recent.col_width_list);
- while (col_l) {
- col_w = (col_width_data *) col_l->data;
- if (col_w->cfmt == cfmt) {
- if (cfmt != COL_CUSTOM || strcmp (cfield, col_w->cfield) == 0) {
- return col_w->xalign;
- }
+ GList *col_l;
+ col_width_data *col_w;
+ gint cfmt;
+ const gchar *cfield = NULL;
+
+ cfmt = get_column_format(col);
+ if (cfmt == COL_CUSTOM) {
+ cfield = get_column_custom_fields(col);
}
- col_l = col_l->next;
- }
- return 0;
+ col_l = g_list_first(recent.col_width_list);
+ while (col_l) {
+ col_w = (col_width_data *) col_l->data;
+ if (col_w->cfmt == cfmt) {
+ if (cfmt != COL_CUSTOM || strcmp (cfield, col_w->cfield) == 0) {
+ return col_w->xalign;
+ }
+ }
+ col_l = col_l->next;
+ }
+
+ return 0;
}
void
recent_set_column_xalign(gint col, gchar xalign)
{
- GList *col_l;
- col_width_data *col_w;
- gint cfmt;
- const gchar *cfield = NULL;
- gboolean found = FALSE;
-
- cfmt = get_column_format(col);
- if (cfmt == COL_CUSTOM) {
- cfield = get_column_custom_fields(col);
- }
-
- col_l = g_list_first(recent.col_width_list);
- while (col_l) {
- col_w = (col_width_data *) col_l->data;
- if (col_w->cfmt == cfmt) {
- if (cfmt != COL_CUSTOM || strcmp (cfield, col_w->cfield) == 0) {
+ GList *col_l;
+ col_width_data *col_w;
+ gint cfmt;
+ const gchar *cfield = NULL;
+ gboolean found = FALSE;
+
+ cfmt = get_column_format(col);
+ if (cfmt == COL_CUSTOM) {
+ cfield = get_column_custom_fields(col);
+ }
+
+ col_l = g_list_first(recent.col_width_list);
+ while (col_l) {
+ col_w = (col_width_data *) col_l->data;
+ if (col_w->cfmt == cfmt) {
+ if (cfmt != COL_CUSTOM || strcmp (cfield, col_w->cfield) == 0) {
+ col_w->xalign = xalign;
+ found = TRUE;
+ break;
+ }
+ }
+ col_l = col_l->next;
+ }
+
+ if (!found) {
+ col_w = (col_width_data *) g_malloc(sizeof(col_width_data));
+ col_w->cfmt = cfmt;
+ col_w->cfield = g_strdup(cfield);
+ col_w->width = 40;
col_w->xalign = xalign;
- found = TRUE;
- break;
- }
+ recent.col_width_list = g_list_append(recent.col_width_list, col_w);
}
- col_l = col_l->next;
- }
-
- if (!found) {
- col_w = (col_width_data *) g_malloc(sizeof(col_width_data));
- col_w->cfmt = cfmt;
- col_w->cfield = g_strdup(cfield);
- col_w->width = 40;
- col_w->xalign = xalign;
- recent.col_width_list = g_list_append(recent.col_width_list, col_w);
- }
}
void
recent_init(void)
{
- memset(&recent, 0, sizeof(recent_settings_t));
+ memset(&recent, 0, sizeof(recent_settings_t));
}
void
recent_cleanup(void)
{
- free_col_width_info(&recent);
- g_free(recent.gui_fileopen_remembered_dir);
- g_list_free_full(recent.gui_additional_toolbars, g_free);
- g_list_free_full(recent.interface_toolbars, g_free);
- prefs_clear_string_list(recent.conversation_tabs);
- prefs_clear_string_list(recent.endpoint_tabs);
- prefs_clear_string_list(recent.custom_colors);
+ free_col_width_info(&recent);
+ g_free(recent.gui_fileopen_remembered_dir);
+ g_list_free_full(recent.gui_additional_toolbars, g_free);
+ g_list_free_full(recent.interface_toolbars, g_free);
+ prefs_clear_string_list(recent.conversation_tabs);
+ prefs_clear_string_list(recent.endpoint_tabs);
+ prefs_clear_string_list(recent.custom_colors);
}
/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
- * c-basic-offset: 2
+ * c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * ex: set shiftwidth=2 tabstop=8 expandtab:
- * :indentSize=2:tabSize=8:noTabs=true:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/recent.h b/ui/recent.h
index f21711fedb..1d3296659d 100644
--- a/ui/recent.h
+++ b/ui/recent.h
@@ -6,19 +6,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __RECENT_H__
@@ -64,8 +52,8 @@ typedef struct _col_width_data {
#define COLUMN_XALIGN_RIGHT 'R'
typedef enum {
- BYTES_HEX,
- BYTES_BITS
+ BYTES_HEX,
+ BYTES_BITS
} bytes_view_type;
/** Recent settings. */
@@ -278,7 +266,7 @@ extern void capture_remote_combo_recent_write_all(FILE *rf);
#endif /* recent.h */
/*
- * Editor modelines
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 4
diff --git a/ui/tap-rtp-common.c b/ui/tap-rtp-common.c
index 67246cbc00..9d689fa2f4 100644
--- a/ui/tap-rtp-common.c
+++ b/ui/tap-rtp-common.c
@@ -12,19 +12,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -51,30 +39,30 @@
/****************************************************************************/
/* Type for storing and writing rtpdump information */
typedef struct st_rtpdump_info {
- double rec_time; /**< milliseconds since start of recording */
+ double rec_time; /**< milliseconds since start of recording */
guint16 num_samples; /**< number of bytes in *frame */
- const guint8 *samples; /**< data bytes */
+ const guint8 *samples; /**< data bytes */
} rtpdump_info_t;
/****************************************************************************/
/* GCompareFunc style comparison function for _rtp_stream_info */
static gint rtp_stream_info_cmp(gconstpointer aa, gconstpointer bb)
{
- const struct _rtp_stream_info* a = (const struct _rtp_stream_info*)aa;
- const struct _rtp_stream_info* b = (const struct _rtp_stream_info*)bb;
-
- if (a==b)
- return 0;
- if (a==NULL || b==NULL)
- return 1;
- if (addresses_equal(&(a->src_addr), &(b->src_addr))
- && (a->src_port == b->src_port)
- && addresses_equal(&(a->dest_addr), &(b->dest_addr))
- && (a->dest_port == b->dest_port)
- && (a->ssrc == b->ssrc))
- return 0;
- else
- return 1;
+ const struct _rtp_stream_info* a = (const struct _rtp_stream_info*)aa;
+ const struct _rtp_stream_info* b = (const struct _rtp_stream_info*)bb;
+
+ if (a==b)
+ return 0;
+ if (a==NULL || b==NULL)
+ return 1;
+ if (addresses_equal(&(a->src_addr), &(b->src_addr))
+ && (a->src_port == b->src_port)
+ && addresses_equal(&(a->dest_addr), &(b->dest_addr))
+ && (a->dest_port == b->dest_port)
+ && (a->ssrc == b->ssrc))
+ return 0;
+ else
+ return 1;
}
@@ -82,33 +70,33 @@ static gint rtp_stream_info_cmp(gconstpointer aa, gconstpointer bb)
/* when there is a [re]reading of packet's */
void rtpstream_reset(rtpstream_tapinfo_t *tapinfo)
{
- GList* list;
-
- if (tapinfo->mode == TAP_ANALYSE) {
- /* free the data items first */
- list = g_list_first(tapinfo->strinfo_list);
- while (list)
- {
- g_free(list->data);
- list = g_list_next(list);
- }
- g_list_free(tapinfo->strinfo_list);
- tapinfo->strinfo_list = NULL;
- tapinfo->nstreams = 0;
- tapinfo->npackets = 0;
- }
-
- return;
+ GList* list;
+
+ if (tapinfo->mode == TAP_ANALYSE) {
+ /* free the data items first */
+ list = g_list_first(tapinfo->strinfo_list);
+ while (list)
+ {
+ g_free(list->data);
+ list = g_list_next(list);
+ }
+ g_list_free(tapinfo->strinfo_list);
+ tapinfo->strinfo_list = NULL;
+ tapinfo->nstreams = 0;
+ tapinfo->npackets = 0;
+ }
+
+ return;
}
void rtpstream_reset_cb(void *arg)
{
- rtpstream_tapinfo_t *ti =(rtpstream_tapinfo_t *)arg;
- if (ti->tap_reset) {
- /* Give listeners a chance to cleanup references. */
- ti->tap_reset(ti);
- }
- rtpstream_reset(ti);
+ rtpstream_tapinfo_t *ti =(rtpstream_tapinfo_t *)arg;
+ if (ti->tap_reset) {
+ /* Give listeners a chance to cleanup references. */
+ ti->tap_reset(ti);
+ }
+ rtpstream_reset(ti);
}
/*
@@ -136,62 +124,62 @@ void rtpstream_reset_cb(void *arg)
*/
void rtp_write_header(rtp_stream_info_t *strinfo, FILE *file)
{
- guint32 start_sec; /* start of recording (GMT) (seconds) */
- guint32 start_usec; /* start of recording (GMT) (microseconds)*/
- guint32 source; /* network source (multicast address) */
- size_t sourcelen;
- guint16 port; /* UDP port */
- guint16 padding; /* 2 padding bytes */
- char* addr_str = address_to_display(NULL, &(strinfo->dest_addr));
-
- fprintf(file, "#!rtpplay%s %s/%u\n", RTPFILE_VERSION,
- addr_str,
- strinfo->dest_port);
- wmem_free(NULL, addr_str);
-
- start_sec = g_htonl(strinfo->start_fd->abs_ts.secs);
- start_usec = g_htonl(strinfo->start_fd->abs_ts.nsecs / 1000000);
- /* rtpdump only accepts guint32 as source, will be fake for IPv6 */
- memset(&source, 0, sizeof source);
- sourcelen = strinfo->src_addr.len;
- if (sourcelen > sizeof source)
- sourcelen = sizeof source;
- memcpy(&source, strinfo->src_addr.data, sourcelen);
- port = g_htons(strinfo->src_port);
- padding = 0;
-
- if (fwrite(&start_sec, 4, 1, file) == 0)
- return;
- if (fwrite(&start_usec, 4, 1, file) == 0)
- return;
- if (fwrite(&source, 4, 1, file) == 0)
- return;
- if (fwrite(&port, 2, 1, file) == 0)
- return;
- if (fwrite(&padding, 2, 1, file) == 0)
- return;
+ guint32 start_sec; /* start of recording (GMT) (seconds) */
+ guint32 start_usec; /* start of recording (GMT) (microseconds)*/
+ guint32 source; /* network source (multicast address) */
+ size_t sourcelen;
+ guint16 port; /* UDP port */
+ guint16 padding; /* 2 padding bytes */
+ char* addr_str = address_to_display(NULL, &(strinfo->dest_addr));
+
+ fprintf(file, "#!rtpplay%s %s/%u\n", RTPFILE_VERSION,
+ addr_str,
+ strinfo->dest_port);
+ wmem_free(NULL, addr_str);
+
+ start_sec = g_htonl(strinfo->start_fd->abs_ts.secs);
+ start_usec = g_htonl(strinfo->start_fd->abs_ts.nsecs / 1000000);
+ /* rtpdump only accepts guint32 as source, will be fake for IPv6 */
+ memset(&source, 0, sizeof source);
+ sourcelen = strinfo->src_addr.len;
+ if (sourcelen > sizeof source)
+ sourcelen = sizeof source;
+ memcpy(&source, strinfo->src_addr.data, sourcelen);
+ port = g_htons(strinfo->src_port);
+ padding = 0;
+
+ if (fwrite(&start_sec, 4, 1, file) == 0)
+ return;
+ if (fwrite(&start_usec, 4, 1, file) == 0)
+ return;
+ if (fwrite(&source, 4, 1, file) == 0)
+ return;
+ if (fwrite(&port, 2, 1, file) == 0)
+ return;
+ if (fwrite(&padding, 2, 1, file) == 0)
+ return;
}
/* utility function for writing a sample to file in rtpdump -F dump format (.rtp)*/
static void rtp_write_sample(rtpdump_info_t* rtpdump_info, FILE* file)
{
- guint16 length; /* length of packet, including this header (may
- be smaller than plen if not whole packet recorded) */
- guint16 plen; /* actual header+payload length for RTP, 0 for RTCP */
- guint32 offset; /* milliseconds since the start of recording */
-
- length = g_htons(rtpdump_info->num_samples + 8);
- plen = g_htons(rtpdump_info->num_samples);
- offset = g_htonl(rtpdump_info->rec_time);
-
- if (fwrite(&length, 2, 1, file) == 0)
- return;
- if (fwrite(&plen, 2, 1, file) == 0)
- return;
- if (fwrite(&offset, 4, 1, file) == 0)
- return;
- if (fwrite(rtpdump_info->samples, rtpdump_info->num_samples, 1, file) == 0)
- return;
+ guint16 length; /* length of packet, including this header (may
+ be smaller than plen if not whole packet recorded) */
+ guint16 plen; /* actual header+payload length for RTP, 0 for RTCP */
+ guint32 offset; /* milliseconds since the start of recording */
+
+ length = g_htons(rtpdump_info->num_samples + 8);
+ plen = g_htons(rtpdump_info->num_samples);
+ offset = g_htonl(rtpdump_info->rec_time);
+
+ if (fwrite(&length, 2, 1, file) == 0)
+ return;
+ if (fwrite(&plen, 2, 1, file) == 0)
+ return;
+ if (fwrite(&offset, 4, 1, file) == 0)
+ return;
+ if (fwrite(rtpdump_info->samples, rtpdump_info->num_samples, 1, file) == 0)
+ return;
}
@@ -199,539 +187,539 @@ static void rtp_write_sample(rtpdump_info_t* rtpdump_info, FILE* file)
/* whenever a RTP packet is seen by the tap listener */
int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2)
{
- rtpstream_tapinfo_t *tapinfo = (rtpstream_tapinfo_t *)arg;
- const struct _rtp_info *rtpinfo = (const struct _rtp_info *)arg2;
- rtp_stream_info_t new_stream_info;
- rtp_stream_info_t *stream_info = NULL;
- GList* list;
- rtpdump_info_t rtpdump_info;
-
- struct _rtp_conversation_info *p_conv_data = NULL;
-
- /* gather infos on the stream this packet is part of */
- memset(&new_stream_info, 0, sizeof(rtp_stream_info_t));
- copy_address(&(new_stream_info.src_addr), &(pinfo->src));
- new_stream_info.src_port = pinfo->srcport;
- copy_address(&(new_stream_info.dest_addr), &(pinfo->dst));
- new_stream_info.dest_port = pinfo->destport;
- new_stream_info.ssrc = rtpinfo->info_sync_src;
- new_stream_info.payload_type = rtpinfo->info_payload_type;
- new_stream_info.payload_type_name = g_strdup(rtpinfo->info_payload_type_str);
-
- if (tapinfo->mode == TAP_ANALYSE) {
- /* check whether we already have a stream with these parameters in the list */
- list = g_list_first(tapinfo->strinfo_list);
- while (list)
- {
- if (rtp_stream_info_cmp(&new_stream_info, (rtp_stream_info_t*)(list->data))==0)
- {
- stream_info = (rtp_stream_info_t*)(list->data); /*found!*/
- break;
- }
- list = g_list_next(list);
- }
-
- /* not in the list? then create a new entry */
- if (!stream_info) {
- new_stream_info.start_fd = pinfo->fd;
- new_stream_info.start_rel_time = pinfo->rel_ts;
-
- /* reset RTP stats */
- new_stream_info.rtp_stats.first_packet = TRUE;
- new_stream_info.rtp_stats.reg_pt = PT_UNDEFINED;
-
- /* Get the Setup frame number who set this RTP stream */
- p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_get_id_by_filter_name("rtp"), 0);
- if (p_conv_data)
- new_stream_info.setup_frame_number = p_conv_data->frame_number;
- else
- new_stream_info.setup_frame_number = 0xFFFFFFFF;
-
- stream_info = g_new(rtp_stream_info_t,1);
- *stream_info = new_stream_info; /* memberwise copy of struct */
- tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, stream_info);
- }
-
- /* get RTP stats for the packet */
- rtp_packet_analyse(&(stream_info->rtp_stats), pinfo, rtpinfo);
- if (stream_info->rtp_stats.flags & STAT_FLAG_WRONG_TIMESTAMP
- || stream_info->rtp_stats.flags & STAT_FLAG_WRONG_SEQ)
- stream_info->problem = TRUE;
-
-
- /* increment the packets counter for this stream */
- ++(stream_info->packet_count);
- stream_info->stop_rel_time = pinfo->rel_ts;
-
- /* increment the packets counter of all streams */
- ++(tapinfo->npackets);
-
- return 1; /* refresh output */
- }
- else if (tapinfo->mode == TAP_SAVE) {
- if (rtp_stream_info_cmp(&new_stream_info, tapinfo->filter_stream_fwd)==0) {
- /* XXX - what if rtpinfo->info_all_data_present is
- FALSE, so that we don't *have* all the data? */
- rtpdump_info.rec_time = nstime_to_msec(&pinfo->abs_ts) -
- nstime_to_msec(&tapinfo->filter_stream_fwd->start_fd->abs_ts);
- rtpdump_info.num_samples = rtpinfo->info_data_len;
- rtpdump_info.samples = rtpinfo->info_data;
- rtp_write_sample(&rtpdump_info, tapinfo->save_file);
- }
- }
- else if (tapinfo->mode == TAP_MARK && tapinfo->tap_mark_packet) {
- if (rtp_stream_info_cmp(&new_stream_info, tapinfo->filter_stream_fwd)==0
- || rtp_stream_info_cmp(&new_stream_info, tapinfo->filter_stream_rev)==0)
- {
- tapinfo->tap_mark_packet(tapinfo, pinfo->fd);
- }
- }
- return 0;
+ rtpstream_tapinfo_t *tapinfo = (rtpstream_tapinfo_t *)arg;
+ const struct _rtp_info *rtpinfo = (const struct _rtp_info *)arg2;
+ rtp_stream_info_t new_stream_info;
+ rtp_stream_info_t *stream_info = NULL;
+ GList* list;
+ rtpdump_info_t rtpdump_info;
+
+ struct _rtp_conversation_info *p_conv_data = NULL;
+
+ /* gather infos on the stream this packet is part of */
+ memset(&new_stream_info, 0, sizeof(rtp_stream_info_t));
+ copy_address(&(new_stream_info.src_addr), &(pinfo->src));
+ new_stream_info.src_port = pinfo->srcport;
+ copy_address(&(new_stream_info.dest_addr), &(pinfo->dst));
+ new_stream_info.dest_port = pinfo->destport;
+ new_stream_info.ssrc = rtpinfo->info_sync_src;
+ new_stream_info.payload_type = rtpinfo->info_payload_type;
+ new_stream_info.payload_type_name = g_strdup(rtpinfo->info_payload_type_str);
+
+ if (tapinfo->mode == TAP_ANALYSE) {
+ /* check whether we already have a stream with these parameters in the list */
+ list = g_list_first(tapinfo->strinfo_list);
+ while (list)
+ {
+ if (rtp_stream_info_cmp(&new_stream_info, (rtp_stream_info_t*)(list->data))==0)
+ {
+ stream_info = (rtp_stream_info_t*)(list->data); /*found!*/
+ break;
+ }
+ list = g_list_next(list);
+ }
+
+ /* not in the list? then create a new entry */
+ if (!stream_info) {
+ new_stream_info.start_fd = pinfo->fd;
+ new_stream_info.start_rel_time = pinfo->rel_ts;
+
+ /* reset RTP stats */
+ new_stream_info.rtp_stats.first_packet = TRUE;
+ new_stream_info.rtp_stats.reg_pt = PT_UNDEFINED;
+
+ /* Get the Setup frame number who set this RTP stream */
+ p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_get_id_by_filter_name("rtp"), 0);
+ if (p_conv_data)
+ new_stream_info.setup_frame_number = p_conv_data->frame_number;
+ else
+ new_stream_info.setup_frame_number = 0xFFFFFFFF;
+
+ stream_info = g_new(rtp_stream_info_t,1);
+ *stream_info = new_stream_info; /* memberwise copy of struct */
+ tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, stream_info);
+ }
+
+ /* get RTP stats for the packet */
+ rtp_packet_analyse(&(stream_info->rtp_stats), pinfo, rtpinfo);
+ if (stream_info->rtp_stats.flags & STAT_FLAG_WRONG_TIMESTAMP
+ || stream_info->rtp_stats.flags & STAT_FLAG_WRONG_SEQ)
+ stream_info->problem = TRUE;
+
+
+ /* increment the packets counter for this stream */
+ ++(stream_info->packet_count);
+ stream_info->stop_rel_time = pinfo->rel_ts;
+
+ /* increment the packets counter of all streams */
+ ++(tapinfo->npackets);
+
+ return 1; /* refresh output */
+ }
+ else if (tapinfo->mode == TAP_SAVE) {
+ if (rtp_stream_info_cmp(&new_stream_info, tapinfo->filter_stream_fwd)==0) {
+ /* XXX - what if rtpinfo->info_all_data_present is
+ FALSE, so that we don't *have* all the data? */
+ rtpdump_info.rec_time = nstime_to_msec(&pinfo->abs_ts) -
+ nstime_to_msec(&tapinfo->filter_stream_fwd->start_fd->abs_ts);
+ rtpdump_info.num_samples = rtpinfo->info_data_len;
+ rtpdump_info.samples = rtpinfo->info_data;
+ rtp_write_sample(&rtpdump_info, tapinfo->save_file);
+ }
+ }
+ else if (tapinfo->mode == TAP_MARK && tapinfo->tap_mark_packet) {
+ if (rtp_stream_info_cmp(&new_stream_info, tapinfo->filter_stream_fwd)==0
+ || rtp_stream_info_cmp(&new_stream_info, tapinfo->filter_stream_rev)==0)
+ {
+ tapinfo->tap_mark_packet(tapinfo, pinfo->fd);
+ }
+ }
+ return 0;
}
typedef struct _key_value {
- guint32 key;
- guint32 value;
+ guint32 key;
+ guint32 value;
} key_value;
/* RTP sampling clock rates for fixed payload types as defined in
http://www.iana.org/assignments/rtp-parameters */
static const key_value clock_map[] = {
- {PT_PCMU, 8000},
- {PT_1016, 8000},
- {PT_G721, 8000},
- {PT_GSM, 8000},
- {PT_G723, 8000},
- {PT_DVI4_8000, 8000},
- {PT_DVI4_16000, 16000},
- {PT_LPC, 8000},
- {PT_PCMA, 8000},
- {PT_G722, 8000},
- {PT_L16_STEREO, 44100},
- {PT_L16_MONO, 44100},
- {PT_QCELP, 8000},
- {PT_CN, 8000},
- {PT_MPA, 90000},
- {PT_G728, 8000},
- {PT_G728, 8000},
- {PT_DVI4_11025, 11025},
- {PT_DVI4_22050, 22050},
- {PT_G729, 8000},
- {PT_CN_OLD, 8000},
- {PT_CELB, 90000},
- {PT_JPEG, 90000},
- {PT_NV, 90000},
- {PT_H261, 90000},
- {PT_MPV, 90000},
- {PT_MP2T, 90000},
- {PT_H263, 90000},
+ {PT_PCMU, 8000},
+ {PT_1016, 8000},
+ {PT_G721, 8000},
+ {PT_GSM, 8000},
+ {PT_G723, 8000},
+ {PT_DVI4_8000, 8000},
+ {PT_DVI4_16000, 16000},
+ {PT_LPC, 8000},
+ {PT_PCMA, 8000},
+ {PT_G722, 8000},
+ {PT_L16_STEREO, 44100},
+ {PT_L16_MONO, 44100},
+ {PT_QCELP, 8000},
+ {PT_CN, 8000},
+ {PT_MPA, 90000},
+ {PT_G728, 8000},
+ {PT_G728, 8000},
+ {PT_DVI4_11025, 11025},
+ {PT_DVI4_22050, 22050},
+ {PT_G729, 8000},
+ {PT_CN_OLD, 8000},
+ {PT_CELB, 90000},
+ {PT_JPEG, 90000},
+ {PT_NV, 90000},
+ {PT_H261, 90000},
+ {PT_MPV, 90000},
+ {PT_MP2T, 90000},
+ {PT_H263, 90000},
};
-#define NUM_CLOCK_VALUES (sizeof clock_map / sizeof clock_map[0])
+#define NUM_CLOCK_VALUES (sizeof clock_map / sizeof clock_map[0])
static guint32
get_clock_rate(guint32 key)
{
- size_t i;
+ size_t i;
- for (i = 0; i < NUM_CLOCK_VALUES; i++) {
- if (clock_map[i].key == key)
- return clock_map[i].value;
- }
- return 0;
+ for (i = 0; i < NUM_CLOCK_VALUES; i++) {
+ if (clock_map[i].key == key)
+ return clock_map[i].value;
+ }
+ return 0;
}
typedef struct _mimetype_and_clock {
- const gchar *pt_mime_name_str;
- guint32 value;
+ const gchar *pt_mime_name_str;
+ guint32 value;
} mimetype_and_clock;
-/* RTP sampling clock rates for
- "In addition to the RTP payload formats (encodings) listed in the RTP
- Payload Types table, there are additional payload formats that do not
- have static RTP payload types assigned but instead use dynamic payload
- type number assignment. Each payload format is named by a registered
- MIME subtype"
- http://www.iana.org/assignments/rtp-parameters.
-
- NOTE: Please keep the mimetypes in case insensitive alphabetical order.
+/* RTP sampling clock rates for
+ "In addition to the RTP payload formats (encodings) listed in the RTP
+ Payload Types table, there are additional payload formats that do not
+ have static RTP payload types assigned but instead use dynamic payload
+ type number assignment. Each payload format is named by a registered
+ MIME subtype"
+ http://www.iana.org/assignments/rtp-parameters.
+
+ NOTE: Please keep the mimetypes in case insensitive alphabetical order.
*/
static const mimetype_and_clock mimetype_and_clock_map[] = {
- {"AMR", 8000}, /* [RFC4867][RFC3267] */
- {"AMR-WB", 16000}, /* [RFC4867][RFC3267] */
- {"BMPEG", 90000}, /* [RFC2343],[RFC3555] */
- {"BT656", 90000}, /* [RFC2431],[RFC3555] */
- {"DV", 90000}, /* [RFC3189] */
- {"EVRC", 8000}, /* [RFC3558] */
- {"EVRC0", 8000}, /* [RFC4788] */
- {"EVRC1", 8000}, /* [RFC4788] */
- {"EVRCB", 8000}, /* [RFC4788] */
- {"EVRCB0", 8000}, /* [RFC4788] */
- {"EVRCB1", 8000}, /* [RFC4788] */
- {"EVRCWB", 16000}, /* [RFC5188] */
- {"EVRCWB0", 16000}, /* [RFC5188] */
- {"EVRCWB1", 16000}, /* [RFC5188] */
- {"EVS", 16000}, /* [3GPP TS 26.445] */
- {"G7221", 16000}, /* [RFC3047] */
- {"G726-16", 8000}, /* [RFC3551][RFC4856] */
- {"G726-24", 8000}, /* [RFC3551][RFC4856] */
- {"G726-32", 8000}, /* [RFC3551][RFC4856] */
- {"G726-40", 8000}, /* [RFC3551][RFC4856] */
- {"G729D", 8000}, /* [RFC3551][RFC4856] */
- {"G729E", 8000}, /* [RFC3551][RFC4856] */
- {"GSM-EFR", 8000}, /* [RFC3551] */
- {"H263-1998", 90000}, /* [RFC2429],[RFC3555] */
- {"H263-2000", 90000}, /* [RFC2429],[RFC3555] */
- {"H264", 90000}, /* [RFC3984] */
- {"MP1S", 90000}, /* [RFC2250],[RFC3555] */
- {"MP2P", 90000}, /* [RFC2250],[RFC3555] */
- {"MP4V-ES", 90000}, /* [RFC3016] */
- {"mpa-robust", 90000}, /* [RFC3119] */
- {"pointer", 90000}, /* [RFC2862] */
- {"raw", 90000}, /* [RFC4175] */
- {"red", 1000}, /* [RFC4102] */
- {"SMV", 8000}, /* [RFC3558] */
- {"SMV0", 8000}, /* [RFC3558] */
- {"t140", 1000}, /* [RFC4103] */
- {"telephone-event", 8000}, /* [RFC4733] */
+ {"AMR", 8000}, /* [RFC4867][RFC3267] */
+ {"AMR-WB", 16000}, /* [RFC4867][RFC3267] */
+ {"BMPEG", 90000}, /* [RFC2343],[RFC3555] */
+ {"BT656", 90000}, /* [RFC2431],[RFC3555] */
+ {"DV", 90000}, /* [RFC3189] */
+ {"EVRC", 8000}, /* [RFC3558] */
+ {"EVRC0", 8000}, /* [RFC4788] */
+ {"EVRC1", 8000}, /* [RFC4788] */
+ {"EVRCB", 8000}, /* [RFC4788] */
+ {"EVRCB0", 8000}, /* [RFC4788] */
+ {"EVRCB1", 8000}, /* [RFC4788] */
+ {"EVRCWB", 16000}, /* [RFC5188] */
+ {"EVRCWB0", 16000}, /* [RFC5188] */
+ {"EVRCWB1", 16000}, /* [RFC5188] */
+ {"EVS", 16000}, /* [3GPP TS 26.445] */
+ {"G7221", 16000}, /* [RFC3047] */
+ {"G726-16", 8000}, /* [RFC3551][RFC4856] */
+ {"G726-24", 8000}, /* [RFC3551][RFC4856] */
+ {"G726-32", 8000}, /* [RFC3551][RFC4856] */
+ {"G726-40", 8000}, /* [RFC3551][RFC4856] */
+ {"G729D", 8000}, /* [RFC3551][RFC4856] */
+ {"G729E", 8000}, /* [RFC3551][RFC4856] */
+ {"GSM-EFR", 8000}, /* [RFC3551] */
+ {"H263-1998", 90000}, /* [RFC2429],[RFC3555] */
+ {"H263-2000", 90000}, /* [RFC2429],[RFC3555] */
+ {"H264", 90000}, /* [RFC3984] */
+ {"MP1S", 90000}, /* [RFC2250],[RFC3555] */
+ {"MP2P", 90000}, /* [RFC2250],[RFC3555] */
+ {"MP4V-ES", 90000}, /* [RFC3016] */
+ {"mpa-robust", 90000}, /* [RFC3119] */
+ {"pointer", 90000}, /* [RFC2862] */
+ {"raw", 90000}, /* [RFC4175] */
+ {"red", 1000}, /* [RFC4102] */
+ {"SMV", 8000}, /* [RFC3558] */
+ {"SMV0", 8000}, /* [RFC3558] */
+ {"t140", 1000}, /* [RFC4103] */
+ {"telephone-event", 8000}, /* [RFC4733] */
};
-#define NUM_DYN_CLOCK_VALUES (sizeof mimetype_and_clock_map / sizeof mimetype_and_clock_map[0])
+#define NUM_DYN_CLOCK_VALUES (sizeof mimetype_and_clock_map / sizeof mimetype_and_clock_map[0])
static guint32
get_dyn_pt_clock_rate(const gchar *payload_type_str)
{
- int i;
+ int i;
- /* Search for matching mimetype in reverse order to avoid false matches
- * when pt_mime_name_str is the prefix of payload_type_str */
- for (i = NUM_DYN_CLOCK_VALUES - 1; i > -1 ; i--) {
- if (g_ascii_strncasecmp(mimetype_and_clock_map[i].pt_mime_name_str,payload_type_str,(strlen(mimetype_and_clock_map[i].pt_mime_name_str))) == 0)
- return mimetype_and_clock_map[i].value;
- }
+ /* Search for matching mimetype in reverse order to avoid false matches
+ * when pt_mime_name_str is the prefix of payload_type_str */
+ for (i = NUM_DYN_CLOCK_VALUES - 1; i > -1 ; i--) {
+ if (g_ascii_strncasecmp(mimetype_and_clock_map[i].pt_mime_name_str,payload_type_str,(strlen(mimetype_and_clock_map[i].pt_mime_name_str))) == 0)
+ return mimetype_and_clock_map[i].value;
+ }
- return 0;
+ return 0;
}
/****************************************************************************/
void
rtp_packet_analyse(tap_rtp_stat_t *statinfo,
- packet_info *pinfo,
- const struct _rtp_info *rtpinfo)
+ packet_info *pinfo,
+ const struct _rtp_info *rtpinfo)
{
- double current_time;
- double current_jitter;
- double current_diff = 0;
- double nominaltime;
- double arrivaltime; /* Time relative to start_time */
- double expected_time;
- double absskew;
- guint32 clock_rate;
-
- /* Store the current time */
- current_time = nstime_to_msec(&pinfo->rel_ts);
-
- /* Is this the first packet we got in this direction? */
- if (statinfo->first_packet) {
- /* Save the MAC address of the first RTP frame */
- if( pinfo->dl_src.type == AT_ETHER){
- copy_address(&(statinfo->first_packet_mac_addr), &(pinfo->dl_src));
- }
- statinfo->start_seq_nr = rtpinfo->info_seq_num;
- statinfo->stop_seq_nr = rtpinfo->info_seq_num;
- statinfo->seq_num = rtpinfo->info_seq_num;
- statinfo->start_time = current_time;
- statinfo->timestamp = rtpinfo->info_timestamp;
- statinfo->first_timestamp = rtpinfo->info_timestamp;
- statinfo->time = current_time;
- statinfo->lastnominaltime = 0;
- statinfo->pt = rtpinfo->info_payload_type;
- statinfo->reg_pt = rtpinfo->info_payload_type;
- if (pinfo->net_src.type == AT_IPv6) {
- statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 48;
- } else {
- statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 28;
- }
- statinfo->bw_history[statinfo->bw_index].time = current_time;
- statinfo->bw_index++;
- if (pinfo->net_src.type == AT_IPv6) {
- statinfo->total_bytes += rtpinfo->info_data_len + 48;
- } else {
- statinfo->total_bytes += rtpinfo->info_data_len + 28;
- }
- statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000;
- /* Not needed ? initialised to zero? */
- statinfo->delta = 0;
- statinfo->jitter = 0;
- statinfo->diff = 0;
-
- statinfo->total_nr++;
- statinfo->flags |= STAT_FLAG_FIRST;
- if (rtpinfo->info_marker_set) {
- statinfo->flags |= STAT_FLAG_MARKER;
- }
- statinfo->first_packet_num = pinfo->num;
- statinfo->first_packet = FALSE;
- return;
- }
-
- /* Reset flags */
- statinfo->flags = 0;
+ double current_time;
+ double current_jitter;
+ double current_diff = 0;
+ double nominaltime;
+ double arrivaltime; /* Time relative to start_time */
+ double expected_time;
+ double absskew;
+ guint32 clock_rate;
+
+ /* Store the current time */
+ current_time = nstime_to_msec(&pinfo->rel_ts);
+
+ /* Is this the first packet we got in this direction? */
+ if (statinfo->first_packet) {
+ /* Save the MAC address of the first RTP frame */
+ if( pinfo->dl_src.type == AT_ETHER){
+ copy_address(&(statinfo->first_packet_mac_addr), &(pinfo->dl_src));
+ }
+ statinfo->start_seq_nr = rtpinfo->info_seq_num;
+ statinfo->stop_seq_nr = rtpinfo->info_seq_num;
+ statinfo->seq_num = rtpinfo->info_seq_num;
+ statinfo->start_time = current_time;
+ statinfo->timestamp = rtpinfo->info_timestamp;
+ statinfo->first_timestamp = rtpinfo->info_timestamp;
+ statinfo->time = current_time;
+ statinfo->lastnominaltime = 0;
+ statinfo->pt = rtpinfo->info_payload_type;
+ statinfo->reg_pt = rtpinfo->info_payload_type;
+ if (pinfo->net_src.type == AT_IPv6) {
+ statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 48;
+ } else {
+ statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 28;
+ }
+ statinfo->bw_history[statinfo->bw_index].time = current_time;
+ statinfo->bw_index++;
+ if (pinfo->net_src.type == AT_IPv6) {
+ statinfo->total_bytes += rtpinfo->info_data_len + 48;
+ } else {
+ statinfo->total_bytes += rtpinfo->info_data_len + 28;
+ }
+ statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000;
+ /* Not needed ? initialised to zero? */
+ statinfo->delta = 0;
+ statinfo->jitter = 0;
+ statinfo->diff = 0;
+
+ statinfo->total_nr++;
+ statinfo->flags |= STAT_FLAG_FIRST;
+ if (rtpinfo->info_marker_set) {
+ statinfo->flags |= STAT_FLAG_MARKER;
+ }
+ statinfo->first_packet_num = pinfo->num;
+ statinfo->first_packet = FALSE;
+ return;
+ }
+
+ /* Reset flags */
+ statinfo->flags = 0;
#if 0
- /*According to bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=11478
- * this code causes problems. A better solution is needed if there is need for the functionality */
- /* Try to detect duplicated packets due to mirroring/span ports by comparing src MAC addresses.
- * Chek for duplicates (src mac differs from first_packet_mac_addr) */
- */
- if( pinfo->dl_src.type == AT_ETHER){
- if(!addresses_equal(&(statinfo->first_packet_mac_addr), &(pinfo->dl_src))){
- statinfo->flags |= STAT_FLAG_DUP_PKT;
- statinfo->delta = current_time-(statinfo->time);
- return;
- }
- }
+ /*According to bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=11478
+ * this code causes problems. A better solution is needed if there is need for the functionality */
+ /* Try to detect duplicated packets due to mirroring/span ports by comparing src MAC addresses.
+ * Chek for duplicates (src mac differs from first_packet_mac_addr) */
+ */
+ if( pinfo->dl_src.type == AT_ETHER){
+ if(!addresses_equal(&(statinfo->first_packet_mac_addr), &(pinfo->dl_src))){
+ statinfo->flags |= STAT_FLAG_DUP_PKT;
+ statinfo->delta = current_time-(statinfo->time);
+ return;
+ }
+ }
#endif
- /* When calculating expected rtp packets the seq number can wrap around
- * so we have to count the number of cycles
- * Variable cycles counts the wraps around in forwarding connection and
- * under is flag that indicates where we are
- *
- * XXX How to determine number of cycles with all possible lost, late
- * and duplicated packets without any doubt? It seems to me, that
- * because of all possible combination of late, duplicated or lost
- * packets, this can only be more or less good approximation
- *
- * There are some combinations (rare but theoretically possible),
- * where below code won't work correctly - statistic may be wrong then.
- */
-
- /* So if the current sequence number is less than the start one
- * we assume, that there is another cycle running
- */
- if ((rtpinfo->info_seq_num < statinfo->start_seq_nr) && (statinfo->under == FALSE)){
- statinfo->cycles++;
- statinfo->under = TRUE;
- }
- /* what if the start seq nr was 0? Then the above condition will never
- * be true, so we add another condition. XXX The problem would arise
- * if one of the packets with seq nr 0 or 65535 would be lost or late
- */
- else if ((rtpinfo->info_seq_num == 0) && (statinfo->stop_seq_nr == 65535) &&
- (statinfo->under == FALSE)){
- statinfo->cycles++;
- statinfo->under = TRUE;
- }
- /* the whole round is over, so reset the flag */
- else if ((rtpinfo->info_seq_num > statinfo->start_seq_nr) && (statinfo->under != FALSE)) {
- statinfo->under = FALSE;
- }
-
- /* Since it is difficult to count lost, duplicate or late packets separately,
- * we would like to know at least how many times the sequence number was not ok
- */
-
- /* If the current seq number equals the last one or if we are here for
- * the first time, then it is ok, we just store the current one as the last one
- */
- if ( (statinfo->seq_num+1 == rtpinfo->info_seq_num) || (statinfo->flags & STAT_FLAG_FIRST) )
- statinfo->seq_num = rtpinfo->info_seq_num;
- /* If the first one is 65535 we wrap */
- else if ( (statinfo->seq_num == 65535) && (rtpinfo->info_seq_num == 0) )
- statinfo->seq_num = rtpinfo->info_seq_num;
- /* Lost packets. If the prev seq is enormously larger than the cur seq
- * we assume that instead of being massively late we lost the packet(s)
- * that would have indicated the sequence number wrapping. An imprecise
- * heuristic at best, but it seems to work well enough.
- * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5958 */
- else if (statinfo->seq_num+1 < rtpinfo->info_seq_num || statinfo->seq_num - rtpinfo->info_seq_num > 0xFF00) {
- statinfo->seq_num = rtpinfo->info_seq_num;
- statinfo->sequence++;
- statinfo->flags |= STAT_FLAG_WRONG_SEQ;
- }
- /* Late or duplicated */
- else if (statinfo->seq_num+1 > rtpinfo->info_seq_num) {
- statinfo->sequence++;
- statinfo->flags |= STAT_FLAG_WRONG_SEQ;
- }
-
- /* Check payload type */
- if (rtpinfo->info_payload_type == PT_CN
- || rtpinfo->info_payload_type == PT_CN_OLD)
- statinfo->flags |= STAT_FLAG_PT_CN;
- if (statinfo->pt == PT_CN
- || statinfo->pt == PT_CN_OLD)
- statinfo->flags |= STAT_FLAG_FOLLOW_PT_CN;
- if (rtpinfo->info_payload_type != statinfo->pt)
- statinfo->flags |= STAT_FLAG_PT_CHANGE;
- statinfo->pt = rtpinfo->info_payload_type;
-
- /*
- * Return for unknown payload types
- * Ignore jitter calculation for clockrate = 0
- */
- if (statinfo->pt < 96 ){
- clock_rate = get_clock_rate(statinfo->pt);
- }else{ /* Dynamic PT */
- if ( rtpinfo->info_payload_type_str != NULL ){
- /* Is it a "telephone-event" ?
- * Timestamp is not increased for telepone-event packets impacting
- * calculation of Jitter Skew and clock drift.
- * see 2.2.1 of RFC 4733
- */
- if (g_ascii_strncasecmp("telephone-event",rtpinfo->info_payload_type_str,(strlen("telephone-event")))==0){
- clock_rate = 0;
- statinfo->flags |= STAT_FLAG_PT_T_EVENT;
- }else{
- if(rtpinfo->info_payload_rate !=0){
- clock_rate = rtpinfo->info_payload_rate;
- }else{
- clock_rate = get_dyn_pt_clock_rate(rtpinfo->info_payload_type_str);
- }
- }
- }else{
- clock_rate = 0;
- }
- }
-
- /* Handle wraparound ? */
- arrivaltime = current_time - statinfo->start_time;
-
- nominaltime = (double)(guint32_wraparound_diff(rtpinfo->info_timestamp, statinfo->first_timestamp));
-
- /* Can only analyze defined sampling rates */
- if (clock_rate != 0) {
- statinfo->clock_rate = clock_rate;
- /* Convert from sampling clock to ms */
- nominaltime = nominaltime /(clock_rate/1000);
-
- /* Calculate the current jitter(in ms) */
- if (!statinfo->first_packet) {
- expected_time = statinfo->time + (nominaltime - statinfo->lastnominaltime);
- current_diff = fabs(current_time - expected_time);
- current_jitter = (15 * statinfo->jitter + current_diff) / 16;
-
- statinfo->delta = current_time-(statinfo->time);
- statinfo->jitter = current_jitter;
- statinfo->diff = current_diff;
- }
- statinfo->lastnominaltime = nominaltime;
- /* Calculate skew, i.e. absolute jitter that also catches clock drift
- * Skew is positive if TS (nominal) is too fast
- */
- statinfo->skew = nominaltime - arrivaltime;
- absskew = fabs(statinfo->skew);
- if(absskew > fabs(statinfo->max_skew)){
- statinfo->max_skew = statinfo->skew;
- }
- /* Gather data for calculation of average, minimum and maximum framerate based on timestamp */
+ /* When calculating expected rtp packets the seq number can wrap around
+ * so we have to count the number of cycles
+ * Variable cycles counts the wraps around in forwarding connection and
+ * under is flag that indicates where we are
+ *
+ * XXX How to determine number of cycles with all possible lost, late
+ * and duplicated packets without any doubt? It seems to me, that
+ * because of all possible combination of late, duplicated or lost
+ * packets, this can only be more or less good approximation
+ *
+ * There are some combinations (rare but theoretically possible),
+ * where below code won't work correctly - statistic may be wrong then.
+ */
+
+ /* So if the current sequence number is less than the start one
+ * we assume, that there is another cycle running
+ */
+ if ((rtpinfo->info_seq_num < statinfo->start_seq_nr) && (statinfo->under == FALSE)){
+ statinfo->cycles++;
+ statinfo->under = TRUE;
+ }
+ /* what if the start seq nr was 0? Then the above condition will never
+ * be true, so we add another condition. XXX The problem would arise
+ * if one of the packets with seq nr 0 or 65535 would be lost or late
+ */
+ else if ((rtpinfo->info_seq_num == 0) && (statinfo->stop_seq_nr == 65535) &&
+ (statinfo->under == FALSE)) {
+ statinfo->cycles++;
+ statinfo->under = TRUE;
+ }
+ /* the whole round is over, so reset the flag */
+ else if ((rtpinfo->info_seq_num > statinfo->start_seq_nr) && (statinfo->under != FALSE)) {
+ statinfo->under = FALSE;
+ }
+
+ /* Since it is difficult to count lost, duplicate or late packets separately,
+ * we would like to know at least how many times the sequence number was not ok
+ */
+
+ /* If the current seq number equals the last one or if we are here for
+ * the first time, then it is ok, we just store the current one as the last one
+ */
+ if ( (statinfo->seq_num+1 == rtpinfo->info_seq_num) || (statinfo->flags & STAT_FLAG_FIRST) )
+ statinfo->seq_num = rtpinfo->info_seq_num;
+ /* If the first one is 65535 we wrap */
+ else if ( (statinfo->seq_num == 65535) && (rtpinfo->info_seq_num == 0) )
+ statinfo->seq_num = rtpinfo->info_seq_num;
+ /* Lost packets. If the prev seq is enormously larger than the cur seq
+ * we assume that instead of being massively late we lost the packet(s)
+ * that would have indicated the sequence number wrapping. An imprecise
+ * heuristic at best, but it seems to work well enough.
+ * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5958 */
+ else if (statinfo->seq_num+1 < rtpinfo->info_seq_num || statinfo->seq_num - rtpinfo->info_seq_num > 0xFF00) {
+ statinfo->seq_num = rtpinfo->info_seq_num;
+ statinfo->sequence++;
+ statinfo->flags |= STAT_FLAG_WRONG_SEQ;
+ }
+ /* Late or duplicated */
+ else if (statinfo->seq_num+1 > rtpinfo->info_seq_num) {
+ statinfo->sequence++;
+ statinfo->flags |= STAT_FLAG_WRONG_SEQ;
+ }
+
+ /* Check payload type */
+ if (rtpinfo->info_payload_type == PT_CN
+ || rtpinfo->info_payload_type == PT_CN_OLD)
+ statinfo->flags |= STAT_FLAG_PT_CN;
+ if (statinfo->pt == PT_CN
+ || statinfo->pt == PT_CN_OLD)
+ statinfo->flags |= STAT_FLAG_FOLLOW_PT_CN;
+ if (rtpinfo->info_payload_type != statinfo->pt)
+ statinfo->flags |= STAT_FLAG_PT_CHANGE;
+ statinfo->pt = rtpinfo->info_payload_type;
+
+ /*
+ * Return for unknown payload types
+ * Ignore jitter calculation for clockrate = 0
+ */
+ if (statinfo->pt < 96 ){
+ clock_rate = get_clock_rate(statinfo->pt);
+ } else { /* Dynamic PT */
+ if ( rtpinfo->info_payload_type_str != NULL ) {
+ /* Is it a "telephone-event" ?
+ * Timestamp is not increased for telepone-event packets impacting
+ * calculation of Jitter Skew and clock drift.
+ * see 2.2.1 of RFC 4733
+ */
+ if (g_ascii_strncasecmp("telephone-event",rtpinfo->info_payload_type_str,(strlen("telephone-event")))==0) {
+ clock_rate = 0;
+ statinfo->flags |= STAT_FLAG_PT_T_EVENT;
+ } else {
+ if(rtpinfo->info_payload_rate !=0) {
+ clock_rate = rtpinfo->info_payload_rate;
+ } else {
+ clock_rate = get_dyn_pt_clock_rate(rtpinfo->info_payload_type_str);
+ }
+ }
+ } else {
+ clock_rate = 0;
+ }
+ }
+
+ /* Handle wraparound ? */
+ arrivaltime = current_time - statinfo->start_time;
+
+ nominaltime = (double)(guint32_wraparound_diff(rtpinfo->info_timestamp, statinfo->first_timestamp));
+
+ /* Can only analyze defined sampling rates */
+ if (clock_rate != 0) {
+ statinfo->clock_rate = clock_rate;
+ /* Convert from sampling clock to ms */
+ nominaltime = nominaltime /(clock_rate/1000);
+
+ /* Calculate the current jitter(in ms) */
+ if (!statinfo->first_packet) {
+ expected_time = statinfo->time + (nominaltime - statinfo->lastnominaltime);
+ current_diff = fabs(current_time - expected_time);
+ current_jitter = (15 * statinfo->jitter + current_diff) / 16;
+
+ statinfo->delta = current_time-(statinfo->time);
+ statinfo->jitter = current_jitter;
+ statinfo->diff = current_diff;
+ }
+ statinfo->lastnominaltime = nominaltime;
+ /* Calculate skew, i.e. absolute jitter that also catches clock drift
+ * Skew is positive if TS (nominal) is too fast
+ */
+ statinfo->skew = nominaltime - arrivaltime;
+ absskew = fabs(statinfo->skew);
+ if(absskew > fabs(statinfo->max_skew)) {
+ statinfo->max_skew = statinfo->skew;
+ }
+ /* Gather data for calculation of average, minimum and maximum framerate based on timestamp */
#if 0
- if (numPackets > 0 && (!hardPayloadType || !alternatePayloadType)) {
- /* Skip first packet and possibly alternate payload type packets */
- double dt;
- dt = nominaltime - statinfo->lastnominaltime;
- sumdt += 1.0 * dt;
- numdt += (dt != 0 ? 1 : 0);
- mindt = (dt < mindt ? dt : mindt);
- maxdt = (dt > maxdt ? dt : maxdt);
- }
+ if (numPackets > 0 && (!hardPayloadType || !alternatePayloadType)) {
+ /* Skip first packet and possibly alternate payload type packets */
+ double dt;
+ dt = nominaltime - statinfo->lastnominaltime;
+ sumdt += 1.0 * dt;
+ numdt += (dt != 0 ? 1 : 0);
+ mindt = (dt < mindt ? dt : mindt);
+ maxdt = (dt > maxdt ? dt : maxdt);
+ }
#endif
- /* Gather data for calculation of skew least square */
- statinfo->sumt += 1.0 * current_time;
- statinfo->sumTS += 1.0 * nominaltime;
- statinfo->sumt2 += 1.0 * current_time * current_time;
- statinfo->sumtTS += 1.0 * current_time * nominaltime;
- }
-
- /* Calculate the BW in Kbps adding the IP+UDP header to the RTP -> 20bytes(IP) + 8bytes(UDP) */
- if (pinfo->net_src.type == AT_IPv6) {
- statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 48;
- } else {
- statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 28;
- }
- statinfo->bw_history[statinfo->bw_index].time = current_time;
-
- /* Check if there are more than 1sec in the history buffer to calculate BW in bps. If so, remove those for the calculation */
- while ((statinfo->bw_history[statinfo->bw_start_index].time+1000/* ms */)<current_time){
- statinfo->total_bytes -= statinfo->bw_history[statinfo->bw_start_index].bytes;
- statinfo->bw_start_index++;
- if (statinfo->bw_start_index == BUFF_BW) statinfo->bw_start_index=0;
- };
- /* IP hdr + UDP + RTP */
- if (pinfo->net_src.type == AT_IPv6){
- statinfo->total_bytes += rtpinfo->info_data_len + 48;
- }else{
- statinfo->total_bytes += rtpinfo->info_data_len + 28;
- }
- statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000;
- statinfo->bw_index++;
- if (statinfo->bw_index == BUFF_BW) statinfo->bw_index = 0;
-
-
- /* Used by GTK code only */
- statinfo->delta_timestamp = guint32_wraparound_diff(rtpinfo->info_timestamp, statinfo->timestamp);
-
- /* Is it a packet with the mark bit set? */
- if (rtpinfo->info_marker_set) {
- statinfo->flags |= STAT_FLAG_MARKER;
- }
-
- /* Difference can be negative. We don't expect difference bigger than 31 bits. Difference don't care about wrap around. */
- gint32 tsdelta=rtpinfo->info_timestamp - statinfo->timestamp;
- if (tsdelta < 0) {
- statinfo->flags |= STAT_FLAG_WRONG_TIMESTAMP;
- }
- /* Is it a regular packet? */
- if (!(statinfo->flags & STAT_FLAG_FIRST)
- && !(statinfo->flags & STAT_FLAG_MARKER)
- && !(statinfo->flags & STAT_FLAG_PT_CN)
- && !(statinfo->flags & STAT_FLAG_WRONG_TIMESTAMP)
- && !(statinfo->flags & STAT_FLAG_FOLLOW_PT_CN)) {
- /* Include it in maximum delta calculation */
- if (statinfo->delta > statinfo->max_delta) {
- statinfo->max_delta = statinfo->delta;
- statinfo->max_nr = pinfo->num;
- }
- if (clock_rate != 0) {
- /* Maximum and mean jitter calculation */
- if (statinfo->jitter > statinfo->max_jitter) {
- statinfo->max_jitter = statinfo->jitter;
- }
- statinfo->mean_jitter = (statinfo->mean_jitter*statinfo->total_nr + current_diff) / (statinfo->total_nr+1);
- }
- }
- /* Regular payload change? (CN ignored) */
- if (!(statinfo->flags & STAT_FLAG_FIRST)
- && !(statinfo->flags & STAT_FLAG_PT_CN)) {
- if ((statinfo->pt != statinfo->reg_pt)
- && (statinfo->reg_pt != PT_UNDEFINED)) {
- statinfo->flags |= STAT_FLAG_REG_PT_CHANGE;
- }
- }
-
- /* Set regular payload*/
- if (!(statinfo->flags & STAT_FLAG_PT_CN)) {
- statinfo->reg_pt = statinfo->pt;
- }
-
- statinfo->time = current_time;
- statinfo->timestamp = rtpinfo->info_timestamp;
- statinfo->stop_seq_nr = rtpinfo->info_seq_num;
- statinfo->total_nr++;
- statinfo->last_payload_len = rtpinfo->info_payload_len - rtpinfo->info_padding_count;
-
- return;
+ /* Gather data for calculation of skew least square */
+ statinfo->sumt += 1.0 * current_time;
+ statinfo->sumTS += 1.0 * nominaltime;
+ statinfo->sumt2 += 1.0 * current_time * current_time;
+ statinfo->sumtTS += 1.0 * current_time * nominaltime;
+ }
+
+ /* Calculate the BW in Kbps adding the IP+UDP header to the RTP -> 20bytes(IP) + 8bytes(UDP) */
+ if (pinfo->net_src.type == AT_IPv6) {
+ statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 48;
+ } else {
+ statinfo->bw_history[statinfo->bw_index].bytes = rtpinfo->info_data_len + 28;
+ }
+ statinfo->bw_history[statinfo->bw_index].time = current_time;
+
+ /* Check if there are more than 1sec in the history buffer to calculate BW in bps. If so, remove those for the calculation */
+ while ((statinfo->bw_history[statinfo->bw_start_index].time+1000/* ms */)<current_time){
+ statinfo->total_bytes -= statinfo->bw_history[statinfo->bw_start_index].bytes;
+ statinfo->bw_start_index++;
+ if (statinfo->bw_start_index == BUFF_BW) statinfo->bw_start_index=0;
+ };
+ /* IP hdr + UDP + RTP */
+ if (pinfo->net_src.type == AT_IPv6){
+ statinfo->total_bytes += rtpinfo->info_data_len + 48;
+ }else{
+ statinfo->total_bytes += rtpinfo->info_data_len + 28;
+ }
+ statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000;
+ statinfo->bw_index++;
+ if (statinfo->bw_index == BUFF_BW) statinfo->bw_index = 0;
+
+
+ /* Used by GTK code only */
+ statinfo->delta_timestamp = guint32_wraparound_diff(rtpinfo->info_timestamp, statinfo->timestamp);
+
+ /* Is it a packet with the mark bit set? */
+ if (rtpinfo->info_marker_set) {
+ statinfo->flags |= STAT_FLAG_MARKER;
+ }
+
+ /* Difference can be negative. We don't expect difference bigger than 31 bits. Difference don't care about wrap around. */
+ gint32 tsdelta=rtpinfo->info_timestamp - statinfo->timestamp;
+ if (tsdelta < 0) {
+ statinfo->flags |= STAT_FLAG_WRONG_TIMESTAMP;
+ }
+ /* Is it a regular packet? */
+ if (!(statinfo->flags & STAT_FLAG_FIRST)
+ && !(statinfo->flags & STAT_FLAG_MARKER)
+ && !(statinfo->flags & STAT_FLAG_PT_CN)
+ && !(statinfo->flags & STAT_FLAG_WRONG_TIMESTAMP)
+ && !(statinfo->flags & STAT_FLAG_FOLLOW_PT_CN)) {
+ /* Include it in maximum delta calculation */
+ if (statinfo->delta > statinfo->max_delta) {
+ statinfo->max_delta = statinfo->delta;
+ statinfo->max_nr = pinfo->num;
+ }
+ if (clock_rate != 0) {
+ /* Maximum and mean jitter calculation */
+ if (statinfo->jitter > statinfo->max_jitter) {
+ statinfo->max_jitter = statinfo->jitter;
+ }
+ statinfo->mean_jitter = (statinfo->mean_jitter*statinfo->total_nr + current_diff) / (statinfo->total_nr+1);
+ }
+ }
+ /* Regular payload change? (CN ignored) */
+ if (!(statinfo->flags & STAT_FLAG_FIRST)
+ && !(statinfo->flags & STAT_FLAG_PT_CN)) {
+ if ((statinfo->pt != statinfo->reg_pt)
+ && (statinfo->reg_pt != PT_UNDEFINED)) {
+ statinfo->flags |= STAT_FLAG_REG_PT_CHANGE;
+ }
+ }
+
+ /* Set regular payload*/
+ if (!(statinfo->flags & STAT_FLAG_PT_CN)) {
+ statinfo->reg_pt = statinfo->pt;
+ }
+
+ statinfo->time = current_time;
+ statinfo->timestamp = rtpinfo->info_timestamp;
+ statinfo->stop_seq_nr = rtpinfo->info_seq_num;
+ statinfo->total_nr++;
+ statinfo->last_payload_len = rtpinfo->info_payload_len - rtpinfo->info_padding_count;
+
+ return;
}
/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
- * Local variables:
- * c-basic-offset: 8
+ * Local Variables:
+ * c-basic-offset: 4
* tab-width: 8
- * indent-tabs-mode: t
+ * indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=8 tabstop=8 noexpandtab:
- * :indentSize=8:tabSize=8:noTabs=false:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/tap-rtp-common.h b/ui/tap-rtp-common.h
index 239180383c..5fbcbd9dce 100644
--- a/ui/tap-rtp-common.h
+++ b/ui/tap-rtp-common.h
@@ -12,19 +12,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __TAP_RTP_COMMON_H__
@@ -65,14 +53,14 @@ int rtpstream_packet(void*, packet_info*, epan_dissect_t *, const void *);
#endif /* __TAP_RTP_COMMON_H__ */
/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
- * Local variables:
+ * Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/tap-sctp-analysis.c b/ui/tap-sctp-analysis.c
index d58b03e985..960e921ef0 100644
--- a/ui/tap-sctp-analysis.c
+++ b/ui/tap-sctp-analysis.c
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "config.h"
@@ -52,166 +40,166 @@ static sctp_allassocs_info_t sctp_tapinfo_struct = {0, NULL, FALSE, NULL};
static void
free_first(gpointer data, gpointer user_data _U_)
{
- g_free(data);
+ g_free(data);
}
static void
tsn_free(gpointer data, gpointer user_data _U_)
{
- tsn_t *tsn;
-
- tsn = (tsn_t *) data;
- if (tsn->tsns != NULL)
- {
- g_list_foreach(tsn->tsns, free_first, NULL);
- g_list_free(tsn->tsns);
- tsn->tsns=NULL;
- }
+ tsn_t *tsn;
+
+ tsn = (tsn_t *) data;
+ if (tsn->tsns != NULL)
+ {
+ g_list_foreach(tsn->tsns, free_first, NULL);
+ g_list_free(tsn->tsns);
+ tsn->tsns=NULL;
+ }
}
static void
reset(void *arg)
{
- sctp_allassocs_info_t *tapdata = (sctp_allassocs_info_t *)arg;
- GList* list;
- sctp_assoc_info_t * info;
-
- list = g_list_first(tapdata->assoc_info_list);
- while (list)
- {
- info = (sctp_assoc_info_t *) (list->data);
-
- if (info->addr1 != NULL)
- {
- g_list_foreach(info->addr1, free_first, NULL);
- g_list_free(info->addr1);
- info->addr1 = NULL;
- }
-
- if (info->addr2 != NULL)
- {
- g_list_foreach(info->addr2,free_first, NULL);
- g_list_free(info->addr2);
- info->addr2 = NULL;
- }
-
- if (info->error_info_list != NULL)
- {
- g_list_foreach(info->error_info_list, free_first, NULL);
- g_list_free(info->error_info_list);
- info->error_info_list = NULL;
- }
-
- if (info->frame_numbers != NULL)
- {
- g_list_foreach(info->frame_numbers, free_first, NULL);
- g_list_free(info->frame_numbers);
- info->frame_numbers = NULL;
- }
-
- if (info->tsn1 != NULL)
- {
- g_list_foreach(info->tsn1, tsn_free, NULL);
- g_list_free(info->tsn1);
- info->tsn1 = NULL;
- }
-
- if (info->tsn2 != NULL)
- {
- g_list_foreach(info->tsn2, tsn_free, NULL);
- g_list_free(info->tsn2);
- info->tsn2 = NULL;
- }
-
- if (info->sack1 != NULL)
- {
- g_list_foreach(info->sack1, tsn_free, NULL);
- g_list_free(info->sack1);
- info->sack1 = NULL;
- }
-
- if (info->sack2 != NULL)
- {
- g_list_foreach(info->sack2, tsn_free, NULL);
- g_list_free(info->sack2);
- info->sack2 = NULL;
- }
-
- if (info->sort_tsn1 != NULL)
- g_ptr_array_free(info->sort_tsn1, TRUE);
-
- if (info->sort_tsn2 != NULL)
- g_ptr_array_free(info->sort_tsn2, TRUE);
-
- if (info->sort_sack1 != NULL)
- g_ptr_array_free(info->sort_sack1, TRUE);
-
- if (info->sort_sack2 != NULL)
- g_ptr_array_free(info->sort_sack2, TRUE);
-
- if (info->min_max != NULL)
- {
- g_slist_foreach(info->min_max, free_first, NULL);
- info->min_max = NULL;
- }
-
- g_free(list->data);
- list = g_list_next(list);
- }
- g_list_free(tapdata->assoc_info_list);
- tapdata->sum_tvbs = 0;
- tapdata->assoc_info_list = NULL;
+ sctp_allassocs_info_t *tapdata = (sctp_allassocs_info_t *)arg;
+ GList* list;
+ sctp_assoc_info_t * info;
+
+ list = g_list_first(tapdata->assoc_info_list);
+ while (list)
+ {
+ info = (sctp_assoc_info_t *) (list->data);
+
+ if (info->addr1 != NULL)
+ {
+ g_list_foreach(info->addr1, free_first, NULL);
+ g_list_free(info->addr1);
+ info->addr1 = NULL;
+ }
+
+ if (info->addr2 != NULL)
+ {
+ g_list_foreach(info->addr2,free_first, NULL);
+ g_list_free(info->addr2);
+ info->addr2 = NULL;
+ }
+
+ if (info->error_info_list != NULL)
+ {
+ g_list_foreach(info->error_info_list, free_first, NULL);
+ g_list_free(info->error_info_list);
+ info->error_info_list = NULL;
+ }
+
+ if (info->frame_numbers != NULL)
+ {
+ g_list_foreach(info->frame_numbers, free_first, NULL);
+ g_list_free(info->frame_numbers);
+ info->frame_numbers = NULL;
+ }
+
+ if (info->tsn1 != NULL)
+ {
+ g_list_foreach(info->tsn1, tsn_free, NULL);
+ g_list_free(info->tsn1);
+ info->tsn1 = NULL;
+ }
+
+ if (info->tsn2 != NULL)
+ {
+ g_list_foreach(info->tsn2, tsn_free, NULL);
+ g_list_free(info->tsn2);
+ info->tsn2 = NULL;
+ }
+
+ if (info->sack1 != NULL)
+ {
+ g_list_foreach(info->sack1, tsn_free, NULL);
+ g_list_free(info->sack1);
+ info->sack1 = NULL;
+ }
+
+ if (info->sack2 != NULL)
+ {
+ g_list_foreach(info->sack2, tsn_free, NULL);
+ g_list_free(info->sack2);
+ info->sack2 = NULL;
+ }
+
+ if (info->sort_tsn1 != NULL)
+ g_ptr_array_free(info->sort_tsn1, TRUE);
+
+ if (info->sort_tsn2 != NULL)
+ g_ptr_array_free(info->sort_tsn2, TRUE);
+
+ if (info->sort_sack1 != NULL)
+ g_ptr_array_free(info->sort_sack1, TRUE);
+
+ if (info->sort_sack2 != NULL)
+ g_ptr_array_free(info->sort_sack2, TRUE);
+
+ if (info->min_max != NULL)
+ {
+ g_slist_foreach(info->min_max, free_first, NULL);
+ info->min_max = NULL;
+ }
+
+ g_free(list->data);
+ list = g_list_next(list);
+ }
+ g_list_free(tapdata->assoc_info_list);
+ tapdata->sum_tvbs = 0;
+ tapdata->assoc_info_list = NULL;
}
static sctp_assoc_info_t *
calc_checksum(const struct _sctp_info *check_data, sctp_assoc_info_t *data)
{
- gboolean ok = FALSE;
-
- if (check_data->adler32_calculated)
- {
- data->n_adler32_calculated++;
- if (check_data->adler32_correct)
- data->n_adler32_correct++;
- }
- if (check_data->crc32c_calculated)
- {
- data->n_crc32c_calculated++;
- if (check_data->crc32c_correct)
- data->n_crc32c_correct++;
- }
- if (data->n_adler32_calculated > 0)
- {
- if ((float)(data->n_adler32_correct*1.0/data->n_adler32_calculated) > 0.5)
- {
- char str[] = "ADLER32";
- g_strlcpy(data->checksum_type, str, strlen(str));
- data->n_checksum_errors=(data->n_adler32_calculated-data->n_adler32_correct);
- ok = TRUE;
- }
- }
-
- if (data->n_crc32c_calculated>0)
- {
- if ((float)(data->n_crc32c_correct*1.0/data->n_crc32c_calculated) > 0.5)
- {
- char str[] = "CRC32C";
- g_strlcpy(data->checksum_type, str, strlen(str));
- data->n_checksum_errors=data->n_crc32c_calculated-data->n_crc32c_correct;
- ok = TRUE;
- }
- }
-
- if (!ok)
- {
- char str[] = "UNKNOWN";
- g_strlcpy(data->checksum_type, str, strlen(str));
- data->n_checksum_errors=0;
- }
-
- return(data);
+ gboolean ok = FALSE;
+
+ if (check_data->adler32_calculated)
+ {
+ data->n_adler32_calculated++;
+ if (check_data->adler32_correct)
+ data->n_adler32_correct++;
+ }
+ if (check_data->crc32c_calculated)
+ {
+ data->n_crc32c_calculated++;
+ if (check_data->crc32c_correct)
+ data->n_crc32c_correct++;
+ }
+ if (data->n_adler32_calculated > 0)
+ {
+ if ((float)(data->n_adler32_correct*1.0/data->n_adler32_calculated) > 0.5)
+ {
+ char str[] = "ADLER32";
+ g_strlcpy(data->checksum_type, str, strlen(str));
+ data->n_checksum_errors=(data->n_adler32_calculated-data->n_adler32_correct);
+ ok = TRUE;
+ }
+ }
+
+ if (data->n_crc32c_calculated>0)
+ {
+ if ((float)(data->n_crc32c_correct*1.0/data->n_crc32c_calculated) > 0.5)
+ {
+ char str[] = "CRC32C";
+ g_strlcpy(data->checksum_type, str, strlen(str));
+ data->n_checksum_errors=data->n_crc32c_calculated-data->n_crc32c_correct;
+ ok = TRUE;
+ }
+ }
+
+ if (!ok)
+ {
+ char str[] = "UNKNOWN";
+ g_strlcpy(data->checksum_type, str, strlen(str));
+ data->n_checksum_errors=0;
+ }
+
+ return(data);
}
@@ -219,998 +207,998 @@ calc_checksum(const struct _sctp_info *check_data, sctp_assoc_info_t *data)
static sctp_assoc_info_t *
find_assoc(sctp_tmp_info_t *needle)
{
- sctp_allassocs_info_t *assoc_info;
- sctp_assoc_info_t *info = NULL;
- GList* list;
-
- assoc_info = &sctp_tapinfo_struct;
- if ((list = g_list_last(assoc_info->assoc_info_list))!=NULL)
- {
- while (list)
- {
- info = (sctp_assoc_info_t*)(list->data);
- if (needle->assoc_id == info->assoc_id)
- return info;
-
- list = g_list_previous(list);
- }
- }
- return NULL;
+ sctp_allassocs_info_t *assoc_info;
+ sctp_assoc_info_t *info = NULL;
+ GList* list;
+
+ assoc_info = &sctp_tapinfo_struct;
+ if ((list = g_list_last(assoc_info->assoc_info_list))!=NULL)
+ {
+ while (list)
+ {
+ info = (sctp_assoc_info_t*)(list->data);
+ if (needle->assoc_id == info->assoc_id)
+ return info;
+
+ list = g_list_previous(list);
+ }
+ }
+ return NULL;
}
static sctp_assoc_info_t *
add_chunk_count(address *vadd, sctp_assoc_info_t *info, guint32 direction, guint32 type)
{
- GList *list;
- address *v=NULL;
- sctp_addr_chunk *ch=NULL;
- guint8 * dat;
- int i;
-
- list = g_list_first(info->addr_chunk_count);
-
- while (list)
- {
- ch = (sctp_addr_chunk *)(list->data);
- if (ch->direction == direction)
- {
- v = (address *) (ch->addr);
- if (addresses_equal(vadd, v))
- {
- if (IS_SCTP_CHUNK_TYPE(type))
- ch->addr_count[type]++;
- else
- ch->addr_count[OTHER_CHUNKS_INDEX]++;
- return info;
- }
- else
- {
- list = g_list_next(list);
- }
- }
- else
- list = g_list_next(list);
- }
- ch = (sctp_addr_chunk *)g_malloc(sizeof(sctp_addr_chunk));
- ch->direction = direction;
- ch->addr = (address *)g_malloc(sizeof(address));
- ch->addr->type = vadd->type;
- ch->addr->len = vadd->len;
- dat = (guint8 *)g_malloc(vadd->len);
- memcpy(dat, vadd->data, vadd->len);
- ch->addr->data = dat;
- for (i=0; i < NUM_CHUNKS; i++)
- ch->addr_count[i] = 0;
-
- if (IS_SCTP_CHUNK_TYPE(type))
- ch->addr_count[type]++;
- else
- ch->addr_count[OTHER_CHUNKS_INDEX]++;
-
- info->addr_chunk_count = g_list_append(info->addr_chunk_count, ch);
- return info;
+ GList *list;
+ address *v=NULL;
+ sctp_addr_chunk *ch=NULL;
+ guint8 * dat;
+ int i;
+
+ list = g_list_first(info->addr_chunk_count);
+
+ while (list)
+ {
+ ch = (sctp_addr_chunk *)(list->data);
+ if (ch->direction == direction)
+ {
+ v = (address *) (ch->addr);
+ if (addresses_equal(vadd, v))
+ {
+ if (IS_SCTP_CHUNK_TYPE(type))
+ ch->addr_count[type]++;
+ else
+ ch->addr_count[OTHER_CHUNKS_INDEX]++;
+ return info;
+ }
+ else
+ {
+ list = g_list_next(list);
+ }
+ }
+ else
+ list = g_list_next(list);
+ }
+ ch = (sctp_addr_chunk *)g_malloc(sizeof(sctp_addr_chunk));
+ ch->direction = direction;
+ ch->addr = (address *)g_malloc(sizeof(address));
+ ch->addr->type = vadd->type;
+ ch->addr->len = vadd->len;
+ dat = (guint8 *)g_malloc(vadd->len);
+ memcpy(dat, vadd->data, vadd->len);
+ ch->addr->data = dat;
+ for (i=0; i < NUM_CHUNKS; i++)
+ ch->addr_count[i] = 0;
+
+ if (IS_SCTP_CHUNK_TYPE(type))
+ ch->addr_count[type]++;
+ else
+ ch->addr_count[OTHER_CHUNKS_INDEX]++;
+
+ info->addr_chunk_count = g_list_append(info->addr_chunk_count, ch);
+ return info;
}
static sctp_assoc_info_t *
add_address(address *vadd, sctp_assoc_info_t *info, guint16 direction)
{
- GList *list;
- address *v=NULL;
-
- if (direction == 1)
- list = g_list_first(info->addr1);
- else
- list = g_list_first(info->addr2);
-
- while (list)
- {
- v = (address *) (list->data);
- if (addresses_equal(vadd, v)) {
- g_free(vadd);
- return info;
- }
- list = g_list_next(list);
- }
-
- if (direction == 1)
- info->addr1 = g_list_append(info->addr1, vadd);
- else if (direction==2)
- info->addr2 = g_list_append(info->addr2, vadd);
-
- return info;
+ GList *list;
+ address *v=NULL;
+
+ if (direction == 1)
+ list = g_list_first(info->addr1);
+ else
+ list = g_list_first(info->addr2);
+
+ while (list)
+ {
+ v = (address *) (list->data);
+ if (addresses_equal(vadd, v)) {
+ g_free(vadd);
+ return info;
+ }
+ list = g_list_next(list);
+ }
+
+ if (direction == 1)
+ info->addr1 = g_list_append(info->addr1, vadd);
+ else if (direction==2)
+ info->addr2 = g_list_append(info->addr2, vadd);
+
+ return info;
}
static gboolean
packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data)
{
- const struct _sctp_info *sctp_info = (const struct _sctp_info *)data;
- guint32 chunk_number = 0, tsnumber, framenumber;
- sctp_tmp_info_t tmp_info;
- sctp_assoc_info_t *info = NULL;
- sctp_error_info_t *error = NULL;
- guint16 type, length = 0;
- address *store = NULL;
- tsn_t *tsn = NULL;
- tsn_t *sack = NULL;
- guint8 *t_s_n = NULL;
- gboolean sackchunk = FALSE;
- gboolean datachunk = FALSE;
- gboolean forwardchunk = FALSE;
- struct tsn_sort *tsn_s;
- guint8* addr = NULL;
- int i;
- guint8 idx = 0;
-
- framenumber = pinfo->num;
-
- type = sctp_info->ip_src.type;
-
- if (type == AT_IPv4)
- {
- tmp_info.src.type = AT_IPv4;
- tmp_info.src.len = 4;
- }
- else if (type == AT_IPv6)
- {
- tmp_info.src.type = AT_IPv6;
- tmp_info.src.len = 16;
- }
- else
- {
- tmp_info.src.type = AT_NONE;
- tmp_info.src.len = 0;
- }
-
- addr = (guint8 *)g_malloc(tmp_info.src.len);
- memcpy(addr, sctp_info->ip_src.data, tmp_info.src.len);
- tmp_info.src.data = addr;
-
- type = sctp_info->ip_dst.type;
-
- if (type == AT_IPv4)
- {
- tmp_info.dst.type = AT_IPv4;
- tmp_info.dst.len = 4;
- }
- else if (type == AT_IPv6)
- {
- tmp_info.dst.type = AT_IPv6;
- tmp_info.dst.len = 16;
- }
- else
- {
- tmp_info.dst.type = AT_NONE;
- tmp_info.dst.len = 0;
- }
-
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr, sctp_info->ip_dst.data, tmp_info.dst.len);
- tmp_info.dst.data = addr;
-
- tmp_info.port1 = sctp_info->sport;
- tmp_info.port2 = sctp_info->dport;
-
- if (sctp_info->vtag_reflected)
- {
- tmp_info.verification_tag2 = sctp_info->verification_tag;
- tmp_info.verification_tag1 = 0;
- }
- else
- {
- tmp_info.verification_tag1 = sctp_info->verification_tag;
- tmp_info.verification_tag2 = 0;
- }
- tmp_info.n_tvbs = 0;
- if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID)
- {
- tmp_info.initiate_tag = tvb_get_ntohl(sctp_info->tvb[0], 4);
- }
- else
- {
- tmp_info.initiate_tag = 0;
- }
-
- tmp_info.direction = sctp_info->direction;
- tmp_info.assoc_id = sctp_info->assoc_index;
- info = find_assoc(&tmp_info);
- if (!info)
- {
- tmp_info.n_tvbs = sctp_info->number_of_tvbs;
- sctp_tapinfo_struct.sum_tvbs+=sctp_info->number_of_tvbs;
-
- if (sctp_info->number_of_tvbs > 0)
- {
- info = (sctp_assoc_info_t *)g_malloc(sizeof(sctp_assoc_info_t));
- memset(info, 0, sizeof(sctp_assoc_info_t));
- info->assoc_id = sctp_info->assoc_index;
- info->src.type = tmp_info.src.type;
- info->src.len = tmp_info.src.len;
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr,(tmp_info.src.data), tmp_info.src.len);
- info->src.data = addr;
- info->dst.type = tmp_info.dst.type;
- info->dst.len = tmp_info.dst.len;
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr, (tmp_info.dst.data), tmp_info.dst.len);
- info->dst.data = addr;
- info->port1 = tmp_info.port1;
- info->port2 = tmp_info.port2;
- info->verification_tag1 = tmp_info.verification_tag1;
- info->verification_tag2 = tmp_info.verification_tag2;
- info->initiate_tag = tmp_info.initiate_tag;
- info->n_tvbs = tmp_info.n_tvbs;
- info->init = FALSE;
- info->initack = FALSE;
- info->check_address = FALSE;
- info->direction = sctp_info->direction;
- info = calc_checksum(sctp_info, info);
- info->n_packets = 1;
- info->error_info_list = NULL;
- info->min_secs = 0xffffffff;
- info->min_usecs = 0xffffffff;
- info->max_secs = 0;
- info->max_usecs = 0;
- info->min_tsn2 = 0xFFFFFFFF;
- info->min_tsn1 = 0xffffffff;
- info->max_tsn1 = 0;
- info->max_tsn2 = 0;
- info->max_bytes1 = 0;
- info->max_bytes2 = 0;
- info->n_data_chunks = 0;
- info->n_data_bytes = 0;
- info->n_data_chunks_ep1 = 0;
- info->n_data_bytes_ep1 = 0;
- info->n_data_chunks_ep2 = 0;
- info->n_data_bytes_ep2 = 0;
- info->n_sack_chunks_ep1 = 0;
- info->n_sack_chunks_ep2 = 0;
- info->n_array_tsn1 = 0;
- info->n_array_tsn2 = 0;
- info->n_forward_chunks = 0;
- info->max_window1 = 0;
- info->max_window2 = 0;
- info->min_max = NULL;
- info->sort_tsn1 = g_ptr_array_new();
- info->sort_tsn2 = g_ptr_array_new();
- info->sort_sack1 = g_ptr_array_new();
- info->sort_sack2 = g_ptr_array_new();
-
- for (i=0; i < NUM_CHUNKS; i++)
- {
- info->chunk_count[i] = 0;
- info->ep1_chunk_count[i] = 0;
- info->ep2_chunk_count[i] = 0;
- }
- info->addr_chunk_count = NULL;
-
- if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_ACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_I_DATA_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_NR_SACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_FORWARD_TSN_CHUNK_ID))
- {
- tsn = (tsn_t *)g_malloc(sizeof(tsn_t));
- sack = (tsn_t *)g_malloc(sizeof(tsn_t));
- tsn->tsns = NULL;
- tsn->first_tsn = 0;
- sack->tsns = NULL;
- sack->first_tsn = 0;
- sack->src.type=tsn->src.type = tmp_info.src.type;
- sack->src.len=tsn->src.len = tmp_info.src.len;
- addr = (guint8 *)g_malloc(tmp_info.src.len);
- memcpy(addr, tmp_info.src.data, tmp_info.src.len);
- tsn->src.data = addr;
- addr = (guint8 *)g_malloc(tmp_info.src.len);
- memcpy(addr, tmp_info.src.data, tmp_info.src.len);
- sack->src.data = addr;
- sack->dst.type = tsn->dst.type = tmp_info.dst.type;
- sack->dst.len =tsn->dst.len = tmp_info.dst.len;
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr, tmp_info.dst.data, tmp_info.dst.len);
- tsn->dst.data = addr;
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr, tmp_info.dst.data, tmp_info.dst.len);
- sack->dst.data = addr;
- sack->secs=tsn->secs = (guint32)pinfo->rel_ts.secs;
- sack->usecs=tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
- if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_I_DATA_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_NR_SACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_FORWARD_TSN_CHUNK_ID))
- {
- if (tsn->secs < info->min_secs)
- {
- info->min_secs = tsn->secs;
- info->min_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
- info->min_usecs = tsn->usecs;
-
- if (tsn->secs > info->max_secs)
- {
- info->max_secs = tsn->secs;
- info->max_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
- info->max_usecs = tsn->usecs;
- }
-
- sack->frame_number = tsn->frame_number = pinfo->num;
- }
- if ((tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID) || (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_ACK_CHUNK_ID))
- {
- info->min_tsn1 = tvb_get_ntohl(sctp_info->tvb[0],INIT_CHUNK_INITIAL_TSN_OFFSET);
- info->verification_tag2 = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_INITIATE_TAG_OFFSET);
- info->instream1 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET);
- info->outstream1 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET);
- info->arwnd1 = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
- for (chunk_number = 1; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
- {
- type = tvb_get_ntohs(sctp_info->tvb[chunk_number],0);
- if (type == IPV4ADDRESS_PARAMETER_ID)
- {
- store = (address *)g_malloc(sizeof (address));
- alloc_address_tvb(NULL, store, AT_IPv4, 4, sctp_info->tvb[chunk_number], IPV4_ADDRESS_OFFSET);
- info = add_address(store, info, info->direction);
- }
- else if (type == IPV6ADDRESS_PARAMETER_ID)
- {
- store = (address *)g_malloc(sizeof (address));
- alloc_address_tvb(NULL, store, AT_IPv6, 16, sctp_info->tvb[chunk_number], IPV6_ADDRESS_OFFSET);
- info = add_address(store, info, info->direction);
- }
- }
-
- if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID)
- {
- info->init = TRUE;
- }
- else
- {
- info->initack_dir = 1;
- info->initack = TRUE;
- }
-
- idx = tvb_get_guint8(sctp_info->tvb[0],0);
- if (!IS_SCTP_CHUNK_TYPE(idx))
- idx = OTHER_CHUNKS_INDEX;
-
- info->chunk_count[idx]++;
- info->ep1_chunk_count[idx]++;
- info = add_chunk_count(&tmp_info.src, info, 1, idx);
- }
- else
- {
- if (((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_INIT_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_INIT_ACK_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_DATA_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_I_DATA_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_SACK_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_NR_SACK_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_FORWARD_TSN_CHUNK_ID))
- {
- tsn = (tsn_t *)g_malloc(sizeof(tsn_t));
- sack = (tsn_t *)g_malloc(sizeof(tsn_t));
- tsn->tsns = NULL;
- sack->tsns = NULL;
- tsn->first_tsn = 0;
- sack->first_tsn = 0;
- }
- for (chunk_number = 0; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
- {
- idx = tvb_get_guint8(sctp_info->tvb[0],0);
- if (!IS_SCTP_CHUNK_TYPE(idx))
- idx = OTHER_CHUNKS_INDEX;
-
- info->chunk_count[idx]++;
- info->ep1_chunk_count[idx]++;
- info = add_chunk_count(&tmp_info.src, info, 1, idx);
-
- if ((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) ||
- (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_I_DATA_CHUNK_ID))
- {
- datachunk = TRUE;
- if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - DATA_CHUNK_HEADER_LENGTH;
- } else {
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - I_DATA_CHUNK_HEADER_LENGTH;
- }
- info->n_data_chunks++;
- info->n_data_bytes+=length;
- info->outstream1 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
- }
- if ((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_FORWARD_TSN_CHUNK_ID))
- {
- forwardchunk = TRUE;
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET);
- info->n_forward_chunks++;
- }
- if (datachunk || forwardchunk)
- {
-
- tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], DATA_CHUNK_TSN_OFFSET);
- if (tsnumber < info->min_tsn1)
- info->min_tsn1 = tsnumber;
- if (tsnumber > info->max_tsn1)
- {
- if (datachunk)
- {
- info->n_data_chunks_ep1++;
- info->n_data_bytes_ep1+=length;
- }
- else
- info->n_forward_chunks_ep1++;
- info->max_tsn1 = tsnumber;
- }
- if (tsn->first_tsn == 0)
- tsn->first_tsn = tsnumber;
- if (datachunk)
- {
- t_s_n = (guint8 *)g_malloc(16);
- tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, 16);
- }
- else
- {
- t_s_n = (guint8 *)g_malloc(length);
- tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, length);
- }
- tsn->tsns = g_list_append(tsn->tsns, t_s_n);
- tsn_s = (struct tsn_sort *)g_malloc(sizeof(struct tsn_sort));
- tsn_s->tsnumber = tsnumber;
- tsn_s->secs = tsn->secs = (guint32)pinfo->rel_ts.secs;
- tsn_s->usecs = tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
- tsn_s->offset = 0;
- tsn_s->framenumber = framenumber;
- if (datachunk)
- if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
- tsn_s->length = length - DATA_CHUNK_HEADER_LENGTH;
- } else {
- tsn_s->length = length - I_DATA_CHUNK_HEADER_LENGTH;
- }
- else
- tsn_s->length = length;
- if (tsn->secs < info->min_secs)
- {
- info->min_secs = tsn->secs;
- info->min_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
- info->min_usecs = tsn->usecs;
-
- if (tsn->secs > info->max_secs)
- {
- info->max_secs = tsn->secs;
- info->max_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
- info->max_usecs = tsn->usecs;
- g_ptr_array_add(info->sort_tsn1, tsn_s);
- info->n_array_tsn1++;
- }
- if ((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_SACK_CHUNK_ID) ||
- (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_NR_SACK_CHUNK_ID) )
- {
- tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET);
- if (tsnumber < info->min_tsn2)
- info->min_tsn2 = tsnumber;
- if (tsnumber > info->max_tsn2)
- info->max_tsn2 = tsnumber;
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET);
- if (sack->first_tsn == 0)
- sack->first_tsn = tsnumber;
- t_s_n = (guint8 *)g_malloc(length);
- tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, length);
- sack->tsns = g_list_append(sack->tsns, t_s_n);
- sackchunk = TRUE;
- tsn_s = (struct tsn_sort *)g_malloc(sizeof(struct tsn_sort));
- tsn_s->tsnumber = tsnumber;
- tsn_s->secs = tsn->secs = (guint32)pinfo->rel_ts.secs;
- tsn_s->usecs = tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
- tsn_s->offset = 0;
- tsn_s->framenumber = framenumber;
- tsn_s->length = tvb_get_ntohl(sctp_info->tvb[chunk_number], SACK_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
- if (tsn_s->length > info->max_window1)
- info->max_window1 = tsn_s->length;
- if (tsn->secs < info->min_secs)
- {
- info->min_secs = tsn->secs;
- info->min_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
- info->min_usecs = tsn->usecs;
-
- if (tsn->secs > info->max_secs)
- {
- info->max_secs = tsn->secs;
- info->max_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
- info->max_usecs = tsn->usecs;
- g_ptr_array_add(info->sort_sack2, tsn_s);
- info->n_sack_chunks_ep2++;
- }
- }
- }
- if (info->verification_tag1 != 0 || info->verification_tag2 != 0)
- {
- guint32 *number;
- store = (address *)g_malloc(sizeof (address));
- store->type = tmp_info.src.type;
- store->len = tmp_info.src.len;
- addr = (guint8 *)g_malloc(tmp_info.src.len);
- memcpy(addr,(tmp_info.src.data),tmp_info.src.len);
- store->data = addr;
- info = add_address(store, info, info->direction);
- store = (address *)g_malloc(sizeof (address));
- store->type = tmp_info.dst.type;
- store->len = tmp_info.dst.len;
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr,(tmp_info.dst.data),tmp_info.dst.len);
- store->data = addr;
- if (info->direction == 1)
- info = add_address(store, info, 2);
- else
- info = add_address(store, info, 1);
- number = (guint32 *)g_malloc(sizeof(guint32));
- *number = pinfo->num;
- info->frame_numbers=g_list_prepend(info->frame_numbers,number);
- if (datachunk || forwardchunk)
- info->tsn1 = g_list_prepend(info->tsn1, tsn);
- if (sackchunk == TRUE)
- info->sack2 = g_list_prepend(info->sack2, sack);
- sctp_tapinfo_struct.assoc_info_list = g_list_append(sctp_tapinfo_struct.assoc_info_list, info);
- }
- else
- {
- gchar* tmp_str;
- error = (sctp_error_info_t *)g_malloc(sizeof(sctp_error_info_t));
- error->frame_number = pinfo->num;
- error->chunk_info[0] = '\0';
- if ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID)
- {
- tmp_str = val_to_str_wmem(NULL, tvb_get_guint8(sctp_info->tvb[0],0),chunk_type_values,"Reserved (%d)");
- g_strlcpy(error->chunk_info, tmp_str, 200);
- wmem_free(NULL, tmp_str);
- }
- else
- {
- for (chunk_number = 0; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
- {
- tmp_str = val_to_str_wmem(NULL, tvb_get_guint8(sctp_info->tvb[chunk_number],0),chunk_type_values,"Reserved (%d)");
- g_strlcat(error->chunk_info, tmp_str, 200);
- wmem_free(NULL, tmp_str);
- }
- }
- error->info_text = "INFOS";
- info->error_info_list = g_list_append(info->error_info_list, error);
- }
- }
- } /* endif (!info) */
- else
- {
- guint32 *number;
- info->direction = sctp_info->direction;
-
- if (info->verification_tag1 == 0 && info->verification_tag2 != sctp_info->verification_tag) {
- info->verification_tag1 = sctp_info->verification_tag;
- } else if (info->verification_tag2 == 0 && info->verification_tag1 != sctp_info->verification_tag) {
- info->verification_tag2 = sctp_info->verification_tag;
- }
- if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_ACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_I_DATA_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_NR_SACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_FORWARD_TSN_CHUNK_ID))
- {
-
- tsn = (tsn_t *)g_malloc(sizeof(tsn_t));
- sack = (tsn_t *)g_malloc(sizeof(tsn_t));
- tsn->tsns = NULL;
- tsn->first_tsn = 0;
- sack->tsns = NULL;
- sack->first_tsn = 0;
- sack->src.type = tsn->src.type = tmp_info.src.type;
- sack->src.len = tsn->src.len = tmp_info.src.len;
- addr = (guint8 *)g_malloc(tmp_info.src.len);
- memcpy(addr, tmp_info.src.data, tmp_info.src.len);
- tsn->src.data = addr;
- addr = (guint8 *)g_malloc(tmp_info.src.len);
- memcpy(addr, tmp_info.src.data, tmp_info.src.len);
- sack->src.data = addr;
- sack->dst.type = tsn->dst.type = tmp_info.dst.type;
- sack->dst.len = tsn->dst.len = tmp_info.dst.len;
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr, tmp_info.dst.data, tmp_info.dst.len);
- tsn->dst.data = addr;
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr, tmp_info.dst.data, tmp_info.dst.len);
- sack->dst.data = addr;
- sack->secs=tsn->secs = (guint32)pinfo->rel_ts.secs;
- sack->usecs=tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
- if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_I_DATA_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_NR_SACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_FORWARD_TSN_CHUNK_ID))
- {
- if (tsn->secs < info->min_secs)
- {
- info->min_secs = tsn->secs;
- info->min_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
- info->min_usecs = tsn->usecs;
-
- if (tsn->secs > info->max_secs)
- {
- info->max_secs = tsn->secs;
- info->max_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
- info->max_usecs = tsn->usecs;
- }
- sack->frame_number = tsn->frame_number = pinfo->num;
- }
- number = (guint32 *)g_malloc(sizeof(guint32));
- *number = pinfo->num;
- info->frame_numbers=g_list_prepend(info->frame_numbers,number);
-
- store = (address *)g_malloc(sizeof (address));
- store->type = tmp_info.src.type;
- store->len = tmp_info.src.len;
- addr = (guint8 *)g_malloc(tmp_info.src.len);
- memcpy(addr,(tmp_info.src.data),tmp_info.src.len);
- store->data = addr;
-
- if (info->direction == 1)
- info = add_address(store, info, 1);
- else if (info->direction == 2)
- info = add_address(store, info, 2);
-
- store = (address *)g_malloc(sizeof (address));
- store->type = tmp_info.dst.type;
- store->len = tmp_info.dst.len;
- addr = (guint8 *)g_malloc(tmp_info.dst.len);
- memcpy(addr,(tmp_info.dst.data),tmp_info.dst.len);
- store->data = addr;
-
- if (info->direction == 1)
- info = add_address(store, info, 2);
- else if (info->direction == 2)
- info = add_address(store, info, 1);
-
- if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_ACK_CHUNK_ID) ||
- ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID))
- {
- tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], INIT_CHUNK_INITIAL_TSN_OFFSET);
-
- if (info->direction == 2)
- {
- if (tsnumber < info->min_tsn2)
- info->min_tsn2 = tsnumber;
- if (tsnumber > info->max_tsn2)
- info->max_tsn2 = tsnumber;
- info->instream2 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET);
- info->outstream2 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET);
- info->arwnd2 = tvb_get_ntohl(sctp_info->tvb[0],INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
- info->tsn2 = g_list_prepend(info->tsn2, tsn);
- }
- else if (info->direction == 1)
- {
- if (tsnumber < info->min_tsn1)
- info->min_tsn1 = tsnumber;
- if (tsnumber > info->max_tsn1)
- info->max_tsn1 = tsnumber;
- info->instream1 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET);
- info->outstream1 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET);
- info->arwnd1 = tvb_get_ntohl(sctp_info->tvb[0],INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
- info->tsn1 = g_list_prepend(info->tsn1, tsn);
- }
-
- idx = tvb_get_guint8(sctp_info->tvb[0],0);
- if (!IS_SCTP_CHUNK_TYPE(idx))
- idx = OTHER_CHUNKS_INDEX;
- info->chunk_count[idx]++;
- if (info->direction == 1)
- info->ep1_chunk_count[idx]++;
- else
- info->ep2_chunk_count[idx]++;
- info = add_chunk_count(&tmp_info.src, info, info->direction, idx);
- for (chunk_number = 1; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
- {
- type = tvb_get_ntohs(sctp_info->tvb[chunk_number],0);
- if (type == IPV4ADDRESS_PARAMETER_ID)
- {
- store = (address *)g_malloc(sizeof (address));
- alloc_address_tvb(NULL, store, AT_IPv4, 4, sctp_info->tvb[chunk_number], IPV4_ADDRESS_OFFSET);
- info = add_address(store, info, info->direction);
- }
- else if (type == IPV6ADDRESS_PARAMETER_ID)
- {
- store = (address *)g_malloc(sizeof (address));
- alloc_address_tvb(NULL, store, AT_IPv6, 16, sctp_info->tvb[chunk_number], IPV6_ADDRESS_OFFSET);
- info = add_address(store, info, info->direction);
- }
- }
- if ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_ACK_CHUNK_ID)
- {
- info->initack = TRUE;
- info->initack_dir = info->direction;
- }
- else if ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID)
- {
- info->init = TRUE;
- }
- }
- else
- {
- if (((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_INIT_ACK_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_DATA_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_I_DATA_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_SACK_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_NR_SACK_CHUNK_ID) &&
- ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_FORWARD_TSN_CHUNK_ID))
- {
- sack = (tsn_t *)g_malloc(sizeof(tsn_t));
- sack->tsns = NULL;
- sack->first_tsn = 0;
- tsn = (tsn_t *)g_malloc(sizeof(tsn_t));
- tsn->tsns = NULL;
- tsn->first_tsn = 0;
- }
- for (chunk_number = 0; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
- {
- idx = tvb_get_guint8(sctp_info->tvb[chunk_number],0);
- if (!IS_SCTP_CHUNK_TYPE(idx))
- idx = OTHER_CHUNKS_INDEX;
-
- info->chunk_count[idx]++;
- if (info->direction == 1)
- info->ep1_chunk_count[idx]++;
- else
- info->ep2_chunk_count[idx]++;
- info = add_chunk_count(&tmp_info.src, info,info->direction, idx);
-
- if ((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) ||
- (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_I_DATA_CHUNK_ID))
- datachunk = TRUE;
- if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_FORWARD_TSN_CHUNK_ID)
- forwardchunk = TRUE;
- if ((datachunk || forwardchunk) && tsn != NULL)
- {
- tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], DATA_CHUNK_TSN_OFFSET);
- if (tsn->first_tsn == 0)
- tsn->first_tsn = tsnumber;
- if (datachunk)
- {
- t_s_n = (guint8 *)g_malloc(16);
- tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, 16);
- if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
- length=tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET)-DATA_CHUNK_HEADER_LENGTH;
- } else {
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - I_DATA_CHUNK_HEADER_LENGTH;
- }
- info->n_data_chunks++;
- info->n_data_bytes+=length;
- }
- else
- {
- length=tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET);
- t_s_n = (guint8 *)g_malloc(length);
- tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, length);
- info->n_forward_chunks++;
- }
- tsn->tsns = g_list_append(tsn->tsns, t_s_n);
-
- tsn_s = (struct tsn_sort *)g_malloc(sizeof(struct tsn_sort));
- tsn_s->tsnumber = tsnumber;
- tsn_s->secs = tsn->secs = (guint32)pinfo->rel_ts.secs;
- tsn_s->usecs = tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
- tsn_s->offset = 0;
- tsn_s->framenumber = framenumber;
- tsn_s->length = length;
-
- if (tsn->secs < info->min_secs)
- {
- info->min_secs = tsn->secs;
- info->min_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
- info->min_usecs = tsn->usecs;
-
- if (tsn->secs > info->max_secs)
- {
- info->max_secs = tsn->secs;
- info->max_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
- info->max_usecs = tsn->usecs;
-
- if (info->direction == 1)
- {
- if(tsnumber < info->min_tsn1)
- info->min_tsn1 = tsnumber;
- if ((info->init == TRUE || (info->initack == TRUE && info->initack_dir == 1))&& tsnumber >= info->min_tsn1 && tsnumber <= info->max_tsn1)
- {
- if (datachunk)
- {
- info->n_data_chunks_ep1++;
- info->n_data_bytes_ep1 += length;
- }
- else if (forwardchunk)
- {
- info->n_forward_chunks_ep1++;
- }
- }
- if(tsnumber > info->max_tsn1)
- {
- info->max_tsn1 = tsnumber;
- if (datachunk)
- {
- info->n_data_chunks_ep1++;
- info->n_data_bytes_ep1 += length;
- }
- else if (forwardchunk)
- {
- info->n_forward_chunks_ep1++;
- }
- }
- if (datachunk)
- {
- if (info->init == FALSE)
- info->outstream1 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
- if (info->initack == FALSE)
- info->instream2 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
- }
-
- g_ptr_array_add(info->sort_tsn1, tsn_s);
- info->n_array_tsn1++;
- }
- else if (info->direction == 2)
- {
-
- if(tsnumber < info->min_tsn2)
- info->min_tsn2 = tsnumber;
-
- if ((info->initack == TRUE && info->initack_dir == 2)&& tsnumber >= info->min_tsn2 && tsnumber <= info->max_tsn2)
- {
- if (datachunk)
- {
- if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - DATA_CHUNK_HEADER_LENGTH;
- } else {
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - I_DATA_CHUNK_HEADER_LENGTH;
- }
- info->n_data_chunks_ep2++;
- info->n_data_bytes_ep2+=length;
- }
- else if (forwardchunk)
- {
- info->n_forward_chunks_ep2++;
- }
- }
- if (tsnumber > info->max_tsn2)
- {
- info->max_tsn2 = tsnumber;
- if (datachunk)
- {
- if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - DATA_CHUNK_HEADER_LENGTH;
- } else {
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - I_DATA_CHUNK_HEADER_LENGTH;
- }
- info->n_data_chunks_ep2++;
- info->n_data_bytes_ep2+=length;
- }
- else if (forwardchunk)
- {
- info->n_forward_chunks_ep2++;
- }
- }
- if (datachunk)
- {
- if (info->init == FALSE)
- info->instream1 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
- if (info->initack == FALSE)
- info->outstream2 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
- }
-
- g_ptr_array_add(info->sort_tsn2, tsn_s);
- info->n_array_tsn2++;
- }
- }
- else if (((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_SACK_CHUNK_ID) ||
- (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_NR_SACK_CHUNK_ID)) &&
- sack != NULL)
- {
- tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET);
- length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET);
-
- if (sack->first_tsn == 0)
- sack->first_tsn = tsnumber;
-
- t_s_n = (guint8 *)g_malloc(length);
- tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, length);
- sack->tsns = g_list_append(sack->tsns, t_s_n);
- sackchunk = TRUE;
- tsn_s = (struct tsn_sort *)g_malloc(sizeof(struct tsn_sort));
- tsn_s->tsnumber = tsnumber;
- tsn_s->secs = tsn->secs = (guint32)pinfo->rel_ts.secs;
- tsn_s->usecs = tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
- tsn_s->offset = 0;
- tsn_s->framenumber = framenumber;
- tsn_s->length = tvb_get_ntohl(sctp_info->tvb[chunk_number], SACK_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
-
- if (tsn->secs < info->min_secs)
- {
- info->min_secs = tsn->secs;
- info->min_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
- info->min_usecs = tsn->usecs;
-
- if (tsn->secs > info->max_secs)
- {
- info->max_secs = tsn->secs;
- info->max_usecs = tsn->usecs;
- }
- else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
- info->max_usecs = tsn->usecs;
-
-
- if (info->direction == 2)
- {
- if(tsnumber < info->min_tsn1)
- info->min_tsn1 = tsnumber;
- if(tsnumber > info->max_tsn1)
- info->max_tsn1 = tsnumber;
- if (tsn_s->length > info->max_window1)
- info->max_window1 = tsn_s->length;
- g_ptr_array_add(info->sort_sack1, tsn_s);
- info->n_sack_chunks_ep1++;
- }
- else if (info->direction == 1)
- {
-
- if(tsnumber < info->min_tsn2)
- info->min_tsn2 = tsnumber;
- if(tsnumber > info->max_tsn2)
- info->max_tsn2 = tsnumber;
- if (tsn_s->length > info->max_window2)
- info->max_window2 = tsn_s->length;
- g_ptr_array_add(info->sort_sack2, tsn_s);
- info->n_sack_chunks_ep2++;
- }
-
- }
- }
-
- }
- if (datachunk || forwardchunk)
- {
- if (info->direction == 1)
- info->tsn1 = g_list_prepend(info->tsn1, tsn);
- else if (info->direction == 2)
- info->tsn2 = g_list_prepend(info->tsn2, tsn);
- }
- if (sackchunk == TRUE)
- {
- if (info->direction == 1)
- info->sack2 = g_list_prepend(info->sack2, sack);
- else if(info->direction == 2)
- info->sack1 = g_list_prepend(info->sack1, sack);
- }
- info->n_tvbs += sctp_info->number_of_tvbs;
- sctp_tapinfo_struct.sum_tvbs += sctp_info->number_of_tvbs;
- info = calc_checksum(sctp_info, info);
- info->n_packets++;
- }
- return TRUE;
+ const struct _sctp_info *sctp_info = (const struct _sctp_info *)data;
+ guint32 chunk_number = 0, tsnumber, framenumber;
+ sctp_tmp_info_t tmp_info;
+ sctp_assoc_info_t *info = NULL;
+ sctp_error_info_t *error = NULL;
+ guint16 type, length = 0;
+ address *store = NULL;
+ tsn_t *tsn = NULL;
+ tsn_t *sack = NULL;
+ guint8 *t_s_n = NULL;
+ gboolean sackchunk = FALSE;
+ gboolean datachunk = FALSE;
+ gboolean forwardchunk = FALSE;
+ struct tsn_sort *tsn_s;
+ guint8* addr = NULL;
+ int i;
+ guint8 idx = 0;
+
+ framenumber = pinfo->num;
+
+ type = sctp_info->ip_src.type;
+
+ if (type == AT_IPv4)
+ {
+ tmp_info.src.type = AT_IPv4;
+ tmp_info.src.len = 4;
+ }
+ else if (type == AT_IPv6)
+ {
+ tmp_info.src.type = AT_IPv6;
+ tmp_info.src.len = 16;
+ }
+ else
+ {
+ tmp_info.src.type = AT_NONE;
+ tmp_info.src.len = 0;
+ }
+
+ addr = (guint8 *)g_malloc(tmp_info.src.len);
+ memcpy(addr, sctp_info->ip_src.data, tmp_info.src.len);
+ tmp_info.src.data = addr;
+
+ type = sctp_info->ip_dst.type;
+
+ if (type == AT_IPv4)
+ {
+ tmp_info.dst.type = AT_IPv4;
+ tmp_info.dst.len = 4;
+ }
+ else if (type == AT_IPv6)
+ {
+ tmp_info.dst.type = AT_IPv6;
+ tmp_info.dst.len = 16;
+ }
+ else
+ {
+ tmp_info.dst.type = AT_NONE;
+ tmp_info.dst.len = 0;
+ }
+
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr, sctp_info->ip_dst.data, tmp_info.dst.len);
+ tmp_info.dst.data = addr;
+
+ tmp_info.port1 = sctp_info->sport;
+ tmp_info.port2 = sctp_info->dport;
+
+ if (sctp_info->vtag_reflected)
+ {
+ tmp_info.verification_tag2 = sctp_info->verification_tag;
+ tmp_info.verification_tag1 = 0;
+ }
+ else
+ {
+ tmp_info.verification_tag1 = sctp_info->verification_tag;
+ tmp_info.verification_tag2 = 0;
+ }
+ tmp_info.n_tvbs = 0;
+ if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID)
+ {
+ tmp_info.initiate_tag = tvb_get_ntohl(sctp_info->tvb[0], 4);
+ }
+ else
+ {
+ tmp_info.initiate_tag = 0;
+ }
+
+ tmp_info.direction = sctp_info->direction;
+ tmp_info.assoc_id = sctp_info->assoc_index;
+ info = find_assoc(&tmp_info);
+ if (!info)
+ {
+ tmp_info.n_tvbs = sctp_info->number_of_tvbs;
+ sctp_tapinfo_struct.sum_tvbs+=sctp_info->number_of_tvbs;
+
+ if (sctp_info->number_of_tvbs > 0)
+ {
+ info = (sctp_assoc_info_t *)g_malloc(sizeof(sctp_assoc_info_t));
+ memset(info, 0, sizeof(sctp_assoc_info_t));
+ info->assoc_id = sctp_info->assoc_index;
+ info->src.type = tmp_info.src.type;
+ info->src.len = tmp_info.src.len;
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr,(tmp_info.src.data), tmp_info.src.len);
+ info->src.data = addr;
+ info->dst.type = tmp_info.dst.type;
+ info->dst.len = tmp_info.dst.len;
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr, (tmp_info.dst.data), tmp_info.dst.len);
+ info->dst.data = addr;
+ info->port1 = tmp_info.port1;
+ info->port2 = tmp_info.port2;
+ info->verification_tag1 = tmp_info.verification_tag1;
+ info->verification_tag2 = tmp_info.verification_tag2;
+ info->initiate_tag = tmp_info.initiate_tag;
+ info->n_tvbs = tmp_info.n_tvbs;
+ info->init = FALSE;
+ info->initack = FALSE;
+ info->check_address = FALSE;
+ info->direction = sctp_info->direction;
+ info = calc_checksum(sctp_info, info);
+ info->n_packets = 1;
+ info->error_info_list = NULL;
+ info->min_secs = 0xffffffff;
+ info->min_usecs = 0xffffffff;
+ info->max_secs = 0;
+ info->max_usecs = 0;
+ info->min_tsn2 = 0xFFFFFFFF;
+ info->min_tsn1 = 0xffffffff;
+ info->max_tsn1 = 0;
+ info->max_tsn2 = 0;
+ info->max_bytes1 = 0;
+ info->max_bytes2 = 0;
+ info->n_data_chunks = 0;
+ info->n_data_bytes = 0;
+ info->n_data_chunks_ep1 = 0;
+ info->n_data_bytes_ep1 = 0;
+ info->n_data_chunks_ep2 = 0;
+ info->n_data_bytes_ep2 = 0;
+ info->n_sack_chunks_ep1 = 0;
+ info->n_sack_chunks_ep2 = 0;
+ info->n_array_tsn1 = 0;
+ info->n_array_tsn2 = 0;
+ info->n_forward_chunks = 0;
+ info->max_window1 = 0;
+ info->max_window2 = 0;
+ info->min_max = NULL;
+ info->sort_tsn1 = g_ptr_array_new();
+ info->sort_tsn2 = g_ptr_array_new();
+ info->sort_sack1 = g_ptr_array_new();
+ info->sort_sack2 = g_ptr_array_new();
+
+ for (i=0; i < NUM_CHUNKS; i++)
+ {
+ info->chunk_count[i] = 0;
+ info->ep1_chunk_count[i] = 0;
+ info->ep2_chunk_count[i] = 0;
+ }
+ info->addr_chunk_count = NULL;
+
+ if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_ACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_I_DATA_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_NR_SACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_FORWARD_TSN_CHUNK_ID))
+ {
+ tsn = (tsn_t *)g_malloc(sizeof(tsn_t));
+ sack = (tsn_t *)g_malloc(sizeof(tsn_t));
+ tsn->tsns = NULL;
+ tsn->first_tsn = 0;
+ sack->tsns = NULL;
+ sack->first_tsn = 0;
+ sack->src.type=tsn->src.type = tmp_info.src.type;
+ sack->src.len=tsn->src.len = tmp_info.src.len;
+ addr = (guint8 *)g_malloc(tmp_info.src.len);
+ memcpy(addr, tmp_info.src.data, tmp_info.src.len);
+ tsn->src.data = addr;
+ addr = (guint8 *)g_malloc(tmp_info.src.len);
+ memcpy(addr, tmp_info.src.data, tmp_info.src.len);
+ sack->src.data = addr;
+ sack->dst.type = tsn->dst.type = tmp_info.dst.type;
+ sack->dst.len =tsn->dst.len = tmp_info.dst.len;
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr, tmp_info.dst.data, tmp_info.dst.len);
+ tsn->dst.data = addr;
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr, tmp_info.dst.data, tmp_info.dst.len);
+ sack->dst.data = addr;
+ sack->secs=tsn->secs = (guint32)pinfo->rel_ts.secs;
+ sack->usecs=tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
+ if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_I_DATA_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_NR_SACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_FORWARD_TSN_CHUNK_ID))
+ {
+ if (tsn->secs < info->min_secs)
+ {
+ info->min_secs = tsn->secs;
+ info->min_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
+ info->min_usecs = tsn->usecs;
+
+ if (tsn->secs > info->max_secs)
+ {
+ info->max_secs = tsn->secs;
+ info->max_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
+ info->max_usecs = tsn->usecs;
+ }
+
+ sack->frame_number = tsn->frame_number = pinfo->num;
+ }
+ if ((tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID) || (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_ACK_CHUNK_ID))
+ {
+ info->min_tsn1 = tvb_get_ntohl(sctp_info->tvb[0],INIT_CHUNK_INITIAL_TSN_OFFSET);
+ info->verification_tag2 = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_INITIATE_TAG_OFFSET);
+ info->instream1 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET);
+ info->outstream1 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET);
+ info->arwnd1 = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
+ for (chunk_number = 1; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
+ {
+ type = tvb_get_ntohs(sctp_info->tvb[chunk_number],0);
+ if (type == IPV4ADDRESS_PARAMETER_ID)
+ {
+ store = (address *)g_malloc(sizeof (address));
+ alloc_address_tvb(NULL, store, AT_IPv4, 4, sctp_info->tvb[chunk_number], IPV4_ADDRESS_OFFSET);
+ info = add_address(store, info, info->direction);
+ }
+ else if (type == IPV6ADDRESS_PARAMETER_ID)
+ {
+ store = (address *)g_malloc(sizeof (address));
+ alloc_address_tvb(NULL, store, AT_IPv6, 16, sctp_info->tvb[chunk_number], IPV6_ADDRESS_OFFSET);
+ info = add_address(store, info, info->direction);
+ }
+ }
+
+ if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID)
+ {
+ info->init = TRUE;
+ }
+ else
+ {
+ info->initack_dir = 1;
+ info->initack = TRUE;
+ }
+
+ idx = tvb_get_guint8(sctp_info->tvb[0],0);
+ if (!IS_SCTP_CHUNK_TYPE(idx))
+ idx = OTHER_CHUNKS_INDEX;
+
+ info->chunk_count[idx]++;
+ info->ep1_chunk_count[idx]++;
+ info = add_chunk_count(&tmp_info.src, info, 1, idx);
+ }
+ else
+ {
+ if (((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_INIT_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_INIT_ACK_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_DATA_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_I_DATA_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_SACK_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_NR_SACK_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_FORWARD_TSN_CHUNK_ID))
+ {
+ tsn = (tsn_t *)g_malloc(sizeof(tsn_t));
+ sack = (tsn_t *)g_malloc(sizeof(tsn_t));
+ tsn->tsns = NULL;
+ sack->tsns = NULL;
+ tsn->first_tsn = 0;
+ sack->first_tsn = 0;
+ }
+ for (chunk_number = 0; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
+ {
+ idx = tvb_get_guint8(sctp_info->tvb[0],0);
+ if (!IS_SCTP_CHUNK_TYPE(idx))
+ idx = OTHER_CHUNKS_INDEX;
+
+ info->chunk_count[idx]++;
+ info->ep1_chunk_count[idx]++;
+ info = add_chunk_count(&tmp_info.src, info, 1, idx);
+
+ if ((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) ||
+ (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_I_DATA_CHUNK_ID))
+ {
+ datachunk = TRUE;
+ if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - DATA_CHUNK_HEADER_LENGTH;
+ } else {
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - I_DATA_CHUNK_HEADER_LENGTH;
+ }
+ info->n_data_chunks++;
+ info->n_data_bytes+=length;
+ info->outstream1 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
+ }
+ if ((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_FORWARD_TSN_CHUNK_ID))
+ {
+ forwardchunk = TRUE;
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET);
+ info->n_forward_chunks++;
+ }
+ if (datachunk || forwardchunk)
+ {
+
+ tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], DATA_CHUNK_TSN_OFFSET);
+ if (tsnumber < info->min_tsn1)
+ info->min_tsn1 = tsnumber;
+ if (tsnumber > info->max_tsn1)
+ {
+ if (datachunk)
+ {
+ info->n_data_chunks_ep1++;
+ info->n_data_bytes_ep1+=length;
+ }
+ else
+ info->n_forward_chunks_ep1++;
+ info->max_tsn1 = tsnumber;
+ }
+ if (tsn->first_tsn == 0)
+ tsn->first_tsn = tsnumber;
+ if (datachunk)
+ {
+ t_s_n = (guint8 *)g_malloc(16);
+ tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, 16);
+ }
+ else
+ {
+ t_s_n = (guint8 *)g_malloc(length);
+ tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, length);
+ }
+ tsn->tsns = g_list_append(tsn->tsns, t_s_n);
+ tsn_s = (struct tsn_sort *)g_malloc(sizeof(struct tsn_sort));
+ tsn_s->tsnumber = tsnumber;
+ tsn_s->secs = tsn->secs = (guint32)pinfo->rel_ts.secs;
+ tsn_s->usecs = tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
+ tsn_s->offset = 0;
+ tsn_s->framenumber = framenumber;
+ if (datachunk)
+ if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
+ tsn_s->length = length - DATA_CHUNK_HEADER_LENGTH;
+ } else {
+ tsn_s->length = length - I_DATA_CHUNK_HEADER_LENGTH;
+ }
+ else
+ tsn_s->length = length;
+ if (tsn->secs < info->min_secs)
+ {
+ info->min_secs = tsn->secs;
+ info->min_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
+ info->min_usecs = tsn->usecs;
+
+ if (tsn->secs > info->max_secs)
+ {
+ info->max_secs = tsn->secs;
+ info->max_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
+ info->max_usecs = tsn->usecs;
+ g_ptr_array_add(info->sort_tsn1, tsn_s);
+ info->n_array_tsn1++;
+ }
+ if ((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_SACK_CHUNK_ID) ||
+ (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_NR_SACK_CHUNK_ID) )
+ {
+ tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET);
+ if (tsnumber < info->min_tsn2)
+ info->min_tsn2 = tsnumber;
+ if (tsnumber > info->max_tsn2)
+ info->max_tsn2 = tsnumber;
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET);
+ if (sack->first_tsn == 0)
+ sack->first_tsn = tsnumber;
+ t_s_n = (guint8 *)g_malloc(length);
+ tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, length);
+ sack->tsns = g_list_append(sack->tsns, t_s_n);
+ sackchunk = TRUE;
+ tsn_s = (struct tsn_sort *)g_malloc(sizeof(struct tsn_sort));
+ tsn_s->tsnumber = tsnumber;
+ tsn_s->secs = tsn->secs = (guint32)pinfo->rel_ts.secs;
+ tsn_s->usecs = tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
+ tsn_s->offset = 0;
+ tsn_s->framenumber = framenumber;
+ tsn_s->length = tvb_get_ntohl(sctp_info->tvb[chunk_number], SACK_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
+ if (tsn_s->length > info->max_window1)
+ info->max_window1 = tsn_s->length;
+ if (tsn->secs < info->min_secs)
+ {
+ info->min_secs = tsn->secs;
+ info->min_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
+ info->min_usecs = tsn->usecs;
+
+ if (tsn->secs > info->max_secs)
+ {
+ info->max_secs = tsn->secs;
+ info->max_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
+ info->max_usecs = tsn->usecs;
+ g_ptr_array_add(info->sort_sack2, tsn_s);
+ info->n_sack_chunks_ep2++;
+ }
+ }
+ }
+ if (info->verification_tag1 != 0 || info->verification_tag2 != 0)
+ {
+ guint32 *number;
+ store = (address *)g_malloc(sizeof (address));
+ store->type = tmp_info.src.type;
+ store->len = tmp_info.src.len;
+ addr = (guint8 *)g_malloc(tmp_info.src.len);
+ memcpy(addr,(tmp_info.src.data),tmp_info.src.len);
+ store->data = addr;
+ info = add_address(store, info, info->direction);
+ store = (address *)g_malloc(sizeof (address));
+ store->type = tmp_info.dst.type;
+ store->len = tmp_info.dst.len;
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr,(tmp_info.dst.data),tmp_info.dst.len);
+ store->data = addr;
+ if (info->direction == 1)
+ info = add_address(store, info, 2);
+ else
+ info = add_address(store, info, 1);
+ number = (guint32 *)g_malloc(sizeof(guint32));
+ *number = pinfo->num;
+ info->frame_numbers=g_list_prepend(info->frame_numbers,number);
+ if (datachunk || forwardchunk)
+ info->tsn1 = g_list_prepend(info->tsn1, tsn);
+ if (sackchunk == TRUE)
+ info->sack2 = g_list_prepend(info->sack2, sack);
+ sctp_tapinfo_struct.assoc_info_list = g_list_append(sctp_tapinfo_struct.assoc_info_list, info);
+ }
+ else
+ {
+ gchar* tmp_str;
+ error = (sctp_error_info_t *)g_malloc(sizeof(sctp_error_info_t));
+ error->frame_number = pinfo->num;
+ error->chunk_info[0] = '\0';
+ if ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID)
+ {
+ tmp_str = val_to_str_wmem(NULL, tvb_get_guint8(sctp_info->tvb[0],0),chunk_type_values,"Reserved (%d)");
+ g_strlcpy(error->chunk_info, tmp_str, 200);
+ wmem_free(NULL, tmp_str);
+ }
+ else
+ {
+ for (chunk_number = 0; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
+ {
+ tmp_str = val_to_str_wmem(NULL, tvb_get_guint8(sctp_info->tvb[chunk_number],0),chunk_type_values,"Reserved (%d)");
+ g_strlcat(error->chunk_info, tmp_str, 200);
+ wmem_free(NULL, tmp_str);
+ }
+ }
+ error->info_text = "INFOS";
+ info->error_info_list = g_list_append(info->error_info_list, error);
+ }
+ }
+ } /* endif (!info) */
+ else
+ {
+ guint32 *number;
+ info->direction = sctp_info->direction;
+
+ if (info->verification_tag1 == 0 && info->verification_tag2 != sctp_info->verification_tag) {
+ info->verification_tag1 = sctp_info->verification_tag;
+ } else if (info->verification_tag2 == 0 && info->verification_tag1 != sctp_info->verification_tag) {
+ info->verification_tag2 = sctp_info->verification_tag;
+ }
+ if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_ACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_I_DATA_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_NR_SACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_FORWARD_TSN_CHUNK_ID))
+ {
+
+ tsn = (tsn_t *)g_malloc(sizeof(tsn_t));
+ sack = (tsn_t *)g_malloc(sizeof(tsn_t));
+ tsn->tsns = NULL;
+ tsn->first_tsn = 0;
+ sack->tsns = NULL;
+ sack->first_tsn = 0;
+ sack->src.type = tsn->src.type = tmp_info.src.type;
+ sack->src.len = tsn->src.len = tmp_info.src.len;
+ addr = (guint8 *)g_malloc(tmp_info.src.len);
+ memcpy(addr, tmp_info.src.data, tmp_info.src.len);
+ tsn->src.data = addr;
+ addr = (guint8 *)g_malloc(tmp_info.src.len);
+ memcpy(addr, tmp_info.src.data, tmp_info.src.len);
+ sack->src.data = addr;
+ sack->dst.type = tsn->dst.type = tmp_info.dst.type;
+ sack->dst.len = tsn->dst.len = tmp_info.dst.len;
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr, tmp_info.dst.data, tmp_info.dst.len);
+ tsn->dst.data = addr;
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr, tmp_info.dst.data, tmp_info.dst.len);
+ sack->dst.data = addr;
+ sack->secs=tsn->secs = (guint32)pinfo->rel_ts.secs;
+ sack->usecs=tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
+ if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_DATA_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_I_DATA_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_SACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_NR_SACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_FORWARD_TSN_CHUNK_ID))
+ {
+ if (tsn->secs < info->min_secs)
+ {
+ info->min_secs = tsn->secs;
+ info->min_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
+ info->min_usecs = tsn->usecs;
+
+ if (tsn->secs > info->max_secs)
+ {
+ info->max_secs = tsn->secs;
+ info->max_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
+ info->max_usecs = tsn->usecs;
+ }
+ sack->frame_number = tsn->frame_number = pinfo->num;
+ }
+ number = (guint32 *)g_malloc(sizeof(guint32));
+ *number = pinfo->num;
+ info->frame_numbers=g_list_prepend(info->frame_numbers,number);
+
+ store = (address *)g_malloc(sizeof (address));
+ store->type = tmp_info.src.type;
+ store->len = tmp_info.src.len;
+ addr = (guint8 *)g_malloc(tmp_info.src.len);
+ memcpy(addr,(tmp_info.src.data),tmp_info.src.len);
+ store->data = addr;
+
+ if (info->direction == 1)
+ info = add_address(store, info, 1);
+ else if (info->direction == 2)
+ info = add_address(store, info, 2);
+
+ store = (address *)g_malloc(sizeof (address));
+ store->type = tmp_info.dst.type;
+ store->len = tmp_info.dst.len;
+ addr = (guint8 *)g_malloc(tmp_info.dst.len);
+ memcpy(addr,(tmp_info.dst.data),tmp_info.dst.len);
+ store->data = addr;
+
+ if (info->direction == 1)
+ info = add_address(store, info, 2);
+ else if (info->direction == 2)
+ info = add_address(store, info, 1);
+
+ if (((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_ACK_CHUNK_ID) ||
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID))
+ {
+ tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], INIT_CHUNK_INITIAL_TSN_OFFSET);
+
+ if (info->direction == 2)
+ {
+ if (tsnumber < info->min_tsn2)
+ info->min_tsn2 = tsnumber;
+ if (tsnumber > info->max_tsn2)
+ info->max_tsn2 = tsnumber;
+ info->instream2 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET);
+ info->outstream2 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET);
+ info->arwnd2 = tvb_get_ntohl(sctp_info->tvb[0],INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
+ info->tsn2 = g_list_prepend(info->tsn2, tsn);
+ }
+ else if (info->direction == 1)
+ {
+ if (tsnumber < info->min_tsn1)
+ info->min_tsn1 = tsnumber;
+ if (tsnumber > info->max_tsn1)
+ info->max_tsn1 = tsnumber;
+ info->instream1 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET);
+ info->outstream1 = tvb_get_ntohs(sctp_info->tvb[0],INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET);
+ info->arwnd1 = tvb_get_ntohl(sctp_info->tvb[0],INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
+ info->tsn1 = g_list_prepend(info->tsn1, tsn);
+ }
+
+ idx = tvb_get_guint8(sctp_info->tvb[0],0);
+ if (!IS_SCTP_CHUNK_TYPE(idx))
+ idx = OTHER_CHUNKS_INDEX;
+ info->chunk_count[idx]++;
+ if (info->direction == 1)
+ info->ep1_chunk_count[idx]++;
+ else
+ info->ep2_chunk_count[idx]++;
+ info = add_chunk_count(&tmp_info.src, info, info->direction, idx);
+ for (chunk_number = 1; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
+ {
+ type = tvb_get_ntohs(sctp_info->tvb[chunk_number],0);
+ if (type == IPV4ADDRESS_PARAMETER_ID)
+ {
+ store = (address *)g_malloc(sizeof (address));
+ alloc_address_tvb(NULL, store, AT_IPv4, 4, sctp_info->tvb[chunk_number], IPV4_ADDRESS_OFFSET);
+ info = add_address(store, info, info->direction);
+ }
+ else if (type == IPV6ADDRESS_PARAMETER_ID)
+ {
+ store = (address *)g_malloc(sizeof (address));
+ alloc_address_tvb(NULL, store, AT_IPv6, 16, sctp_info->tvb[chunk_number], IPV6_ADDRESS_OFFSET);
+ info = add_address(store, info, info->direction);
+ }
+ }
+ if ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_ACK_CHUNK_ID)
+ {
+ info->initack = TRUE;
+ info->initack_dir = info->direction;
+ }
+ else if ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID)
+ {
+ info->init = TRUE;
+ }
+ }
+ else
+ {
+ if (((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_INIT_ACK_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_DATA_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_I_DATA_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_SACK_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_NR_SACK_CHUNK_ID) &&
+ ((tvb_get_guint8(sctp_info->tvb[0],0)) != SCTP_FORWARD_TSN_CHUNK_ID))
+ {
+ sack = (tsn_t *)g_malloc(sizeof(tsn_t));
+ sack->tsns = NULL;
+ sack->first_tsn = 0;
+ tsn = (tsn_t *)g_malloc(sizeof(tsn_t));
+ tsn->tsns = NULL;
+ tsn->first_tsn = 0;
+ }
+ for (chunk_number = 0; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
+ {
+ idx = tvb_get_guint8(sctp_info->tvb[chunk_number],0);
+ if (!IS_SCTP_CHUNK_TYPE(idx))
+ idx = OTHER_CHUNKS_INDEX;
+
+ info->chunk_count[idx]++;
+ if (info->direction == 1)
+ info->ep1_chunk_count[idx]++;
+ else
+ info->ep2_chunk_count[idx]++;
+ info = add_chunk_count(&tmp_info.src, info,info->direction, idx);
+
+ if ((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) ||
+ (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_I_DATA_CHUNK_ID))
+ datachunk = TRUE;
+ if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_FORWARD_TSN_CHUNK_ID)
+ forwardchunk = TRUE;
+ if ((datachunk || forwardchunk) && tsn != NULL)
+ {
+ tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], DATA_CHUNK_TSN_OFFSET);
+ if (tsn->first_tsn == 0)
+ tsn->first_tsn = tsnumber;
+ if (datachunk)
+ {
+ t_s_n = (guint8 *)g_malloc(16);
+ tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, 16);
+ if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
+ length=tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET)-DATA_CHUNK_HEADER_LENGTH;
+ } else {
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - I_DATA_CHUNK_HEADER_LENGTH;
+ }
+ info->n_data_chunks++;
+ info->n_data_bytes+=length;
+ }
+ else
+ {
+ length=tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET);
+ t_s_n = (guint8 *)g_malloc(length);
+ tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, length);
+ info->n_forward_chunks++;
+ }
+ tsn->tsns = g_list_append(tsn->tsns, t_s_n);
+
+ tsn_s = (struct tsn_sort *)g_malloc(sizeof(struct tsn_sort));
+ tsn_s->tsnumber = tsnumber;
+ tsn_s->secs = tsn->secs = (guint32)pinfo->rel_ts.secs;
+ tsn_s->usecs = tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
+ tsn_s->offset = 0;
+ tsn_s->framenumber = framenumber;
+ tsn_s->length = length;
+
+ if (tsn->secs < info->min_secs)
+ {
+ info->min_secs = tsn->secs;
+ info->min_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
+ info->min_usecs = tsn->usecs;
+
+ if (tsn->secs > info->max_secs)
+ {
+ info->max_secs = tsn->secs;
+ info->max_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
+ info->max_usecs = tsn->usecs;
+
+ if (info->direction == 1)
+ {
+ if(tsnumber < info->min_tsn1)
+ info->min_tsn1 = tsnumber;
+ if ((info->init == TRUE || (info->initack == TRUE && info->initack_dir == 1))&& tsnumber >= info->min_tsn1 && tsnumber <= info->max_tsn1)
+ {
+ if (datachunk)
+ {
+ info->n_data_chunks_ep1++;
+ info->n_data_bytes_ep1 += length;
+ }
+ else if (forwardchunk)
+ {
+ info->n_forward_chunks_ep1++;
+ }
+ }
+ if(tsnumber > info->max_tsn1)
+ {
+ info->max_tsn1 = tsnumber;
+ if (datachunk)
+ {
+ info->n_data_chunks_ep1++;
+ info->n_data_bytes_ep1 += length;
+ }
+ else if (forwardchunk)
+ {
+ info->n_forward_chunks_ep1++;
+ }
+ }
+ if (datachunk)
+ {
+ if (info->init == FALSE)
+ info->outstream1 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
+ if (info->initack == FALSE)
+ info->instream2 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
+ }
+
+ g_ptr_array_add(info->sort_tsn1, tsn_s);
+ info->n_array_tsn1++;
+ }
+ else if (info->direction == 2)
+ {
+
+ if(tsnumber < info->min_tsn2)
+ info->min_tsn2 = tsnumber;
+
+ if ((info->initack == TRUE && info->initack_dir == 2)&& tsnumber >= info->min_tsn2 && tsnumber <= info->max_tsn2)
+ {
+ if (datachunk)
+ {
+ if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - DATA_CHUNK_HEADER_LENGTH;
+ } else {
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - I_DATA_CHUNK_HEADER_LENGTH;
+ }
+ info->n_data_chunks_ep2++;
+ info->n_data_bytes_ep2+=length;
+ }
+ else if (forwardchunk)
+ {
+ info->n_forward_chunks_ep2++;
+ }
+ }
+ if (tsnumber > info->max_tsn2)
+ {
+ info->max_tsn2 = tsnumber;
+ if (datachunk)
+ {
+ if (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_DATA_CHUNK_ID) {
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - DATA_CHUNK_HEADER_LENGTH;
+ } else {
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET) - I_DATA_CHUNK_HEADER_LENGTH;
+ }
+ info->n_data_chunks_ep2++;
+ info->n_data_bytes_ep2+=length;
+ }
+ else if (forwardchunk)
+ {
+ info->n_forward_chunks_ep2++;
+ }
+ }
+ if (datachunk)
+ {
+ if (info->init == FALSE)
+ info->instream1 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
+ if (info->initack == FALSE)
+ info->outstream2 = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
+ }
+
+ g_ptr_array_add(info->sort_tsn2, tsn_s);
+ info->n_array_tsn2++;
+ }
+ }
+ else if (((tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_SACK_CHUNK_ID) ||
+ (tvb_get_guint8(sctp_info->tvb[chunk_number],0) == SCTP_NR_SACK_CHUNK_ID)) &&
+ sack != NULL)
+ {
+ tsnumber = tvb_get_ntohl((sctp_info->tvb)[chunk_number], SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET);
+ length = tvb_get_ntohs(sctp_info->tvb[chunk_number], CHUNK_LENGTH_OFFSET);
+
+ if (sack->first_tsn == 0)
+ sack->first_tsn = tsnumber;
+
+ t_s_n = (guint8 *)g_malloc(length);
+ tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(t_s_n),0, length);
+ sack->tsns = g_list_append(sack->tsns, t_s_n);
+ sackchunk = TRUE;
+ tsn_s = (struct tsn_sort *)g_malloc(sizeof(struct tsn_sort));
+ tsn_s->tsnumber = tsnumber;
+ tsn_s->secs = tsn->secs = (guint32)pinfo->rel_ts.secs;
+ tsn_s->usecs = tsn->usecs = (guint32)pinfo->rel_ts.nsecs/1000;
+ tsn_s->offset = 0;
+ tsn_s->framenumber = framenumber;
+ tsn_s->length = tvb_get_ntohl(sctp_info->tvb[chunk_number], SACK_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
+
+ if (tsn->secs < info->min_secs)
+ {
+ info->min_secs = tsn->secs;
+ info->min_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->min_secs && tsn->usecs < info->min_usecs)
+ info->min_usecs = tsn->usecs;
+
+ if (tsn->secs > info->max_secs)
+ {
+ info->max_secs = tsn->secs;
+ info->max_usecs = tsn->usecs;
+ }
+ else if (tsn->secs == info->max_secs && tsn->usecs > info->max_usecs)
+ info->max_usecs = tsn->usecs;
+
+
+ if (info->direction == 2)
+ {
+ if(tsnumber < info->min_tsn1)
+ info->min_tsn1 = tsnumber;
+ if(tsnumber > info->max_tsn1)
+ info->max_tsn1 = tsnumber;
+ if (tsn_s->length > info->max_window1)
+ info->max_window1 = tsn_s->length;
+ g_ptr_array_add(info->sort_sack1, tsn_s);
+ info->n_sack_chunks_ep1++;
+ }
+ else if (info->direction == 1)
+ {
+
+ if(tsnumber < info->min_tsn2)
+ info->min_tsn2 = tsnumber;
+ if(tsnumber > info->max_tsn2)
+ info->max_tsn2 = tsnumber;
+ if (tsn_s->length > info->max_window2)
+ info->max_window2 = tsn_s->length;
+ g_ptr_array_add(info->sort_sack2, tsn_s);
+ info->n_sack_chunks_ep2++;
+ }
+
+ }
+ }
+
+ }
+ if (datachunk || forwardchunk)
+ {
+ if (info->direction == 1)
+ info->tsn1 = g_list_prepend(info->tsn1, tsn);
+ else if (info->direction == 2)
+ info->tsn2 = g_list_prepend(info->tsn2, tsn);
+ }
+ if (sackchunk == TRUE)
+ {
+ if (info->direction == 1)
+ info->sack2 = g_list_prepend(info->sack2, sack);
+ else if(info->direction == 2)
+ info->sack1 = g_list_prepend(info->sack1, sack);
+ }
+ info->n_tvbs += sctp_info->number_of_tvbs;
+ sctp_tapinfo_struct.sum_tvbs += sctp_info->number_of_tvbs;
+ info = calc_checksum(sctp_info, info);
+ info->n_packets++;
+ }
+ return TRUE;
}
@@ -1218,52 +1206,53 @@ packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const voi
void
remove_tap_listener_sctp_stat(void)
{
- if (sctp_tapinfo_struct.is_registered) {
- remove_tap_listener(&sctp_tapinfo_struct);
- sctp_tapinfo_struct.is_registered = FALSE;
- }
+ if (sctp_tapinfo_struct.is_registered) {
+ remove_tap_listener(&sctp_tapinfo_struct);
+ sctp_tapinfo_struct.is_registered = FALSE;
+ }
}
void
sctp_stat_scan(void)
{
- if (!sctp_tapinfo_struct.is_registered)
- register_tap_listener_sctp_stat();
+ if (!sctp_tapinfo_struct.is_registered) {
+ register_tap_listener_sctp_stat();
+ }
}
const sctp_allassocs_info_t *
sctp_stat_get_info(void)
{
- return &sctp_tapinfo_struct;
+ return &sctp_tapinfo_struct;
}
void
register_tap_listener_sctp_stat(void)
{
- GString *error_string;
-
- if (!sctp_tapinfo_struct.is_registered)
- {
- if ((error_string = register_tap_listener("sctp", &sctp_tapinfo_struct, NULL, 0, reset, packet, NULL))) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
- g_string_free(error_string, TRUE);
- return;
- }
- sctp_tapinfo_struct.is_registered=TRUE;
- }
+ GString *error_string;
+
+ if (!sctp_tapinfo_struct.is_registered)
+ {
+ if ((error_string = register_tap_listener("sctp", &sctp_tapinfo_struct, NULL, 0, reset, packet, NULL))) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
+ g_string_free(error_string, TRUE);
+ return;
+ }
+ sctp_tapinfo_struct.is_registered=TRUE;
+ }
}
/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
- * Local variables:
- * c-basic-offset: 8
+ * Local Variables:
+ * c-basic-offset: 4
* tab-width: 8
- * indent-tabs-mode: t
+ * indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=8 tabstop=8 noexpandtab:
- * :indentSize=8:tabSize=8:noTabs=false:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/
diff --git a/ui/tap-sctp-analysis.h b/ui/tap-sctp-analysis.h
index b5d5f1542a..d9f04a3982 100644
--- a/ui/tap-sctp-analysis.h
+++ b/ui/tap-sctp-analysis.h
@@ -5,19 +5,7 @@
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __TAP_SCTP_ANALYSIS_H__
@@ -316,14 +304,14 @@ const sctp_assoc_info_t* get_selected_assoc(void);
#endif /* __TAP_SCTP_ANALYSIS_H__ */
/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
*
- * Local variables:
- * c-basic-offset: 8
+ * Local Variables:
+ * c-basic-offset: 4
* tab-width: 8
- * indent-tabs-mode: t
+ * indent-tabs-mode: nil
* End:
*
- * vi: set shiftwidth=8 tabstop=8 noexpandtab:
- * :indentSize=8:tabSize=8:noTabs=false:
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
*/