language
stringlengths 0
24
| filename
stringlengths 9
214
| code
stringlengths 99
9.93M
|
---|---|---|
C | wireshark/ui/preference_utils.c | /* preference_utils.c
* Routines for handling preferences
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <errno.h>
#include <epan/column.h>
#include <wsutil/filesystem.h>
#include <wsutil/wslog.h>
#include <epan/prefs.h>
#include <epan/prefs-int.h>
#include <epan/packet.h>
#include <epan/decode_as.h>
#include <epan/uat-int.h>
#include <ui/recent.h>
#ifdef HAVE_LIBPCAP
#include "capture_opts.h"
#include "ui/capture_globals.h"
#endif
#include "ui/preference_utils.h"
#include "ui/simple_dialog.h"
/* Fill in capture options with values from the preferences */
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. */
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;
global_capture_opts.real_time_mode = prefs.capture_real_time;
global_capture_opts.update_interval = prefs.capture_update_interval;
#endif /* HAVE_LIBPCAP */
}
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 preferences 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);
}
/* Write recent and recent_common files out to ensure sync with prefs. */
write_profile_recent();
write_recent();
}
}
static unsigned int
prefs_store_ext_helper(const char * module_name, const char *pref_name, const char *pref_value)
{
module_t * module = NULL;
pref_t * pref = NULL;
unsigned int pref_changed = 0;
if ( !prefs_is_registered_protocol(module_name))
return 0;
module = prefs_find_module(module_name);
if ( !module )
return 0;
pref = prefs_find_preference(module, pref_name);
if (!pref)
return 0;
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);
} else if (prefs_get_type(pref) == PREF_PASSWORD )
{
pref_changed |= prefs_set_password_value(pref, pref_value, pref_stashed);
if ( !pref_changed || prefs_get_password_value(pref, pref_stashed) != 0 )
pref_changed |= prefs_set_password_value(pref, pref_value, pref_current);
}
return pref_changed;
}
unsigned int
prefs_store_ext(const char * module_name, const char *pref_name, const char *pref_value)
{
unsigned int changed_flags = prefs_store_ext_helper(module_name, pref_name, pref_value);
if ( changed_flags )
{
prefs_main_write();
prefs_apply_all();
prefs_to_capture_opts();
return changed_flags;
}
return 0;
}
gboolean
prefs_store_ext_multiple(const char * module, GHashTable * pref_values)
{
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;
for ( GList * key = keys; key != NULL; key = g_list_next(key) )
{
gchar * pref_name = (gchar *)key->data;
gchar * pref_value = (gchar *) g_hash_table_lookup(pref_values, key->data);
if ( pref_name && pref_value )
{
if ( prefs_store_ext_helper(module, pref_name, pref_value) )
pref_changed = TRUE;
}
}
g_list_free(keys);
if ( pref_changed )
{
prefs_main_write();
prefs_apply_all();
prefs_to_capture_opts();
}
return TRUE;
}
gint
column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_fields, gint position)
{
GList *clp;
fmt_data *cfmt, *last_cfmt;
gint colnr;
cfmt = g_new(fmt_data, 1);
/*
* Because a single underscore is interpreted as a signal that the next character
* is going to be marked as accelerator for this header (i.e. is going to be
* shown underlined), escape it be inserting a second consecutive underscore.
*/
cfmt->title = g_strdup(title);
cfmt->fmt = fmt;
cfmt->custom_fields = g_strdup(custom_fields);
cfmt->custom_occurrence = 0;
cfmt->resolved = TRUE;
colnr = g_list_length(prefs.col_list);
if (custom_fields) {
cfmt->visible = TRUE;
clp = g_list_last(prefs.col_list);
last_cfmt = (fmt_data *) clp->data;
if (position > 0 && position <= colnr) {
/* Custom fields may be added at any position, depending on the given argument */
prefs.col_list = g_list_insert(prefs.col_list, cfmt, position);
} else if (last_cfmt->fmt == COL_INFO) {
/* Last column is COL_INFO, add custom column before this */
colnr -= 1;
prefs.col_list = g_list_insert(prefs.col_list, cfmt, colnr);
} else {
prefs.col_list = g_list_append(prefs.col_list, cfmt);
}
} else {
cfmt->visible = FALSE; /* Will be set to TRUE in visible_toggled() when added to list */
prefs.col_list = g_list_append(prefs.col_list, cfmt);
}
return colnr;
}
gint
column_prefs_has_custom(const gchar *custom_field)
{
GList *clp;
fmt_data *cfmt;
gint colnr = -1;
for (gint i = 0; i < prefs.num_cols; i++) {
clp = g_list_nth(prefs.col_list, i);
if (clp == NULL) /* Sanity check, invalid column requested */
continue;
cfmt = (fmt_data *) clp->data;
if (cfmt->fmt == COL_CUSTOM && cfmt->custom_occurrence == 0 && strcmp(custom_field, cfmt->custom_fields) == 0) {
colnr = i;
break;
}
}
return colnr;
}
gboolean
column_prefs_custom_resolve(const gchar* custom_field)
{
gchar **fields;
header_field_info *hfi;
bool resolve = false;
fields = g_regex_split_simple(COL_CUSTOM_PRIME_REGEX, custom_field,
(GRegexCompileFlags) (G_REGEX_ANCHORED | G_REGEX_RAW),
G_REGEX_MATCH_ANCHORED);
for (guint i = 0; i < g_strv_length(fields); i++) {
if (fields[i] && *fields[i]) {
hfi = proto_registrar_get_byname(fields[i]);
if (hfi && ((hfi->type == FT_OID) || (hfi->type == FT_REL_OID) || (hfi->type == FT_ETHER) || (hfi->type == FT_IPv4) || (hfi->type == FT_IPv6) || (hfi->type == FT_FCWWN) || (hfi->type == FT_BOOLEAN) ||
((hfi->strings != NULL) &&
(FT_IS_INT(hfi->type) || FT_IS_UINT(hfi->type)))))
{
resolve = TRUE;
break;
}
}
}
g_strfreev(fields);
return resolve;
}
void
column_prefs_remove_link(GList *col_link)
{
fmt_data *cfmt;
if (!col_link || !col_link->data) return;
cfmt = (fmt_data *) col_link->data;
g_free(cfmt->title);
g_free(cfmt->custom_fields);
g_free(cfmt);
prefs.col_list = g_list_remove_link(prefs.col_list, col_link);
g_list_free_1(col_link);
}
void
column_prefs_remove_nth(gint col)
{
column_prefs_remove_link(g_list_nth(prefs.col_list, col));
}
void save_migrated_uat(const char *uat_name, gboolean *old_pref)
{
char *err = NULL;
if (!uat_save(uat_get_table_by_name(uat_name), &err)) {
ws_warning("Unable to save %s: %s", uat_name, err);
g_free(err);
return;
}
// Ensure that any old preferences are removed after successful migration.
if (*old_pref) {
*old_pref = FALSE;
prefs_main_write();
}
} |
C/C++ | wireshark/ui/preference_utils.h | /** @file
*
* Routines for handling preferences
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PREFRENCE_UTILS_H__
#define __PREFRENCE_UTILS_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @file
* Preference utility routines.
* @ingroup prefs_group
*/
/** If autoscroll in live captures is active or not
*/
extern gboolean auto_scroll_live;
/** Fill in capture options with values from the preferences
*/
extern void prefs_to_capture_opts(void);
/** Save all preferences
*/
extern void prefs_main_write(void);
/** Convenient function for plugin_if
*
* Note: The preferences must exist, it is not possible to create entries
* using this function
*
* @param module the module for the preference
* @param key the key for the preference
* @param value the new value as string for the preference
*
* @return flags of types of preferences changed, non-zero if the value has been stored successfully
*/
extern unsigned int prefs_store_ext(const char * module, const char * key, const char * value);
/** Convenient function for the writing of multiple preferences, without
* explicitly having prefs_t variables.
*
* Note: The preferences must exist, it is not possible to create entries
* using this function
*
* @param module the module for the preference
* @param pref_values a hash table
*
* @return true if the value has been stored successfully
*/
extern gboolean prefs_store_ext_multiple(const char * module, GHashTable * pref_values);
/** Add a custom column.
*
* @param fmt column format
* @param title column title
* @param custom_field column custom field
* @param position the intended position of the insert
*
* @return The index of the inserted column
*/
gint column_prefs_add_custom(gint fmt, const gchar *title,
const gchar *custom_field,
gint position);
/** Check if a custom column exists.
*
* @param custom_field column custom field
*
* @return The index of the column if existing, -1 if not existing
*/
gint column_prefs_has_custom(const gchar *custom_field);
/** Check if a custom column's data can be displayed differently
* resolved or unresolved, e.g. it has a field with a value string.
*
* This is for when adding or editing custom columns. Compare with
* resolve_column() in packet_list_utils.h, which is for columns
* that have already been added.
*
* @param custom_field column custom field
*
* @return TRUE if a custom column with the field description
* would support being displayed differently resolved or unresolved,
* FALSE otherwise.
*/
gboolean column_prefs_custom_resolve(const gchar *custom_field);
/** Remove a column.
*
* @param col_link Column list entry
*/
void column_prefs_remove_link(GList* col_link);
/** Remove a column.
*
* @param col Column number
*/
void column_prefs_remove_nth(gint col);
/** Save the UAT and complete migration of old preferences by writing the main
* preferences file (if necessary).
*/
void save_migrated_uat(const char *uat_name, gboolean *old_pref);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PREFRENCE_UTILS_H__ */ |
C | wireshark/ui/profile.c | /* profile.c
* Dialog box for profiles editing
* Stig Bjorlykke <[email protected]>, 2008
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <string.h>
#include <errno.h>
#include <glib.h>
#include <wsutil/filesystem.h>
#include "profile.h"
#include "ui/simple_dialog.h"
#include "ui/recent.h"
#include <wsutil/file_util.h>
#include <wsutil/ws_assert.h>
static GList *current_profiles = NULL;
static GList *edited_profiles = NULL;
#define PROF_OPERATION_NEW 1
#define PROF_OPERATION_EDIT 2
GList * current_profile_list(void) {
return g_list_first(current_profiles);
}
GList * edited_profile_list(void) {
return g_list_first(edited_profiles);
}
static GList *
add_profile_entry(GList *fl, const char *profilename, const char *reference, int status,
gboolean is_global, gboolean from_global, gboolean is_import)
{
profile_def *profile;
profile = g_new0(profile_def, 1);
profile->name = g_strdup(profilename);
profile->reference = g_strdup(reference);
profile->status = status;
profile->is_global = is_global;
profile->from_global = from_global;
profile->is_import = is_import;
return g_list_append(fl, profile);
}
static GList *
remove_profile_entry(GList *fl, GList *fl_entry)
{
GList *list;
profile_def *profile;
profile = (profile_def *) fl_entry->data;
g_free(profile->name);
g_free(profile->reference);
g_free(profile);
list = g_list_remove_link(fl, fl_entry);
g_list_free_1(fl_entry);
return list;
}
const gchar *
get_profile_parent (const gchar *profilename)
{
GList *fl_entry = g_list_first(edited_profiles);
guint no_edited = g_list_length(edited_profiles);
profile_def *profile;
guint i;
if (fl_entry) {
/* We have edited profiles, find parent */
for (i = 0; i < no_edited; i++) {
while (fl_entry) {
profile = (profile_def *) fl_entry->data;
if (strcmp (profile->name, profilename) == 0) {
if ((profile->status == PROF_STAT_NEW) ||
(profile->reference == NULL)) {
/* Copy from a new profile */
return NULL;
} else {
/* Found a parent, use this */
profilename = profile->reference;
}
}
fl_entry = g_list_next(fl_entry);
}
fl_entry = g_list_first(edited_profiles);
}
}
return profilename;
}
gchar *apply_profile_changes(void)
{
char *pf_dir_path, *pf_dir_path2, *pf_filename;
GList *fl1, *fl2;
profile_def *profile1, *profile2;
gboolean found;
gchar *err_msg;
/* First validate all profile names */
fl1 = edited_profile_list();
while (fl1) {
profile1 = (profile_def *) fl1->data;
g_strstrip(profile1->name);
if ((err_msg = profile_name_is_valid(profile1->name)) != NULL) {
gchar *message = ws_strdup_printf("%s\nProfiles unchanged.", err_msg);
g_free(err_msg);
return message;
}
fl1 = g_list_next(fl1);
}
/* Write recent file for current profile before copying or renaming */
write_profile_recent();
/* Then do all copy profiles */
fl1 = edited_profile_list();
while (fl1) {
profile1 = (profile_def *) fl1->data;
g_strstrip(profile1->name);
if (profile1->status == PROF_STAT_COPY) {
if (create_persconffile_profile(profile1->name, &pf_dir_path) == -1) {
err_msg = ws_strdup_printf("Can't create directory\n\"%s\":\n%s.",
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
return err_msg;
}
profile1->status = PROF_STAT_EXISTS;
if (profile1->reference) {
if (copy_persconffile_profile(profile1->name, profile1->reference, profile1->from_global,
&pf_filename, &pf_dir_path, &pf_dir_path2) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.",
pf_filename, pf_dir_path2, pf_dir_path, g_strerror(errno));
g_free(pf_filename);
g_free(pf_dir_path);
g_free(pf_dir_path2);
}
}
g_free (profile1->reference);
profile1->reference = g_strdup(profile1->name);
}
fl1 = g_list_next(fl1);
}
/* Then create new and rename changed */
fl1 = edited_profile_list();
while (fl1) {
profile1 = (profile_def *) fl1->data;
g_strstrip(profile1->name);
if (profile1->status == PROF_STAT_NEW) {
/* We do not create a directory for the default profile */
if (strcmp(profile1->name, DEFAULT_PROFILE)!=0 && ! profile1->is_import) {
if (create_persconffile_profile(profile1->name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\":\n%s.",
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
}
profile1->status = PROF_STAT_EXISTS;
g_free (profile1->reference);
profile1->reference = g_strdup(profile1->name);
/* correctly apply imports as existing profiles */
} else if (profile1->is_import) {
profile1->status = PROF_STAT_EXISTS;
g_free (profile1->reference);
profile1->reference = g_strdup(profile1->name);
profile1->is_import = FALSE;
}
} else if (profile1->status == PROF_STAT_CHANGED) {
if (strcmp(profile1->reference, profile1->name)!=0) {
/* Rename old profile directory to new */
if (rename_persconffile_profile(profile1->reference, profile1->name,
&pf_dir_path, &pf_dir_path2) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't rename directory\n\"%s\" to\n\"%s\":\n%s.",
pf_dir_path, pf_dir_path2, g_strerror(errno));
g_free(pf_dir_path);
g_free(pf_dir_path2);
}
profile1->status = PROF_STAT_EXISTS;
}
}
fl1 = g_list_next(fl1);
}
/* Last remove deleted */
fl1 = current_profile_list();
while (fl1) {
found = FALSE;
profile1 = (profile_def *) fl1->data;
fl2 = edited_profile_list();
while (fl2) {
profile2 = (profile_def *) fl2->data;
if (!profile2->is_global) {
if (strcmp(profile1->name, profile2->name)==0) {
/* Profile exists in both lists */
found = TRUE;
} else if (strcmp(profile1->name, profile2->reference)==0) {
/* Profile has been renamed, update reference to the new name */
g_free (profile2->reference);
profile2->reference = g_strdup(profile2->name);
found = TRUE;
}
}
fl2 = g_list_next(fl2);
}
if (!found) {
/* Exists in existing list and not in edited, this is a deleted profile */
if (delete_persconffile_profile(profile1->name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't delete profile directory\n\"%s\":\n%s.",
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
}
}
fl1 = g_list_next(fl1);
}
copy_profile_list();
return NULL;
}
GList *
add_to_profile_list(const char *name, const char *expression, int status,
gboolean is_global, gboolean from_global, gboolean is_imported)
{
edited_profiles = add_profile_entry(edited_profiles, name, expression, status,
is_global, from_global, is_imported);
return g_list_last(edited_profiles);
}
void
remove_from_profile_list(GList *fl_entry)
{
edited_profiles = remove_profile_entry(edited_profiles, fl_entry);
}
void
empty_profile_list(gboolean edit_list)
{
GList **flpp;
if (edit_list) {
flpp = &edited_profiles;
while(*flpp) {
*flpp = remove_profile_entry(*flpp, g_list_first(*flpp));
}
ws_assert(g_list_length(*flpp) == 0);
if ( ! edited_profiles )
edited_profiles = NULL;
}
flpp = ¤t_profiles;
while(*flpp) {
*flpp = remove_profile_entry(*flpp, g_list_first(*flpp));
}
ws_assert(g_list_length(*flpp) == 0);
if ( ! current_profiles )
current_profiles = NULL;
}
void
copy_profile_list(void)
{
GList *flp_src;
profile_def *profile;
flp_src = edited_profiles;
/* throw away the "old" destination list - a NULL list is ok here */
empty_profile_list(FALSE);
/* copy the list entries */
while(flp_src) {
profile = (profile_def *)(flp_src)->data;
current_profiles = add_profile_entry(current_profiles, profile->name,
profile->reference, profile->status,
profile->is_global, profile->from_global, FALSE);
flp_src = g_list_next(flp_src);
}
}
void
init_profile_list(void)
{
WS_DIR *dir; /* scanned directory */
WS_DIRENT *file; /* current file */
const gchar *name;
GList *local_profiles = NULL;
GList *global_profiles = NULL;
GList *iter;
gchar *profiles_dir, *filename;
empty_profile_list(TRUE);
/* Default entry */
add_to_profile_list(DEFAULT_PROFILE, DEFAULT_PROFILE, PROF_STAT_DEFAULT, FALSE, FALSE, FALSE);
/* Local (user) profiles */
profiles_dir = get_profiles_dir();
if ((dir = ws_dir_open(profiles_dir, 0, NULL)) != NULL) {
while ((file = ws_dir_read_name(dir)) != NULL) {
name = ws_dir_get_name(file);
filename = ws_strdup_printf ("%s%s%s", profiles_dir, G_DIR_SEPARATOR_S, name);
if (test_for_directory(filename) == EISDIR) {
local_profiles = g_list_prepend(local_profiles, g_strdup(name));
}
g_free (filename);
}
ws_dir_close (dir);
}
g_free(profiles_dir);
local_profiles = g_list_sort(local_profiles, (GCompareFunc)g_ascii_strcasecmp);
for (iter = g_list_first(local_profiles); iter; iter = g_list_next(iter)) {
name = (gchar *)iter->data;
add_to_profile_list(name, name, PROF_STAT_EXISTS, FALSE, FALSE, FALSE);
}
g_list_free_full(local_profiles, g_free);
/* Global profiles */
profiles_dir = get_global_profiles_dir();
if ((dir = ws_dir_open(profiles_dir, 0, NULL)) != NULL) {
while ((file = ws_dir_read_name(dir)) != NULL) {
name = ws_dir_get_name(file);
filename = ws_strdup_printf ("%s%s%s", profiles_dir, G_DIR_SEPARATOR_S, name);
if (test_for_directory(filename) == EISDIR) {
global_profiles = g_list_prepend(global_profiles, g_strdup(name));
}
g_free (filename);
}
ws_dir_close (dir);
}
g_free(profiles_dir);
global_profiles = g_list_sort(global_profiles, (GCompareFunc)g_ascii_strcasecmp);
for (iter = g_list_first(global_profiles); iter; iter = g_list_next(iter)) {
name = (gchar *)iter->data;
add_to_profile_list(name, name, PROF_STAT_EXISTS, TRUE, TRUE, FALSE);
}
g_list_free_full(global_profiles, g_free);
/* Make the current list and the edited list equal */
copy_profile_list ();
}
gchar *
profile_name_is_valid(const gchar *name)
{
gchar *reason = NULL;
gchar *message;
#ifdef _WIN32
char *invalid_dir_char = "\\/:*?\"<>|";
gboolean invalid = FALSE;
int i;
for (i = 0; i < 9; i++) {
if (strchr(name, invalid_dir_char[i])) {
/* Invalid character in directory */
invalid = TRUE;
}
}
if (name[0] == '.' || name[strlen(name)-1] == '.') {
/* Profile name cannot start or end with period */
invalid = TRUE;
}
if (invalid) {
reason = ws_strdup_printf("start or end with period (.), or contain any of the following characters:\n"
" \\ / : * ? \" < > |");
}
#else
if (strchr(name, '/')) {
/* Invalid character in directory */
reason = ws_strdup_printf("contain the '/' character.");
}
#endif
if (reason) {
message = ws_strdup_printf("A profile name cannot %s", reason);
g_free(reason);
return message;
}
return NULL;
}
gboolean delete_current_profile(void) {
const gchar *name = get_profile_name();
char *pf_dir_path;
if (profile_exists(name, FALSE) && strcmp (name, DEFAULT_PROFILE) != 0) {
if (delete_persconffile_profile(name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't delete profile directory\n\"%s\":\n%s.",
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
} else {
return TRUE;
}
}
return FALSE;
} |
C/C++ | wireshark/ui/profile.h | /** @file
*
* Definitions for dialog box for profiles editing.
* Stig Bjorlykke <[email protected]>, 2008
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PROFILE_H__
#define __PROFILE_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @file
* "Configuration Profiles" dialog box
* @ingroup dialog_group
*/
#define PROF_STAT_DEFAULT 1
#define PROF_STAT_EXISTS 2
#define PROF_STAT_NEW 3
#define PROF_STAT_CHANGED 4
#define PROF_STAT_COPY 5
#define PROF_STAT_IMPORT 6
typedef struct {
char *name; /* profile name */
char *reference; /* profile reference */
int status;
gboolean is_global;
gboolean from_global;
gboolean is_import;
} profile_def;
/** @file
* "Configuration Profiles" utility routines
* @ingroup utility_group
*/
/** Initialize the profile list. Can be called more than once.
*/
void init_profile_list(void);
/** User requested the "Configuration Profiles" popup menu.
*
* @param name Profile name
* @param parent Parent profile name
* @param status Current status
* @param is_global Profile is in the global configuration directory
* @param from_global Profile is copied from the global configuration directory
* @param is_import Profile has been imported and no directory has to be created
*
* @return A pointer to the new profile list
*/
GList *add_to_profile_list(const char *name, const char *parent, int status,
gboolean is_global, gboolean from_global, gboolean is_import);
/** Refresh the current (non-edited) profile list.
*/
void copy_profile_list(void);
/** Clear out the profile list
*
* @param edit_list Remove edited entries
*/
void empty_profile_list(gboolean edit_list);
/** Remove an entry from the profile list.
*
* @param fl_entry Profile list entry
*/
void remove_from_profile_list(GList *fl_entry);
/** Current profile list
*
* @return The head of the current profile list
*/
GList *current_profile_list(void);
/** Edited profile list
*
* @return The head of the edited profile list
*/
GList * edited_profile_list(void);
/** Apply the changes in the edited profile list
* @return NULL if the operation was successful or an error message otherwise.
* The error message must be freed by the caller.
*/
gchar *apply_profile_changes(void);
/** Given a profile name, return the name of its parent profile.
*
* @param profilename Child profile name
*
* @return Parent profile name
*/
const gchar *get_profile_parent (const gchar *profilename);
/** Check the validity of a profile name.
*
* @param name Profile name
* @return NULL if the name is valid or an error message otherwise.
*/
gchar *profile_name_is_valid(const gchar *name);
/** Remove the current profile.
*
* @return TRUE if the current profile exists and was successfully deleted
* or FALSE otherwise.
*/
gboolean delete_current_profile(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PROFILE_H__ */ |
C/C++ | wireshark/ui/progress_dlg.h | /** @file
*
* Definitions for progress dialog box routines
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PROGRESS_DLG_H__
#define __PROGRESS_DLG_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @file
* Progress (modal) dialog box routines.
* @ingroup dialog_group
*/
/** Progress dialog data. */
struct progdlg;
/** Progress dialog data. */
typedef struct progdlg progdlg_t;
/**
* Create and pop up the progress dialog. Allocates a "progdlg_t"
* and initialize it to contain all information the implementation
* needs in order to manipulate the dialog, and return a pointer to
* it.
*
* @param top_level_window UI widget to associate with the progress dialog, e.g.
* the main window.
* @param task_title The task to do, e.g. "Loading"
* @param item_title The item to do, e.g. "capture.cap"
* @param terminate_is_stop TRUE if the operation can't be cancelled, just
* stopped (i.e., it has a "Stop" button and clicking it doesn't undo
* anything already done), FALSE if it can
* @param stop_flag A pointer to a Boolean variable that will be
* set to TRUE if the user hits that button
* @return The newly created progress dialog
*/
progdlg_t *create_progress_dlg(gpointer top_level_window, const gchar *task_title, const gchar *item_title,
gboolean terminate_is_stop, gboolean *stop_flag);
/**
* Create a progress dialog, but only if it's not likely to disappear
* immediately. This can be disconcerting for the user.
*
* @param top_level_window The top-level window associated with the progress update.
* May be NULL.
* @param task_title The task to do, e.g. "Loading"
* @param item_title The item to do, e.g. "capture.cap"
* @param terminate_is_stop TRUE if the operation can't be cancelled, just
* stopped (i.e., it has a "Stop" button and clicking it doesn't undo
* anything already done), FALSE if it can
* @param stop_flag A pointer to a Boolean variable that will be
* set to TRUE if the user hits that button
* @param progress The current progress (0..1)
* @return The newly created progress dialog
*/
progdlg_t *delayed_create_progress_dlg(gpointer top_level_window, const gchar *task_title, const gchar *item_title,
gboolean terminate_is_stop, gboolean *stop_flag, gfloat progress);
/**
* Update the progress information of the progress dialog box.
*
* @param dlg The progress dialog from create_progress_dlg()
* @param percentage The current percentage value (0..1)
* @param status the New status string to show, e.g. "3000KB of 6000KB"
*/
void update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status);
/**
* Destroy or hide the progress bar.
*
* @param dlg The progress dialog from create_progress_dlg()
*/
void destroy_progress_dlg(progdlg_t *dlg);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PROGRESS_DLG_H__ */ |
C | wireshark/ui/proto_hier_stats.c | /* proto_hier_stats.c
* Routines for calculating statistics based on protocol.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <string.h>
#include "file.h"
#include "frame_tvbuff.h"
#include "ui/proto_hier_stats.h"
#include "ui/progress_dlg.h"
#include "epan/epan_dissect.h"
#include "epan/proto.h"
#include <wsutil/ws_assert.h>
/* Update the progress bar this many times when scanning the packet list. */
#define N_PROGBAR_UPDATES 100
#define STAT_NODE_STATS(n) ((ph_stats_node_t*)(n)->data)
#define STAT_NODE_HFINFO(n) (STAT_NODE_STATS(n)->hfinfo)
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_pdus_total = 0;
stats->num_pkts_last = 0;
stats->num_bytes_total = 0;
stats->num_bytes_last = 0;
stats->last_pkt = 0;
needle_stat_node = g_node_new(stats);
g_node_append(parent_stat_node, needle_stat_node);
return needle_stat_node;
}
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.
* Even with a faked proto tree, we don't fake nodes when PTREE_FINFO(tree)
* is NULL in order to avoid crashes here and elsewhere. (See epan/proto.c)
*/
ws_assert(finfo);
stat_node = find_stat_node(parent_stat_node, finfo->hfinfo);
stats = STAT_NODE_STATS(stat_node);
/* Only increment the total packet count once per packet for a given
* node, since there could be multiple PDUs in a frame.
* (All the other statistics should be incremented every time,
* including the count for how often a protocol was the last
* protocol in a packet.)
*/
if (stats->last_pkt != ps->tot_packets) {
stats->num_pkts_total++;
stats->last_pkt = ps->tot_packets;
}
stats->num_pdus_total++;
stats->num_bytes_total += finfo->length + finfo->appendix_length;
proto_sibling_node = ptree_node->next;
/* Skip entries that are not protocols, e.g.
* toplevel tree item of desegmentation "[Reassembled TCP Segments]")
* XXX: We should probably skip PINOs with field_type FT_BYTES too.
*
* XXX: We look at siblings not children, and thus don't descend into
* the tree to pick up embedded protocols not added to the toplevel of
* the tree.
*/
while (proto_sibling_node && !proto_registrar_is_protocol(PNODE_FINFO(proto_sibling_node)->hfinfo->id)) {
proto_sibling_node = proto_sibling_node->next;
}
if (proto_sibling_node) {
process_node(proto_sibling_node, stat_node, ps);
} else {
stats->num_pkts_last++;
stats->num_bytes_last += finfo->length + finfo->appendix_length;
}
}
static void
process_tree(proto_tree *protocol_tree, ph_stats_t* ps)
{
proto_node *ptree_node;
/*
* Skip over non-protocols and comments. (Packet comments are a PINO
* with FT_PROTOCOL field type). This keeps us from having a top-level
* "Packet comments" item that steals items from "Frame".
*/
ptree_node = ((proto_node *)protocol_tree)->first_child;
while (ptree_node && (ptree_node->finfo->hfinfo->id == pc_proto_id || !proto_registrar_is_protocol(ptree_node->finfo->hfinfo->id))) {
ptree_node = ptree_node->next;
}
if (!ptree_node) {
return;
}
process_node(ptree_node, ps->stats_tree, ps);
}
static gboolean
process_record(capture_file *cf, frame_data *frame, column_info *cinfo,
wtap_rec *rec, Buffer *buf, ph_stats_t* ps)
{
epan_dissect_t edt;
double cur_time;
/* Load the record from the capture file */
if (!cf_read_record(cf, frame, rec, 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, rec,
frame_tvbuff_new_buffer(&cf->provider, frame, buf),
frame, cinfo);
/* Get stats from this protocol tree */
process_tree(edt.tree, ps);
if (frame->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);
return TRUE; /* success */
}
ph_stats_t*
ph_stats_new(capture_file *cf)
{
ph_stats_t *ps;
guint32 framenum;
frame_data *frame;
progdlg_t *progbar = NULL;
int count;
wtap_rec rec;
Buffer buf;
float progbar_val;
gchar status_str[100];
int progbar_nextstep;
int progbar_quantum;
if (!cf) return NULL;
if (cf->read_lock) {
ws_warning("Failing to compute protocol hierarchy stats on \"%s\" since a read is in progress", cf->filename);
return NULL;
}
cf->read_lock = TRUE;
cf->stop_flag = FALSE;
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;
wtap_rec_init(&rec);
ws_buffer_init(&buf, 1514);
for (framenum = 1; framenum <= cf->count; framenum++) {
frame = frame_data_sequence_find(cf->provider.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, &cf->stop_flag, 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
*/
ws_assert(cf->count > 0);
progbar_val = (gfloat) count / cf->count;
if (progbar != NULL) {
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 (cf->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->passed_dfilter) {
if (frame->has_ts) {
if (ps->tot_packets == 0) {
double cur_time = nstime_to_sec(&frame->abs_ts);
ps->first_time = cur_time;
ps->last_time = cur_time;
}
}
/* We throw away the statistics if we quit in the middle,
* so increment this first so that the count starts at 1
* when processing records, since we initialize the stat
* nodes' last_pkt to 0.
*/
ps->tot_packets++;
/* we don't care about colinfo */
if (!process_record(cf, frame, NULL, &rec, &buf, ps)) {
/*
* Give up, and set "stop_flag" so we
* just abort rather than popping up
* the statistics window.
*/
cf->stop_flag = TRUE;
break;
}
ps->tot_bytes += frame->pkt_len;
}
count++;
}
wtap_rec_cleanup(&rec);
ws_buffer_free(&buf);
/* We're done calculating the statistics; destroy the progress bar
if it was created. */
if (progbar != NULL)
destroy_progress_dlg(progbar);
if (cf->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);
ps = NULL;
}
ws_assert(cf->read_lock);
cf->read_lock = FALSE;
return ps;
}
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;
}
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);
} |
C/C++ | wireshark/ui/proto_hier_stats.h | /** @file
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __UI_PROTO_HIER_STATS_H__
#define __UI_PROTO_HIER_STATS_H__
#include <epan/proto.h>
#include "cfile.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @file
* Protocol Hierarchy Statistics
*/
typedef struct {
header_field_info *hfinfo;
guint num_pkts_total;
guint num_pdus_total;
guint num_pkts_last;
guint num_bytes_total;
guint num_bytes_last;
guint last_pkt;
} 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 */
} ph_stats_t;
ph_stats_t *ph_stats_new(capture_file *cf);
void ph_stats_free(ph_stats_t *ps);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __UI_PROTO_HIER_STATS_H__ */ |
C | wireshark/ui/recent.c | /* recent.c
* Recent "preference" handling routines
* Copyright 2004, Ulf Lamping <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <wireshark.h>
#include <stdlib.h>
#include <errno.h>
#ifdef HAVE_PCAP_REMOTE
#include <capture_opts.h>
#endif
#include <wsutil/filesystem.h>
#include <epan/prefs.h>
#include <epan/prefs-int.h>
#include <epan/column.h>
#include <epan/value_string.h>
#include "ui/last_open_dir.h"
#include "ui/recent.h"
#include "ui/recent_utils.h"
#include "ui/packet_list_utils.h"
#include "ui/simple_dialog.h"
#include <wsutil/file_util.h>
#define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show"
#define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show"
#define RECENT_KEY_WIRELESS_TOOLBAR_SHOW "gui.wireless_toolbar_show"
#define RECENT_KEY_PACKET_LIST_SHOW "gui.packet_list_show"
#define RECENT_KEY_TREE_VIEW_SHOW "gui.tree_view_show"
#define RECENT_KEY_BYTE_VIEW_SHOW "gui.byte_view_show"
#define RECENT_KEY_PACKET_DIAGRAM_SHOW "gui.packet_diagram_show"
#define RECENT_KEY_STATUSBAR_SHOW "gui.statusbar_show"
#define RECENT_KEY_PACKET_LIST_COLORIZE "gui.packet_list_colorize"
#define RECENT_KEY_CAPTURE_AUTO_SCROLL "capture.auto_scroll"
#define RECENT_GUI_TIME_FORMAT "gui.time_format"
#define RECENT_GUI_TIME_PRECISION "gui.time_precision"
#define RECENT_GUI_SECONDS_FORMAT "gui.seconds_format"
#define RECENT_GUI_ZOOM_LEVEL "gui.zoom_level"
#define RECENT_GUI_BYTES_VIEW "gui.bytes_view"
#define RECENT_GUI_BYTES_ENCODING "gui.bytes_encoding"
#define RECENT_GUI_ALLOW_HOVER_SELECTION "gui.allow_hover_selection"
#define RECENT_GUI_PACKET_DIAGRAM_FIELD_VALUES "gui.packet_diagram_field_values"
#define RECENT_GUI_GEOMETRY_MAIN_X "gui.geometry_main_x"
#define RECENT_GUI_GEOMETRY_MAIN_Y "gui.geometry_main_y"
#define RECENT_GUI_GEOMETRY_MAIN_WIDTH "gui.geometry_main_width"
#define RECENT_GUI_GEOMETRY_MAIN_HEIGHT "gui.geometry_main_height"
#define RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED "gui.geometry_main_maximized"
#define RECENT_GUI_GEOMETRY_LEFTALIGN_ACTIONS "gui.geometry_leftalign_actions"
#define RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE "gui.geometry_main_upper_pane"
#define RECENT_GUI_GEOMETRY_MAIN_LOWER_PANE "gui.geometry_main_lower_pane"
#define RECENT_GUI_GEOMETRY_WLAN_STATS_PANE "gui.geometry_status_wlan_stats_pane"
#define RECENT_LAST_USED_PROFILE "gui.last_used_profile"
#define RECENT_GUI_FILEOPEN_REMEMBERED_DIR "gui.fileopen_remembered_dir"
#define RECENT_GUI_CONVERSATION_TABS "gui.conversation_tabs"
#define RECENT_GUI_CONVERSATION_TABS_COLUMNS "gui.conversation_tabs_columns"
#define RECENT_GUI_ENDPOINT_TABS "gui.endpoint_tabs"
#define RECENT_GUI_ENDPOINT_TABS_COLUMNS "gui.endpoint_tabs_columns"
#define RECENT_GUI_RLC_PDUS_FROM_MAC_FRAMES "gui.rlc_pdus_from_mac_frames"
#define RECENT_GUI_CUSTOM_COLORS "gui.custom_colors"
#define RECENT_GUI_TOOLBAR_SHOW "gui.additional_toolbar_show"
#define RECENT_GUI_INTERFACE_TOOLBAR_SHOW "gui.interface_toolbar_show"
#define RECENT_GUI_SEARCH_IN "gui.search_in"
#define RECENT_GUI_SEARCH_CHAR_SET "gui.search_char_set"
#define RECENT_GUI_SEARCH_CASE_SENSITIVE "gui.search_case_sensitive"
#define RECENT_GUI_SEARCH_TYPE "gui.search_type"
#define RECENT_GUI_FOLLOW_SHOW "gui.follow_show"
#define RECENT_GUI_GEOMETRY "gui.geom."
#define RECENT_KEY_PRIVS_WARN_IF_ELEVATED "privs.warn_if_elevated"
#define RECENT_KEY_SYS_WARN_IF_NO_CAPTURE "sys.warn_if_no_capture"
#define RECENT_FILE_NAME "recent"
#define RECENT_COMMON_FILE_NAME "recent_common"
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 }
};
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 }
};
static const value_string ts_seconds_values[] = {
{ TS_SECONDS_DEFAULT, "SECONDS" },
{ TS_SECONDS_HOUR_MIN_SEC, "HOUR_MIN_SEC" },
{ 0, NULL }
};
static const value_string bytes_view_type_values[] = {
{ BYTES_HEX, "HEX" },
{ BYTES_BITS, "BITS" },
{ BYTES_DEC, "DEC" },
{ BYTES_OCT, "OCT" },
{ 0, NULL }
};
static const value_string bytes_encoding_type_values[] = {
{ BYTES_ENC_FROM_PACKET, "FROM_PACKET" },
{ BYTES_ENC_ASCII, "ASCII" },
{ BYTES_ENC_EBCDIC, "EBCDIC" },
{ 0, NULL }
};
static const value_string search_in_values[] = {
{ SEARCH_IN_PACKET_LIST, "PACKET_LIST" },
{ SEARCH_IN_PACKET_DETAILS, "PACKET_DETAILS" },
{ SEARCH_IN_PACKET_BYTES, "PACKET_BYTES" },
{ 0, NULL }
};
static const value_string search_char_set_values[] = {
{ SEARCH_CHAR_SET_NARROW_AND_WIDE, "NARROW_AND_WIDE" },
{ SEARCH_CHAR_SET_NARROW, "NARROW" },
{ SEARCH_CHAR_SET_WIDE, "WIDE" },
{ 0, NULL }
};
static const value_string search_type_values[] = {
{ SEARCH_TYPE_DISPLAY_FILTER, "DISPLAY_FILTER" },
{ SEARCH_TYPE_HEX_VALUE, "HEX_VALUE" },
{ SEARCH_TYPE_STRING, "STRING" },
{ SEARCH_TYPE_REGEX, "REGEX" },
{ 0, NULL }
};
static const value_string follow_show_values[] = {
{ SHOW_ASCII, "ASCII" },
{ SHOW_CARRAY, "C_ARRAYS" },
{ SHOW_EBCDIC, "EBCDIC" },
{ SHOW_HEXDUMP, "HEX_DUMP" },
{ SHOW_RAW, "RAW" },
{ SHOW_CODEC, "UTF-8" },
{ SHOW_YAML, "YAML"},
{ 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);
}
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;
}
/** Write the geometry values of a single window to the recent file.
*
* @param key unused
* @param value the geometry values
* @param rfh recent file handle (FILE)
*/
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");
}
/* the geometry hashtable for all known window classes,
* the window name is the key, and the geometry struct is the value */
static GHashTable *window_geom_hash = NULL;
/* save the window and its current geometry into the geometry hashtable */
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 = g_new(window_geometry_t, 1);
*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 */
gboolean
window_geom_load(const gchar *name,
window_geometry_t *geom)
{
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);
}
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 */
static void
parse_recent_boolean(const gchar *val_str, gboolean *valuep)
{
if (g_ascii_strcasecmp(val_str, "true") == 0) {
*valuep = TRUE;
}
else {
*valuep = FALSE;
}
}
/** Read in a single geometry key value pair from the recent file.
*
* @param name the geom_name of the window
* @param key the subkey of this pair (e.g. "x")
* @param value the new value (e.g. "123")
*/
static void
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;
}
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.
* Will call write_recent_geom() for every existing window type.
*
* @param rf recent file handle from caller
*/
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);
}
g_hash_table_foreach(window_geom_hash, write_recent_geom, rf);
}
/* Global list of recent capture filters. */
static GList *recent_cfilter_list;
/*
* Per-interface lists of recent capture filters; stored in a hash
* table indexed by interface name.
*/
static GHashTable *per_interface_cfilter_lists_hash;
/* XXX: use a preference for this setting! */
static guint cfilter_combo_max_recent = 20;
/**
* Returns a list of recent capture filters.
*
* @param ifname interface name; NULL refers to the global list.
*/
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);
}
/**
* Add a capture filter to the global recent capture filter list or
* the recent capture filter list for an interface.
*
* @param ifname interface name; NULL refers to the global list.
* @param s text of capture filter
*/
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;
}
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);
}
#ifdef HAVE_PCAP_REMOTE
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);
}
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);
}
static gboolean
free_remote_host (gpointer key _U_, gpointer value, gpointer user _U_)
{
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);
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);
}
}
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;
fprintf (rf, RECENT_KEY_REMOTE_HOST ": %s,%s,%d\n", ri->remote_host, ri->remote_port, ri->auth_type);
}
/**
* Write the contents of the remote_host_list to the 'recent' file.
*
* @param rf File to write to.
*/
static 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);
}
}
void recent_free_remote_host_list(void)
{
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);
}
/**
* Fill the remote_host_list with the entries stored in the 'recent' file.
*
* @param s String to be filled from the 'recent' file.
* @return True, if the list was written successfully, False otherwise.
*/
static 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 */
if (!strcmp((const char*)valp->data, "0")) {
/* Port 0 isn't valid, so leave port blank */
rh->remote_port = (gchar *)g_strdup ("");
} else {
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 ("");
}
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;
}
}
/* Do not store username and password */
rh->auth_username = g_strdup ("");
rh->auth_password = g_strdup ("");
prefs_clear_string_list(vals);
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);
}
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);
}
/** Write all capture filter values to the recent file.
*
* @param rf recent file handle from caller
*/
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 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. */
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");
}
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;
const gchar *str_value;
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");
str_value = try_val_to_str(value, values);
if (str_value != NULL)
fprintf(rf, "%s: %s\n", name, str_value);
else
fprintf(rf, "%s: %s\n", name, if_invalid != NULL ? if_invalid : "Unknown");
}
/* Attempt to write out "recent common" to the user's recent_common file.
If we got an error report it with a dialog box and return FALSE,
otherwise return TRUE. */
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));
g_free(rf_path);
return FALSE;
}
g_free(rf_path);
fprintf(rf, "# Common recent settings file for %s " VERSION ".\n"
"#\n"
"# This file is regenerated each time %s is quit\n"
"# and when changing configuration profile.\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",
get_configuration_namespace(), get_configuration_namespace());
menu_recent_file_write_all(rf);
fputs("\n"
"######## Recent capture filters (latest last), cannot be altered through command line ########\n"
"\n", rf);
cfilter_recent_write_all(rf);
fputs("\n"
"######## Recent display filters (latest last), cannot be altered through command line ########\n"
"\n", 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);
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_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);
write_recent_boolean(rf, "Leftalign Action Buttons",
RECENT_GUI_GEOMETRY_LEFTALIGN_ACTIONS,
recent.gui_geometry_leftalign_actions);
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 Wireshark is unable to capture",
RECENT_KEY_SYS_WARN_IF_NO_CAPTURE,
recent.sys_warn_if_no_capture);
write_recent_enum(rf, "Find packet search in", RECENT_GUI_SEARCH_IN, search_in_values,
recent.gui_search_in);
write_recent_enum(rf, "Find packet character set", RECENT_GUI_SEARCH_CHAR_SET, search_char_set_values,
recent.gui_search_char_set);
write_recent_boolean(rf, "Find packet case sensitive search",
RECENT_GUI_SEARCH_CASE_SENSITIVE,
recent.gui_search_case_sensitive);
write_recent_enum(rf, "Find packet search type", RECENT_GUI_SEARCH_TYPE, search_type_values,
recent.gui_search_type);
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;
}
/* Attempt to Write out profile "recent" to the user's profile recent file.
If we got an error report it with a dialog box and return FALSE,
otherwise return TRUE. */
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));
g_free(rf_path);
return FALSE;
}
g_free(rf_path);
fprintf(rf, "# Recent settings file for %s " VERSION ".\n"
"#\n"
"# This file is regenerated each time %s is quit\n"
"# and when changing configuration profile.\n"
"# So be careful, if you want to make manual changes here.\n"
"\n",
get_configuration_namespace(), get_configuration_namespace());
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, "Wireless Settings Toolbar show (hide)",
RECENT_KEY_WIRELESS_TOOLBAR_SHOW,
recent.wireless_toolbar_show);
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, "Packet diagram show (hide)",
RECENT_KEY_PACKET_DIAGRAM_SHOW,
recent.packet_diagram_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_boolean(rf, "Auto scroll packet list when capturing",
RECENT_KEY_CAPTURE_AUTO_SCROLL,
recent.capture_auto_scroll);
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);
write_recent_enum(rf, "Bytes view display type",
RECENT_GUI_BYTES_VIEW, bytes_view_type_values,
recent.gui_bytes_view);
write_recent_enum(rf, "Bytes view text encoding",
RECENT_GUI_BYTES_ENCODING, bytes_encoding_type_values,
recent.gui_bytes_encoding);
write_recent_boolean(rf, "Packet diagram field values show (hide)",
RECENT_GUI_PACKET_DIAGRAM_FIELD_VALUES,
recent.gui_packet_diagram_field_values);
write_recent_boolean(rf, "Allow hover selection in byte view",
RECENT_GUI_ALLOW_HOVER_SELECTION,
recent.gui_allow_hover_selection);
write_recent_enum(rf, "Follow stream show as",
RECENT_GUI_FOLLOW_SHOW, follow_show_values,
recent.gui_follow_show);
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# Conversation dialog tabs columns.\n");
fprintf(rf, "# List of conversation columns numbers.\n");
string_list = join_string_list(recent.conversation_tabs_columns);
fprintf(rf, RECENT_GUI_CONVERSATION_TABS_COLUMNS ": %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);
fprintf(rf, "\n# Endpoint dialog tabs columns.\n");
fprintf(rf, "# List of endpoint columns numbers.\n");
string_list = join_string_list(recent.endpoint_tabs_columns);
fprintf(rf, RECENT_GUI_ENDPOINT_TABS_COLUMNS ": %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 */
static prefs_set_pref_e
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_LEFTALIGN_ACTIONS) == 0) {
parse_recent_boolean(value, &recent.gui_geometry_leftalign_actions);
} 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_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_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_SYS_WARN_IF_NO_CAPTURE) == 0) {
parse_recent_boolean(value, &recent.sys_warn_if_no_capture);
} else if (strcmp(key, RECENT_GUI_SEARCH_IN) == 0) {
recent.gui_search_in = (search_in_type)str_to_val(value, search_in_values, SEARCH_IN_PACKET_LIST);
} else if (strcmp(key, RECENT_GUI_SEARCH_CHAR_SET) == 0) {
recent.gui_search_char_set = (search_char_set_type)str_to_val(value, search_char_set_values, SEARCH_CHAR_SET_NARROW_AND_WIDE);
} else if (strcmp(key, RECENT_GUI_SEARCH_CASE_SENSITIVE) == 0) {
parse_recent_boolean(value, &recent.gui_search_case_sensitive);
} else if (strcmp(key, RECENT_GUI_SEARCH_TYPE) == 0) {
recent.gui_search_type = (search_type_type)str_to_val(value, search_type_values, SEARCH_TYPE_DISPLAY_FILTER);
} else if (strcmp(key, RECENT_GUI_CUSTOM_COLORS) == 0) {
recent.custom_colors = prefs_get_string_list(value);
}
return PREFS_SET_OK;
}
/* set one user's recent file key/value pair */
static prefs_set_pref_e
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_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_PACKET_DIAGRAM_SHOW) == 0) {
parse_recent_boolean(value, &recent.packet_diagram_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_KEY_CAPTURE_AUTO_SCROLL) == 0) {
parse_recent_boolean(value, &recent.capture_auto_scroll);
} else if (strcmp(key, RECENT_GUI_TIME_FORMAT) == 0) {
recent.gui_time_format = (ts_type)str_to_val(value, ts_type_values,
is_packet_configuration_namespace() ? TS_RELATIVE : TS_ABSOLUTE);
} 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) {
recent.gui_bytes_view =
(bytes_view_type)str_to_val(value, bytes_view_type_values, BYTES_HEX);
} else if (strcmp(key, RECENT_GUI_BYTES_ENCODING) == 0) {
recent.gui_bytes_encoding =
(bytes_encoding_type)str_to_val(value, bytes_encoding_type_values, BYTES_ENC_FROM_PACKET);
} else if (strcmp(key, RECENT_GUI_PACKET_DIAGRAM_FIELD_VALUES) == 0) {
parse_recent_boolean(value, &recent.gui_packet_diagram_field_values);
} else if (strcmp(key, RECENT_GUI_ALLOW_HOVER_SELECTION) == 0) {
parse_recent_boolean(value, &recent.gui_allow_hover_selection);
} else if (strcmp(key, RECENT_GUI_FOLLOW_SHOW) == 0) {
recent.gui_follow_show = (follow_show_type)str_to_val(value, follow_show_values, SHOW_ASCII);
} 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;
} 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;
} else if (strcmp(key, RECENT_GUI_CONVERSATION_TABS) == 0) {
recent.conversation_tabs = prefs_get_string_list(value);
} else if (strcmp(key, RECENT_GUI_CONVERSATION_TABS_COLUMNS) == 0) {
recent.conversation_tabs_columns = 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_ENDPOINT_TABS_COLUMNS) == 0) {
recent.endpoint_tabs_columns = 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) {
fmt_data cfmt_check;
/* 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;
}
/* Some predefined columns have been migrated to use custom
* columns. We'll convert these silently here */
try_convert_to_custom_column((char **)&col_l_elt->data);
/* Check the format. */
if (!parse_column_format(&cfmt_check, (char *)col_l_elt->data)) {
/* It's not a valid column format. */
prefs_clear_string_list(col_l);
return PREFS_SET_SYNTAX_ERR;
}
if (cfmt_check.fmt == COL_CUSTOM) {
/* We don't need the custom column field on this pass. */
g_free(cfmt_check.custom_fields);
}
/* 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 = g_new(col_width_data, 1);
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);
}
return PREFS_SET_OK;
}
/* set one user's recent file key/value pair */
static prefs_set_pref_e
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);
#ifdef HAVE_PCAP_REMOTE
} else if (strcmp(key, RECENT_KEY_REMOTE_HOST) == 0) {
capture_remote_combo_add_recent(value);
#endif
}
return PREFS_SET_OK;
}
/*
* Given a string of the form "<recent name>:<recent value>", as might appear
* as an argument to a "-o" option, parse it and set the recent value in
* question. Return an indication of whether it succeeded or failed
* in some fashion.
*/
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') {
/*
* 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;
}
/* opens the user's recent common file and read the first part */
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_geometry_main_width = DEF_WIDTH;
recent.gui_geometry_main_height = DEF_HEIGHT;
recent.gui_geometry_main_maximized= FALSE;
recent.gui_geometry_leftalign_actions = FALSE;
recent.gui_geometry_wlan_stats_pane = 200;
recent.privs_warn_if_elevated = TRUE;
recent.sys_warn_if_no_capture = TRUE;
recent.col_width_list = NULL;
recent.gui_fileopen_remembered_dir = NULL;
/* 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;
}
/* opens the user's recent file and read the first part */
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.packet_list_show = TRUE;
recent.tree_view_show = TRUE;
recent.byte_view_show = TRUE;
recent.packet_diagram_show = TRUE;
recent.statusbar_show = TRUE;
recent.packet_list_colorize = TRUE;
recent.capture_auto_scroll = 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;
recent.gui_bytes_encoding = BYTES_ENC_FROM_PACKET;
recent.gui_allow_hover_selection = TRUE;
recent.gui_follow_show = SHOW_ASCII;
/* pane size of zero will autodetect */
recent.gui_geometry_main_upper_pane = 0;
recent.gui_geometry_main_lower_pane = 0;
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;
}
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;
}
/* 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);
#if 0
/* 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;
}
}
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) {
return col_w->width;
} else if (cfield && 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) {
col_w->width = width;
found = TRUE;
break;
}
}
col_l = col_l->next;
}
if (!found) {
col_w = g_new(col_width_data, 1);
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) {
return col_w->xalign;
} else if (cfield && 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) {
col_w->xalign = xalign;
found = TRUE;
break;
}
}
col_l = col_l->next;
}
if (!found) {
col_w = g_new(col_width_data, 1);
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));
}
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.conversation_tabs_columns);
prefs_clear_string_list(recent.endpoint_tabs);
prefs_clear_string_list(recent.endpoint_tabs_columns);
prefs_clear_string_list(recent.custom_colors);
} |
C/C++ | wireshark/ui/recent.h | /** @file
*
* Definitions for recent "preference" handling routines
* Copyright 2004, Ulf Lamping <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __RECENT_H__
#define __RECENT_H__
#include <glib.h>
#include <stdio.h>
#include "epan/timestamp.h"
#include "ui/ws_ui_util.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @file
* Recent user interface settings.
* @ingroup main_window_group
*/
/** ???. */
#define RECENT_KEY_CAPTURE_FILE "recent.capture_file"
/** ???. */
#define RECENT_KEY_DISPLAY_FILTER "recent.display_filter"
#define RECENT_KEY_COL_WIDTH "column.width"
#define RECENT_KEY_CAPTURE_FILTER "recent.capture_filter"
#define RECENT_KEY_REMOTE_HOST "recent.remote_host"
typedef struct _col_width_data {
gint cfmt;
gchar *cfield;
gint width;
gchar xalign;
} col_width_data;
/** Defines used in col_width_data.xalign */
#define COLUMN_XALIGN_DEFAULT 0
#define COLUMN_XALIGN_LEFT 'L'
#define COLUMN_XALIGN_CENTER 'C'
#define COLUMN_XALIGN_RIGHT 'R'
typedef enum {
BYTES_HEX,
BYTES_BITS,
BYTES_DEC,
BYTES_OCT
} bytes_view_type;
typedef enum {
BYTES_ENC_FROM_PACKET, // frame_data packet_char_enc
BYTES_ENC_ASCII,
BYTES_ENC_EBCDIC
} bytes_encoding_type;
typedef enum {
SEARCH_IN_PACKET_LIST,
SEARCH_IN_PACKET_DETAILS,
SEARCH_IN_PACKET_BYTES
} search_in_type;
typedef enum {
SEARCH_CHAR_SET_NARROW_AND_WIDE,
SEARCH_CHAR_SET_NARROW,
SEARCH_CHAR_SET_WIDE
} search_char_set_type;
typedef enum {
SEARCH_TYPE_DISPLAY_FILTER,
SEARCH_TYPE_HEX_VALUE,
SEARCH_TYPE_STRING,
SEARCH_TYPE_REGEX
} search_type_type;
typedef enum {
SHOW_ASCII,
SHOW_CARRAY,
SHOW_EBCDIC,
SHOW_HEXDUMP,
SHOW_RAW,
SHOW_CODEC, // Ordered to match UTF-8 combobox index
SHOW_YAML
} follow_show_type;
/** Recent settings. */
typedef struct recent_settings_tag {
gboolean main_toolbar_show;
gboolean filter_toolbar_show;
gboolean wireless_toolbar_show;
gboolean packet_list_show;
gboolean tree_view_show;
gboolean byte_view_show;
gboolean packet_diagram_show;
gboolean statusbar_show;
gboolean packet_list_colorize;
gboolean capture_auto_scroll;
ts_type gui_time_format;
gint gui_time_precision;
ts_seconds_type gui_seconds_format;
gint gui_zoom_level;
bytes_view_type gui_bytes_view;
bytes_encoding_type gui_bytes_encoding;
gboolean gui_packet_diagram_field_values;
gboolean gui_allow_hover_selection;
search_in_type gui_search_in;
search_char_set_type gui_search_char_set;
gboolean gui_search_case_sensitive;
search_type_type gui_search_type;
follow_show_type gui_follow_show;
gint gui_geometry_main_x;
gint gui_geometry_main_y;
gint gui_geometry_main_width;
gint gui_geometry_main_height;
gboolean gui_geometry_main_maximized;
gboolean gui_geometry_leftalign_actions;
gint gui_geometry_main_upper_pane;
gint gui_geometry_main_lower_pane;
gint gui_geometry_wlan_stats_pane;
gboolean privs_warn_if_elevated;
gboolean sys_warn_if_no_capture;
GList *col_width_list; /* column widths */
GList *conversation_tabs; /* enabled conversation dialog tabs */
GList *conversation_tabs_columns; /* save the columns for conversation dialogs */
GList *endpoint_tabs; /* enabled endpoint dialog tabs */
GList *endpoint_tabs_columns; /* save the columns for endpoint dialogs */
gchar *gui_fileopen_remembered_dir; /* folder of last capture loaded in File Open dialog */
gboolean gui_rlc_use_pdus_from_mac;
GList *custom_colors;
GList *gui_additional_toolbars;
GList *interface_toolbars;
} recent_settings_t;
/** Global recent settings. */
extern recent_settings_t recent;
/** Initialize recent settings module (done at startup) */
extern void recent_init(void);
/** Cleanup/Frees recent settings (done at shutdown) */
extern void recent_cleanup(void);
/** Write recent_common settings file.
*
* @return TRUE if succeeded, FALSE if failed
*/
extern gboolean write_recent(void);
/** Write profile recent settings file.
*
* @return TRUE if succeeded, FALSE if failed
*/
extern gboolean write_profile_recent(void);
/** Read recent settings file (static part).
*
* @param rf_path_return path to recent file if function failed
* @param rf_errno_return if failed
* @return TRUE if succeeded, FALSE if failed (check parameters for reason).
*/
extern gboolean recent_read_static(char **rf_path_return, int *rf_errno_return);
/** Read profile recent settings file (static part).
*
* @param rf_path_return path to recent file if function failed
* @param rf_errno_return if failed
* @return TRUE if succeeded, FALSE if failed (check parameters for reason).
*/
extern gboolean recent_read_profile_static(char **rf_path_return, int *rf_errno_return);
/** Read recent settings file (dynamic part).
*
* @param rf_path_return path to recent file if function failed
* @param rf_errno_return if failed
* @return TRUE if succeeded, FALSE if failed (check parameters for reason).
*/
extern gboolean recent_read_dynamic(char **rf_path_return, int *rf_errno_return);
/**
* Given a -o command line string, parse it and set the recent value in
* question. Return an indication of whether it succeeded or failed
* in some fashion.
*
* @param prefarg a string of the form "<recent name>:<recent value>", as might appear
* as an argument to a "-o" command line option
* @return PREFS_SET_OK or PREFS_SET_SYNTAX_ERR
*/
extern int recent_set_arg(char *prefarg);
/** Get the column width for the given column
*
* @param col column number
*/
extern gint recent_get_column_width(gint col);
/** Set the column width for the given column
*
* @param col column number
* @param width column width
*/
extern void recent_set_column_width(gint col, gint width);
/** Get the column xalign for the given column
*
* @param col column number
*/
extern gchar recent_get_column_xalign(gint col);
/** Set the column xalign for the given column
*
* @param col column number
* @param xalign column alignment
*/
extern void recent_set_column_xalign(gint col, gchar xalign);
/* save the window and its current geometry into the geometry hashtable */
extern void window_geom_save(const gchar *name, window_geometry_t *geom);
/* load the desired geometry for this window from the geometry hashtable */
extern gboolean window_geom_load(const gchar *name, window_geometry_t *geom);
/**
* Returns a list of recent capture filters.
*
* @param ifname interface name; NULL refers to the global list.
*/
extern GList *recent_get_cfilter_list(const gchar *ifname);
/**
* Add a capture filter to the global recent capture filter list or
* the recent capture filter list for an interface.
*
* @param ifname interface name; NULL refers to the global list.
* @param s text of capture filter
*/
extern void recent_add_cfilter(const gchar *ifname, const gchar *s);
/**
* Get the value of an entry for a remote host from the remote host list.
*
* @param host host name for the remote host.
*
* @return pointer to the entry for the remote host.
*/
extern struct remote_host *recent_get_remote_host(const gchar *host);
/**
* Get the number of entries of the remote host list.
*
* @return number of entries in the list.
*/
extern int recent_get_remote_host_list_size(void);
/**
* Iterate over all items in the remote host list, calling a
* function for each member
*
* @param func function to be called
* @param user_data argument to pass as user data to the function
*/
extern void recent_remote_host_list_foreach(GHFunc func, gpointer user_data);
/**
* Free all entries of the remote host list.
*/
extern void recent_free_remote_host_list(void);
/**
* Add an entry to the remote_host_list.
*
* @param host Key of the entry
* @param rh Value of the entry
*/
extern void recent_add_remote_host(gchar *host, struct remote_host *rh);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* recent.h */ |
C/C++ | wireshark/ui/recent_utils.h | /** @file
*
* Routines called to write stuff to the recent file; their implementations
* are GUI-dependent, but the API's aren't
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __UI_RECENT_UTILS_H__
#define __UI_RECENT_UTILS_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Add a new recent capture filename to the "Recent Files" submenu
(duplicates will be ignored) */
extern void add_menu_recent_capture_file(const gchar *cf_name);
/** Write all recent capture filenames to the user's recent file.
* @param rf recent file
*/
extern void menu_recent_file_write_all(FILE *rf);
/** Write all non-empty capture filters (until maximum count)
* of the combo box GList to the user's recent file.
*
* @param rf the recent file
*/
extern void cfilter_combo_recent_write_all(FILE *rf);
/** Add a display filter coming from the user's recent file to the dfilter combo box.
*
* @param dftext the filter string
*/
extern gboolean dfilter_combo_add_recent(const gchar *dftext);
/** Write all non-empty display filters (until maximum count)
* of the combo box GList to the user's recent file.
*
* @param rf the recent file
*/
extern void dfilter_recent_combo_write_all(FILE *rf);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __UI_RECENT_UTILS_H__ */ |
C | wireshark/ui/rtp_media.c | /* rtp_media.c
*
* RTP decoding routines for Wireshark.
* Copied from ui/gtk/rtp_player.c
*
* Copyright 2006, Alejandro Vaquero <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1999 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <wsutil/codecs.h>
#include <epan/rtp_pt.h>
#include <epan/dissectors/packet-rtp.h>
#include <ui/rtp_media.h>
/****************************************************************************/
/* DECODING */
/****************************************************************************/
typedef struct _rtp_decoder_t {
codec_handle_t handle;
codec_context_t *context;
} rtp_decoder_t;
/****************************************************************************/
/*
* Return the number of decoded bytes
*/
size_t
decode_rtp_packet_payload(guint8 payload_type, const gchar *payload_type_str, int payload_rate, int payload_channels, wmem_map_t *payload_fmtp_map, guint8 *payload_data, size_t payload_len, SAMPLE **out_buff, GHashTable *decoders_hash, guint *channels_ptr, guint *sample_rate_ptr)
{
const gchar *p;
rtp_decoder_t *decoder;
SAMPLE *tmp_buff = NULL;
size_t tmp_buff_len;
size_t decoded_bytes = 0;
/* Look for registered codecs */
decoder = (rtp_decoder_t *)g_hash_table_lookup(decoders_hash, GUINT_TO_POINTER(payload_type));
if (!decoder) { /* Put either valid or empty decoder into the hash table */
decoder = g_new(rtp_decoder_t,1);
decoder->handle = NULL;
decoder->context = g_new(codec_context_t, 1);
decoder->context->sample_rate = payload_rate;
decoder->context->channels = payload_channels;
decoder->context->fmtp_map = payload_fmtp_map;
decoder->context->priv = NULL;
if (payload_type_str && find_codec(payload_type_str)) {
p = payload_type_str;
} else {
p = try_val_to_str_ext(payload_type, &rtp_payload_type_short_vals_ext);
}
if (p) {
decoder->handle = find_codec(p);
if (decoder->handle)
decoder->context->priv = codec_init(decoder->handle, decoder->context);
}
g_hash_table_insert(decoders_hash, GUINT_TO_POINTER(payload_type), decoder);
}
if (decoder->handle) { /* Decode with registered codec */
/* if output == NULL and outputSizeBytes == NULL => ask for expected size of the buffer */
tmp_buff_len = codec_decode(decoder->handle, decoder->context, payload_data, payload_len, NULL, NULL);
tmp_buff = (SAMPLE *)g_malloc(tmp_buff_len);
decoded_bytes = codec_decode(decoder->handle, decoder->context, payload_data, payload_len, tmp_buff, &tmp_buff_len);
*out_buff = tmp_buff;
if (channels_ptr) {
*channels_ptr = codec_get_channels(decoder->handle, decoder->context);
}
if (sample_rate_ptr) {
*sample_rate_ptr = codec_get_frequency(decoder->handle, decoder->context);
}
return decoded_bytes;
}
*out_buff = NULL;
return 0;
}
/****************************************************************************/
/*
* @return Number of decoded bytes
*/
size_t
decode_rtp_packet(rtp_packet_t *rp, SAMPLE **out_buff, GHashTable *decoders_hash, guint *channels_ptr, guint *sample_rate_ptr)
{
guint8 payload_type;
if ((rp->payload_data == NULL) || (rp->info->info_payload_len == 0) ) {
return 0;
}
payload_type = rp->info->info_payload_type;
return decode_rtp_packet_payload(payload_type, rp->info->info_payload_type_str, rp->info->info_payload_rate, rp->info->info_payload_channels, rp->info->info_payload_fmtp_map, rp->payload_data, rp->info->info_payload_len, out_buff, decoders_hash, channels_ptr, sample_rate_ptr);
}
/****************************************************************************/
static void
rtp_decoder_value_destroy(gpointer dec_arg)
{
rtp_decoder_t *dec = (rtp_decoder_t *)dec_arg;
if (dec->handle) {
codec_release(dec->handle, dec->context);
g_free(dec->context);
}
g_free(dec_arg);
}
GHashTable *rtp_decoder_hash_table_new(void)
{
return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, rtp_decoder_value_destroy);
} |
C/C++ | wireshark/ui/rtp_media.h | /** @file
*
* RTP decoding routines for Wireshark.
* Copied from ui/gtk/rtp_player.c
*
* Copyright 2006, Alejandro Vaquero <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1999 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __RTP_MEDIA_H__
#define __RTP_MEDIA_H__
#include <glib.h>
#include <wsutil/wmem/wmem_map.h>
/** @file
* "RTP Player" dialog box common routines.
* @ingroup main_ui_group
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
/* INTERFACE */
/****************************************************************************/
typedef gint16 SAMPLE;
#define SAMPLE_MAX G_MAXINT16
#define SAMPLE_MIN G_MININT16
#define SAMPLE_NaN SAMPLE_MIN
#define SAMPLE_BYTES (sizeof(SAMPLE) / sizeof(char))
/* Defines an RTP packet */
typedef struct _rtp_packet {
guint32 frame_num; /* Qt only */
struct _rtp_info *info; /* the RTP dissected info */
double arrive_offset; /* arrive offset time since the beginning of the stream as ms in GTK UI and s in Qt UI */
guint8* payload_data;
} rtp_packet_t;
/** Create a new hash table.
*
* @return A new hash table suitable for passing to decode_rtp_packet.
*/
GHashTable *rtp_decoder_hash_table_new(void);
/** Decode payload from an RTP packet
* For RTP packets with dynamic payload types, the payload name, clock rate,
* and number of audio channels (e.g., from the SDP) can be provided.
* Note that the output sample rate and number of channels might not be the
* same as that of the input.
*
* @param payload_type Payload number
* @param payload_type_str Payload name, can be NULL
* @param payload_rate Sample rate, can be 0 for codec default
* @param payload_channels Audio channels, can be 0 for codec default
* @param payload_fmtp_map Map of format parameters for the media type
* @param payload_data Payload
* @param payload_len Length of payload
* @param out_buff Output audio samples.
* @param decoders_hash Hash table created with rtp_decoder_hash_table_new.
* @param channels_ptr If non-NULL, receives the number of channels in the sample.
* @param sample_rate_ptr If non-NULL, receives the sample rate.
* @return The number of decoded bytes on success, 0 on failure.
*/
size_t decode_rtp_packet_payload(guint8 payload_type, const gchar *payload_type_str, int payload_rate, int payload_channels, wmem_map_t *payload_fmtp_map, guint8 *payload_data, size_t payload_len, SAMPLE **out_buff, GHashTable *decoders_hash, guint *channels_ptr, guint *sample_rate_ptr);
/** Decode an RTP packet
*
* @param rp Wrapper for per-packet RTP tap data.
* @param out_buff Output audio samples.
* @param decoders_hash Hash table created with rtp_decoder_hash_table_new.
* @param channels_ptr If non-NULL, receives the number of channels in the sample.
* @param sample_rate_ptr If non-NULL, receives the sample rate.
* @return The number of decoded bytes on success, 0 on failure.
*/
size_t decode_rtp_packet(rtp_packet_t *rp, SAMPLE **out_buff, GHashTable *decoders_hash, guint *channels_ptr, guint *sample_rate_ptr);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __RTP_MEDIA_H__ */ |
C | wireshark/ui/rtp_stream.c | /* rtp_stream.c
* RTP streams summary addition for Wireshark
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "file.h"
#include <epan/epan.h>
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/dissectors/packet-rtp.h>
#include <epan/addr_resolv.h>
#include "ui/alert_box.h"
#include "ui/simple_dialog.h"
#include "ui/rtp_stream.h"
#include "ui/tap-rtp-common.h"
#include <wsutil/file_util.h>
/****************************************************************************/
/* scan for RTP streams */
void
show_tap_registration_error(GString *error_string)
{
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
}
/****************************************************************************/
/* scan for RTP streams */
void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const char *fstring)
{
gboolean was_registered;
if (!tapinfo || !cap_file) {
return;
}
was_registered = tapinfo->is_registered;
if (!tapinfo->is_registered)
register_tap_listener_rtpstream(tapinfo, fstring, show_tap_registration_error);
/* RTP_STREAM_DEBUG("scanning %s, filter: %s", cap_file->filename, fstring); */
tapinfo->mode = TAP_ANALYSE;
cf_retap_packets(cap_file);
if (!was_registered)
remove_tap_listener_rtpstream(tapinfo);
}
/****************************************************************************/
/* save rtp dump of stream_fwd */
gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream, const gchar *filename)
{
gboolean was_registered;
if (!tapinfo) {
return FALSE;
}
was_registered = tapinfo->is_registered;
/* open file for saving */
tapinfo->save_file = ws_fopen(filename, "wb");
if (tapinfo->save_file==NULL) {
open_failure_alert_box(filename, errno, TRUE);
return FALSE;
}
rtp_write_header(stream, tapinfo->save_file);
if (ferror(tapinfo->save_file)) {
write_failure_alert_box(filename, errno);
fclose(tapinfo->save_file);
return FALSE;
}
if (!tapinfo->is_registered)
register_tap_listener_rtpstream(tapinfo, NULL, show_tap_registration_error);
tapinfo->mode = TAP_SAVE;
tapinfo->filter_stream_fwd = stream;
cf_retap_packets(cap_file);
tapinfo->mode = TAP_ANALYSE;
if (!was_registered)
remove_tap_listener_rtpstream(tapinfo);
if (ferror(tapinfo->save_file)) {
write_failure_alert_box(filename, errno);
fclose(tapinfo->save_file);
return FALSE;
}
if (fclose(tapinfo->save_file) == EOF) {
write_failure_alert_box(filename, errno);
return FALSE;
}
return TRUE;
}
/****************************************************************************/
/* mark packets in stream_fwd or stream_rev */
void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream_fwd, rtpstream_info_t* stream_rev)
{
gboolean was_registered;
if (!tapinfo) {
return;
}
was_registered = tapinfo->is_registered;
if (!tapinfo->is_registered)
register_tap_listener_rtpstream(tapinfo, NULL, show_tap_registration_error);
tapinfo->mode = TAP_MARK;
tapinfo->filter_stream_fwd = stream_fwd;
tapinfo->filter_stream_rev = stream_rev;
cf_retap_packets(cap_file);
tapinfo->mode = TAP_ANALYSE;
if (!was_registered)
remove_tap_listener_rtpstream(tapinfo);
} |
C/C++ | wireshark/ui/rtp_stream.h | /** @file
*
* RTP streams summary addition for Wireshark
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __RTP_STREAM_H__
#define __RTP_STREAM_H__
#include <glib.h>
#include "tap-rtp-analysis.h"
#include <stdio.h>
#include "cfile.h"
#include <epan/address.h>
#include <epan/tap.h>
#include "ui/rtp_stream_id.h"
/** @file
* "RTP Streams" dialog box common routines.
* @ingroup main_ui_group
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** Defines an rtp stream */
typedef struct _rtpstream_info {
rtpstream_id_t id;
guint8 first_payload_type; /**< Numeric payload type */
const gchar *first_payload_type_name; /**< Payload type name */
const gchar *payload_type_names[256]; /**< Seen payload type names. Array index is payload type (byte), filled only during TAP_ANALYSE */
gchar *all_payload_type_names; /**< All seen payload names for a stream in one string */
gboolean is_srtp;
guint32 packet_count;
gboolean end_stream; /**< Used to track streams across payload types */
int rtp_event;
int call_num; /**< Used to match call_num in voip_calls_info_t */
guint32 setup_frame_number; /**< frame number of setup message */
/* Start and stop packets needed for .num and .abs_ts */
frame_data *start_fd;
frame_data *stop_fd;
nstime_t start_rel_time; /**< relative start time from pinfo */
nstime_t stop_rel_time; /**< relative stop time from pinfo */
nstime_t start_abs_time; /**< abs start time from pinfo */
guint16 vlan_id;
gboolean tag_vlan_error;
gboolean tag_diffserv_error;
tap_rtp_stat_t rtp_stats; /**< here goes the RTP statistics info */
gboolean problem; /**< if the streams had wrong sequence numbers or wrong timestamps */
const gchar *ed137_info; /** pointer to static text, no freeing is required */
} rtpstream_info_t;
/** tapping modes */
typedef enum
{
TAP_ANALYSE,
TAP_SAVE,
TAP_MARK
} tap_mode_t;
typedef struct _rtpstream_tapinfo rtpstream_tapinfo_t;
typedef void (*rtpstream_tap_reset_cb)(rtpstream_tapinfo_t *tapinfo);
typedef void (*rtpstream_tap_draw_cb)(rtpstream_tapinfo_t *tapinfo);
typedef void (*tap_mark_packet_cb)(rtpstream_tapinfo_t *tapinfo, frame_data *fd);
typedef void (*rtpstream_tap_error_cb)(GString *error_string);
/* structure that holds the information about all detected streams */
/** struct holding all information of the tap */
struct _rtpstream_tapinfo {
rtpstream_tap_reset_cb tap_reset; /**< tap reset callback */
rtpstream_tap_draw_cb tap_draw; /**< tap draw callback */
tap_mark_packet_cb tap_mark_packet; /**< packet marking callback */
void *tap_data; /**< data for tap callbacks */
int nstreams; /**< number of streams in the list */
GList *strinfo_list; /**< list of rtpstream_info_t* */
GHashTable *strinfo_hash; /**< multihash of rtpstream_info_t **/
/* multihash means that there can be */
/* more values related to one hash key */
int npackets; /**< total number of rtp packets of all streams */
/* used while tapping. user shouldn't modify these */
tap_mode_t mode;
rtpstream_info_t *filter_stream_fwd; /**< used as filter in some tap modes */
rtpstream_info_t *filter_stream_rev; /**< used as filter in some tap modes */
FILE *save_file;
gboolean is_registered; /**< if the tap listener is currently registered or not */
gboolean apply_display_filter; /**< if apply display filter during analyse */
};
#if 0
#define RTP_STREAM_DEBUG(...) { \
char *RTP_STREAM_DEBUG_MSG = ws_strdup_printf(__VA_ARGS__); \
ws_warning("rtp_stream: %s:%d %s", G_STRFUNC, __LINE__, RTP_STREAM_DEBUG_MSG); \
g_free(RTP_STREAM_DEBUG_MSG); \
}
#else
#define RTP_STREAM_DEBUG(...)
#endif
/****************************************************************************/
/* INTERFACE */
void show_tap_registration_error(GString *error_string);
/**
* Scans all packets for RTP streams and updates the RTP streams list.
* (redissects all packets)
*/
void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const char *fstring);
/**
* Saves an RTP stream as raw data stream with timestamp information for later RTP playback.
* (redissects all packets)
*/
gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream, const gchar *filename);
/**
* Marks all packets belonging to either of stream_fwd or stream_rev.
* (both can be NULL)
* (redissects all packets)
*/
void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream_fwd, rtpstream_info_t* stream_rev);
/* Constant based on fix for bug 4119/5902: don't insert too many silence
* frames.
*/
#define MAX_SILENCE_FRAMES 14400000
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __RTP_STREAM_H__ */ |
C | wireshark/ui/rtp_stream_id.c | /* rtp_stream_id.c
* RTP stream id functions for Wireshark
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "file.h"
#include "ui/rtp_stream_id.h"
#include "epan/dissectors/packet-rtp.h"
/****************************************************************************/
/* rtpstream id functions */
/****************************************************************************/
/****************************************************************************/
/* deep copy of id */
void rtpstream_id_copy(const rtpstream_id_t *src, rtpstream_id_t *dest)
{
copy_address(&(dest->src_addr), &(src->src_addr));
dest->src_port=src->src_port;
copy_address(&(dest->dst_addr), &(src->dst_addr));
dest->dst_port=src->dst_port;
dest->ssrc=src->ssrc;
}
/****************************************************************************/
/* deep copy of id from packet_info */
void rtpstream_id_copy_pinfo(const packet_info *pinfo, rtpstream_id_t *dest, gboolean swap_src_dst)
{
if (!swap_src_dst)
{
copy_address(&(dest->src_addr), &(pinfo->src));
dest->src_port=pinfo->srcport;
copy_address(&(dest->dst_addr), &(pinfo->dst));
dest->dst_port=pinfo->destport;
}
else
{
copy_address(&(dest->src_addr), &(pinfo->dst));
dest->src_port=pinfo->destport;
copy_address(&(dest->dst_addr), &(pinfo->src));
dest->dst_port=pinfo->srcport;
}
}
/****************************************************************************/
/* shallow copy from packet_info to id */
void rtpstream_id_copy_pinfo_shallow(const packet_info *pinfo, rtpstream_id_t *dest, gboolean swap_src_dst)
{
if (!swap_src_dst)
{
copy_address_shallow(&(dest->src_addr), &(pinfo->src));
dest->src_port=pinfo->srcport;
copy_address_shallow(&(dest->dst_addr), &(pinfo->dst));
dest->dst_port=pinfo->destport;
}
else
{
copy_address_shallow(&(dest->src_addr), &(pinfo->dst));
dest->src_port=pinfo->destport;
copy_address_shallow(&(dest->dst_addr), &(pinfo->src));
dest->dst_port=pinfo->srcport;
}
}
/****************************************************************************/
/* free memory allocated for id */
void rtpstream_id_free(rtpstream_id_t *id)
{
free_address(&(id->src_addr));
free_address(&(id->dst_addr));
memset(id, 0, sizeof(*id));
}
/****************************************************************************/
/* convert rtpstream_id_t to hash */
guint rtpstream_id_to_hash(const rtpstream_id_t *id)
{
guint hash = 0;
if (!id) { return 0; }
/* XOR of: */
/* SRC PORT | DST_PORT */
/* SSRC */
/* SRC ADDR */
/* DST ADDR */
hash ^= id->src_port | id->dst_port << 16;
hash ^= id->ssrc;
hash = add_address_to_hash(hash, &id->src_addr);
hash = add_address_to_hash(hash, &id->dst_addr);
return hash;
}
/****************************************************************************/
/* compare two ids by flags */
gboolean rtpstream_id_equal(const rtpstream_id_t *id1, const rtpstream_id_t *id2, guint flags)
{
if (addresses_equal(&(id1->src_addr), &(id2->src_addr))
&& id1->src_port == id2->src_port
&& addresses_equal(&(id1->dst_addr), &(id2->dst_addr))
&& id1->dst_port == id2->dst_port)
{
gboolean equal = TRUE;
if ((flags & RTPSTREAM_ID_EQUAL_SSRC)
&& id1->ssrc != id2->ssrc)
{
equal = FALSE;
}
return equal;
}
return FALSE;
}
/****************************************************************************/
/* compare an rtpstream id address and ports with pinfo */
gboolean rtpstream_id_equal_pinfo(const rtpstream_id_t *id, const packet_info *pinfo, bool swap_src_dst)
{
if (!swap_src_dst) {
if (addresses_equal(&(id->src_addr), &(pinfo->src))
&& id->src_port == pinfo->srcport
&& addresses_equal(&(id->dst_addr), &(pinfo->dst))
&& id->dst_port == pinfo->destport)
{
return TRUE;
}
} else {
if (addresses_equal(&(id->src_addr), &(pinfo->dst))
&& id->src_port == pinfo->destport
&& addresses_equal(&(id->dst_addr), &(pinfo->src))
&& id->dst_port == pinfo->srcport)
{
return TRUE;
}
}
return FALSE;
}
/****************************************************************************/
/* compare two ids, one in pinfo */
gboolean rtpstream_id_equal_pinfo_rtp_info(const rtpstream_id_t *id, const packet_info *pinfo, const struct _rtp_info *rtp_info)
{
if (addresses_equal(&(id->src_addr), &(pinfo->src))
&& id->src_port == pinfo->srcport
&& addresses_equal(&(id->dst_addr), &(pinfo->dst))
&& id->dst_port == pinfo->destport
&& id->ssrc == rtp_info->info_sync_src)
{
return TRUE;
}
return FALSE;
}
/****************************************************************************/
/* convert packet_info and _rtp_info to hash */
guint pinfo_rtp_info_to_hash(const packet_info *pinfo, const struct _rtp_info *rtp_info)
{
guint hash = 0;
if (!pinfo || !rtp_info) { return 0; }
/* XOR of: */
/* SRC PORT | DST_PORT */
/* SSRC */
/* SRC ADDR */
/* DST ADDR */
hash ^= pinfo->srcport | pinfo->destport << 16;
hash ^= rtp_info->info_sync_src;
hash = add_address_to_hash(hash, &pinfo->src);
hash = add_address_to_hash(hash, &pinfo->dst);
return hash;
} |
C/C++ | wireshark/ui/rtp_stream_id.h | /** @file
*
* RTP stream id functions for Wireshark
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __RTP_STREAM_ID_H__
#define __RTP_STREAM_ID_H__
/** @file
* "RTP Streams" dialog box common routines.
* @ingroup main_ui_group
*/
#include <epan/address.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* forward */
struct _rtp_info;
/** Defines an rtp stream identification */
typedef struct _rtpstream_id {
address src_addr;
guint16 src_port;
address dst_addr;
guint16 dst_port;
guint32 ssrc;
} rtpstream_id_t;
/**
* Get hash of rtpstream_id
*/
guint rtpstream_id_to_hash(const rtpstream_id_t *id);
/**
* Copy rtpstream_id_t structure
*/
void rtpstream_id_copy(const rtpstream_id_t *src, rtpstream_id_t *dest);
/**
* Deep copy addresses and ports from pinfo
*/
void rtpstream_id_copy_pinfo(const packet_info *pinfo, rtpstream_id_t *dest, gboolean swap_src_dst);
/**
* Shallow copy addresses and ports from pinfo
* Do not call rtpstream_id_free if you use this function.
*/
void rtpstream_id_copy_pinfo_shallow(const packet_info *pinfo, rtpstream_id_t *dest, gboolean swap_src_dst);
/**
* Free memory allocated for id
* it releases address items only, do not release whole structure!
*/
void rtpstream_id_free(rtpstream_id_t *id);
/**
* Check if two rtpstream_id_t are equal
* - compare src_addr, dest_addr, src_port, dest_port
* - compare other items when requested
* Note: ssrc is the only other item now, but it is expected it will be extended later
*/
#define RTPSTREAM_ID_EQUAL_NONE 0x0000
#define RTPSTREAM_ID_EQUAL_SSRC 0x0001
gboolean rtpstream_id_equal(const rtpstream_id_t *id1, const rtpstream_id_t *id2, guint flags);
/**
* Check if rtpstream_id_t is equal to pinfo
* - compare src_addr, dest_addr, src_port, dest_port with pinfo
* - if swap_src_dst is true, compare src to dst and vice versa
*/
gboolean rtpstream_id_equal_pinfo(const rtpstream_id_t *id, const packet_info *pinfo, bool swap_src_dst);
/**
* Check if rtpstream_id_t is equal to pinfo and rtp_info
* - compare src_addr, dest_addr, src_port, dest_port with pinfo
* - compare ssrc with rtp_info
*/
gboolean rtpstream_id_equal_pinfo_rtp_info(const rtpstream_id_t *id, const packet_info *pinfo, const struct _rtp_info *rtp_info);
/**
* Get hash of rtpstream_id extracted from packet_info and _rtp_info
*/
guint pinfo_rtp_info_to_hash(const packet_info *pinfo, const struct _rtp_info *rtp_info);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __RTP_STREAM_ID_H__ */ |
C | wireshark/ui/service_response_time.c | /* service_response_time.c
* Copied from ui/gtk/service_response_time_table.h, 2003 Ronnie Sahlberg
* Helper routines and structs common to all service response time statistics
* taps.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "service_response_time.h"
extern const char*
service_response_time_get_column_name (int idx)
{
static const char *default_titles[] = { "Index", "Procedure", "Calls", "Min SRT (s)", "Max SRT (s)", "Avg SRT (s)", "Sum SRT (s)" };
if (idx < 0 || idx >= NUM_SRT_COLUMNS) return "(Unknown)";
return default_titles[idx];
} |
C/C++ | wireshark/ui/service_response_time.h | /** @file
*
* Copied from ui/gtk/service_response_time_table.h, 2003 Ronnie Sahlberg
* Helper routines and structs common to all service response time statistics
* taps.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/** @file
* Helper routines common to all service response time statistics taps.
*/
#ifndef __SRT_STATS_H__
#define __SRT_STATS_H__
#include <epan/timestats.h>
#include <epan/srt_table.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
enum
{
SRT_COLUMN_INDEX,
SRT_COLUMN_PROCEDURE,
SRT_COLUMN_CALLS,
SRT_COLUMN_MIN,
SRT_COLUMN_MAX,
SRT_COLUMN_AVG,
SRT_COLUMN_SUM,
NUM_SRT_COLUMNS
};
/** returns the column name for a given column index */
extern const char* service_response_time_get_column_name(int index);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SRT_STATS_H__ */ |
C/C++ | wireshark/ui/simple_dialog.h | /** @file
*
* Definitions for alert box routines with toolkit-independent APIs but
* toolkit-dependent implementations.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __SIMPLE_DIALOG_UI_H__
#define __SIMPLE_DIALOG_UI_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @file
* Simple dialog box.
* @ingroup dialog_group
*/
/** Dialog types. */
typedef enum {
ESD_TYPE_INFO, /**< tells the user something they should know, but not requiring
any action; the only button should be "OK" */
ESD_TYPE_WARN, /**< tells the user about a problem; the only button should be "OK" */
ESD_TYPE_CONFIRMATION, /**< asks the user for confirmation; there should be more than
one button */
ESD_TYPE_ERROR, /**< tells the user about a serious problem; the only button should be "OK" */
ESD_TYPE_STOP /**< tells the user a stop action is in progress, there should be no button */
} ESD_TYPE_E;
/** display no buttons at all */
#define ESD_BTN_NONE 0x00
/** display an "Ok" button */
#define ESD_BTN_OK 0x01
/** display a "Cancel" button */
#define ESD_BTN_CANCEL 0x02
/** display a "Yes" button */
#define ESD_BTN_YES 0x04
/** display a "No" button */
#define ESD_BTN_NO 0x08
/** display a "Clear" button */
#define ESD_BTN_CLEAR 0x10
/** display a "Save" button */
#define ESD_BTN_SAVE 0x20
/** display a "Continue without Saving" button */
#define ESD_BTN_DONT_SAVE 0x40
/** display a "Quit without Saving" button */
#define ESD_BTN_QUIT_DONT_SAVE 0x80
/** Standard button combination "Ok" + "Cancel". */
#define ESD_BTNS_OK_CANCEL (ESD_BTN_OK|ESD_BTN_CANCEL)
/** Standard button combination "Yes" + "No". */
#define ESD_BTNS_YES_NO (ESD_BTN_YES|ESD_BTN_NO)
/** Standard button combination "Yes" + "No" + "Cancel". */
#define ESD_BTNS_YES_NO_CANCEL (ESD_BTN_YES|ESD_BTN_NO|ESD_BTN_CANCEL)
/** Standard button combination "No" + "Cancel" + "Save". */
#define ESD_BTNS_SAVE_DONTSAVE (ESD_BTN_SAVE|ESD_BTN_DONT_SAVE)
#define ESD_BTNS_SAVE_DONTSAVE_CANCEL (ESD_BTN_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
/** Standard button combination "Quit without saving" + "Cancel" + "Save". */
#define ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
/** Standard button combination "Quit without saving" + "Cancel". */
#define ESD_BTNS_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL)
/** Create and show a simple dialog.
*
* @param type type of dialog, e.g. ESD_TYPE_WARN
* @param btn_mask The buttons to display, e.g. ESD_BTNS_OK_CANCEL
* @param msg_format Printf like message format. Text must be plain.
* @param ... Printf like parameters
* @return The newly created dialog
*/
/*
* XXX This is a bit clunky. We typically pass in:
* - simple_dialog_primary_start
* - The primary message
* - simple_dialog_primary_end
* - Optionally, the secondary message.
*
* In the Qt UI we use primary_start and _end to split the primary and
* secondary messages. They are then added to a QMessageBox via setText and
* setInformativeText respectively. No formatting is applied.
*
* Callers are responsible for wrapping the primary message and formatting
* the message text.
*
* Explicitly passing in separate primary and secondary messages would let us
* get rid of primary_start and primary_end and reduce the amount of
* gymnastics we have to do in the Qt UI.
*/
extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask,
const gchar *msg_format, ...)
G_GNUC_PRINTF(3, 4);
extern gpointer simple_dialog_async(ESD_TYPE_E type, gint btn_mask,
const gchar *msg_format, ...)
G_GNUC_PRINTF(3, 4);
/** Surround the primary dialog message text by
* simple_dialog_primary_start() and simple_dialog_primary_end().
*/
extern const char *simple_dialog_primary_start(void);
/** Surround the primary dialog message text by
* simple_dialog_primary_start() and simple_dialog_primary_end().
*/
extern const char *simple_dialog_primary_end(void);
/** Escape the message text, if it probably contains Pango escape sequences.
* For example html like tags starting with a <.
*
* @param msg the string to escape
* @return the escaped message text, must be freed with g_free() later
*/
extern char *simple_dialog_format_message(const char *msg);
/*
* Alert box, with optional "don't show this message again" variable
* and checkbox, and optional secondary text.
*/
extern void simple_message_box(ESD_TYPE_E type, gboolean *notagain,
const char *secondary_msg,
const char *msg_format, ...) G_GNUC_PRINTF(4, 5);
/*
* Error alert box, taking a format and a va_list argument.
*/
extern void vsimple_error_message_box(const char *msg_format, va_list ap);
/*
* Error alert box, taking a format and a list of arguments.
*/
extern void simple_error_message_box(const char *msg_format, ...) G_GNUC_PRINTF(1, 2);
/*
* Warning alert box, taking a format and a va_list argument.
*/
extern void vsimple_warning_message_box(const char *msg_format, va_list ap);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SIMPLE_DIALOG_UI_H__ */ |
C | wireshark/ui/software_update.c | /* software_update.h
* Wrappers and routines to check for software updates.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include "software_update.h"
#include "language.h"
#include "../epan/prefs.h"
#include "../wsutil/filesystem.h"
/*
* Version 0 of the update URI path has the following elements:
* - The update path prefix (fixed, "update")
* - The schema version (fixed, 0)
* - The application name (variable, "Wireshark" or "Logray")
* - The application version ("<major>.<minor>.<micro>")
* - The operating system (variable, one of "Windows" or "macOS")
* - The architecture name (variable, one of "x86", "x86-64", or "arm64")
* - The locale (fixed, "en-US")
* - The update channel (variable, one of "development" or "stable") + .xml
*
* Based on https://wiki.mozilla.org/Software_Update:Checking_For_Updates
*
* To do for version 1:
* - Distinguish between NSIS (.exe) and WiX (.msi) on Windows.
*/
#ifdef HAVE_SOFTWARE_UPDATE
#define SU_SCHEMA_PREFIX "update"
#define SU_SCHEMA_VERSION 0
#define SU_LOCALE "en-US"
#endif /* HAVE_SOFTWARE_UPDATE */
#ifdef HAVE_SOFTWARE_UPDATE
#include "glib.h"
#ifdef _WIN32
#include <winsparkle.h>
#define SU_OSNAME "Windows"
#elif defined(__APPLE__)
#include <macosx/sparkle_bridge.h>
#define SU_OSNAME "macOS"
#else
#error HAVE_SOFTWARE_UPDATE can only be defined for Windows or macOS.
#endif
// https://sourceforge.net/p/predef/wiki/Architectures/
#if defined(__x86_64__) || defined(_M_X64)
#define SU_ARCH "x86-64"
#elif defined(__i386__) || defined(_M_IX86)
#define SU_ARCH "x86"
#elif defined(__arm64__) || defined(_M_ARM64)
#define SU_ARCH "arm64"
#else
#error HAVE_SOFTWARE_UPDATE can only be defined for x86-64 or x86 or arm64.
#endif
static char *get_appcast_update_url(software_update_channel_e chan) {
GString *update_url_str = g_string_new("");;
const char *chan_name;
const char *su_application = get_configuration_namespace();
const char *su_version = VERSION;
if (!is_packet_configuration_namespace()) {
su_version = LOG_VERSION;
}
switch (chan) {
case UPDATE_CHANNEL_DEVELOPMENT:
chan_name = "development";
break;
default:
chan_name = "stable";
break;
}
g_string_printf(update_url_str, "https://www.wireshark.org/%s/%u/%s/%s/%s/%s/en-US/%s.xml",
SU_SCHEMA_PREFIX,
SU_SCHEMA_VERSION,
su_application,
su_version,
SU_OSNAME,
SU_ARCH,
chan_name);
return g_string_free(update_url_str, FALSE);
}
#ifdef _WIN32
/** Initialize software updates.
*/
void
software_update_init(void) {
const char *update_url = get_appcast_update_url(prefs.gui_update_channel);
/*
* According to the WinSparkle 0.5 documentation these must be called
* once, before win_sparkle_init. We can't update them dynamically when
* our preferences change.
*/
win_sparkle_set_registry_path("Software\\Wireshark\\WinSparkle Settings");
win_sparkle_set_appcast_url(update_url);
win_sparkle_set_automatic_check_for_updates(prefs.gui_update_enabled ? 1 : 0);
win_sparkle_set_update_check_interval(prefs.gui_update_interval);
win_sparkle_set_can_shutdown_callback(software_update_can_shutdown_callback);
win_sparkle_set_shutdown_request_callback(software_update_shutdown_request_callback);
if ((language != NULL) && (strcmp(language, "system") != 0)) {
win_sparkle_set_lang(language);
}
win_sparkle_init();
}
/** Force a software update check.
*/
void
software_update_check(void) {
win_sparkle_check_update_with_ui();
}
/** Clean up software update checking.
*
* Does nothing on platforms that don't support software updates.
*/
extern void software_update_cleanup(void) {
win_sparkle_cleanup();
}
const char *software_update_info(void) {
return "WinSparkle " WIN_SPARKLE_VERSION_STRING;
}
#elif defined (__APPLE__)
/** Initialize software updates.
*/
void
software_update_init(void) {
char *update_url = get_appcast_update_url(prefs.gui_update_channel);
sparkle_software_update_init(update_url, prefs.gui_update_enabled, prefs.gui_update_interval);
g_free(update_url);
}
/** Force a software update check.
*/
void
software_update_check(void) {
sparkle_software_update_check();
}
/** Clean up software update checking.
*/
void software_update_cleanup(void) {
}
const char *software_update_info(void) {
return "Sparkle";
}
#endif
#else /* No updates */
/** Initialize software updates.
*/
void
software_update_init(void) {
}
/** Force a software update check.
*/
void
software_update_check(void) {
}
/** Clean up software update checking.
*/
void software_update_cleanup(void) {
}
const char *software_update_info(void) {
return NULL;
}
#endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */ |
C/C++ | wireshark/ui/software_update.h | /** @file
*
* Wrappers and routines to check for software updates.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __SOFTWARE_UPDATE_H__
#define __SOFTWARE_UPDATE_H__
/** @file
* Automatic update routines.
*
* Routines that integrate with WinSparkle on Windows and Sparkle on
* macOS.
* @ingroup main_ui_group
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** Initialize software updates.
*
* Does nothing on platforms that don't support software updates.
*/
extern void software_update_init(void);
/** Force a software update check.
*
* Does nothing on platforms that don't support software updates.
*/
extern void software_update_check(void);
/** Clean up software update checking.
*
* Does nothing on platforms that don't support software updates.
*/
extern void software_update_cleanup(void);
/** Fetch a description of the software update mechanism.
*
* @return NULL, "Sparkle", or "WinSparkle".
*/
extern const char *software_update_info(void);
#ifdef _WIN32
/** Check to see if Wireshark can shut down safely (e.g. offer to save the
* current capture). Called from a separate thread.
*
* Does nothing on platforms that don't support software updates.
*/
extern int software_update_can_shutdown_callback(void);
/** Shut down Wireshark in preparation for an upgrade. Called from a separate
* thread.
*
* Does nothing on platforms that don't support software updates.
*/
extern void software_update_shutdown_request_callback(void);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SOFTWARE_UPDATE_H__ */ |
C | wireshark/ui/ssl_key_export.c | /* export_sslkeys.c
*
* Export SSL Session Keys dialog
* by Sake Blok <[email protected]> (20110526)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <glib.h>
#include <epan/address.h>
#include <epan/dissectors/packet-tls-utils.h>
#include <wiretap/secrets-types.h>
#include "ui/ssl_key_export.h"
int
ssl_session_key_count(void)
{
int count = 0;
ssl_master_key_map_t *mk_map = tls_get_master_key_map(FALSE);
if (!mk_map)
return count;
GHashTableIter iter;
gpointer key;
g_hash_table_iter_init(&iter, mk_map->used_crandom);
while (g_hash_table_iter_next(&iter, &key, NULL)) {
if (g_hash_table_contains(mk_map->crandom, key)) {
count++;
}
if (g_hash_table_contains(mk_map->tls13_client_early, key)) {
count++;
}
if (g_hash_table_contains(mk_map->tls13_client_handshake, key)) {
count++;
}
if (g_hash_table_contains(mk_map->tls13_server_handshake, key)) {
count++;
}
if (g_hash_table_contains(mk_map->tls13_client_appdata, key)) {
count++;
}
if (g_hash_table_contains(mk_map->tls13_server_appdata, key)) {
count++;
}
}
return count;
}
static void
tls_export_client_randoms_func(gpointer key, gpointer value, gpointer user_data, const char* label)
{
guint i;
StringInfo *client_random = (StringInfo *)key;
StringInfo *master_secret = (StringInfo *)value;
GString *keylist = (GString *)user_data;
g_string_append(keylist, label);
for (i = 0; i < client_random->data_len; i++) {
g_string_append_printf(keylist, "%.2x", client_random->data[i]);
}
g_string_append_c(keylist, ' ');
for (i = 0; i < master_secret->data_len; i++) {
g_string_append_printf(keylist, "%.2x", master_secret->data[i]);
}
g_string_append_c(keylist, '\n');
}
gchar*
ssl_export_sessions(gsize *length)
{
/* Output format is:
* "CLIENT_RANDOM zzzz yyyy\n"
* Where zzzz is the client random (always 64 chars)
* Where yyyy is same as above
* So length will always be 13+1+64+1+96+2 = 177 chars
*
* Wireshark can read CLIENT_RANDOM since v1.8.0.
* Both values are exported in case you use the Session-ID for resuming a
* session in a different capture.
*
* TLS 1.3 derived secrets are similar to the CLIENT_RANDOM master secret
* export, but with a (longer) label indicating the type of derived secret
* to which the client random maps, e.g.
* "CLIENT_HANDSHAKE_TRAFFIC_SECRET zzzz yyyy\n"
*
* The TLS 1.3 values are obtained from an existing key log, but exporting
* them is useful in order to filter actually used secrets or add a DSB.
*/
ssl_master_key_map_t *mk_map = tls_get_master_key_map(FALSE);
if (!mk_map) {
*length = 0;
return g_strdup("");
}
gsize len = 177 * (gsize)ssl_session_key_count();
GString *keylist = g_string_sized_new(len);
GHashTableIter iter;
gpointer key, value;
g_hash_table_iter_init(&iter, mk_map->used_crandom);
while (g_hash_table_iter_next(&iter, &key, NULL)) {
if ((value = g_hash_table_lookup(mk_map->crandom, key))) {
tls_export_client_randoms_func(key, value, (gpointer)keylist, "CLIENT_RANDOM ");
}
if ((value = g_hash_table_lookup(mk_map->tls13_client_early, key))) {
tls_export_client_randoms_func(key, value, (gpointer)keylist, "CLIENT_EARLY_TRAFFIC_SECRET ");
}
if ((value = g_hash_table_lookup(mk_map->tls13_client_handshake, key))) {
tls_export_client_randoms_func(key, value, (gpointer)keylist, "CLIENT_HANDSHAKE_TRAFFIC_SECRET ");
}
if ((value = g_hash_table_lookup(mk_map->tls13_server_handshake, key))) {
tls_export_client_randoms_func(key, value, (gpointer)keylist, "SERVER_HANDSHAKE_TRAFFIC_SECRET ");
}
if ((value = g_hash_table_lookup(mk_map->tls13_server_appdata, key))) {
tls_export_client_randoms_func(key, value, (gpointer)keylist, "SERVER_TRAFFIC_SECRET_0 ");
}
if ((value = g_hash_table_lookup(mk_map->tls13_client_appdata, key))) {
tls_export_client_randoms_func(key, value, (gpointer)keylist, "CLIENT_TRAFFIC_SECRET_0 ");
}
#if 0
/* We don't use the EARLY_EXPORT_SECRET or EXPORTER_SECRET now so don't
export, but we may in the future. */
if ((value = g_hash_table_lookup(mk_map->tls13_early_exporter, key))) {
tls_export_client_randoms_func(key, value, (gpointer)keylist, "EARLY_EXPORTER_SECRET ");
}
if ((value = g_hash_table_lookup(mk_map->tls13_exporter, key))) {
tls_export_client_randoms_func(key, value, (gpointer)keylist, "EXPORTER_SECRET ");
}
#endif
}
*length = keylist->len;
return g_string_free(keylist, FALSE);
}
void
tls_export_dsb(capture_file *cf)
{
wtap_block_t block;
wtapng_dsb_mandatory_t *dsb;
size_t secrets_len;
char* secrets = ssl_export_sessions(&secrets_len);
block = wtap_block_create(WTAP_BLOCK_DECRYPTION_SECRETS);
dsb = (wtapng_dsb_mandatory_t *)wtap_block_get_mandatory_data(block);
dsb->secrets_type = SECRETS_TYPE_TLS;
dsb->secrets_data = g_memdup2(secrets, secrets_len);
dsb->secrets_len = (guint)secrets_len;
/* XXX - support replacing the DSB of the same type instead of adding? */
wtap_file_add_decryption_secrets(cf->provider.wth, block);
/* Mark the file as having unsaved changes */
cf->unsaved_changes = TRUE;
return;
} |
C/C++ | wireshark/ui/ssl_key_export.h | /** @file
*
* SSL session key utilities. Copied from ui/gkt/export_sslkeys.c
* by Sake Blok <[email protected]> (20110526)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __SSL_KEY_EXPORT_H__
#define __SSL_KEY_EXPORT_H__
#include "cfile.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** Return the number of available SSL session keys.
*
* @return The number of available SSL session keys.
*/
extern int ssl_session_key_count(void);
/** Dump our SSL Session Keys to a string
*
* @param[out] length Length of returned string.
*
* @return A string containing all the SSL Session Keys. Must be freed with
* g_free().
*/
extern gchar* ssl_export_sessions(gsize *length);
/** Add a DSB with the used TLS secrets to a capture file.
*
* @param cf The capture file
*/
extern void tls_export_dsb(capture_file *cf);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SSL_KEY_EXPORT_H__ */ |
C | wireshark/ui/summary.c | /* summary.c
* Routines for capture file summary info
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config.h>
#include <wiretap/pcap-encap.h>
#include <wiretap/wtap_opttypes.h>
#include <epan/packet.h>
#include <wsutil/file_util.h>
#include <gcrypt.h>
#include "cfile.h"
#include "ui/summary.h"
// Strongest to weakest
#define HASH_SIZE_SHA256 32
#define HASH_SIZE_SHA1 20
#define HASH_BUF_SIZE (1024 * 1024)
static void
tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
{
double cur_time;
sum_tally->bytes += cur_frame->pkt_len;
if (cur_frame->passed_dfilter){
sum_tally->filtered_count++;
sum_tally->filtered_bytes += cur_frame->pkt_len;
}
if (cur_frame->marked){
sum_tally->marked_count++;
sum_tally->marked_bytes += cur_frame->pkt_len;
}
if (cur_frame->ignored){
sum_tally->ignored_count++;
}
if (cur_frame->has_ts) {
/* This packet has a time stamp. */
cur_time = nstime_to_sec(&cur_frame->abs_ts);
sum_tally->packet_count_ts++;
if (cur_time < sum_tally->start_time) {
sum_tally->start_time = cur_time;
}
if (cur_time > sum_tally->stop_time){
sum_tally->stop_time = cur_time;
}
if (cur_frame->passed_dfilter){
sum_tally->filtered_count_ts++;
/*
* If we've seen one filtered packet, this is the first
* one.
*/
if (sum_tally->filtered_count == 1){
sum_tally->filtered_start= cur_time;
sum_tally->filtered_stop = cur_time;
} else {
if (cur_time < sum_tally->filtered_start) {
sum_tally->filtered_start = cur_time;
}
if (cur_time > sum_tally->filtered_stop) {
sum_tally->filtered_stop = cur_time;
}
}
}
if (cur_frame->marked){
sum_tally->marked_count_ts++;
/*
* If we've seen one marked packet, this is the first
* one.
*/
if (sum_tally->marked_count == 1){
sum_tally->marked_start= cur_time;
sum_tally->marked_stop = cur_time;
} else {
if (cur_time < sum_tally->marked_start) {
sum_tally->marked_start = cur_time;
}
if (cur_time > sum_tally->marked_stop) {
sum_tally->marked_stop = cur_time;
}
}
}
}
}
static void
hash_to_str(const unsigned char *hash, size_t length, char *str) {
int i;
for (i = 0; i < (int) length; i++) {
snprintf(str+(i*2), 3, "%02x", hash[i]);
}
}
void
summary_fill_in(capture_file *cf, summary_tally *st)
{
frame_data *first_frame, *cur_frame;
guint32 framenum;
iface_summary_info iface;
guint i;
wtapng_iface_descriptions_t* idb_info;
wtap_block_t wtapng_if_descr;
wtapng_if_descr_mandatory_t *wtapng_if_descr_mand;
wtap_block_t if_stats;
guint64 isb_ifdrop;
char* if_string;
if_filter_opt_t if_filter;
FILE *fh;
char *hash_buf;
gcry_md_hd_t hd;
size_t hash_bytes;
st->packet_count_ts = 0;
st->start_time = 0;
st->stop_time = 0;
st->bytes = 0;
st->filtered_count = 0;
st->filtered_count_ts = 0;
st->filtered_start = 0;
st->filtered_stop = 0;
st->filtered_bytes = 0;
st->marked_count = 0;
st->marked_count_ts = 0;
st->marked_start = 0;
st->marked_stop = 0;
st->marked_bytes = 0;
st->ignored_count = 0;
/* initialize the tally */
if (cf->count != 0) {
first_frame = frame_data_sequence_find(cf->provider.frames, 1);
st->start_time = nstime_to_sec(&first_frame->abs_ts);
st->stop_time = nstime_to_sec(&first_frame->abs_ts);
for (framenum = 1; framenum <= cf->count; framenum++) {
cur_frame = frame_data_sequence_find(cf->provider.frames, framenum);
tally_frame_data(cur_frame, st);
}
}
st->filename = cf->filename;
st->file_length = cf->f_datalen;
st->file_type = cf->cd_t;
st->compression_type = cf->compression_type;
st->is_tempfile = cf->is_tempfile;
st->file_encap_type = cf->lnk_t;
st->packet_encap_types = cf->linktypes;
st->snap = cf->snap;
st->elapsed_time = nstime_to_sec(&cf->elapsed_time);
st->packet_count = cf->count;
st->drops_known = cf->drops_known;
st->drops = cf->drops;
st->dfilter = cf->dfilter;
st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_summary_info));
idb_info = wtap_file_get_idb_info(cf->provider.wth);
for (i = 0; i < idb_info->interface_data->len; i++) {
wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_block_t, i);
wtapng_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(wtapng_if_descr);
if (wtap_block_get_if_filter_option_value(wtapng_if_descr, OPT_IDB_FILTER, &if_filter) == WTAP_OPTTYPE_SUCCESS) {
if (if_filter.type == if_filter_pcap) {
iface.cfilter = g_strdup(if_filter.data.filter_str);
} else {
/* Not a pcap filter string; punt for now */
iface.cfilter = NULL;
}
} else {
iface.cfilter = NULL;
}
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_NAME, &if_string) == WTAP_OPTTYPE_SUCCESS) {
iface.name = g_strdup(if_string);
} else {
iface.name = NULL;
}
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCRIPTION, &if_string) == WTAP_OPTTYPE_SUCCESS) {
iface.descr = g_strdup(if_string);
} else {
iface.descr = NULL;
}
iface.drops_known = FALSE;
iface.drops = 0;
iface.snap = wtapng_if_descr_mand->snap_len;
iface.encap_type = wtapng_if_descr_mand->wtap_encap;
iface.isb_comment = NULL;
if(wtapng_if_descr_mand->num_stat_entries == 1){
/* dumpcap only writes one ISB, only handle that for now */
if_stats = g_array_index(wtapng_if_descr_mand->interface_statistics, wtap_block_t, 0);
if (wtap_block_get_uint64_option_value(if_stats, OPT_ISB_IFDROP, &isb_ifdrop) == WTAP_OPTTYPE_SUCCESS) {
iface.drops_known = TRUE;
iface.drops = isb_ifdrop;
}
/* XXX: this doesn't get used, and might need to be g_strdup'ed when it does */
/* XXX - support multiple comments */
if (wtap_block_get_nth_string_option_value(if_stats, OPT_COMMENT, 0, &iface.isb_comment) != WTAP_OPTTYPE_SUCCESS) {
iface.isb_comment = NULL;
}
}
g_array_append_val(st->ifaces, iface);
}
g_free(idb_info);
(void) g_strlcpy(st->file_sha256, "<unknown>", HASH_STR_SIZE);
(void) g_strlcpy(st->file_sha1, "<unknown>", HASH_STR_SIZE);
gcry_md_open(&hd, GCRY_MD_SHA256, 0);
if (hd) {
gcry_md_enable(hd, GCRY_MD_SHA1);
}
hash_buf = (char *)g_malloc(HASH_BUF_SIZE);
fh = ws_fopen(cf->filename, "rb");
if (fh && hash_buf && hd) {
while((hash_bytes = fread(hash_buf, 1, HASH_BUF_SIZE, fh)) > 0) {
gcry_md_write(hd, hash_buf, hash_bytes);
}
gcry_md_final(hd);
hash_to_str(gcry_md_read(hd, GCRY_MD_SHA256), HASH_SIZE_SHA256, st->file_sha256);
hash_to_str(gcry_md_read(hd, GCRY_MD_SHA1), HASH_SIZE_SHA1, st->file_sha1);
}
if (fh) fclose(fh);
g_free(hash_buf);
gcry_md_close(hd);
}
#ifdef HAVE_LIBPCAP
void
summary_fill_in_capture(capture_file *cf,capture_options *capture_opts, summary_tally *st)
{
iface_summary_info iface;
interface_t *device;
guint i;
if (st->ifaces->len == 0) {
/*
* XXX - do this only if we have a live capture.
*/
for (i = 0; i < capture_opts->all_ifaces->len; i++) {
device = &g_array_index(capture_opts->all_ifaces, interface_t, i);
if (!device->selected) {
continue;
}
iface.cfilter = g_strdup(device->cfilter);
iface.name = g_strdup(device->name);
iface.descr = g_strdup(device->display_name);
iface.drops_known = cf->drops_known;
iface.drops = cf->drops;
iface.snap = device->snaplen;
iface.encap_type = wtap_pcap_encap_to_wtap_encap(device->active_dlt);
g_array_append_val(st->ifaces, iface);
}
}
}
#endif |
C/C++ | wireshark/ui/summary.h | /** @file
*
* Definitions for capture file summary data
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __SUMMARY_H__
#define __SUMMARY_H__
#ifdef HAVE_LIBPCAP
#include "ui/capture.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct iface_summary_info_tag {
char *name;
char *descr;
char *cfilter;
char *isb_comment;
guint64 drops; /**< number of packet drops */
gboolean drops_known; /**< TRUE if number of packet drops is known */
int snap; /**< Maximum captured packet length; 0 if not known */
int encap_type; /**< wiretap encapsulation type */
} iface_summary_info;
#define HASH_STR_SIZE (65) /* Max hash size * 2 + '\0' */
typedef struct _summary_tally {
guint64 bytes; /**< total bytes */
double start_time; /**< seconds, with msec resolution */
double stop_time; /**< seconds, with msec resolution */
double elapsed_time; /**< seconds, with msec resolution,
includes time before first packet
and after last packet */
guint32 marked_count; /**< number of marked packets */
guint32 marked_count_ts; /**< number of time-stamped marked packets */
guint64 marked_bytes; /**< total bytes in the marked packets */
double marked_start; /**< time in seconds, with msec resolution */
double marked_stop; /**< time in seconds, with msec resolution */
guint32 ignored_count; /**< number of ignored packets */
guint32 packet_count; /**< total number of packets in trace */
guint32 packet_count_ts; /**< total number of time-stamped packets in trace */
guint32 filtered_count; /**< number of filtered packets */
guint32 filtered_count_ts; /**< number of time-stamped filtered packets */
guint64 filtered_bytes; /**< total bytes in the filtered packets */
double filtered_start; /**< time in seconds, with msec resolution */
double filtered_stop; /**< time in seconds, with msec resolution */
const char *filename; /**< path of capture file */
gint64 file_length; /**< file length in bytes */
gchar file_sha256[HASH_STR_SIZE]; /**< SHA256 hash of capture file */
gchar file_sha1[HASH_STR_SIZE]; /**< SHA1 hash of capture file */
int file_type; /**< wiretap file type */
wtap_compression_type compression_type; /**< compression type of file, or uncompressed */
int file_encap_type; /**< wiretap encapsulation type for file */
GArray *packet_encap_types; /**< wiretap encapsulation types for packets */
int snap; /**< Maximum captured packet length; 0 if not known */
gboolean drops_known; /**< TRUE if number of packet drops is known */
guint64 drops; /**< number of packet drops */
const char *dfilter; /**< display filter */
gboolean is_tempfile;
/* capture related, use summary_fill_in_capture() to get values */
GArray *ifaces;
gboolean legacy;
} summary_tally;
extern void
summary_fill_in(capture_file *cf, summary_tally *st);
#ifdef HAVE_LIBPCAP
extern void
summary_fill_in_capture(capture_file *cf, capture_options *capture_opts, summary_tally *st);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* summary.h */ |
C/C++ | wireshark/ui/tap-credentials.h | /** @file
*
* Tap credentials data structure
* Copyright 2019 - Dario Lombardo <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_CREDENTIALS_H__
#define __TAP_CREDENTIALS_H__
#define TAP_CREDENTIALS_PLACEHOLDER "n.a."
typedef struct tap_credential {
guint num;
guint username_num;
guint password_hf_id;
gchar* username;
const gchar* proto;
gchar* info;
} tap_credential_t;
#endif |
C | wireshark/ui/tap-iax2-analysis.c | /* tap-iax2-analysis.c
* IAX2 analysis addition for Wireshark
*
* based on rtp_analysis.c
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* based on tap_rtp.c
* Copyright 2003, Iskratel, Ltd, Kranj
* By Miha Jemec <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <math.h>
#include <glib.h>
#include <epan/dissectors/packet-iax2.h>
#include "tap-iax2-analysis.h"
/****************************************************************************/
/* This comes from tap-rtp-common.c */
/****************************************************************************/
void
iax2_packet_analyse(tap_iax2_stat_t *statinfo,
packet_info *pinfo,
const struct _iax2_info_t *iax2info)
{
double current_time;
double current_jitter;
double current_diff;
statinfo->flags = 0;
/* check payload type */
if (iax2info->ftype == AST_FRAME_VOICE) {
if (iax2info->csub != statinfo->pt) {
statinfo->flags |= STAT_FLAG_PT_CHANGE;
}
statinfo->pt = iax2info->csub;
}
/* store the current time and calculate the current jitter */
current_time = nstime_to_sec(&pinfo->rel_ts);
current_diff = fabs (current_time - statinfo->time - (((double)iax2info->timestamp - (double)statinfo->timestamp)/1000));
current_jitter = statinfo->jitter + ( current_diff - statinfo->jitter)/16;
statinfo->delta = current_time - (statinfo->time);
statinfo->jitter = current_jitter;
statinfo->diff = current_diff;
/* calculate the BW in Kbps adding the IP+IAX2 header to the RTP -> 20bytes(IP)+ 4bytes(Mini) = 24bytes */
statinfo->bw_history[statinfo->bw_index].bytes = iax2info->payload_len + 24;
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+1) < 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;
}
};
statinfo->total_bytes += iax2info->payload_len + 24;
statinfo->bandwidth = (double)(statinfo->total_bytes*8)/1000;
statinfo->bw_index++;
if (statinfo->bw_index == BUFF_BW) {
statinfo->bw_index = 0;
}
/* is this the first packet we got in this direction? */
if (statinfo->first_packet) {
statinfo->start_seq_nr = 0;
statinfo->start_time = current_time;
statinfo->delta = 0;
statinfo->jitter = 0;
statinfo->diff = 0;
statinfo->flags |= STAT_FLAG_FIRST;
statinfo->first_packet = FALSE;
}
/* 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;
}
/* 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_jitter) / (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;
}
/* TODO: lost packets / duplicated: we should infer this from timestamp... */
statinfo->time = current_time;
statinfo->timestamp = iax2info->timestamp; /* millisecs */
statinfo->stop_seq_nr = 0;
statinfo->total_nr++;
return;
} |
C/C++ | wireshark/ui/tap-iax2-analysis.h | /** @file
*
* IAX2 analysis addition for Wireshark
*
* based on rtp_analysis.c
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* based on tap_rtp.c
* Copyright 2003, Iskratel, Ltd, Kranj
* By Miha Jemec <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_IAX2_ANALYSIS_H__
#define __TAP_IAX2_ANALYSIS_H__
#include <epan/address.h>
#include <epan/packet_info.h>
/** @file
* ???
* @todo what's this?
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
/* structure that holds the information about the forward and reversed direction */
typedef struct _iax2_bw_history_item {
double time;
guint32 bytes;
} iax2_bw_history_item;
#define BUFF_BW 300
typedef struct _tap_iax2_stat_t {
gboolean first_packet; /* do not use in code that is called after iax2_packet_analyse */
/* use (flags & STAT_FLAG_FIRST) instead */
/* all of the following fields will be initialized after
iax2_packet_analyse has been called */
guint32 flags; /* see STAT_FLAG-defines below */
guint16 seq_num;
guint32 timestamp;
guint32 delta_timestamp;
double bandwidth;
iax2_bw_history_item bw_history[BUFF_BW];
guint16 bw_start_index;
guint16 bw_index;
guint32 total_bytes;
double delta;
double jitter;
double diff;
double time;
double start_time;
double max_delta;
double max_jitter;
double mean_jitter;
guint32 max_nr;
guint16 start_seq_nr;
guint16 stop_seq_nr;
guint32 total_nr;
guint32 sequence;
gboolean under; /* Unused? */
gint cycles; /* Unused? */
guint16 pt;
int reg_pt;
} tap_iax2_stat_t;
#define PT_UNDEFINED -1
/* status flags for the flags parameter in tap_iax2_stat_t */
#define STAT_FLAG_FIRST 0x001
#define STAT_FLAG_MARKER 0x002
#define STAT_FLAG_WRONG_SEQ 0x004
#define STAT_FLAG_PT_CHANGE 0x008
#define STAT_FLAG_PT_CN 0x010
#define STAT_FLAG_FOLLOW_PT_CN 0x020
#define STAT_FLAG_REG_PT_CHANGE 0x040
#define STAT_FLAG_WRONG_TIMESTAMP 0x080
/* function for analysing an IAX2 packet. Called from iax2_analysis. */
extern void iax2_packet_analyse(tap_iax2_stat_t *statinfo,
packet_info *pinfo,
const struct _iax2_info_t *iax2info);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_IAX2_ANALYSIS_H__ */ |
C | wireshark/ui/tap-rlc-graph.c | /* tap-rlc-graph.c
* LTE RLC channel graph info
*
* Originally from tcp_graph.c by Pavel Mores <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include "tap-rlc-graph.h"
#include <file.h>
#include <frame_tvbuff.h>
#include <epan/epan_dissect.h>
#include <epan/tap.h>
/* Return TRUE if the 2 sets of parameters refer to the same channel. */
gboolean compare_rlc_headers(guint16 ueid1, guint16 channelType1, guint16 channelId1, guint8 rlcMode1, guint8 direction1,
guint16 ueid2, guint16 channelType2, guint16 channelId2, guint8 rlcMode2, guint8 direction2,
gboolean frameIsControl)
{
/* Same direction, data - OK. */
if (!frameIsControl) {
return (direction1 == direction2) &&
(ueid1 == ueid2) &&
(channelType1 == channelType2) &&
(channelId1 == channelId2) &&
(rlcMode1 == rlcMode2);
}
else {
/* Control case */
if ((rlcMode1 == RLC_AM_MODE) && (rlcMode2 == RLC_AM_MODE)) {
return ((direction1 != direction2) &&
(ueid1 == ueid2) &&
(channelType1 == channelType2) &&
(channelId1 == channelId2));
}
else {
return FALSE;
}
}
}
/* This is the tap function used to identify a list of channels found in the current frame. It is only used for the single,
currently selected frame. */
static tap_packet_status
tap_lte_rlc_packet(void *pct, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags _U_)
{
int n;
gboolean is_unique = TRUE;
th_t *th = (th_t *)pct;
const rlc_lte_tap_info *header = (const rlc_lte_tap_info*)vip;
/* Check new header details against any/all stored ones */
for (n=0; n < th->num_hdrs; n++) {
rlc_lte_tap_info *stored = th->rlchdrs[n];
if (compare_rlc_headers(stored->ueid, stored->channelType, stored->channelId, stored->rlcMode, stored->direction,
header->ueid, header->channelType, header->channelId, header->rlcMode, header->direction,
header->isControlPDU)) {
is_unique = FALSE;
break;
}
}
/* Add address if unique and have space for it */
if (is_unique && (th->num_hdrs < MAX_SUPPORTED_CHANNELS)) {
/* Copy the tap stuct in as next header */
/* Need to take a deep copy of the tap struct, it may not be valid
to read after this function returns? */
th->rlchdrs[th->num_hdrs] = g_new(rlc_lte_tap_info,1);
*(th->rlchdrs[th->num_hdrs]) = *header;
/* Store in direction of data though... */
if (th->rlchdrs[th->num_hdrs]->isControlPDU) {
th->rlchdrs[th->num_hdrs]->direction = !th->rlchdrs[th->num_hdrs]->direction;
}
th->num_hdrs++;
}
return TAP_PACKET_DONT_REDRAW; /* i.e. no immediate redraw requested */
}
/* Return an array of tap_info structs that were found while dissecting the current frame
* in the packet list. Errors are passed back to the caller, as they will be reported differently
* depending upon which GUI toolkit is being used. */
rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf,
struct rlc_segment *hdrs,
gchar **err_msg)
{
frame_data *fdata;
epan_dissect_t edt;
dfilter_t *sfcode;
GString *error_string;
nstime_t rel_ts;
/* Initialised to no known channels */
th_t th = {0, {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}};
if (cf->state == FILE_CLOSED) {
return NULL;
}
/* No real filter yet */
if (!dfilter_compile("rlc-lte", &sfcode, NULL)) {
return NULL;
}
/* Dissect the data from the current frame. */
if (!cf_read_current_record(cf)) {
dfilter_free(sfcode);
return NULL; /* error reading the record */
}
fdata = cf->current_frame;
/* Set tap listener that will populate th. */
error_string = register_tap_listener("rlc-lte", &th, NULL, 0, NULL, tap_lte_rlc_packet, NULL, NULL);
if (error_string){
fprintf(stderr, "wireshark: Couldn't register rlc_lte_graph tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
dfilter_free(sfcode);
exit(1); /* XXX: fix this */
}
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
epan_dissect_prime_with_dfilter(&edt, sfcode);
epan_dissect_run_with_taps(&edt, cf->cd_t, &cf->rec,
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
fdata, NULL);
rel_ts = edt.pi.rel_ts;
epan_dissect_cleanup(&edt);
remove_tap_listener(&th);
if (th.num_hdrs == 0){
/* This "shouldn't happen", as the graph menu items won't
* even be enabled if the selected packet isn't an RLC PDU.
*/
*err_msg = g_strdup("Selected packet doesn't have an RLC PDU");
return NULL;
}
/* XXX fix this later, we should show a dialog allowing the user
* to select which session he wants here */
if (th.num_hdrs>1){
/* Can only handle a single RLC channel yet */
*err_msg = g_strdup("The selected packet has more than one LTE RLC channel in it.");
return NULL;
}
/* For now, still always choose the first/only one */
hdrs->num = fdata->num;
hdrs->rel_secs = rel_ts.secs;
hdrs->rel_usecs = rel_ts.nsecs/1000;
hdrs->ueid = th.rlchdrs[0]->ueid;
hdrs->channelType = th.rlchdrs[0]->channelType;
hdrs->channelId = th.rlchdrs[0]->channelId;
hdrs->rlcMode = th.rlchdrs[0]->rlcMode;
hdrs->isControlPDU = th.rlchdrs[0]->isControlPDU;
/* Flip direction if have control PDU */
hdrs->direction = !hdrs->isControlPDU ? th.rlchdrs[0]->direction : !th.rlchdrs[0]->direction;
return th.rlchdrs[0];
}
/* This is the tapping function to update stats when dissecting the whole packet list */
static tap_packet_status rlc_lte_tap_for_graph_data(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags _U_)
{
struct rlc_graph *graph = (struct rlc_graph *)pct;
const rlc_lte_tap_info *rlchdr = (const rlc_lte_tap_info*)vip;
/* See if this one matches graph's channel */
if (compare_rlc_headers(graph->ueid, graph->channelType, graph->channelId, graph->rlcMode, graph->direction,
rlchdr->ueid, rlchdr->channelType, rlchdr->channelId, rlchdr->rlcMode, rlchdr->direction,
rlchdr->isControlPDU)) {
/* It matches. Copy segment details out of tap struct */
struct rlc_segment *segment = g_new(struct rlc_segment, 1);
segment->next = NULL;
segment->num = pinfo->num;
segment->rel_secs = (guint32) pinfo->rel_ts.secs;
segment->rel_usecs = pinfo->rel_ts.nsecs/1000;
segment->ueid = rlchdr->ueid;
segment->channelType = rlchdr->channelType;
segment->channelId = rlchdr->channelId;
segment->direction = rlchdr->direction;
segment->rlcMode = rlchdr->rlcMode;
segment->isControlPDU = rlchdr->isControlPDU;
if (!rlchdr->isControlPDU) {
/* Data */
segment->SN = rlchdr->sequenceNumber;
segment->isResegmented = rlchdr->isResegmented;
segment->pduLength = rlchdr->pduLength;
}
else {
/* Status PDU */
gint n;
segment->ACKNo = rlchdr->ACKNo;
segment->noOfNACKs = rlchdr->noOfNACKs;
for (n=0; n < rlchdr->noOfNACKs; n++) {
segment->NACKs[n] = rlchdr->NACKs[n];
}
}
/* Add segment to end of list */
if (graph->segments) {
/* Add to end of existing last element */
graph->last_segment->next = segment;
} else {
/* Make this the first (only) segment */
graph->segments = segment;
}
/* This one is now the last one */
graph->last_segment = segment;
}
return TAP_PACKET_DONT_REDRAW; /* i.e. no immediate redraw requested */
}
/* If don't have a channel, try to get one from current frame, then read all frames looking for data
* for that channel. */
gboolean rlc_graph_segment_list_get(capture_file *cf, struct rlc_graph *g, gboolean stream_known,
char **err_string)
{
struct rlc_segment current;
GString *error_string;
if (!cf || !g) {
/* Really shouldn't happen */
return FALSE;
}
if (!stream_known) {
struct rlc_lte_tap_info *header = select_rlc_lte_session(cf, ¤t, err_string);
if (!header) {
/* Didn't have a channel, and current frame didn't provide one */
return FALSE;
}
g->channelSet = TRUE;
g->ueid = header->ueid;
g->channelType = header->channelType;
g->channelId = header->channelId;
g->rlcMode = header->rlcMode;
g->direction = header->direction;
}
/* Rescan all the packets and pick up all interesting RLC headers.
* We only filter for rlc-lte here for speed and do the actual compare
* in the tap listener
*/
g->last_segment = NULL;
error_string = register_tap_listener("rlc-lte", g, "rlc-lte", 0, NULL, rlc_lte_tap_for_graph_data, NULL, NULL);
if (error_string) {
fprintf(stderr, "wireshark: Couldn't register rlc_graph tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
exit(1); /* XXX: fix this */
}
cf_retap_packets(cf);
remove_tap_listener(g);
if (g->last_segment == NULL) {
*err_string = g_strdup("No packets found");
return FALSE;
}
return TRUE;
}
/* Free and zero the segments list of an rlc_graph struct */
void rlc_graph_segment_list_free(struct rlc_graph * g)
{
struct rlc_segment *segment;
/* Free all segments */
while (g->segments) {
segment = g->segments->next;
g_free(g->segments);
g->segments = segment;
}
} |
C/C++ | wireshark/ui/tap-rlc-graph.h | /** @file
*
* LTE RLC stream statistics
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_RLC_GRAPH_H__
#define __TAP_RLC_GRAPH_H__
#include <epan/epan.h>
#include <epan/packet.h>
#include <cfile.h>
#include <epan/dissectors/packet-rlc-lte.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct rlc_segment {
struct rlc_segment *next;
guint32 num; /* framenum */
time_t rel_secs;
guint32 rel_usecs;
gboolean isControlPDU;
guint16 SN;
guint16 isResegmented;
guint16 ACKNo;
#define MAX_NACKs 128
guint16 noOfNACKs;
guint16 NACKs[MAX_NACKs];
guint16 pduLength;
guint16 ueid;
guint16 channelType;
guint16 channelId;
guint8 rlcMode;
guint8 direction;
};
/* A collection of channels that may be found in one frame. Used when working out
which channel(s) are present in a frame. */
typedef struct _th_t {
int num_hdrs;
#define MAX_SUPPORTED_CHANNELS 8
rlc_lte_tap_info *rlchdrs[MAX_SUPPORTED_CHANNELS];
} th_t;
struct rlc_graph {
/* List of segments to show */
struct rlc_segment *segments;
struct rlc_segment *last_segment;
/* These are filled in with the channel/direction this graph is showing */
gboolean channelSet;
guint16 ueid;
guint16 channelType;
guint16 channelId;
guint8 rlcMode;
guint8 direction;
};
gboolean rlc_graph_segment_list_get(capture_file *cf, struct rlc_graph *tg, gboolean stream_known,
char **err_string);
void rlc_graph_segment_list_free(struct rlc_graph * );
gboolean compare_rlc_headers(guint16 ueid1, guint16 channelType1, guint16 channelId1, guint8 rlcMode1, guint8 direction1,
guint16 ueid2, guint16 channelType2, guint16 channelId2, guint8 rlcMode2, guint8 direction2,
gboolean isControlFrame);
rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct rlc_segment *hdrs,
gchar **err_msg);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif |
C | wireshark/ui/tap-rtp-analysis.c | /* tap-rtp-analysis.c
* RTP stream handler functions used by tshark and wireshark
*
* Copyright 2008, Ericsson AB
* By Balint Reczey <[email protected]>
*
* most functions are copied from ui/gtk/rtp_stream.c and ui/gtk/rtp_analysis.c
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <glib.h>
#include <math.h>
#include "globals.h"
#include <string.h>
#include <epan/rtp_pt.h>
#include <epan/addr_resolv.h>
#include <epan/proto_data.h>
#include <epan/dissectors/packet-rtp.h>
#include "rtp_stream.h"
#include "tap-rtp-common.h"
#include "tap-rtp-analysis.h"
typedef struct _key_value {
guint32 key;
guint32 value;
} key_value;
/* RTP sampling clock rates for fixed payload types as defined in
https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml */
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},
};
#define NUM_CLOCK_VALUES (sizeof clock_map / sizeof clock_map[0])
static guint32
get_clock_rate(guint32 key)
{
size_t i;
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;
} 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
media subtype"
https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml.
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] */
};
#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;
/* 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;
}
#define TIMESTAMP_DIFFERENCE(v1,v2) ((gint64)v2-(gint64)v1)
/****************************************************************************/
void
rtppacket_analyse(tap_rtp_stat_t *statinfo,
const packet_info *pinfo,
const struct _rtp_info *rtpinfo)
{
double current_time;
double current_jitter = 0;
double current_diff = 0;
double nominaltime;
double nominaltime_diff;
double arrivaltime;
double expected_time;
double absskew;
guint32 clock_rate;
gboolean in_time_sequence;
/* 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) {
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->seq_timestamp = rtpinfo->info_timestamp;
statinfo->first_timestamp = rtpinfo->info_timestamp;
statinfo->time = current_time;
statinfo->lastnominaltime = 0;
statinfo->lastarrivaltime = 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->max_delta = 0;
statinfo->min_delta = -1;
statinfo->mean_delta = 0;
statinfo->jitter = 0;
statinfo->min_jitter = -1;
statinfo->max_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;
/* When calculating expected rtp packets the seq number can wrap around
* so we have to count the number of cycles
* Variable seq_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.
*/
/* Check if time sequence of packets is in order. We check whether
* timestamp difference is below 1/2 of timestamp range (hours or days).
* Packets can be in pure sequence or sequence can be wrapped arround
* 0xFFFFFFFF.
*/
if ((statinfo->first_timestamp <= rtpinfo->info_timestamp) &&
TIMESTAMP_DIFFERENCE(statinfo->first_timestamp, rtpinfo->info_timestamp) < 0x80000000) {
// Normal timestamp sequence
in_time_sequence = TRUE;
} else if ((statinfo->first_timestamp > rtpinfo->info_timestamp) &&
(TIMESTAMP_DIFFERENCE(statinfo->first_timestamp, 0xFFFFFFFF) + TIMESTAMP_DIFFERENCE(0x00000000, rtpinfo->info_timestamp)) < 0x80000000) {
// Normal timestamp sequence with wraparound
in_time_sequence = TRUE;
} else {
// New packet is not in sequence (is in past)
in_time_sequence = FALSE;
statinfo->flags |= STAT_FLAG_WRONG_TIMESTAMP;
}
/* 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) &&
in_time_sequence &&
(statinfo->under == FALSE)) {
statinfo->seq_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) &&
in_time_sequence &&
(statinfo->under == FALSE)) {
statinfo->seq_cycles++;
statinfo->under = TRUE;
}
/* the whole round is over, so reset the flag */
else if ((rtpinfo->info_seq_num > statinfo->start_seq_nr) &&
in_time_sequence &&
(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 ( in_time_sequence &&
( (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 ( in_time_sequence &&
( (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://gitlab.com/wireshark/wireshark/-/issues/5958 */
else if ( in_time_sequence &&
(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;
}
}
/* diff/jitter/skew calculations are done just for in sequence packets */
/* Note, "in_time_sequence" just means relative to the first packet in
* stream (within 0x80000000), excluding packets that are before the first
* packet in timestamp (or implausibly far away.)
* XXX: Do we really need to exclude those? The underlying problem in
* #16330 was not allowing the time difference to be negative.
*/
if ( in_time_sequence || TRUE ) {
/* XXX: We try to handle clock rate changes, but if the clock rate
* changed during a dropped packet (or if we go backwards because
* a packet is reorderd), it won't be quite right.
*/
nominaltime_diff = (double)(TIMESTAMP_DIFFERENCE(statinfo->seq_timestamp, rtpinfo->info_timestamp));
/* Can only analyze defined sampling rates */
if (clock_rate != 0) {
statinfo->clock_rate = clock_rate;
/* Convert from sampling clock to ms */
nominaltime_diff = nominaltime_diff /(clock_rate/1000);
/* Calculate the current jitter(in ms) */
if (!statinfo->first_packet) {
expected_time = statinfo->time + nominaltime_diff;
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;
}
nominaltime = statinfo->lastnominaltime + nominaltime_diff;
arrivaltime = statinfo->lastarrivaltime + statinfo->delta;
/* 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);
}
#endif
/* Gather data for calculation of skew least square */
statinfo->sumt += 1.0 * arrivaltime;
statinfo->sumTS += 1.0 * nominaltime;
statinfo->sumt2 += 1.0 * arrivaltime * arrivaltime;
statinfo->sumtTS += 1.0 * arrivaltime * nominaltime;
statinfo->lastnominaltime = nominaltime;
statinfo->lastarrivaltime = arrivaltime;
} else {
if (!statinfo->first_packet) {
statinfo->delta = current_time-(statinfo->time);
}
}
}
/* 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;
/* Is it a packet with the mark bit set? */
if (rtpinfo->info_marker_set) {
statinfo->flags |= STAT_FLAG_MARKER;
}
/* 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;
}
/* Include it in minimum delta calculation */
if (statinfo->min_delta == -1 ) {
statinfo->min_delta = statinfo->delta;
} else if (statinfo->delta < statinfo->min_delta) {
statinfo->min_delta = statinfo->delta;
}
/* Mean delta calculation; average over the deltas between packets.
* For N packets there are N-1 deltas between them. The first packet
* has total_nr == 1, but here while we're processing the Nth
* packet, total_nr isn't incremented yet.
* E.g., when we arrive here and total_nr == 1, we're actually on
* packet #2, and thus, the first delta. So interestingly, when we
* divide by total_nr here, we're not dividing by the number of
* packets, but by the number of deltas.
* Important: total_nr here is never 0; when the first packet is
* handled, that logic increments total_nr from 0 to 1; here, it is
* always >=1 .
*/
statinfo->mean_delta = (statinfo->mean_delta*(statinfo->total_nr-1) + statinfo->delta) / statinfo->total_nr;
if (clock_rate != 0) {
/* Maximum and mean jitter calculation */
if (statinfo->jitter > statinfo->max_jitter) {
statinfo->max_jitter = statinfo->jitter;
}
/* Mean jitter calculation; average over the diffs between packets.
* For N packets there are N-1 diffs between them. The first packet
* has total_nr == 1, but here while we're processing the Nth
* packet, total_nr isn't incremented yet.
* E.g., when we arrive here and total_nr == 1, we're actually on
* packet #2, and thus, the first diff. So interestingly, when we
* divide by total_nr here, we're not dividing by the number of
* packets, but by the number of diffs.
* Important: total_nr here is never 0; when the first packet is
* handled, that logic increments total_nr from 0 to 1; here, it is
* always >=1 .
*/
statinfo->mean_jitter = (statinfo->mean_jitter*(statinfo->total_nr-1) + current_jitter) / statinfo->total_nr;
/* Minimum jitter calculation */
if (statinfo->min_jitter == -1 ) {
statinfo->min_jitter = statinfo->jitter;
} else if (statinfo->jitter < statinfo->min_jitter) {
statinfo->min_jitter = statinfo->jitter;
}
}
}
/* 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;
}
if (in_time_sequence) {
/* We remember last time just for in_time sequence packets
* therefore diff calculations are correct for it
*/
statinfo->time = current_time;
statinfo->seq_timestamp = rtpinfo->info_timestamp;
}
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;
} |
C/C++ | wireshark/ui/tap-rtp-analysis.h | /** @file
*
* RTP analysis addition for Wireshark
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* based on tap_rtp.c
* Copyright 2003, Iskratel, Ltd, Kranj
* By Miha Jemec <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_RTP_ANALYSIS_H__
#define __TAP_RTP_ANALYSIS_H__
#include <epan/address.h>
#include <epan/packet_info.h>
/** @file
* ???
* @todo what's this?
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
/* structure that holds the information about the forward and reversed direction */
typedef struct _bw_history_item {
double time;
guint32 bytes;
} bw_history_item;
#define BUFF_BW 300
typedef struct _tap_rtp_stat_t {
gboolean first_packet; /**< do not use in code that is called after rtppacket_analyse */
/* use (flags & STAT_FLAG_FIRST) instead */
/* all of the following fields will be initialized after
* rtppacket_analyse has been called
*/
guint32 flags; /* see STAT_FLAG-defines below */
guint16 seq_num;
guint32 timestamp;
guint32 seq_timestamp;
guint32 first_timestamp;
double bandwidth;
bw_history_item bw_history[BUFF_BW];
guint16 bw_start_index;
guint16 bw_index;
guint32 total_bytes;
guint32 clock_rate;
double delta;
double jitter;
double diff;
double skew;
double sumt;
double sumTS;
double sumt2;
double sumtTS;
double time; /**< Unit is ms */
double start_time; /**< Unit is ms */
double lastnominaltime;
double lastarrivaltime;
double min_delta;
double max_delta;
double mean_delta;
double min_jitter;
double max_jitter;
double max_skew;
double mean_jitter;
guint32 max_nr;
guint16 start_seq_nr;
guint16 stop_seq_nr;
guint32 total_nr;
guint32 sequence;
gboolean under;
gint seq_cycles;
guint16 pt;
int reg_pt;
guint32 first_packet_num;
guint last_payload_len;
} tap_rtp_stat_t;
typedef struct _tap_rtp_save_data_t {
guint32 timestamp;
unsigned int payload_type;
size_t payload_len;
} tap_rtp_save_data_t;
#define PT_UNDEFINED -1
/* status flags for the flags parameter in tap_rtp_stat_t */
#define STAT_FLAG_FIRST 0x001
#define STAT_FLAG_MARKER 0x002
#define STAT_FLAG_WRONG_SEQ 0x004
#define STAT_FLAG_PT_CHANGE 0x008
#define STAT_FLAG_PT_CN 0x010
#define STAT_FLAG_FOLLOW_PT_CN 0x020
#define STAT_FLAG_REG_PT_CHANGE 0x040
#define STAT_FLAG_WRONG_TIMESTAMP 0x080
#define STAT_FLAG_PT_T_EVENT 0x100
#define STAT_FLAG_DUP_PKT 0x200
/* forward */
struct _rtp_info;
/* function for analysing an RTP packet. Called from rtp_analysis and rtp_streams */
extern void rtppacket_analyse(tap_rtp_stat_t *statinfo,
const packet_info *pinfo,
const struct _rtp_info *rtpinfo);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_RTP_ANALYSIS_H__ */ |
C | wireshark/ui/tap-rtp-common.c | /* tap-rtp-common.c
* RTP stream handler functions used by tshark and wireshark
*
* Copyright 2008, Ericsson AB
* By Balint Reczey <[email protected]>
*
* most functions are copied from ui/gtk/rtp_stream.c and ui/gtk/rtp_analysis.c
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <glib.h>
#include <epan/rtp_pt.h>
#include <epan/addr_resolv.h>
#include <epan/proto_data.h>
#include <epan/dissectors/packet-rtp.h>
#include <wsutil/pint.h>
#include "rtp_stream.h"
#include "tap-rtp-common.h"
/* XXX: are changes needed to properly handle situations where
info_all_data_present == FALSE ?
E.G., when captured frames are truncated.
*/
/****************************************************************************/
/* Type for storing and writing rtpdump information */
typedef struct st_rtpdump_info {
double rec_time; /**< milliseconds since start of recording */
guint16 num_samples; /**< number of bytes in *frame */
const guint8 *samples; /**< data bytes */
} rtpdump_info_t;
/****************************************************************************/
/* init rtpstream_info_t structure */
void rtpstream_info_init(rtpstream_info_t *info)
{
memset(info, 0, sizeof(rtpstream_info_t));
}
/****************************************************************************/
/* malloc and init rtpstream_info_t structure */
rtpstream_info_t *rtpstream_info_malloc_and_init(void)
{
rtpstream_info_t *dest;
dest = g_new(rtpstream_info_t, 1);
rtpstream_info_init(dest);
return dest;
}
/****************************************************************************/
/* deep copy of rtpstream_info_t */
void rtpstream_info_copy_deep(rtpstream_info_t *dest, const rtpstream_info_t *src)
{
/* Deep clone of contents */
*dest = *src; /* memberwise copy of struct */
copy_address(&(dest->id.src_addr), &(src->id.src_addr));
copy_address(&(dest->id.dst_addr), &(src->id.dst_addr));
dest->all_payload_type_names = g_strdup(src->all_payload_type_names);
}
/****************************************************************************/
/* malloc and deep copy rtpstream_info_t structure */
rtpstream_info_t *rtpstream_info_malloc_and_copy_deep(const rtpstream_info_t *src)
{
rtpstream_info_t *dest;
dest = g_new(rtpstream_info_t, 1);
rtpstream_info_copy_deep(dest, src);
return dest;
}
/****************************************************************************/
/* free rtpstream_info_t referenced values */
void rtpstream_info_free_data(rtpstream_info_t *info)
{
if (info->all_payload_type_names != NULL) {
g_free(info->all_payload_type_names);
}
rtpstream_id_free(&info->id);
}
/****************************************************************************/
/* free rtpstream_info_t referenced values and whole structure */
void rtpstream_info_free_all(rtpstream_info_t *info)
{
rtpstream_info_free_data(info);
g_free(info);
}
/****************************************************************************/
/* GCompareFunc style comparison function for rtpstream_info_t */
gint rtpstream_info_cmp(gconstpointer aa, gconstpointer bb)
{
const rtpstream_info_t *a = (const rtpstream_info_t *)aa;
const rtpstream_info_t *b = (const rtpstream_info_t *)bb;
if (a==b)
return 0;
if (a==NULL || b==NULL)
return 1;
if (rtpstream_id_equal(&(a->id),&(b->id),RTPSTREAM_ID_EQUAL_SSRC))
return 0;
else
return 1;
}
/****************************************************************************/
/* compare the endpoints of two RTP streams */
gboolean rtpstream_info_is_reverse(const rtpstream_info_t *stream_a, rtpstream_info_t *stream_b)
{
if (stream_a == NULL || stream_b == NULL)
return FALSE;
if ((addresses_equal(&(stream_a->id.src_addr), &(stream_b->id.dst_addr)))
&& (stream_a->id.src_port == stream_b->id.dst_port)
&& (addresses_equal(&(stream_a->id.dst_addr), &(stream_b->id.src_addr)))
&& (stream_a->id.dst_port == stream_b->id.src_port))
return TRUE;
else
return FALSE;
}
/****************************************************************************/
/* when there is a [re]reading of packet's */
void rtpstream_reset(rtpstream_tapinfo_t *tapinfo)
{
GList* list;
rtpstream_info_t *stream_info;
if (tapinfo->mode == TAP_ANALYSE) {
/* free the data items first */
if (tapinfo->strinfo_hash) {
g_hash_table_foreach(tapinfo->strinfo_hash, rtpstream_info_multihash_destroy_value, NULL);
g_hash_table_destroy(tapinfo->strinfo_hash);
}
list = g_list_first(tapinfo->strinfo_list);
while (list)
{
stream_info = (rtpstream_info_t *)(list->data);
rtpstream_info_free_data(stream_info);
g_free(list->data);
list = g_list_next(list);
}
g_list_free(tapinfo->strinfo_list);
tapinfo->strinfo_list = NULL;
tapinfo->strinfo_hash = 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);
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
/****************************************************************************/
/* redraw the output */
static void rtpstream_draw_cb(void *ti_ptr)
{
rtpstream_tapinfo_t *tapinfo = (rtpstream_tapinfo_t *)ti_ptr;
/* XXX: see rtpstream_on_update in rtp_streams_dlg.c for comments
g_signal_emit_by_name(top_level, "signal_rtpstream_update");
*/
if (tapinfo && tapinfo->tap_draw) {
/* RTP_STREAM_DEBUG("streams: %d packets: %d", tapinfo->nstreams, tapinfo->npackets); */
tapinfo->tap_draw(tapinfo);
}
return;
}
/****************************************************************************/
void
remove_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo)
{
if (tapinfo && tapinfo->is_registered) {
remove_tap_listener(tapinfo);
tapinfo->is_registered = FALSE;
}
}
/****************************************************************************/
void
register_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo, const char *fstring, rtpstream_tap_error_cb tap_error)
{
GString *error_string;
if (!tapinfo) {
return;
}
if (!tapinfo->is_registered) {
error_string = register_tap_listener("rtp", tapinfo,
fstring, 0, rtpstream_reset_cb, rtpstream_packet_cb,
rtpstream_draw_cb, NULL);
if (error_string != NULL) {
if (tap_error) {
tap_error(error_string);
}
g_string_free(error_string, TRUE);
exit(1);
}
tapinfo->is_registered = TRUE;
}
}
/*
* rtpdump file format
*
* The file starts with the tool to be used for playing this file,
* the multicast/unicast receive address and the port.
*
* #!rtpplay1.0 224.2.0.1/3456\n
*
* This is followed by one binary header (RD_hdr_t) and one RD_packet_t
* structure for each received packet. All fields are in network byte
* order. We don't need the source IP address since we can do mapping
* based on SSRC. This saves (a little) space, avoids non-IPv4
* problems and privacy/security concerns. The header is followed by
* the RTP/RTCP header and (optionally) the actual payload.
*/
static const gchar *PAYLOAD_UNKNOWN_STR = "Unknown";
static void update_payload_names(rtpstream_info_t *stream_info, const struct _rtp_info *rtpinfo)
{
GString *payload_type_names;
const gchar *new_payload_type_str;
/* Ensure that we have non empty payload_type_str */
if (rtpinfo->info_payload_type_str != NULL) {
new_payload_type_str = rtpinfo->info_payload_type_str;
}
else {
/* String is created from const strings only */
new_payload_type_str = val_to_str_ext_const(rtpinfo->info_payload_type,
&rtp_payload_type_short_vals_ext,
PAYLOAD_UNKNOWN_STR
);
}
stream_info->payload_type_names[rtpinfo->info_payload_type] = new_payload_type_str;
/* Join all existing payload names to one string */
payload_type_names = g_string_sized_new(40); /* Preallocate memory */
for(int i=0; i<256; i++) {
if (stream_info->payload_type_names[i] != NULL) {
if (payload_type_names->len > 0) {
g_string_append(payload_type_names, ", ");
}
g_string_append(payload_type_names, stream_info->payload_type_names[i]);
}
}
if (stream_info->all_payload_type_names != NULL) {
g_free(stream_info->all_payload_type_names);
}
stream_info->all_payload_type_names = payload_type_names->str;
g_string_free(payload_type_names, FALSE);
}
gboolean rtpstream_is_payload_used(const rtpstream_info_t *stream_info, const guint8 payload_type)
{
return stream_info->payload_type_names[payload_type] != NULL;
}
#define RTPFILE_VERSION "1.0"
/*
* Write a header to the current output file.
* The header consists of an identifying string, followed
* by a binary structure.
*/
void rtp_write_header(rtpstream_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->id.dst_addr));
fprintf(file, "#!rtpplay%s %s/%u\n", RTPFILE_VERSION,
addr_str,
strinfo->id.dst_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 / 1000);
/* rtpdump only accepts guint32 as source, will be fake for IPv6 */
memset(&source, 0, sizeof source);
sourcelen = strinfo->id.src_addr.len;
if (sourcelen > sizeof source)
sourcelen = sizeof source;
memcpy(&source, strinfo->id.src_addr.data, sourcelen);
port = g_htons(strinfo->id.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;
}
/****************************************************************************/
/* whenever a RTP packet is seen by the tap listener */
tap_packet_status rtpstream_packet_cb(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2, tap_flags_t flags _U_)
{
rtpstream_tapinfo_t *tapinfo = (rtpstream_tapinfo_t *)arg;
const struct _rtp_info *rtpinfo = (const struct _rtp_info *)arg2;
rtpstream_id_t new_stream_id;
rtpstream_info_t *stream_info = NULL;
rtpdump_info_t rtpdump_info;
/* gather infos on the stream this packet is part of.
* Shallow copy addresses as this is just for examination. */
rtpstream_id_copy_pinfo_shallow(pinfo,&new_stream_id,FALSE);
new_stream_id.ssrc = rtpinfo->info_sync_src;
if (tapinfo->mode == TAP_ANALYSE) {
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* check whether we already have a stream with these parameters in the list */
if (tapinfo->strinfo_hash) {
stream_info = rtpstream_info_multihash_lookup(tapinfo->strinfo_hash, &new_stream_id);
}
/* not in the list? then create a new entry */
if (!stream_info) {
/* init info and collect id */
stream_info = rtpstream_info_malloc_and_init();
/* Deep copy addresses for the new entry. */
rtpstream_id_copy_pinfo(pinfo,&(stream_info->id),FALSE);
stream_info->id.ssrc = rtpinfo->info_sync_src;
/* init counters for first packet */
rtpstream_info_analyse_init(stream_info, pinfo, rtpinfo);
/* add it to hash */
tapinfo->strinfo_list = g_list_prepend(tapinfo->strinfo_list, stream_info);
if (!tapinfo->strinfo_hash) {
tapinfo->strinfo_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
}
rtpstream_info_multihash_insert(tapinfo->strinfo_hash, stream_info);
}
/* update analysis counters */
rtpstream_info_analyse_process(stream_info, pinfo, rtpinfo);
/* increment the packets counter of all streams */
++(tapinfo->npackets);
return TAP_PACKET_REDRAW; /* refresh output */
}
else if (tapinfo->mode == TAP_SAVE) {
if (rtpstream_id_equal(&new_stream_id, &(tapinfo->filter_stream_fwd->id), RTPSTREAM_ID_EQUAL_SSRC)) {
/* 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 (rtpstream_id_equal(&new_stream_id, &(tapinfo->filter_stream_fwd->id), RTPSTREAM_ID_EQUAL_SSRC)
|| rtpstream_id_equal(&new_stream_id, &(tapinfo->filter_stream_rev->id), RTPSTREAM_ID_EQUAL_SSRC))
{
tapinfo->tap_mark_packet(tapinfo, pinfo->fd);
}
}
return TAP_PACKET_DONT_REDRAW;
}
/****************************************************************************/
/* evaluate rtpstream_info_t calculations */
/* - code is gathered from existing GTK/Qt/tui sources related to RTP statistics calculation
* - one place for calculations ensures that all wireshark tools shows same output for same input and avoids code duplication
*/
void rtpstream_info_calculate(const rtpstream_info_t *strinfo, rtpstream_info_calc_t *calc)
{
double sumt;
double sumTS;
double sumt2;
double sumtTS;
double clock_drift_x;
guint32 clock_rate_x;
double duration_x;
calc->src_addr_str = address_to_display(NULL, &(strinfo->id.src_addr));
calc->src_port = strinfo->id.src_port;
calc->dst_addr_str = address_to_display(NULL, &(strinfo->id.dst_addr));
calc->dst_port = strinfo->id.dst_port;
calc->ssrc = strinfo->id.ssrc;
calc->all_payload_type_names = wmem_strdup(NULL, strinfo->all_payload_type_names);
calc->packet_count = strinfo->packet_count;
/* packet count, lost packets */
calc->packet_expected = (strinfo->rtp_stats.stop_seq_nr + strinfo->rtp_stats.seq_cycles*0x10000)
- strinfo->rtp_stats.start_seq_nr + 1;
calc->total_nr = strinfo->rtp_stats.total_nr;
calc->lost_num = calc->packet_expected - strinfo->rtp_stats.total_nr;
if (calc->packet_expected) {
calc->lost_perc = (double)(calc->lost_num*100)/(double)calc->packet_expected;
} else {
calc->lost_perc = 0;
}
calc->max_delta = strinfo->rtp_stats.max_delta;
calc->min_delta = strinfo->rtp_stats.min_delta;
calc->mean_delta = strinfo->rtp_stats.mean_delta;
calc->min_jitter = strinfo->rtp_stats.min_jitter;
calc->max_jitter = strinfo->rtp_stats.max_jitter;
calc->mean_jitter = strinfo->rtp_stats.mean_jitter;
calc->max_skew = strinfo->rtp_stats.max_skew;
calc->problem = strinfo->problem;
sumt = strinfo->rtp_stats.sumt;
sumTS = strinfo->rtp_stats.sumTS;
sumt2 = strinfo->rtp_stats.sumt2;
sumtTS = strinfo->rtp_stats.sumtTS;
duration_x = strinfo->rtp_stats.time - strinfo->rtp_stats.start_time;
if ((calc->packet_count >0) && (sumt2 > 0)) {
clock_drift_x = (calc->packet_count * sumtTS - sumt * sumTS) / (calc->packet_count * sumt2 - sumt * sumt);
calc->clock_drift_ms = duration_x * (clock_drift_x - 1.0);
clock_rate_x = (guint32)(strinfo->rtp_stats.clock_rate * clock_drift_x);
calc->freq_drift_hz = clock_drift_x * clock_rate_x;
calc->freq_drift_perc = 100.0 * (clock_drift_x - 1.0);
} else {
calc->clock_drift_ms = 0.0;
calc->freq_drift_hz = 0.0;
calc->freq_drift_perc = 0.0;
}
calc->duration_ms = duration_x / 1000.0;
calc->sequence_err = strinfo->rtp_stats.sequence;
calc->start_time_ms = strinfo->rtp_stats.start_time / 1000.0;
calc->first_packet_num = strinfo->rtp_stats.first_packet_num;
calc->last_packet_num = strinfo->rtp_stats.max_nr;
}
/****************************************************************************/
/* free rtpstream_info_calc_t structure (internal items) */
void rtpstream_info_calc_free(rtpstream_info_calc_t *calc)
{
wmem_free(NULL, calc->src_addr_str);
wmem_free(NULL, calc->dst_addr_str);
wmem_free(NULL, calc->all_payload_type_names);
}
/****************************************************************************/
/* Init analyse counters in rtpstream_info_t from pinfo */
void rtpstream_info_analyse_init(rtpstream_info_t *stream_info, const packet_info *pinfo, const struct _rtp_info *rtpinfo)
{
struct _rtp_packet_info *p_packet_data = NULL;
/* reset stream stats */
stream_info->first_payload_type = rtpinfo->info_payload_type;
stream_info->first_payload_type_name = rtpinfo->info_payload_type_str;
stream_info->start_fd = pinfo->fd;
stream_info->start_rel_time = pinfo->rel_ts;
stream_info->start_abs_time = pinfo->abs_ts;
/* reset RTP stats */
stream_info->rtp_stats.first_packet = TRUE;
stream_info->rtp_stats.reg_pt = PT_UNDEFINED;
/* Get the Setup frame number who set this RTP stream */
p_packet_data = (struct _rtp_packet_info *)p_get_proto_data(wmem_file_scope(), (packet_info *)pinfo, proto_get_id_by_filter_name("rtp"), 0);
if (p_packet_data)
stream_info->setup_frame_number = p_packet_data->frame_number;
else
stream_info->setup_frame_number = 0xFFFFFFFF;
}
/****************************************************************************/
/* Update analyse counters in rtpstream_info_t from pinfo */
void rtpstream_info_analyse_process(rtpstream_info_t *stream_info, const packet_info *pinfo, const struct _rtp_info *rtpinfo)
{
/* get RTP stats for the packet */
rtppacket_analyse(&(stream_info->rtp_stats), pinfo, rtpinfo);
if (stream_info->payload_type_names[rtpinfo->info_payload_type] == NULL ) {
update_payload_names(stream_info, 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;
}
/****************************************************************************/
/* Get hash for rtpstream_info_t */
guint rtpstream_to_hash(gconstpointer key)
{
if (key) {
return rtpstream_id_to_hash(&((rtpstream_info_t *)key)->id);
} else {
return 0;
}
}
/****************************************************************************/
/* Inserts new_stream_info to multihash if its not there */
void rtpstream_info_multihash_insert(GHashTable *multihash, rtpstream_info_t *new_stream_info)
{
GList *hlist = (GList *)g_hash_table_lookup(multihash, GINT_TO_POINTER(rtpstream_to_hash(new_stream_info)));
gboolean found = FALSE;
if (hlist) {
// Key exists in hash
GList *list = g_list_first(hlist);
while (list)
{
if (rtpstream_id_equal(&(new_stream_info->id), &((rtpstream_info_t *)(list->data))->id, RTPSTREAM_ID_EQUAL_SSRC)) {
found = TRUE;
break;
}
list = g_list_next(list);
}
if (!found) {
// stream_info is not in list yet, add it
hlist = g_list_prepend(hlist, new_stream_info);
}
} else {
// No key in hash, init new list
hlist = g_list_prepend(hlist, new_stream_info);
}
g_hash_table_insert(multihash, GINT_TO_POINTER(rtpstream_to_hash(new_stream_info)), hlist);
}
/****************************************************************************/
/* Lookup stream_info in multihash */
rtpstream_info_t *rtpstream_info_multihash_lookup(GHashTable *multihash, rtpstream_id_t *stream_id)
{
GList *hlist = (GList *)g_hash_table_lookup(multihash, GINT_TO_POINTER(rtpstream_to_hash(stream_id)));
if (hlist) {
// Key exists in hash
GList *list = g_list_first(hlist);
while (list)
{
if (rtpstream_id_equal(stream_id, &((rtpstream_info_t *)(list->data))->id, RTPSTREAM_ID_EQUAL_SSRC)) {
return (rtpstream_info_t *)(list->data);
}
list = g_list_next(list);
}
}
// No stream_info in hash or was not found in existing list
return NULL;
}
/****************************************************************************/
/* Destroys GList used in multihash */
void rtpstream_info_multihash_destroy_value(gpointer key _U_, gpointer value, gpointer user_data _U_)
{
g_list_free((GList *)value);
} |
C/C++ | wireshark/ui/tap-rtp-common.h | /** @file
*
* RTP streams handler functions used by tshark and wireshark
*
* Copyright 2008, Ericsson AB
* By Balint Reczey <[email protected]>
*
* most functions are copied from ui/gtk/rtp_stream.c and ui/gtk/rtp_analisys.c
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_RTP_COMMON_H__
#define __TAP_RTP_COMMON_H__
#include "ui/rtp_stream.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* type of error when saving voice in a file didn't succeed */
typedef enum {
TAP_RTP_NO_ERROR,
TAP_RTP_WRONG_CODEC,
TAP_RTP_WRONG_LENGTH,
TAP_RTP_PADDING_ERROR,
TAP_RTP_SHORT_FRAME,
TAP_RTP_FILE_OPEN_ERROR,
TAP_RTP_FILE_WRITE_ERROR,
TAP_RTP_NO_DATA
} tap_rtp_error_type_t;
typedef struct _tap_rtp_save_info_t {
FILE *fp;
guint32 count;
tap_rtp_error_type_t error_type;
gboolean saved;
} tap_rtp_save_info_t;
typedef struct _rtpstream_info_calc {
gchar *src_addr_str;
guint16 src_port;
gchar *dst_addr_str;
guint16 dst_port;
guint32 ssrc;
gchar *all_payload_type_names; /* Name of codec derived from fixed or dynamic codec names */
guint32 packet_count;
guint32 total_nr;
guint32 packet_expected; /* Count of expected packets, derived from lenght of RTP stream */
gint32 lost_num;
double lost_perc;
double max_delta;
double min_delta;
double mean_delta;
double min_jitter;
double max_jitter;
double max_skew;
double mean_jitter;
gboolean problem; /* Indication that RTP stream contains something unusual -GUI should indicate it somehow */
double clock_drift_ms;
double freq_drift_hz;
double freq_drift_perc;
double duration_ms;
guint32 sequence_err;
double start_time_ms; /**< Unit is ms */
guint32 first_packet_num;
guint32 last_packet_num;
} rtpstream_info_calc_t;
/**
* Funcions for init and destroy of rtpstream_info_t and attached structures
*/
void rtpstream_info_init(rtpstream_info_t* info);
rtpstream_info_t *rtpstream_info_malloc_and_init(void);
void rtpstream_info_copy_deep(rtpstream_info_t *dest, const rtpstream_info_t *src);
rtpstream_info_t *rtpstream_info_malloc_and_copy_deep(const rtpstream_info_t *src);
void rtpstream_info_free_data(rtpstream_info_t* info);
void rtpstream_info_free_all(rtpstream_info_t* info);
/**
* Compares two RTP stream infos (GCompareFunc style comparison function)
*
* @return -1,0,1
*/
gint rtpstream_info_cmp(gconstpointer aa, gconstpointer bb);
/**
* Compares the endpoints of two RTP streams.
*
* @return TRUE if the
*/
gboolean rtpstream_info_is_reverse(const rtpstream_info_t *stream_a, rtpstream_info_t *stream_b);
/**
* Checks if payload_type is used in rtpstream.
*
* @returns TRUE if is used
*/
gboolean rtpstream_is_payload_used(const rtpstream_info_t *stream_info, const guint8 payload_type);
/****************************************************************************/
/* INTERFACE */
/**
* Registers the rtp_streams tap listener (if not already done).
* From that point on, the RTP streams list will be updated with every redissection.
* This function is also the entry point for the initialization routine of the tap system.
* So whenever rtp_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
* If not, it will be registered on demand by the rtp_streams and rtp_analysis functions that need it.
*/
void register_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo, const char *fstring, rtpstream_tap_error_cb tap_error);
/**
* Removes the rtp_streams tap listener (if not already done)
* From that point on, the RTP streams list won't be updated any more.
*/
void remove_tap_listener_rtpstream(rtpstream_tapinfo_t *tapinfo);
/**
* Cleans up memory of rtp streams tap.
*/
void rtpstream_reset(rtpstream_tapinfo_t *tapinfo);
void rtpstream_reset_cb(void*);
void rtp_write_header(rtpstream_info_t*, FILE*);
tap_packet_status rtpstream_packet_cb(void*, packet_info*, epan_dissect_t *, const void *, tap_flags_t);
/**
* Evaluate rtpstream_info_t calculations
*/
void rtpstream_info_calculate(const rtpstream_info_t *strinfo, rtpstream_info_calc_t *calc);
/**
* Free rtpstream_info_calc_t structure (internal items)
*/
void rtpstream_info_calc_free(rtpstream_info_calc_t *calc);
/**
* Init analyse counters in rtpstream_info_t from pinfo
*/
void rtpstream_info_analyse_init(rtpstream_info_t *stream_info, const packet_info *pinfo, const struct _rtp_info *rtpinfo);
/**
* Update analyse counters in rtpstream_info_t from pinfo
*/
void rtpstream_info_analyse_process(rtpstream_info_t *stream_info, const packet_info *pinfo, const struct _rtp_info *rtpinfo);
/**
* Get hash key for rtpstream_info_t
*/
guint rtpstream_to_hash(gconstpointer key);
/**
* Insert new_stream_info into multihash
*/
void rtpstream_info_multihash_insert(GHashTable *multihash, rtpstream_info_t *new_stream_info);
/**
* Lookup stream_info in stream_info multihash
*/
rtpstream_info_t *rtpstream_info_multihash_lookup(GHashTable *multihash, rtpstream_id_t *stream_id);
/**
* GHFunc () for destroying GList in multihash
*/
void rtpstream_info_multihash_destroy_value(gpointer key, gpointer value, gpointer user_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_RTP_COMMON_H__ */ |
C | wireshark/ui/tap-sctp-analysis.c | /*
* Copyright 2004-2013, Irene Ruengeler <i.ruengeler [AT] fh-muenster.de>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <string.h>
#include <math.h>
#include <glib.h>
#include "epan/packet_info.h"
#include "epan/tap.h"
#include "epan/value_string.h"
#include "ui/tap-sctp-analysis.h"
#include "ui/simple_dialog.h"
#define FORWARD_STREAM 0
#define BACKWARD_STREAM 1
#define FORWARD_ADD_FORWARD_VTAG 2
#define BACKWARD_ADD_FORWARD_VTAG 3
#define BACKWARD_ADD_BACKWARD_VTAG 4
#define ADDRESS_FORWARD_STREAM 5
#define ADDRESS_BACKWARD_STREAM 6
#define ADDRESS_FORWARD_ADD_FORWARD_VTAG 7
#define ADDRESS_BACKWARD_ADD_FORWARD_VTAG 8
#define ADDRESS_BACKWARD_ADD_BACKWARD_VTAG 9
#define ASSOC_NOT_FOUND 10
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);
}
static void
tsn_free(gpointer data)
{
tsn_t *tsn;
tsn = (tsn_t *) data;
if (tsn->tsns != NULL)
{
g_list_free_full(tsn->tsns, g_free);
}
free_address(&tsn->src);
free_address(&tsn->dst);
g_free(tsn);
}
static void
chunk_free(gpointer data)
{
sctp_addr_chunk *chunk = (sctp_addr_chunk *) data;
free_address(&chunk->addr);
g_free(chunk);
}
static void
store_free(gpointer data)
{
address *addr = (address *) data;
free_address(addr);
g_free(addr);
}
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_free_full(info->addr1, store_free);
info->addr1 = NULL;
}
if (info->addr2 != NULL)
{
g_list_free_full(info->addr2, store_free);
info->addr2 = NULL;
}
if (info->error_info_list != NULL)
{
g_list_free_full(info->error_info_list, g_free);
info->error_info_list = NULL;
}
if (info->frame_numbers != NULL)
{
g_list_free(info->frame_numbers);
info->frame_numbers = NULL;
}
if (info->tsn1 != NULL)
{
g_list_free_full(info->tsn1, tsn_free);
info->tsn1 = NULL;
}
if (info->tsn2 != NULL)
{
g_list_free_full(info->tsn2, tsn_free);
info->tsn2 = NULL;
}
if (info->sack1 != NULL)
{
g_list_free_full(info->sack1, tsn_free);
info->sack1 = NULL;
}
if (info->sack2 != NULL)
{
g_list_free_full(info->sack2, tsn_free);
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;
}
if (info->addr_chunk_count) {
g_list_free_full(info->addr_chunk_count, chunk_free);
}
g_free(info->dir1);
g_free(info->dir2);
free_address(&info->src);
free_address(&info->dst);
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";
(void) 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";
(void) 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";
(void) g_strlcpy(data->checksum_type, str, strlen(str));
data->n_checksum_errors=0;
}
return(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;
}
static sctp_assoc_info_t *
add_chunk_count(address *vadd, sctp_assoc_info_t *info, guint32 direction, guint32 type)
{
GList *list;
sctp_addr_chunk *ch=NULL;
int i;
list = g_list_first(info->addr_chunk_count);
while (list)
{
ch = (sctp_addr_chunk *)(list->data);
if (ch->direction == direction)
{
if (addresses_equal(vadd, &ch->addr))
{
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 = g_new(sctp_addr_chunk, 1);
ch->direction = direction;
copy_address(&ch->addr, vadd);
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)) {
free_address(vadd);
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 tap_packet_status
packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data, tap_flags_t flags _U_)
{
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;
int i;
guint8 idx = 0;
gboolean tsn_used = FALSE;
gboolean sack_used = FALSE;
framenumber = pinfo->num;
type = sctp_info->ip_src.type;
if (type == AT_IPv4 || type == AT_IPv6)
copy_address(&tmp_info.src, &sctp_info->ip_src);
else
set_address(&tmp_info.src, AT_NONE, 0, NULL);
type = sctp_info->ip_dst.type;
if (type == AT_IPv4 || type == AT_IPv6)
copy_address(&tmp_info.dst, &sctp_info->ip_dst);
else
set_address(&tmp_info.dst, AT_NONE, 0, NULL);
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 = g_new0(sctp_assoc_info_t, 1);
info->assoc_id = sctp_info->assoc_index;
copy_address(&info->src, &tmp_info.src);
copy_address(&info->dst, &tmp_info.dst);
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->firstdata = TRUE;
info->direction = sctp_info->direction;
info->instream1 = 0;
info->outstream1 = 0;
info->instream2 = 0;
info->outstream2 = 0;
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_with_free_func(g_free);
info->sort_tsn2 = g_ptr_array_new_with_free_func(g_free);
info->sort_sack1 = g_ptr_array_new_with_free_func(g_free);
info->sort_sack2 = g_ptr_array_new_with_free_func(g_free);
info->dir1 = g_new0(sctp_init_collision_t, 1);
info->dir1->init_min_tsn = 0xffffffff;
info->dir1->initack_min_tsn = 0xffffffff;
info->dir2 = g_new0(sctp_init_collision_t, 1);
info->dir2->init_min_tsn = 0xffffffff;
info->dir2->initack_min_tsn = 0xffffffff;
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 = g_new0(tsn_t, 1);
copy_address(&tsn->src, &tmp_info.src);
copy_address(&tsn->dst, &tmp_info.dst);
sack = g_new0(tsn_t, 1);
copy_address(&sack->src, &tmp_info.src);
copy_address(&sack->dst, &tmp_info.dst);
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 = g_new(address, 1);
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 = g_new(address, 1);
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);
if (info->direction == 1) {
if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID) {
info->dir1->init = TRUE;
info->dir1->init_min_tsn = info->min_tsn1;
info->dir1->init_vtag = info->verification_tag2;
} else if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_ACK_CHUNK_ID) {
info->dir1->initack = TRUE;
info->dir1->initack_min_tsn = info->min_tsn1;
info->dir1->initack_vtag = info->verification_tag2;
}
} else {
if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID) {
info->dir2->init = TRUE;
info->dir2->init_min_tsn = info->min_tsn1;
info->dir2->init_vtag = info->verification_tag2;
} else if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_ACK_CHUNK_ID) {
info->dir2->initack = TRUE;
info->dir2->initack_min_tsn = info->min_tsn1;
info->dir2->initack_vtag = info->verification_tag2;
}
}
}
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 = g_new0(tsn_t, 1);
sack = g_new0(tsn_t, 1);
}
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);
info->firstdata = FALSE;
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 = g_new(struct tsn_sort, 1);
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 = g_new(struct tsn_sort, 1);
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 = g_new(address, 1);
copy_address(store, &tmp_info.src);
info = add_address(store, info, info->direction);
store = g_new(address, 1);
copy_address(store, &tmp_info.dst);
if (info->direction == 1)
info = add_address(store, info, 2);
else
info = add_address(store, info, 1);
number = pinfo->num;
info->frame_numbers=g_list_prepend(info->frame_numbers, GUINT_TO_POINTER(number));
if (datachunk || forwardchunk) {
info->tsn1 = g_list_prepend(info->tsn1, tsn);
tsn_used = TRUE;
}
if (sackchunk == TRUE) {
info->sack2 = g_list_prepend(info->sack2, sack);
sack_used = TRUE;
}
sctp_tapinfo_struct.assoc_info_list = g_list_append(sctp_tapinfo_struct.assoc_info_list, info);
}
else
{
gchar* tmp_str;
error = g_new(sctp_error_info_t, 1);
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)");
(void) 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)");
(void) 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 = g_new0(tsn_t, 1);
copy_address(&tsn->src, &tmp_info.src);
copy_address(&tsn->dst, &tmp_info.dst);
sack = g_new0(tsn_t, 1);
copy_address(&sack->src, &tmp_info.src);
copy_address(&sack->dst, &tmp_info.dst);
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 = pinfo->num;
info->frame_numbers=g_list_prepend(info->frame_numbers, GUINT_TO_POINTER(number));
store = g_new(address, 1);
copy_address(store, &tmp_info.src);
switch (info->direction) {
case 1:
info = add_address(store, info, 1);
break;
case 2:
info = add_address(store, info, 2);
break;
default:
g_free(store);
break;
}
store = g_new(address, 1);
copy_address(store, &tmp_info.dst);
switch (info->direction) {
case 1:
info = add_address(store, info, 2);
break;
case 2:
info = add_address(store, info, 1);
break;
default:
g_free(store);
break;
}
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);
tsn_used = TRUE;
}
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);
tsn_used = TRUE;
}
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 = g_new(address, 1);
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 = g_new(address, 1);
alloc_address_tvb(NULL, store, AT_IPv6, 16, sctp_info->tvb[chunk_number], IPV6_ADDRESS_OFFSET);
info = add_address(store, info, info->direction);
}
}
if (info->direction == 1) {
if (info->dir1->init || info->dir1->initack) {
info->init_collision = TRUE;
}
if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID) {
info->dir1->init = TRUE;
info->dir1->init_min_tsn = tvb_get_ntohl((sctp_info->tvb)[0], INIT_CHUNK_INITIAL_TSN_OFFSET);
info->min_tsn1 = info->dir1->init_min_tsn;
info->dir1->init_vtag = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_INITIATE_TAG_OFFSET);
} else if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_ACK_CHUNK_ID) {
info->dir1->initack = TRUE;
info->dir1->initack_min_tsn = tvb_get_ntohl((sctp_info->tvb)[0], INIT_CHUNK_INITIAL_TSN_OFFSET);
info->min_tsn1 = info->dir1->initack_min_tsn;
info->dir1->initack_vtag = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_INITIATE_TAG_OFFSET);
}
} else {
if (info->dir2->init || info->dir2->initack) {
info->init_collision = TRUE;
}
if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_CHUNK_ID) {
info->dir2->init = TRUE;
info->dir2->init_min_tsn = tvb_get_ntohl((sctp_info->tvb)[0], INIT_CHUNK_INITIAL_TSN_OFFSET);
info->min_tsn2 = info->dir2->init_min_tsn;
info->dir2->init_vtag = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_INITIATE_TAG_OFFSET);
} else if (tvb_get_guint8(sctp_info->tvb[0],0) == SCTP_INIT_ACK_CHUNK_ID) {
info->dir2->initack = TRUE;
info->dir2->initack_min_tsn = tvb_get_ntohl((sctp_info->tvb)[0], INIT_CHUNK_INITIAL_TSN_OFFSET);
info->min_tsn2 = info->dir2->initack_min_tsn;
info->dir2->initack_vtag = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_INITIATE_TAG_OFFSET);
}
}
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))
{
if (!sack)
sack = g_new0(tsn_t, 1);
sack->tsns = NULL;
sack->first_tsn = 0;
if (!tsn)
tsn = g_new0(tsn_t, 1);
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 = g_new0(struct tsn_sort, 1);
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 (info->firstdata) {
info->firstdata = FALSE;
if (info->init_collision) {
if (tsnumber != info->min_tsn1) {
info->min_tsn1 = info->dir1->init_min_tsn;
}
info->min_tsn2 = info->dir2->initack_min_tsn;
}
} else {
if(tsnumber < info->min_tsn1) {
info->min_tsn1 = tsnumber;
}
}
if ((info->init || (info->initack && 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) {
guint16 tmp = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
if (info->outstream1 < tmp) info->outstream1 = tmp;
}
if (info->initack == FALSE) {
guint16 tmp = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
if (info->instream2 < tmp) info->instream2 = tmp;
}
}
g_ptr_array_add(info->sort_tsn1, tsn_s);
info->n_array_tsn1++;
}
else if (info->direction == 2)
{
if (info->firstdata) {
info->firstdata = FALSE;
if (info->init_collision) {
if (tsnumber != info->min_tsn2) {
info->min_tsn2 = info->dir2->init_min_tsn;
info->initack_dir = 2;
}
info->min_tsn1 = info->dir1->initack_min_tsn;
}
} else {
if(tsnumber < info->min_tsn2)
info->min_tsn2 = tsnumber;
}
if ((info->initack && 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) {
guint16 tmp = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
if (info->instream1 < tmp) info->instream1 = tmp;
}
if (info->initack == FALSE) {
guint16 tmp = tvb_get_ntohs((sctp_info->tvb)[chunk_number], DATA_CHUNK_STREAM_ID_OFFSET)+1;
if (info->outstream2 < tmp) info->outstream2 = tmp;
}
}
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 = g_new0(struct tsn_sort, 1);
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);
tsn_used = TRUE;
}
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);
sack_used = TRUE;
}
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++;
}
if (tsn && !tsn_used)
tsn_free(tsn);
if (sack && !sack_used)
tsn_free(sack);
free_address(&tmp_info.src);
free_address(&tmp_info.dst);
return TAP_PACKET_REDRAW;
}
/****************************************************************************/
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;
}
}
void
sctp_stat_scan(void)
{
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;
}
const sctp_assoc_info_t *
get_sctp_assoc_info(guint16 assoc_id)
{
sctp_tmp_info_t needle = { .assoc_id = assoc_id };
return find_assoc(&needle);
}
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, 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;
}
} |
C/C++ | wireshark/ui/tap-sctp-analysis.h | /** @file
*
* Copyright 2004-2013, Irene Ruengeler <i.ruengeler [AT] fh-muenster.de>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_SCTP_ANALYSIS_H__
#define __TAP_SCTP_ANALYSIS_H__
#include <stdbool.h>
#include <epan/dissectors/packet-sctp.h>
#include <epan/address.h>
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define CHUNK_TYPE_LENGTH 1
#define CHUNK_FLAGS_LENGTH 1
#define CHUNK_LENGTH_LENGTH 2
#define CHUNK_HEADER_OFFSET 0
#define CHUNK_TYPE_OFFSET CHUNK_HEADER_OFFSET
#define CHUNK_FLAGS_OFFSET (CHUNK_TYPE_OFFSET + CHUNK_TYPE_LENGTH)
#define CHUNK_LENGTH_OFFSET (CHUNK_FLAGS_OFFSET + CHUNK_FLAGS_LENGTH)
#define CHUNK_VALUE_OFFSET (CHUNK_LENGTH_OFFSET + CHUNK_LENGTH_LENGTH)
#define INIT_CHUNK_INITIATE_TAG_LENGTH 4
#define INIT_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH 4
#define INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_LENGTH 2
#define INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_LENGTH 2
#define INIT_CHUNK_INITIATE_TAG_OFFSET CHUNK_VALUE_OFFSET
#define INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET (INIT_CHUNK_INITIATE_TAG_OFFSET + \
INIT_CHUNK_INITIATE_TAG_LENGTH )
#define INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET (INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET + \
INIT_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH )
#define INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET (INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET + \
INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_LENGTH )
#define INIT_CHUNK_INITIAL_TSN_OFFSET (INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET + \
INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_LENGTH )
#define DATA_CHUNK_TSN_LENGTH 4
#define DATA_CHUNK_TSN_OFFSET (CHUNK_VALUE_OFFSET + 0)
#define DATA_CHUNK_STREAM_ID_OFFSET (DATA_CHUNK_TSN_OFFSET + DATA_CHUNK_TSN_LENGTH)
#define DATA_CHUNK_STREAM_ID_LENGTH 2
#define DATA_CHUNK_STREAM_SEQ_NUMBER_LENGTH 2
#define DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH 4
#define I_DATA_CHUNK_RESERVED_LENGTH 2
#define I_DATA_CHUNK_MID_LENGTH 4
#define I_DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH 4
#define I_DATA_CHUNK_FSN_LENGTH 4
#define I_DATA_CHUNK_RESERVED_OFFSET (DATA_CHUNK_STREAM_ID_OFFSET + \
DATA_CHUNK_STREAM_ID_LENGTH)
#define I_DATA_CHUNK_MID_OFFSET (I_DATA_CHUNK_RESERVED_OFFSET + \
I_DATA_CHUNK_RESERVED_LENGTH)
#define I_DATA_CHUNK_PAYLOAD_PROTOCOL_ID_OFFSET (I_DATA_CHUNK_MID_OFFSET + \
I_DATA_CHUNK_MID_LENGTH)
#define I_DATA_CHUNK_FSN_OFFSET (I_DATA_CHUNK_MID_OFFSET + \
I_DATA_CHUNK_MID_LENGTH)
#define I_DATA_CHUNK_PAYLOAD_OFFSET (I_DATA_CHUNK_PAYLOAD_PROTOCOL_ID_OFFSET + \
I_DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH)
#define DATA_CHUNK_HEADER_LENGTH (CHUNK_HEADER_LENGTH + \
DATA_CHUNK_TSN_LENGTH + \
DATA_CHUNK_STREAM_ID_LENGTH + \
DATA_CHUNK_STREAM_SEQ_NUMBER_LENGTH + \
DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH)
#define I_DATA_CHUNK_HEADER_LENGTH (CHUNK_HEADER_LENGTH + \
DATA_CHUNK_TSN_LENGTH + \
DATA_CHUNK_STREAM_ID_LENGTH + \
I_DATA_CHUNK_RESERVED_LENGTH + \
I_DATA_CHUNK_MID_LENGTH +\
I_DATA_CHUNK_PAYLOAD_PROTOCOL_ID_LENGTH)
#define MAX_ADDRESS_LEN 47
#define SCTP_ABORT_CHUNK_T_BIT 0x01
#define PARAMETER_TYPE_LENGTH 2
#define PARAMETER_LENGTH_LENGTH 2
#define PARAMETER_HEADER_LENGTH (PARAMETER_TYPE_LENGTH + PARAMETER_LENGTH_LENGTH)
#define PARAMETER_HEADER_OFFSET 0
#define PARAMETER_TYPE_OFFSET PARAMETER_HEADER_OFFSET
#define PARAMETER_LENGTH_OFFSET (PARAMETER_TYPE_OFFSET + PARAMETER_TYPE_LENGTH)
#define PARAMETER_VALUE_OFFSET (PARAMETER_LENGTH_OFFSET + PARAMETER_LENGTH_LENGTH)
#define IPV6_ADDRESS_LENGTH 16
#define IPV6_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
#define IPV4_ADDRESS_LENGTH 4
#define IPV4_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
#define IPV4ADDRESS_PARAMETER_ID 0x0005
#define IPV6ADDRESS_PARAMETER_ID 0x0006
#define SACK_CHUNK_CUMULATIVE_TSN_ACK_LENGTH 4
#define SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET (CHUNK_VALUE_OFFSET + 0)
#define SACK_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH 4
#define SACK_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET (SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET + \
SACK_CHUNK_CUMULATIVE_TSN_ACK_LENGTH)
#define INIT_CHUNK_INITIAL_TSN_LENGTH 4
#define INIT_CHUNK_FIXED_PARAMETERS_LENGTH (INIT_CHUNK_INITIATE_TAG_LENGTH + \
INIT_CHUNK_ADV_REC_WINDOW_CREDIT_LENGTH + \
INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_LENGTH + \
INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_LENGTH + \
INIT_CHUNK_INITIAL_TSN_LENGTH)
#define CHUNK_HEADER_LENGTH (CHUNK_TYPE_LENGTH + \
CHUNK_FLAGS_LENGTH + \
CHUNK_LENGTH_LENGTH)
#define INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET (INIT_CHUNK_INITIAL_TSN_OFFSET + \
INIT_CHUNK_INITIAL_TSN_LENGTH )
/* The below value is 255 */
#define NUM_CHUNKS 0x100
/* This variable is used as an index into arrays
* which store the cumulative information corresponding
* all chunks with Chunk Type greater > 16
* The value for the below variable is 17
*/
#define OTHER_CHUNKS_INDEX 0xfe
/* VNB */
/* This variable stores the maximum chunk type value
* that can be associated with a sctp chunk.
*/
#define MAX_SCTP_CHUNK_TYPE 256
typedef struct _tsn {
guint32 frame_number;
guint32 secs; /* Absolute seconds */
guint32 usecs;
address src;
address dst;
guint32 first_tsn;
GList *tsns;
} tsn_t;
typedef struct _sctp_tmp_info {
guint16 assoc_id;
guint16 direction;
address src;
address dst;
guint16 port1;
guint16 port2;
guint32 verification_tag1;
guint32 verification_tag2;
guint32 initiate_tag;
guint32 n_tvbs;
} sctp_tmp_info_t;
typedef struct _sctp_init_collision {
guint32 init_vtag; /* initiate tag of the INIT chunk */
guint32 initack_vtag; /* initiate tag of the INIT-ACK chunk */
guint32 init_min_tsn; /* initial tsn of the INIT chunk */
guint32 initack_min_tsn; /* initial tsn of the INIT-ACK chunk */
bool init:1;
bool initack:1;
} sctp_init_collision_t;
struct tsn_sort{
guint32 tsnumber;
guint32 secs;
guint32 usecs;
guint32 offset;
guint32 length;
guint32 framenumber;
};
typedef struct _sctp_addr_chunk {
guint32 direction;
address addr;
/* The array is initialized to MAX_SCTP_CHUNK_TYPE
* so that there is no memory overwrite
* when accessed using sctp chunk type as index.
*/
guint32 addr_count[MAX_SCTP_CHUNK_TYPE];
} sctp_addr_chunk;
typedef struct _sctp_assoc_info {
guint16 assoc_id;
address src;
address dst;
guint16 port1;
guint16 port2;
guint32 verification_tag1;
guint32 verification_tag2;
guint32 initiate_tag;
guint32 n_tvbs;
GList *addr1;
GList *addr2;
guint16 instream1;
guint16 outstream1;
guint16 instream2;
guint16 outstream2;
guint32 n_adler32_calculated;
guint32 n_adler32_correct;
guint32 n_crc32c_calculated;
guint32 n_crc32c_correct;
gchar checksum_type[8];
guint32 n_checksum_errors;
guint32 n_bundling_errors;
guint32 n_padding_errors;
guint32 n_length_errors;
guint32 n_value_errors;
guint32 n_data_chunks;
guint32 n_forward_chunks;
guint32 n_forward_chunks_ep1;
guint32 n_forward_chunks_ep2;
guint32 n_data_bytes;
guint32 n_packets;
guint32 n_data_chunks_ep1;
guint32 n_data_bytes_ep1;
guint32 n_data_chunks_ep2;
guint32 n_data_bytes_ep2;
guint32 n_sack_chunks_ep1;
guint32 n_sack_chunks_ep2;
guint32 n_array_tsn1;
guint32 n_array_tsn2;
guint32 max_window1;
guint32 max_window2;
guint32 arwnd1;
guint32 arwnd2;
bool init:1;
bool initack:1;
bool firstdata:1;
bool init_collision:1;
guint16 initack_dir;
guint16 direction;
guint32 min_secs;
guint32 min_usecs;
guint32 max_secs;
guint32 max_usecs;
guint32 min_tsn1;
guint32 min_tsn2;
guint32 max_tsn1;
guint32 max_tsn2;
guint32 max_bytes1;
guint32 max_bytes2;
sctp_init_collision_t *dir1;
sctp_init_collision_t *dir2;
GSList *min_max;
GList *frame_numbers;
GList *tsn1;
GPtrArray *sort_tsn1;
GPtrArray *sort_sack1;
GList *sack1;
GList *tsn2;
GPtrArray *sort_tsn2;
GPtrArray *sort_sack2;
GList *sack2;
gboolean check_address;
GList* error_info_list;
/* The array is initialized to MAX_SCTP_CHUNK_TYPE
* so that there is no memory overwrite
* when accessed using sctp chunk type as index.
*/
guint32 chunk_count[MAX_SCTP_CHUNK_TYPE];
guint32 ep1_chunk_count[MAX_SCTP_CHUNK_TYPE];
guint32 ep2_chunk_count[MAX_SCTP_CHUNK_TYPE];
GList *addr_chunk_count;
} sctp_assoc_info_t;
typedef struct _sctp_error_info {
guint32 frame_number;
gchar chunk_info[200];
const gchar *info_text;
} sctp_error_info_t;
typedef struct _sctp_allassocs_info {
guint32 sum_tvbs;
GList *assoc_info_list;
gboolean is_registered;
GList *children;
} sctp_allassocs_info_t;
void register_tap_listener_sctp_stat(void);
const sctp_allassocs_info_t* sctp_stat_get_info(void);
void sctp_stat_scan(void);
void remove_tap_listener_sctp_stat(void);
const sctp_assoc_info_t* get_sctp_assoc_info(guint16 assoc_id);
const sctp_assoc_info_t* get_selected_assoc(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_SCTP_ANALYSIS_H__ */ |
C | wireshark/ui/tap-tcp-stream.c | /* tap-tcp-stream.c
* TCP stream statistics
* Originally from tcp_graph.c by Pavel Mores <[email protected]>
* Win32 port: [email protected]
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include <file.h>
#include <frame_tvbuff.h>
#include <epan/epan_dissect.h>
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/dissectors/packet-tcp.h>
#include "ui/simple_dialog.h"
#include "tap-tcp-stream.h"
typedef struct _tcp_scan_t {
int direction;
struct tcp_graph *tg;
struct segment *last;
} tcp_scan_t;
static tap_packet_status
tapall_tcpip_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags _U_)
{
tcp_scan_t *ts = (tcp_scan_t *)pct;
struct tcp_graph *tg = ts->tg;
const struct tcpheader *tcphdr = (const struct tcpheader *)vip;
if (tg->stream == tcphdr->th_stream
&& (tg->src_address.type == AT_NONE || tg->dst_address.type == AT_NONE)) {
/*
* We only know the stream number. Fill in our connection data.
* We assume that the server response is more interesting.
*/
copy_address(&tg->src_address, &tcphdr->ip_dst);
tg->src_port = tcphdr->th_dport;
copy_address(&tg->dst_address, &tcphdr->ip_src);
tg->dst_port = tcphdr->th_sport;
}
if (compare_headers(&tg->src_address, &tg->dst_address,
tg->src_port, tg->dst_port,
&tcphdr->ip_src, &tcphdr->ip_dst,
tcphdr->th_sport, tcphdr->th_dport,
ts->direction)
&& tg->stream == tcphdr->th_stream)
{
struct segment *segment = g_new(struct segment, 1);
segment->next = NULL;
segment->num = pinfo->num;
segment->rel_secs = (guint32)pinfo->rel_ts.secs;
segment->rel_usecs = pinfo->rel_ts.nsecs/1000;
/* Currently unused
segment->abs_secs = pinfo->abs_ts.secs;
segment->abs_usecs = pinfo->abs_ts.nsecs/1000;
*/
segment->th_seq = tcphdr->th_seq;
segment->th_ack = tcphdr->th_ack;
segment->th_win = tcphdr->th_win;
segment->th_flags = tcphdr->th_flags;
segment->th_sport = tcphdr->th_sport;
segment->th_dport = tcphdr->th_dport;
segment->th_seglen = tcphdr->th_seglen;
copy_address(&segment->ip_src, &tcphdr->ip_src);
copy_address(&segment->ip_dst, &tcphdr->ip_dst);
segment->num_sack_ranges = MIN(MAX_TCP_SACK_RANGES, tcphdr->num_sack_ranges);
if (segment->num_sack_ranges > 0) {
/* Copy entries in the order they happen */
memcpy(&segment->sack_left_edge, &tcphdr->sack_left_edge, sizeof(segment->sack_left_edge));
memcpy(&segment->sack_right_edge, &tcphdr->sack_right_edge, sizeof(segment->sack_right_edge));
}
if (ts->tg->segments) {
ts->last->next = segment;
} else {
ts->tg->segments = segment;
}
ts->last = segment;
}
return TAP_PACKET_DONT_REDRAW;
}
/* here we collect all the external data we will ever need */
void
graph_segment_list_get(capture_file *cf, struct tcp_graph *tg)
{
GString *error_string;
tcp_scan_t ts;
if (!cf || !tg) {
return;
}
/* rescan all the packets and pick up all interesting tcp headers.
* we only filter for TCP here for speed and do the actual compare
* in the tap listener
*/
ts.direction = COMPARE_ANY_DIR;
ts.tg = tg;
ts.last = NULL;
error_string = register_tap_listener("tcp", &ts, "tcp", 0, NULL, tapall_tcpip_packet, NULL, NULL);
if (error_string) {
fprintf(stderr, "wireshark: Couldn't register tcp_graph tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
exit(1); /* XXX: fix this */
}
cf_retap_packets(cf);
remove_tap_listener(&ts);
}
void
graph_segment_list_free(struct tcp_graph *tg)
{
struct segment *segment;
free_address(&tg->src_address);
free_address(&tg->dst_address);
while (tg->segments) {
segment = tg->segments->next;
free_address(&tg->segments->ip_src);
free_address(&tg->segments->ip_dst);
g_free(tg->segments);
tg->segments = segment;
}
}
int
compare_headers(address *saddr1, address *daddr1, guint16 sport1, guint16 dport1, const address *saddr2, const address *daddr2, guint16 sport2, guint16 dport2, int dir)
{
int dir1, dir2;
dir1 = ((!(cmp_address(saddr1, saddr2))) &&
(!(cmp_address(daddr1, daddr2))) &&
(sport1==sport2) &&
(dport1==dport2));
if (dir == COMPARE_CURR_DIR) {
return dir1;
} else {
dir2 = ((!(cmp_address(saddr1, daddr2))) &&
(!(cmp_address(daddr1, saddr2))) &&
(sport1 == dport2) &&
(dport1 == sport2));
return dir1 || dir2;
}
}
int
get_num_dsegs(struct tcp_graph *tg)
{
int count;
struct segment *tmp;
for (tmp=tg->segments, count=0; tmp; tmp=tmp->next) {
if (compare_headers(&tg->src_address, &tg->dst_address,
tg->src_port, tg->dst_port,
&tmp->ip_src, &tmp->ip_dst,
tmp->th_sport, tmp->th_dport,
COMPARE_CURR_DIR)) {
count++;
}
}
return count;
}
int
get_num_acks(struct tcp_graph *tg, int *num_sack_ranges)
{
int count;
struct segment *tmp;
for (tmp = tg->segments, count=0; tmp; tmp = tmp->next) {
if (!compare_headers(&tg->src_address, &tg->dst_address,
tg->src_port, tg->dst_port,
&tmp->ip_src, &tmp->ip_dst,
tmp->th_sport, tmp->th_dport,
COMPARE_CURR_DIR)) {
count++;
*num_sack_ranges += tmp->num_sack_ranges;
}
}
return count;
}
typedef struct _th_t {
int num_hdrs;
#define MAX_SUPPORTED_TCP_HEADERS 8
struct tcpheader *tcphdrs[MAX_SUPPORTED_TCP_HEADERS];
} th_t;
static tap_packet_status
tap_tcpip_packet(void *pct, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags _U_)
{
int n;
gboolean is_unique = TRUE;
th_t *th = (th_t *)pct;
const struct tcpheader *header = (const struct tcpheader *)vip;
/* Check new header details against any/all stored ones */
for (n=0; n < th->num_hdrs; n++) {
struct tcpheader *stored = th->tcphdrs[n];
if (compare_headers(&stored->ip_src, &stored->ip_dst,
stored->th_sport, stored->th_dport,
&header->ip_src, &header->ip_dst,
header->th_sport, stored->th_dport,
COMPARE_CURR_DIR)) {
is_unique = FALSE;
break;
}
}
/* Add address if unique and have space for it */
if (is_unique && (th->num_hdrs < MAX_SUPPORTED_TCP_HEADERS)) {
/* Need to take a deep copy of the tap struct, it may not be valid
to read after this function returns? */
th->tcphdrs[th->num_hdrs] = g_new(struct tcpheader, 1);
*(th->tcphdrs[th->num_hdrs]) = *header;
copy_address(&th->tcphdrs[th->num_hdrs]->ip_src, &header->ip_src);
copy_address(&th->tcphdrs[th->num_hdrs]->ip_dst, &header->ip_dst);
th->num_hdrs++;
}
return TAP_PACKET_DONT_REDRAW;
}
/* XXX should be enhanced so that if we have multiple TCP layers in the trace
* then present the user with a dialog where the user can select WHICH tcp
* session to graph.
*/
guint32
select_tcpip_session(capture_file *cf)
{
frame_data *fdata;
epan_dissect_t edt;
dfilter_t *sfcode;
guint32 th_stream;
df_error_t *df_err;
GString *error_string;
th_t th = {0, {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}};
if (!cf) {
return G_MAXUINT32;
}
/* no real filter yet */
if (!dfilter_compile("tcp", &sfcode, &df_err)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", df_err->msg);
df_error_free(&df_err);
return G_MAXUINT32;
}
/* dissect the current record */
if (!cf_read_current_record(cf)) {
return G_MAXUINT32; /* error reading the record */
}
fdata = cf->current_frame;
error_string = register_tap_listener("tcp", &th, NULL, 0, NULL, tap_tcpip_packet, NULL, NULL);
if (error_string) {
fprintf(stderr, "wireshark: Couldn't register tcp_graph tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
epan_dissect_prime_with_dfilter(&edt, sfcode);
epan_dissect_run_with_taps(&edt, cf->cd_t, &cf->rec,
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
fdata, NULL);
epan_dissect_cleanup(&edt);
remove_tap_listener(&th);
dfilter_free(sfcode);
if (th.num_hdrs == 0) {
/* This "shouldn't happen", as our menu items shouldn't
* even be enabled if the selected packet isn't a TCP
* segment, as tcp_graph_selected_packet_enabled() is used
* to determine whether to enable any of our menu items. */
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Selected packet isn't a TCP segment or is truncated");
return G_MAXUINT32;
}
/* XXX fix this later, we should show a dialog allowing the user
to select which session he wants here
*/
if (th.num_hdrs > 1) {
/* can only handle a single tcp layer yet */
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"The selected packet has more than one TCP unique conversation "
"in it.");
return G_MAXUINT32;
}
/* For now, still always choose the first/only one */
th_stream = th.tcphdrs[0]->th_stream;
for (int n = 0; n < th.num_hdrs; n++) {
free_address(&th.tcphdrs[n]->ip_src);
free_address(&th.tcphdrs[n]->ip_dst);
g_free(th.tcphdrs[n]);
}
return th_stream;
}
int rtt_is_retrans(struct rtt_unack *list, unsigned int seqno)
{
struct rtt_unack *u;
for (u=list; u; u=u->next) {
if (tcp_seq_eq_or_after(seqno, u->seqno) &&
tcp_seq_before(seqno, u->end_seqno)) {
return TRUE;
}
}
return FALSE;
}
struct rtt_unack *
rtt_get_new_unack(double time_val, unsigned int seqno, unsigned int seglen)
{
struct rtt_unack *u;
u = g_new(struct rtt_unack, 1);
u->next = NULL;
u->time = time_val;
u->seqno = seqno;
u->end_seqno = seqno + seglen;
return u;
}
void rtt_put_unack_on_list(struct rtt_unack **l, struct rtt_unack *new_unack)
{
struct rtt_unack *u, *list = *l;
for (u=list; u; u=u->next) {
if (!u->next) {
break;
}
}
if (u) {
u->next = new_unack;
} else {
*l = new_unack;
}
}
void rtt_delete_unack_from_list(struct rtt_unack **l, struct rtt_unack *dead)
{
struct rtt_unack *u, *list = *l;
if (!dead || !list) {
return;
}
if (dead == list) {
*l = list->next;
g_free(list);
} else {
for (u=list; u; u=u->next) {
if (u->next == dead) {
u->next = u->next->next;
g_free(dead);
break;
}
}
}
}
void rtt_destroy_unack_list(struct rtt_unack **l ) {
while (*l) {
struct rtt_unack *head = *l;
*l = head->next;
g_free(head);
}
} |
C/C++ | wireshark/ui/tap-tcp-stream.h | /** @file
*
* TCP stream statistics
* Originally from tcp_graph.c by Pavel Mores <[email protected]>
* Win32 port: [email protected]
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_TCP_STREAM_H__
#define __TAP_TCP_STREAM_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef enum tcp_graph_type_ {
GRAPH_TSEQ_STEVENS,
GRAPH_TSEQ_TCPTRACE,
GRAPH_THROUGHPUT,
GRAPH_RTT,
GRAPH_WSCALE,
GRAPH_UNDEFINED
} tcp_graph_type;
struct segment {
struct segment *next;
guint32 num;
guint32 rel_secs;
guint32 rel_usecs;
/* Currently unused.
time_t abs_secs;
guint32 abs_usecs;
*/
guint32 th_seq;
guint32 th_ack;
guint16 th_flags;
guint32 th_win; /* make it 32 bits so we can handle some scaling */
guint32 th_seglen;
guint16 th_sport;
guint16 th_dport;
address ip_src;
address ip_dst;
guint8 num_sack_ranges;
guint32 sack_left_edge[MAX_TCP_SACK_RANGES];
guint32 sack_right_edge[MAX_TCP_SACK_RANGES];
};
struct tcp_graph {
tcp_graph_type type;
/* The stream this graph will show */
address src_address;
guint16 src_port;
address dst_address;
guint16 dst_port;
guint32 stream;
/* Should this be a map or tree instead? */
struct segment *segments;
};
/** Fill in the segment list for a TCP graph
*
* @param cf Capture file to scan
* @param tg TCP graph. A valid stream must be set. If either the source or
* destination address types are AT_NONE the address and port
* information will be filled in using the first packet in the
* specified stream.
*/
void graph_segment_list_get(capture_file *cf, struct tcp_graph *tg);
void graph_segment_list_free(struct tcp_graph * );
/* for compare_headers() */
/* segment went the same direction as the currently selected one */
#define COMPARE_CURR_DIR 0
#define COMPARE_ANY_DIR 1
int compare_headers(address *saddr1, address *daddr1, guint16 sport1, guint16 dport1, const address *saddr2, const address *daddr2, guint16 sport2, guint16 dport2, int dir);
int get_num_dsegs(struct tcp_graph * );
int get_num_acks(struct tcp_graph *, int * );
guint32 select_tcpip_session(capture_file *);
/* This is used by rtt module only */
struct rtt_unack {
struct rtt_unack *next;
double time;
unsigned int seqno;
unsigned int end_seqno;
};
int rtt_is_retrans(struct rtt_unack * , unsigned int );
struct rtt_unack *rtt_get_new_unack(double , unsigned int , unsigned int );
void rtt_put_unack_on_list(struct rtt_unack ** , struct rtt_unack * );
void rtt_delete_unack_from_list(struct rtt_unack ** , struct rtt_unack * );
void rtt_destroy_unack_list(struct rtt_unack ** );
static inline int
tcp_seq_before(guint32 s1, guint32 s2) {
return (gint32)(s1 - s2) < 0;
}
static inline int
tcp_seq_eq_or_after(guint32 s1, guint32 s2) {
return !tcp_seq_before(s1, s2);
}
static inline int
tcp_seq_after(guint32 s1, guint32 s2) {
return (gint32)(s1 - s2) > 0;
}
static inline int tcp_seq_before_or_eq(guint32 s1, guint32 s2) {
return !tcp_seq_after(s1, s2);
}
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_TCP_STREAM_H__ */ |
C/C++ | wireshark/ui/taps.h | /** @file
*
* Definitions for tap registration
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAPS_H__
#define __TAPS_H__
#include <glib.h>
#include <epan/tap.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern tap_reg_t tap_reg_listener[];
extern const gulong tap_reg_listener_count;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAPS_H__ */ |
C | wireshark/ui/tap_export_pdu.c | /* tap_export_pdu.c
* Routines for exporting PDUs to file
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/tap.h>
#include <epan/exported_pdu.h>
#include <epan/epan_dissect.h>
#include <wiretap/wtap.h>
#include <wiretap/wtap_opttypes.h>
#include <wsutil/os_version_info.h>
#include <wsutil/report_message.h>
#include "wsutil/version_info.h"
#include "tap_export_pdu.h"
/* Main entry point to the tap */
static tap_packet_status
export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const void *data, tap_flags_t flags _U_)
{
const exp_pdu_data_t *exp_pdu_data = (const exp_pdu_data_t *)data;
exp_pdu_t *exp_pdu_tap_data = (exp_pdu_t *)tapdata;
wtap_rec rec;
int err;
gchar *err_info;
int buffer_len;
guint8 *packet_buf;
tap_packet_status status = TAP_PACKET_DONT_REDRAW; /* no GUI, nothing to redraw */
/*
* Count this packet.
*/
exp_pdu_tap_data->framenum++;
memset(&rec, 0, sizeof rec);
buffer_len = exp_pdu_data->tvb_captured_length + exp_pdu_data->tlv_buffer_len;
packet_buf = (guint8 *)g_malloc(buffer_len);
if(exp_pdu_data->tlv_buffer_len > 0){
memcpy(packet_buf, exp_pdu_data->tlv_buffer, exp_pdu_data->tlv_buffer_len);
}
if(exp_pdu_data->tvb_captured_length > 0){
tvb_memcpy(exp_pdu_data->pdu_tvb, packet_buf+exp_pdu_data->tlv_buffer_len, 0, exp_pdu_data->tvb_captured_length);
}
rec.rec_type = REC_TYPE_PACKET;
rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS;
rec.ts.secs = pinfo->abs_ts.secs;
rec.ts.nsecs = pinfo->abs_ts.nsecs;
rec.rec_header.packet_header.caplen = buffer_len;
rec.rec_header.packet_header.len = exp_pdu_data->tvb_reported_length + exp_pdu_data->tlv_buffer_len;
rec.rec_header.packet_header.pkt_encap = exp_pdu_tap_data->pkt_encap;
/* rec.opt_block is not modified by wtap_dump, but if for some reason the
* epan_get_modified_block() or pinfo->rec->block are invalidated,
* copying it here does not hurt. (Can invalidation really happen?) */
if (pinfo->fd->has_modified_block) {
rec.block = epan_get_modified_block(edt->session, pinfo->fd);
rec.block_was_modified = TRUE;
} else {
rec.block = pinfo->rec->block;
}
/* XXX: should the rec.rec_header.packet_header.pseudo_header be set to the pinfo's pseudo-header? */
if (!wtap_dump(exp_pdu_tap_data->wdh, &rec, packet_buf, &err, &err_info)) {
report_cfile_write_failure(NULL, exp_pdu_tap_data->pathname,
err, err_info, exp_pdu_tap_data->framenum,
wtap_dump_file_type_subtype(exp_pdu_tap_data->wdh));
status = TAP_PACKET_FAILED;
}
g_free(packet_buf);
return status;
}
gboolean
exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, char *pathname,
int file_type_subtype, int fd, const char *comment,
int *err, gchar **err_info)
{
/* pcapng defs */
wtap_block_t shb_hdr;
wtap_block_t int_data;
wtapng_if_descr_mandatory_t *int_data_mand;
GString *os_info_str;
gsize opt_len;
gchar *opt_str;
/*
* If the file format supports a section block, and the section
* block supports comments, create data for it.
*/
if (wtap_file_type_subtype_supports_block(file_type_subtype,
WTAP_BLOCK_SECTION) != BLOCK_NOT_SUPPORTED &&
wtap_file_type_subtype_supports_option(file_type_subtype,
WTAP_BLOCK_SECTION,
OPT_COMMENT) != OPTION_NOT_SUPPORTED) {
os_info_str = g_string_new("");
get_os_version_info(os_info_str);
shb_hdr = wtap_block_create(WTAP_BLOCK_SECTION);
/* options */
wtap_block_add_string_option(shb_hdr, OPT_COMMENT, comment, strlen(comment));
/*
* UTF-8 string containing the name of the operating system used to
* create this section.
*/
opt_len = os_info_str->len;
opt_str = g_string_free(os_info_str, FALSE);
if (opt_str) {
wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, opt_str, opt_len);
g_free(opt_str);
}
/*
* UTF-8 string containing the name of the application used to create
* this section.
*/
wtap_block_add_string_option_format(shb_hdr, OPT_SHB_USERAPPL, "%s",
get_appname_and_version());
exp_pdu_tap_data->shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
g_array_append_val(exp_pdu_tap_data->shb_hdrs, shb_hdr);
} else {
exp_pdu_tap_data->shb_hdrs = NULL;
}
/*
* Create fake interface information for files that support (meaning
* "require") interface information and per-packet interface IDs.
*/
if (wtap_file_type_subtype_supports_block(file_type_subtype,
WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
exp_pdu_tap_data->idb_inf = g_new(wtapng_iface_descriptions_t,1);
exp_pdu_tap_data->idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
/* create the fake interface data */
int_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = exp_pdu_tap_data->pkt_encap;
int_data_mand->time_units_per_second = 1000000000; /* default nanosecond resolution */
int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE_STANDARD;
wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export", strlen("Fake IF, PDU->Export"));
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 9);
g_array_append_val(exp_pdu_tap_data->idb_inf->interface_data, int_data);
} else {
exp_pdu_tap_data->idb_inf = NULL;
}
const wtap_dump_params params = {
.encap = exp_pdu_tap_data->pkt_encap,
.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD,
.shb_hdrs = exp_pdu_tap_data->shb_hdrs,
.idb_inf = exp_pdu_tap_data->idb_inf,
};
if (fd == 1) {
exp_pdu_tap_data->wdh = wtap_dump_open_stdout(file_type_subtype,
WTAP_UNCOMPRESSED, ¶ms, err, err_info);
} else {
exp_pdu_tap_data->wdh = wtap_dump_fdopen(fd, file_type_subtype,
WTAP_UNCOMPRESSED, ¶ms, err, err_info);
}
if (exp_pdu_tap_data->wdh == NULL)
return FALSE;
exp_pdu_tap_data->pathname = pathname;
exp_pdu_tap_data->framenum = 0; /* No frames written yet */
return TRUE;
}
gboolean
exp_pdu_close(exp_pdu_t *exp_pdu_tap_data, int *err, gchar **err_info)
{
gboolean status;
status = wtap_dump_close(exp_pdu_tap_data->wdh, NULL, err, err_info);
wtap_block_array_free(exp_pdu_tap_data->shb_hdrs);
wtap_free_idb_info(exp_pdu_tap_data->idb_inf);
remove_tap_listener(exp_pdu_tap_data);
return status;
}
char *
exp_pdu_pre_open(const char *tap_name, const char *filter, exp_pdu_t *exp_pdu_tap_data)
{
GString *error_string;
/* Register this tap listener now */
error_string = register_tap_listener(tap_name, /* The name of the tap we want to listen to */
exp_pdu_tap_data, /* instance identifier/pointer to a struct holding
* all state variables */
filter, /* pointer to a filter string */
TL_REQUIRES_PROTO_TREE, /* flags for the tap listener */
NULL,
export_pdu_packet,
NULL,
NULL);
if (error_string != NULL)
return g_string_free(error_string, FALSE);
exp_pdu_tap_data->pkt_encap = export_pdu_tap_get_encap(tap_name);
return NULL;
} |
C/C++ | wireshark/ui/tap_export_pdu.h | /** @file
*
* Routines for exporting PDUs to file
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_EXPORT_PDU_H__
#define __TAP_EXPORT_PDU_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _exp_pdu_t {
char* pathname;
int pkt_encap;
wtap_dumper* wdh;
GArray* shb_hdrs;
wtapng_iface_descriptions_t* idb_inf;
guint32 framenum;
} exp_pdu_t;
/**
* Registers the tap listener which will add matching packets to the exported
* file. Must be called before exp_pdu_open.
*
* @param tap_name One of the names registered with register_export_pdu_tap().
* @param filter An tap filter, may be NULL to disable filtering which
* improves performance if you do not need a filter.
* @return NULL on success or an error string on failure which must be freed
* with g_free(). Failure could occur when the filter or tap_name are invalid.
*/
char *exp_pdu_pre_open(const char *tap_name, const char *filter,
exp_pdu_t *exp_pdu_tap_data);
/**
* Use the given file descriptor for writing an output file. Can only be called
* once and exp_pdu_pre_open() must be called before.
*
* @param[out] err Will be set to an error code on failure.
* @param[out] err_info for some errors, a string giving more details of
* the error
* @return TRUE on success or FALSE on failure.
*/
gboolean exp_pdu_open(exp_pdu_t *data, char *pathname, int file_type_subtype,
int fd, const char *comment, int *err, gchar **err_info);
/* Stops the PDUs export. */
gboolean exp_pdu_close(exp_pdu_t *exp_pdu_tap_data, int *err, gchar **err_info);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_EXPORT_PDU_H__ */ |
C | wireshark/ui/text_import.c | /* text_import.c
* State machine for text import
* November 2010, Jaap Keuter <[email protected]>
* Modified March 2021, Paul Weiß <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Based on text2pcap.c by Ashok Narayanan <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*******************************************************************************
*
* This code reads in an ASCII hexdump of this common format:
*
* 00000000 00 E0 1E A7 05 6F 00 10 5A A0 B9 12 08 00 46 00 .....o..Z.....F.
* 00000010 03 68 00 00 00 00 0A 2E EE 33 0F 19 08 7F 0F 19 .h.......3......
* 00000020 03 80 94 04 00 00 10 01 16 A2 0A 00 03 50 00 0C .............P..
* 00000030 01 01 0F 19 03 80 11 01 1E 61 00 0C 03 01 0F 19 .........a......
*
* Each bytestring line consists of an offset, one or more bytes, and
* text at the end. An offset is defined as a hex string of more than
* two characters. A byte is defined as a hex string of exactly two
* characters. The text at the end is ignored, as is any text before
* the offset. Bytes read from a bytestring line are added to the
* current packet only if all the following conditions are satisfied:
*
* - No text appears between the offset and the bytes (any bytes appearing after
* such text would be ignored)
*
* - The offset must be arithmetically correct, i.e. if the offset is 00000020,
* then exactly 32 bytes must have been read into this packet before this.
* If the offset is wrong, the packet is immediately terminated
*
* A packet start is signaled by a zero offset.
*
* Lines starting with #TEXT2PCAP are directives. These allow the user
* to embed instructions into the capture file which allows text2pcap
* to take some actions (e.g. specifying the encapsulation
* etc.). Currently no directives are implemented.
*
* Lines beginning with # which are not directives are ignored as
* comments. Currently all non-hexdump text is ignored by text2pcap;
* in the future, text processing may be added, but lines prefixed
* with '#' will still be ignored.
*
* The output is a libpcap packet containing Ethernet frames by
* default. This program takes options which allow the user to add
* dummy Ethernet, IP and UDP, TCP or SCTP headers to the packets in order
* to allow dumps of L3 or higher protocols to be decoded.
*
* Considerable flexibility is built into this code to read hexdumps
* of slightly different formats. For example, any text prefixing the
* hexdump line is dropped (including mail forwarding '>'). The offset
* can be any hex number of four digits or greater.
*
* This converter cannot read a single packet greater than
* WTAP_MAX_PACKET_SIZE_STANDARD. The snapshot length is automatically
* set to WTAP_MAX_PACKET_SIZE_STANDARD.
*/
/*******************************************************************************
* Alternatively this parses a Textfile based on a prel regex containing named
* capturing groups like so:
* (?<seqno>\d+)\s*(?<dir><|>)\s*(?<time>\d+:\d\d:\d\d.\d+)\s+(?<data>[0-9a-fA-F]+)\\s+
*
* Fields are decoded using a leanient parser, but only one attempt is made.
* Except for in data invalid values will be replaced by default ones.
* data currently only accepts plain HEX, OCT or BIN encoded data.
* common field seperators are ignored. Note however that 0x or 0b prefixing is
* not supported and no automatic format detection is attempted.
*/
#include "config.h"
#include "text_import.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wsutil/file_util.h>
#include <ws_exit_codes.h>
#include <time.h>
#include <glib.h>
#include <errno.h>
#include <assert.h>
#include <epan/tvbuff.h>
#include <wsutil/crc32.h>
#include <epan/in_cksum.h>
#include <wsutil/report_message.h>
#include <wsutil/exported_pdu_tlvs.h>
#include <wsutil/nstime.h>
#include <wsutil/time_util.h>
#include <wsutil/version_info.h>
#include <wsutil/cpu_info.h>
#include <wsutil/os_version_info.h>
#include "text_import_scanner.h"
#include "text_import_scanner_lex.h"
#include "text_import_regex.h"
/*--- Options --------------------------------------------------------------------*/
/* maximum time precision we can handle = 10^(-SUBSEC_PREC) */
#define SUBSEC_PREC 9
static text_import_info_t *info_p;
/* Dummy Ethernet header */
static gboolean hdr_ethernet = FALSE;
static guint8 hdr_eth_dest_addr[6] = {0x20, 0x52, 0x45, 0x43, 0x56, 0x00};
static guint8 hdr_eth_src_addr[6] = {0x20, 0x53, 0x45, 0x4E, 0x44, 0x00};
static guint32 hdr_ethernet_proto = 0;
/* Dummy IP header */
static gboolean hdr_ip = FALSE;
static gboolean hdr_ipv6 = FALSE;
static guint hdr_ip_proto = 0;
/* Destination and source addresses for IP header */
static ws_in6_addr NO_IPv6_ADDRESS = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
/* These IPv6 default addresses are unique local addresses generated using
* the pseudo-random method from Section 3.2.2 of RFC 4193
*/
static ws_in6_addr IPv6_SRC = {{0xfd, 0xce, 0xd8, 0x62, 0x14, 0x1b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}};
static ws_in6_addr IPv6_DST = {{0xfd, 0xce, 0xd8, 0x62, 0x14, 0x1b, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}};
/* Dummy UDP header */
static gboolean hdr_udp = FALSE;
/* Dummy TCP header */
static gboolean hdr_tcp = FALSE;
/* TCP sequence numbers when has_direction is true */
static guint32 tcp_in_seq_num = 0;
static guint32 tcp_out_seq_num = 0;
/* Dummy SCTP header */
static gboolean hdr_sctp = FALSE;
/* Dummy DATA chunk header */
static gboolean hdr_data_chunk = FALSE;
static guint8 hdr_data_chunk_type = 0;
static guint8 hdr_data_chunk_bits = 0;
static guint32 hdr_data_chunk_tsn = 0;
static guint16 hdr_data_chunk_sid = 0;
static guint16 hdr_data_chunk_ssn = 0;
/* Dummy ExportPdu header */
static gboolean hdr_export_pdu = FALSE;
/* Hex+ASCII text dump identification, to handle an edge case where
* the ASCII representation contains patterns that look like bytes. */
static guint8* pkt_lnstart;
static gboolean has_direction = FALSE;
static guint32 direction = PACK_FLAGS_RECEPTION_TYPE_UNSPECIFIED;
static gboolean has_seqno = FALSE;
static guint64 seqno = 0;
/*--- Local data -----------------------------------------------------------------*/
/* This is where we store the packet currently being built */
static guint8 *packet_buf;
static guint32 curr_offset = 0;
static guint32 packet_start = 0;
static gboolean offset_warned = FALSE;
static import_status_t start_new_packet(gboolean);
/* This buffer contains strings present before the packet offset 0 */
#define PACKET_PREAMBLE_MAX_LEN 2048
static guint8 packet_preamble[PACKET_PREAMBLE_MAX_LEN+1];
static int packet_preamble_len = 0;
/* Time code of packet, derived from packet_preamble */
static time_t ts_sec = 0;
static guint32 ts_nsec = 0;
static gboolean ts_fmt_iso = FALSE;
static struct tm timecode_default;
static gboolean timecode_warned = FALSE;
/* The time delta to add to packets without a valid time code.
* This can be no smaller than the time resolution of the dump
* file, so the default is 1000 nanoseconds, or 1 microsecond.
* XXX: We should at least get this from the resolution of the file we're
* writing to, and possibly allow the user to set a different value.
*/
static guint32 ts_tick = 1000;
/* HDR_ETH Offset base to parse */
static guint32 offset_base = 16;
/* ----- State machine -----------------------------------------------------------*/
/* Current state of parser */
typedef enum {
INIT, /* Waiting for start of new packet */
START_OF_LINE, /* Starting from beginning of line */
READ_OFFSET, /* Just read the offset */
READ_BYTE, /* Just read a byte */
READ_TEXT /* Just read text - ignore until EOL */
} parser_state_t;
static parser_state_t state = INIT;
static const char *state_str[] = {"Init",
"Start-of-line",
"Offset",
"Byte",
"Text"
};
static const char *token_str[] = {"",
"Byte",
"Offset",
"Directive",
"Text",
"End-of-line",
"End-of-file"
};
/* ----- Skeleton Packet Headers --------------------------------------------------*/
typedef struct {
guint8 dest_addr[6];
guint8 src_addr[6];
guint16 l3pid;
} hdr_ethernet_t;
static hdr_ethernet_t HDR_ETHERNET;
typedef struct {
guint8 ver_hdrlen;
guint8 dscp;
guint16 packet_length;
guint16 identification;
guint8 flags;
guint8 fragment;
guint8 ttl;
guint8 protocol;
guint16 hdr_checksum;
guint32 src_addr;
guint32 dest_addr;
} hdr_ip_t;
/* Default IPv4 addresses if none supplied */
#if G_BYTE_ORDER == G_BIG_ENDIAN
#define IP_ID 0x1234
#define IP_SRC 0x0a010101
#define IP_DST 0x0a020202
#else
#define IP_ID 0x3412
#define IP_SRC 0x0101010a
#define IP_DST 0x0202020a
#endif
static hdr_ip_t HDR_IP =
{0x45, 0, 0, IP_ID, 0, 0, 0xff, 0, 0, IP_SRC, IP_DST};
static struct { /* pseudo header for checksum calculation */
guint32 src_addr;
guint32 dest_addr;
guint8 zero;
guint8 protocol;
guint16 length;
} pseudoh;
/* headers taken from glibc */
typedef struct {
union {
struct ip6_hdrctl {
guint32 ip6_un1_flow; /* 24 bits of flow-ID */
guint16 ip6_un1_plen; /* payload length */
guint8 ip6_un1_nxt; /* next header */
guint8 ip6_un1_hlim; /* hop limit */
} ip6_un1;
guint8 ip6_un2_vfc; /* 4 bits version, 4 bits priority */
} ip6_ctlun;
ws_in6_addr ip6_src; /* source address */
ws_in6_addr ip6_dst; /* destination address */
} hdr_ipv6_t;
static hdr_ipv6_t HDR_IPv6;
/* https://tools.ietf.org/html/rfc2460#section-8.1 */
static struct { /* pseudo header ipv6 for checksum calculation */
struct e_in6_addr src_addr6;
struct e_in6_addr dst_addr6;
guint32 length;
guint8 zero[3];
guint8 next_header;
} pseudoh6;
typedef struct {
guint16 source_port;
guint16 dest_port;
guint16 length;
guint16 checksum;
} hdr_udp_t;
static hdr_udp_t HDR_UDP = {0, 0, 0, 0};
typedef struct {
guint16 source_port;
guint16 dest_port;
guint32 seq_num;
guint32 ack_num;
guint8 hdr_length;
guint8 flags;
guint16 window;
guint16 checksum;
guint16 urg;
} hdr_tcp_t;
static hdr_tcp_t HDR_TCP = {0, 0, 0, 0, 0x50, 0, 0, 0, 0};
typedef struct {
guint16 src_port;
guint16 dest_port;
guint32 tag;
guint32 checksum;
} hdr_sctp_t;
static hdr_sctp_t HDR_SCTP = {0, 0, 0, 0};
typedef struct {
guint8 type;
guint8 bits;
guint16 length;
guint32 tsn;
guint16 sid;
guint16 ssn;
guint32 ppid;
} hdr_data_chunk_t;
static hdr_data_chunk_t HDR_DATA_CHUNK = {0, 0, 0, 0, 0, 0, 0};
typedef struct {
guint16 tag_type;
guint16 payload_len;
} hdr_export_pdu_t;
static hdr_export_pdu_t HDR_EXPORT_PDU = {0, 0};
#define EXPORT_PDU_END_OF_OPTIONS_SIZE 4
/*----------------------------------------------------------------------
* Parse a single hex number
* Will abort the program if it can't parse the number
* Pass in TRUE if this is an offset, FALSE if not
*/
static import_status_t
parse_num(const char *str, int offset, guint32* num)
{
char *c;
if (str == NULL) {
report_failure("FATAL ERROR: str is NULL");
return IMPORT_FAILURE;
}
errno = 0;
unsigned long ulnum = strtoul(str, &c, offset ? offset_base : 16);
if (errno != 0) {
report_failure("Unable to convert %s to base %u: %s", str,
offset ? offset_base : 16, g_strerror(errno));
return IMPORT_FAILURE;
}
if (c == str) {
report_failure("Unable to convert %s to base %u", str,
offset ? offset_base : 16);
return IMPORT_FAILURE;
}
if (ulnum > G_MAXUINT32) {
report_failure("%s too large", str);
return IMPORT_FAILURE;
}
*num = (guint32) ulnum;
return IMPORT_SUCCESS;
}
/*----------------------------------------------------------------------
* Write this byte into current packet
*/
static import_status_t
write_byte(const char *str)
{
guint32 num;
if (parse_num(str, FALSE, &num) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
packet_buf[curr_offset] = (guint8) num;
curr_offset++;
if (curr_offset >= info_p->max_frame_length) /* packet full */
if (start_new_packet(TRUE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
return IMPORT_SUCCESS;
}
/*----------------------------------------------------------------------
* Remove bytes from the current packet
*/
static void
unwrite_bytes (guint32 nbytes)
{
curr_offset -= nbytes;
}
/*----------------------------------------------------------------------
* Determine SCTP chunk padding length
*/
static guint32
number_of_padding_bytes (guint32 length)
{
guint32 remainder;
remainder = length % 4;
if (remainder == 0)
return 0;
else
return 4 - remainder;
}
/*----------------------------------------------------------------------
* Write current packet out
*
* @param cont [IN] TRUE if a packet is being written because the max frame
* length was reached, and the original packet from the input file is
* continued in a later frame. Used to set fragmentation fields in dummy
* headers (currently only implemented for SCTP; IPv4 could be added later.)
*/
static import_status_t
write_current_packet(gboolean cont)
{
int prefix_length = 0;
int proto_length = 0;
int ip_length = 0;
int eth_trailer_length = 0;
int prefix_index = 0;
int i, padding_length;
if (curr_offset > 0) {
/* Write the packet */
/* Is direction indication on with an inbound packet? */
gboolean isOutbound = has_direction && (direction == PACK_FLAGS_DIRECTION_OUTBOUND);
/* Compute packet length */
prefix_length = 0;
if (hdr_export_pdu) {
prefix_length += (int)sizeof(HDR_EXPORT_PDU) + (int)strlen(info_p->payload) + EXPORT_PDU_END_OF_OPTIONS_SIZE;
proto_length = prefix_length + curr_offset;
}
if (hdr_data_chunk) { prefix_length += (int)sizeof(HDR_DATA_CHUNK); }
if (hdr_sctp) { prefix_length += (int)sizeof(HDR_SCTP); }
if (hdr_udp) { prefix_length += (int)sizeof(HDR_UDP); proto_length = prefix_length + curr_offset; }
if (hdr_tcp) { prefix_length += (int)sizeof(HDR_TCP); proto_length = prefix_length + curr_offset; }
if (hdr_ip) {
prefix_length += (int)sizeof(HDR_IP);
ip_length = prefix_length + curr_offset + ((hdr_data_chunk) ? number_of_padding_bytes(curr_offset) : 0);
} else if (hdr_ipv6) {
ip_length = prefix_length + curr_offset + ((hdr_data_chunk) ? number_of_padding_bytes(curr_offset) : 0);
/* IPv6 payload length field does not include the header itself.
* It does include extension headers, but we don't put any
* (if we later do fragments, that would change.)
*/
prefix_length += (int)sizeof(HDR_IPv6);
}
if (hdr_ethernet) { prefix_length += (int)sizeof(HDR_ETHERNET); }
/* Make room for dummy header */
memmove(&packet_buf[prefix_length], packet_buf, curr_offset);
if (hdr_ethernet) {
/* Pad trailer */
if (prefix_length + curr_offset < 60) {
eth_trailer_length = 60 - (prefix_length + curr_offset);
}
}
/* Write Ethernet header */
if (hdr_ethernet) {
if (isOutbound)
{
memcpy(HDR_ETHERNET.dest_addr, hdr_eth_src_addr, 6);
memcpy(HDR_ETHERNET.src_addr, hdr_eth_dest_addr, 6);
} else {
memcpy(HDR_ETHERNET.dest_addr, hdr_eth_dest_addr, 6);
memcpy(HDR_ETHERNET.src_addr, hdr_eth_src_addr, 6);
}
HDR_ETHERNET.l3pid = g_htons(hdr_ethernet_proto);
memcpy(&packet_buf[prefix_index], &HDR_ETHERNET, sizeof(HDR_ETHERNET));
prefix_index += (int)sizeof(HDR_ETHERNET);
}
/* Write IP header */
if (hdr_ip) {
vec_t cksum_vector[1];
if (isOutbound) {
HDR_IP.src_addr = info_p->ip_dest_addr.ipv4 ? info_p->ip_dest_addr.ipv4 : IP_DST;
HDR_IP.dest_addr = info_p->ip_src_addr.ipv4 ? info_p->ip_src_addr.ipv4 : IP_SRC;
}
else {
HDR_IP.src_addr = info_p->ip_src_addr.ipv4 ? info_p->ip_src_addr.ipv4 : IP_SRC;
HDR_IP.dest_addr = info_p->ip_dest_addr.ipv4 ? info_p->ip_dest_addr.ipv4 : IP_DST;
}
HDR_IP.packet_length = g_htons(ip_length);
HDR_IP.protocol = (guint8) hdr_ip_proto;
HDR_IP.hdr_checksum = 0;
cksum_vector[0].ptr = (guint8 *)&HDR_IP; cksum_vector[0].len = sizeof(HDR_IP);
HDR_IP.hdr_checksum = in_cksum(cksum_vector, 1);
memcpy(&packet_buf[prefix_index], &HDR_IP, sizeof(HDR_IP));
prefix_index += (int)sizeof(HDR_IP);
/* initialize pseudo header for checksum calculation */
pseudoh.src_addr = HDR_IP.src_addr;
pseudoh.dest_addr = HDR_IP.dest_addr;
pseudoh.zero = 0;
pseudoh.protocol = (guint8) hdr_ip_proto;
pseudoh.length = g_htons(proto_length);
} else if (hdr_ipv6) {
if (memcmp(&info_p->ip_dest_addr.ipv6, &NO_IPv6_ADDRESS, sizeof(ws_in6_addr))) {
memcpy(isOutbound ? &HDR_IPv6.ip6_src : &HDR_IPv6.ip6_dst, &info_p->ip_dest_addr.ipv6, sizeof(ws_in6_addr));
} else {
memcpy(isOutbound ? &HDR_IPv6.ip6_src : &HDR_IPv6.ip6_dst, &IPv6_DST, sizeof(ws_in6_addr));
}
if (memcmp(&info_p->ip_src_addr.ipv6, &NO_IPv6_ADDRESS, sizeof(ws_in6_addr))) {
memcpy(isOutbound ? &HDR_IPv6.ip6_dst : &HDR_IPv6.ip6_src, &info_p->ip_src_addr.ipv6, sizeof(ws_in6_addr));
} else {
memcpy(isOutbound ? &HDR_IPv6.ip6_dst : &HDR_IPv6.ip6_src, &IPv6_SRC, sizeof(ws_in6_addr));
}
HDR_IPv6.ip6_ctlun.ip6_un2_vfc &= 0x0F;
HDR_IPv6.ip6_ctlun.ip6_un2_vfc |= (6<< 4);
HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen = g_htons(ip_length);
HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_nxt = (guint8) hdr_ip_proto;
HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_hlim = 32;
memcpy(&packet_buf[prefix_index], &HDR_IPv6, sizeof(HDR_IPv6));
prefix_index += (int)sizeof(HDR_IPv6);
/* initialize pseudo ipv6 header for checksum calculation */
pseudoh6.src_addr6 = HDR_IPv6.ip6_src;
pseudoh6.dst_addr6 = HDR_IPv6.ip6_dst;
memset(pseudoh6.zero, 0, sizeof(pseudoh6.zero));
pseudoh6.next_header = (guint8) hdr_ip_proto;
pseudoh6.length = g_htons(proto_length);
}
/* Write UDP header */
if (hdr_udp) {
vec_t cksum_vector[3];
HDR_UDP.source_port = isOutbound ? g_htons(info_p->dst_port): g_htons(info_p->src_port);
HDR_UDP.dest_port = isOutbound ? g_htons(info_p->src_port) : g_htons(info_p->dst_port);
HDR_UDP.length = g_htons(proto_length);
HDR_UDP.checksum = 0;
if (hdr_ipv6) {
cksum_vector[0].ptr = (guint8 *)&pseudoh6; cksum_vector[0].len = sizeof(pseudoh6);
} else {
cksum_vector[0].ptr = (guint8 *)&pseudoh; cksum_vector[0].len = sizeof(pseudoh);
}
cksum_vector[1].ptr = (guint8 *)&HDR_UDP; cksum_vector[1].len = sizeof(HDR_UDP);
cksum_vector[2].ptr = &packet_buf[prefix_length]; cksum_vector[2].len = curr_offset;
HDR_UDP.checksum = in_cksum(cksum_vector, 3);
memcpy(&packet_buf[prefix_index], &HDR_UDP, sizeof(HDR_UDP));
prefix_index += (int)sizeof(HDR_UDP);
}
/* Write TCP header */
if (hdr_tcp) {
vec_t cksum_vector[3];
HDR_TCP.source_port = isOutbound ? g_htons(info_p->dst_port): g_htons(info_p->src_port);
HDR_TCP.dest_port = isOutbound ? g_htons(info_p->src_port) : g_htons(info_p->dst_port);
/* set ack number if we have direction */
if (has_direction) {
HDR_TCP.flags = 0x10;
HDR_TCP.ack_num = g_ntohl(isOutbound ? tcp_out_seq_num : tcp_in_seq_num);
HDR_TCP.ack_num = g_htonl(HDR_TCP.ack_num);
}
else {
HDR_TCP.flags = 0;
HDR_TCP.ack_num = 0;
}
HDR_TCP.seq_num = isOutbound ? tcp_in_seq_num : tcp_out_seq_num;
HDR_TCP.window = g_htons(0x2000);
HDR_TCP.checksum = 0;
if (hdr_ipv6) {
cksum_vector[0].ptr = (guint8 *)&pseudoh6; cksum_vector[0].len = sizeof(pseudoh6);
} else {
cksum_vector[0].ptr = (guint8 *)&pseudoh; cksum_vector[0].len = sizeof(pseudoh);
}
cksum_vector[1].ptr = (guint8 *)&HDR_TCP; cksum_vector[1].len = sizeof(HDR_TCP);
cksum_vector[2].ptr = &packet_buf[prefix_length]; cksum_vector[2].len = curr_offset;
HDR_TCP.checksum = in_cksum(cksum_vector, 3);
memcpy(&packet_buf[prefix_index], &HDR_TCP, sizeof(HDR_TCP));
prefix_index += (int)sizeof(HDR_TCP);
if (isOutbound) {
tcp_in_seq_num = g_ntohl(tcp_in_seq_num) + curr_offset;
tcp_in_seq_num = g_htonl(tcp_in_seq_num);
}
else {
tcp_out_seq_num = g_ntohl(tcp_out_seq_num) + curr_offset;
tcp_out_seq_num = g_htonl(tcp_out_seq_num);
}
}
/* Compute DATA chunk header and append padding */
if (hdr_data_chunk) {
hdr_data_chunk_bits = 0;
if (packet_start == 0) {
hdr_data_chunk_bits |= 0x02;
}
if (!cont) {
hdr_data_chunk_bits |= 0x01;
}
HDR_DATA_CHUNK.type = hdr_data_chunk_type;
HDR_DATA_CHUNK.bits = hdr_data_chunk_bits;
HDR_DATA_CHUNK.length = g_htons(curr_offset + sizeof(HDR_DATA_CHUNK));
HDR_DATA_CHUNK.tsn = g_htonl(hdr_data_chunk_tsn);
HDR_DATA_CHUNK.sid = g_htons(hdr_data_chunk_sid);
HDR_DATA_CHUNK.ssn = g_htons(hdr_data_chunk_ssn);
HDR_DATA_CHUNK.ppid = g_htonl(info_p->ppi);
hdr_data_chunk_tsn++;
if (!cont) {
hdr_data_chunk_ssn++;
}
padding_length = number_of_padding_bytes(curr_offset);
for (i=0; i<padding_length; i++)
packet_buf[prefix_length+curr_offset+i] = 0;
curr_offset += padding_length;
}
/* Write SCTP header */
if (hdr_sctp) {
HDR_SCTP.src_port = isOutbound ? g_htons(info_p->dst_port): g_htons(info_p->src_port);
HDR_SCTP.dest_port = isOutbound ? g_htons(info_p->src_port) : g_htons(info_p->dst_port);
HDR_SCTP.tag = g_htonl(info_p->tag);
HDR_SCTP.checksum = g_htonl(0);
HDR_SCTP.checksum = crc32c_calculate(&HDR_SCTP, sizeof(HDR_SCTP), CRC32C_PRELOAD);
if (hdr_data_chunk)
HDR_SCTP.checksum = crc32c_calculate(&HDR_DATA_CHUNK, sizeof(HDR_DATA_CHUNK), HDR_SCTP.checksum);
HDR_SCTP.checksum = g_htonl(~crc32c_calculate(&packet_buf[prefix_length], curr_offset, HDR_SCTP.checksum));
memcpy(&packet_buf[prefix_index], &HDR_SCTP, sizeof(HDR_SCTP));
prefix_index += (int)sizeof(HDR_SCTP);
}
/* Write DATA chunk header */
if (hdr_data_chunk) {
memcpy(&packet_buf[prefix_index], &HDR_DATA_CHUNK, sizeof(HDR_DATA_CHUNK));
/*prefix_index += (int)sizeof(HDR_DATA_CHUNK);*/
}
/* Write ExportPDU header */
if (hdr_export_pdu) {
guint payload_len = (guint)strlen(info_p->payload);
HDR_EXPORT_PDU.tag_type = g_htons(EXP_PDU_TAG_DISSECTOR_NAME);
HDR_EXPORT_PDU.payload_len = g_htons(payload_len);
memcpy(&packet_buf[prefix_index], &HDR_EXPORT_PDU, sizeof(HDR_EXPORT_PDU));
prefix_index += sizeof(HDR_EXPORT_PDU);
memcpy(&packet_buf[prefix_index], info_p->payload, payload_len);
prefix_index += payload_len;
/* Add end-of-options tag */
memset(&packet_buf[prefix_index], 0x00, 4);
}
/* Write Ethernet trailer */
if (hdr_ethernet && eth_trailer_length > 0) {
memset(&packet_buf[prefix_length+curr_offset], 0, eth_trailer_length);
}
HDR_TCP.seq_num = g_ntohl(HDR_TCP.seq_num) + curr_offset;
HDR_TCP.seq_num = g_htonl(HDR_TCP.seq_num);
/* Write the packet */
wtap_rec rec;
int err;
gchar *err_info;
memset(&rec, 0, sizeof rec);
if (info_p->encapsulation == WTAP_ENCAP_SYSTEMD_JOURNAL) {
rec.rec_type = REC_TYPE_SYSTEMD_JOURNAL_EXPORT;
rec.block = wtap_block_create(WTAP_BLOCK_SYSTEMD_JOURNAL_EXPORT);
rec.rec_header.systemd_journal_export_header.record_len = prefix_length + curr_offset + eth_trailer_length;
rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_TS;
/* XXX: Ignore our direction, packet id, and timestamp. For a
* systemd Journal Export Block the timestamp comes from the
* __REALTIME_TIMESTAMP= field. We don't check to see if that
* field is there (it MUST be, but we don't check whether our
* input is malformed in general), but since the presence flags
* aren't really used when writing, it doesn't matter.
*/
} else {
rec.rec_type = REC_TYPE_PACKET;
rec.block = wtap_block_create(WTAP_BLOCK_PACKET);
rec.rec_header.packet_header.caplen = rec.rec_header.packet_header.len = prefix_length + curr_offset + eth_trailer_length;
rec.ts.secs = ts_sec;
rec.ts.nsecs = ts_nsec;
rec.rec_header.packet_header.pkt_encap = info_p->encapsulation;
rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS;
if (has_direction) {
wtap_block_add_uint32_option(rec.block, OPT_PKT_FLAGS, direction);
}
if (has_seqno) {
wtap_block_add_uint64_option(rec.block, OPT_PKT_PACKETID, seqno);
}
}
if (!wtap_dump(info_p->wdh, &rec, packet_buf, &err, &err_info)) {
report_cfile_write_failure(info_p->import_text_filename,
info_p->output_filename, err, err_info,
info_p->num_packets_read,
wtap_dump_file_type_subtype(info_p->wdh));
wtap_block_unref(rec.block);
return IMPORT_FAILURE;
}
wtap_block_unref(rec.block);
info_p->num_packets_written++;
}
packet_start += curr_offset;
curr_offset = 0;
return IMPORT_SUCCESS;
}
/*----------------------------------------------------------------------
* Append a token to the packet preamble.
*/
static import_status_t
append_to_preamble(char *str)
{
size_t toklen;
if (packet_preamble_len != 0) {
if (packet_preamble_len == PACKET_PREAMBLE_MAX_LEN)
return IMPORT_SUCCESS; /* no room to add more preamble */
/* XXX: Just keep going? This is probably not a problem, unless
* someone had >2000 bytes of whitespace before the timestamp... */
/* Add a blank separator between the previous token and this token. */
packet_preamble[packet_preamble_len++] = ' ';
}
if(str == NULL){
report_failure("FATAL ERROR: str is NULL");
return IMPORT_FAILURE;
}
toklen = strlen(str);
if (toklen != 0) {
if (packet_preamble_len + toklen > PACKET_PREAMBLE_MAX_LEN)
return IMPORT_SUCCESS; /* no room to add token to the preamble */
/* XXX: Just keep going? This is probably not a problem, as above.*/
(void) g_strlcpy(&packet_preamble[packet_preamble_len], str, PACKET_PREAMBLE_MAX_LEN);
packet_preamble_len += (int) toklen;
if (ws_log_get_level() >= LOG_LEVEL_NOISY) {
char *c;
char xs[PACKET_PREAMBLE_MAX_LEN];
(void) g_strlcpy(xs, packet_preamble, PACKET_PREAMBLE_MAX_LEN);
while ((c = strchr(xs, '\r')) != NULL) *c=' ';
ws_noisy("[[append_to_preamble: \"%s\"]]", xs);
}
}
return IMPORT_SUCCESS;
}
#define INVALID_VALUE (-1)
#define WHITESPACE_VALUE (-2)
/*
* Information on how to parse any plainly encoded binary data
*
* one Unit is least_common_mmultiple(bits_per_char, 8) bits.
*/
struct plain_decoding_data {
const gchar* name;
guint chars_per_unit;
guint bytes_per_unit : 3; /* Internally a guint64 is used to hold units */
guint bits_per_char : 6;
gint8 table[256];
};
#define _INVALID_INIT2 INVALID_VALUE, INVALID_VALUE
#define _INVALID_INIT4 _INVALID_INIT2, _INVALID_INIT2
#define _INVALID_INIT8 _INVALID_INIT4, _INVALID_INIT4
#define _INVALID_INIT16 _INVALID_INIT8, _INVALID_INIT8
#define _INVALID_INIT32 _INVALID_INIT16, _INVALID_INIT16
#define _INVALID_INIT64 _INVALID_INIT32, _INVALID_INIT32
#define _INVALID_INIT128 _INVALID_INIT64, _INVALID_INIT64
#define _INVALID_INIT256 _INVALID_INIT128, _INVALID_INIT128
#define INVALID_INIT _INVALID_INIT256
// this is a gcc/clang extension:
// [0 ... 255] = INVALID_VALUE
#define WHITESPACE_INIT \
[' '] = WHITESPACE_VALUE, \
['\t'] = WHITESPACE_VALUE, \
['\n'] = WHITESPACE_VALUE, \
['\v'] = WHITESPACE_VALUE, \
['\f'] = WHITESPACE_VALUE, \
['\r'] = WHITESPACE_VALUE
/*
* Some compilers warn about initializing the same subobject
* more than once with designated initializers.
*
* We're doing that - INVALID_INIT iniitalizes everything to
* INVALID_VALUE, but then we override selected elements -
* but we know what we're doing, so just suppress that
* warning.
*/
DIAG_OFF_INIT_TWICE
const struct plain_decoding_data hex_decode_info = {
.chars_per_unit = 2,
.bytes_per_unit = 1,
.bits_per_char = 4,
.table = {
INVALID_INIT,
WHITESPACE_INIT,
[':'] = WHITESPACE_VALUE,
['0'] = 0,1,2,3,4,5,6,7,8,9,
['A'] = 10,11,12,13,14,15,
['a'] = 10,11,12,13,14,15
}
};
const struct plain_decoding_data bin_decode_info = {
.chars_per_unit = 8,
.bytes_per_unit = 1,
.bits_per_char = 1,
.table = {
INVALID_INIT,
WHITESPACE_INIT,
['0'] = 0, 1
}
};
const struct plain_decoding_data oct_decode_info = {
.chars_per_unit = 8,
.bytes_per_unit = 3,
.bits_per_char = 3,
.table = {
INVALID_INIT,
WHITESPACE_INIT,
['0'] = 0,1,2,3,4,5,6,7
}
};
const struct plain_decoding_data base64_decode_info = {
.chars_per_unit = 4,
.bytes_per_unit = 3,
.bits_per_char = 6,
.table = {
INVALID_INIT,
WHITESPACE_INIT,
['A'] = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,
['a'] = 26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
['0'] = 52,53,54,55,56,57,58,59,60,61,
['+'] = 62,
['/'] = 63,
['='] = WHITESPACE_VALUE /* padding at the end, the decoder doesn't need this, so just ignores it */
}
};
DIAG_ON_INIT_TWICE
/*******************************************************************************
* The modularized part of this mess, used by the wrapper around the regex
* engine in text_import_regex.c to hook into this state-machine backend.
*
* Should the rest be modularized aswell? Maybe, but then start with pcap2text.c
*/
/**
* This function parses encoded data according to <encoding> into binary data.
* It will continue until one of the following conditions is met:
* - src is depletetd
* - dest cannot hold another full unit of data
* - an invalid character is read
* When this happens any complete bytes will be recovered from the remaining
* possibly incomplete unit and stored to dest (there will be no incomplete unit
* if dest is full). Any remaining bits will be discarded.
* src and dest will be advanced to where parsing including this last incomplete
* unit stopped.
* If you want to continue parsing (meaning incomplete units were due to call
* fragmentation and not actually due to EOT) you have to resume the parser at
* *src_last_unit and dest - result % bytes_per_unit
*/
static int parse_plain_data(guchar** src, const guchar* src_end,
guint8** dest, const guint8* dest_end, const struct plain_decoding_data* encoding,
guchar** src_last_unit) {
int status = 1;
int units = 0;
/* unit buffer */
guint64 c_val = 0;
guint c_chars = 0;
/**
* Src data |- - -|- - -|- - -|- - -|- - -|- - -|- - -|- - -|
* Bytes |- - - - - - - -|- - - - - - - -|- - - - - - - -|
* Units |- - - - - - - - - - - - - - - - - - - - - - - -|
*/
guint64 val;
int j;
if (ws_log_get_level() >= LOG_LEVEL_NOISY) {
char* debug_str = wmem_strndup(NULL, *src, (src_end-*src));
ws_noisy("parsing data: %s", debug_str);
wmem_free(NULL, debug_str);
}
while (*src < src_end && *dest + encoding->bytes_per_unit <= dest_end) {
val = encoding->table[**src];
switch (val) {
case INVALID_VALUE:
status = -1;
goto remainder;
case WHITESPACE_VALUE:
ws_warning("Unexpected char %d in data", **src);
break;
default:
c_val = c_val << encoding->bits_per_char | val;
++c_chars;
/* another full unit */
if (c_chars == encoding->chars_per_unit) {
++units;
if (src_last_unit)
*src_last_unit = *src;
c_chars = 0;
for (j = encoding->bytes_per_unit; j > 0; --j) {
**dest = (gchar) (c_val >> (j * 8 - 8));
*dest += 1;
}
}
}
*src += 1;
}
remainder:
for (j = c_chars * encoding->bits_per_char; j >= 8; j -= 8) {
**dest = (gchar) (c_val >> (j - 8));
*dest += 1;
}
return status * units;
}
void parse_data(guchar* start_field, guchar* end_field, enum data_encoding encoding) {
guint8* dest = &packet_buf[curr_offset];
guint8* dest_end = &packet_buf[info_p->max_frame_length];
const struct plain_decoding_data* table; /* should be further down */
switch (encoding) {
case ENCODING_PLAIN_HEX:
case ENCODING_PLAIN_OCT:
case ENCODING_PLAIN_BIN:
case ENCODING_BASE64:
/* const struct plain_decoding_data* table; // This can't be here because gcc says no */
switch (encoding) {
case ENCODING_PLAIN_HEX:
table = &hex_decode_info;
break;
case ENCODING_PLAIN_OCT:
table = &oct_decode_info;
break;
case ENCODING_PLAIN_BIN:
table = &bin_decode_info;
break;
case ENCODING_BASE64:
table = &base64_decode_info;
break;
default:
return;
}
info_p->num_packets_read++;
while (1) {
parse_plain_data(&start_field, end_field, &dest, dest_end, table, NULL);
curr_offset = (int) (dest - packet_buf);
if (curr_offset == info_p->max_frame_length) {
write_current_packet(TRUE);
dest = &packet_buf[curr_offset];
} else
break;
}
break;
default:
ws_critical("not implemented/invalid encoding type");
return;
}
}
#define setFlags(VAL, MASK, FLAGS) \
((VAL) & ~(MASK)) | ((FLAGS) & (MASK))
static void _parse_dir(const guchar* start_field, const guchar* end_field _U_, const gchar* in_indicator, const gchar* out_indicator, guint32* dir) {
for (; *in_indicator && *start_field != *in_indicator; ++in_indicator);
if (*in_indicator) {
*dir = setFlags(*dir, PACK_FLAGS_DIRECTION_MASK << PACK_FLAGS_DIRECTION_SHIFT, PACK_FLAGS_DIRECTION_INBOUND);
return;
}
for (; *out_indicator && *start_field != *out_indicator; ++out_indicator);
if (*out_indicator) {
*dir = setFlags(*dir, PACK_FLAGS_DIRECTION_MASK << PACK_FLAGS_DIRECTION_SHIFT, PACK_FLAGS_DIRECTION_OUTBOUND);
return;
}
*dir = setFlags(*dir, PACK_FLAGS_DIRECTION_MASK << PACK_FLAGS_DIRECTION_SHIFT, PACK_FLAGS_DIRECTION_UNKNOWN);
}
void parse_dir(const guchar* start_field, const guchar* end_field, const gchar* in_indicator, const gchar* out_indicator) {
_parse_dir(start_field, end_field, in_indicator, out_indicator, &direction);
}
#define PARSE_BUF 64
/* Attempt to parse a time according to the given format. If the conversion
* succeeds, set sec and nsec appropriately and return TRUE. If it fails,
* leave sec and nsec unchanged and return FALSE.
*/
static gboolean
_parse_time(const guchar* start_field, const guchar* end_field, const gchar* _format, time_t* sec, gint* nsec) {
struct tm timecode;
time_t sec_buf;
gint nsec_buf = 0;
char field[PARSE_BUF];
char format[PARSE_BUF];
char* subsecs_fmt;
int subseclen = -1;
char *cursor;
char *p;
int i;
(void) g_strlcpy(field, start_field, MIN(end_field - start_field + 1, PARSE_BUF));
if (ts_fmt_iso) {
nstime_t ts_iso;
if (!iso8601_to_nstime(&ts_iso, field, ISO8601_DATETIME_AUTO)) {
return FALSE;
}
*sec = ts_iso.secs;
*nsec = ts_iso.nsecs;
} else {
(void) g_strlcpy(format, _format, PARSE_BUF);
/*
* Initialize to today, local time, just in case not all fields
* of the date and time are specified.
*/
timecode = timecode_default;
cursor = &field[0];
/*
* %f is for fractions of seconds not supported by strptime
* BTW: what is this function name? is this some russian joke?
*/
subsecs_fmt = g_strrstr(format, "%f");
if (subsecs_fmt) {
*subsecs_fmt = 0;
}
cursor = ws_strptime(cursor, format, &timecode);
if (cursor == NULL) {
return FALSE;
}
if (subsecs_fmt != NULL) {
/*
* Parse subsecs and any following format
*/
nsec_buf = (guint) strtol(cursor, &p, 10);
if (p == cursor) {
return FALSE;
}
subseclen = (int) (p - cursor);
cursor = p;
cursor = ws_strptime(cursor, subsecs_fmt + 2, &timecode);
if (cursor == NULL) {
return FALSE;
}
}
if (subseclen > 0) {
/*
* Convert that number to a number
* of nanoseconds; if it's N digits
* long, it's in units of 10^(-N) seconds,
* so, to convert it to units of
* 10^-9 seconds, we multiply by
* 10^(9-N).
*/
if (subseclen > SUBSEC_PREC) {
/*
* *More* than 9 digits; 9-N is
* negative, so we divide by
* 10^(N-9).
*/
for (i = subseclen - SUBSEC_PREC; i != 0; i--)
nsec_buf /= 10;
} else if (subseclen < SUBSEC_PREC) {
for (i = SUBSEC_PREC - subseclen; i != 0; i--)
nsec_buf *= 10;
}
}
if ( -1 == (sec_buf = mktime(&timecode)) ) {
return FALSE;
}
*sec = sec_buf;
*nsec = nsec_buf;
}
ws_noisy("parsed time %s Format(%s), time(%u), subsecs(%u)\n", field, _format, (guint32)*sec, (guint32)*nsec);
return TRUE;
}
void parse_time(const guchar* start_field, const guchar* end_field, const gchar* format) {
if (format == NULL || !_parse_time(start_field, end_field, format, &ts_sec, &ts_nsec)) {
ts_nsec += ts_tick;
}
}
void parse_seqno(const guchar* start_field, const guchar* end_field) {
char* buf = (char*) g_alloca(end_field - start_field + 1);
(void) g_strlcpy(buf, start_field, end_field - start_field + 1);
seqno = g_ascii_strtoull(buf, NULL, 10);
}
void flush_packet(void) {
write_current_packet(FALSE);
}
/*----------------------------------------------------------------------
* Parse the preamble to get the timecode.
*/
static void
parse_preamble (void)
{
int i;
gboolean got_time = FALSE;
/*
* Null-terminate the preamble.
*/
packet_preamble[packet_preamble_len] = '\0';
if (has_direction) {
_parse_dir(&packet_preamble[0], &packet_preamble[1], "iI", "oO", &direction);
i = (direction == PACK_FLAGS_DIRECTION_UNKNOWN) ? 0 : 1;
while (packet_preamble[i] == ' ' ||
packet_preamble[i] == '\r' ||
packet_preamble[i] == '\t') {
i++;
}
packet_preamble_len -= i;
/* Also move the trailing '\0'. */
memmove(packet_preamble, packet_preamble + i, packet_preamble_len + 1);
}
/*
* If no time stamp format was specified, don't attempt to parse
* the packet preamble to extract a time stamp.
*/
/* Ensure preamble has more than two chars before attempting to parse.
* This should cover line breaks etc that get counted.
*/
if ( info_p->timestamp_format != NULL && strlen(packet_preamble) > 2 ) {
got_time = _parse_time(packet_preamble, packet_preamble + strlen(packet_preamble), info_p->timestamp_format, &ts_sec, &ts_nsec);
if (!got_time) {
/* Let's only have a possible GUI popup once, other messages to log
*/
if (!timecode_warned) {
report_warning("Time conversions (%s) failed, advancing time by %d ns from previous packet on failure. First failure was for %s on input packet %d.", info_p->timestamp_format, ts_tick, packet_preamble, info_p->num_packets_read);
timecode_warned = TRUE;
}
ws_warning("Time conversion (%s) failed for %s on input packet %d.", info_p->timestamp_format, packet_preamble, info_p->num_packets_read);
}
}
if (ws_log_get_level() >= LOG_LEVEL_NOISY) {
char *c;
while ((c = strchr(packet_preamble, '\r')) != NULL) *c=' ';
ws_noisy("[[parse_preamble: \"%s\"]]", packet_preamble);
ws_noisy("Format(%s), time(%u), subsecs(%u)", info_p->timestamp_format, (guint32)ts_sec, ts_nsec);
}
if (!got_time) {
ts_nsec += ts_tick;
}
/* Clear Preamble */
packet_preamble_len = 0;
}
/*----------------------------------------------------------------------
* Start a new packet
*
* @param cont [IN] TRUE if a new packet is starting because the max frame
* length was reached on the current packet, and the original packet from the
* input file is continued in a later frame. Passed to write_current_packet,
* where it is used to set fragmentation fields in dummy headers (currently
* only implemented for SCTP; IPv4 could be added later.)
*/
static import_status_t
start_new_packet(gboolean cont)
{
ws_debug("Start new packet (cont = %s).", cont ? "TRUE" : "FALSE");
/* Write out the current packet, if required */
if (write_current_packet(cont) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
info_p->num_packets_read++;
/* Ensure we parse the packet preamble as it may contain the time */
/* THIS IMPLIES A STATE TRANSITION OUTSIDE THE STATE MACHINE */
parse_preamble();
return IMPORT_SUCCESS;
}
/*----------------------------------------------------------------------
* Process a directive
*/
static void
process_directive (char *str _U_)
{
char **tokens;
tokens = g_strsplit_set(str+10, "\r\n", 2);
ws_message("--- Directive [%s] currently unsupported ---", tokens[0]);
g_strfreev(tokens);
}
/*----------------------------------------------------------------------
* Parse a single token (called from the scanner)
*/
import_status_t
parse_token(token_t token, char *str)
{
guint32 num;
/* Variables for the hex+ASCII identification / lookback */
int by_eol;
int rollback = 0;
int line_size;
int i;
char *s2;
char tmp_str[3];
char **tokens;
/*
* This is implemented as a simple state machine of five states.
* State transitions are caused by tokens being received from the
* scanner. The code should be self_documenting.
*/
if (ws_log_get_level() >= LOG_LEVEL_NOISY) {
/* Sanitize - remove all '\r' */
char *c;
if (str!=NULL) { while ((c = strchr(str, '\r')) != NULL) *c=' '; }
ws_noisy("(%s, %s \"%s\") -> (",
state_str[state], token_str[token], str ? str : "");
}
switch(state) {
/* ----- Waiting for new packet -------------------------------------------*/
case INIT:
switch(token) {
case T_TEXT:
append_to_preamble(str);
break;
case T_DIRECTIVE:
process_directive(str);
break;
case T_OFFSET:
if (offset_base == 0) {
append_to_preamble(str);
/* If we're still in the INIT state, maybe there's something
* odd like a time format with no separators. That wouldn't
* work in a mode with an offset, but give it a try.
*/
tokens = g_strsplit_set(str, ": \t\r\n", 2);
if (!offset_warned) {
report_warning("Running in no offset mode but read offset (%s) at start of file, treating as preamble", tokens[0]);
offset_warned = TRUE;
}
ws_warning("Running in no offset mode but read offset (%s) at start of file, treating as preamble", tokens[0]);
g_strfreev(tokens);
break;
}
if (parse_num(str, TRUE, &num) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
if (num == 0) {
/* New packet starts here */
if (start_new_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
state = READ_OFFSET;
pkt_lnstart = packet_buf + num;
}
break;
case T_BYTE:
if (offset_base == 0) {
if (start_new_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
if (write_byte(str) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
state = READ_BYTE;
pkt_lnstart = packet_buf;
}
break;
case T_EOF:
if (write_current_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
break;
default:
break;
}
break;
/* ----- Processing packet, start of new line -----------------------------*/
case START_OF_LINE:
switch(token) {
case T_TEXT:
append_to_preamble(str);
break;
case T_DIRECTIVE:
process_directive(str);
break;
case T_OFFSET:
if (offset_base == 0) {
/* After starting the packet there's no point adding it to
* the preamble in this mode (we only do one packet.)
* Use a generic warning message to suppress the many
* expected duplicates. */
tokens = g_strsplit_set(str, ": \t\r\n", 2);
if (!offset_warned) {
report_warning("Running in no offset mode but read offset (%s) at start of line, ignoring", tokens[0]);
offset_warned = TRUE;
}
ws_warning("Running in no offset mode but read offset (%s) at start of line, ignoring.", tokens[0]);
g_strfreev(tokens);
break;
}
if (parse_num(str, TRUE, &num) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
if (num == 0) {
/* New packet starts here */
if (start_new_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
packet_start = 0;
state = READ_OFFSET;
} else if ((num - packet_start) != curr_offset) {
/*
* The offset we read isn't the one we expected.
* This may only mean that we mistakenly interpreted
* some text as byte values (e.g., if the text dump
* of packet data included a number with spaces around
* it). If the offset is less than what we expected,
* assume that's the problem, and throw away the putative
* extra byte values.
*/
if (num < curr_offset) {
unwrite_bytes(curr_offset - num);
state = READ_OFFSET;
} else {
/* Bad offset; switch to INIT state */
ws_message("Inconsistent offset. Expecting %0X, got %0X. Ignoring rest of packet",
curr_offset, num);
if (write_current_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
state = INIT;
}
} else {
state = READ_OFFSET;
}
pkt_lnstart = packet_buf + num;
break;
case T_BYTE:
if (offset_base == 0) {
if (write_byte(str) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
state = READ_BYTE;
pkt_lnstart = packet_buf;
}
break;
case T_EOF:
if (write_current_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
break;
default:
break;
}
break;
/* ----- Processing packet, read offset -----------------------------------*/
case READ_OFFSET:
switch(token) {
case T_BYTE:
/* Record the byte */
state = READ_BYTE;
if (write_byte(str) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
break;
case T_TEXT:
case T_DIRECTIVE:
case T_OFFSET:
state = READ_TEXT;
break;
case T_EOL:
state = START_OF_LINE;
break;
case T_EOF:
if (write_current_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
break;
default:
break;
}
break;
/* ----- Processing packet, read byte -------------------------------------*/
case READ_BYTE:
switch(token) {
case T_BYTE:
/* Record the byte */
if (write_byte(str) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
break;
case T_TEXT:
case T_DIRECTIVE:
case T_OFFSET:
case T_EOL:
by_eol = 0;
state = READ_TEXT;
if (token == T_EOL) {
by_eol = 1;
state = START_OF_LINE;
}
if (info_p->hexdump.identify_ascii) {
/* Here a line of pkt bytes reading is finished
compare the ascii and hex to avoid such situation:
"61 62 20 ab ", when ab is ascii dump then it should
not be treat as byte */
rollback = 0;
/* s2 is the ASCII string, s1 is the HEX string, e.g, when
s2 = "ab ", s1 = "616220"
we should find out the largest tail of s1 matches the head
of s2, it means the matched part in tail is the ASCII dump
of the head byte. These matched should be rollback */
line_size = curr_offset-(int)(pkt_lnstart-packet_buf);
s2 = (char*)g_malloc((line_size+1)/4+1);
/* gather the possible pattern */
for (i = 0; i < (line_size+1)/4; i++) {
tmp_str[0] = pkt_lnstart[i*3];
tmp_str[1] = pkt_lnstart[i*3+1];
tmp_str[2] = '\0';
/* it is a valid convertable string */
if (!g_ascii_isxdigit(tmp_str[0]) || !g_ascii_isxdigit(tmp_str[1])) {
break;
}
s2[i] = (char)strtoul(tmp_str, (char **)NULL, 16);
rollback++;
/* the 3rd entry is not a delimiter, so the possible byte pattern will not shown */
if (!(pkt_lnstart[i*3+2] == ' ')) {
if (by_eol != 1)
rollback--;
break;
}
}
/* If packet line start contains possible byte pattern, the line end
should contain the matched pattern if the user open the -a flag.
The packet will be possible invalid if the byte pattern cannot find
a matched one in the line of packet buffer.*/
if (rollback > 0) {
if (strncmp(pkt_lnstart+line_size-rollback, s2, rollback) == 0) {
unwrite_bytes(rollback);
}
/* Not matched. This line contains invalid packet bytes, so
discard the whole line */
else {
unwrite_bytes(line_size);
}
}
g_free(s2);
}
break;
case T_EOF:
if (write_current_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
break;
default:
break;
}
break;
/* ----- Processing packet, read text -------------------------------------*/
case READ_TEXT:
switch(token) {
case T_EOL:
state = START_OF_LINE;
break;
case T_EOF:
if (write_current_packet(FALSE) != IMPORT_SUCCESS)
return IMPORT_FAILURE;
break;
default:
break;
}
break;
default:
report_failure("FATAL ERROR: Bad state (%d)", state);
return IMPORT_FAILURE;
}
ws_noisy(", %s)", state_str[state]);
return IMPORT_SUCCESS;
}
/*----------------------------------------------------------------------
* Import a text file.
*/
int
text_import(text_import_info_t * const info)
{
import_status_t status;
int ret;
struct tm *now_tm;
/* Lets start from the beginning */
state = INIT;
curr_offset = 0;
packet_start = 0;
packet_preamble_len = 0;
direction = PACK_FLAGS_DIRECTION_UNKNOWN;
ts_sec = time(0); /* initialize to current time */
now_tm = localtime(&ts_sec);
if (now_tm == NULL) {
/*
* This shouldn't happen - on UN*X, this should Just Work, and
* on 32 bit Windows built with 32 bit time_t, it won't work if ts_sec
* is before the Epoch, but it's long after 1970 (and even 32 bit
* Windows builds with 64 bit time_t by default now), so....
*/
report_failure("localtime(right now) failed");
return WS_EXIT_INIT_FAILED;
}
timecode_default = *now_tm;
timecode_default.tm_isdst = -1; /* Unknown for now, depends on time given to the strptime() function */
ts_nsec = 0;
/* Get input parameters. */
info_p = info;
/* Dummy headers */
hdr_ethernet = FALSE;
hdr_ip = FALSE;
hdr_udp = FALSE;
hdr_tcp = FALSE;
hdr_sctp = FALSE;
hdr_data_chunk = FALSE;
hdr_export_pdu = FALSE;
if (info->mode == TEXT_IMPORT_HEXDUMP) {
switch (info->hexdump.offset_type)
{
case OFFSET_NONE:
offset_base = 0;
break;
case OFFSET_HEX:
offset_base = 16;
break;
case OFFSET_OCT:
offset_base = 8;
break;
case OFFSET_DEC:
offset_base = 10;
break;
}
has_direction = info->hexdump.has_direction;
} else if (info->mode == TEXT_IMPORT_REGEX) {
has_direction = g_regex_get_string_number(info->regex.format, "dir") >= 0;
has_seqno = g_regex_get_string_number(info->regex.format, "seqno") >= 0;
}
if (info->timestamp_format == NULL || g_ascii_strcasecmp(info->timestamp_format, "ISO")) {
ts_fmt_iso = FALSE;
} else {
ts_fmt_iso = TRUE;
}
offset_warned = FALSE;
timecode_warned = FALSE;
/* XXX: It would be good to know the time precision of the file,
* to use for the time delta for packets without timestamps. (ts_tick)
* That could either be added to text_import_info_t or a method
* added to get it from wtap_dumper (which is opaque.)
*/
switch (info->dummy_header_type)
{
case HEADER_ETH:
hdr_ethernet = TRUE;
hdr_ethernet_proto = info->pid;
break;
case HEADER_IPV4:
hdr_ip = TRUE;
hdr_ip_proto = info->protocol;
break;
case HEADER_UDP:
hdr_udp = TRUE;
hdr_tcp = FALSE;
hdr_ip = TRUE;
hdr_ip_proto = 17;
break;
case HEADER_TCP:
hdr_tcp = TRUE;
hdr_udp = FALSE;
hdr_ip = TRUE;
hdr_ip_proto = 6;
break;
case HEADER_SCTP:
hdr_sctp = TRUE;
hdr_ip = TRUE;
hdr_ip_proto = 132;
break;
case HEADER_SCTP_DATA:
hdr_sctp = TRUE;
hdr_data_chunk = TRUE;
hdr_ip = TRUE;
hdr_ip_proto = 132;
break;
case HEADER_EXPORT_PDU:
hdr_export_pdu = TRUE;
break;
default:
break;
}
if (hdr_ip) {
if (info->ipv6) {
hdr_ipv6 = TRUE;
hdr_ip = FALSE;
hdr_ethernet_proto = 0x86DD;
} else {
hdr_ethernet_proto = 0x0800;
}
switch (info->encapsulation) {
case (WTAP_ENCAP_ETHERNET):
hdr_ethernet = TRUE;
break;
case (WTAP_ENCAP_RAW_IP):
break;
case (WTAP_ENCAP_RAW_IP4):
if (info->ipv6) {
report_failure("Encapsulation %s only supports IPv4 headers, not IPv6", wtap_encap_name(info->encapsulation));
return WS_EXIT_INVALID_OPTION;
}
break;
case (WTAP_ENCAP_RAW_IP6):
if (!info->ipv6) {
report_failure("Encapsulation %s only supports IPv6 headers, not IPv4", wtap_encap_name(info->encapsulation));
return WS_EXIT_INVALID_OPTION;
}
break;
default:
report_failure("Dummy IP header not supported with encapsulation: %s (%s)", wtap_encap_name(info->encapsulation), wtap_encap_description(info->encapsulation));
return WS_EXIT_INVALID_OPTION;
}
}
info->num_packets_read = 0;
info->num_packets_written = 0;
packet_buf = (guint8 *)g_malloc(sizeof(HDR_ETHERNET) + sizeof(HDR_IP) +
sizeof(HDR_SCTP) + sizeof(HDR_DATA_CHUNK) +
sizeof(HDR_EXPORT_PDU) + WTAP_MAX_PACKET_SIZE_STANDARD);
if (!packet_buf)
{
/* XXX: This doesn't happen, because g_malloc aborts the program on
* error, unlike malloc or g_try_malloc.
*/
report_failure("FATAL ERROR: no memory for packet buffer");
return WS_EXIT_INIT_FAILED;
}
if (info->mode == TEXT_IMPORT_HEXDUMP) {
status = text_import_scan(info->hexdump.import_text_FILE);
switch(status) {
case (IMPORT_SUCCESS):
ret = 0;
break;
case (IMPORT_FAILURE):
ret = WS_EXIT_INVALID_FILE;
break;
case (IMPORT_INIT_FAILED):
report_failure("Can't initialize scanner: %s", g_strerror(errno));
ret = WS_EXIT_INIT_FAILED;
break;
default:
ret = 0;
}
} else if (info->mode == TEXT_IMPORT_REGEX) {
ret = text_import_regex(info);
if (ret > 0) {
info->num_packets_read = ret;
ret = 0;
} else if (ret < 0) {
ret = WS_EXIT_INVALID_FILE;
}
} else {
ret = WS_EXIT_INVALID_OPTION;
}
g_free(packet_buf);
return ret;
}
/* Write the SHB and IDB to the wtap_dump_params before opening the wtap dump
* file. While dummy headers can be written automatically, this writes out
* some extra information including an optional interface name.
*/
int
text_import_pre_open(wtap_dump_params * const params, int file_type_subtype, const char* const input_filename, const char* const interface_name)
{
wtap_block_t shb_hdr;
wtap_block_t int_data;
wtapng_if_descr_mandatory_t *int_data_mand;
char *comment;
GString *info_str;
if (wtap_file_type_subtype_supports_block(file_type_subtype, WTAP_BLOCK_SECTION) != BLOCK_NOT_SUPPORTED &&
wtap_file_type_subtype_supports_option(file_type_subtype, WTAP_BLOCK_SECTION, OPT_COMMENT) != OPTION_NOT_SUPPORTED) {
shb_hdr = wtap_block_create(WTAP_BLOCK_SECTION);
comment = ws_strdup_printf("Generated from input file %s.", input_filename);
wtap_block_add_string_option(shb_hdr, OPT_COMMENT, comment, strlen(comment));
g_free(comment);
info_str = g_string_new("");
get_cpu_info(info_str);
if (info_str->str) {
wtap_block_add_string_option(shb_hdr, OPT_SHB_HARDWARE, info_str->str, info_str->len);
}
g_string_free(info_str, TRUE);
info_str = g_string_new("");
get_os_version_info(info_str);
if (info_str->str) {
wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, info_str->str, info_str->len);
}
g_string_free(info_str, TRUE);
wtap_block_add_string_option_format(shb_hdr, OPT_SHB_USERAPPL, "%s", get_appname_and_version());
params->shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
g_array_append_val(params->shb_hdrs, shb_hdr);
}
/* wtap_dump_init_dumper() will create a interface block if the file type
* supports it and one isn't created already, but since we have the
* option of including the interface name, create it ourself.
*
* (XXX: IDBs should be optional for wtap_dump_init_dumper(), e.g. if
* the encap type is WTAP_ENCAP_SYSTEMD_JOURNAL, which doesn't use
* interfaces. But it's not, so always create it here.)
*/
if (wtap_file_type_subtype_supports_block(file_type_subtype, WTAP_BLOCK_IF_ID_AND_INFO) != BLOCK_NOT_SUPPORTED) {
int_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = params->encap;
int_data_mand->time_units_per_second = 1000000000;
int_data_mand->snap_len = params->snaplen;
if (interface_name != NULL) {
wtap_block_add_string_option(int_data, OPT_IDB_NAME, interface_name, strlen(interface_name));
} else {
wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF, text2pcap", strlen("Fake IF, text2pcap"));
}
switch (params->tsprec) {
case WTAP_TSPREC_SEC:
int_data_mand->time_units_per_second = 1;
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 0);
break;
case WTAP_TSPREC_DSEC:
int_data_mand->time_units_per_second = 10;
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 1);
break;
case WTAP_TSPREC_CSEC:
int_data_mand->time_units_per_second = 100;
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 2);
break;
case WTAP_TSPREC_MSEC:
int_data_mand->time_units_per_second = 1000;
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 3);
break;
case WTAP_TSPREC_USEC:
int_data_mand->time_units_per_second = 1000000;
/* This is the default, so no need to add an option */
break;
case WTAP_TSPREC_NSEC:
int_data_mand->time_units_per_second = 1000000000;
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 9);
break;
case WTAP_TSPREC_PER_PACKET:
case WTAP_TSPREC_UNKNOWN:
default:
/*
* Don't do this.
*/
ws_assert_not_reached();
break;
}
params->idb_inf = g_new(wtapng_iface_descriptions_t,1);
params->idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
g_array_append_val(params->idb_inf->interface_data, int_data);
}
return EXIT_SUCCESS;
} |
C/C++ | wireshark/ui/text_import.h | /** @file
*
* text_import.h
* State machine for text import
* November 2010, Jaap Keuter <[email protected]>
* Modified February 2021, Paul Weiß
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Based on text2pcap.h by Ashok Narayanan <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later*
*******************************************************************************/
#ifndef __TEXT_IMPORT_H__
#define __TEXT_IMPORT_H__
#include <stdio.h>
#include <wireshark.h>
#include <wiretap/wtap.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* The parameter interface */
enum offset_type
{
OFFSET_NONE = 0,
OFFSET_HEX,
OFFSET_OCT,
OFFSET_DEC
};
enum data_encoding {
ENCODING_PLAIN_HEX,
ENCODING_PLAIN_OCT,
ENCODING_PLAIN_BIN,
ENCODING_BASE64
};
enum dummy_header_type
{
HEADER_NONE,
HEADER_ETH,
HEADER_IPV4,
HEADER_UDP,
HEADER_TCP,
HEADER_SCTP,
HEADER_SCTP_DATA,
HEADER_EXPORT_PDU
};
enum text_import_mode {
TEXT_IMPORT_HEXDUMP,
TEXT_IMPORT_REGEX
};
typedef struct
{
/* Input info */
// TODO: add const, as this way string constants can't be used
// BUT: the other way clang-check complaines when you free them
/* const */ char *import_text_filename;
char *output_filename;
enum text_import_mode mode;
struct {
FILE *import_text_FILE;
enum offset_type offset_type;
gboolean has_direction;
gboolean identify_ascii;
} hexdump;
struct {
GMappedFile* import_text_GMappedFile;
/* const */ GRegex* format;
enum data_encoding encoding;
/* const */ gchar* in_indication;
/* const */ gchar* out_indication;
} regex;
const char* timestamp_format;
/* Import info */
/* Wiretap encapsulation type; see wiretap/wtap.h for details */
guint encapsulation;
wtap_dumper* wdh;
/* Dummy header info (if encapsulation == 1) */
enum dummy_header_type dummy_header_type;
guint pid;
gboolean ipv6;
union {
ws_in4_addr ipv4;
ws_in6_addr ipv6;
} ip_src_addr;
union {
ws_in4_addr ipv4;
ws_in6_addr ipv6;
} ip_dest_addr;
guint protocol;
guint src_port;
guint dst_port;
guint tag;
guint ppi;
/* const */ gchar* payload;
guint max_frame_length;
/* Output info */
guint num_packets_read;
guint num_packets_written;
} text_import_info_t;
int text_import(text_import_info_t * const info);
/* Write the SHB and IDB to the wtap_dump_params before opening the wtap dump
* file. While dummy headers can be written automatically, this writes out
* some extra information including an optional interface name.
*
* NOTE: The caller will be responsible for freeing params->idb_inf after
* finished with the wtap_dumper to avoid a memory leak. wtap_dump_close
* does not free it.
*/
int
text_import_pre_open(wtap_dump_params * const params, int file_type_subtype, const char* const input_filename, const char* const interface_name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TEXT_IMPORT_H__ */ |
C | wireshark/ui/text_import_regex.c | /* text_import_regex.c
* Regex based text importer
* March 2021, Paul Weiß <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Based on text_import.c by Jaap Keuter <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include "text_import.h"
#include "text_import_regex.h"
typedef unsigned int uint;
/*--- Options --------------------------------------------------------------------*/
int text_import_regex(const text_import_info_t* info) {
int status = 1;
int parsed_packets = 0;
ws_debug("starting import...");
// IO
GMappedFile* file = g_mapped_file_ref(info->regex.import_text_GMappedFile);
GError* gerror = NULL;
gsize f_size = g_mapped_file_get_length(file);
guchar* f_content = g_mapped_file_get_contents(file);
{ /* zero terminate the file */
if (f_content[f_size - 1] != '\n') {
fprintf(stderr, "Error: file did not end on \\n\n");
g_mapped_file_unref(file);
return -1;
}
f_content[f_size] = 0;
}
// Regex result dissecting
gboolean re_time, re_dir, re_seqno;
GMatchInfo* match;
gint field_start;
gint field_end;
{ /* analyze regex */
re_time = g_regex_get_string_number(info->regex.format, "time") >= 0;
re_dir = g_regex_get_string_number(info->regex.format, "dir") >= 0;
re_seqno = g_regex_get_string_number(info->regex.format, "seqno") >= 0;
if (g_regex_get_string_number(info->regex.format, "data") < 0) {
/* This should never happen, as the dialog checks for this */
fprintf(stderr, "Error could not find data in pattern\n");
g_mapped_file_unref(file);
return -1;
}
}
ws_debug("regex has %s%s%s", re_dir ? "dir, " : "",
re_time ? "time, " : "",
re_seqno ? "seqno, " : "");
g_regex_match(info->regex.format, f_content, G_REGEX_MATCH_NOTEMPTY, &match);
while (g_match_info_matches(match)) {
/* parse the data */
if (!g_match_info_fetch_named_pos(match, "data", &field_start, &field_end)) {
fprintf(stderr, "Warning: could not fetch data on would be packet %d, discarding\n", parsed_packets + 1);
continue;
}
parse_data(f_content + field_start, f_content + field_end, info->regex.encoding);
/* parse the auxillary information if present */
if (re_time &&
g_match_info_fetch_named_pos(match, "time", &field_start, &field_end)) {
parse_time(f_content + field_start, f_content + field_end, info->timestamp_format);
} else {
/* No time present, so add a fixed delta. */
parse_time(NULL, NULL, NULL);
}
if (re_dir &&
g_match_info_fetch_named_pos(match, "dir", &field_start, &field_end))
parse_dir(f_content + field_start, f_content + field_end, info->regex.in_indication, info->regex.out_indication);
if (re_seqno &&
g_match_info_fetch_named_pos(match, "seqno", &field_start, &field_end))
parse_seqno(f_content + field_start, f_content + field_end);
if (ws_log_get_level() == LOG_LEVEL_NOISY) {
g_match_info_fetch_pos(match, 0, &field_start, &field_end);
ws_noisy("Packet %d at %x to %x: %.*s\n", parsed_packets + 1,
field_start, field_end,
field_end - field_start, f_content + field_start);
}
flush_packet();
/* prepare next packet */
++parsed_packets;
g_match_info_next(match, &gerror);
if (gerror && gerror->code) {
status = -1;
g_error_free(gerror);
break;
}
}
ws_debug("processed %d packets", parsed_packets);
g_match_info_unref(match);
g_mapped_file_unref(file);
return status * parsed_packets;
} |
C/C++ | wireshark/ui/text_import_regex.h | /** @file
*
* text_import_regex.h
* Regex based alternative to the state machine for text import
* Feburary 2021, Paul Weiß <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Based on text_import.h by Jaap Keuter <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later*
*******************************************************************************/
#ifndef __TEXT_IMPORT_REGEX_H__
#define __TEXT_IMPORT_REGEX_H__
#include <glib.h>
#include "text_import.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void parse_data(guchar* start_field, guchar* end_field, enum data_encoding encoding);
void parse_dir(const guchar* start_field, const guchar* end_field, const gchar* in_indicator, const gchar* out_indicator);
void parse_time(const guchar* start_field, const guchar* end_field, const gchar* _format);
void parse_seqno(const guchar* start_field, const guchar* end_field);
void flush_packet(void);
int text_import_regex(const text_import_info_t *info);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TEXT_IMPORT_REGEX_H__ */ |
C/C++ | wireshark/ui/text_import_scanner.h | /** @file
*
* text_import_scanner.h
* Scanner for text import
* November 2010, Jaap Keuter <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Based on text2pcap.h by Ashok Narayanan <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later*
*******************************************************************************/
#ifndef __TEXT_IMPORT_SCANNER_H__
#define __TEXT_IMPORT_SCANNER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef enum {
T_BYTE = 1,
T_OFFSET,
T_DIRECTIVE,
T_TEXT,
T_EOL,
T_EOF
} token_t;
typedef enum {
IMPORT_SUCCESS,
IMPORT_FAILURE,
IMPORT_INIT_FAILED
} import_status_t;
import_status_t parse_token(token_t token, char *str);
extern FILE *text_importin;
import_status_t text_import_scan(FILE *input_file);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TEXT_IMPORT_SCANNER_H__ */ |
wireshark/ui/text_import_scanner.l | /* -*-mode: flex-*- */
%top {
/* Include this before everything else, for various large-file definitions */
#include "config.h"
#include <wireshark.h>
}
/*
* We want a reentrant scanner.
*/
%option reentrant
/*
* We don't use input, so don't generate code for it.
*/
%option noinput
/*
* We don't use unput, so don't generate code for it.
*/
%option nounput
/*
* We don't read interactively from the terminal.
*/
%option never-interactive
/*
* We want to stop processing when we get to the end of the input.
*/
%option noyywrap
/*
* Prefix scanner routines with "text_import_" rather than "yy", so this scanner
* can coexist with other scanners.
*/
%option prefix="text_import_"
/*
* We have to override the memory allocators so that we don't get
* "unused argument" warnings from the yyscanner argument (which
* we don't use, as we have a global memory allocator).
*
* We provide, as macros, our own versions of the routines generated by Flex,
* which just call malloc()/realloc()/free() (as the Flex versions do),
* discarding the extra argument.
*/
%option noyyalloc
%option noyyrealloc
%option noyyfree
%{
/********************************************************************************
*
* text_import_scanner.l
* Scanner for text import
* November 2010, Jaap Keuter <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Based on text2pcap-scanner.l by Ashok Narayanan <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "text_import_scanner.h"
/*
* Disable diagnostics in the code generated by Flex.
*/
DIAG_OFF_FLEX()
/*
* Flex (v 2.5.35) uses this symbol to "exclude" unistd.h
*/
#ifdef _WIN32
# define YY_NO_UNISTD_H
#endif
/*
* Sleazy hack to suppress compiler warnings in yy_fatal_error().
*/
#define YY_EXIT_FAILURE ((void)yyscanner, 2)
/*
* Macros for the allocators, to discard the extra argument.
*/
#define text_import_alloc(size, yyscanner) (void *)malloc(size)
#define text_import_realloc(ptr, size, yyscanner) (void *)realloc((char *)(ptr), (size))
#define text_import_free(ptr, yyscanner) free((char *)ptr)
%}
directive ^#TEXT2PCAP.*\r?\n
comment ^[\t ]*#.*\r?\n
byte [0-9A-Fa-f][0-9A-Fa-f][ \t]?
byte_eol [0-9A-Fa-f][0-9A-Fa-f]\r?\n
offset [0-9A-Fa-f]+[: \t]
offset_eol [0-9A-Fa-f]+\r?\n
text [^ \n\t]+
mailfwd >
eol \r?\n\r?
%%
{byte} { if (parse_token(T_BYTE, yytext) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
{byte_eol} { if (parse_token(T_BYTE, yytext) != IMPORT_SUCCESS) return IMPORT_FAILURE;
if (parse_token(T_EOL, NULL) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
{offset} { if (parse_token(T_OFFSET, yytext) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
{offset_eol} { if (parse_token(T_OFFSET, yytext) != IMPORT_SUCCESS) return IMPORT_FAILURE;
if (parse_token(T_EOL, NULL) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
{mailfwd}{offset} { if (parse_token(T_OFFSET, yytext+1) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
{eol} { if (parse_token(T_EOL, NULL) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
[ \t] ; /* ignore whitespace */
{directive} { if (parse_token(T_DIRECTIVE, yytext) != IMPORT_SUCCESS) return IMPORT_FAILURE;
if (parse_token(T_EOL, NULL) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
{comment} { if (parse_token(T_EOL, NULL) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
{text} { if (parse_token(T_TEXT, yytext) != IMPORT_SUCCESS) return IMPORT_FAILURE; }
<<EOF>> { if (parse_token(T_EOF, NULL) != IMPORT_SUCCESS) return IMPORT_FAILURE; yyterminate(); }
%%
/*
* Turn diagnostics back on, so we check the code that we've written.
*/
DIAG_ON_FLEX()
import_status_t
text_import_scan(FILE *input_file)
{
yyscan_t scanner;
int ret;
if (text_import_lex_init(&scanner) != 0)
return IMPORT_INIT_FAILED;
text_import_set_in(input_file, scanner);
ret = text_import_lex(scanner);
text_import_lex_destroy(scanner);
return ret;
} |
|
C | wireshark/ui/time_shift.c | /* time_shift.c
* Routines for "Time Shift" window
* Submitted by Edwin Groothuis <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "time_shift.h"
#include "ui/packet_list_utils.h"
#define SHIFT_POS 0
#define SHIFT_NEG 1
#define SHIFT_SETTOZERO 1
#define SHIFT_KEEPOFFSET 0
#define CHECK_YEARS(Y) \
if (*Y < 1970) { \
return "Years must be larger than 1970"; \
}
#define CHECK_MONTHS(M) \
if (*M < 1 || *M > 12) { \
return "Months must be between [1..12]"; \
}
#define CHECK_DAYS(D) \
if (*D < 1 || *D > 31) { \
return "Days must be between [1..31]"; \
}
#define CHECK_HOURS(h) \
if (*h < 0 || *h > 23) { \
return "Hours must be between [0..23]"; \
}
#define CHECK_HOUR(h) \
if (*h < 0) { \
return "Negative hours. Have you specified more than " \
"one minus character?"; \
}
#define CHECK_MINUTE(m) \
if (*m < 0 || *m > 59) { \
return "Minutes must be between [0..59]"; \
}
#define CHECK_SECOND(s) \
if (*s < 0 || *s > 59) { \
return "Seconds must be between [0..59]"; \
}
static void
modify_time_perform(frame_data *fd, int neg, nstime_t *offset, int settozero)
{
/* The actual shift */
if (settozero == SHIFT_SETTOZERO) {
nstime_subtract(&(fd->abs_ts), &(fd->shift_offset));
nstime_set_zero(&(fd->shift_offset));
}
if (neg == SHIFT_POS) {
nstime_add(&(fd->abs_ts), offset);
nstime_add(&(fd->shift_offset), offset);
} else if (neg == SHIFT_NEG) {
nstime_subtract(&(fd->abs_ts), offset);
nstime_subtract(&(fd->shift_offset), offset);
} else {
fprintf(stderr, "Modify_time_perform: neg = %d?\n", neg);
}
}
/*
* If the line between (OT1, NT1) and (OT2, NT2) is a straight line
* and (OT3, NT3) is on that line,
* then (NT2 - NT1) / (OT2 - OT2) = (NT3 - NT1) / (OT3 - OT1) and
* then (OT3 - OT1) * (NT2 - NT1) / (OT2 - OT2) = (NT3 - NT1) and
* then NT1 + (OT3 - OT1) * (NT2 - NT1) / (OT2 - OT2) = NT3 and
* then NT3 = NT1 + (OT3 - OT1) * (NT2 - NT1) / (OT2 - OT2) and
* thus NT3 = NT1 + (OT3 - OT1) * (NT2 - NT1) / (OT2 - OT1)
* or NT3 = NT1 + (OT3 - OT1) * ( deltaNT12 / deltaOT12)
*
* All the things you come up when waiting for the train to come...
*/
static void
calcNT3(nstime_t *OT1, nstime_t *OT3, nstime_t *NT1, nstime_t *NT3,
nstime_t *deltaOT, nstime_t *deltaNT)
{
long double fnt, fot, f, secs, nsecs;
fnt = (long double)deltaNT->secs + (deltaNT->nsecs / 1000000000.0L);
fot = (long double)deltaOT->secs + (deltaOT->nsecs / 1000000000.0L);
f = fnt / fot;
nstime_copy(NT3, OT3);
nstime_subtract(NT3, OT1);
secs = f * (long double)NT3->secs;
nsecs = f * (long double)NT3->nsecs;
nsecs += (secs - floorl(secs)) * 1000000000.0L;
while (nsecs > 1000000000L) {
secs += 1;
nsecs -= 1000000000L;
}
while (nsecs < 0) {
secs -= 1;
nsecs += 1000000000L;
}
NT3->secs = (time_t)secs;
NT3->nsecs = (int)nsecs;
nstime_add(NT3, NT1);
}
const gchar *
time_string_parse(const gchar *time_text, int *year, int *month, int *day, gboolean *negative, int *hour, int *minute, long double *second) {
const gchar *pts = time_text;
if (!time_text || !hour || !minute || !second)
return "Unable to convert time.";
/* strip whitespace */
while (g_ascii_isspace(pts[0]))
++pts;
if (year && month && day) {
/*
* The following time format is allowed:
* [YYYY-MM-DD] hh:mm:ss(.decimals)?
*
* Since Wireshark doesn't support regular expressions (please prove me
* wrong :-) we will have to figure it out ourselves in the
* following order:
*
* 1. YYYY-MM-DD hh:mm:ss.decimals
* 2. hh:mm:ss.decimals
*
*/
/* check for empty string */
if (pts[0] == '\0')
return "Time is empty.";
if (sscanf(pts, "%d-%d-%d %d:%d:%Lf", year, month, day, hour, minute, second) == 6) {
/* printf("%%d-%%d-%%d %%d:%%d:%%f\n"); */
CHECK_YEARS(year);
CHECK_MONTHS(month);
CHECK_DAYS(day);
CHECK_HOURS(hour);
CHECK_MINUTE(minute);
CHECK_SECOND(second);
} else if (sscanf(pts, "%d:%d:%Lf", hour, minute, second) == 3) {
/* printf("%%d:%%d:%%f\n"); */
*year = *month = *day = 0;
CHECK_HOUR(hour);
CHECK_MINUTE(minute);
CHECK_SECOND(second);
} else {
return "Could not parse the time. Expected [YYYY-MM-DD] "
"hh:mm:ss[.dec].";
}
} else {
if (!negative)
return "Unable to convert time.";
/*
* The following offset types are allowed:
* -?((hh:)mm:)ss(.decimals)?
*
* Since Wireshark doesn't support regular expressions (please prove me
* wrong :-) we will have to figure it out ourselves in the
* following order:
*
* 1. hh:mm:ss.decimals
* 2. mm:ss.decimals
* 3. ss.decimals
*
*/
/* check for minus sign */
*negative = FALSE;
if (pts[0] == '-') {
*negative = TRUE;
pts++;
}
/* check for empty string */
if (pts[0] == '\0')
return "Time is empty.";
if (sscanf(pts, "%d:%d:%Lf", hour, minute, second) == 3) {
/* printf("%%d:%%d:%%d.%%d\n"); */
CHECK_HOUR(hour);
CHECK_MINUTE(minute);
CHECK_SECOND(second);
} else if (sscanf(pts, "%d:%Lf", minute, second) == 2) {
/* printf("%%d:%%d.%%d\n"); */
CHECK_MINUTE(minute);
CHECK_SECOND(second);
*hour = 0;
} else if (sscanf(pts, "%Lf", second) == 1) {
/* printf("%%d.%%d\n"); */
CHECK_SECOND(second);
*hour = *minute = 0;
} else {
return "Could not parse the time: Expected [[hh:]mm:]ss.[dec].";
}
}
return NULL;
}
static const gchar *
time_string_to_nstime(const gchar *time_text, nstime_t *packettime, nstime_t *nstime)
{
int h, m, Y, M, D;
long double f;
struct tm tm, *tmptm;
time_t tt;
const gchar *err_str;
if ((err_str = time_string_parse(time_text, &Y, &M, &D, NULL, &h, &m, &f)) != NULL)
return err_str;
/* Convert the time entered in an epoch offset */
tmptm = localtime(&(packettime->secs));
if (tmptm) {
tm = *tmptm;
} else {
memset (&tm, 0, sizeof (tm));
}
if (Y != 0) {
tm.tm_year = Y - 1900;
tm.tm_mon = M - 1;
tm.tm_mday = D;
}
tm.tm_hour = h;
tm.tm_min = m;
tm.tm_sec = (int)floorl(f);
tm.tm_isdst = -1;
tt = mktime(&tm);
if (tt == -1) {
return "Mktime went wrong. Is the time valid?";
}
nstime->secs = tt;
f -= tm.tm_sec;
nstime->nsecs = (int)(f * 1000000000);
return NULL;
}
const gchar *
time_shift_all(capture_file *cf, const gchar *offset_text)
{
nstime_t offset;
long double offset_float = 0;
guint32 i;
frame_data *fd;
gboolean neg;
int h, m;
long double f;
const gchar *err_str;
if (!cf || !offset_text)
return "Nothing to work with.";
if ((err_str = time_string_parse(offset_text, NULL, NULL, NULL, &neg, &h, &m, &f)) != NULL)
return err_str;
offset_float = h * 3600 + m * 60 + f;
if (offset_float == 0)
return "Offset is zero.";
nstime_set_zero(&offset);
offset.secs = (time_t)floorl(offset_float);
offset_float -= offset.secs;
offset.nsecs = (int)(offset_float * 1000000000);
if (!frame_data_sequence_find(cf->provider.frames, 1))
return "No frames found."; /* Shouldn't happen */
for (i = 1; i <= cf->count; i++) {
if ((fd = frame_data_sequence_find(cf->provider.frames, i)) == NULL)
continue; /* Shouldn't happen */
modify_time_perform(fd, neg ? SHIFT_NEG : SHIFT_POS, &offset, SHIFT_KEEPOFFSET);
}
cf->unsaved_changes = TRUE;
packet_list_queue_draw();
return NULL;
}
const gchar *
time_shift_settime(capture_file *cf, guint packet_num, const gchar *time_text)
{
nstime_t set_time, diff_time, packet_time;
frame_data *fd, *packetfd;
guint32 i;
const gchar *err_str;
if (!cf || !time_text)
return "Nothing to work with.";
if (packet_num < 1 || packet_num > cf->count)
return "Packet out of range.";
/*
* Get a copy of the real time (abs_ts - shift_offset) do we can find out the
* difference between the specified time and the original packet
*/
if ((packetfd = frame_data_sequence_find(cf->provider.frames, packet_num)) == NULL)
return "No packets found.";
nstime_delta(&packet_time, &(packetfd->abs_ts), &(packetfd->shift_offset));
if ((err_str = time_string_to_nstime(time_text, &packet_time, &set_time)) != NULL)
return err_str;
/* Calculate difference between packet time and requested time */
nstime_delta(&diff_time, &set_time, &packet_time);
/* Up to here nothing is changed */
if (!frame_data_sequence_find(cf->provider.frames, 1))
return "No frames found."; /* Shouldn't happen */
/* Set everything back to the original time */
for (i = 1; i <= cf->count; i++) {
if ((fd = frame_data_sequence_find(cf->provider.frames, i)) == NULL)
continue; /* Shouldn't happen */
modify_time_perform(fd, SHIFT_POS, &diff_time, SHIFT_SETTOZERO);
}
cf->unsaved_changes = TRUE;
packet_list_queue_draw();
return NULL;
}
const gchar *
time_shift_adjtime(capture_file *cf, guint packet1_num, const gchar *time1_text, guint packet2_num, const gchar *time2_text)
{
nstime_t nt1, nt2, ot1, ot2, nt3;
nstime_t dnt, dot, d3t;
frame_data *fd, *packet1fd, *packet2fd;
guint32 i;
const gchar *err_str;
if (!cf || !time1_text || !time2_text)
return "Nothing to work with.";
if (packet1_num < 1 || packet1_num > cf->count || packet2_num < 1 || packet2_num > cf->count)
return "Packet out of range.";
/*
* The following time format is allowed:
* [YYYY-MM-DD] hh:mm:ss(.decimals)?
*
* Since Wireshark doesn't support regular expressions (please prove me
* wrong :-) we will have to figure it out ourselves in the
* following order:
*
* 1. YYYY-MM-DD hh:mm:ss.decimals
* 2. hh:mm:ss.decimals
*
*/
/*
* Get a copy of the real time (abs_ts - shift_offset) do we can find out the
* difference between the specified time and the original packet
*/
if ((packet1fd = frame_data_sequence_find(cf->provider.frames, packet1_num)) == NULL)
return "No frames found.";
nstime_copy(&ot1, &(packet1fd->abs_ts));
nstime_subtract(&ot1, &(packet1fd->shift_offset));
if ((err_str = time_string_to_nstime(time1_text, &ot1, &nt1)) != NULL)
return err_str;
/*
* Get a copy of the real time (abs_ts - shift_offset) do we can find out the
* difference between the specified time and the original packet
*/
if ((packet2fd = frame_data_sequence_find(cf->provider.frames, packet2_num)) == NULL)
return "No frames found.";
nstime_copy(&ot2, &(packet2fd->abs_ts));
nstime_subtract(&ot2, &(packet2fd->shift_offset));
if ((err_str = time_string_to_nstime(time2_text, &ot2, &nt2)) != NULL)
return err_str;
nstime_copy(&dot, &ot2);
nstime_subtract(&dot, &ot1);
nstime_copy(&dnt, &nt2);
nstime_subtract(&dnt, &nt1);
/* Up to here nothing is changed */
if (!frame_data_sequence_find(cf->provider.frames, 1))
return "No frames found."; /* Shouldn't happen */
for (i = 1; i <= cf->count; i++) {
if ((fd = frame_data_sequence_find(cf->provider.frames, i)) == NULL)
continue; /* Shouldn't happen */
/* Set everything back to the original time */
nstime_subtract(&(fd->abs_ts), &(fd->shift_offset));
nstime_set_zero(&(fd->shift_offset));
/* Add the difference to each packet */
calcNT3(&ot1, &(fd->abs_ts), &nt1, &nt3, &dot, &dnt);
nstime_copy(&d3t, &nt3);
nstime_subtract(&d3t, &(fd->abs_ts));
modify_time_perform(fd, SHIFT_POS, &d3t, SHIFT_SETTOZERO);
}
cf->unsaved_changes = TRUE;
packet_list_queue_draw();
return NULL;
}
const gchar *
time_shift_undo(capture_file *cf)
{
guint32 i;
frame_data *fd;
nstime_t nulltime;
if (!cf)
return "Nothing to work with.";
nulltime.secs = nulltime.nsecs = 0;
if (!frame_data_sequence_find(cf->provider.frames, 1))
return "No frames found."; /* Shouldn't happen */
for (i = 1; i <= cf->count; i++) {
if ((fd = frame_data_sequence_find(cf->provider.frames, i)) == NULL)
continue; /* Shouldn't happen */
modify_time_perform(fd, SHIFT_NEG, &nulltime, SHIFT_SETTOZERO);
}
packet_list_queue_draw();
return NULL;
} |
C/C++ | wireshark/ui/time_shift.h | /** @file
*
* Submitted by Edwin Groothuis <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TIME_SHIFT_H__
#define __TIME_SHIFT_H__
#include "cfile.h"
#include <wsutil/nstime.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* XXX - We might want to move all of this somewhere more accessible to
* editcap so that we can make its time adjustments more versatile.
*/
/**
* Parse a time string and fill in each component.
*
* If year, month, and day are non-NULL a full time format "[YYYY-MM-DD] hh:mm:ss[.decimals]"
* is allowed. Otherwise an offset format "[-][[hh:]mm:]ss[.decimals]" is allowed.
*
* @param time_text Time string
* @param year Year. May be NULL
* @param month Month. May be NULL
* @param day Day. May be NULL.
* @param negative Time offset is negative. May be NULL if year, month, and day are not NULL.
* @param hour Hours. Must not be NULL.
* @param minute Minutes. Must not be NULL.
* @param second Seconds. Must not be NULL.
*
* @return NULL on success or an error description on failure.
*/
const gchar * time_string_parse(const gchar *time_text, int *year, int *month, int *day, gboolean *negative, int *hour, int *minute, long double *second);
/** Shift all packets by an offset
*
* @param cf Capture file to shift
* @param offset_text String representation of the offset.
*
* @return NULL on success or an error description on failure.
*/
const gchar * time_shift_all(capture_file *cf, const gchar *offset_text);
/* Set the time for a single packet
*
* @param cf Capture file to set
* @param packet_num Packet to set
* @param time_text String representation of the time
*
* @return NULL on success or an error description on failure.
*/
const gchar * time_shift_settime(capture_file *cf, guint packet_num, const gchar *time_text);
/* Set the time for two packets and extrapolate the rest
*
* @param cf Capture file to set
* @param packet1_num First packet to set
* @param time1_text String representation of the first packet time
* @param packet2_num Second packet to set
* @param time2_text String representation of the second packet time
*
* @return NULL on success or an error description on failure.
*/
const gchar * time_shift_adjtime(capture_file *cf, guint packet1_num, const gchar *time1_text, guint packet2_num, const gchar *time2_text);
/* Reset the times for all packets
*
* @param cf Capture file to set
*
* @return NULL on success or an error description on failure.
*/
const gchar * time_shift_undo(capture_file *cf);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TIME_SHIFT_H__ */ |
C/C++ | wireshark/ui/urls.h | /** @file
*
* Define URLs for various Wireshark sites, so that if they move, we only
* have to change the URLs here.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 2000 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#define WS_HOME_PAGE_URL "https://www.wireshark.org"
#define WS_DOWNLOAD_URL "https://www.wireshark.org/download.html"
#define WS_DOCS_URL "https://www.wireshark.org/docs/"
#define WS_FAQ_URL "https://www.wireshark.org/faq.html"
#define WS_Q_AND_A_URL "https://ask.wireshark.org"
#define WS_WIKI_HOME_URL "https://gitlab.com/wireshark/wireshark/-/wikis"
/*
* Construct a wiki URL given the path to the wiki page.
*/
#define WS_WIKI_URL(path) WS_WIKI_HOME_URL "/" path |
C | wireshark/ui/util.c | /* util.c
* Utility routines
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include "epan/address.h"
#include "epan/addr_resolv.h"
#include "epan/strutil.h"
#include "ui/util.h"
/*
* Collect command-line arguments as a string consisting of the arguments,
* separated by spaces.
*/
char *
get_args_as_string(int argc, char **argv, int optindex)
{
int len;
int i;
char *argstring;
/*
* Find out how long the string will be.
*/
len = 0;
for (i = optindex; i < argc; i++) {
len += (int) strlen(argv[i]);
len++; /* space, or '\0' if this is the last argument */
}
/*
* If no arguments, return empty string
*/
if (len == 0)
return g_strdup("");
/*
* Allocate the buffer for the string.
*/
argstring = (char *)g_malloc(len);
/*
* Now construct the string.
*/
argstring[0] = '\0';
i = optindex;
for (;;) {
(void) g_strlcat(argstring, argv[i], len);
i++;
if (i == argc)
break;
(void) g_strlcat(argstring, " ", len);
}
return argstring;
}
/* Compute the difference between two seconds/microseconds time stamps. */
void
compute_timestamp_diff(gint *diffsec, gint *diffusec,
guint32 sec1, guint32 usec1, guint32 sec2, guint32 usec2)
{
if (sec1 == sec2) {
/* The seconds part of the first time is the same as the seconds
part of the second time, so if the microseconds part of the first
time is less than the microseconds part of the second time, the
first time is before the second time. The microseconds part of
the delta should just be the difference between the microseconds
part of the first time and the microseconds part of the second
time; don't adjust the seconds part of the delta, as it's OK if
the microseconds part is negative. */
*diffsec = sec1 - sec2;
*diffusec = usec1 - usec2;
} else if (sec1 <= sec2) {
/* The seconds part of the first time is less than the seconds part
of the second time, so the first time is before the second time.
Both the "seconds" and "microseconds" value of the delta
should have the same sign, so if the difference between the
microseconds values would be *positive*, subtract 1,000,000
from it, and add one to the seconds value. */
*diffsec = sec1 - sec2;
if (usec2 >= usec1) {
*diffusec = usec1 - usec2;
} else {
*diffusec = (usec1 - 1000000) - usec2;
(*diffsec)++;
}
} else {
/* Oh, good, we're not caught in a chronosynclastic infindibulum. */
*diffsec = sec1 - sec2;
if (usec2 <= usec1) {
*diffusec = usec1 - usec2;
} else {
*diffusec = (usec1 + 1000000) - usec2;
(*diffsec)--;
}
}
}
/* Remove any %<interface_name> from an IP address. */
static char *sanitize_filter_ip(char *hostname) {
gchar *end;
gchar *ret;
ret = g_strdup(hostname);
if (!ret)
return NULL;
end = strchr(ret, '%');
if (end)
*end = '\0';
return ret;
}
/* Try to figure out if we're remotely connected, e.g. via ssh or
Terminal Server, and create a capture filter that matches aspects of the
connection. We match the following environment variables:
SSH_CONNECTION (ssh): <remote IP> <remote port> <local IP> <local port>
SSH_CLIENT (ssh): <remote IP> <remote port> <local port>
REMOTEHOST (tcsh, others?): <remote name>
DISPLAY (x11): [remote name]:<display num>
SESSIONNAME (terminal server): <remote name>
*/
const gchar *get_conn_cfilter(void) {
static GString *filter_str = NULL;
gchar *env, **tokens;
char *lastp, *lastc, *p;
char *pprotocol = NULL;
char *phostname = NULL;
size_t hostlen;
char *remip, *locip;
if (filter_str == NULL) {
filter_str = g_string_new("");
}
if ((env = getenv("SSH_CONNECTION")) != NULL) {
tokens = g_strsplit(env, " ", 4);
if (g_strv_length(tokens) == 4) {
remip = sanitize_filter_ip(tokens[0]);
locip = sanitize_filter_ip(tokens[2]);
g_string_printf(filter_str, "not (tcp port %s and host %s "
"and tcp port %s and host %s)", tokens[1], remip,
tokens[3], locip);
g_free(remip);
g_free(locip);
}
g_strfreev(tokens);
} else if ((env = getenv("SSH_CLIENT")) != NULL) {
tokens = g_strsplit(env, " ", 3);
if (g_strv_length(tokens) == 3) {
remip = sanitize_filter_ip(tokens[2]);
g_string_printf(filter_str, "not (tcp port %s and host %s "
"and tcp port %s)", tokens[1], tokens[0], remip);
g_free(remip);
}
g_strfreev(tokens);
} else if ((env = getenv("REMOTEHOST")) != NULL) {
/* FreeBSD 7.0 sets REMOTEHOST to an empty string */
if (g_ascii_strcasecmp(env, "localhost") == 0 ||
strcmp(env, "127.0.0.1") == 0 ||
strcmp(env, "") == 0) {
return "";
}
remip = sanitize_filter_ip(env);
g_string_printf(filter_str, "not host %s", remip);
g_free(remip);
} else if ((env = getenv("DISPLAY")) != NULL) {
/*
* This mirrors what _X11TransConnectDisplay() does.
* Note that, on some systems, the hostname can
* begin with "/", which means that it's a pathname
* of a UNIX domain socket to connect to.
*
* The comments mirror those in _X11TransConnectDisplay(),
* too. :-)
*
* Display names may be of the following format:
*
* [protoco./] [hostname] : [:] displaynumber [.screennumber]
*
* A string with exactly two colons separating hostname
* from the display indicates a DECnet style name. Colons
* in the hostname may occur if an IPv6 numeric address
* is used as the hostname. An IPv6 numeric address may
* also end in a double colon, so three colons in a row
* indicates an IPv6 address ending in :: followed by
* :display. To make it easier for people to read, an
* IPv6 numeric address hostname may be surrounded by []
* in a similar fashion to the IPv6 numeric address URL
* syntax defined by IETF RFC 2732.
*
* If no hostname and no protocol is specified, the string
* is interpreted as the most efficient local connection
* to a server on the same machine. This is usually:
*
* o shared memory
* o local stream
* o UNIX domain socket
* o TCP to local host.
*/
p = env;
/*
* Step 0, find the protocol. This is delimited by
* the optional slash ('/').
*/
for (lastp = p; *p != '\0' && *p != ':' && *p != '/'; p++)
;
if (*p == '\0')
return ""; /* must have a colon */
if (p != lastp && *p != ':') { /* protocol given? */
/* Yes */
pprotocol = p;
/* Is it TCP? */
if (p - lastp != 3 || g_ascii_strncasecmp(lastp, "tcp", 3) != 0)
return ""; /* not TCP */
p++; /* skip the '/' */
} else
p = env; /* reset the pointer in
case no protocol was given */
/*
* Step 1, find the hostname. This is delimited either by
* one colon, or two colons in the case of DECnet (DECnet
* Phase V allows a single colon in the hostname). (See
* note above regarding IPv6 numeric addresses with
* triple colons or [] brackets.)
*/
lastp = p;
lastc = NULL;
for (; *p != '\0'; p++)
if (*p == ':')
lastc = p;
if (lastc == NULL)
return ""; /* must have a colon */
if ((lastp != lastc) && (*(lastc - 1) == ':')
&& (((lastc - 1) == lastp) || (*(lastc - 2) != ':'))) {
/* DECnet display specified */
return "";
} else
hostlen = lastc - lastp;
if (hostlen == 0)
return ""; /* no hostname supplied */
phostname = (char *)g_malloc(hostlen + 1);
memcpy(phostname, lastp, hostlen);
phostname[hostlen] = '\0';
if (pprotocol == NULL) {
/*
* No protocol was explicitly specified, so it
* could be a local connection over a transport
* that we won't see.
*
* Does the host name refer to the local host?
* If so, the connection would probably be a
* local connection.
*
* XXX - compare against our host name?
* _X11TransConnectDisplay() does.
*/
if (g_ascii_strcasecmp(phostname, "localhost") == 0 ||
strcmp(phostname, "127.0.0.1") == 0) {
g_free(phostname);
return "";
}
/*
* A host name of "unix" (case-sensitive) also
* causes a local connection.
*/
if (strcmp(phostname, "unix") == 0) {
g_free(phostname);
return "";
}
/*
* Does the host name begin with "/"? If so,
* it's presumed to be the pathname of a
* UNIX domain socket.
*/
if (phostname[0] == '/') {
g_free(phostname);
return "";
}
}
g_string_printf(filter_str, "not host %s", phostname);
g_free(phostname);
#ifdef _WIN32
} else if (GetSystemMetrics(SM_REMOTESESSION)) {
/* We have a remote session: https://docs.microsoft.com/en-us/windows/win32/termserv/detecting-the-terminal-services-environment */
g_string_printf(filter_str, "not port 3389");
#endif /* _WIN32 */
} else {
return "";
}
return filter_str->str;
}
gboolean display_is_remote(void)
{
static gboolean remote_display_checked;
static gboolean is_remote;
if (!remote_display_checked) {
is_remote = (strlen(get_conn_cfilter()) > 0);
}
return is_remote;
} |
C/C++ | wireshark/ui/util.h | /** @file
*
* Utility definitions
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __UTIL_H__
#define __UTIL_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Collect command-line arguments as a string consisting of the arguments,
* separated by spaces.
*/
char *get_args_as_string(int argc, char **argv, int optindex);
/* Compute the difference between two seconds/microseconds time stamps.
* Beware: we're using nanosecond resolution now and function is currently unused
*/
void compute_timestamp_diff(gint *diffsec, gint *diffusec,
guint32 sec1, guint32 usec1, guint32 sec2, guint32 usec2);
/* Try to figure out if we're remotely connected, e.g. via ssh or
Terminal Server, and create a capture filter that matches aspects of the
connection. We match the following environment variables:
SSH_CONNECTION (ssh): <remote IP> <remote port> <local IP> <local port>
SSH_CLIENT (ssh): <remote IP> <remote port> <local port>
REMOTEHOST (tcsh, others?): <remote name>
DISPLAY (x11): [remote name]:<display num>
CLIENTNAME (terminal server): <remote name>
*/
const char *get_conn_cfilter(void);
/** Check if we're running on a remote connection.
* @return TRUE if we're running remotely, FALSE if local.
*/
gboolean display_is_remote(void);
/** Set the latest opened directory.
* Will already be done when using file_selection_new().
*
* @param dirname the dirname
*/
extern void set_last_open_dir(const char *dirname);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __UTIL_H__ */ |
C | wireshark/ui/voip_calls.c | /* voip_calls.c
* VoIP calls summary addition for Wireshark
*
* Copyright 2004, Ericsson, Spain
* By Francisco Alcoba <[email protected]>
*
* based on h323_calls.c
* Copyright 2004, Iskratel, Ltd, Kranj
* By Miha Jemec <[email protected]>
*
* H323, RTP, RTP Event, MGCP, AudioCodes (ISDN PRI and CAS), T38 and Graph Support
* By Alejandro Vaquero, [email protected]
* Copyright 2005, Verso Technologies Inc.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "epan/epan_dissect.h"
#include "epan/packet.h"
#include "epan/proto_data.h"
#include "epan/to_str.h"
#include "epan/dissectors/packet-sip.h"
#include "epan/dissectors/packet-h225.h"
#include "epan/dissectors/packet-h245.h"
#include "epan/dissectors/packet-isup.h"
#include "epan/dissectors/packet-sdp.h"
#include "epan/dissectors/packet-mgcp.h"
#include "epan/dissectors/packet-mtp3.h"
#include "epan/dissectors/packet-actrace.h"
#include "epan/dissectors/packet-q931.h"
#include "epan/dissectors/packet-rtp.h"
#include "epan/dissectors/packet-rtp-events.h"
#include "epan/dissectors/packet-t38.h"
#include "epan/dissectors/packet-t30.h"
#include "epan/dissectors/packet-h248.h"
#include "epan/dissectors/packet-sccp.h"
#include "plugins/epan/unistim/packet-unistim.h"
#include "epan/dissectors/packet-skinny.h"
#include "epan/dissectors/packet-iax2.h"
#include "epan/rtp_pt.h"
#include "ui/rtp_stream.h"
#include "ui/simple_dialog.h"
#include "ui/tap-rtp-common.h"
#include "ui/ws_ui_util.h"
#include "ui/voip_calls.h"
#include "wsutil/glib-compat.h"
#include <wsutil/ws_assert.h>
#define DUMP_PTR1(p) printf("#=> %p\n",(void *)p)
#define DUMP_PTR2(p) printf("==> %p\n",(void *)p)
const char *voip_call_state_name[8]={
"",
"CALL SETUP",
"RINGING",
"IN CALL",
"CANCELLED",
"COMPLETED",
"REJECTED",
"UNKNOWN"
};
/* defines whether we can consider the call active */
const char *voip_protocol_name[]={
"SIP",
"ISUP",
"H.323",
"MGCP",
"AC_ISDN",
"AC_CAS",
"T.38",
"H.248",
"SCCP",
"BSSMAP",
"RANAP",
"UNISTIM",
"SKINNY",
"IAX2",
"VoIP"
};
/*
* Tap IDs must be unique. Since different taps need to share the
* same voip_calls_tapinfo_t *, make it unique by offsetting its
* value.
*/
enum {
tap_id_offset_actrace_,
tap_id_offset_h225_,
tap_id_offset_h245dg_,
tap_id_offset_h248_,
tap_id_offset_iax2_,
tap_id_offset_isup_,
tap_id_offset_m3ua_,
tap_id_offset_megaco_,
tap_id_offset_mgcp_,
tap_id_offset_mtp3_,
tap_id_offset_q931_,
tap_id_offset_rtp_,
tap_id_offset_rtp_event_,
tap_id_offset_sccp_,
tap_id_offset_sdp_,
tap_id_offset_sip_,
tap_id_offset_skinny_,
tap_id_offset_sua_,
tap_id_offset_t38_,
tap_id_offset_unistim_,
tap_id_offset_voip_
};
#define REDRAW_ACTRACE (1 << tap_id_offset_actrace_)
#define REDRAW_H225 (1 << tap_id_offset_h225_)
#define REDRAW_H245DG (1 << tap_id_offset_h245dg_)
#define REDRAW_H248 (1 << tap_id_offset_h248_)
#define REDRAW_IAX2 (1 << tap_id_offset_iax2_)
#define REDRAW_ISUP (1 << tap_id_offset_isup_)
#define REDRAW_M3UA (1 << tap_id_offset_m3ua_)
#define REDRAW_MEGACO (1 << tap_id_offset_megaco_)
#define REDRAW_MGCP (1 << tap_id_offset_mgcp_)
#define REDRAW_MTP3 (1 << tap_id_offset_mtp3_)
#define REDRAW_Q931 (1 << tap_id_offset_q931_)
#define REDRAW_RTP (1 << tap_id_offset_rtp_)
#define REDRAW_RTP_EVENT (1 << tap_id_offset_rtp_event_)
#define REDRAW_SCCP (1 << tap_id_offset_sccp_)
#define REDRAW_SDP (1 << tap_id_offset_sdp_)
#define REDRAW_SIP (1 << tap_id_offset_sip_)
#define REDRAW_SKINNY (1 << tap_id_offset_skinny_)
#define REDRAW_SUA (1 << tap_id_offset_sua_)
#define REDRAW_T38 (1 << tap_id_offset_t38_)
#define REDRAW_UNISTIM (1 << tap_id_offset_unistim_)
#define REDRAW_VOIP (1 << tap_id_offset_voip_)
static inline void *
tap_base_to_id(voip_calls_tapinfo_t* tap_base, int offset) {
return GSIZE_TO_POINTER(GPOINTER_TO_SIZE(tap_base) + offset);
}
static inline voip_calls_tapinfo_t *
tap_id_to_base(void* tap_id, int offset) {
return (voip_calls_tapinfo_t *) GSIZE_TO_POINTER(GPOINTER_TO_SIZE(tap_id) - offset);
}
typedef struct {
gchar *frame_label;
gchar *comment;
} graph_str;
#define H245_MAX 6
typedef struct _h245_labels {
guint32 frame_num;
gint8 labels_count;
graph_str labels[H245_MAX];
} h245_labels_t;
static void actrace_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void h225_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void h245dg_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void h248_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void iax2_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void isup_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void mgcp_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void mtp3_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void q931_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void rtp_event_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void rtp_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void sccp_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void sdp_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void sip_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void skinny_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void t38_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void unistim_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
static void voip_calls_init_tap(voip_calls_tapinfo_t *tap_id_base);
void
voip_calls_init_all_taps(voip_calls_tapinfo_t *tap_id_base)
{
actrace_calls_init_tap(tap_id_base);
h225_calls_init_tap(tap_id_base);
h245dg_calls_init_tap(tap_id_base);
h248_calls_init_tap(tap_id_base);
iax2_calls_init_tap(tap_id_base);
isup_calls_init_tap(tap_id_base);
mgcp_calls_init_tap(tap_id_base);
mtp3_calls_init_tap(tap_id_base);
q931_calls_init_tap(tap_id_base);
rtp_event_init_tap(tap_id_base);
rtp_init_tap(tap_id_base); /* This calls tap_reset_cb, tap_packet_cb, and tap_draw_cb */
sccp_calls_init_tap(tap_id_base);
sdp_calls_init_tap(tap_id_base);
sip_calls_init_tap(tap_id_base);
skinny_calls_init_tap(tap_id_base);
t38_init_tap(tap_id_base);
/* We don't register this tap if we don't have the unistim plugin loaded.*/
if (find_tap_id("unistim")) {
unistim_calls_init_tap(tap_id_base);
}
if (find_tap_id("voip")) {
voip_calls_init_tap(tap_id_base);
}
}
static void remove_tap_listener_actrace_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_h225_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_h245dg_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_h248_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_iax2_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_isup_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_mgcp_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_mtp3_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_q931_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_rtp(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_rtp_event(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_sccp_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_sdp_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_sip_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_skinny_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_t38(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_unistim_calls(voip_calls_tapinfo_t *tap_id_base);
static void remove_tap_listener_voip_calls(voip_calls_tapinfo_t *tap_id_base);
void voip_calls_remove_all_tap_listeners(voip_calls_tapinfo_t *tap_id_base)
{
/* Remove the calls tap listener */
remove_tap_listener_actrace_calls(tap_id_base);
remove_tap_listener_h225_calls(tap_id_base);
remove_tap_listener_h245dg_calls(tap_id_base);
remove_tap_listener_h248_calls(tap_id_base);
remove_tap_listener_iax2_calls(tap_id_base);
remove_tap_listener_isup_calls(tap_id_base);
remove_tap_listener_mgcp_calls(tap_id_base);
remove_tap_listener_mtp3_calls(tap_id_base);
remove_tap_listener_q931_calls(tap_id_base);
remove_tap_listener_rtp(tap_id_base);
remove_tap_listener_rtp_event(tap_id_base);
remove_tap_listener_sccp_calls(tap_id_base);
remove_tap_listener_sdp_calls(tap_id_base);
remove_tap_listener_sip_calls(tap_id_base);
remove_tap_listener_skinny_calls(tap_id_base);
remove_tap_listener_t38(tap_id_base);
if (find_tap_id("unistim")) { /* The plugin may be missing */
remove_tap_listener_unistim_calls(tap_id_base);
}
if (find_tap_id("voip")) {
remove_tap_listener_voip_calls(tap_id_base);
}
}
/****************************************************************************/
/* when there is a [re]reading of packet's */
void
voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo)
{
voip_calls_info_t *callsinfo;
rtpstream_info_t *strinfo;
GList *list = NULL;
/* VOIP_CALLS_DEBUG("reset packets: %d streams: %d", tapinfo->npackets, tapinfo->nrtpstreams); */
/* free the data items first */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
callsinfo = (voip_calls_info_t *)list->data;
voip_calls_free_callsinfo(callsinfo);
list = g_list_next(list);
}
g_queue_clear(tapinfo->callsinfos);
/* free the SIP_HASH */
if(NULL!=tapinfo->callsinfo_hashtable[SIP_HASH])
{
g_hash_table_destroy(tapinfo->callsinfo_hashtable[SIP_HASH]);
tapinfo->callsinfo_hashtable[SIP_HASH] = NULL;
}
/* free the strinfo data items first */
list = g_list_first(tapinfo->rtpstream_list);
while(list)
{
strinfo = (rtpstream_info_t *)list->data;
rtpstream_info_free_all(strinfo);
list = g_list_next(list);
}
g_list_free(tapinfo->rtpstream_list);
tapinfo->rtpstream_list = NULL;
g_free(tapinfo->sdp_summary);
tapinfo->sdp_summary = NULL;
if (tapinfo->h245_labels) {
memset(tapinfo->h245_labels, 0, sizeof(h245_labels_t));
}
tapinfo->ncalls = 0;
tapinfo->start_packets = 0;
tapinfo->completed_calls = 0;
tapinfo->rejected_calls = 0;
return;
}
/****************************************************************************/
/* free one callsinfo */
void
voip_calls_free_callsinfo(voip_calls_info_t *callsinfo)
{
g_free(callsinfo->call_id);
g_free(callsinfo->from_identity);
g_free(callsinfo->to_identity);
free_address(&callsinfo->initial_speaker);
g_free(callsinfo->protocol_name);
g_free(callsinfo->call_comment);
if (callsinfo->free_prot_info && callsinfo->prot_info)
callsinfo->free_prot_info(callsinfo->prot_info);
g_free(callsinfo);
}
/****************************************************************************/
/* Add a new item into the graph */
static void
add_to_graph(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan_dissect_t *edt, const gchar *frame_label, const gchar *comment, guint16 call_num, address *src_addr, address *dst_addr, guint16 line_style)
{
seq_analysis_item_t *gai;
gchar time_str[COL_MAX_LEN];
if (!tapinfo->graph_analysis) {
return;
}
gai = g_new0(seq_analysis_item_t, 1);
gai->frame_number = pinfo->num;
copy_address(&(gai->src_addr),src_addr);
copy_address(&(gai->dst_addr),dst_addr);
gai->port_src=pinfo->srcport;
gai->port_dst=pinfo->destport;
if (frame_label != NULL)
gai->frame_label = g_strdup(frame_label);
else
gai->frame_label = g_strdup("");
if (comment != NULL)
gai->comment = g_strdup(comment);
else
gai->comment = g_strdup("");
gai->conv_num=call_num;
gai->line_style=line_style;
set_fd_time(edt->session, pinfo->fd, time_str);
gai->time_str = g_strdup(time_str);
gai->display=FALSE;
g_queue_push_tail(tapinfo->graph_analysis->items, gai);
g_hash_table_insert(tapinfo->graph_analysis->ht, GUINT_TO_POINTER(gai->frame_number), gai);
}
/****************************************************************************/
/* Append str to frame_label and comment in a graph item */
/* return 0 if the frame_num is not in the graph list */
static int append_to_frame_graph(voip_calls_tapinfo_t *tapinfo, guint32 frame_num, const gchar *new_frame_label, const gchar *new_comment)
{
seq_analysis_item_t *gai=NULL;
gchar *frame_label = NULL;
gchar *comment = NULL;
if(tapinfo->graph_analysis && NULL!=tapinfo->graph_analysis->ht)
gai=(seq_analysis_item_t *)g_hash_table_lookup(tapinfo->graph_analysis->ht, GUINT_TO_POINTER(frame_num));
if(gai) {
frame_label = gai->frame_label;
comment = gai->comment;
if (new_frame_label != NULL) {
gai->frame_label = ws_strdup_printf("%s %s", frame_label, new_frame_label);
g_free(frame_label);
}
if (new_comment != NULL) {
gai->comment = ws_strdup_printf("%s %s", comment, new_comment);
g_free(comment);
}
}
return gai? 1 : 0;
}
/****************************************************************************/
/* Change the frame_label and comment in a graph item if not NULL*/
/* return 0 if the frame_num is not in the graph list */
static int change_frame_graph(voip_calls_tapinfo_t *tapinfo, guint32 frame_num, const gchar *new_frame_label, const gchar *new_comment)
{
seq_analysis_item_t *gai=NULL;
gchar *frame_label = NULL;
gchar *comment = NULL;
if(tapinfo->graph_analysis && NULL!=tapinfo->graph_analysis->ht)
gai=(seq_analysis_item_t *)g_hash_table_lookup(tapinfo->graph_analysis->ht, GUINT_TO_POINTER(frame_num));
if(gai) {
frame_label = gai->frame_label;
comment = gai->comment;
if (new_frame_label != NULL) {
gai->frame_label = g_strdup(new_frame_label);
g_free(frame_label);
}
if (new_comment != NULL) {
gai->comment = g_strdup(new_comment);
g_free(comment);
}
}
return gai? 1 : 0;
}
/****************************************************************************/
/* Change all the graph items with call_num to new_call_num */
static guint change_call_num_graph(voip_calls_tapinfo_t *tapinfo, guint16 call_num, guint16 new_call_num)
{
seq_analysis_item_t *gai;
GList *list;
guint items_changed;
items_changed = 0;
if(tapinfo->graph_analysis){
list = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
while (list)
{
gai = (seq_analysis_item_t *)list->data;
if (gai->conv_num == call_num) {
gai->conv_num = new_call_num;
items_changed++;
}
list = g_list_next(list);
}
}
return items_changed;
}
/****************************************************************************/
/* Insert the item in the graph list */
static void insert_to_graph_t38(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan_dissect_t *edt, const gchar *frame_label, const gchar *comment, guint16 call_num, address *src_addr, address *dst_addr, guint16 line_style, guint32 frame_num)
{
seq_analysis_item_t *gai, *new_gai;
GList *list;
gboolean inserted;
gchar time_str[COL_MAX_LEN];
if (!tapinfo->graph_analysis){
/* Nothing to do */
return;
}
new_gai = g_new0(seq_analysis_item_t, 1);
new_gai->frame_number = frame_num;
copy_address(&(new_gai->src_addr),src_addr);
copy_address(&(new_gai->dst_addr),dst_addr);
new_gai->port_src=pinfo->srcport;
new_gai->port_dst=pinfo->destport;
if (frame_label != NULL)
new_gai->frame_label = g_strdup(frame_label);
else
new_gai->frame_label = g_strdup("");
if (comment != NULL)
new_gai->comment = g_strdup(comment);
else
new_gai->comment = g_strdup("");
new_gai->conv_num=call_num;
new_gai->line_style=line_style;
set_fd_time(edt->session, pinfo->fd, time_str);
new_gai->time_str = g_strdup(time_str);
new_gai->display=FALSE;
inserted = FALSE;
list = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
while (list)
{
gai = (seq_analysis_item_t *)list->data;
if (gai->frame_number > frame_num) {
g_queue_insert_before(tapinfo->graph_analysis->items, list, new_gai);
g_hash_table_insert(tapinfo->graph_analysis->ht, GUINT_TO_POINTER(new_gai->frame_number), new_gai);
inserted = TRUE;
break;
}
list = g_list_next(list);
}
if (!inserted) {
/* Just add to the end */
g_queue_push_tail(tapinfo->graph_analysis->items, new_gai);
g_hash_table_insert(tapinfo->graph_analysis->ht, GUINT_TO_POINTER(new_gai->frame_number), new_gai);
}
}
/****************************************************************************/
/* ***************************TAP for RTP Events*****************************/
/****************************************************************************/
/*static guint32 rtp_evt_setup_frame_num = 0;*/
/****************************************************************************/
/* whenever a rtp event packet is seen by the tap listener */
static tap_packet_status
rtp_event_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt _U_, const void *rtp_event_info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_rtp_event_);
const struct _rtp_event_info *pi = (const struct _rtp_event_info *)rtp_event_info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* do not consider RTP events packets without a setup frame */
if (pi->info_setup_frame_num == 0) {
return TAP_PACKET_DONT_REDRAW;
}
tapinfo->rtp_evt_frame_num = pinfo->num;
tapinfo->rtp_evt = pi->info_rtp_evt;
tapinfo->rtp_evt_end = pi->info_end;
return TAP_PACKET_DONT_REDRAW;
}
/****************************************************************************/
void
rtp_event_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("rtpevent", tap_base_to_id(tap_id_base, tap_id_offset_rtp_event_),
NULL,
0,
NULL,
rtp_event_packet,
NULL,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_rtp_event(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_rtp_event_));
}
/****************************************************************************/
/* ***************************TAP for RTP **********************************/
/****************************************************************************/
/****************************************************************************/
/* when there is a [re]reading of RTP packets */
static void
rtp_reset(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_rtp_);
GList *list;
rtpstream_info_t *stream_info;
/* free the data items first */
list = g_list_first(tapinfo->rtpstream_list);
while (list)
{
stream_info = (rtpstream_info_t*)(list->data);
rtpstream_info_free_data(stream_info);
g_free(list->data);
list = g_list_next(list);
}
g_list_free(tapinfo->rtpstream_list);
tapinfo->rtpstream_list = NULL;
tapinfo->nrtpstreams = 0;
// Do not touch graph_analysis, it is handled by caller
if (tapinfo->tap_reset) {
tapinfo->tap_reset(tapinfo);
}
return;
}
/****************************************************************************/
/* whenever a RTP packet is seen by the tap listener */
static tap_packet_status
rtp_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, void const *rtp_info_ptr, tap_flags_t flags)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_rtp_);
rtpstream_info_t *tmp_listinfo;
rtpstream_info_t *strinfo = NULL;
GList *list;
struct _rtp_packet_info *p_packet_data = NULL;
const struct _rtp_info *rtp_info = (const struct _rtp_info *)rtp_info_ptr;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* do not consider RTP packets without a setup frame */
if (rtp_info->info_setup_frame_num == 0) {
return TAP_PACKET_DONT_REDRAW;
}
if (tapinfo->tap_packet) {
tapinfo->tap_packet(tapinfo, pinfo, edt, rtp_info_ptr, flags);
}
/* check whether we already have a RTP stream with this setup frame and ssrc in the list */
list = g_list_first(tapinfo->rtpstream_list);
while (list)
{
tmp_listinfo=(rtpstream_info_t *)list->data;
if ( (tmp_listinfo->setup_frame_number == rtp_info->info_setup_frame_num)
&& (tmp_listinfo->id.ssrc == rtp_info->info_sync_src) && (tmp_listinfo->end_stream == FALSE)) {
/* if the payload type has changed, we mark the stream as finished to create a new one
this is to show multiple payload changes in the Graph for example for DTMF RFC2833 */
if ( tmp_listinfo->first_payload_type != rtp_info->info_payload_type ) {
tmp_listinfo->end_stream = TRUE;
} else if ( ( ( tmp_listinfo->ed137_info == NULL ) && (rtp_info->info_ed137_info != NULL) ) ||
( ( tmp_listinfo->ed137_info != NULL ) && (rtp_info->info_ed137_info == NULL) ) ||
( ( tmp_listinfo->ed137_info != NULL ) && (rtp_info->info_ed137_info != NULL) &&
( 0!=strcmp(tmp_listinfo->ed137_info, rtp_info->info_ed137_info) )
)
) {
/* if ed137_info has changed, create new stream */
tmp_listinfo->end_stream = TRUE;
} else {
strinfo = (rtpstream_info_t*)(list->data);
break;
}
}
list = g_list_next(list);
}
/* if this is a duplicated RTP Event End, just return */
if ((tapinfo->rtp_evt_frame_num == pinfo->num) && !strinfo && (tapinfo->rtp_evt_end == TRUE)) {
return TAP_PACKET_DONT_REDRAW;
}
/* not in the list? then create a new entry */
if (strinfo==NULL) {
strinfo = rtpstream_info_malloc_and_init();
rtpstream_id_copy_pinfo(pinfo,&(strinfo->id),FALSE);
strinfo->id.ssrc = rtp_info->info_sync_src;
strinfo->first_payload_type = rtp_info->info_payload_type;
strinfo->is_srtp = rtp_info->info_is_srtp;
/* if it is dynamic payload, let use the conv data to see if it is defined */
if ( (strinfo->first_payload_type >= PT_UNDF_96) && (strinfo->first_payload_type <= PT_UNDF_127) ) {
/* Use existing packet info if available */
p_packet_data = (struct _rtp_packet_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_get_id_by_filter_name("rtp"), 0);
if (p_packet_data && p_packet_data->rtp_dyn_payload) {
const gchar *encoding_name = rtp_dyn_payload_get_name(p_packet_data->rtp_dyn_payload, strinfo->first_payload_type);
if (encoding_name) {
strinfo->first_payload_type_name = encoding_name;
}
}
}
if (!strinfo->first_payload_type_name) {
strinfo->first_payload_type_name = val_to_str_ext(strinfo->first_payload_type, &rtp_payload_type_short_vals_ext, "%u");
}
strinfo->start_fd = pinfo->fd;
strinfo->start_rel_time = pinfo->rel_ts;
strinfo->start_abs_time = pinfo->abs_ts;
strinfo->setup_frame_number = rtp_info->info_setup_frame_num;
strinfo->call_num = -1;
strinfo->rtp_event = -1;
if (rtp_info->info_ed137_info != NULL) {
strinfo->ed137_info = rtp_info->info_ed137_info;
} else {
strinfo->ed137_info = NULL;
}
tapinfo->rtpstream_list = g_list_prepend(tapinfo->rtpstream_list, strinfo);
}
/* Add the info to the existing RTP stream */
strinfo->packet_count++;
strinfo->stop_fd = pinfo->fd;
strinfo->stop_rel_time = pinfo->rel_ts;
/* process RTP Event */
if (tapinfo->rtp_evt_frame_num == pinfo->num) {
strinfo->rtp_event = tapinfo->rtp_evt;
if (tapinfo->rtp_evt_end == TRUE) {
strinfo->end_stream = TRUE;
}
}
tapinfo->redraw |= REDRAW_RTP;
return TAP_PACKET_DONT_REDRAW;
}
/****************************************************************************/
/* whenever a redraw in the RTP tap listener */
static void
rtp_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_rtp_);
GList *rtpstreams_list;
rtpstream_info_t *rtp_listinfo;
/* GList *voip_calls_graph_list; */
seq_analysis_item_t *gai = NULL;
seq_analysis_item_t *new_gai;
guint16 conv_num;
gdouble duration;
gchar time_str[COL_MAX_LEN];
/* add each rtp stream to the graph */
rtpstreams_list = g_list_first(tapinfo->rtpstream_list);
while (rtpstreams_list)
{
rtp_listinfo = (rtpstream_info_t *)rtpstreams_list->data;
/* using the setup frame number of the RTP stream, we get the call number that it belongs to*/
/* voip_calls_graph_list = g_list_first(tapinfo->graph_analysis->list); */
if(tapinfo->graph_analysis){
gai = (seq_analysis_item_t *)g_hash_table_lookup(tapinfo->graph_analysis->ht, GUINT_TO_POINTER(rtp_listinfo->setup_frame_number));
}
if(gai != NULL) {
const char *comment_fmt_src = "%%s, %%u packets. Duration: %%.%dfs SSRC: 0x%%X";
char *comment_fmt = ws_strdup_printf(comment_fmt_src, prefs.gui_decimal_places1);
/* Found the setup frame*/
conv_num = gai->conv_num;
/* if RTP was already in the Graph, just update the comment information */
gai = (seq_analysis_item_t *)g_hash_table_lookup(tapinfo->graph_analysis->ht, GUINT_TO_POINTER(rtp_listinfo->start_fd->num));
if (gai != NULL) {
duration = (gdouble)(nstime_to_msec(&rtp_listinfo->stop_rel_time) - nstime_to_msec(&rtp_listinfo->start_rel_time));
g_free(gai->comment);
gai->comment = ws_strdup_printf(comment_fmt,
(rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->packet_count,
duration/1000, rtp_listinfo->id.ssrc);
} else {
new_gai = g_new0(seq_analysis_item_t, 1);
new_gai->frame_number = rtp_listinfo->start_fd->num;
copy_address(&(new_gai->src_addr),&(rtp_listinfo->id.src_addr));
copy_address(&(new_gai->dst_addr),&(rtp_listinfo->id.dst_addr));
new_gai->port_src = rtp_listinfo->id.src_port;
new_gai->port_dst = rtp_listinfo->id.dst_port;
duration = (gdouble)(nstime_to_msec(&rtp_listinfo->stop_rel_time) - nstime_to_msec(&rtp_listinfo->start_rel_time));
new_gai->frame_label = ws_strdup_printf("%s (%s) %s%s%s",
(rtp_listinfo->is_srtp)?"SRTP":"RTP",
rtp_listinfo->first_payload_type_name,
(rtp_listinfo->rtp_event == -1)?
"":val_to_str_ext_const(rtp_listinfo->rtp_event, &rtp_event_type_values_ext, "Unknown RTP Event"),
(rtp_listinfo->ed137_info!=NULL?" ":""),
(rtp_listinfo->ed137_info!=NULL?rtp_listinfo->ed137_info:"")
);
new_gai->comment = ws_strdup_printf(comment_fmt,
(rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->packet_count,
duration/1000, rtp_listinfo->id.ssrc);
new_gai->info_type=GA_INFO_TYPE_RTP;
rtpstream_info_t *new_info = g_new(rtpstream_info_t, 1);
new_gai->info_ptr = new_info;
rtpstream_info_init(new_info);
rtpstream_id_copy(&rtp_listinfo->id, &new_info->id);
new_info->packet_count = rtp_listinfo->packet_count;
new_info->setup_frame_number = rtp_listinfo->setup_frame_number;
new_info->rtp_stats = rtp_listinfo->rtp_stats;
nstime_copy(&new_info->start_rel_time, &rtp_listinfo->start_rel_time);
nstime_copy(&new_info->stop_rel_time, &rtp_listinfo->stop_rel_time);
nstime_copy(&new_info->start_abs_time, &rtp_listinfo->start_abs_time);
new_gai->conv_num = conv_num;
set_fd_time(tapinfo->session, rtp_listinfo->start_fd, time_str);
new_gai->time_str = g_strdup(time_str);
new_gai->display=FALSE;
new_gai->line_style = 2; /* the arrow line will be 2 pixels width */
g_queue_push_tail(tapinfo->graph_analysis->items, new_gai);
g_hash_table_insert(tapinfo->graph_analysis->ht, GUINT_TO_POINTER(rtp_listinfo->start_fd->num), new_gai);
}
g_free(comment_fmt);
}
rtpstreams_list = g_list_next(rtpstreams_list);
} /* while (rtpstreams_list) */
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_RTP)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_RTP;
}
}
#if 0
static void
rtp_packet_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_rtp_);
GList *rtpstreams_list;
rtpstream_info_t *rtp_listinfo;
GList *voip_calls_graph_list;
guint item;
seq_analysis_item_t *gai;
seq_analysis_item_t *new_gai;
guint16 conv_num;
guint32 duration;
gchar time_str[COL_MAX_LEN];
/* add each rtp stream to the graph */
rtpstreams_list = g_list_first(tapinfo->stream_list);
while (rtpstreams_list)
{
rtp_listinfo = rtpstreams_list->data;
/* using the setup frame number of the RTP stream, we get the call number that it belongs to*/
voip_calls_graph_list = g_list_first(tapinfo->graph_analysis->list);
while (voip_calls_graph_list)
{
gai = voip_calls_graph_list->data;
conv_num = gai->conv_num;
/* if we get the setup frame number, then get the time position to graph the RTP arrow */
if (rtp_listinfo->setup_frame_number == gai->frame_number) {
/* look again from the beginning because there are cases where the Setup frame is after the RTP */
voip_calls_graph_list = g_list_first(tapinfo->graph_analysis->list);
item = 0;
while(voip_calls_graph_list) {
gai = voip_calls_graph_list->data;
/* if RTP was already in the Graph, just update the comment information */
if (rtp_listinfo->start_fd->num == gai->frame_number) {
duration = (guint32)(nstime_to_msec(&rtp_listinfo->stop_fd->rel_ts) - nstime_to_msec(&rtp_listinfo->start_fd->rel_ts));
g_free(gai->comment);
gai->comment = ws_strdup_printf("%s Num packets:%u Duration:%u.%03us SSRC:0x%X",
(rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->npackets,
duration/1000,(duration%1000), rtp_listinfo->id.ssrc);
break;
}
/* we increment the list here to be able to check if it is the last item in this calls, which means the RTP is after so we have to draw it */
voip_calls_graph_list = g_list_next(voip_calls_graph_list);
if (!voip_calls_graph_list) item++;
/* add the RTP item to the graph if was not there*/
if (rtp_listinfo->start_fd->num<gai->frame_number || !voip_calls_graph_list) {
new_gai = g_new0(seq_analysis_item_t, 1);
new_gai->frame_number = rtp_listinfo->start_fd->num;
copy_address(&(new_gai->src_addr),&(rtp_listinfo->src_addr));
copy_address(&(new_gai->dst_addr),&(rtp_listinfo->dst_addr));
new_gai->port_src = rtp_listinfo->id.src_port;
new_gai->port_dst = rtp_listinfo->id.dst_port;
new_gai->protocol = g_strdup(port_type_to_str(pinfo->ptype));
duration = (guint32)(nstime_to_msec(&rtp_listinfo->stop_fd->rel_ts) - nstime_to_msec(&rtp_listinfo->start_fd->rel_ts));
new_gai->frame_label = ws_strdup_printf("%s (%s) %s",
(rtp_listinfo->is_srtp)?"SRTP":"RTP",
rtp_listinfo->first_payload_type_str,
(rtp_listinfo->rtp_event == -1)?
"":val_to_str_ext_const(rtp_listinfo->rtp_event, &rtp_event_type_values_ext, "Unknown RTP Event"));
new_gai->comment = ws_strdup_printf("%s Num packets:%u Duration:%u.%03us SSRC:0x%X",
(rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->npackets,
duration/1000,(duration%1000), rtp_listinfo->id.ssrc);
new_gai->conv_num = conv_num;
set_fd_time(cfile.epan, rtp_listinfo->start_fd, time_str);
new_gai->time_str = g_strdup(time_str);
new_gai->display=FALSE;
new_gai->line_style = 2; /* the arrow line will be 2 pixels width */
tapinfo->graph_analysis->list = g_list_insert(tapinfo->graph_analysis->list, new_gai, item);
break;
}
if (voip_calls_graph_list) item++;
}
break;
}
voip_calls_graph_list = g_list_next(voip_calls_graph_list);
}
rtpstreams_list = g_list_next(rtpstreams_list);
}
}
#endif
/****************************************************************************/
void
rtp_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("rtp", tap_base_to_id(tap_id_base, tap_id_offset_rtp_), NULL,
0,
rtp_reset,
rtp_packet,
rtp_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_rtp(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_rtp_));
}
/****************************************************************************/
/******************************TAP for T38 **********************************/
/****************************************************************************/
/****************************************************************************/
/* whenever a T38 packet is seen by the tap listener */
static tap_packet_status
t38_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *t38_info_ptr, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_t38_);
voip_calls_info_t *callsinfo = NULL;
voip_calls_info_t *tmp_listinfo;
GList *voip_calls_graph_list = NULL;
GList *list;
gchar *frame_label = NULL;
gchar *comment = NULL;
seq_analysis_item_t *tmp_gai, *gai = NULL;
gchar *tmp_str1, *tmp_str2;
guint16 line_style = 2;
gdouble duration;
int conv_num = -1;
const t38_packet_info *t38_info = (const t38_packet_info *)t38_info_ptr;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
if (t38_info->setup_frame_number != 0) {
/* using the setup frame number of the T38 packet, we get the call number that it belongs */
if(tapinfo->graph_analysis){
voip_calls_graph_list = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
}
while (voip_calls_graph_list)
{
tmp_gai = (seq_analysis_item_t *)voip_calls_graph_list->data;
if (t38_info->setup_frame_number == tmp_gai->frame_number) {
gai = tmp_gai;
break;
}
voip_calls_graph_list = g_list_next(voip_calls_graph_list);
}
if (gai) conv_num = (int) gai->conv_num;
}
/* if setup_frame_number in the t38 packet is 0, it means it was not set using an SDP or H245 sesion, which means we don't
* have the associated Voip calls. It probably means that the packet was decoded using the default t38 port, or using "Decode as.."
* in this case we create a "voip" call that only have t38 media (no signaling)
* OR if we have not found the Setup message in the graph.
*/
if ( (t38_info->setup_frame_number == 0) || (gai == NULL) ) {
/* check whether we already have a call with these parameters in the list */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == MEDIA_T38) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
list = g_list_next (list);
}
/* not in the list? then create a new entry */
if (callsinfo==NULL) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_UNKNOWN;
callsinfo->from_identity=g_strdup("T38 Media only");
callsinfo->to_identity=g_strdup("T38 Media only");
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
callsinfo->start_fd = pinfo->fd;
callsinfo->start_rel_ts = pinfo->rel_ts;
callsinfo->protocol=MEDIA_T38;
callsinfo->prot_info=NULL;
callsinfo->free_prot_info = NULL;
callsinfo->npackets = 0;
callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
}
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
conv_num = (int) callsinfo->call_num;
}
/* at this point we should have found the call num for this t38 packets belong */
if (conv_num == -1) {
return TAP_PACKET_DONT_REDRAW;
}
/* add the item to the graph list */
if (t38_info->type_msg == 0) { /* 0=t30-indicator */
tmp_str1 = val_to_str_wmem(NULL, t38_info->t30ind_value, t38_T30_indicator_vals, "Ukn (0x%02X)");
frame_label = g_strdup(tmp_str1);
comment = ws_strdup_printf("t38:t30 Ind:%s", tmp_str1);
wmem_free(NULL, tmp_str1);
line_style = 1;
} else if (t38_info->type_msg == 1) { /* 1=data */
switch(t38_info->Data_Field_field_type_value) {
case 0: /* hdlc-data */
break;
case 2: /* hdlc-fcs-OK */
case 4: /* hdlc-fcs-OK-sig-end */
tmp_str1 = val_to_str_ext_wmem(NULL, t38_info->t30_Facsimile_Control & 0x7F,
&t30_facsimile_control_field_vals_short_ext,
"Ukn (0x%02X)");
frame_label = ws_strdup_printf("%s %s",
tmp_str1,
t38_info->desc);
wmem_free(NULL, tmp_str1);
tmp_str1 = val_to_str_ext_wmem(NULL, t38_info->t30_Facsimile_Control & 0x7F,
&t30_facsimile_control_field_vals_ext,
"Ukn (0x%02X)");
tmp_str2 = val_to_str_wmem(NULL, t38_info->data_value,
t38_T30_data_vals,
"Ukn (0x%02X)");
comment = ws_strdup_printf("t38:%s:HDLC:%s", tmp_str2, tmp_str1);
wmem_free(NULL, tmp_str1);
wmem_free(NULL, tmp_str2);
break;
case 3: /* hdlc-fcs-BAD */
case 5: /* hdlc-fcs-BAD-sig-end */
frame_label = g_strdup(t38_info->Data_Field_field_type_value == 3 ? "fcs-BAD" : "fcs-BAD-sig-end");
tmp_str1 = val_to_str_wmem(NULL, t38_info->data_value, t38_T30_data_vals, "Ukn (0x%02X)");
comment = ws_strdup_printf("WARNING: received t38:%s:HDLC:%s",
tmp_str1,
t38_info->Data_Field_field_type_value == 3 ? "fcs-BAD" : "fcs-BAD-sig-end");
wmem_free(NULL, tmp_str1);
break;
case 7: /* t4-non-ecm-sig-end */
duration = nstime_to_sec(&pinfo->rel_ts) - t38_info->time_first_t4_data;
tmp_str1 = val_to_str_wmem(NULL, t38_info->data_value, t38_T30_data_vals, "Ukn (0x%02X)");
frame_label = ws_strdup_printf("t4-non-ecm-data:%s", tmp_str1);
const char *comment_fmt_src = "t38:t4-non-ecm-data:%%s Duration: %%.%dfs %%s";
char *comment_fmt = ws_strdup_printf(comment_fmt_src, prefs.gui_decimal_places1);
comment = ws_strdup_printf(comment_fmt,
tmp_str1, duration, t38_info->desc_comment );
insert_to_graph_t38(tapinfo, pinfo, edt, frame_label, comment,
(guint16)conv_num, &(pinfo->src), &(pinfo->dst),
line_style, t38_info->frame_num_first_t4_data);
g_free(comment_fmt);
wmem_free(NULL, tmp_str1);
break;
}
}
if (frame_label && !(t38_info->Data_Field_field_type_value == 7 && t38_info->type_msg == 1)) {
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, (guint16)conv_num, &(pinfo->src), &(pinfo->dst), line_style);
}
g_free(comment);
g_free(frame_label);
tapinfo->redraw |= REDRAW_T38;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
t38_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_t38_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_T38)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_T38;
}
}
/****************************************************************************/
void
t38_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("t38", tap_base_to_id(tap_id_base, tap_id_offset_t38_), NULL,
0,
NULL,
t38_packet,
t38_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_t38(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_t38_));
}
/****************************************************************************/
/* ***************************TAP for SIP **********************************/
/****************************************************************************/
static void
free_sip_info(gpointer p) {
sip_calls_info_t *si = (sip_calls_info_t *)p;
g_free(si->call_identifier);
g_free(si);
}
/****************************************************************************/
/* whenever a SIP packet is seen by the tap listener */
static tap_packet_status
sip_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt , const void *SIPinfo, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_sip_);
/* we just take note of the ISUP data here; when we receive the MTP3 part everything will
be compared with existing calls */
voip_calls_info_t *callsinfo = NULL;
sip_calls_info_t *tmp_sipinfo = NULL;
address tmp_src, tmp_dst;
gchar *frame_label = NULL;
gchar *comment = NULL;
gchar *old_comment = NULL;
gchar *key = NULL;
const sip_info_value_t *pi = (const sip_info_value_t *)SIPinfo;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
tapinfo->sip_frame_num = pinfo->num;
/* do not consider packets without call_id */
if (pi->tap_call_id ==NULL) {
return TAP_PACKET_DONT_REDRAW;
}
key=pi->tap_call_id;
/* init the hash table */
if(NULL==tapinfo->callsinfo_hashtable[SIP_HASH]) {
/* TODO: check how efficient g_str_hash is for sip call ids */
tapinfo->callsinfo_hashtable[SIP_HASH]=g_hash_table_new_full(g_str_hash,
g_str_equal,
NULL, /* key_destroy_func */
NULL);/* value_destroy_func */
}
/* search the call information in the SIP_HASH */
callsinfo = (voip_calls_info_t *)g_hash_table_lookup(tapinfo->callsinfo_hashtable[SIP_HASH], key);
/* Create a new flow entry if the message is INVITE in case of FLOW_ONLY_INVITES,
Create a new flow entry for all messages which have a method in case of FLOW_ALL.
Flows for REGISTER, OPTIONS, MESSAGE and other SIP methods can be seen. */
if ((callsinfo==NULL) && (pi->request_method!=NULL)) {
/* check VoIPcalls_get_flow_show_option() == FLOW_ALL or FLOW_ONLY_INVITES */
if (tapinfo->fs_option == FLOW_ALL ||
(tapinfo->fs_option == FLOW_ONLY_INVITES &&
strcmp(pi->request_method,"INVITE")==0)) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_CALL_SETUP;
callsinfo->from_identity=g_strdup(pi->tap_from_addr);
callsinfo->to_identity=g_strdup(pi->tap_to_addr);
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->protocol=VOIP_SIP;
callsinfo->prot_info=g_new(sip_calls_info_t, 1);
callsinfo->free_prot_info = free_sip_info;
callsinfo->call_id = g_strdup(pi->tap_call_id);
tmp_sipinfo = (sip_calls_info_t *)callsinfo->prot_info;
tmp_sipinfo->call_identifier = g_strdup(pi->tap_call_id);
tmp_sipinfo->sip_state = SIP_INVITE_SENT;
tmp_sipinfo->invite_cseq = pi->tap_cseq_number;
callsinfo->npackets = 0;
callsinfo->call_num = tapinfo->ncalls++;
/* show method in comment in conversation list dialog, user can discern different conversation types */
callsinfo->call_comment=g_strdup(pi->request_method);
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
/* insert the call information in the SIP_HASH */
g_hash_table_insert(tapinfo->callsinfo_hashtable[SIP_HASH],
tmp_sipinfo->call_identifier, callsinfo);
}
}
if (callsinfo != NULL) {
tmp_sipinfo = (sip_calls_info_t *)callsinfo->prot_info;
/* let's analyze the call state */
copy_address(&(tmp_src), &(pinfo->src));
copy_address(&(tmp_dst), &(pinfo->dst));
if (pi->request_method == NULL) {
frame_label = ws_strdup_printf("%u %s", pi->response_code, pi->reason_phrase );
comment = ws_strdup_printf("SIP Status %u %s", pi->response_code, pi->reason_phrase );
if ((tmp_sipinfo && pi->tap_cseq_number == tmp_sipinfo->invite_cseq)&&(addresses_equal(&tmp_dst,&(callsinfo->initial_speaker)))) {
if ((pi->response_code > 199) && (pi->response_code<300) && (tmp_sipinfo->sip_state == SIP_INVITE_SENT)) {
tmp_sipinfo->sip_state = SIP_200_REC;
}
else if ((pi->response_code>299)&&(tmp_sipinfo->sip_state == SIP_INVITE_SENT)) {
callsinfo->call_state = VOIP_REJECTED;
tapinfo->rejected_calls++;
}
/* UPDATE comment in conversation list dialog with response code and reason.
Multiple code(+reason) may be appended, so skip over intermediate codes (100 trying, 183 ringing, e.t.c.)
TODO: is useful but not perfect, what is appended is truncated when displayed in dialog window */
if (pi->response_code >= 200) {
old_comment = callsinfo->call_comment;
callsinfo->call_comment=ws_strdup_printf("%s %u",
callsinfo->call_comment,
pi->response_code/*, pi->reason_phrase*/);
g_free(old_comment);
}
}
}
else {
frame_label = g_strdup(pi->request_method);
if ((strcmp(pi->request_method,"INVITE")==0)&&(addresses_equal(&tmp_src,&(callsinfo->initial_speaker)))) {
tmp_sipinfo->invite_cseq = pi->tap_cseq_number;
callsinfo->call_state = VOIP_CALL_SETUP;
/* TODO: sometimes truncated when displayed in dialog window */
comment = ws_strdup_printf("SIP INVITE From: %s To:%s Call-ID:%s CSeq:%d",
callsinfo->from_identity, callsinfo->to_identity,
callsinfo->call_id, pi->tap_cseq_number);
}
else if ((strcmp(pi->request_method,"ACK")==0)&&(pi->tap_cseq_number == tmp_sipinfo->invite_cseq)
&&(addresses_equal(&tmp_src,&(callsinfo->initial_speaker)))&&(tmp_sipinfo->sip_state==SIP_200_REC)
&&(callsinfo->call_state == VOIP_CALL_SETUP)) {
callsinfo->call_state = VOIP_IN_CALL;
comment = ws_strdup_printf("SIP Request INVITE ACK 200 CSeq:%d", pi->tap_cseq_number);
}
else if (strcmp(pi->request_method,"BYE")==0) {
callsinfo->call_state = VOIP_COMPLETED;
tapinfo->completed_calls++;
comment = ws_strdup_printf("SIP Request BYE CSeq:%d", pi->tap_cseq_number);
}
else if ((strcmp(pi->request_method,"CANCEL")==0)&&(pi->tap_cseq_number == tmp_sipinfo->invite_cseq)
&&(addresses_equal(&tmp_src,&(callsinfo->initial_speaker)))&&(callsinfo->call_state==VOIP_CALL_SETUP)) {
callsinfo->call_state = VOIP_CANCELLED;
tmp_sipinfo->sip_state = SIP_CANCEL_SENT;
comment = ws_strdup_printf("SIP Request CANCEL CSeq:%d", pi->tap_cseq_number);
} else {
/* comment = ws_strdup_printf("SIP %s", pi->request_method); */
comment = ws_strdup_printf("SIP %s From: %s To:%s CSeq:%d",
pi->request_method,
callsinfo->from_identity,
callsinfo->to_identity, pi->tap_cseq_number);
}
}
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
g_free(frame_label);
free_address(&tmp_src);
free_address(&tmp_dst);
/* add SDP info if apply */
if ( (tapinfo->sdp_summary != NULL) && (tapinfo->sdp_frame_num == pinfo->num) ) {
append_to_frame_graph(tapinfo, pinfo->num, tapinfo->sdp_summary, NULL);
g_free(tapinfo->sdp_summary);
tapinfo->sdp_summary = NULL;
}
}
tapinfo->redraw |= REDRAW_SIP;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
sip_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_sip_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_SIP)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_SIP;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
sip_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("sip", tap_base_to_id(tap_id_base, tap_id_offset_sip_), NULL,
0,
NULL,
sip_calls_packet,
sip_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_sip_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_sip_));
}
/****************************************************************************/
/* ***************************TAP for ISUP **********************************/
/****************************************************************************/
/****************************************************************************/
/* whenever a isup_ packet is seen by the tap listener */
static tap_packet_status
isup_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *isup_info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_isup_);
voip_calls_info_t *tmp_listinfo;
voip_calls_info_t *callsinfo = NULL;
isup_calls_info_t *tmp_isupinfo;
gboolean found = FALSE;
gboolean forward = FALSE;
gboolean right_pair;
GList *list;
gchar *frame_label = NULL;
gchar *comment = NULL;
const isup_tap_rec_t *pi = (const isup_tap_rec_t *)isup_info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* check if the lower layer is MTP matching the frame number */
if (tapinfo->mtp3_frame_num != pinfo->num)
return TAP_PACKET_DONT_REDRAW;
/* check whether we already have a call with these parameters in the list */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
right_pair = TRUE;
tmp_listinfo=(voip_calls_info_t *)list->data;
if ((tmp_listinfo->protocol == VOIP_ISUP)&&(tmp_listinfo->call_active_state==VOIP_ACTIVE)) {
tmp_isupinfo = (isup_calls_info_t *)tmp_listinfo->prot_info;
if ((tmp_isupinfo->cic == pi->circuit_id)&&(tmp_isupinfo->ni == tapinfo->mtp3_ni)) {
if ((tmp_isupinfo->opc == tapinfo->mtp3_opc)&&(tmp_isupinfo->dpc == tapinfo->mtp3_dpc)) {
forward = TRUE;
} else if ((tmp_isupinfo->dpc == tapinfo->mtp3_opc)&&(tmp_isupinfo->opc == tapinfo->mtp3_dpc)) {
forward = FALSE;
} else {
right_pair = FALSE;
}
if (right_pair) {
/* if there is an IAM for a call that is not in setup state, that means the previous call in the same
cic is no longer active */
if (tmp_listinfo->call_state == VOIP_CALL_SETUP) {
found = TRUE;
} else if (pi->message_type != 1) {
found = TRUE;
} else {
tmp_listinfo->call_active_state=VOIP_INACTIVE;
}
}
if (found) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
}
list = g_list_next (list);
}
/* not in the list? then create a new entry if the message is IAM
-i.e. if this session is a call*/
if ((callsinfo==NULL) &&(pi->message_type==1)) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_UNKNOWN;
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
callsinfo->start_fd = pinfo->fd;
callsinfo->start_rel_ts = pinfo->rel_ts;
callsinfo->protocol = VOIP_ISUP;
callsinfo->from_identity = g_strdup(pi->calling_number);
callsinfo->to_identity = g_strdup(pi->called_number);
callsinfo->prot_info = g_new(isup_calls_info_t, 1);
callsinfo->free_prot_info = g_free;
tmp_isupinfo = (isup_calls_info_t *)callsinfo->prot_info;
tmp_isupinfo->opc = tapinfo->mtp3_opc;
tmp_isupinfo->dpc = tapinfo->mtp3_dpc;
tmp_isupinfo->ni = tapinfo->mtp3_ni;
tmp_isupinfo->cic = pi->circuit_id;
callsinfo->npackets = 0;
callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
}
if (callsinfo!=NULL) {
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
/* Let's analyze the call state */
frame_label = g_strdup(val_to_str_ext_const(pi->message_type, &isup_message_type_value_acro_ext, "Unknown"));
if (callsinfo->npackets == 1) { /* this is the first packet, that must be an IAM */
if ((pi->calling_number!=NULL)&&(pi->called_number !=NULL)) {
comment = ws_strdup_printf("Call from %s to %s",
pi->calling_number, pi->called_number);
}
} else if (callsinfo->npackets == 2) { /* in the second packet we show the SPs */
if (forward) {
comment = ws_strdup_printf("%i-%i -> %i-%i. Cic:%i",
tapinfo->mtp3_ni, tapinfo->mtp3_opc,
tapinfo->mtp3_ni, tapinfo->mtp3_dpc, pi->circuit_id);
} else {
comment = ws_strdup_printf("%i-%i -> %i-%i. Cic:%i",
tapinfo->mtp3_ni, tapinfo->mtp3_dpc,
tapinfo->mtp3_ni, tapinfo->mtp3_opc, pi->circuit_id);
}
}
switch(pi->message_type) {
case 1: /* IAM */
callsinfo->call_state=VOIP_CALL_SETUP;
break;
case 7: /* CONNECT */
case 9: /* ANSWER */
callsinfo->call_state=VOIP_IN_CALL;
break;
case 12: /* RELEASE */
if (callsinfo->call_state==VOIP_CALL_SETUP) {
if (forward) {
callsinfo->call_state=VOIP_CANCELLED;
}
else {
callsinfo->call_state=VOIP_REJECTED;
tapinfo->rejected_calls++;
}
}
else if (callsinfo->call_state == VOIP_IN_CALL) {
callsinfo->call_state = VOIP_COMPLETED;
tapinfo->completed_calls++;
}
/* Overwrite any comment set above */
g_free(comment);
comment = ws_strdup_printf("Cause %i - %s",
pi->cause_value,
val_to_str_ext_const(pi->cause_value, &q931_cause_code_vals_ext, "(Unknown)"));
break;
}
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
g_free(frame_label);
}
tapinfo->redraw |= REDRAW_ISUP;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
isup_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_isup_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_ISUP)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_ISUP;
}
}
/****************************************************************************/
void
isup_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("isup", tap_base_to_id(tap_id_base, tap_id_offset_isup_),
NULL,
0,
NULL,
isup_calls_packet,
isup_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_isup_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_isup_));
}
/****************************************************************************/
/* ***************************TAP for MTP3 **********************************/
/****************************************************************************/
/****************************************************************************/
/* whenever a mtp3_ packet is seen by the tap listener */
static tap_packet_status
mtp3_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt _U_, const void *mtp3_info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_mtp3_);
const mtp3_tap_rec_t *pi = (const mtp3_tap_rec_t *)mtp3_info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* keep the data in memory to use when the ISUP information arrives */
tapinfo->mtp3_opc = pi->addr_opc.pc;
tapinfo->mtp3_dpc = pi->addr_dpc.pc;
tapinfo->mtp3_ni = pi->addr_opc.ni;
tapinfo->mtp3_frame_num = pinfo->num;
return TAP_PACKET_DONT_REDRAW;
}
static tap_packet_status
m3ua_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt _U_, const void *mtp3_info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_m3ua_);
const mtp3_tap_rec_t *pi = (const mtp3_tap_rec_t *)mtp3_info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* keep the data in memory to use when the ISUP information arrives */
tapinfo->mtp3_opc = pi->addr_opc.pc;
tapinfo->mtp3_dpc = pi->addr_dpc.pc;
tapinfo->mtp3_ni = pi->addr_opc.ni;
tapinfo->mtp3_frame_num = pinfo->num;
return TAP_PACKET_DONT_REDRAW;
}
/****************************************************************************/
void
mtp3_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("mtp3", tap_base_to_id(tap_id_base, tap_id_offset_mtp3_),
NULL,
0,
NULL,
mtp3_calls_packet,
NULL,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
error_string = register_tap_listener("m3ua", tap_base_to_id(tap_id_base, tap_id_offset_m3ua_),
NULL,
0,
NULL,
m3ua_calls_packet,
NULL,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_mtp3_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_mtp3_));
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_m3ua_));
}
/****************************************************************************/
/* ***************************TAP for Q931 **********************************/
/****************************************************************************/
static void h245_add_to_graph(voip_calls_tapinfo_t *tapinfo, guint32 new_frame_num);
static const e_guid_t guid_allzero = {0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
/* defines specific H323 data */
/****************************************************************************/
/* whenever a q931_ packet is seen by the tap listener */
static tap_packet_status
q931_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *q931_info, tap_flags_t flags _U_)
{
GList *list,*list2;
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_q931_);
h323_calls_info_t *tmp_h323info,*tmp2_h323info;
actrace_isdn_calls_info_t *tmp_actrace_isdn_info;
voip_calls_info_t *tmp_listinfo;
voip_calls_info_t *callsinfo = NULL;
h245_address_t *h245_add = NULL;
gchar *comment, *tmp_str;
const q931_packet_info *pi = (const q931_packet_info *)q931_info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* free previously allocated q931_calling/ed_number */
g_free(tapinfo->q931_calling_number);
g_free(tapinfo->q931_called_number);
if (pi->calling_number!=NULL)
tapinfo->q931_calling_number = g_strdup(pi->calling_number);
else
tapinfo->q931_calling_number = g_strdup("");
if (pi->called_number!=NULL)
tapinfo->q931_called_number = g_strdup(pi->called_number);
else
tapinfo->q931_called_number = g_strdup("");
tapinfo->q931_cause_value = pi->cause_value;
tapinfo->q931_frame_num = pinfo->num;
tapinfo->q931_crv = pi->crv;
/* add staff to H323 calls */
if (tapinfo->h225_frame_num == tapinfo->q931_frame_num) {
tmp_h323info = NULL;
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if ( (tmp_listinfo->protocol == VOIP_H323) && (tmp_listinfo->call_num == tapinfo->h225_call_num) ) {
tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info;
callsinfo = (voip_calls_info_t*)(list->data);
/* Add the CRV to the h323 call */
if (tmp_h323info->q931_crv == -1) {
tmp_h323info->q931_crv = tapinfo->q931_crv;
} else if (tmp_h323info->q931_crv != tapinfo->q931_crv) {
tmp_h323info->q931_crv2 = tapinfo->q931_crv;
}
break;
}
list = g_list_next (list);
}
if (callsinfo != NULL) {
comment = NULL;
if (tapinfo->h225_cstype == H225_SETUP) {
/* set te calling and called number from the Q931 packet */
if (tapinfo->q931_calling_number != NULL) {
g_free(callsinfo->from_identity);
callsinfo->from_identity=g_strdup(tapinfo->q931_calling_number);
}
if (tapinfo->q931_called_number != NULL) {
g_free(callsinfo->to_identity);
callsinfo->to_identity=g_strdup(tapinfo->q931_called_number);
}
/* check if there is an LRQ/LCF that match this Setup */
/* TODO: we are just checking the DialedNumer in LRQ/LCF against the Setup
we should also check if the h225 signaling IP and port match the destination
Setup ip and port */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == VOIP_H323) {
tmp2_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info;
/* check if the called number match a LRQ/LCF */
if ( (strcmp(callsinfo->to_identity, tmp_listinfo->to_identity)==0)
&& (memcmp(tmp2_h323info->guid, &guid_allzero, GUID_LEN) == 0) ) {
/* change the call graph to the LRQ/LCF to belong to this call */
callsinfo->npackets += change_call_num_graph(tapinfo, tmp_listinfo->call_num, callsinfo->call_num);
/* remove this LRQ/LCF call entry because we have found the Setup that match them */
g_free(tmp_listinfo->from_identity);
g_free(tmp_listinfo->to_identity);
/* DUMP_PTR2(tmp2_h323info->guid); */
g_free(tmp2_h323info->guid);
list2 = g_list_first(tmp2_h323info->h245_list);
while (list2)
{
h245_add=(h245_address_t *)list2->data;
free_address(&h245_add->h245_address);
g_free(list2->data);
list2 = g_list_next(list2);
}
g_list_free(tmp_h323info->h245_list);
tmp_h323info->h245_list = NULL;
g_free(tmp_listinfo->prot_info);
g_queue_unlink(tapinfo->callsinfos, list);
break;
}
}
list = g_list_next (list);
}
comment = ws_strdup_printf("H225 From: %s To:%s TunnH245:%s FS:%s", callsinfo->from_identity, callsinfo->to_identity, (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
(tapinfo->h225_is_faststart==TRUE?"on":"off"));
} else if (tapinfo->h225_cstype == H225_RELEASE_COMPLET) {
/* get the Q931 Release cause code */
if (tapinfo->q931_cause_value != 0xFF) {
comment = ws_strdup_printf("H225 Q931 Rel Cause (%i):%s", tapinfo->q931_cause_value,
val_to_str_ext_const(tapinfo->q931_cause_value, &q931_cause_code_vals_ext, "<unknown>"));
} else { /* Cause not set */
comment = g_strdup("H225 No Q931 Rel Cause");
}
}
/* change the graph comment for this new one */
if (comment != NULL) {
change_frame_graph(tapinfo, tapinfo->h225_frame_num, NULL, comment);
g_free(comment);
}
}
/* we reset the h225_frame_num to 0 because there could be empty h225 in the same frame
as non empty h225 (e.g connect), so we don't have to be here twice */
tapinfo->h225_frame_num = 0;
/* add staff to H245 */
} else if (tapinfo->h245_labels->frame_num == tapinfo->q931_frame_num) {
/* there are empty H225 frames that don't have guid (guaid=0) but they have h245 info,
so the only way to match those frames is with the Q931 CRV number */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == VOIP_H323) {
tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info;
if ( ((tmp_h323info->q931_crv == tapinfo->q931_crv) || (tmp_h323info->q931_crv2 == tapinfo->q931_crv)) && (tapinfo->q931_crv!=-1)) {
/* if the frame number exists in graph, append to it*/
if (!append_to_frame_graph(tapinfo, tapinfo->q931_frame_num, NULL, NULL)) {
/* if not exist, add to the graph */
add_to_graph(tapinfo, pinfo, edt, NULL, NULL, tmp_listinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
++(tmp_listinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
}
/* Add the H245 info if exists to the Graph */
h245_add_to_graph(tapinfo, pinfo->num);
break;
}
}
list = g_list_next (list);
}
/* SIP-Q */
} else if (tapinfo->sip_frame_num == tapinfo->q931_frame_num) {
/* Do nothing for now */
/* add stuff to ACTRACE */
} else {
address pstn_add;
comment = NULL;
callsinfo = NULL;
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if ( tmp_listinfo->protocol == VOIP_AC_ISDN ) {
tmp_actrace_isdn_info = (actrace_isdn_calls_info_t *)tmp_listinfo->prot_info;
/* TODO: Also check the IP of the Blade, and if the call is complete (no active) */
if ( (tmp_actrace_isdn_info->crv == tapinfo->q931_crv) && (tmp_actrace_isdn_info->trunk == tapinfo->actrace_trunk) ) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
set_address(&pstn_add, AT_STRINGZ, 5, g_strdup("PSTN"));
/* if it is a new call, add it to the list */
if (!callsinfo) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_CALL_SETUP;
callsinfo->from_identity=g_strdup(tapinfo->q931_calling_number);
callsinfo->to_identity=g_strdup(tapinfo->q931_called_number);
copy_address(&(callsinfo->initial_speaker),tapinfo->actrace_direction?&pstn_add:&(pinfo->src));
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->protocol=VOIP_AC_ISDN;
callsinfo->prot_info=g_new(actrace_isdn_calls_info_t, 1);
callsinfo->free_prot_info = g_free;
tmp_actrace_isdn_info=(actrace_isdn_calls_info_t *)callsinfo->prot_info;
tmp_actrace_isdn_info->crv=tapinfo->q931_crv;
tmp_actrace_isdn_info->trunk=tapinfo->actrace_trunk;
callsinfo->npackets = 0;
callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
}
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
switch(pi->message_type) {
case Q931_SETUP:
comment = ws_strdup_printf("AC_ISDN trunk:%u Calling: %s Called:%s", tapinfo->actrace_trunk, tapinfo->q931_calling_number, tapinfo->q931_called_number);
callsinfo->call_state=VOIP_CALL_SETUP;
break;
case Q931_CONNECT:
callsinfo->call_state=VOIP_IN_CALL;
break;
case Q931_RELEASE_COMPLETE:
case Q931_RELEASE:
case Q931_DISCONNECT:
if (callsinfo->call_state==VOIP_CALL_SETUP) {
if (addresses_equal(&(callsinfo->initial_speaker), tapinfo->actrace_direction?&pstn_add:&(pinfo->src) )) { /* forward direction */
callsinfo->call_state=VOIP_CANCELLED;
}
else { /* reverse */
callsinfo->call_state=VOIP_REJECTED;
tapinfo->rejected_calls++;
}
} else if ( (callsinfo->call_state!=VOIP_CANCELLED) && (callsinfo->call_state!=VOIP_REJECTED) ) {
callsinfo->call_state=VOIP_COMPLETED;
tapinfo->completed_calls++;
}
if (tapinfo->q931_cause_value != 0xFF) {
comment = ws_strdup_printf("AC_ISDN trunk:%u Q931 Rel Cause (%i):%s", tapinfo->actrace_trunk, tapinfo->q931_cause_value,
val_to_str_ext_const(tapinfo->q931_cause_value, &q931_cause_code_vals_ext, "<unknown>"));
} else { /* Cause not set */
comment = g_strdup("AC_ISDN No Q931 Rel Cause");
}
break;
}
if (!comment)
comment = ws_strdup_printf("AC_ISDN trunk:%u", tapinfo->actrace_trunk );
tmp_str = val_to_str_wmem(NULL, pi->message_type, q931_message_type_vals, "<unknown (%d)>");
add_to_graph(tapinfo, pinfo, edt, tmp_str, comment, callsinfo->call_num,
tapinfo->actrace_direction?&pstn_add:&(pinfo->src),
tapinfo->actrace_direction?&(pinfo->src):&pstn_add,
1 );
wmem_free(NULL, tmp_str);
g_free(comment);
free_address(&pstn_add);
}
tapinfo->redraw |= REDRAW_Q931;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
q931_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_q931_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_Q931)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_Q931;
}
}
/****************************************************************************/
void
q931_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("q931", tap_base_to_id(tap_id_base, tap_id_offset_q931_),
NULL,
0,
NULL,
q931_calls_packet,
q931_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_q931_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_q931_));
}
/****************************************************************************/
/****************************TAP for H323 ***********************************/
/****************************************************************************/
static void
add_h245_Address(h323_calls_info_t *h323info, h245_address_t *h245_address)
{
h323info->h245_list = g_list_prepend(h323info->h245_list, h245_address);
}
static void
free_h225_info(gpointer p) {
h323_calls_info_t *tmp_h323info = (h323_calls_info_t *)p;
/* DUMP_PTR2(tmp_h323info->guid); */
g_free(tmp_h323info->guid);
if (tmp_h323info->h245_list) {
GList *list2 = g_list_first(tmp_h323info->h245_list);
while (list2)
{
h245_address_t *h245_add=(h245_address_t *)list2->data;
free_address(&h245_add->h245_address);
g_free(list2->data);
list2 = g_list_next(list2);
}
g_list_free(tmp_h323info->h245_list);
}
g_free(p);
}
/****************************************************************************/
/* whenever a H225 packet is seen by the tap listener */
static tap_packet_status
h225_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *H225info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_h225_);
voip_calls_info_t *tmp_listinfo;
voip_calls_info_t *callsinfo = NULL;
h323_calls_info_t *tmp_h323info = NULL;
gchar *frame_label;
gchar *comment;
GList *list;
h245_address_t *h245_add = NULL;
const h225_packet_info *pi = (const h225_packet_info *)H225info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* if not guid and RAS and not LRQ, LCF or LRJ return because did not belong to a call */
/* OR, if not guid and is H225 return because doesn't belong to a call */
if ((memcmp(&pi->guid, &guid_allzero, GUID_LEN) == 0))
if ( ((pi->msg_type == H225_RAS) && ((pi->msg_tag < 18) || (pi->msg_tag > 20))) || (pi->msg_type != H225_RAS) )
return TAP_PACKET_DONT_REDRAW;
/* if it is RAS LCF or LRJ*/
if ( (pi->msg_type == H225_RAS) && ((pi->msg_tag == 19) || (pi->msg_tag == 20))) {
/* if the LCF/LRJ doesn't match to a LRQ, just return */
if (!pi->request_available) return TAP_PACKET_DONT_REDRAW;
/* check whether we already have a call with this request SeqNum */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
ws_assert(tmp_listinfo != NULL);
if (tmp_listinfo->protocol == VOIP_H323) {
tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info;
if (tmp_h323info->requestSeqNum == pi->requestSeqNum) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
} else {
/* check whether we already have a call with this guid in the list */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == VOIP_H323) {
tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info;
ws_assert(tmp_h323info != NULL);
if ( (memcmp(tmp_h323info->guid, &guid_allzero, GUID_LEN) != 0) && (memcmp(tmp_h323info->guid, &pi->guid,GUID_LEN)==0) ) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
}
tapinfo->h225_cstype = pi->cs_type;
tapinfo->h225_is_faststart = pi->is_faststart;
/* not in the list? then create a new entry */
if (callsinfo==NULL) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_UNKNOWN;
callsinfo->from_identity=g_strdup("");
callsinfo->to_identity=g_strdup("");
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->protocol=VOIP_H323;
callsinfo->prot_info=g_new(h323_calls_info_t, 1);
callsinfo->free_prot_info = free_h225_info;
tmp_h323info = (h323_calls_info_t *)callsinfo->prot_info;
ws_assert(tmp_h323info != NULL);
tmp_h323info->guid = (e_guid_t *)g_memdup2(&pi->guid, sizeof pi->guid);
/* DUMP_PTR1(tmp_h323info->guid); */
clear_address(&tmp_h323info->h225SetupAddr);
tmp_h323info->h245_list = NULL;
tmp_h323info->is_faststart_Setup = FALSE;
tmp_h323info->is_faststart_Proc = FALSE;
tmp_h323info->is_h245Tunneling = FALSE;
tmp_h323info->is_h245 = FALSE;
tmp_h323info->q931_crv = -1;
tmp_h323info->q931_crv2 = -1;
tmp_h323info->requestSeqNum = 0;
callsinfo->call_num = tapinfo->ncalls++;
callsinfo->npackets = 0;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
}
tapinfo->h225_frame_num = pinfo->num;
tapinfo->h225_call_num = callsinfo->call_num;
/* let's analyze the call state */
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* XXX: it is supposed to be initialized isn't it? */
ws_assert(tmp_h323info != NULL);
/* change the status */
if (pi->msg_type == H225_CS) {
/* this is still IPv4 only, because the dissector is */
if (pi->is_h245 == TRUE) {
h245_add = g_new(h245_address_t, 1);
alloc_address_wmem(NULL, &h245_add->h245_address, AT_IPv4, 4, &pi->h245_address);
h245_add->h245_port = pi->h245_port;
add_h245_Address(tmp_h323info, h245_add);
}
if (pi->cs_type != H225_RELEASE_COMPLET) tmp_h323info->is_h245Tunneling = pi->is_h245Tunneling;
frame_label = g_strdup(pi->frame_label);
switch(pi->cs_type) {
case H225_SETUP:
tmp_h323info->is_faststart_Setup = pi->is_faststart;
/* Set the Setup address if it was not set */
if (tmp_h323info->h225SetupAddr.type == AT_NONE)
copy_address(&(tmp_h323info->h225SetupAddr), &(pinfo->src));
callsinfo->call_state=VOIP_CALL_SETUP;
comment = ws_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
(pi->is_faststart==TRUE?"on":"off"));
break;
case H225_CONNECT:
callsinfo->call_state=VOIP_IN_CALL;
if (pi->is_faststart == TRUE) tmp_h323info->is_faststart_Proc = TRUE;
comment = ws_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
(pi->is_faststart==TRUE?"on":"off"));
break;
case H225_RELEASE_COMPLET:
if (callsinfo->call_state==VOIP_CALL_SETUP) {
if (addresses_equal(&(tmp_h323info->h225SetupAddr),&(pinfo->src))) { /* forward direction */
callsinfo->call_state=VOIP_CANCELLED;
}
else { /* reverse */
callsinfo->call_state=VOIP_REJECTED;
tapinfo->rejected_calls++;
}
} else {
callsinfo->call_state=VOIP_COMPLETED;
tapinfo->completed_calls++;
}
comment = g_strdup("H225 No Q931 Rel Cause");
break;
case H225_PROGRESS:
case H225_ALERTING:
case H225_CALL_PROCEDING:
if (pi->is_faststart == TRUE) tmp_h323info->is_faststart_Proc = TRUE;
comment = ws_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
(pi->is_faststart==TRUE?"on":"off"));
break;
default:
comment = ws_strdup_printf("H225 TunnH245:%s FS:%s", (tmp_h323info->is_h245Tunneling==TRUE?"on":"off"),
(pi->is_faststart==TRUE?"on":"off"));
}
}
else if (pi->msg_type == H225_RAS) {
switch(pi->msg_tag) {
case 18: /* LRQ */
if (!pi->is_duplicate) {
g_free(callsinfo->to_identity);
callsinfo->to_identity=g_strdup(pi->dialedDigits);
tmp_h323info->requestSeqNum = pi->requestSeqNum;
}
/* Fall Through */
case 19: /* LCF */
if (strlen(pi->dialedDigits))
comment = ws_strdup_printf("H225 RAS dialedDigits: %s", pi->dialedDigits);
else
comment = g_strdup("H225 RAS");
break;
default:
comment = g_strdup("H225 RAS");
}
frame_label = g_strdup(val_to_str_const(pi->msg_tag, h225_RasMessage_vals, "<unknown>"));
} else {
frame_label = g_strdup("H225: Unknown");
comment = NULL;
}
/* add to graph analysis */
/* if the frame number exists in graph, append to it*/
if (!append_to_frame_graph(tapinfo, pinfo->num, pi->frame_label, comment)) {
/* if not exist, add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
}
/* Add the H245 info if exists to the Graph */
h245_add_to_graph(tapinfo, pinfo->num);
g_free(frame_label);
g_free(comment);
tapinfo->redraw |= REDRAW_H225;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
h225_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_h225_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_H225)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_H225;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
h225_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("h225", tap_base_to_id(tap_id_base, tap_id_offset_h225_), NULL,
0,
NULL,
h225_calls_packet,
h225_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_h225_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_h225_));
}
/* Add the h245 label info to the graph */
void
h245_add_to_graph(voip_calls_tapinfo_t *tapinfo, guint32 new_frame_num)
{
gint8 n;
if (new_frame_num != tapinfo->h245_labels->frame_num) return;
for (n=0; n<tapinfo->h245_labels->labels_count; n++) {
append_to_frame_graph(tapinfo, new_frame_num, tapinfo->h245_labels->labels[n].frame_label, tapinfo->h245_labels->labels[n].comment);
g_free(tapinfo->h245_labels->labels[n].frame_label);
tapinfo->h245_labels->labels[n].frame_label = NULL;
g_free(tapinfo->h245_labels->labels[n].comment);
tapinfo->h245_labels->labels[n].comment = NULL;
}
tapinfo->h245_labels->frame_num = 0;
tapinfo->h245_labels->labels_count = 0;
}
/* free the h245_labels if the frame number is different */
static void
h245_free_labels(voip_calls_tapinfo_t *tapinfo, guint32 new_frame_num)
{
gint8 n;
if (new_frame_num == tapinfo->h245_labels->frame_num) return;
for (n=0; n<tapinfo->h245_labels->labels_count; n++) {
g_free(tapinfo->h245_labels->labels[n].frame_label);
tapinfo->h245_labels->labels[n].frame_label = NULL;
g_free(tapinfo->h245_labels->labels[n].comment);
tapinfo->h245_labels->labels[n].comment = NULL;
}
tapinfo->h245_labels->frame_num = 0;
tapinfo->h245_labels->labels_count = 0;
}
/* add the frame_label and comment to h245_labels and free the actual one if it is different frame num */
static void
h245_add_label(voip_calls_tapinfo_t *tapinfo, guint32 new_frame_num, const gchar *frame_label, const gchar *comment)
{
h245_free_labels(tapinfo, new_frame_num);
tapinfo->h245_labels->frame_num = new_frame_num;
tapinfo->h245_labels->labels[tapinfo->h245_labels->labels_count].frame_label = g_strdup(frame_label);
tapinfo->h245_labels->labels[tapinfo->h245_labels->labels_count].comment = g_strdup(comment);
if (tapinfo->h245_labels->labels_count < (H245_MAX-1))
tapinfo->h245_labels->labels_count++;
}
/****************************************************************************/
/* whenever a H245dg packet is seen by the tap listener (when H245 tunneling is ON) */
static tap_packet_status
h245dg_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *H245info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_h245dg_);
voip_calls_info_t *tmp_listinfo;
voip_calls_info_t *callsinfo = NULL;
h323_calls_info_t *tmp_h323info;
GList *list;
GList *list2;
h245_address_t *h245_add = NULL;
const h245_packet_info *pi = (const h245_packet_info *)H245info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* check if Tunneling is OFF and we have a call with this H245 add */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == VOIP_H323) {
tmp_h323info = (h323_calls_info_t *)tmp_listinfo->prot_info;
list2 = g_list_first(tmp_h323info->h245_list);
while (list2)
{
h245_add=(h245_address_t *)list2->data;
if ( (addresses_equal(&(h245_add->h245_address),&(pinfo->src)) && (h245_add->h245_port == pinfo->srcport))
|| (addresses_equal(&(h245_add->h245_address),&(pinfo->dst)) && (h245_add->h245_port == pinfo->destport)) ) {
callsinfo = (voip_calls_info_t*)(list->data);
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
break;
}
list2 = g_list_next(list2);
}
if (callsinfo!=NULL) break;
}
list = g_list_next(list);
}
/* Tunnel is OFF, and we matched the h245 add so we add it to graph */
if (callsinfo!=NULL) {
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* if the frame number exists in graph, append to it*/
if (!append_to_frame_graph(tapinfo, pinfo->num, pi->frame_label, pi->comment)) {
/* if not exist, add to the graph */
add_to_graph(tapinfo, pinfo, edt, pi->frame_label, pi->comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
}
} else {
/* Tunnel is ON, so we save the label info to use it into h225 or q931 tap. OR may be
tunnel OFF but we did not matched the h245 add, in this case nobady will set this label
since the frame_num will not match */
h245_add_label(tapinfo, pinfo->num, pi->frame_label, pi->comment);
}
tapinfo->redraw |= REDRAW_H245DG;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
h245dg_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_h245dg_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_H245DG)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_H245DG;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
h245dg_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
if (!tap_id_base->h245_labels) {
tap_id_base->h245_labels = g_new0(h245_labels_t, 1);
}
error_string = register_tap_listener("h245dg", tap_base_to_id(tap_id_base, tap_id_offset_h245dg_), NULL,
0,
NULL,
h245dg_calls_packet,
h245dg_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_h245dg_calls(voip_calls_tapinfo_t *tap_id_base)
{
if (tap_id_base->h245_labels) {
g_free(tap_id_base->h245_labels);
tap_id_base->h245_labels = NULL;
}
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_h245dg_));
}
/****************************************************************************/
/****************************TAP for SDP PROTOCOL ***************************/
/****************************************************************************/
/* whenever a SDP packet is seen by the tap listener */
static tap_packet_status
sdp_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt _U_, const void *SDPinfo, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_sdp_);
const sdp_packet_info *pi = (const sdp_packet_info *)SDPinfo;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* There are protocols like MGCP/SIP where the SDP is called before the tap for the
MGCP/SIP packet, in those cases we assign the SPD summary to global lastSDPsummary
to use it later
*/
g_free(tapinfo->sdp_summary);
tapinfo->sdp_frame_num = pinfo->num;
/* Append to graph the SDP summary if the packet exists */
tapinfo->sdp_summary = ws_strdup_printf("SDP (%s)", pi->summary_str);
append_to_frame_graph(tapinfo, pinfo->num, tapinfo->sdp_summary, NULL);
tapinfo->redraw |= REDRAW_SDP;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
sdp_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_sdp_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_SDP)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_SDP;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
sdp_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("sdp", tap_base_to_id(tap_id_base, tap_id_offset_sdp_), NULL,
0,
NULL,
sdp_calls_packet,
sdp_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_sdp_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_sdp_));
}
/****************************************************************************/
/* ***************************TAP for MGCP **********************************/
/****************************************************************************/
/*
This function will look for a signal/event in the SignalReq/ObsEvent string
and return true if it is found
*/
static gboolean
is_mgcp_signal(const gchar *signal_str_p, const gchar *signalStr)
{
gint i;
gchar **resultArray;
gboolean found = FALSE;
/* if there is no signalStr, just return false */
if (signalStr == NULL) return FALSE;
/* if are both "blank" return true */
if ( (*signal_str_p == '\0') && (*signalStr == '\0') ) return TRUE;
/* look for signal in signalStr */
resultArray = g_strsplit(signalStr, ",", 10);
for (i = 0; resultArray[i]; i++) {
g_strstrip(resultArray[i]);
if (strcmp(resultArray[i], signal_str_p) == 0) {
found = TRUE;
break;
}
}
g_strfreev(resultArray);
return found;
}
/*
This function will get the Caller ID info and replace the current string
This is how it looks the caller Id: rg, ci(02/16/08/29, "3035550002","Ale Sipura 2")
*/
static void
mgcp_caller_id(gchar *signalStr, gchar **callerId)
{
gchar **arrayStr;
/* if there is no signalStr, just return false */
if (signalStr == NULL) return;
arrayStr = g_strsplit(signalStr, "\"", 3);
/* look for the ci signal */
if (g_strv_length(arrayStr) == 3 && strstr(arrayStr[0], "ci(")) {
/* free the previous "From" field of the call, and assign the new */
g_free(*callerId);
*callerId = g_strdup(arrayStr[1]);
}
g_strfreev(arrayStr);
}
/*
This function will get the Dialed Digits and replace the current string
This is how it looks the dialed digits 5,5,5,0,0,0,2,#,*
*/
static void
mgcp_dialed_digits(gchar *signalStr, gchar **dialedDigits)
{
gchar *tmpStr;
gchar *resultStr;
gint i,j;
/* start with 1 for the null-terminator */
guint resultStrLen = 1;
/* if there is no signalStr, just return false */
if (signalStr == NULL) return;
tmpStr = g_strdup(signalStr);
for ( i = 0 ; tmpStr[i] ; i++) {
switch (tmpStr[i]) {
case '0' : case '1' : case '2' : case '3' : case '4' :
case '5' : case '6' : case '7' : case '8' : case '9' :
case '#' : case '*' :
resultStrLen++;
break;
default:
tmpStr[i] = '?';
break;
}
}
if (resultStrLen == 1) {
g_free(tmpStr);
return;
}
resultStr = (gchar *)g_malloc(resultStrLen);
for (i = 0, j = 0; tmpStr[i]; i++) {
if (tmpStr[i] != '?')
resultStr[j++] = tmpStr[i];
}
resultStr[j] = '\0';
g_free(*dialedDigits);
g_free(tmpStr);
*dialedDigits = resultStr;
return;
}
/****************************************************************************/
/* whenever a MGCP packet is seen by the tap listener */
static tap_packet_status
mgcp_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *MGCPinfo, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_mgcp_);
voip_calls_info_t *tmp_listinfo;
voip_calls_info_t *callsinfo = NULL;
mgcp_calls_info_t *tmp_mgcpinfo = NULL;
GList *list;
GList *listGraph = NULL;
gchar *frame_label = NULL;
gchar *comment = NULL;
seq_analysis_item_t *gai = NULL;
gboolean newcall = FALSE;
gboolean fromEndpoint = FALSE; /* true for calls originated in Endpoints, false for calls from MGC */
gdouble diff_time;
const mgcp_info_t *pi = (const mgcp_info_t *)MGCPinfo;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
if ((pi->mgcp_type == MGCP_REQUEST) && !pi->is_duplicate ) {
/* check whether we already have a call with this Endpoint and it is active*/
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if ((tmp_listinfo->protocol == VOIP_MGCP) && (tmp_listinfo->call_active_state == VOIP_ACTIVE)) {
tmp_mgcpinfo = (mgcp_calls_info_t *)tmp_listinfo->prot_info;
if (pi->endpointId != NULL) {
if (g_ascii_strcasecmp(tmp_mgcpinfo->endpointId,pi->endpointId) == 0) {
/*
check first if it is an ended call. We can still match packets to this Endpoint 2 seconds
after the call has been released
*/
diff_time = nstime_to_sec(&pinfo->rel_ts) - nstime_to_sec(&tmp_listinfo->stop_rel_ts);
if ( ((tmp_listinfo->call_state == VOIP_CANCELLED) ||
(tmp_listinfo->call_state == VOIP_COMPLETED) ||
(tmp_listinfo->call_state == VOIP_REJECTED)) &&
(diff_time > 2) )
{
tmp_listinfo->call_active_state = VOIP_INACTIVE;
} else {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
}
}
list = g_list_next (list);
}
/* there is no call with this Endpoint, lets see if this a new call or not */
if (callsinfo == NULL) {
if ( (strcmp(pi->code, "NTFY") == 0) && is_mgcp_signal("hd", pi->observedEvents) ) { /* off hook transition */
/* this is a new call from the Endpoint */
fromEndpoint = TRUE;
newcall = TRUE;
} else if (strcmp(pi->code, "CRCX") == 0) {
/* this is a new call from the MGC */
fromEndpoint = FALSE;
newcall = TRUE;
}
if (!newcall) return TAP_PACKET_DONT_REDRAW;
}
} else if ( ((pi->mgcp_type == MGCP_RESPONSE) && pi->request_available) ||
((pi->mgcp_type == MGCP_REQUEST) && pi->is_duplicate) ) {
/* if it is a response OR if it is a duplicated Request, lets look in the Graph to see
if there is a request that matches */
if(tapinfo->graph_analysis){
listGraph = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
}
while (listGraph)
{
gai = (seq_analysis_item_t *)listGraph->data;
if (gai->frame_number == pi->req_num) {
/* there is a request that match, so look the associated call with this call_num */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == VOIP_MGCP) {
if (tmp_listinfo->call_num == gai->conv_num) {
tmp_mgcpinfo = (mgcp_calls_info_t *)tmp_listinfo->prot_info;
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
if (callsinfo != NULL) break;
}
listGraph = g_list_next(listGraph);
}
/* if there is not a matching request, just return */
if (callsinfo == NULL) return TAP_PACKET_DONT_REDRAW;
} else return TAP_PACKET_DONT_REDRAW;
/* not in the list? then create a new entry */
if (callsinfo==NULL) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_CALL_SETUP;
if (fromEndpoint) {
callsinfo->from_identity=g_strdup(pi->endpointId);
callsinfo->to_identity=g_strdup("");
} else {
callsinfo->from_identity=g_strdup("");
callsinfo->to_identity=g_strdup(pi->endpointId);
}
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->protocol=VOIP_MGCP;
callsinfo->prot_info=g_new(mgcp_calls_info_t, 1);
callsinfo->free_prot_info = g_free;
tmp_mgcpinfo=(mgcp_calls_info_t *)callsinfo->prot_info;
tmp_mgcpinfo->endpointId = g_strdup(pi->endpointId);
tmp_mgcpinfo->fromEndpoint = fromEndpoint;
callsinfo->npackets = 0;
callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
}
ws_assert(tmp_mgcpinfo != NULL);
/* change call state and add to graph */
switch (pi->mgcp_type)
{
case MGCP_REQUEST:
if ( (strcmp(pi->code, "NTFY") == 0) && (pi->observedEvents != NULL) ) {
frame_label = ws_strdup_printf("%s ObsEvt:%s",pi->code, pi->observedEvents);
if (tmp_mgcpinfo->fromEndpoint) {
/* use the Dialed digits to fill the "To" for the call, but use the first NTFY */
if (callsinfo->to_identity[0] == '\0') mgcp_dialed_digits(pi->observedEvents, &(callsinfo->to_identity));
/* from MGC and the user picked up, the call is connected */
} else if (is_mgcp_signal("hd", pi->observedEvents))
callsinfo->call_state=VOIP_IN_CALL;
/* hung up signal */
if (is_mgcp_signal("hu", pi->observedEvents)) {
if ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)) {
callsinfo->call_state = VOIP_CANCELLED;
} else {
callsinfo->call_state = VOIP_COMPLETED;
}
}
} else if (strcmp(pi->code, "RQNT") == 0) {
/* for calls from Endpoint: if there is a "no signal" RQNT and the call was RINGING, we assume this is the CONNECT */
if ( tmp_mgcpinfo->fromEndpoint && is_mgcp_signal("", pi->signalReq) && (callsinfo->call_state == VOIP_RINGING) ) {
callsinfo->call_state = VOIP_IN_CALL;
}
/* if there is ringback or ring tone, change state to ringing */
if ( is_mgcp_signal("rg", pi->signalReq) || is_mgcp_signal("rt", pi->signalReq) ) {
callsinfo->call_state = VOIP_RINGING;
}
/* if there is a Busy or ReorderTone, and the call was Ringing or Setup the call is Rejected */
if ( (is_mgcp_signal("ro", pi->signalReq) || is_mgcp_signal("bz", pi->signalReq)) && ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)) ) {
callsinfo->call_state = VOIP_REJECTED;
}
if (pi->signalReq != NULL)
frame_label = ws_strdup_printf("%s%sSigReq:%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":"", pi->signalReq);
else
frame_label = ws_strdup_printf("%s%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":"");
/* use the CallerID info to fill the "From" for the call */
if (!tmp_mgcpinfo->fromEndpoint) mgcp_caller_id(pi->signalReq, &(callsinfo->from_identity));
} else if (strcmp(pi->code, "DLCX") == 0) {
/*
if there is a DLCX in a call To an Endpoint and the call was not connected, we use
the DLCX as the end of the call
*/
if (!tmp_mgcpinfo->fromEndpoint) {
if ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)) {
callsinfo->call_state = VOIP_CANCELLED;
}
}
}
if (frame_label == NULL) frame_label = g_strdup(pi->code);
break;
case MGCP_RESPONSE:
frame_label = ws_strdup_printf("%u (%s)",pi->rspcode, pi->code);
break;
case MGCP_OTHERS:
/* XXX what to do? */
break;
}
comment = ws_strdup_printf("MGCP %s %s%s", tmp_mgcpinfo->endpointId, (pi->mgcp_type == MGCP_REQUEST)?"Request":"Response", pi->is_duplicate?" Duplicate":"");
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
g_free(frame_label);
/* add SDP info if apply */
if ( (tapinfo->sdp_summary != NULL) && (tapinfo->sdp_frame_num == pinfo->num) ) {
append_to_frame_graph(tapinfo, pinfo->num, tapinfo->sdp_summary, NULL);
g_free(tapinfo->sdp_summary);
tapinfo->sdp_summary = NULL;
}
tapinfo->redraw |= REDRAW_MGCP;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
mgcp_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_mgcp_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_MGCP)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_MGCP;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
mgcp_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
/*
* We set TL_REQUIRES_PROTO_TREE to force a non-null "tree"
* in the MGCP dissector; otherwise, the dissector
* doesn't fill in the info passed to the tap's packet
* routine.
*/
error_string = register_tap_listener("mgcp",
tap_base_to_id(tap_id_base, tap_id_offset_mgcp_),
NULL,
TL_REQUIRES_PROTO_TREE,
NULL,
mgcp_calls_packet,
mgcp_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_mgcp_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_mgcp_));
}
/****************************************************************************/
/****************************TAP for ACTRACE (AudioCodes trace)**************/
/****************************************************************************/
/* whenever a ACTRACE packet is seen by the tap listener */
static tap_packet_status
actrace_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *ACTRACEinfo, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_actrace_);
const actrace_info_t *pi = (const actrace_info_t *)ACTRACEinfo;
GList *list;
actrace_cas_calls_info_t *tmp_actrace_cas_info;
voip_calls_info_t *tmp_listinfo;
voip_calls_info_t *callsinfo = NULL;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
tapinfo->actrace_frame_num = pinfo->num;
tapinfo->actrace_trunk = pi->trunk;
tapinfo->actrace_direction = pi->direction;
if (pi->type == 1) { /* is CAS protocol */
address pstn_add;
gchar *comment = NULL;
callsinfo = NULL;
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
tmp_listinfo=(voip_calls_info_t *)list->data;
if ( tmp_listinfo->protocol == VOIP_AC_CAS ) {
tmp_actrace_cas_info = (actrace_cas_calls_info_t *)tmp_listinfo->prot_info;
/* TODO: Also check the IP of the Blade, and if the call is complete (no active) */
if ( (tmp_actrace_cas_info->bchannel == pi->cas_bchannel) && (tmp_actrace_cas_info->trunk == tapinfo->actrace_trunk) ) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
set_address(&pstn_add, AT_STRINGZ, 5, "PSTN");
/* if it is a new call, add it to the list */
if (!callsinfo) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_CALL_SETUP;
callsinfo->from_identity=g_strdup("N/A");
callsinfo->to_identity=g_strdup("N/A");
copy_address(&(callsinfo->initial_speaker),tapinfo->actrace_direction?&pstn_add:&(pinfo->src));
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->protocol=VOIP_AC_CAS;
callsinfo->prot_info=g_new(actrace_cas_calls_info_t, 1);
callsinfo->free_prot_info = g_free;
tmp_actrace_cas_info=(actrace_cas_calls_info_t *)callsinfo->prot_info;
tmp_actrace_cas_info->bchannel=pi->cas_bchannel;
tmp_actrace_cas_info->trunk=tapinfo->actrace_trunk;
callsinfo->npackets = 0;
callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
}
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
comment = ws_strdup_printf("AC_CAS trunk:%u", tapinfo->actrace_trunk);
add_to_graph(tapinfo, pinfo, edt, pi->cas_frame_label, comment, callsinfo->call_num,
tapinfo->actrace_direction?&pstn_add:&(pinfo->src),
tapinfo->actrace_direction?&(pinfo->src):&pstn_add,
1 );
g_free(comment);
}
tapinfo->redraw |= REDRAW_ACTRACE;
return TAP_PACKET_REDRAW; /* refresh output */
}
/****************************************************************************/
static void
actrace_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_actrace_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_ACTRACE)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_ACTRACE;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
actrace_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("actrace", tap_base_to_id(tap_id_base, tap_id_offset_actrace_), NULL,
0,
NULL,
actrace_calls_packet,
actrace_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_actrace_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_actrace_));
}
/****************************************************************************/
/**************************** TAP for H248/MEGACO **********************************/
/****************************************************************************/
#define gcp_is_req(type) ( type == GCP_CMD_ADD_REQ || type == GCP_CMD_MOVE_REQ || type == GCP_CMD_MOD_REQ || \
type == GCP_CMD_SUB_REQ || type == GCP_CMD_AUDITCAP_REQ || type == GCP_CMD_AUDITVAL_REQ || \
type == GCP_CMD_NOTIFY_REQ || type == GCP_CMD_SVCCHG_REQ || type == GCP_CMD_TOPOLOGY_REQ || \
type == GCP_CMD_CTX_ATTR_AUDIT_REQ )
static tap_packet_status
h248_calls_packet_common(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan_dissect_t *edt, const void *prot_info, guint32 redraw_bit) {
const gcp_cmd_t *cmd = (const gcp_cmd_t *)prot_info;
GList *list;
voip_calls_info_t *callsinfo = NULL;
address *mgw;
address *mgc;
gchar mgw_addr[128];
if (cmd->ctx->id == NULL_CONTEXT || cmd->ctx->id == ALL_CONTEXTS ) {
return TAP_PACKET_DONT_REDRAW;
}
if ( gcp_is_req(cmd->type) ) {
mgw = &(pinfo->dst);
mgc = &(pinfo->src);
} else {
mgc = &(pinfo->dst);
mgw = &(pinfo->src);
}
address_to_str_buf(mgw, mgw_addr, 128);
/* check whether we already have this context in the list */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
voip_calls_info_t* tmp_listinfo = (voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == TEL_H248) {
if (tmp_listinfo->prot_info == cmd->ctx) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
if (callsinfo==NULL) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_state = VOIP_NO_STATE;
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->from_identity = ws_strdup_printf("%s : %.8x", mgw_addr, cmd->ctx->id);
callsinfo->to_identity = g_strdup("");
callsinfo->prot_info = cmd->ctx;
callsinfo->free_prot_info = NULL;
callsinfo->npackets = 1;
copy_address(&(callsinfo->initial_speaker), mgc);
callsinfo->protocol = TEL_H248;
callsinfo->call_num = tapinfo->ncalls++;
callsinfo->start_fd = pinfo->fd;
callsinfo->start_rel_ts = pinfo->rel_ts;
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
} else {
GString *s = g_string_new("");
gcp_terms_t *ctx_term;
g_free(callsinfo->from_identity);
callsinfo->from_identity = ws_strdup_printf("%s : %.8x", mgw_addr, ((gcp_ctx_t*)callsinfo->prot_info)->id);
g_free(callsinfo->to_identity);
for (ctx_term = ((gcp_ctx_t*)callsinfo->prot_info)->terms.next;
ctx_term;
ctx_term = ctx_term->next ) {
if ( ctx_term->term && ctx_term->term->str) {
g_string_append_printf(s," %s",ctx_term->term->str);
}
}
callsinfo->to_identity = g_string_free(s,FALSE);
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
}
add_to_graph(tapinfo, pinfo, edt, cmd->str ? cmd->str : "unknown Msg",
wmem_strdup_printf(pinfo->pool, "TrxId = %u, CtxId = %.8x",cmd->trx->id,cmd->ctx->id),
callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
++(tapinfo->npackets);
tapinfo->redraw |= redraw_bit;
return TAP_PACKET_REDRAW;
}
static tap_packet_status
h248_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *prot_info, tap_flags_t flags _U_) {
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_h248_);
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
return h248_calls_packet_common(tapinfo, pinfo, edt, prot_info, REDRAW_H248);
}
static void
h248_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_h248_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_H248)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_H248;
}
}
static tap_packet_status
megaco_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *prot_info, tap_flags_t flags _U_) {
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_megaco_);
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
return h248_calls_packet_common(tapinfo, pinfo, edt, prot_info, REDRAW_MEGACO);
}
static void
megaco_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_megaco_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_MEGACO)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_MEGACO;
}
}
void
h248_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("megaco", tap_base_to_id(tap_id_base, tap_id_offset_megaco_),
NULL,
0,
NULL,
megaco_calls_packet,
megaco_calls_draw,
NULL);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
error_string = register_tap_listener("h248", tap_base_to_id(tap_id_base, tap_id_offset_h248_),
NULL,
0,
NULL,
h248_calls_packet,
h248_calls_draw,
NULL);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
void
remove_tap_listener_h248_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_h248_));
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_megaco_));
}
/****************************************************************************/
/**************************** TAP for SCCP and SUA **********************************/
/**************************** ( RANAP and BSSAP ) **********************************/
/****************************************************************************/
static const voip_protocol sccp_proto_map[] = {
TEL_SCCP,
TEL_BSSMAP,
TEL_RANAP
};
#define SP2VP(ap) ((ap) < SCCP_PLOAD_NUM_PLOADS ? sccp_proto_map[(ap)] : TEL_SCCP)
const value_string* sccp_payload_values;
static tap_packet_status
sccp_calls(voip_calls_tapinfo_t *tapinfo, packet_info *pinfo, epan_dissect_t *edt, const void *prot_info, guint32 redraw_bit) {
const sccp_msg_info_t* msg = (const sccp_msg_info_t *)prot_info;
sccp_assoc_info_t* assoc = msg->data.co.assoc;
GList *list;
voip_calls_info_t *callsinfo = NULL;
gchar *label = NULL;
const gchar *comment = NULL;
/* check whether we already have this assoc in the list */
for(list = g_queue_peek_nth_link(tapinfo->callsinfos, 0) ; list ; list = g_list_next (list) ) {
if ( ((voip_calls_info_t*)(list->data))->prot_info == assoc ) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
if (callsinfo==NULL) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_state = VOIP_CALL_SETUP;
callsinfo->call_active_state = VOIP_ACTIVE;
if ( assoc->calling_party ) {
callsinfo->from_identity = g_strdup(assoc->calling_party);
} else {
callsinfo->from_identity = g_strdup("Unknown");
}
if ( assoc->called_party ) {
callsinfo->to_identity = g_strdup(assoc->called_party);
} else {
callsinfo->to_identity = g_strdup("Unknown");
}
callsinfo->prot_info = (void*)assoc;
callsinfo->free_prot_info = NULL;
callsinfo->npackets = 1;
copy_address(&(callsinfo->initial_speaker), &(pinfo->src));
callsinfo->protocol = SP2VP(assoc->payload);
/* Store frame data which holds time and frame number */
callsinfo->start_fd = pinfo->fd;
callsinfo->start_rel_ts = pinfo->rel_ts;
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
} else {
if ( assoc->calling_party ) {
g_free(callsinfo->from_identity);
callsinfo->from_identity = g_strdup(assoc->calling_party);
}
if ( assoc->called_party ) {
g_free(callsinfo->to_identity);
callsinfo->to_identity = g_strdup(assoc->called_party);
}
callsinfo->protocol = SP2VP(assoc->payload);
/* Store frame data which holds stop time and frame number */
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
switch (msg->type) {
case SCCP_MSG_TYPE_CC:
callsinfo->call_state = VOIP_IN_CALL;
break;
case SCCP_MSG_TYPE_RLC:
callsinfo->call_state = VOIP_COMPLETED;
callsinfo->call_active_state = VOIP_INACTIVE;
break;
default:
break;
}
}
if (msg->data.co.label) {
label = wmem_strdup(NULL, msg->data.co.label);
} else {
label = val_to_str_wmem(NULL, msg->type, sccp_payload_values, "Unknown(%d)");
}
if (msg->data.co.comment) {
comment = msg->data.co.comment;
} else {
comment = NULL;
}
add_to_graph(tapinfo, pinfo, edt, label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
wmem_free(NULL, label);
++(tapinfo->npackets);
tapinfo->redraw |= redraw_bit;
return TAP_PACKET_REDRAW;
}
static tap_packet_status
sccp_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *prot_info, tap_flags_t flags _U_) {
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_sccp_);
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
sccp_payload_values = sccp_message_type_acro_values;
return sccp_calls(tapinfo, pinfo, edt, prot_info, REDRAW_SCCP);
}
static void
sccp_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_sccp_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_SCCP)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_SCCP;
}
}
static tap_packet_status
sua_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *prot_info, tap_flags_t flags _U_) {
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_sua_);
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
sccp_payload_values = sua_co_class_type_acro_values;
return sccp_calls(tapinfo, pinfo, edt, prot_info, REDRAW_SUA);
}
static void
sua_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_sua_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_SUA)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_SUA;
}
}
void sccp_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("sccp", tap_base_to_id(tap_id_base, tap_id_offset_sccp_),
NULL,
0,
NULL,
sccp_calls_packet,
sccp_calls_draw,
NULL);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
error_string = register_tap_listener("sua", tap_base_to_id(tap_id_base, tap_id_offset_sua_),
NULL,
0,
NULL,
sua_calls_packet,
sua_calls_draw,
NULL);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
void
remove_tap_listener_sccp_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_sccp_));
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_sua_));
}
/****************************************************************************/
/****************************TAP for UNISTIM ********************************/
/****************************************************************************/
static tap_packet_status
unistim_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *unistim_info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_unistim_);
voip_calls_info_t *tmp_listinfo;
voip_calls_info_t *callsinfo = NULL;
unistim_info_t *tmp_unistim_info = NULL;
GList *list = NULL;
GString *g_tmp = NULL;
const gchar *frame_label = NULL;
gchar *comment = NULL;
/* Fetch specific packet infos */
const unistim_info_t *pi = (const unistim_info_t *)unistim_info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* Init gstring */
g_tmp = g_string_new(NULL);
/* Check to see if this is a dup */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while(list)
{
tmp_listinfo = (voip_calls_info_t *)list->data;
if(tmp_listinfo->protocol == VOIP_UNISTIM) {
tmp_unistim_info = (unistim_info_t *)tmp_listinfo->prot_info;
/* Search by termid if possible, otherwise use ni/it ip + port.. */
if(pi->termid != 0) {
if(tmp_unistim_info->termid == pi->termid) {
/* If the call has ended, then we can reuse it.. */
if(tmp_listinfo->call_state == VOIP_COMPLETED || tmp_listinfo->call_state == VOIP_UNKNOWN) {
/* Do nothing */
} else {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
} else {
/* If no term id use ips / port to find entry */
if(addresses_equal(&tmp_unistim_info->it_ip, &pinfo->dst) && addresses_equal(&tmp_unistim_info->ni_ip,&pinfo->src) && (tmp_unistim_info->it_port == pinfo->destport)) {
if(tmp_listinfo->call_state == VOIP_COMPLETED || tmp_listinfo->call_state == VOIP_UNKNOWN) {
/* Do nothing previous call */
} else {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
else if(addresses_equal(&tmp_unistim_info->it_ip, &pinfo->src) && addresses_equal(&tmp_unistim_info->ni_ip,&pinfo->dst) && (tmp_unistim_info->it_port == pinfo->srcport)) {
if(tmp_listinfo->call_state == VOIP_COMPLETED || tmp_listinfo->call_state == VOIP_UNKNOWN) {
/* Do nothing, it ain't our call.. */
} else {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
}
}
/* Otherwise, go to the next one.. */
list = g_list_next(list);
}
if(pi->payload_type == 2 || pi->payload_type == 1) {
if(pi->key_state == 1 || pi->hook_state == 1) {
/* If the user hits a button,
Session will be SETUP */
/* If new add to list */
if (callsinfo==NULL) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_CALL_SETUP;
callsinfo->from_identity=ws_strdup_printf("%x",pi->termid);
callsinfo->to_identity=g_strdup("UNKNOWN");
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
/* Set this on init of struct so in case the call doesn't complete, we'll have a ref. */
/* Otherwise if the call is completed we'll have the open/close streams to ref actual call duration */
/* Store frame data which holds time and frame number */
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->protocol=VOIP_UNISTIM;
callsinfo->prot_info=g_new(unistim_info_t, 1);
tmp_unistim_info = (unistim_info_t *)callsinfo->prot_info;
/* Clear tap struct */
tmp_unistim_info->rudp_type = 0;
tmp_unistim_info->payload_type = 0;
tmp_unistim_info->sequence = pi->sequence;
tmp_unistim_info->termid = pi->termid;
tmp_unistim_info->key_val = -1;
tmp_unistim_info->key_state = -1;
tmp_unistim_info->hook_state = -1;
tmp_unistim_info->stream_connect = -1;
tmp_unistim_info->trans_connect = -1;
tmp_unistim_info->set_termid = -1;
tmp_unistim_info->string_data = NULL;
tmp_unistim_info->key_buffer = NULL;
copy_address(&(tmp_unistim_info->it_ip),&(pi->it_ip));
copy_address(&(tmp_unistim_info->ni_ip),&(pi->ni_ip));
tmp_unistim_info->it_port = pi->it_port;
callsinfo->free_prot_info = g_free;
callsinfo->npackets = 0;
callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
} else {
/* Set up call wide info struct */
tmp_unistim_info = (unistim_info_t *)callsinfo->prot_info;
tmp_unistim_info->sequence = pi->sequence;
}
/* Each packet COULD BE OUR LAST!!!! */
/* Store frame data which holds time and frame number */
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
/* This is a valid packet so increment counter */
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* Key was depressed.. update key buffer.. */
if(pi->key_val >= 0 && pi->key_val <= 11) {
if(tmp_unistim_info->key_buffer != NULL) {
/* assign to temp variable */
g_string_assign(g_tmp,tmp_unistim_info->key_buffer);
/* Manipulate the data */
if(pi->key_val == 10) {
tmp_unistim_info->key_buffer = ws_strdup_printf("%s*",g_tmp->str);
} else if(pi->key_val == 11) {
tmp_unistim_info->key_buffer = ws_strdup_printf("%s#",g_tmp->str);
} else {
tmp_unistim_info->key_buffer = ws_strdup_printf("%s%d",g_tmp->str,pi->key_val);
}
} else {
/* Create new string */
if(pi->key_val == 10) {
tmp_unistim_info->key_buffer = g_strdup("*");
} else if(pi->key_val == 11) {
tmp_unistim_info->key_buffer = g_strdup("#");
} else {
tmp_unistim_info->key_buffer = ws_strdup_printf("%d",pi->key_val);
}
}
/* Select for non-digit characters */
if(pi->key_val == 10) {
comment = ws_strdup_printf("Key Input Sent: * (%d)", pi->sequence);
} else if(pi->key_val == 11) {
comment = ws_strdup_printf("Key Input Sent: # (%d)", pi->sequence);
} else {
comment = ws_strdup_printf("Key Input Sent: %d (%d)",pi->key_val, pi->sequence);
}
} else if(pi->key_val == 12) {
/* Set label and comment for graph */
comment = ws_strdup_printf("Key Input Sent: UP (%d)", pi->sequence);
} else if(pi->key_val == 13) {
/* Set label and comment for graph */
comment = ws_strdup_printf("Key Input Sent: DOWN (%d)", pi->sequence);
} else if(pi->key_val == 14) {
/* Set label and comment for graph */
comment = ws_strdup_printf("Key Input Sent: RIGHT (%d)", pi->sequence);
} else if(pi->key_val == 15) {
if(pi->key_buffer != NULL) {
/* Get data */
g_string_assign(g_tmp,pi->key_buffer);
/* Manipulate the data */
g_string_truncate(g_tmp,g_tmp->len-1);
/* Insert new data */
tmp_unistim_info->key_buffer = g_strdup(g_tmp->str);
}
/* Set label and comment for graph */
comment = ws_strdup_printf("Key Input Sent: LEFT (%d)", pi->sequence);
} else if(pi->key_val == 20) {
/* User pressed the soft key 0 probably dial */
comment = ws_strdup_printf("Key Input Sent: S0 (%d)", pi->sequence);
} else if(pi->key_val == 21) {
/* User pressed the soft key 1 */
comment = ws_strdup_printf("Key Input Sent: S1 (%d)", pi->sequence);
} else if(pi->key_val == 22) {
/* User pressed the soft key 2 */
/* On cs2k phones, soft key 2 is backspace. */
if(pi->key_buffer != NULL) {
/* Get data */
g_string_assign(g_tmp,pi->key_buffer);
/* Manipulate the data */
g_string_truncate(g_tmp,g_tmp->len-1);
/* Insert new data */
tmp_unistim_info->key_buffer = g_strdup(g_tmp->str);
}
/* add label and comment */
comment = ws_strdup_printf("Key Input Sent: S2 (%d)", pi->sequence);
} else if(pi->key_val == 28) {
/* User pressed something */
comment = ws_strdup_printf("Key Input Sent: Release (%d)", pi->sequence);
} else if(pi->key_val == 23) {
/* User pressed the soft key 3 */
/* Cancel on cs2k so clear buffer */
/* On mcs it's config which will clear the buffer too */
tmp_unistim_info->key_buffer = g_strdup("\n");
/* User pressed something, set labels*/
comment = ws_strdup_printf("Key Input Sent: S3 (%d)", pi->sequence);
} else if(pi->key_val == 27) {
/* User pressed something */
comment = ws_strdup_printf("Key Input Sent: Hold (%d)", pi->sequence);
} else if(pi->key_val == 29) {
/* User pressed something */
comment = ws_strdup_printf("Key Input Sent: Mute (%d)", pi->sequence);
} else if(pi->key_val == 30) {
/* User pressed something */
comment = ws_strdup_printf("Key Input Sent: Headset (%d)", pi->sequence);
} else if(pi->key_val == 31) {
/* Handsfree button */
comment = ws_strdup_printf("Key Input Sent: Handsfree (%d)", pi->sequence);
} else if(pi->key_val >= 32 && pi->key_val <= 56) {
/* Prog. Key X */
comment = ws_strdup_printf("Key Input Sent: Prog%d (%d)", (pi->key_val & 31), pi->sequence);
}
if(pi->key_val != -1) {
frame_label = "KEY INPUT";
if (comment == NULL)
/* Ouch! What do you do!? */
/* User pressed something */
comment = ws_strdup_printf("Key Input Sent: UNKNOWN - %d (%d)", pi->key_val, pi->sequence);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
}
if(pi->hook_state == 1) {
/* Phone is off hook */
frame_label = "OFF HOOK";
comment = ws_strdup_printf("Off Hook (%d)", pi->sequence);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
} else if(pi->hook_state == 0) {
/* Phone is on hook */
frame_label = "ON HOOK";
comment = ws_strdup_printf("On Hook (%d)", pi->sequence);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
}
}
/* Open stream was sent from server */
if(pi->stream_connect == 1 && callsinfo != NULL) {
/* Open stream */
/* Signifies the start of the call so set start_sec & start_usec */
/* Frame data holds the time info */
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
/* Each packet COULD BE OUR LAST!!!! */
/* Store frame data which holds time and frame number */
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
/* Local packets too */
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* ?? means we're not quite sure if this is accurate. Since Unistim isn't a true
Call control protocol, we can only guess at the destination by messing with
key buffers. */
if(tmp_unistim_info->key_buffer != NULL) {
callsinfo->to_identity = ws_strdup_printf("?? %s",tmp_unistim_info->key_buffer);
}
/* change sequence number for ACK detection */
tmp_unistim_info->sequence = pi->sequence;
/* State changes too */
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_IN_CALL;
/* Add graph data */
frame_label = "STREAM OPENED";
comment = ws_strdup_printf("Stream Opened (%d)",pi->sequence);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
} else if(pi->stream_connect == 1 && callsinfo == NULL) {
/* Research indicates some nortel products initiate stream first
* without keypresses, therefore creating this solely on a keypress is
* ineffective.
* Sometimes calls start immediately with open stream.
*/
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_CALL_SETUP;
callsinfo->from_identity=g_strdup("UNKNOWN");
callsinfo->to_identity=g_strdup("UNKNOWN");
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
/* Set this on init of struct so in case the call doesn't complete, we'll have a ref. */
/* Otherwise if the call is completed we'll have the open/close streams to ref actual call duration */
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->protocol=VOIP_UNISTIM;
callsinfo->prot_info=g_new(unistim_info_t, 1);
tmp_unistim_info = (unistim_info_t *)callsinfo->prot_info;
/* Clear tap struct */
tmp_unistim_info->rudp_type = 0;
tmp_unistim_info->payload_type = 0;
tmp_unistim_info->sequence = 0;
tmp_unistim_info->termid = 0;
tmp_unistim_info->key_val = -1;
tmp_unistim_info->key_state = -1;
tmp_unistim_info->hook_state = -1;
tmp_unistim_info->stream_connect = -1;
tmp_unistim_info->trans_connect = -1;
tmp_unistim_info->set_termid = -1;
tmp_unistim_info->string_data = NULL;
tmp_unistim_info->key_buffer = NULL;
copy_address(&(tmp_unistim_info->it_ip),&(pi->it_ip));
copy_address(&(tmp_unistim_info->ni_ip),&(pi->ni_ip));
tmp_unistim_info->it_port = pi->it_port;
callsinfo->free_prot_info = g_free;
callsinfo->npackets = 0;
callsinfo->call_num = tapinfo->ncalls++;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
/* Open stream */
/* Each packet COULD BE OUR LAST!!!! */
/* Store frame data which holds time and frame number */
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
/* Local packets too */
++(callsinfo->npackets);
/* increment the packets counter of all calls */
++(tapinfo->npackets);
/* ?? means we're not quite sure if this is accurate. Since Unistim isn't a true
Call control protocol, we can only guess at the destination by messing with
key buffers. */
if(tmp_unistim_info->key_buffer != NULL) {
callsinfo->to_identity = ws_strdup_printf("?? %s",tmp_unistim_info->key_buffer);
}
/* change sequence number for ACK detection */
tmp_unistim_info->sequence = pi->sequence;
/* State changes too */
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->call_state = VOIP_IN_CALL;
/* Add graph data */
frame_label = "STREAM OPENED";
comment = ws_strdup_printf("Stream Opened (%d)",pi->sequence);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
} else if(pi->stream_connect == 0 && callsinfo != NULL) {
/* Close Stream */
/* Set stop seconds + usec */
/* frame_data holds the time info */
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
tmp_unistim_info->sequence = pi->sequence;
if(callsinfo->call_state == VOIP_IN_CALL) {
callsinfo->call_active_state = VOIP_INACTIVE;
callsinfo->call_state = VOIP_COMPLETED;
} else {
callsinfo->call_state = VOIP_UNKNOWN;
callsinfo->call_active_state = VOIP_INACTIVE;
}
frame_label = "STREAM CLOSED";
comment = ws_strdup_printf("Stream Closed (%d)",pi->sequence);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
} else
comment = NULL;
} else if(pi->rudp_type == 1 && callsinfo != NULL) {
/* ACK */
/* Only show acks for processed seq #s */
if(tmp_unistim_info->sequence == pi->sequence) {
frame_label = "ACK";
comment = ws_strdup_printf("ACK for sequence %d",pi->sequence);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
}
} else if(pi->rudp_type == 0 && callsinfo != NULL) {
/* NAK */
frame_label = "NAK";
comment = ws_strdup_printf("NAK for sequence %d",pi->sequence);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
}
/* free data */
g_free(comment);
g_string_free(g_tmp, TRUE);
tapinfo->redraw |= REDRAW_UNISTIM;
return TAP_PACKET_REDRAW;
}
/****************************************************************************/
static void
unistim_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_unistim_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_UNISTIM)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_UNISTIM;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
unistim_calls_init_tap(voip_calls_tapinfo_t *tap_id_base) {
GString *error_string;
error_string = register_tap_listener("unistim", tap_base_to_id(tap_id_base, tap_id_offset_unistim_),
NULL,
0,
NULL,
unistim_calls_packet,
unistim_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_unistim_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_unistim_));
}
/****************************************************************************/
/* ***************************TAP for SKINNY **********************************/
/****************************************************************************/
/* Telecaster to tap-voip call state mapping */
static const voip_call_state skinny_tap_voip_state[] = {
VOIP_NO_STATE,
VOIP_CALL_SETUP,
VOIP_COMPLETED,
VOIP_RINGING,
VOIP_RINGING,
VOIP_IN_CALL,
VOIP_REJECTED,
VOIP_REJECTED,
VOIP_IN_CALL,
VOIP_IN_CALL,
VOIP_COMPLETED,
VOIP_COMPLETED,
VOIP_CALL_SETUP,
VOIP_UNKNOWN,
VOIP_REJECTED
};
static tap_packet_status
skinny_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *skinny_info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_skinny_);
GList* list;
voip_calls_info_t *callsinfo = NULL;
address* phone;
const skinny_info_t *si = (const skinny_info_t *)skinny_info;
skinny_calls_info_t *tmp_skinnyinfo;
gchar *comment;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
if (si == NULL || (si->callId == 0 && si->passThroughPartyId == 0))
return TAP_PACKET_DONT_REDRAW;
/* check whether we already have this context in the list */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
voip_calls_info_t* tmp_listinfo = (voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == VOIP_SKINNY) {
tmp_skinnyinfo = (skinny_calls_info_t *)tmp_listinfo->prot_info;
if (tmp_skinnyinfo->callId == si->callId ||
tmp_skinnyinfo->callId == si->passThroughPartyId) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
if (si->messId >= 256)
phone = &(pinfo->dst);
else
phone = &(pinfo->src);
if (callsinfo==NULL) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_state = VOIP_NO_STATE;
callsinfo->call_active_state = VOIP_ACTIVE;
/* callsinfo->from_identity = ws_strdup_printf("%s : %.8x", "Skinny", 1); */
callsinfo->from_identity = g_strdup("");
callsinfo->to_identity = g_strdup("");
callsinfo->prot_info = g_new(skinny_calls_info_t, 1);
callsinfo->free_prot_info = g_free;
tmp_skinnyinfo = (skinny_calls_info_t *)callsinfo->prot_info;
tmp_skinnyinfo->callId = si->callId ? si->callId : si->passThroughPartyId;
callsinfo->npackets = 1;
copy_address(&(callsinfo->initial_speaker), phone);
callsinfo->protocol = VOIP_SKINNY;
callsinfo->call_num = tapinfo->ncalls++;
callsinfo->start_fd = pinfo->fd;
callsinfo->start_rel_ts = pinfo->rel_ts;
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
} else {
if (si->callingParty) {
g_free(callsinfo->from_identity);
callsinfo->from_identity = g_strdup(si->callingParty);
}
if (si->calledParty) {
g_free(callsinfo->to_identity);
callsinfo->to_identity = g_strdup(si->calledParty);
}
if ((si->callState > 0) && (si->callState < (sizeof(skinny_tap_voip_state)/sizeof(skinny_tap_voip_state[0]))))
callsinfo->call_state = skinny_tap_voip_state[si->callState];
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
}
if (si->callId) {
if (si->passThroughPartyId)
comment = ws_strdup_printf("CallId = %u, PTId = %u", si->callId, si->passThroughPartyId);
else
comment = ws_strdup_printf("CallId = %u, LineId = %u", si->callId, si->lineId);
} else {
if (si->passThroughPartyId)
comment = ws_strdup_printf("PTId = %u", si->passThroughPartyId);
else
comment = NULL;
}
add_to_graph(tapinfo, pinfo, edt, si->messageName, comment,
callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
append_to_frame_graph(tapinfo, pinfo->num, si->additionalInfo, NULL);
tapinfo->redraw |= REDRAW_SKINNY;
return TAP_PACKET_REDRAW;
}
/****************************************************************************/
static void
skinny_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_skinny_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_SKINNY)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_SKINNY;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
skinny_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
/*
* We set TL_REQUIRES_PROTO_TREE to force a non-null "tree"
* in the SKINNY dissector; otherwise, the dissector
* doesn't fill in the info passed to the tap's packet
* routine.
*/
error_string = register_tap_listener("skinny",
tap_base_to_id(tap_id_base, tap_id_offset_skinny_),
NULL,
TL_REQUIRES_PROTO_TREE,
NULL,
skinny_calls_packet,
skinny_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_skinny_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_skinny_));
}
/****************************************************************************/
/* ***************************TAP for IAX2 **********************************/
/****************************************************************************/
static void free_iax2_info(gpointer p) {
iax2_info_t *ii = (iax2_info_t *)p;
g_free(ii);
}
/****************************************************************************/
/* whenever a IAX2 packet is seen by the tap listener */
static tap_packet_status
iax2_calls_packet( void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *iax2_info, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_iax2_);
GList* list;
voip_calls_info_t *callsinfo = NULL;
address *phone;
const iax2_info_t *ii = (const iax2_info_t *)iax2_info;
iax2_info_t *tmp_iax2info;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
if (ii == NULL || ii->ptype != IAX2_FULL_PACKET || (ii->scallno == 0 && ii->dcallno == 0))
return TAP_PACKET_DONT_REDRAW;
/* check whether we already have this context in the list */
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list)
{
voip_calls_info_t* tmp_listinfo = (voip_calls_info_t *)list->data;
if (tmp_listinfo->protocol == VOIP_IAX2) {
tmp_iax2info = (iax2_info_t *)tmp_listinfo->prot_info;
if (tmp_iax2info->scallno == ii->scallno ||
tmp_iax2info->scallno == ii->dcallno) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next (list);
}
phone = &(pinfo->src);
if (callsinfo==NULL) {
/* We only care about real calls, i.e., no registration stuff */
if (ii->ftype != AST_FRAME_IAX || ii->csub != IAX_COMMAND_NEW)
return TAP_PACKET_DONT_REDRAW;
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_state = VOIP_NO_STATE;
callsinfo->call_active_state = VOIP_ACTIVE;
callsinfo->prot_info=g_new(iax2_info_t, 1);
callsinfo->free_prot_info = free_iax2_info;
tmp_iax2info = (iax2_info_t *)callsinfo->prot_info;
tmp_iax2info->scallno = ii->scallno;
if (tmp_iax2info->scallno == 0) tmp_iax2info->scallno = ii->dcallno;
tmp_iax2info->callState = ii->callState;
callsinfo->npackets = 1;
copy_address(&(callsinfo->initial_speaker), phone);
callsinfo->from_identity = g_strdup(ii->callingParty);
callsinfo->to_identity = g_strdup(ii->calledParty);
callsinfo->protocol = VOIP_IAX2;
callsinfo->call_num = tapinfo->ncalls++;
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
} else {
callsinfo->call_state = ii->callState;
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
}
add_to_graph(tapinfo, pinfo, edt, ii->messageName, "",
callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
tapinfo->redraw |= REDRAW_IAX2;
return TAP_PACKET_REDRAW;
}
/****************************************************************************/
static void
iax2_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_iax2_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_IAX2)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_IAX2;
}
}
/****************************************************************************/
/* TAP INTERFACE */
/****************************************************************************/
void
iax2_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
/*
* We set TL_REQUIRES_PROTO_TREE to force a non-null "tree"
* in the IAX2 dissector; otherwise, the dissector
* doesn't fill in the info passed to the tap's packet
* routine.
* XXX - that appears to be true of the MGCP and SKINNY
* dissectors, but, unless I've missed something, it doesn't
* appear to be true of the IAX2 dissector.
*/
error_string = register_tap_listener("IAX2",
tap_base_to_id(tap_id_base, tap_id_offset_iax2_),
NULL,
TL_REQUIRES_PROTO_TREE,
NULL,
iax2_calls_packet,
iax2_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s",
error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_iax2_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_iax2_));
}
/****************************************************************************/
/* ***************************TAP for OTHER PROTOCOL **********************************/
/****************************************************************************/
/* voip_calls_packet and voip_calls_init_tap appear to be dead code. We don't have a "voip" tap. */
static tap_packet_status
voip_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, const void *VoIPinfo, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_voip_);
voip_calls_info_t *callsinfo = NULL;
voip_calls_info_t *tmp_listinfo;
GList *list = NULL;
const voip_packet_info_t *pi = (const voip_packet_info_t *)VoIPinfo;
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
/* VOIP_CALLS_DEBUG("num %u", pinfo->num); */
if (pi->call_id)
list = g_queue_peek_nth_link(tapinfo->callsinfos, 0);
while (list) {
tmp_listinfo = (voip_calls_info_t *)list->data;
if ( tmp_listinfo->protocol == VOIP_COMMON ) {
if (!strcmp(pi->call_id, tmp_listinfo->call_id)) {
callsinfo = (voip_calls_info_t*)(list->data);
break;
}
}
list = g_list_next(list);
}
if (callsinfo == NULL) {
callsinfo = g_new0(voip_calls_info_t, 1);
callsinfo->call_active_state = pi->call_active_state;
callsinfo->call_state = pi->call_state;
callsinfo->call_id=g_strdup((pi->call_id)?pi->call_id:"");
callsinfo->from_identity = g_strdup((pi->from_identity)?pi->from_identity:"");
callsinfo->to_identity = g_strdup((pi->to_identity)?pi->to_identity:"");
copy_address(&(callsinfo->initial_speaker),&(pinfo->src));
callsinfo->start_fd=pinfo->fd;
callsinfo->start_rel_ts=pinfo->rel_ts;
callsinfo->protocol=VOIP_COMMON;
callsinfo->protocol_name=g_strdup((pi->protocol_name)?pi->protocol_name:"");
callsinfo->call_comment=g_strdup((pi->call_comment)?pi->call_comment:"");
callsinfo->prot_info=NULL;
callsinfo->free_prot_info = NULL;
callsinfo->call_num = tapinfo->ncalls++;
callsinfo->npackets = 0;
g_queue_push_tail(tapinfo->callsinfos, callsinfo);
}
callsinfo->call_active_state = pi->call_active_state;
if ((callsinfo->call_state != VOIP_COMPLETED) && (pi->call_state == VOIP_COMPLETED))
tapinfo->completed_calls++;
if (pi->call_state != VOIP_NO_STATE)
callsinfo->call_state = pi->call_state;
if (pi->call_comment) {
g_free(callsinfo->call_comment);
callsinfo->call_comment=g_strdup(pi->call_comment);
}
callsinfo->stop_fd = pinfo->fd;
callsinfo->stop_rel_ts = pinfo->rel_ts;
++(callsinfo->npackets);
++(tapinfo->npackets);
/* add to the graph */
add_to_graph(tapinfo, pinfo, edt, (pi->frame_label)?pi->frame_label:"VoIP msg", pi->frame_comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
tapinfo->redraw |= REDRAW_VOIP;
return TAP_PACKET_REDRAW;
}
/****************************************************************************/
static void
voip_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_voip_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_VOIP)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_VOIP;
}
}
/****************************************************************************/
void
voip_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("voip", tap_base_to_id(tap_id_base, tap_id_offset_voip_),
NULL,
0,
NULL,
voip_calls_packet,
voip_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_voip_calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_voip_));
}
/****************************************************************************/
/* ***************************TAP for OTHER PROTOCOL **********************************/
/****************************************************************************/
/****************************************************************************/
/* whenever a prot_ packet is seen by the tap listener */
#if 0
static tap_packet_status
prot_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prot_info _U_, tap_flags_t flags _U_)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_prot_);
/* if display filtering activated and packet do not match, ignore it */
if (tapinfo->apply_display_filter && (pinfo->fd->passed_dfilter == 0)) {
return TAP_PACKET_DONT_REDRAW;
}
if (callsinfo!=NULL) {
callsinfo->stop_abs = pinfo->abs_ts;
callsinfo->stop_rel = pinfo->rel_ts;
callsinfo->last_frame_num=pinfo->num;
++(callsinfo->npackets);
++(tapinfo->npackets);
}
tapinfo->redraw = REDRAW_PROT;
return TAP_PACKET_REDRAW;
}
/****************************************************************************/
static void
prot_calls_draw(void *tap_offset_ptr)
{
voip_calls_tapinfo_t *tapinfo = tap_id_to_base(tap_offset_ptr, tap_id_offset_prot_);
if (tapinfo->tap_draw && (tapinfo->redraw & REDRAW_PROT)) {
tapinfo->tap_draw(tapinfo);
tapinfo->redraw &= ~REDRAW_PROT;
}
}
/****************************************************************************/
void
prot_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
{
GString *error_string;
error_string = register_tap_listener("prot_", tap_base_to_id(tap_id_base, tap_id_offset_prot_),
NULL,
0,
NULL,
prot_calls_packet,
prot_calls_draw,
NULL
);
if (error_string != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%s", error_string->str);
g_string_free(error_string, TRUE);
}
}
/****************************************************************************/
void
remove_tap_listener_prot__calls(voip_calls_tapinfo_t *tap_id_base)
{
remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_prot_));
}
#endif |
C/C++ | wireshark/ui/voip_calls.h | /** @file
*
* VoIP calls summary addition for Wireshark
*
* Copyright 2004, Ericsson , Spain
* By Francisco Alcoba <[email protected]>
*
* based on h323_calls.h
* Copyright 2004, Iskratel, Ltd, Kranj
* By Miha Jemec <[email protected]>
*
* H323, RTP and Graph Support
* By Alejandro Vaquero, [email protected]
* Copyright 2005, Verso Technologies Inc.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __VOIP_CALLS_H__
#define __VOIP_CALLS_H__
#include <glib.h>
#include <stdio.h>
#include "epan/address.h"
#include "epan/packet.h"
#include "epan/guid-utils.h"
#include "epan/tap.h"
#include "epan/tap-voip.h"
#include "epan/sequence_analysis.h"
/** @file
* "VoIP Calls" dialog box common routines.
* @ingroup main_ui_group
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/****************************************************************************/
extern const char *voip_call_state_name[8];
typedef enum _voip_protocol {
VOIP_SIP,
VOIP_ISUP,
VOIP_H323,
VOIP_MGCP,
VOIP_AC_ISDN,
VOIP_AC_CAS,
MEDIA_T38,
TEL_H248,
TEL_SCCP,
TEL_BSSMAP,
TEL_RANAP,
VOIP_UNISTIM,
VOIP_SKINNY,
VOIP_IAX2,
VOIP_COMMON
} voip_protocol;
typedef enum _hash_indexes {
SIP_HASH=0
} hash_indexes;
extern const char *voip_protocol_name[];
typedef enum _flow_show_options
{
FLOW_ALL,
FLOW_ONLY_INVITES
} flow_show_options;
/** defines specific SIP data */
typedef enum _sip_call_state {
SIP_INVITE_SENT,
SIP_200_REC,
SIP_CANCEL_SENT
} sip_call_state;
typedef struct _sip_calls_info {
gchar *call_identifier;
guint32 invite_cseq;
sip_call_state sip_state;
} sip_calls_info_t;
/** defines specific ISUP data */
typedef struct _isup_calls_info {
guint16 cic;
guint32 opc, dpc;
guint8 ni;
} isup_calls_info_t;
/* defines specific H245 data */
typedef struct _h245_address {
address h245_address;
guint16 h245_port;
} h245_address_t;
/** defines specific H323 data */
typedef struct _h323_calls_info {
e_guid_t *guid; /* Call ID to identify a H225 */
GList* h245_list; /**< list of H245 Address and ports for tunneling off calls*/
address h225SetupAddr; /**< we use the SETUP H225 IP to determine if packets are forward or reverse */
gboolean is_h245;
gboolean is_faststart_Setup; /**< if faststart field is included in Setup*/
gboolean is_faststart_Proc; /**< if faststart field is included in Proce, Alerting, Progress or Connect*/
gboolean is_h245Tunneling;
gint32 q931_crv;
gint32 q931_crv2;
guint requestSeqNum;
} h323_calls_info_t;
/**< defines specific MGCP data */
typedef struct _mgcp_calls_info {
gchar *endpointId;
gboolean fromEndpoint; /**< true if the call was originated from the Endpoint, false for calls from MGC */
} mgcp_calls_info_t;
/** defines specific ACTRACE ISDN data */
typedef struct _actrace_isdn_calls_info {
gint32 crv;
int trunk;
} actrace_isdn_calls_info_t;
/** defines specific ACTRACE CAS data */
typedef struct _actrace_cas_calls_info {
gint32 bchannel;
int trunk;
} actrace_cas_calls_info_t;
/** defines specific SKINNY data */
typedef struct _skinny_calls_info {
guint32 callId;
} skinny_calls_info_t;
/** defines a voip call */
typedef struct _voip_calls_info {
voip_call_state call_state;
voip_call_active_state call_active_state;
gchar *call_id;
gchar *from_identity;
gchar *to_identity;
gpointer prot_info;
void (*free_prot_info)(gpointer);
address initial_speaker;
guint32 npackets;
voip_protocol protocol;
gchar *protocol_name;
gchar *call_comment;
guint16 call_num;
/**> The frame_data struct holds the frame number and timing information needed. */
frame_data *start_fd;
nstime_t start_rel_ts;
frame_data *stop_fd;
nstime_t stop_rel_ts;
} voip_calls_info_t;
/**
* structure that holds the information about all detected calls */
/* struct holding all information of the tap */
/*
* XXX Most of these are private to voip_calls.c. We might want to
* make them private.
*/
struct _h245_labels;
typedef struct _voip_calls_tapinfo {
tap_reset_cb tap_reset; /**< tap reset callback */
tap_packet_cb tap_packet; /**< tap per-packet callback */
tap_draw_cb tap_draw; /**< tap draw callback */
void *tap_data; /**< data for tap callbacks */
int ncalls; /**< number of call */
GQueue* callsinfos; /**< queue with all calls (voip_calls_info_t) */
GHashTable* callsinfo_hashtable[1]; /**< array of hashes per voip protocol (voip_calls_info_t); currently only the one for SIP is used */
int npackets; /**< total number of packets of all calls */
voip_calls_info_t *filter_calls_fwd; /**< used as filter in some tap modes */
int start_packets;
int completed_calls;
int rejected_calls;
seq_analysis_info_t *graph_analysis;
epan_t *session; /**< epan session */
int nrtpstreams; /**< number of rtp streams */
GList* rtpstream_list; /**< list of rtpstream_info_t */
guint32 rtp_evt_frame_num;
guint8 rtp_evt;
gboolean rtp_evt_end;
gchar *sdp_summary;
guint32 sdp_frame_num;
guint32 mtp3_opc;
guint32 mtp3_dpc;
guint8 mtp3_ni;
guint32 mtp3_frame_num;
struct _h245_labels *h245_labels; /**< H.245 labels */
gchar *q931_calling_number;
gchar *q931_called_number;
guint8 q931_cause_value;
gint32 q931_crv;
guint32 q931_frame_num;
guint32 h225_frame_num;
guint16 h225_call_num;
int h225_cstype; /* XXX actually an enum */
gboolean h225_is_faststart;
guint32 sip_frame_num;
guint32 actrace_frame_num;
gint32 actrace_trunk;
gint32 actrace_direction;
flow_show_options fs_option;
guint32 redraw;
gboolean apply_display_filter;
} voip_calls_tapinfo_t;
#if 0
#define VOIP_CALLS_DEBUG(...) { \
char *VOIP_CALLS_DEBUG_MSG = ws_strdup_printf(__VA_ARGS__); \
ws_warning("voip_calls: %s:%d %s", G_STRFUNC, __LINE__, VOIP_CALLS_DEBUG_MSG); \
g_free(VOIP_CALLS_DEBUG_MSG); \
}
#else
#define VOIP_CALLS_DEBUG(...)
#endif
/****************************************************************************/
/* INTERFACE */
/**
* Registers the voip_calls tap listeners (if not already done).
* From that point on, the calls list will be updated with every redissection.
* This function is also the entry point for the initialization routine of the tap system.
* So whenever voip_calls.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
* If not, it will be registered on demand by the voip_calls functions that need it.
*/
void voip_calls_init_all_taps(voip_calls_tapinfo_t *tap_id_base);
/**
* Removes the voip_calls tap listener (if not already done)
* From that point on, the voip calls list won't be updated any more.
*/
void voip_calls_remove_all_tap_listeners(voip_calls_tapinfo_t *tap_id_base);
/**
* Cleans up memory of voip calls tap.
*/
void voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo);
/**
* Frees one callsinfo
*/
void
voip_calls_free_callsinfo(voip_calls_info_t *callsinfo);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __VOIP_CALLS_H__ */ |
C/C++ | wireshark/ui/ws_ui_util.h | /** @file
*
* Declarations of UI utility routines; these routines have GUI-independent
* APIs, but GUI-dependent implementations, so that they can be called by
* GUI-independent code to affect the GUI.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __UI_UTIL_H__
#define __UI_UTIL_H__
#include <stdint.h>
#include <wsutil/processes.h>
#include "epan/packet_info.h"
#include "epan/column-utils.h"
#include "epan/color_filters.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** geometry values for use in window_get_geometry() and window_set_geometry() */
typedef struct window_geometry_s {
gchar *key; /**< current key in hashtable (internally used only) */
gboolean set_pos; /**< set the x and y position values */
gint x; /**< the windows x position */
gint y; /**< the windows y position */
gboolean set_size; /**< set the width and height values */
gint width; /**< the windows width */
gint height; /**< the windows height */
gboolean set_maximized; /**< set the maximized state */
gboolean maximized; /**< the windows maximized state */
} window_geometry_t;
/* update the main window */
extern void main_window_update(void);
/* Exit routine provided by UI-specific code. */
WS_NORETURN extern void exit_application(int status);
/* XXX - Yes this isn't the best place, but they are used by file_dlg_win32.c, which is supposed
to be GUI independent, but has lots of GTK leanings. But if you put these in a GTK UI
header file, file_dlg_win32.c complains about all of the GTK structures also in the header
files
Function names make it clear where they are coming from
*/
void color_filter_add_cb(color_filter_t *colorf, gpointer user_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __UI_UTIL_H__ */ |
wireshark/ui/cli/.editorconfig | #
# Editor configuration
#
# https://editorconfig.org
#
[tap-camelsrt.[ch]]
indent_size = 2
[tap-diameter-avp.[ch]]
indent_style = tab
indent_size = tab
[tap-endpoints.[ch]]
indent_style = tab
indent_size = tab
[tap-follow.[ch]]
indent_size = 2
[tap-hosts.[ch]]
indent_style = tab
indent_size = tab
[tap-httpstat.[ch]]
indent_style = tab
indent_size = tab
[tap-iousers.[ch]]
indent_style = tab
indent_size = tab
[tap-protocolinfo.[ch]]
indent_style = tab
indent_size = tab
[tap-protohierstat.[ch]]
indent_style = tab
indent_size = tab
[tap-rpcprogs.[ch]]
indent_style = tab
indent_size = tab
[tap-rtd.[ch]]
indent_style = tab
indent_size = tab
[tap-rtspstat.[ch]]
indent_style = tab
indent_size = tab
[tap-sctpchunkstat.[ch]]
indent_style = tab
indent_size = tab
[tap-simple_stattable.[ch]]
indent_style = tab
indent_size = tab
[tap-sipstat.[ch]]
indent_style = tab
indent_size = tab
[tap-smbsids.[ch]]
indent_style = tab
indent_size = tab
[tap-srt.[ch]]
indent_style = tab
indent_size = tab
[tap-stats_tree.[ch]]
indent_style = tab
indent_size = tab
[tap-sv.[ch]]
indent_style = tab
indent_size = tab
[tap-wspstat.[ch]]
indent_style = tab
indent_size = tab |
|
C | wireshark/ui/cli/simple_dialog.c | /* simple_dialog.c
* simple_dialog 2023 Niels Widger
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides a minimal cli implementation of simple dialogs.
* It is only used by tshark and not wireshark.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib.h>
#include <stdio.h>
#include <ui/simple_dialog.h>
#include "ws_attributes.h"
gpointer
simple_dialog(
ESD_TYPE_E type _U_,
gint btn_mask _U_,
const gchar * msg_format,
...
)
{
va_list ap;
va_start(ap, msg_format);
vfprintf(stderr, msg_format, ap);
va_end(ap);
return NULL;
}
void
simple_message_box(ESD_TYPE_E type _U_, gboolean *notagain _U_,
const char *secondary_msg, const char *msg_format, ...)
{
va_list ap;
va_start(ap, msg_format);
vfprintf(stderr, msg_format, ap);
va_end(ap);
fprintf(stderr, "%s\n", secondary_msg);
}
/*
* Error alert box, taking a format and a va_list argument.
*/
void
vsimple_error_message_box(const char *msg_format, va_list ap)
{
vfprintf(stderr, msg_format, ap);
} |
C | wireshark/ui/cli/tap-camelsrt.c | /* tap_camelsrt.c
* CAMEL Service Response Time statistics for tshark
* Copyright 2006 Florent Drouin (based on tap_h225rassrt.c from Lars Roland)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "epan/packet.h"
#include <epan/tap.h>
#include "epan/value_string.h"
#include "epan/asn1.h"
#include "epan/dissectors/packet-camel.h"
#include "epan/dissectors/packet-tcap.h"
#include "epan/timestats.h"
#include "epan/stat_tap_ui.h"
#include <wsutil/cmdarg_err.h>
void register_tap_listener_camelsrt(void);
/* Save the first NUM_RAS_STATS stats in the array to calculate percentile */
#define NUM_RAS_STATS 500000
/* Number of couple message Request/Response to analyze*/
#define NB_CRITERIA 7
/* used to keep track of the statistics for an entire program interface */
struct camelsrt_t {
char *filter;
guint32 count[NB_CAMELSRT_CATEGORY];
timestat_t stats[NB_CAMELSRT_CATEGORY];
nstime_t delta_time[NB_CAMELSRT_CATEGORY][NUM_RAS_STATS];
};
/* Reset the counter */
static void camelsrt_reset(void *phs)
{
struct camelsrt_t *hs = (struct camelsrt_t *)phs;
memset(hs, 0, sizeof(struct camelsrt_t));
}
static tap_packet_status camelsrt_packet(void *phs,
packet_info *pinfo _U_,
epan_dissect_t *edt _U_,
const void *phi, tap_flags_t flags _U_)
{
struct camelsrt_t *hs = (struct camelsrt_t *)phs;
const struct camelsrt_info_t * pi = (const struct camelsrt_info_t *)phi;
int i;
for (i=0; i<NB_CAMELSRT_CATEGORY; i++) {
if (pi->bool_msginfo[i] &&
pi->msginfo[i].is_delta_time
&& pi->msginfo[i].request_available
&& !pi->msginfo[i].is_duplicate ) {
time_stat_update(&(hs->stats[i]),
&(pi->msginfo[i].delta_time),
pinfo);
if (hs->count[i] < NUM_RAS_STATS) {
hs->delta_time[i][hs->count[i]++]
= pi->msginfo[i].delta_time;
}
}
}
return TAP_PACKET_REDRAW;
}
static void camelsrt_draw(void *phs)
{
struct camelsrt_t *hs = (struct camelsrt_t *)phs;
guint j, z;
guint32 li;
int somme, iteration = 0;
timestat_t *rtd_temp;
double x, delay, delay_max, delay_min, delta;
double criteria[NB_CRITERIA] = { 5.0, 10.0, 75.0, 90.0, 95.0, 99.0, 99.90 };
double delay_criteria[NB_CRITERIA];
gchar* tmp_str;
printf("\n");
printf("Camel Service Response Time (SRT) Statistics:\n");
printf("=================================================================================================\n");
printf("| Category | Measure | Min SRT | Max SRT | Avg SRT | Min frame | Max frame |\n");
printf("|-------------------------|---------|-----------|-----------|-----------|-----------|-----------|\n");
j = 1;
tmp_str = val_to_str_wmem(NULL, j, camelSRTtype_naming, "Unknown Message 0x%02x");
printf("|%24s |%8u |%8.2f s |%8.2f s |%8.2f s |%10u |%10u |\n",
tmp_str,
hs->stats[j].num,
nstime_to_sec(&(hs->stats[j].min)),
nstime_to_sec(&(hs->stats[j].max)),
get_average(&(hs->stats[j].tot), hs->stats[j].num)/1000.0,
hs->stats[j].min_num,
hs->stats[j].max_num
);
wmem_free(NULL, tmp_str);
for (j=2; j<NB_CAMELSRT_CATEGORY; j++) {
if (hs->stats[j].num == 0) {
tmp_str = val_to_str_wmem(NULL, j, camelSRTtype_naming, "Unknown Message 0x%02x");
printf("|%24s |%8u |%8.2f ms|%8.2f ms|%8.2f ms|%10u |%10u |\n",
tmp_str, 0U, 0.0, 0.0, 0.0, 0U, 0U);
wmem_free(NULL, tmp_str);
continue;
}
tmp_str = val_to_str_wmem(NULL, j, camelSRTtype_naming, "Unknown Message 0x%02x");
printf("|%24s |%8u |%8.2f ms|%8.2f ms|%8.2f ms|%10u |%10u |\n",
tmp_str,
hs->stats[j].num,
MIN(9999, nstime_to_msec(&(hs->stats[j].min))),
MIN(9999, nstime_to_msec(&(hs->stats[j].max))),
MIN(9999, get_average(&(hs->stats[j].tot), hs->stats[j].num)),
hs->stats[j].min_num,
hs->stats[j].max_num
);
wmem_free(NULL, tmp_str);
} /* j category */
printf("=================================================================================================\n");
/*
* Display 95%
*/
printf("| Category/Criteria |");
for (z=0; z<NB_CRITERIA; z++) printf("%7.2f%% |", criteria[z]);
printf("\n");
printf("|-------------------------|");
for (z=0; z<NB_CRITERIA; z++) printf("---------|");
printf("\n");
/* calculate the delay max to have a given number of messages (in percentage) */
for (j=2; j<NB_CAMELSRT_CATEGORY;j++) {
rtd_temp = &(hs->stats[j]);
if (hs->count[j] > 0) {
/* Calculate the delay to answer to p% of the MS */
for (z=0; z<NB_CRITERIA; z++) {
iteration = 0;
delay_max = (double)rtd_temp->max.secs*1000 +(double)rtd_temp->max.nsecs/1000000;
delay_min = (double)rtd_temp->min.secs*1000 +(double)rtd_temp->min.nsecs/1000000;
delay = delay_min;
delta = delay_max-delay_min;
while ( (delta > 0.001) && (iteration < 10000) ) {
somme = 0;
iteration++;
for (li=0; li<hs->count[j]; li++) {
x = hs->delta_time[j][li].secs*1000
+ (double)hs->delta_time[j][li].nsecs/1000000;
if (x <= delay) somme++;
}
if ( somme*100 > hs->count[j]*criteria[z] ) { /* trop grand */
delay_max = delay;
delay = (delay_max+delay_min)/2;
delta = delay_max-delay_min;
} else { /* trop petit */
delay_min = delay;
delay = (delay_max+delay_min)/2;
delta = delay_max-delay_min;
}
} /* while */
delay_criteria[z] = delay;
} /* z criteria */
/* Append the result to the table */
tmp_str = val_to_str_wmem(NULL, j, camelSRTtype_naming, "Unknown Message 0x%02x");
printf("X%24s |", tmp_str);
wmem_free(NULL, tmp_str);
for (z=0; z<NB_CRITERIA; z++) printf("%8.2f |", MIN(9999, delay_criteria[z]));
printf("\n");
} else { /* count */
tmp_str = val_to_str_wmem(NULL, j, camelSRTtype_naming, "Unknown Message 0x%02x");
printf("X%24s |", tmp_str);
wmem_free(NULL, tmp_str);
for (z=0; z<NB_CRITERIA; z++) printf("%8.2f |", 0.0);
printf("\n");
} /* count */
}/* j category */
printf("===========================");
for (z=0; z<NB_CRITERIA; z++) printf("==========");
printf("\n");
}
static void camelsrt_init(const char *opt_arg, void *userdata _U_)
{
struct camelsrt_t *p_camelsrt;
GString *error_string;
p_camelsrt = g_new(struct camelsrt_t, 1);
camelsrt_reset(p_camelsrt);
if (!strncmp(opt_arg, "camel,srt,", 10)) {
p_camelsrt->filter = g_strdup(opt_arg+10);
} else {
p_camelsrt->filter = NULL;
}
error_string = register_tap_listener("CAMEL",
p_camelsrt,
p_camelsrt->filter,
0,
NULL,
camelsrt_packet,
camelsrt_draw,
NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(p_camelsrt->filter);
g_free(p_camelsrt);
cmdarg_err("Couldn't register camel,srt tap: %s", error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
/*
* If we are using tshark, we have to display the stats, even if the stats are not persistent
* As the frame are proceeded in the chronological order, we do not need persistent stats
* Whereas, with wireshark, it is not possible to have the correct display, if the stats are
* not saved along the analyze
*/
gtcap_StatSRT = TRUE;
gcamel_StatSRT = TRUE;
}
static stat_tap_ui camelsrt_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"camel,srt",
camelsrt_init,
0,
NULL
};
void
register_tap_listener_camelsrt(void)
{
register_stat_tap_ui(&camelsrt_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/ |
C | wireshark/ui/cli/tap-credentials.c | /*
* tap-credentials.c
* Copyright 2019 Dario Lombardo <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <wsutil/cmdarg_err.h>
#include <ui/tap-credentials.h>
void register_tap_listener_credentials(void);
wmem_array_t* credentials = NULL;
static tap_credential_t* tap_credential_clone(tap_credential_t* auth)
{
tap_credential_t* clone = wmem_new0(NULL, tap_credential_t);
clone->num = auth->num;
clone->username_num = auth->username_num;
clone->password_hf_id = auth->password_hf_id;
if (auth->username)
clone->username = wmem_strdup(NULL, auth->username);
clone->proto = auth->proto;
if (auth->info)
clone->info = wmem_strdup(NULL, auth->info);
return clone;
}
static tap_packet_status credentials_packet(void *p _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri, tap_flags_t flags _U_)
{
tap_credential_t* clone = tap_credential_clone((tap_credential_t*)pri);
wmem_array_append(credentials, (void*)clone, 1);
return TAP_PACKET_REDRAW;
}
static void credentials_reset(void* p)
{
if (!p)
return;
tap_credential_t* auth = (tap_credential_t*)p;
wmem_free(NULL, auth->username);
wmem_free(NULL, auth->info);
wmem_free(NULL, auth);
}
static void credentials_draw(void *p _U_)
{
printf("===================================================================\n");
printf("%-10s %-16s %-16s %-16s\n", "Packet", "Protocol", "Username", "Info");
printf("------ -------- -------- --------\n");
for (guint i = 0; i < wmem_array_get_count(credentials); i++) {
tap_credential_t* auth = (tap_credential_t*)wmem_array_index(credentials, i);
printf("%-10u %-16s %-16s %-16s\n", auth->num, auth->proto, auth->username, auth->info ? auth->info : "");
}
printf("===================================================================\n");
}
static void credentials_init(const char *opt_arg _U_, void *userdata _U_)
{
GString* error_string;
error_string = register_tap_listener("credentials", NULL, NULL, TL_REQUIRES_NOTHING,
credentials_reset, credentials_packet, credentials_draw, NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
cmdarg_err("Couldn't register credentials tap: %s", error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
credentials = wmem_array_new(wmem_epan_scope(), sizeof(tap_credential_t));
}
static stat_tap_ui credentials_ui = {
REGISTER_TOOLS_GROUP_UNSORTED,
"Username and passwords",
"credentials",
credentials_init,
0,
NULL
};
void
register_tap_listener_credentials(void)
{
register_stat_tap_ui(&credentials_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-diameter-avp.c | /* tap-diameter-avp.c
* Copyright 2010 Andrej Kuehnal <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* This TAP enables extraction of most important diameter fields in text format.
* - much more performance than -T text and -T pdml
* - more powerful than -T field and -z proto,colinfo
* - exacltly one text line per diameter message
* - multiple diameter messages in one frame supported
* E.g. one device watchdog answer and two credit control answers
* in one TCP packet produces 3 text lines.
* - several fields with same name within one diameter message supported
* E.g. Multiple AVP(444) Subscription-Id-Data once with IMSI once with MSISDN
* - several grouped AVPs supported
* E.g. Zero or more Multiple-Services-Credit-Control AVPs(456)
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <wsutil/strtoi.h>
#include <wsutil/cmdarg_err.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/epan_dissect.h>
#include <epan/stat_tap_ui.h>
#include <epan/value_string.h>
#include <epan/to_str.h>
#include <epan/dissectors/packet-diameter.h>
void register_tap_listener_diameteravp(void);
/* used to keep track of the statistics for an entire program interface */
typedef struct _diameteravp_t {
guint32 frame;
guint32 diammsg_toprocess;
guint32 cmd_code;
guint32 req_count;
guint32 ans_count;
guint32 paired_ans_count;
gchar *filter;
} diameteravp_t;
/* Copied from proto.c */
static gboolean
tree_traverse_pre_order(proto_tree *tree, proto_tree_traverse_func func, gpointer data)
{
proto_node *pnode = tree;
proto_node *child;
proto_node *current;
if (func(pnode, data))
return TRUE;
child = pnode->first_child;
while (child != NULL) {
current = child;
child = current->next;
if (tree_traverse_pre_order((proto_tree *)current, func, data))
return TRUE;
}
return FALSE;
}
static gboolean
diam_tree_to_csv(proto_node *node, gpointer data)
{
char *val_str = NULL;
char *val_tmp = NULL;
ftenum_t ftype;
field_info *fi;
header_field_info *hfi;
if (!node) {
fprintf(stderr, "traverse end: empty node. node='%p' data='%p'\n", (void *)node, (void *)data);
return FALSE;
}
fi = node->finfo;
hfi = fi ? fi->hfinfo : NULL;
if (!hfi) {
fprintf(stderr, "traverse end: hfi not found. node='%p'\n", (void *)node);
return FALSE;
}
ftype = fvalue_type_ftenum(fi->value);
if (ftype != FT_NONE && ftype != FT_PROTOCOL) {
/* convert value to string */
val_tmp = fvalue_to_string_repr(NULL, fi->value, FTREPR_DISPLAY, hfi->display);
if (val_tmp)
{
val_str = g_strdup(val_tmp);
wmem_free(NULL, val_tmp);
} else
val_str = ws_strdup_printf("unsupported type: %s", ftype_name(ftype));
/*printf("traverse: name='%s', abbrev='%s',desc='%s', val='%s'\n", hfi->name, hfi->abbrev, ftype_name(hfi->type), val_str);*/
printf("%s='%s' ", hfi->name, val_str);
g_free(val_str);
}
return FALSE;
}
static tap_packet_status
diameteravp_packet(void *pds, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pdi, tap_flags_t flags _U_)
{
tap_packet_status ret = TAP_PACKET_DONT_REDRAW;
double resp_time = 0.;
gboolean is_request = TRUE;
guint32 cmd_code = 0;
guint32 req_frame = 0;
guint32 ans_frame = 0;
guint32 diam_child_node = 0;
proto_node *current = NULL;
proto_node *node = NULL;
header_field_info *hfi = NULL;
field_info *finfo = NULL;
const diameter_req_ans_pair_t *dp = (const diameter_req_ans_pair_t *)pdi;
diameteravp_t *ds = NULL;
/* Validate paramerers. */
if (!dp || !edt || !edt->tree)
return ret;
/* Several diameter messages within one frame are possible. *
* Check if we processing the message in same frame like befor or in new frame.*/
ds = (diameteravp_t *)pds;
if (pinfo->num > ds->frame) {
ds->frame = pinfo->num;
ds->diammsg_toprocess = 0;
} else {
ds->diammsg_toprocess += 1;
}
/* Extract data from request/answer pair provided by diameter dissector.*/
is_request = dp->processing_request;
cmd_code = dp->cmd_code;
req_frame = dp->req_frame;
ans_frame = dp->ans_frame;
if (!is_request) {
nstime_t ns;
nstime_delta(&ns, &pinfo->abs_ts, &dp->req_time);
resp_time = nstime_to_sec(&ns);
resp_time = resp_time < 0. ? 0. : resp_time;
}
/* Check command code provided by command line option.*/
if (ds->cmd_code && ds->cmd_code != cmd_code)
return ret;
/* Loop over top level nodes */
node = edt->tree->first_child;
while (node != NULL) {
current = node;
node = current->next;
finfo = current->finfo;
hfi = finfo ? finfo->hfinfo : NULL;
/*fprintf(stderr, "DEBUG: diameteravp_packet %d %p %p node=%p abbrev=%s\n", cmd_code, edt, edt->tree, current, hfi->abbrev);*/
/* process current diameter subtree in the current frame. */
if (hfi && hfi->abbrev && strcmp(hfi->abbrev, "diameter") == 0) {
/* Process current diameter message in the frame */
if (ds->diammsg_toprocess == diam_child_node) {
if (is_request) {
ds->req_count++;
} else {
ds->ans_count++;
if (req_frame > 0)
ds->paired_ans_count++;
}
/* Output frame data.*/
printf("frame='%u' time='%f' src='%s' srcport='%u' dst='%s' dstport='%u' proto='diameter' msgnr='%u' is_request='%d' cmd='%u' req_frame='%u' ans_frame='%u' resp_time='%f' ",
pinfo->num, nstime_to_sec(&pinfo->abs_ts), address_to_str(pinfo->pool, &pinfo->src), pinfo->srcport, address_to_str(pinfo->pool, &pinfo->dst), pinfo->destport, ds->diammsg_toprocess, is_request, cmd_code, req_frame, ans_frame, resp_time);
/* Visit selected nodes of one diameter message.*/
tree_traverse_pre_order(current, diam_tree_to_csv, &ds);
/* End of message.*/
printf("\n");
/*printf("hfi: name='%s', msg_curr='%d' abbrev='%s',type='%s'\n", hfi->name, diam_child_node, hfi->abbrev, ftype_name(hfi->type));*/
}
diam_child_node++;
}
}
return ret;
}
static void
diameteravp_draw(void *pds)
{
diameteravp_t *ds = (diameteravp_t *)pds;
/* printing results */
printf("=== Diameter Summary ===\nrequest count:\t%u\nanswer count:\t%u\nreq/ans pairs:\t%u\n", ds->req_count, ds->ans_count, ds->paired_ans_count);
}
static void
diameteravp_init(const char *opt_arg, void *userdata _U_)
{
diameteravp_t *ds;
gchar *field = NULL;
gchar **tokens;
guint opt_count = 0;
guint opt_idx = 0;
GString *filter = NULL;
GString *error_string = NULL;
ds = g_new(diameteravp_t, 1);
ds->frame = 0;
ds->diammsg_toprocess = 0;
ds->cmd_code = 0;
ds->req_count = 0;
ds->ans_count = 0;
ds->paired_ans_count = 0;
ds->filter = NULL;
filter = g_string_new("diameter");
/* Split command line options. */
tokens = g_strsplit(opt_arg, ",", 1024);
opt_count = 0;
while (tokens[opt_count])
opt_count++;
if (opt_count > 2) {
/* if the token is a not-null string and it's not *, the conversion must succeeed */
if (strlen(tokens[2]) > 0 && tokens[2][0] != '*') {
if (!ws_strtou32(tokens[2], NULL, &ds->cmd_code)) {
fprintf(stderr, "Invalid integer token: %s\n", tokens[2]);
g_strfreev(tokens);
exit(1);
}
}
}
/* Loop over diameter field names. */
for (opt_idx=3; opt_idx<opt_count; opt_idx++)
{
/* Current field from command line arguments. */
field = tokens[opt_idx];
/* Connect all requested fields with logical OR. */
g_string_append(filter, "||");
/* Prefix field name with "diameter." by default. */
if (!strchr(field, '.'))
g_string_append(filter, "diameter.");
/* Append field name to the filter. */
g_string_append(filter, field);
}
g_strfreev(tokens);
ds->filter = g_string_free(filter, FALSE);
error_string = register_tap_listener("diameter", ds, ds->filter, 0, NULL, diameteravp_packet, diameteravp_draw, NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(ds);
cmdarg_err("Couldn't register diam,csv tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui diameteravp_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"diameter,avp",
diameteravp_init,
0,
NULL
};
void
register_tap_listener_diameteravp(void)
{
register_stat_tap_ui(&diameteravp_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-endpoints.c | /* tap-endpoints.c
* endpoints 2014 Michael Mann
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/conversation_table.h>
#include <wsutil/cmdarg_err.h>
#include <ui/cli/tshark-tap.h>
typedef struct _endpoints_t {
const char *type;
const char *filter;
conv_hash_t hash;
} endpoints_t;
static void
endpoints_draw(void *arg)
{
conv_hash_t *hash = (conv_hash_t*)arg;
endpoints_t *iu = (endpoints_t *)hash->user_data;
endpoint_item_t *endpoint;
guint64 last_frames, max_frames;
guint i;
gboolean display_port = (!strncmp(iu->type, "TCP", 3) || !strncmp(iu->type, "UDP", 3) || !strncmp(iu->type, "SCTP", 4)) ? TRUE : FALSE;
printf("================================================================================\n");
printf("%s Endpoints\n", iu->type);
printf("Filter:%s\n", iu->filter ? iu->filter : "<No Filter>");
printf(" | %sPackets | | Bytes | | Tx Packets | | Tx Bytes | | Rx Packets | | Rx Bytes |\n",
display_port ? "Port || " : "");
max_frames = UINT_MAX;
do {
last_frames = 0;
for (i=0; (iu->hash.conv_array && i < iu->hash.conv_array->len); i++) {
guint64 tot_frames;
endpoint = &g_array_index(iu->hash.conv_array, endpoint_item_t, i);
tot_frames = endpoint->rx_frames + endpoint->tx_frames;
if ((tot_frames > last_frames) && (tot_frames < max_frames)) {
last_frames = tot_frames;
}
}
for (i=0; (iu->hash.conv_array && i < iu->hash.conv_array->len); i++) {
guint64 tot_frames;
gchar *conversation_str, *port_str;
endpoint = &g_array_index(iu->hash.conv_array, endpoint_item_t, i);
tot_frames = endpoint->rx_frames + endpoint->tx_frames;
if (tot_frames == last_frames) {
/* XXX - TODO: make name resolution configurable (through gbl_resolv_flags?) */
conversation_str = get_conversation_address(NULL, &endpoint->myaddress, TRUE);
if (display_port) {
/* XXX - TODO: make port resolution configurable (through gbl_resolv_flags?) */
port_str = get_endpoint_port(NULL, endpoint, TRUE);
printf("%-20s %5s %6" PRIu64 " %9" PRIu64
" %6" PRIu64 " %9" PRIu64 " %6"
PRIu64 " %9" PRIu64 " \n",
conversation_str,
port_str,
endpoint->tx_frames+endpoint->rx_frames, endpoint->tx_bytes+endpoint->rx_bytes,
endpoint->tx_frames, endpoint->tx_bytes,
endpoint->rx_frames, endpoint->rx_bytes);
wmem_free(NULL, port_str);
} else {
printf("%-20s %6" PRIu64 " %9" PRIu64
" %6" PRIu64 " %9" PRIu64 " %6"
PRIu64 " %9" PRIu64 " \n",
/* XXX - TODO: make name resolution configurable (through gbl_resolv_flags?) */
conversation_str,
endpoint->tx_frames+endpoint->rx_frames, endpoint->tx_bytes+endpoint->rx_bytes,
endpoint->tx_frames, endpoint->tx_bytes,
endpoint->rx_frames, endpoint->rx_bytes);
}
wmem_free(NULL, conversation_str);
}
}
max_frames = last_frames;
} while (last_frames);
printf("================================================================================\n");
}
void init_endpoints(struct register_ct *ct, const char *filter)
{
endpoints_t *iu;
GString *error_string;
iu = g_new0(endpoints_t, 1);
iu->type = proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(ct)));
iu->filter = g_strdup(filter);
iu->hash.user_data = iu;
error_string = register_tap_listener(proto_get_protocol_filter_name(get_conversation_proto_id(ct)), &iu->hash, filter, 0, NULL, get_endpoint_packet_func(ct), endpoints_draw, NULL);
if (error_string) {
g_free(iu);
cmdarg_err("Couldn't register endpoint tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-expert.c | /* tap-expert.c
* Copyright 2011 Martin Mathieson
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/expert.h>
#include <wsutil/ws_assert.h>
void register_tap_listener_expert_info(void);
/* Tap data */
typedef enum severity_level_t {
comment_level = 0,
chat_level,
note_level,
warn_level,
error_level,
max_level
} severity_level_t;
/* This variable stores the lowest level that will be displayed.
May be changed from the command line */
static severity_level_t lowest_report_level = comment_level;
typedef struct expert_entry
{
guint32 group;
int frequency;
const gchar *protocol;
gchar *summary;
} expert_entry;
/* Overall struct for storing all data seen */
typedef struct expert_tapdata_t {
GArray *ei_array[max_level]; /* expert info items */
GStringChunk *text; /* for efficient storage of summary strings */
} expert_tapdata_t;
/* Reset expert stats */
static void
expert_stat_reset(void *tapdata)
{
gint n;
expert_tapdata_t *etd = (expert_tapdata_t *)tapdata;
/* Free & reallocate chunk of strings */
g_string_chunk_free(etd->text);
etd->text = g_string_chunk_new(100);
/* Empty each of the arrays */
for (n=0; n < max_level; n++) {
g_array_set_size(etd->ei_array[n], 0);
}
}
/* Process stat struct for an expert frame */
static tap_packet_status
expert_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_,
const void *pointer, tap_flags_t flags _U_)
{
const expert_info_t *ei = (const expert_info_t *)pointer;
expert_tapdata_t *data = (expert_tapdata_t *)tapdata;
severity_level_t severity_level;
expert_entry tmp_entry;
expert_entry *entry;
guint n;
switch (ei->severity) {
case PI_COMMENT:
severity_level = comment_level;
break;
case PI_CHAT:
severity_level = chat_level;
break;
case PI_NOTE:
severity_level = note_level;
break;
case PI_WARN:
severity_level = warn_level;
break;
case PI_ERROR:
severity_level = error_level;
break;
default:
ws_assert_not_reached();
return TAP_PACKET_DONT_REDRAW;
}
/* Don't store details at a lesser severity than we are interested in */
if (severity_level < lowest_report_level) {
return TAP_PACKET_REDRAW; /* XXX - TAP_PACKET_DONT_REDRAW? */
}
/* If a duplicate just bump up frequency.
TODO: could make more efficient by avoiding linear search...*/
for (n=0; n < data->ei_array[severity_level]->len; n++) {
entry = &g_array_index(data->ei_array[severity_level], expert_entry, n);
if ((strcmp(ei->protocol, entry->protocol) == 0) &&
(strcmp(ei->summary, entry->summary) == 0)) {
entry->frequency++;
return TAP_PACKET_REDRAW;
}
}
/* Else Add new item to end of list for severity level */
entry = &tmp_entry;
/* Copy/Store protocol and summary strings efficiently using GStringChunk */
entry->protocol = g_string_chunk_insert_const(data->text, ei->protocol);
entry->summary = g_string_chunk_insert_const(data->text, ei->summary);
entry->group = ei->group;
entry->frequency = 1;
/* Store a copy of the expert entry */
g_array_append_val(data->ei_array[severity_level], tmp_entry);
return TAP_PACKET_REDRAW;
}
/* Output for all of the items of one severity */
static void draw_items_for_severity(GArray *items, const gchar *label)
{
guint n;
expert_entry *ei;
int total = 0;
gchar *tmp_str;
/* Don't print title if no items */
if (items->len == 0) {
return;
}
/* Add frequencies together to get total */
for (n=0; n < items->len; n++) {
ei = &g_array_index(items, expert_entry, n);
total += ei->frequency;
}
/* Title */
printf("\n%s (%d)\n", label, total);
printf("=============\n");
/* Column headings */
printf(" Frequency Group Protocol Summary\n");
/* Items */
for (n=0; n < items->len; n++) {
ei = &g_array_index(items, expert_entry, n);
tmp_str = val_to_str_wmem(NULL, ei->group, expert_group_vals, "Unknown (%d)");
printf("%12d %10s %18s %s\n",
ei->frequency,
tmp_str,
ei->protocol, ei->summary);
wmem_free(NULL, tmp_str);
}
}
/* (Re)draw expert stats */
static void
expert_stat_draw(void *phs _U_)
{
/* Look up the statistics struct */
expert_tapdata_t *hs = (expert_tapdata_t *)phs;
draw_items_for_severity(hs->ei_array[error_level], "Errors");
draw_items_for_severity(hs->ei_array[warn_level], "Warns");
draw_items_for_severity(hs->ei_array[note_level], "Notes");
draw_items_for_severity(hs->ei_array[chat_level], "Chats");
draw_items_for_severity(hs->ei_array[comment_level], "Comments");
}
static void
expert_tapdata_free(expert_tapdata_t* hs)
{
for (int n = 0; n < max_level; n++) {
g_array_free(hs->ei_array[n], TRUE);
}
g_string_chunk_free(hs->text);
g_free(hs);
}
/* Create a new expert stats struct */
static void expert_stat_init(const char *opt_arg, void *userdata _U_)
{
const char *args = NULL;
const char *filter = NULL;
GString *error_string;
expert_tapdata_t *hs;
int n;
/* Check for args. */
if (strncmp(opt_arg, "expert", 6) == 0) {
/* Skip those characters */
args = opt_arg + 6;
}
else {
/* No args. Will show all reports, with no filter */
lowest_report_level = max_level;
}
/* First (optional) arg is Error|Warn|Note|Chat */
if (args != NULL) {
if (g_ascii_strncasecmp(args, ",error", 6) == 0) {
lowest_report_level = error_level;
args += 6;
}
else if (g_ascii_strncasecmp(args, ",warn", 5) == 0) {
lowest_report_level = warn_level;
args += 5;
} else if (g_ascii_strncasecmp(args, ",note", 5) == 0) {
lowest_report_level = note_level;
args += 5;
} else if (g_ascii_strncasecmp(args, ",chat", 5) == 0) {
lowest_report_level = chat_level;
args += 5;
} else if (g_ascii_strncasecmp(args, ",comment", 8) == 0) {
lowest_report_level = comment_level;
args += 8;
}
}
/* Second (optional) arg is a filter string */
if (args != NULL) {
if (args[0] == ',') {
filter = args+1;
}
}
/* Create top-level struct */
hs = g_new0(expert_tapdata_t, 1);
/* Allocate chunk of strings */
hs->text = g_string_chunk_new(100);
/* Allocate GArray for each severity level */
for (n=0; n < max_level; n++) {
hs->ei_array[n] = g_array_sized_new(FALSE, FALSE, sizeof(expert_entry), 1000);
}
/**********************************************/
/* Register the tap listener */
/**********************************************/
error_string = register_tap_listener("expert", hs,
filter, 0,
expert_stat_reset,
expert_stat_packet,
expert_stat_draw,
(tap_finish_cb)expert_tapdata_free);
if (error_string) {
printf("Expert tap error (%s)!\n", error_string->str);
g_string_free(error_string, TRUE);
expert_tapdata_free(hs);
exit(1);
}
}
static stat_tap_ui expert_stat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"expert",
expert_stat_init,
0,
NULL
};
/* Register this tap listener (need void on own so line register function found) */
void
register_tap_listener_expert_info(void)
{
register_stat_tap_ui(&expert_stat_ui, NULL);
} |
C | wireshark/ui/cli/tap-exportobject.c | /* tap-exportobject.c
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <glib.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wsutil/file_util.h>
#include <wsutil/filesystem.h>
#include <wsutil/cmdarg_err.h>
#include <epan/packet_info.h>
#include <epan/packet.h>
#include <epan/export_object.h>
#include "tap-exportobject.h"
typedef struct _export_object_list_gui_t {
GSList *entries;
register_eo_t* eo;
} export_object_list_gui_t;
static GHashTable* eo_opts = NULL;
static bool
list_exportobject_protocol(const void *key, void *value _U_, void *userdata _U_)
{
fprintf(stderr, " %s\n", (const gchar*)key);
return FALSE;
}
void eo_list_object_types(void)
{
eo_iterate_tables(list_exportobject_protocol, NULL);
}
gboolean eo_tap_opt_add(const char *option_string)
{
gchar** splitted;
if (!eo_opts)
eo_opts = g_hash_table_new(g_str_hash,g_str_equal);
splitted = g_strsplit(option_string, ",", 2);
if ((splitted[0] == NULL) || (splitted[1] == NULL) || (get_eo_by_name(splitted[0]) == NULL))
{
fprintf(stderr, "tshark: \"--export-objects\" are specified as: <protocol>,<destdir>\n");
fprintf(stderr, "tshark: The available export object types for the \"--export-objects\" option are:\n");
eo_list_object_types();
}
else
{
gchar* dir = (gchar*)g_hash_table_lookup(eo_opts, splitted[0]);
/* Since we're saving all objects from a protocol,
it can only be listed once */
if (dir == NULL) {
g_hash_table_insert(eo_opts, splitted[0], splitted[1]);
g_free(splitted);
return TRUE;
}
else
{
cmdarg_err("\"--export-objects\" already specified protocol '%s'", splitted[0]);
}
}
g_strfreev(splitted);
return FALSE;
}
static void
object_list_add_entry(void *gui_data, export_object_entry_t *entry)
{
export_object_list_gui_t *object_list = (export_object_list_gui_t*)gui_data;
object_list->entries = g_slist_append(object_list->entries, entry);
}
static export_object_entry_t*
object_list_get_entry(void *gui_data, int row) {
export_object_list_gui_t *object_list = (export_object_list_gui_t*)gui_data;
return (export_object_entry_t *)g_slist_nth_data(object_list->entries, row);
}
/* This is just for writing Exported Objects to a file */
static void
eo_draw(void *tapdata)
{
export_object_list_t *tap_object = (export_object_list_t *)tapdata;
export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data;
GSList *slist = object_list->entries;
export_object_entry_t *entry;
gchar* save_in_path = (gchar*)g_hash_table_lookup(eo_opts, proto_get_protocol_filter_name(get_eo_proto_id(object_list->eo)));
GString *safe_filename = NULL;
gchar *save_as_fullpath = NULL;
guint count = 0;
if (!g_file_test(save_in_path, G_FILE_TEST_IS_DIR)) {
/* If the destination directory (or its parents) do not exist, create them. */
if (g_mkdir_with_parents(save_in_path, 0755) == -1) {
fprintf(stderr, "Failed to create export objects output directory \"%s\": %s\n",
save_in_path, g_strerror(errno));
return;
}
}
while (slist) {
entry = (export_object_entry_t *)slist->data;
do {
g_free(save_as_fullpath);
if (entry->filename) {
safe_filename = eo_massage_str(entry->filename,
EXPORT_OBJECT_MAXFILELEN, count);
} else {
char generic_name[EXPORT_OBJECT_MAXFILELEN+1];
const char *ext;
ext = eo_ct2ext(entry->content_type);
snprintf(generic_name, sizeof(generic_name),
"object%u%s%s", entry->pkt_num, ext ? "." : "", ext ? ext : "");
safe_filename = eo_massage_str(generic_name,
EXPORT_OBJECT_MAXFILELEN, count);
}
save_as_fullpath = g_build_filename(save_in_path, safe_filename->str, NULL);
g_string_free(safe_filename, TRUE);
} while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < prefs.gui_max_export_objects);
count = 0;
write_file_binary_mode(save_as_fullpath, entry->payload_data, entry->payload_len);
g_free(save_as_fullpath);
save_as_fullpath = NULL;
slist = slist->next;
}
}
static void
exportobject_handler(gpointer key, gpointer value _U_, gpointer user_data _U_)
{
GString *error_msg;
export_object_list_t *tap_data;
export_object_list_gui_t *object_list;
register_eo_t* eo;
eo = get_eo_by_name((const char*)key);
if (eo == NULL)
{
cmdarg_err("\"--export-objects\" INTERNAL ERROR '%s' protocol not found", (const char*)key);
return;
}
tap_data = g_new0(export_object_list_t,1);
object_list = g_new0(export_object_list_gui_t,1);
tap_data->add_entry = object_list_add_entry;
tap_data->get_entry = object_list_get_entry;
tap_data->gui_data = (void*)object_list;
object_list->eo = eo;
/* Data will be gathered via a tap callback */
error_msg = register_tap_listener(get_eo_tap_listener_name(eo), tap_data, NULL, 0,
NULL, get_eo_packet_func(eo), eo_draw, NULL);
if (error_msg) {
cmdarg_err("Can't register %s tap: %s", (const char*)key, error_msg->str);
g_string_free(error_msg, TRUE);
g_free(tap_data);
g_free(object_list);
return;
}
}
void start_exportobjects(void)
{
if (eo_opts != NULL)
g_hash_table_foreach(eo_opts, exportobject_handler, NULL);
} |
C/C++ | wireshark/ui/cli/tap-exportobject.h | /** @file
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_EXPORT_OBJECT_H__
#define __TAP_EXPORT_OBJECT_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void eo_list_object_types(void);
/* will be called by main each time a --export-objects option is found */
gboolean eo_tap_opt_add(const char *ws_optarg);
void start_exportobjects(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_EXPORT_OBJECT_H__ */
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-flow.c | /* tap-flow.c
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides udp and tcp follow stream capabilities to tshark.
* It is only used by tshark and not wireshark.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <epan/sequence_analysis.h>
#include <epan/stat_tap_ui.h>
#include <epan/tap.h>
void register_tap_listener_flow(void);
#define STR_FLOW "flow,"
#define STR_STANDARD ",standard"
#define STR_NETWORK ",network"
WS_NORETURN static void flow_exit(const char *strp)
{
fprintf(stderr, "tshark: flow - %s\n", strp);
exit(1);
}
static void
flow_draw(void *arg)
{
seq_analysis_info_t* flow_info = (seq_analysis_info_t*)arg;
sequence_analysis_get_nodes(flow_info);
sequence_analysis_dump_to_file(stdout, flow_info, 0);
//clean up the data
sequence_analysis_list_free(flow_info);
sequence_analysis_info_free(flow_info);
}
static gboolean flow_arg_strncmp(const char **opt_argp, const char *strp)
{
size_t len = strlen(strp);
if (strncmp(*opt_argp, strp, len) == 0)
{
*opt_argp += len;
return TRUE;
}
return FALSE;
}
static void
flow_arg_mode(const char **opt_argp, seq_analysis_info_t *flow_info)
{
if (flow_arg_strncmp(opt_argp, STR_STANDARD))
{
flow_info->any_addr = 1;
}
else if (flow_arg_strncmp(opt_argp, STR_NETWORK))
{
flow_info->any_addr = 0;
}
else
{
flow_exit("Invalid address type.");
}
}
static void
flow_init(const char *opt_argp, void *userdata)
{
seq_analysis_info_t *flow_info = g_new0(seq_analysis_info_t, 1);
GString *errp;
register_analysis_t* analysis = (register_analysis_t*)userdata;
const char *filter=NULL;
opt_argp += strlen(STR_FLOW);
opt_argp += strlen(sequence_analysis_get_name(analysis));
flow_arg_mode(&opt_argp, flow_info);
if (*opt_argp == ',') {
filter = opt_argp + 1;
}
sequence_analysis_list_free(flow_info);
errp = register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), flow_info, filter, sequence_analysis_get_tap_flags(analysis),
NULL, sequence_analysis_get_packet_func(analysis), flow_draw, NULL);
if (errp != NULL)
{
sequence_analysis_list_free(flow_info);
sequence_analysis_info_free(flow_info);
g_string_free(errp, TRUE);
flow_exit("Error registering tap listener.");
}
}
static bool
flow_register(const void *key _U_, void *value, void *userdata _U_)
{
register_analysis_t* analysis = (register_analysis_t*)value;
stat_tap_ui flow_ui;
GString *cmd_str = g_string_new(STR_FLOW);
gchar *cli_string;
g_string_append(cmd_str, sequence_analysis_get_name(analysis));
cli_string = g_string_free(cmd_str, FALSE);
flow_ui.group = REGISTER_STAT_GROUP_GENERIC;
flow_ui.title = NULL; /* construct this from the protocol info? */
flow_ui.cli_string = cli_string;
flow_ui.tap_init_cb = flow_init;
flow_ui.nparams = 0;
flow_ui.params = NULL;
register_stat_tap_ui(&flow_ui, analysis);
g_free(cli_string);
return FALSE;
}
void
register_tap_listener_flow(void)
{
sequence_analysis_table_iterate_tables(flow_register, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* 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:
*/ |
C | wireshark/ui/cli/tap-follow.c | /* tap-follow.c
*
* Copyright 2011-2013, QA Cafe <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides udp and tcp follow stream capabilities to tshark.
* It is only used by tshark and not wireshark.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <epan/addr_resolv.h>
#include <wsutil/str_util.h>
#include <epan/follow.h>
#include <epan/stat_tap_ui.h>
#include <epan/tap.h>
#include <wsutil/ws_assert.h>
void register_tap_listener_follow(void);
/* Show Type */
typedef enum {
SHOW_ASCII,
SHOW_CARRAY,
SHOW_EBCDIC,
SHOW_HEXDUMP,
SHOW_RAW,
SHOW_CODEC, // Ordered to match UTF-8 combobox index
SHOW_YAML
} show_type_t;
typedef struct _cli_follow_info {
show_type_t show_type;
register_follow_t* follower;
/* range */
guint32 chunkMin;
guint32 chunkMax;
/* filter */
int stream_index;
int sub_stream_index;
int port[2];
address addr[2];
union {
guint32 addrBuf_v4;
ws_in6_addr addrBuf_v6;
} addrBuf[2];
} cli_follow_info_t;
#define STR_FOLLOW "follow,"
#define STR_HEX ",hex"
#define STR_ASCII ",ascii"
#define STR_EBCDIC ",ebcdic"
#define STR_RAW ",raw"
#define STR_YAML ",yaml"
WS_NORETURN static void follow_exit(const char *strp)
{
fprintf(stderr, "tshark: follow - %s\n", strp);
exit(1);
}
static const char * follow_str_type(cli_follow_info_t* cli_follow_info)
{
switch (cli_follow_info->show_type)
{
case SHOW_HEXDUMP: return "hex";
case SHOW_ASCII: return "ascii";
case SHOW_EBCDIC: return "ebcdic";
case SHOW_RAW: return "raw";
case SHOW_YAML: return "yaml";
default:
ws_assert_not_reached();
break;
}
ws_assert_not_reached();
return "<unknown-mode>";
}
static void
follow_free(follow_info_t *follow_info)
{
cli_follow_info_t* cli_follow_info = (cli_follow_info_t*)follow_info->gui_data;
g_free(cli_follow_info);
follow_info_free(follow_info);
}
#define BYTES_PER_LINE 16
#define OFFSET_LEN 8
#define OFFSET_SPACE 2
#define HEX_START (OFFSET_LEN + OFFSET_SPACE)
#define HEX_LEN (BYTES_PER_LINE * 3) /* extra space at column 8 */
#define HEX_SPACE 2
#define ASCII_START (HEX_START + HEX_LEN + HEX_SPACE)
#define ASCII_LEN (BYTES_PER_LINE + 1) /* extra space at column 8 */
#define LINE_LEN (ASCII_START + ASCII_LEN)
static const char bin2hex[] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
static void follow_print_hex(const char *prefixp, guint32 offset, void *datap, int len)
{
int ii;
int jj;
int kk;
guint8 val;
char line[LINE_LEN + 1];
for (ii = 0, jj = 0, kk = 0; ii < len; )
{
if ((ii % BYTES_PER_LINE) == 0)
{
/* new line */
snprintf(line, LINE_LEN + 1, "%0*X", OFFSET_LEN, offset);
memset(line + HEX_START - OFFSET_SPACE, ' ',
HEX_LEN + OFFSET_SPACE + HEX_SPACE);
/* offset of hex */
jj = HEX_START;
/* offset of ascii */
kk = ASCII_START;
}
val = ((guint8 *)datap)[ii];
line[jj++] = bin2hex[val >> 4];
line[jj++] = bin2hex[val & 0xf];
jj++;
line[kk++] = val >= ' ' && val < 0x7f ? val : '.';
/* extra space at column 8 */
if (++ii % BYTES_PER_LINE == BYTES_PER_LINE/2)
{
line[jj++] = ' ';
line[kk++] = ' ';
}
if ((ii % BYTES_PER_LINE) == 0 || ii == len)
{
/* end of line or buffer */
if (line[kk - 1] == ' ')
{
kk--;
}
line[kk] = 0;
printf("%s%s\n", prefixp, line);
offset += BYTES_PER_LINE;
}
}
}
static void follow_draw(void *contextp)
{
static const char separator[] =
"===================================================================\n";
follow_info_t *follow_info = (follow_info_t*)contextp;
cli_follow_info_t* cli_follow_info = (cli_follow_info_t*)follow_info->gui_data;
gchar buf[WS_INET6_ADDRSTRLEN];
guint32 global_client_pos = 0, global_server_pos = 0;
guint32 *global_pos;
guint32 ii, jj;
char *buffer;
GList *cur;
follow_record_t *follow_record;
guint chunk;
gchar *b64encoded;
const guint32 base64_raw_len = 57; /* Encodes to 76 bytes, common in RFCs */
/* Print header */
switch (cli_follow_info->show_type)
{
case SHOW_YAML:
printf("peers:\n");
printf(" - peer: 0\n");
address_to_str_buf(&follow_info->client_ip, buf, sizeof buf);
printf(" host: %s\n", buf);
printf(" port: %d\n", follow_info->client_port);
printf(" - peer: 1\n");
address_to_str_buf(&follow_info->server_ip, buf, sizeof buf);
printf(" host: %s\n", buf);
printf(" port: %d\n", follow_info->server_port);
printf("packets:\n");
break;
default:
printf("\n%s", separator);
printf("Follow: %s,%s\n", proto_get_protocol_filter_name(get_follow_proto_id(cli_follow_info->follower)), follow_str_type(cli_follow_info));
printf("Filter: %s\n", follow_info->filter_out_filter);
address_to_str_buf(&follow_info->client_ip, buf, sizeof buf);
if (follow_info->client_ip.type == AT_IPv6)
printf("Node 0: [%s]:%u\n", buf, follow_info->client_port);
else
printf("Node 0: %s:%u\n", buf, follow_info->client_port);
address_to_str_buf(&follow_info->server_ip, buf, sizeof buf);
if (follow_info->server_ip.type == AT_IPv6)
printf("Node 1: [%s]:%u\n", buf, follow_info->server_port);
else
printf("Node 1: %s:%u\n", buf, follow_info->server_port);
break;
}
for (cur = g_list_last(follow_info->payload), chunk = 1;
cur != NULL;
cur = g_list_previous(cur), chunk++)
{
follow_record = (follow_record_t *)cur->data;
if (!follow_record->is_server) {
global_pos = &global_client_pos;
} else {
global_pos = &global_server_pos;
}
/* ignore chunks not in range */
if ((chunk < cli_follow_info->chunkMin) || (chunk > cli_follow_info->chunkMax)) {
(*global_pos) += follow_record->data->len;
continue;
}
/* Print start of line */
switch (cli_follow_info->show_type)
{
case SHOW_HEXDUMP:
case SHOW_YAML:
break;
case SHOW_ASCII:
case SHOW_EBCDIC:
printf("%s%u\n", follow_record->is_server ? "\t" : "", follow_record->data->len);
break;
case SHOW_RAW:
if (follow_record->is_server)
{
putchar('\t');
}
break;
default:
ws_assert_not_reached();
}
/* Print data */
switch (cli_follow_info->show_type)
{
case SHOW_HEXDUMP:
follow_print_hex(follow_record->is_server ? "\t" : "", *global_pos, follow_record->data->data, follow_record->data->len);
(*global_pos) += follow_record->data->len;
break;
case SHOW_ASCII:
case SHOW_EBCDIC:
buffer = (char *)g_malloc(follow_record->data->len+2);
for (ii = 0; ii < follow_record->data->len; ii++)
{
switch (follow_record->data->data[ii])
{
case '\r':
case '\n':
buffer[ii] = follow_record->data->data[ii];
break;
default:
buffer[ii] = g_ascii_isprint(follow_record->data->data[ii]) ? follow_record->data->data[ii] : '.';
break;
}
}
buffer[ii++] = '\n';
buffer[ii] = 0;
if (cli_follow_info->show_type == SHOW_EBCDIC) {
EBCDIC_to_ASCII(buffer, ii);
}
printf("%s", buffer);
g_free(buffer);
break;
case SHOW_RAW:
buffer = (char *)g_malloc((follow_record->data->len*2)+2);
for (ii = 0, jj = 0; ii < follow_record->data->len; ii++)
{
buffer[jj++] = bin2hex[follow_record->data->data[ii] >> 4];
buffer[jj++] = bin2hex[follow_record->data->data[ii] & 0xf];
}
buffer[jj++] = '\n';
buffer[jj] = 0;
printf("%s", buffer);
g_free(buffer);
break;
case SHOW_YAML:
printf(" - packet: %d\n", follow_record->packet_num);
printf(" peer: %d\n", follow_record->is_server ? 1 : 0);
printf(" timestamp: %.9f\n", nstime_to_sec(&follow_record->abs_ts));
printf(" data: !!binary |\n");
ii = 0;
while (ii < follow_record->data->len) {
guint32 len = ii + base64_raw_len < follow_record->data->len
? base64_raw_len
: follow_record->data->len - ii;
b64encoded = g_base64_encode(&follow_record->data->data[ii], len);
printf(" %s\n", b64encoded);
g_free(b64encoded);
ii += len;
}
break;
default:
ws_assert_not_reached();
}
}
/* Print footer */
switch (cli_follow_info->show_type)
{
case SHOW_YAML:
break;
default:
printf("%s", separator);
break;
}
}
static gboolean follow_arg_strncmp(const char **opt_argp, const char *strp)
{
size_t len = strlen(strp);
if (strncmp(*opt_argp, strp, len) == 0)
{
*opt_argp += len;
return TRUE;
}
return FALSE;
}
static void
follow_arg_mode(const char **opt_argp, follow_info_t *follow_info)
{
cli_follow_info_t* cli_follow_info = (cli_follow_info_t*)follow_info->gui_data;
if (follow_arg_strncmp(opt_argp, STR_HEX))
{
cli_follow_info->show_type = SHOW_HEXDUMP;
}
else if (follow_arg_strncmp(opt_argp, STR_ASCII))
{
cli_follow_info->show_type = SHOW_ASCII;
}
else if (follow_arg_strncmp(opt_argp, STR_EBCDIC))
{
cli_follow_info->show_type = SHOW_EBCDIC;
}
else if (follow_arg_strncmp(opt_argp, STR_RAW))
{
cli_follow_info->show_type = SHOW_RAW;
}
else if (follow_arg_strncmp(opt_argp, STR_YAML))
{
cli_follow_info->show_type = SHOW_YAML;
}
else
{
follow_exit("Invalid display mode.");
}
}
#define _STRING(s) # s
#define STRING(s) _STRING(s)
#define ADDR_CHARS 80
#define ADDR_LEN (ADDR_CHARS + 1)
#define ADDRv6_FMT ",[%" STRING(ADDR_CHARS) "[^]]]:%d%n"
#define ADDRv4_FMT ",%" STRING(ADDR_CHARS) "[^:]:%d%n"
static void
follow_arg_filter(const char **opt_argp, follow_info_t *follow_info)
{
int len;
unsigned int ii;
char addr[ADDR_LEN];
cli_follow_info_t* cli_follow_info = (cli_follow_info_t*)follow_info->gui_data;
gboolean is_ipv6;
if (sscanf(*opt_argp, ",%d%n", &cli_follow_info->stream_index, &len) == 1 &&
((*opt_argp)[len] == 0 || (*opt_argp)[len] == ','))
{
*opt_argp += len;
/* if it's HTTP2 or QUIC protocol we should read substream id otherwise it's a range parameter from follow_arg_range */
if (cli_follow_info->sub_stream_index == -1 && sscanf(*opt_argp, ",%d%n", &cli_follow_info->sub_stream_index, &len) == 1 &&
((*opt_argp)[len] == 0 || (*opt_argp)[len] == ','))
{
*opt_argp += len;
follow_info->substream_id = cli_follow_info->sub_stream_index;
}
}
else
{
for (ii = 0; ii < sizeof cli_follow_info->addr/sizeof *cli_follow_info->addr; ii++)
{
if (sscanf(*opt_argp, ADDRv6_FMT, addr, &cli_follow_info->port[ii], &len) == 2)
{
is_ipv6 = TRUE;
}
else if (sscanf(*opt_argp, ADDRv4_FMT, addr, &cli_follow_info->port[ii], &len) == 2)
{
is_ipv6 = FALSE;
}
else
{
follow_exit("Invalid address.");
}
if (cli_follow_info->port[ii] <= 0 || cli_follow_info->port[ii] > G_MAXUINT16)
{
follow_exit("Invalid port.");
}
if (is_ipv6)
{
if (!get_host_ipaddr6(addr, &cli_follow_info->addrBuf[ii].addrBuf_v6))
{
follow_exit("Can't get IPv6 address");
}
set_address(&cli_follow_info->addr[ii], AT_IPv6, 16, (void *)&cli_follow_info->addrBuf[ii].addrBuf_v6);
}
else
{
if (!get_host_ipaddr(addr, &cli_follow_info->addrBuf[ii].addrBuf_v4))
{
follow_exit("Can't get IPv4 address");
}
set_address(&cli_follow_info->addr[ii], AT_IPv4, 4, (void *)&cli_follow_info->addrBuf[ii].addrBuf_v4);
}
*opt_argp += len;
}
if (cli_follow_info->addr[0].type != cli_follow_info->addr[1].type)
{
follow_exit("Mismatched IP address types.");
}
cli_follow_info->stream_index = -1;
}
}
static void follow_arg_range(const char **opt_argp, cli_follow_info_t* cli_follow_info)
{
int len;
if (**opt_argp == 0)
{
cli_follow_info->chunkMin = 1;
cli_follow_info->chunkMax = G_MAXUINT32;
}
else
{
if (sscanf(*opt_argp, ",%u-%u%n", &cli_follow_info->chunkMin, &cli_follow_info->chunkMax, &len) == 2)
{
*opt_argp += len;
}
else if (sscanf(*opt_argp, ",%u%n", &cli_follow_info->chunkMin, &len) == 1)
{
cli_follow_info->chunkMax = cli_follow_info->chunkMin;
*opt_argp += len;
}
else
{
follow_exit("Invalid range.");
}
if (cli_follow_info->chunkMin < 1 || cli_follow_info->chunkMin > cli_follow_info->chunkMax)
{
follow_exit("Invalid range value.");
}
}
}
static void
follow_arg_done(const char *opt_argp)
{
if (*opt_argp != 0)
{
follow_exit("Invalid parameter.");
}
}
static void follow_stream(const char *opt_argp, void *userdata)
{
follow_info_t *follow_info;
cli_follow_info_t* cli_follow_info;
GString *errp;
register_follow_t* follower = (register_follow_t*)userdata;
follow_index_filter_func index_filter;
follow_address_filter_func address_filter;
int proto_id = get_follow_proto_id(follower);
const char* proto_filter_name = proto_get_protocol_filter_name(proto_id);
opt_argp += strlen(STR_FOLLOW);
opt_argp += strlen(proto_filter_name);
cli_follow_info = g_new0(cli_follow_info_t, 1);
cli_follow_info->stream_index = -1;
/* use second parameter only for followers that have sub streams
* (currently HTTP2 or QUIC) */
if (get_follow_sub_stream_id_func(follower)) {
cli_follow_info->sub_stream_index = -1;
} else {
cli_follow_info->sub_stream_index = 0;
}
follow_info = g_new0(follow_info_t, 1);
follow_info->gui_data = cli_follow_info;
follow_info->substream_id = SUBSTREAM_UNUSED;
cli_follow_info->follower = follower;
follow_arg_mode(&opt_argp, follow_info);
follow_arg_filter(&opt_argp, follow_info);
follow_arg_range(&opt_argp, cli_follow_info);
follow_arg_done(opt_argp);
if (cli_follow_info->stream_index >= 0)
{
index_filter = get_follow_index_func(follower);
follow_info->filter_out_filter = index_filter(cli_follow_info->stream_index, cli_follow_info->sub_stream_index);
if (follow_info->filter_out_filter == NULL || cli_follow_info->sub_stream_index < 0)
{
follow_exit("Error creating filter for this stream.");
}
}
else
{
address_filter = get_follow_address_func(follower);
follow_info->filter_out_filter = address_filter(&cli_follow_info->addr[0], &cli_follow_info->addr[1], cli_follow_info->port[0], cli_follow_info->port[1]);
if (follow_info->filter_out_filter == NULL)
{
follow_exit("Error creating filter for this address/port pair.\n");
}
}
errp = register_tap_listener(get_follow_tap_string(follower), follow_info, follow_info->filter_out_filter, 0,
NULL, get_follow_tap_handler(follower), follow_draw, (tap_finish_cb)follow_free);
if (errp != NULL)
{
follow_free(follow_info);
g_string_free(errp, TRUE);
follow_exit("Error registering tap listener.");
}
}
static bool
follow_register(const void *key _U_, void *value, void *userdata _U_)
{
register_follow_t *follower = (register_follow_t*)value;
stat_tap_ui follow_ui;
gchar *cli_string;
cli_string = follow_get_stat_tap_string(follower);
follow_ui.group = REGISTER_STAT_GROUP_GENERIC;
follow_ui.title = NULL; /* construct this from the protocol info? */
follow_ui.cli_string = cli_string;
follow_ui.tap_init_cb = follow_stream;
follow_ui.nparams = 0;
follow_ui.params = NULL;
register_stat_tap_ui(&follow_ui, follower);
g_free(cli_string);
return FALSE;
}
void
register_tap_listener_follow(void)
{
follow_iterate_followers(follow_register, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/ |
C | wireshark/ui/cli/tap-funnel.c | /*
* tap-funnel.c
*
* EPAN's GUI mini-API
*
* (c) 2006, Luis E. Garcia Ontanon <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/funnel.h>
#include <stdio.h>
#include "ws_attributes.h"
#include <wsutil/wslog.h>
void register_tap_listener_funnel(void);
struct _funnel_text_window_t {
gchar *title;
GString *text;
};
static GPtrArray *text_windows = NULL;
static funnel_text_window_t *new_text_window(funnel_ops_id_t *ops_id _U_, const gchar *title) {
funnel_text_window_t *tw = g_new(funnel_text_window_t, 1);
tw->title = g_strdup(title);
tw->text = g_string_new("");
if (!text_windows)
text_windows = g_ptr_array_new();
g_ptr_array_add(text_windows, tw);
return tw;
}
static void text_window_clear(funnel_text_window_t *tw) {
g_string_free(tw->text, TRUE);
tw->text = g_string_new("");
}
static void text_window_append(funnel_text_window_t *tw, const char *text ) {
g_string_append(tw->text, text);
}
static void text_window_set_text(funnel_text_window_t *tw, const char *text) {
g_string_free(tw->text, TRUE);
tw->text = g_string_new(text);
}
static void text_window_prepend(funnel_text_window_t *tw, const char *text) {
g_string_prepend(tw->text, text);
}
static const gchar *text_window_get_text(funnel_text_window_t *tw) {
return tw->text->str;
}
static const funnel_ops_t funnel_ops = {
NULL,
new_text_window,
text_window_set_text,
text_window_append,
text_window_prepend,
text_window_clear,
text_window_get_text,
NULL,
NULL,
NULL,
NULL,
/*...,*/
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
void initialize_funnel_ops(void) {
funnel_set_funnel_ops(&funnel_ops);
}
void funnel_dump_all_text_windows(void) {
guint i;
if (!text_windows) return;
for ( i = 0 ; i < text_windows->len; i++) {
funnel_text_window_t *tw = (funnel_text_window_t *)g_ptr_array_index(text_windows, i);
printf("\n========================== %s "
"==========================\n%s\n", tw->title, tw->text->str);
g_ptr_array_remove_index(text_windows, i);
g_free(tw->title);
g_string_free(tw->text, TRUE);
g_free(tw);
}
}
#if 0
GHashTable *menus = NULL;
typedef struct _menu_cb_t {
void (*callback)(gpointer);
void *callback_data;
} menu_cb_t;
static void init_funnel_cmd(const char *opt_arg, void *data ) {
gchar **args = g_strsplit(opt_arg, ",", 0);
gchar **arg;
menu_cb_t *mcb = data;
for (arg = args; *arg ; arg++) {
g_strstrip(*arg);
}
if (mcb->callback) {
mcb->callback(mcb->callback_data);
}
}
static void register_menu_cb(const char *name,
register_stat_group_t group _U_,
void (*callback)(gpointer),
gpointer callback_data,
gboolean retap _U_) {
menu_cb_t* mcb = g_new(menu_cb_t, 1);
stat_tap_ui ui_info;
mcb->callback = callback;
mcb->callback_data = callback_data;
if (!menus)
menus = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(menus, g_strdup(name), mcb);
ui_info.group = REGISTER_STAT_GROUP_GENERIC;
ui_info.title = NULL;
ui_info.cli_string = name;
ui_info.tap_init_cb = init_funnel_cmd;
ui_info.nparams = 0;
ui_info.params = NULL;
register_stat_tap_ui(&ui_info, mcb);
}
void initialize_funnel_ops(void) {
funnel_set_funnel_ops(&funnel_ops);
}
#endif
void
register_tap_listener_funnel(void)
{
#if 0
/* #if 0 at least since Revision Rev 17396 */
funnel_register_all_menus(register_menu_cb);
#endif
} |
C | wireshark/ui/cli/tap-gsm_astat.c | /* tap-gsm_astat.c
*
* Copyright 2003, Michael Lum <mlum [AT] telostech.com>
* In association with Telos Technology Inc.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* This TAP provides statistics for the GSM A Interface:
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/value_string.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-bssap.h>
#include <epan/dissectors/packet-gsm_a_common.h>
void register_tap_listener_gsm_astat(void);
typedef struct _gsm_a_stat_t {
int bssmap_message_type[0x100];
int dtap_mm_message_type[0x100];
int dtap_rr_message_type[0x100];
int dtap_cc_message_type[0x100];
int dtap_gmm_message_type[0x100];
int dtap_sms_message_type[0x100];
int dtap_sm_message_type[0x100];
int dtap_ss_message_type[0x100];
int dtap_tp_message_type[0x100];
int sacch_rr_message_type[0x100];
} gsm_a_stat_t;
static tap_packet_status
gsm_a_stat_packet(
void *tapdata,
packet_info *pinfo _U_,
epan_dissect_t *edt _U_,
const void *data,
tap_flags_t flags _U_)
{
gsm_a_stat_t *stat_p = (gsm_a_stat_t *)tapdata;
const gsm_a_tap_rec_t *tap_p = (const gsm_a_tap_rec_t *)data;
switch (tap_p->pdu_type)
{
case BSSAP_PDU_TYPE_BSSMAP:
stat_p->bssmap_message_type[tap_p->message_type]++;
break;
case BSSAP_PDU_TYPE_DTAP:
switch (tap_p->protocol_disc)
{
case PD_CC:
stat_p->dtap_cc_message_type[tap_p->message_type]++;
break;
case PD_MM:
stat_p->dtap_mm_message_type[tap_p->message_type]++;
break;
case PD_RR:
stat_p->dtap_rr_message_type[tap_p->message_type]++;
break;
case PD_GMM:
stat_p->dtap_gmm_message_type[tap_p->message_type]++;
break;
case PD_SMS:
stat_p->dtap_sms_message_type[tap_p->message_type]++;
break;
case PD_SM:
stat_p->dtap_sm_message_type[tap_p->message_type]++;
break;
case PD_SS:
stat_p->dtap_ss_message_type[tap_p->message_type]++;
break;
case PD_TP:
stat_p->dtap_tp_message_type[tap_p->message_type]++;
break;
default:
/*
* unsupported PD
*/
return(TAP_PACKET_DONT_REDRAW);
}
break;
case GSM_A_PDU_TYPE_SACCH:
switch (tap_p->protocol_disc)
{
case 0:
stat_p->sacch_rr_message_type[tap_p->message_type]++;
break;
default:
/* unknown Short PD */
break;
}
break;
default:
/*
* unknown PDU type !!!
*/
return(TAP_PACKET_DONT_REDRAW);
}
return(TAP_PACKET_REDRAW);
}
static void
gsm_a_stat_draw(
void *tapdata)
{
gsm_a_stat_t *stat_p = (gsm_a_stat_t *)tapdata;
guint8 i;
printf("\n");
printf("=========== GS=M A-i/f Statistics ============================\n");
printf("BSSMAP\n");
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_bssmap_msg_strings[i].strptr)
{
if (stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_bssmap_msg_strings[i].value,
gsm_a_bssmap_msg_strings[i].strptr,
stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_MM]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_mm_strings[i].strptr)
{
if (stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_mm_strings[i].value,
gsm_a_dtap_msg_mm_strings[i].strptr,
stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_RR]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_rr_strings[i].strptr)
{
if (stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_rr_strings[i].value,
gsm_a_dtap_msg_rr_strings[i].strptr,
stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_CC]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_cc_strings[i].strptr)
{
if (stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_cc_strings[i].value,
gsm_a_dtap_msg_cc_strings[i].strptr,
stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_GMM]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_gmm_strings[i].strptr)
{
if (stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_gmm_strings[i].value,
gsm_a_dtap_msg_gmm_strings[i].strptr,
stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_SMS]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_sms_strings[i].strptr)
{
if (stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_sms_strings[i].value,
gsm_a_dtap_msg_sms_strings[i].strptr,
stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_SM]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_sm_strings[i].strptr)
{
if (stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_sm_strings[i].value,
gsm_a_dtap_msg_sm_strings[i].strptr,
stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_SS]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_ss_strings[i].strptr)
{
if (stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_ss_strings[i].value,
gsm_a_dtap_msg_ss_strings[i].strptr,
stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_TP]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_tp_strings[i].strptr)
{
if (stat_p->dtap_tp_message_type[gsm_a_dtap_msg_tp_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_tp_strings[i].value,
gsm_a_dtap_msg_tp_strings[i].strptr,
stat_p->dtap_tp_message_type[gsm_a_dtap_msg_tp_strings[i].value]);
}
i++;
}
printf("\nSACCH Radio Resources Management messages\n");
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_rr_short_pd_msg_strings[i].strptr)
{
if (stat_p->sacch_rr_message_type[gsm_a_rr_short_pd_msg_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_rr_short_pd_msg_strings[i].value,
gsm_a_rr_short_pd_msg_strings[i].strptr,
stat_p->sacch_rr_message_type[gsm_a_rr_short_pd_msg_strings[i].value]);
}
i++;
}
printf("==============================================================\n");
}
static void
gsm_a_stat_init(const char *opt_arg _U_, void *userdata _U_)
{
gsm_a_stat_t *stat_p;
GString *err_p;
stat_p = g_new(gsm_a_stat_t, 1);
memset(stat_p, 0, sizeof(gsm_a_stat_t));
err_p =
register_tap_listener("gsm_a", stat_p, NULL, 0,
NULL,
gsm_a_stat_packet,
gsm_a_stat_draw,
NULL);
if (err_p != NULL)
{
g_free(stat_p);
g_string_free(err_p, TRUE);
exit(1);
}
}
static stat_tap_ui gsm_a_stat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"gsm_a",
gsm_a_stat_init,
0,
NULL
};
void
register_tap_listener_gsm_astat(void)
{
register_stat_tap_ui(&gsm_a_stat_ui, NULL);
} |
C | wireshark/ui/cli/tap-hosts.c | /* tap-hosts.c
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* Dump our collected IPv4- and IPv6-to-hostname mappings */
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "globals.h"
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/addr_resolv.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_hosts(void);
static gboolean dump_v4 = FALSE;
static gboolean dump_v6 = FALSE;
#define TAP_NAME "hosts"
static void
ipv4_hash_table_print_resolved(gpointer key _U_, gpointer value, gpointer user_data _U_)
{
hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value;
if ((ipv4_hash_table_entry->flags & NAME_RESOLVED)) {
printf("%s\t%s\n",
ipv4_hash_table_entry->ip,
ipv4_hash_table_entry->name);
}
}
static void
ipv6_hash_table_print_resolved(gpointer key _U_, gpointer value, gpointer user_data _U_)
{
hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *)value;
if ((ipv6_hash_table_entry->flags & NAME_RESOLVED)) {
printf("%s\t%s\n",
ipv6_hash_table_entry->ip6,
ipv6_hash_table_entry->name);
}
}
static void
hosts_draw(void *dummy _U_)
{
wmem_map_t *ipv4_hash_table;
wmem_map_t *ipv6_hash_table;
printf("# TShark hosts output\n");
printf("#\n");
printf("# Host data gathered from %s\n",
cfile.is_tempfile ? "the temporary capture file" : cfile.filename);
printf("\n");
if (dump_v4) {
ipv4_hash_table = get_ipv4_hash_table();
if (ipv4_hash_table) {
wmem_map_foreach( ipv4_hash_table, ipv4_hash_table_print_resolved, NULL);
}
}
if (dump_v6) {
ipv6_hash_table = get_ipv6_hash_table();
if (ipv6_hash_table) {
wmem_map_foreach( ipv6_hash_table, ipv6_hash_table_print_resolved, NULL);
}
}
}
static void
hosts_init(const char *opt_arg, void *userdata _U_)
{
GString *error_string;
gchar **tokens;
gint opt_count;
dump_v4 = FALSE;
dump_v6 = FALSE;
if (strcmp(TAP_NAME, opt_arg) == 0) {
/* No arguments; dump everything */
dump_v4 = TRUE;
dump_v6 = TRUE;
} else {
tokens = g_strsplit(opt_arg, ",", 0);
opt_count = 0;
while (tokens[opt_count]) {
if ((strcmp("ipv4", tokens[opt_count]) == 0) ||
(strcmp("ip", tokens[opt_count]) == 0)) {
dump_v4 = TRUE;
} else if (strcmp("ipv6", tokens[opt_count]) == 0) {
dump_v6 = TRUE;
} else if (opt_count > 0) {
cmdarg_err("invalid \"-z " TAP_NAME "[,ip|ipv4|ipv6]\" argument");
exit(1);
}
opt_count++;
}
g_strfreev(tokens);
}
error_string = register_tap_listener("frame", NULL, NULL, TL_REQUIRES_PROTO_TREE,
NULL, NULL, hosts_draw, NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
cmdarg_err("Couldn't register " TAP_NAME " tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui hosts_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
TAP_NAME,
hosts_init,
0,
NULL
};
void
register_tap_listener_hosts(void)
{
register_stat_tap_ui(&hosts_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-httpstat.c | /* tap-httpstat.c
* tap-httpstat 2003 Jean-Michel FAYARD
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/value_string.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-http.h>
#include <wsutil/wslog.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_httpstat(void);
/* used to keep track of the statictics for an entire program interface */
typedef struct _http_stats_t {
char *filter;
GHashTable *hash_responses;
GHashTable *hash_requests;
} httpstat_t;
/* used to keep track of the stats for a specific response code
* for example it can be { 3, 404, "Not Found" ,...}
* which means we captured 3 reply http/1.1 404 Not Found */
typedef struct _http_response_code_t {
guint32 packets; /* 3 */
guint response_code; /* 404 */
const gchar *name; /* Not Found */
httpstat_t *sp;
} http_response_code_t;
/* used to keep track of the stats for a specific request string */
typedef struct _http_request_methode_t {
gchar *response; /* eg. : GET */
guint32 packets;
httpstat_t *sp;
} http_request_methode_t;
/* insert some entries */
static void
http_init_hash(httpstat_t *sp)
{
int i;
sp->hash_responses = g_hash_table_new(g_direct_hash, g_direct_equal);
for (i=0; vals_http_status_code[i].strptr; i++)
{
http_response_code_t *sc = g_new (http_response_code_t, 1);
sc->packets = 0;
sc->response_code = vals_http_status_code[i].value;
sc->name = vals_http_status_code[i].strptr;
sc->sp = sp;
g_hash_table_insert(sc->sp->hash_responses, GUINT_TO_POINTER(vals_http_status_code[i].value), sc);
}
sp->hash_requests = g_hash_table_new(g_str_hash, g_str_equal);
}
static void
http_draw_hash_requests(gchar *key _U_, http_request_methode_t *data, gchar *format)
{
if (data->packets == 0)
return;
printf(format, data->response, data->packets);
}
static void
http_draw_hash_responses(gint * key _U_, http_response_code_t *data, char *format)
{
if (data == NULL) {
ws_warning("No data available, key=%d\n", *key);
exit(EXIT_FAILURE);
}
if (data->packets == 0)
return;
/* " %3d %-35s %9d packets", */
/* The maximum existing response code length is 32 characters */
printf(format, data->response_code, data->name, data->packets);
}
/* NOT USED at this moment */
/*
static void
http_free_hash(gpointer key, gpointer value, gpointer user_data _U_)
{
g_free(key);
g_free(value);
}
*/
static void
http_reset_hash_responses(gchar *key _U_, http_response_code_t *data, gpointer ptr _U_)
{
data->packets = 0;
}
static void
http_reset_hash_requests(gchar *key _U_, http_request_methode_t *data, gpointer ptr _U_)
{
data->packets = 0;
}
static void
httpstat_reset(void *psp)
{
httpstat_t *sp = (httpstat_t *)psp;
g_hash_table_foreach(sp->hash_responses, (GHFunc)http_reset_hash_responses, NULL);
g_hash_table_foreach(sp->hash_requests, (GHFunc)http_reset_hash_requests, NULL);
}
static tap_packet_status
httpstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri, tap_flags_t flags _U_)
{
const http_info_value_t *value = (const http_info_value_t *)pri;
httpstat_t *sp = (httpstat_t *)psp;
/* We are only interested in reply packets with a status code */
/* Request or reply packets ? */
if (value->response_code != 0) {
http_response_code_t *sc;
guint key = value->response_code;
sc = (http_response_code_t *)g_hash_table_lookup(
sp->hash_responses,
GUINT_TO_POINTER(key));
if (sc == NULL) {
/* non standard status code ; we classify it as others
* in the relevant category (Informational,Success,Redirection,Client Error,Server Error)
*/
int i = value->response_code;
if ((i < 100) || (i >= 600)) {
return TAP_PACKET_DONT_REDRAW;
}
else if (i < 200) {
key = 199; /* Hopefully, this status code will never be used */
}
else if (i < 300) {
key = 299;
}
else if (i < 400) {
key = 399;
}
else if (i < 500) {
key = 499;
}
else{
key = 599;
}
sc = (http_response_code_t *)g_hash_table_lookup(
sp->hash_responses,
GUINT_TO_POINTER(key));
if (sc == NULL)
return TAP_PACKET_DONT_REDRAW;
}
sc->packets++;
}
else if (value->request_method) {
http_request_methode_t *sc;
sc = (http_request_methode_t *)g_hash_table_lookup(
sp->hash_requests,
value->request_method);
if (sc == NULL) {
sc = g_new(http_request_methode_t, 1);
sc->response = g_strdup(value->request_method);
sc->packets = 1;
sc->sp = sp;
g_hash_table_insert(sp->hash_requests, sc->response, sc);
} else {
sc->packets++;
}
} else {
return TAP_PACKET_DONT_REDRAW;
}
return TAP_PACKET_REDRAW;
}
static void
httpstat_draw(void *psp)
{
httpstat_t *sp = (httpstat_t *)psp;
printf("\n");
printf("===================================================================\n");
if (! sp->filter || ! sp->filter[0])
printf("HTTP Statistics\n");
else
printf("HTTP Statistics with filter %s\n", sp->filter);
printf("* HTTP Response Status Codes Packets\n");
g_hash_table_foreach(sp->hash_responses, (GHFunc)http_draw_hash_responses,
(gpointer)" %3d %-35s %9d\n");
printf("* HTTP Request Methods Packets\n");
g_hash_table_foreach(sp->hash_requests, (GHFunc)http_draw_hash_requests,
(gpointer)" %-39s %9d \n");
printf("===================================================================\n");
}
/* When called, this function will create a new instance of httpstat.
*/
static void
httpstat_init(const char *opt_arg, void *userdata _U_)
{
httpstat_t *sp;
const char *filter = NULL;
GString *error_string;
if (!strncmp (opt_arg, "http,stat,", 10)) {
filter = opt_arg+10;
} else {
filter = NULL;
}
sp = g_new(httpstat_t, 1);
sp->filter = g_strdup(filter);
/*g_hash_table_foreach(http_status, (GHFunc)http_reset_hash_responses, NULL);*/
error_string = register_tap_listener(
"http",
sp,
filter,
0,
httpstat_reset,
httpstat_packet,
httpstat_draw,
NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(sp->filter);
g_free(sp);
cmdarg_err("Couldn't register http,stat tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
http_init_hash(sp);
}
static stat_tap_ui httpstat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"http,stat",
httpstat_init,
0,
NULL
};
void
register_tap_listener_httpstat(void)
{
register_stat_tap_ui(&httpstat_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-icmpstat.c | /* tap-icmpstat.c
* icmpstat 2011 Christopher Maynard
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides icmp echo request/reply SRT statistics to tshark.
* It is only used by tshark and not wireshark
*
* It was based on tap-rpcstat.c and doc/README.tapping.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-icmp.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_icmpstat(void);
/* used to keep track of the ICMP statistics */
typedef struct _icmpstat_t {
char *filter;
GSList *rt_list;
guint num_rqsts;
guint num_resps;
guint min_frame;
guint max_frame;
double min_msecs;
double max_msecs;
double tot_msecs;
} icmpstat_t;
/* This callback is never used by tshark but it is here for completeness. When
* registering below, we could just have left this function as NULL.
*
* When used by wireshark, this function will be called whenever we would need
* to reset all state, such as when wireshark opens a new file, when it starts
* a new capture, when it rescans the packetlist after some prefs have changed,
* etc.
*
* So if your application has some state it needs to clean up in those
* situations, here is a good place to put that code.
*/
static void
icmpstat_reset(void *tapdata)
{
icmpstat_t *icmpstat = (icmpstat_t *)tapdata;
g_slist_free(icmpstat->rt_list);
memset(icmpstat, 0, sizeof(icmpstat_t));
icmpstat->min_msecs = 1.0 * G_MAXUINT;
}
static gint compare_doubles(gconstpointer a, gconstpointer b)
{
double ad, bd;
ad = *(const double *)a;
bd = *(const double *)b;
if (ad < bd)
return -1;
if (ad > bd)
return 1;
return 0;
}
/* This callback is invoked whenever the tap system has seen a packet we might
* be interested in. The function is to be used to only update internal state
* information in the *tapdata structure, and if there were state changes which
* requires the window to be redrawn, return 1 and (*draw) will be called
* sometime later.
*
* This function should be as lightweight as possible since it executes
* together with the normal wireshark dissectors. Try to push as much
* processing as possible into (*draw) instead since that function executes
* asynchronously and does not affect the main thread's performance.
*
* If it is possible, try to do all "filtering" explicitly since you will get
* MUCH better performance than applying a similar display-filter in the
* register call.
*
* The third parameter is tap dependent. Since we register this one to the
* "icmp" tap, the third parameter type is icmp_transaction_t.
*
* function returns :
* TAP_PACKET_DONT_REDRAW: no updates, no need to call (*draw) later
* TAP_PACKET_REDRAW: state has changed, call (*draw) sometime later
*/
static tap_packet_status
icmpstat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *data, tap_flags_t flags _U_)
{
icmpstat_t *icmpstat = (icmpstat_t *)tapdata;
const icmp_transaction_t *trans = (const icmp_transaction_t *)data;
double resp_time, *rt;
if (trans == NULL)
return TAP_PACKET_DONT_REDRAW;
if (trans->resp_frame) {
resp_time = nstime_to_msec(&trans->resp_time);
rt = g_new(double, 1);
if (rt == NULL)
return TAP_PACKET_DONT_REDRAW;
*rt = resp_time;
icmpstat->rt_list = g_slist_prepend(icmpstat->rt_list, rt);
icmpstat->num_resps++;
if (icmpstat->min_msecs > resp_time) {
icmpstat->min_frame = trans->resp_frame;
icmpstat->min_msecs = resp_time;
}
if (icmpstat->max_msecs < resp_time) {
icmpstat->max_frame = trans->resp_frame;
icmpstat->max_msecs = resp_time;
}
icmpstat->tot_msecs += resp_time;
} else if (trans->rqst_frame)
icmpstat->num_rqsts++;
else
return TAP_PACKET_DONT_REDRAW;
return TAP_PACKET_REDRAW;
}
/*
* Compute the mean, median and standard deviation.
*/
static void compute_stats(icmpstat_t *icmpstat, double *mean, double *med, double *sdev)
{
GSList *slist;
double diff;
double sq_diff_sum = 0.0;
icmpstat->rt_list = g_slist_sort(icmpstat->rt_list, compare_doubles);
slist = icmpstat->rt_list;
if (icmpstat->num_resps == 0 || slist == NULL) {
*mean = 0.0;
*med = 0.0;
*sdev = 0.0;
return;
}
/* (arithmetic) mean */
*mean = icmpstat->tot_msecs / icmpstat->num_resps;
/* median: If we have an odd number of elements in our list, then the
* median is simply the middle element, otherwise the median is computed by
* averaging the 2 elements on either side of the mid-point. */
if (icmpstat->num_resps & 1)
*med = *(double *)g_slist_nth_data(slist, icmpstat->num_resps / 2);
else {
*med =
(*(double *)g_slist_nth_data(slist, (icmpstat->num_resps - 1) / 2) +
*(double *)g_slist_nth_data(slist, icmpstat->num_resps / 2)) / 2;
}
/* (sample) standard deviation */
for ( ; slist; slist = g_slist_next(slist)) {
diff = *(double *)slist->data - *mean;
sq_diff_sum += diff * diff;
}
if (icmpstat->num_resps > 1)
*sdev = sqrt(sq_diff_sum / (icmpstat->num_resps - 1));
else
*sdev = 0.0;
}
/* This callback is used when tshark wants us to draw/update our data to the
* output device. Since this is tshark, the only output is stdout.
* TShark will only call this callback once, which is when tshark has finished
* reading all packets and exits.
* If used with wireshark this may be called any time, perhaps once every 3
* seconds or so.
* This function may even be called in parallel with (*reset) or (*draw), so
* make sure there are no races. The data in the icmpstat_t can thus change
* beneath us. Beware!
*
* How best to display the data? For now, following other tap statistics
* output, but here are a few other alternatives we might choose from:
*
* -> Windows ping output:
* Ping statistics for <IP>:
* Packets: Sent = <S>, Received = <R>, Lost = <L> (<LP>% loss),
* Approximate round trip times in milli-seconds:
* Minimum = <m>ms, Maximum = <M>ms, Average = <A>ms
*
* -> Cygwin ping output:
* ----<HOST> PING Statistics----
* <S> packets transmitted, <R> packets received, <LP>% packet loss
* round-trip (ms) min/avg/max/med = <m>/<M>/<A>/<D>
*
* -> Linux ping output:
* --- <HOST> ping statistics ---
* <S> packets transmitted, <R> received, <LP>% packet loss, time <T>ms
* rtt min/avg/max/mdev = <m>/<A>/<M>/<D> ms
*/
static void
icmpstat_draw(void *tapdata)
{
icmpstat_t *icmpstat = (icmpstat_t *)tapdata;
unsigned int lost;
double mean, sdev, med;
printf("\n");
printf("==========================================================================\n");
printf("ICMP Service Response Time (SRT) Statistics (all times in ms):\n");
printf("Filter: %s\n", icmpstat->filter ? icmpstat->filter : "<none>");
printf("\nRequests Replies Lost %% Loss\n");
if (icmpstat->num_rqsts) {
lost = icmpstat->num_rqsts - icmpstat->num_resps;
compute_stats(icmpstat, &mean, &med, &sdev);
printf("%-10u%-10u%-10u%5.1f%%\n\n",
icmpstat->num_rqsts, icmpstat->num_resps, lost,
100.0 * lost / icmpstat->num_rqsts);
printf("Minimum Maximum Mean Median SDeviation Min Frame Max Frame\n");
printf("%-10.3f%-10.3f%-10.3f%-10.3f%-10.3f %-10u%-10u\n",
icmpstat->min_msecs >= G_MAXUINT ? 0.0 : icmpstat->min_msecs,
icmpstat->max_msecs, mean, med, sdev,
icmpstat->min_frame, icmpstat->max_frame);
} else {
printf("0 0 0 0.0%%\n\n");
printf("Minimum Maximum Mean Median SDeviation Min Frame Max Frame\n");
printf("0.000 0.000 0.000 0.000 0.000 0 0\n");
}
printf("==========================================================================\n");
}
/* When called, this function will create a new instance of icmpstat.
*
* This function is called from tshark when it parses the -z icmp, arguments
* and it creates a new instance to store statistics in and registers this new
* instance for the icmp tap.
*/
static void
icmpstat_init(const char *opt_arg, void *userdata _U_)
{
icmpstat_t *icmpstat;
const char *filter = NULL;
GString *error_string;
if (strstr(opt_arg, "icmp,srt,"))
filter = opt_arg + strlen("icmp,srt,");
icmpstat = (icmpstat_t *)g_try_malloc(sizeof(icmpstat_t));
if (icmpstat == NULL) {
cmdarg_err("Couldn't register icmp,srt tap: Out of memory");
exit(1);
}
memset(icmpstat, 0, sizeof(icmpstat_t));
icmpstat->min_msecs = 1.0 * G_MAXUINT;
icmpstat->filter = g_strdup(filter);
/* It is possible to create a filter and attach it to the callbacks. Then the
* callbacks would only be invoked if the filter matched.
*
* Evaluating filters is expensive and if we can avoid it and not use them,
* then we gain performance.
*
* In this case we do the filtering for protocol and version inside the
* callback itself but use whatever filter the user provided.
*/
error_string = register_tap_listener("icmp", icmpstat, icmpstat->filter,
TL_REQUIRES_NOTHING, icmpstat_reset, icmpstat_packet, icmpstat_draw,
NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(icmpstat->filter);
g_free(icmpstat);
cmdarg_err("Couldn't register icmp,srt tap: %s", error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui icmpstat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"icmp,srt",
icmpstat_init,
0,
NULL
};
void
register_tap_listener_icmpstat(void)
{
register_stat_tap_ui(&icmpstat_ui, NULL);
} |
C | wireshark/ui/cli/tap-icmpv6stat.c | /* tap-icmpv6stat.c
* icmpv6stat 2011 Christopher Maynard
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides icmpv6 echo request/reply SRT statistics to tshark.
* It is only used by tshark and not wireshark
*
* It was based on tap-icmptat.c, which itself was based on tap-rpcstat.c and
* doc/README.tapping.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-icmp.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_icmpv6stat(void);
/* used to keep track of the ICMPv6 statistics */
typedef struct _icmpv6stat_t {
char *filter;
GSList *rt_list;
guint num_rqsts;
guint num_resps;
guint min_frame;
guint max_frame;
double min_msecs;
double max_msecs;
double tot_msecs;
} icmpv6stat_t;
/* This callback is never used by tshark but it is here for completeness. When
* registering below, we could just have left this function as NULL.
*
* When used by wireshark, this function will be called whenever we would need
* to reset all state, such as when wireshark opens a new file, when it starts
* a new capture, when it rescans the packetlist after some prefs have changed,
* etc.
*
* So if your application has some state it needs to clean up in those
* situations, here is a good place to put that code.
*/
static void
icmpv6stat_reset(void *tapdata)
{
icmpv6stat_t *icmpv6stat = (icmpv6stat_t *)tapdata;
g_slist_free(icmpv6stat->rt_list);
memset(icmpv6stat, 0, sizeof(icmpv6stat_t));
icmpv6stat->min_msecs = 1.0 * G_MAXUINT;
}
static gint compare_doubles(gconstpointer a, gconstpointer b)
{
double ad, bd;
ad = *(const double *)a;
bd = *(const double *)b;
if (ad < bd)
return -1;
if (ad > bd)
return 1;
return 0;
}
/* This callback is invoked whenever the tap system has seen a packet we might
* be interested in. The function is to be used to only update internal state
* information in the *tapdata structure, and if there were state changes which
* requires the window to be redrawn, return 1 and (*draw) will be called
* sometime later.
*
* This function should be as lightweight as possible since it executes
* together with the normal wireshark dissectors. Try to push as much
* processing as possible into (*draw) instead since that function executes
* asynchronously and does not affect the main thread's performance.
*
* If it is possible, try to do all "filtering" explicitly since you will get
* MUCH better performance than applying a similar display-filter in the
* register call.
*
* The third parameter is tap dependent. Since we register this one to the
* "icmpv6" tap, the third parameter type is icmp_transaction_t.
*
* function returns :
* TAP_PACKET_DONT_REDRAW: no updates, no need to call (*draw) later
* TAP_PACKET_REDRAW: state has changed, call (*draw) sometime later
*/
static tap_packet_status
icmpv6stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *data, tap_flags_t flags _U_)
{
icmpv6stat_t *icmpv6stat = (icmpv6stat_t *)tapdata;
const icmp_transaction_t *trans = (const icmp_transaction_t *)data;
double resp_time, *rt;
if (trans == NULL)
return TAP_PACKET_DONT_REDRAW;
if (trans->resp_frame) {
resp_time = nstime_to_msec(&trans->resp_time);
rt = g_new(double, 1);
if (rt == NULL)
return TAP_PACKET_DONT_REDRAW;
*rt = resp_time;
icmpv6stat->rt_list = g_slist_prepend(icmpv6stat->rt_list, rt);
icmpv6stat->num_resps++;
if (icmpv6stat->min_msecs > resp_time) {
icmpv6stat->min_frame = trans->resp_frame;
icmpv6stat->min_msecs = resp_time;
}
if (icmpv6stat->max_msecs < resp_time) {
icmpv6stat->max_frame = trans->resp_frame;
icmpv6stat->max_msecs = resp_time;
}
icmpv6stat->tot_msecs += resp_time;
} else if (trans->rqst_frame)
icmpv6stat->num_rqsts++;
else
return TAP_PACKET_DONT_REDRAW;
return TAP_PACKET_REDRAW;
}
/*
* Compute the mean, median and standard deviation.
*/
static void compute_stats(icmpv6stat_t *icmpv6stat, double *mean, double *med, double *sdev)
{
GSList *slist;
double diff;
double sq_diff_sum = 0.0;
icmpv6stat->rt_list = g_slist_sort(icmpv6stat->rt_list, compare_doubles);
slist = icmpv6stat->rt_list;
if (icmpv6stat->num_resps == 0 || slist == NULL) {
*mean = 0.0;
*med = 0.0;
*sdev = 0.0;
return;
}
/* (arithmetic) mean */
*mean = icmpv6stat->tot_msecs / icmpv6stat->num_resps;
/* median: If we have an odd number of elements in our list, then the
* median is simply the middle element, otherwise the median is computed by
* averaging the 2 elements on either side of the mid-point. */
if (icmpv6stat->num_resps & 1)
*med = *(double *)g_slist_nth_data(slist, icmpv6stat->num_resps / 2);
else {
*med =
(*(double *)g_slist_nth_data(slist, (icmpv6stat->num_resps - 1) / 2) +
*(double *)g_slist_nth_data(slist, icmpv6stat->num_resps / 2)) / 2;
}
/* (sample) standard deviation */
for ( ; slist; slist = g_slist_next(slist)) {
diff = *(double *)slist->data - *mean;
sq_diff_sum += diff * diff;
}
if (icmpv6stat->num_resps > 1)
*sdev = sqrt(sq_diff_sum / (icmpv6stat->num_resps - 1));
else
*sdev = 0.0;
}
/* This callback is used when tshark wants us to draw/update our data to the
* output device. Since this is tshark, the only output is stdout.
* TShark will only call this callback once, which is when tshark has finished
* reading all packets and exits.
* If used with wireshark this may be called any time, perhaps once every 3
* seconds or so.
* This function may even be called in parallel with (*reset) or (*draw), so
* make sure there are no races. The data in the icmpv6stat_t can thus change
* beneath us. Beware!
*
* How best to display the data? For now, following other tap statistics
* output, but here are a few other alternatives we might choose from:
*
* -> Windows ping output:
* Ping statistics for <IP>:
* Packets: Sent = <S>, Received = <R>, Lost = <L> (<LP>% loss),
* Approximate round trip times in milli-seconds:
* Minimum = <m>ms, Maximum = <M>ms, Average = <A>ms
*
* -> Cygwin ping output:
* ----<HOST> PING Statistics----
* <S> packets transmitted, <R> packets received, <LP>% packet loss
* round-trip (ms) min/avg/max/med = <m>/<M>/<A>/<D>
*
* -> Linux ping output:
* --- <HOST> ping statistics ---
* <S> packets transmitted, <R> received, <LP>% packet loss, time <T>ms
* rtt min/avg/max/mdev = <m>/<A>/<M>/<D> ms
*/
static void
icmpv6stat_draw(void *tapdata)
{
icmpv6stat_t *icmpv6stat = (icmpv6stat_t *)tapdata;
unsigned int lost;
double mean, sdev, med;
printf("\n");
printf("==========================================================================\n");
printf("ICMPv6 Service Response Time (SRT) Statistics (all times in ms):\n");
printf("Filter: %s\n", icmpv6stat->filter ? icmpv6stat->filter : "<none>");
printf("\nRequests Replies Lost %% Loss\n");
if (icmpv6stat->num_rqsts) {
lost = icmpv6stat->num_rqsts - icmpv6stat->num_resps;
compute_stats(icmpv6stat, &mean, &med, &sdev);
printf("%-10u%-10u%-10u%5.1f%%\n\n",
icmpv6stat->num_rqsts, icmpv6stat->num_resps, lost,
100.0 * lost / icmpv6stat->num_rqsts);
printf("Minimum Maximum Mean Median SDeviation Min Frame Max Frame\n");
printf("%-10.3f%-10.3f%-10.3f%-10.3f%-10.3f %-10u%-10u\n",
icmpv6stat->min_msecs >= G_MAXUINT ? 0.0 : icmpv6stat->min_msecs,
icmpv6stat->max_msecs, mean, med, sdev,
icmpv6stat->min_frame, icmpv6stat->max_frame);
} else {
printf("0 0 0 0.0%%\n\n");
printf("Minimum Maximum Mean Median SDeviation Min Frame Max Frame\n");
printf("0.000 0.000 0.000 0.000 0.000 0 0\n");
}
printf("==========================================================================\n");
}
/* When called, this function will create a new instance of icmpv6stat.
*
* This function is called from tshark when it parses the -z icmpv6, arguments
* and it creates a new instance to store statistics in and registers this new
* instance for the icmpv6 tap.
*/
static void
icmpv6stat_init(const char *opt_arg, void *userdata _U_)
{
icmpv6stat_t *icmpv6stat;
const char *filter = NULL;
GString *error_string;
if (strstr(opt_arg, "icmpv6,srt,"))
filter = opt_arg + strlen("icmpv6,srt,");
icmpv6stat = (icmpv6stat_t *)g_try_malloc(sizeof(icmpv6stat_t));
if (icmpv6stat == NULL) {
cmdarg_err("Couldn't register icmpv6,srt tap: Out of memory");
exit(1);
}
memset(icmpv6stat, 0, sizeof(icmpv6stat_t));
icmpv6stat->min_msecs = 1.0 * G_MAXUINT;
icmpv6stat->filter = g_strdup(filter);
/* It is possible to create a filter and attach it to the callbacks. Then the
* callbacks would only be invoked if the filter matched.
*
* Evaluating filters is expensive and if we can avoid it and not use them,
* then we gain performance.
*
* In this case we do the filtering for protocol and version inside the
* callback itself but use whatever filter the user provided.
*/
error_string = register_tap_listener("icmpv6", icmpv6stat, icmpv6stat->filter,
TL_REQUIRES_NOTHING, icmpv6stat_reset, icmpv6stat_packet, icmpv6stat_draw, NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(icmpv6stat->filter);
g_free(icmpv6stat);
cmdarg_err("Couldn't register icmpv6,srt tap: %s", error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui icmpv6stat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"icmpv6,srt",
icmpv6stat_init,
0,
NULL
};
void
register_tap_listener_icmpv6stat(void)
{
register_stat_tap_ui(&icmpv6stat_ui, NULL);
} |
C | wireshark/ui/cli/tap-iostat.c | /* tap-iostat.c
* iostat 2002 Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <epan/epan_dissect.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include "globals.h"
#include <wsutil/ws_assert.h>
#define CALC_TYPE_FRAMES 0
#define CALC_TYPE_BYTES 1
#define CALC_TYPE_FRAMES_AND_BYTES 2
#define CALC_TYPE_COUNT 3
#define CALC_TYPE_SUM 4
#define CALC_TYPE_MIN 5
#define CALC_TYPE_MAX 6
#define CALC_TYPE_AVG 7
#define CALC_TYPE_LOAD 8
void register_tap_listener_iostat(void);
typedef struct {
const char *func_name;
int calc_type;
} calc_type_ent_t;
static calc_type_ent_t calc_type_table[] = {
{ "FRAMES", CALC_TYPE_FRAMES },
{ "BYTES", CALC_TYPE_BYTES },
{ "FRAMES BYTES", CALC_TYPE_FRAMES_AND_BYTES },
{ "COUNT", CALC_TYPE_COUNT },
{ "SUM", CALC_TYPE_SUM },
{ "MIN", CALC_TYPE_MIN },
{ "MAX", CALC_TYPE_MAX },
{ "AVG", CALC_TYPE_AVG },
{ "LOAD", CALC_TYPE_LOAD },
{ NULL, 0 }
};
typedef struct _io_stat_t {
guint64 interval; /* The user-specified time interval (us) */
guint invl_prec; /* Decimal precision of the time interval (1=10s, 2=100s etc) */
unsigned int num_cols; /* The number of columns of stats in the table */
struct _io_stat_item_t *items; /* Each item is a single cell in the table */
time_t start_time; /* Time of first frame matching the filter */
const char **filters; /* 'io,stat' cmd strings (e.g., "AVG(smb.time)smb.time") */
guint64 *max_vals; /* The max value sans the decimal or nsecs portion in each stat column */
guint32 *max_frame; /* The max frame number displayed in each stat column */
} io_stat_t;
typedef struct _io_stat_item_t {
io_stat_t *parent;
struct _io_stat_item_t *next;
struct _io_stat_item_t *prev;
guint64 start_time; /* Time since start of capture (us)*/
int calc_type; /* The statistic type */
int colnum; /* Column number of this stat (0 to n) */
int hf_index;
guint32 frames;
guint32 num; /* The sample size of a given statistic (only needed for AVG) */
guint64 counter; /* The accumulated data for the calculation of that statistic */
gfloat float_counter;
gdouble double_counter;
} io_stat_item_t;
#define NANOSECS_PER_SEC G_GUINT64_CONSTANT(1000000000)
static guint64 last_relative_time;
static tap_packet_status
iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *dummy _U_, tap_flags_t flags _U_)
{
io_stat_t *parent;
io_stat_item_t *mit;
io_stat_item_t *it;
guint64 relative_time, rt;
const nstime_t *new_time;
GPtrArray *gp;
guint i;
int ftype;
mit = (io_stat_item_t *) arg;
parent = mit->parent;
/* If this frame's relative time is negative, set its relative time to last_relative_time
rather than disincluding it from the calculations. */
if ((pinfo->rel_ts.secs >= 0) && (pinfo->rel_ts.nsecs >= 0)) {
relative_time = ((guint64)pinfo->rel_ts.secs * G_GUINT64_CONSTANT(1000000)) +
((guint64)((pinfo->rel_ts.nsecs+500)/1000));
last_relative_time = relative_time;
} else {
relative_time = last_relative_time;
}
if (mit->parent->start_time == 0) {
mit->parent->start_time = pinfo->abs_ts.secs - pinfo->rel_ts.secs;
}
/* The prev item is always the last interval in which we saw packets. */
it = mit->prev;
/* If we have moved into a new interval (row), create a new io_stat_item_t struct for every interval
* between the last struct and this one. If an item was not found in a previous interval, an empty
* struct will be created for it. */
rt = relative_time;
while (rt >= it->start_time + parent->interval) {
it->next = g_new(io_stat_item_t, 1);
it->next->prev = it;
it->next->next = NULL;
it = it->next;
mit->prev = it;
it->start_time = it->prev->start_time + parent->interval;
it->frames = 0;
it->counter = 0;
it->float_counter = 0;
it->double_counter = 0;
it->num = 0;
it->calc_type = it->prev->calc_type;
it->hf_index = it->prev->hf_index;
it->colnum = it->prev->colnum;
}
/* Store info in the current structure */
it->frames++;
switch (it->calc_type) {
case CALC_TYPE_FRAMES:
case CALC_TYPE_BYTES:
case CALC_TYPE_FRAMES_AND_BYTES:
it->counter += pinfo->fd->pkt_len;
break;
case CALC_TYPE_COUNT:
gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
if (gp) {
it->counter += gp->len;
}
break;
case CALC_TYPE_SUM:
gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
if (gp) {
guint64 val;
for (i=0; i<gp->len; i++) {
switch (proto_registrar_get_ftype(it->hf_index)) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
it->counter += fvalue_get_uinteger(((field_info *)gp->pdata[i])->value);
break;
case FT_UINT40:
case FT_UINT48:
case FT_UINT56:
case FT_UINT64:
it->counter += fvalue_get_uinteger64(((field_info *)gp->pdata[i])->value);
break;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
it->counter += fvalue_get_sinteger(((field_info *)gp->pdata[i])->value);
break;
case FT_INT40:
case FT_INT48:
case FT_INT56:
case FT_INT64:
it->counter += (gint64)fvalue_get_sinteger64(((field_info *)gp->pdata[i])->value);
break;
case FT_FLOAT:
it->float_counter +=
(gfloat)fvalue_get_floating(((field_info *)gp->pdata[i])->value);
break;
case FT_DOUBLE:
it->double_counter += fvalue_get_floating(((field_info *)gp->pdata[i])->value);
break;
case FT_RELATIVE_TIME:
new_time = fvalue_get_time(((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
it->counter += val;
break;
default:
/*
* "Can't happen"; see the checks
* in register_io_tap().
*/
ws_assert_not_reached();
break;
}
}
}
break;
case CALC_TYPE_MIN:
gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
if (gp) {
guint64 val;
gfloat float_val;
gdouble double_val;
ftype = proto_registrar_get_ftype(it->hf_index);
for (i=0; i<gp->len; i++) {
switch (ftype) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
val = fvalue_get_uinteger(((field_info *)gp->pdata[i])->value);
if ((it->frames == 1 && i == 0) || (val < it->counter)) {
it->counter = val;
}
break;
case FT_UINT40:
case FT_UINT48:
case FT_UINT56:
case FT_UINT64:
val = fvalue_get_uinteger64(((field_info *)gp->pdata[i])->value);
if ((it->frames == 1 && i == 0) || (val < it->counter)) {
it->counter = val;
}
break;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
val = fvalue_get_sinteger(((field_info *)gp->pdata[i])->value);
if ((it->frames == 1 && i == 0) || ((gint32)val < (gint32)it->counter)) {
it->counter = val;
}
break;
case FT_INT40:
case FT_INT48:
case FT_INT56:
case FT_INT64:
val = fvalue_get_sinteger64(((field_info *)gp->pdata[i])->value);
if ((it->frames == 1 && i == 0) || ((gint64)val < (gint64)it->counter)) {
it->counter = val;
}
break;
case FT_FLOAT:
float_val = (gfloat)fvalue_get_floating(((field_info *)gp->pdata[i])->value);
if ((it->frames == 1 && i == 0) || (float_val < it->float_counter)) {
it->float_counter = float_val;
}
break;
case FT_DOUBLE:
double_val = fvalue_get_floating(((field_info *)gp->pdata[i])->value);
if ((it->frames == 1 && i == 0) || (double_val < it->double_counter)) {
it->double_counter = double_val;
}
break;
case FT_RELATIVE_TIME:
new_time = fvalue_get_time(((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
if ((it->frames == 1 && i == 0) || (val < it->counter)) {
it->counter = val;
}
break;
default:
/*
* "Can't happen"; see the checks
* in register_io_tap().
*/
ws_assert_not_reached();
break;
}
}
}
break;
case CALC_TYPE_MAX:
gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
if (gp) {
guint64 val;
gfloat float_val;
gdouble double_val;
ftype = proto_registrar_get_ftype(it->hf_index);
for (i=0; i<gp->len; i++) {
switch (ftype) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
val = fvalue_get_uinteger(((field_info *)gp->pdata[i])->value);
if (val > it->counter)
it->counter = val;
break;
case FT_UINT40:
case FT_UINT48:
case FT_UINT56:
case FT_UINT64:
val = fvalue_get_uinteger64(((field_info *)gp->pdata[i])->value);
if (val > it->counter)
it->counter = val;
break;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
val = fvalue_get_sinteger(((field_info *)gp->pdata[i])->value);
if ((gint32)val > (gint32)it->counter)
it->counter = val;
break;
case FT_INT40:
case FT_INT48:
case FT_INT56:
case FT_INT64:
val = fvalue_get_sinteger64(((field_info *)gp->pdata[i])->value);
if ((gint64)val > (gint64)it->counter)
it->counter = val;
break;
case FT_FLOAT:
float_val = (gfloat)fvalue_get_floating(((field_info *)gp->pdata[i])->value);
if (float_val > it->float_counter)
it->float_counter = float_val;
break;
case FT_DOUBLE:
double_val = fvalue_get_floating(((field_info *)gp->pdata[i])->value);
if (double_val > it->double_counter)
it->double_counter = double_val;
break;
case FT_RELATIVE_TIME:
new_time = fvalue_get_time(((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
if (val > it->counter)
it->counter = val;
break;
default:
/*
* "Can't happen"; see the checks
* in register_io_tap().
*/
ws_assert_not_reached();
break;
}
}
}
break;
case CALC_TYPE_AVG:
gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
if (gp) {
guint64 val;
ftype = proto_registrar_get_ftype(it->hf_index);
for (i=0; i<gp->len; i++) {
it->num++;
switch (ftype) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
val = fvalue_get_uinteger(((field_info *)gp->pdata[i])->value);
it->counter += val;
break;
case FT_UINT40:
case FT_UINT48:
case FT_UINT56:
case FT_UINT64:
val = fvalue_get_uinteger64(((field_info *)gp->pdata[i])->value);
it->counter += val;
break;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
val = fvalue_get_sinteger(((field_info *)gp->pdata[i])->value);
it->counter += val;
break;
case FT_INT40:
case FT_INT48:
case FT_INT56:
case FT_INT64:
val = fvalue_get_sinteger64(((field_info *)gp->pdata[i])->value);
it->counter += val;
break;
case FT_FLOAT:
it->float_counter += (gfloat)fvalue_get_floating(((field_info *)gp->pdata[i])->value);
break;
case FT_DOUBLE:
it->double_counter += fvalue_get_floating(((field_info *)gp->pdata[i])->value);
break;
case FT_RELATIVE_TIME:
new_time = fvalue_get_time(((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
it->counter += val;
break;
default:
/*
* "Can't happen"; see the checks
* in register_io_tap().
*/
ws_assert_not_reached();
break;
}
}
}
break;
case CALC_TYPE_LOAD:
gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
if (gp) {
ftype = proto_registrar_get_ftype(it->hf_index);
if (ftype != FT_RELATIVE_TIME) {
fprintf(stderr,
"\ntshark: LOAD() is only supported for relative-time fields such as smb.time\n");
exit(10);
}
for (i=0; i<gp->len; i++) {
guint64 val;
int tival;
io_stat_item_t *pit;
new_time = fvalue_get_time(((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs*G_GUINT64_CONSTANT(1000000)) + (guint64)(new_time->nsecs/1000);
tival = (int)(val % parent->interval);
it->counter += tival;
val -= tival;
pit = it->prev;
while (val > 0) {
if (val < (guint64)parent->interval) {
pit->counter += val;
break;
}
pit->counter += parent->interval;
val -= parent->interval;
pit = pit->prev;
}
}
}
break;
}
/* Store the highest value for this item in order to determine the width of each stat column.
* For real numbers we only need to know its magnitude (the value to the left of the decimal point
* so round it up before storing it as an integer in max_vals. For AVG of RELATIVE_TIME fields,
* calc the average, round it to the next second and store the seconds. For all other calc types
* of RELATIVE_TIME fields, store the counters without modification.
* fields. */
switch (it->calc_type) {
case CALC_TYPE_FRAMES:
case CALC_TYPE_FRAMES_AND_BYTES:
parent->max_frame[it->colnum] =
MAX(parent->max_frame[it->colnum], it->frames);
if (it->calc_type == CALC_TYPE_FRAMES_AND_BYTES)
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], it->counter);
break;
case CALC_TYPE_BYTES:
case CALC_TYPE_COUNT:
case CALC_TYPE_LOAD:
parent->max_vals[it->colnum] = MAX(parent->max_vals[it->colnum], it->counter);
break;
case CALC_TYPE_SUM:
case CALC_TYPE_MIN:
case CALC_TYPE_MAX:
ftype = proto_registrar_get_ftype(it->hf_index);
switch (ftype) {
case FT_FLOAT:
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], (guint64)(it->float_counter+0.5));
break;
case FT_DOUBLE:
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], (guint64)(it->double_counter+0.5));
break;
case FT_RELATIVE_TIME:
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], it->counter);
break;
default:
/* UINT16-64 and INT8-64 */
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], it->counter);
break;
}
break;
case CALC_TYPE_AVG:
if (it->num == 0) /* avoid division by zero */
break;
ftype = proto_registrar_get_ftype(it->hf_index);
switch (ftype) {
case FT_FLOAT:
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], (guint64)it->float_counter/it->num);
break;
case FT_DOUBLE:
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], (guint64)it->double_counter/it->num);
break;
case FT_RELATIVE_TIME:
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], ((it->counter/(guint64)it->num) + G_GUINT64_CONSTANT(500000000)) / NANOSECS_PER_SEC);
break;
default:
/* UINT16-64 and INT8-64 */
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], it->counter/it->num);
break;
}
}
return TAP_PACKET_REDRAW;
}
static unsigned int
magnitude (guint64 val, unsigned int max_w)
{
unsigned int i, mag = 0;
for (i=0; i<max_w; i++) {
mag++;
if ((val /= 10) == 0)
break;
}
return(mag);
}
/*
* Print the calc_type_table[] function label centered in the column header.
*/
static void
printcenter (const char *label, int lenval, int numpad)
{
int lenlab = (int) strlen(label), len;
const char spaces[] = " ", *spaces_ptr;
len = (int) (strlen(spaces)) - (((lenval-lenlab) / 2) + numpad);
if (len > 0 && len < 6) {
spaces_ptr = &spaces[len];
if ((lenval-lenlab)%2 == 0) {
printf("%s%s%s|", spaces_ptr, label, spaces_ptr);
} else {
printf("%s%s%s|", spaces_ptr-1, label, spaces_ptr);
}
} else if (len > 0 && len <= 15) {
printf("%s|", label);
}
}
typedef struct {
int fr; /* Width of this FRAMES column sans padding and border chars */
int val; /* Width of this non-FRAMES column sans padding and border chars */
} column_width;
static void
iostat_draw(void *arg)
{
guint32 num;
guint64 interval, duration, t, invl_end, dv;
unsigned int i, j, k, num_cols, num_rows, dur_secs_orig, dur_nsecs_orig, dur_secs, dur_nsecs, dur_mag,
invl_mag, invl_prec, tabrow_w, borderlen, invl_col_w, numpad = 1, namelen, len_filt, type,
maxfltr_w, ftype;
unsigned int fr_mag; /* The magnitude of the max frame number in this column */
unsigned int val_mag; /* The magnitude of the max value in this column */
char *spaces, *spaces_s, *filler_s = NULL, **fmts, *fmt = NULL;
const char *filter;
static gchar dur_mag_s[3], invl_prec_s[3], fr_mag_s[3], val_mag_s[3], *invl_fmt, *full_fmt;
io_stat_item_t *mit, **stat_cols, *item, **item_in_column;
gboolean last_row = FALSE;
io_stat_t *iot;
column_width *col_w;
struct tm *tm_time;
time_t the_time;
mit = (io_stat_item_t *)arg;
iot = mit->parent;
num_cols = iot->num_cols;
col_w = g_new(column_width, num_cols);
fmts = (char **)g_malloc(sizeof(char *) * num_cols);
duration = ((guint64)cfile.elapsed_time.secs * G_GUINT64_CONSTANT(1000000)) +
(guint64)((cfile.elapsed_time.nsecs + 500) / 1000);
/* Store the pointer to each stat column */
stat_cols = (io_stat_item_t **)g_malloc(sizeof(io_stat_item_t *) * num_cols);
for (j=0; j<num_cols; j++)
stat_cols[j] = &iot->items[j];
/* The following prevents gross inaccuracies when the user specifies an interval that is greater
* than the capture duration. */
if (iot->interval > duration || iot->interval == G_MAXUINT64) {
interval = duration;
iot->interval = G_MAXUINT64;
} else {
interval = iot->interval;
}
/* Calc the capture duration's magnitude (dur_mag) */
dur_secs = (unsigned int)(duration/G_GUINT64_CONSTANT(1000000));
dur_secs_orig = dur_secs;
dur_nsecs = (unsigned int)(duration%G_GUINT64_CONSTANT(1000000));
dur_nsecs_orig = dur_nsecs;
dur_mag = magnitude((guint64)dur_secs, 5);
snprintf(dur_mag_s, 3, "%u", dur_mag);
/* Calc the interval's magnitude */
invl_mag = magnitude(interval/G_GUINT64_CONSTANT(1000000), 5);
/* Set or get the interval precision */
if (interval == duration) {
/*
* An interval arg of 0 or an interval size exceeding the capture duration was specified.
* Set the decimal precision of duration based on its magnitude. */
if (dur_mag >= 2)
invl_prec = 1;
else if (dur_mag == 1)
invl_prec = 3;
else
invl_prec = 6;
borderlen = 30 + dur_mag + (invl_prec == 0 ? 0 : invl_prec+1);
} else {
invl_prec = iot->invl_prec;
borderlen = 25 + MAX(invl_mag,dur_mag) + (invl_prec == 0 ? 0 : invl_prec+1);
}
/* Round the duration according to invl_prec */
dv = 1000000;
for (i=0; i<invl_prec; i++)
dv /= 10;
if ((duration%dv) > 5*(dv/10)) {
duration += 5*(dv/10);
duration = (duration/dv) * dv;
dur_secs = (unsigned int)(duration/G_GUINT64_CONSTANT(1000000));
dur_nsecs = (unsigned int)(duration%G_GUINT64_CONSTANT(1000000));
/*
* Recalc dur_mag in case rounding has increased its magnitude */
dur_mag = magnitude((guint64)dur_secs, 5);
}
if (iot->interval == G_MAXUINT64)
interval = duration;
/* Calc the width of the time interval column (incl borders and padding). */
if (invl_prec == 0)
invl_col_w = (2*dur_mag) + 8;
else
invl_col_w = (2*dur_mag) + (2*invl_prec) + 10;
/* Update the width of the time interval column if date is shown */
switch (timestamp_get_type()) {
case TS_ABSOLUTE_WITH_YMD:
case TS_ABSOLUTE_WITH_YDOY:
case TS_UTC_WITH_YMD:
case TS_UTC_WITH_YDOY:
invl_col_w = MAX(invl_col_w, 23);
break;
default:
invl_col_w = MAX(invl_col_w, 12);
break;
}
borderlen = MAX(borderlen, invl_col_w);
/* Calc the total width of each row in the stats table and build the printf format string for each
* column based on its field type, width, and name length.
* NOTE: The magnitude of all types including float and double are stored in iot->max_vals which
* is an *integer*. */
tabrow_w = invl_col_w;
for (j=0; j<num_cols; j++) {
type = iot->items[j].calc_type;
if (type == CALC_TYPE_FRAMES_AND_BYTES) {
namelen = 5;
} else {
namelen = (unsigned int)strlen(calc_type_table[type].func_name);
}
if (type == CALC_TYPE_FRAMES
|| type == CALC_TYPE_FRAMES_AND_BYTES) {
fr_mag = magnitude(iot->max_frame[j], 15);
fr_mag = MAX(6, fr_mag);
col_w[j].fr = fr_mag;
tabrow_w += col_w[j].fr + 3;
snprintf(fr_mag_s, 3, "%u", fr_mag);
if (type == CALC_TYPE_FRAMES) {
fmt = g_strconcat(" %", fr_mag_s, "u |", NULL);
} else {
/* CALC_TYPE_FRAMES_AND_BYTES
*/
val_mag = magnitude(iot->max_vals[j], 15);
val_mag = MAX(5, val_mag);
col_w[j].val = val_mag;
tabrow_w += (col_w[j].val + 3);
snprintf(val_mag_s, 3, "%u", val_mag);
fmt = g_strconcat(" %", fr_mag_s, "u |", " %", val_mag_s, PRIu64 " |", NULL);
}
if (fmt)
fmts[j] = fmt;
continue;
}
switch (type) {
case CALC_TYPE_BYTES:
case CALC_TYPE_COUNT:
val_mag = magnitude(iot->max_vals[j], 15);
val_mag = MAX(5, val_mag);
col_w[j].val = val_mag;
snprintf(val_mag_s, 3, "%u", val_mag);
fmt = g_strconcat(" %", val_mag_s, PRIu64 " |", NULL);
break;
default:
ftype = proto_registrar_get_ftype(stat_cols[j]->hf_index);
switch (ftype) {
case FT_FLOAT:
case FT_DOUBLE:
val_mag = magnitude(iot->max_vals[j], 15);
snprintf(val_mag_s, 3, "%u", val_mag);
fmt = g_strconcat(" %", val_mag_s, ".6f |", NULL);
col_w[j].val = val_mag + 7;
break;
case FT_RELATIVE_TIME:
/* Convert FT_RELATIVE_TIME field to seconds
* CALC_TYPE_LOAD was already converted in iostat_packet() ) */
if (type == CALC_TYPE_LOAD) {
iot->max_vals[j] /= interval;
} else if (type != CALC_TYPE_AVG) {
iot->max_vals[j] = (iot->max_vals[j] + G_GUINT64_CONSTANT(500000000)) / NANOSECS_PER_SEC;
}
val_mag = magnitude(iot->max_vals[j], 15);
snprintf(val_mag_s, 3, "%u", val_mag);
fmt = g_strconcat(" %", val_mag_s, "u.%06u |", NULL);
col_w[j].val = val_mag + 7;
break;
default:
val_mag = magnitude(iot->max_vals[j], 15);
val_mag = MAX(namelen, val_mag);
col_w[j].val = val_mag;
snprintf(val_mag_s, 3, "%u", val_mag);
switch (ftype) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
case FT_UINT64:
fmt = g_strconcat(" %", val_mag_s, PRIu64 " |", NULL);
break;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
case FT_INT64:
fmt = g_strconcat(" %", val_mag_s, PRId64 " |", NULL);
break;
}
} /* End of ftype switch */
} /* End of calc_type switch */
tabrow_w += col_w[j].val + 3;
if (fmt)
fmts[j] = fmt;
} /* End of for loop (columns) */
borderlen = MAX(borderlen, tabrow_w);
/* Calc the max width of the list of filters. */
maxfltr_w = 0;
for (j=0; j<num_cols; j++) {
if (iot->filters[j]) {
k = (unsigned int) (strlen(iot->filters[j]) + 11);
maxfltr_w = MAX(maxfltr_w, k);
} else {
maxfltr_w = MAX(maxfltr_w, 26);
}
}
/* The stat table is not wrapped (by tshark) but filter is wrapped at the width of the stats table
* (which currently = borderlen); however, if the filter width exceeds the table width and the
* table width is less than 102 bytes, set borderlen to the lesser of the max filter width and 102.
* The filters will wrap at the lesser of borderlen-2 and the last space in the filter.
* NOTE: 102 is the typical size of a user window when the font is fixed width (e.g., COURIER 10).
* XXX: A pref could be added to change the max width from the default size of 102. */
if (maxfltr_w > borderlen && borderlen < 102)
borderlen = MIN(maxfltr_w, 102);
/* Prevent double right border by adding a space */
if (borderlen-tabrow_w == 1)
borderlen++;
/* Display the top border */
printf("\n");
for (i=0; i<borderlen; i++)
printf("=");
spaces = (char *)g_malloc(borderlen+1);
for (i=0; i<borderlen; i++)
spaces[i] = ' ';
spaces[borderlen] = '\0';
spaces_s = &spaces[16];
printf("\n| IO Statistics%s|\n", spaces_s);
spaces_s = &spaces[2];
printf("|%s|\n", spaces_s);
if (invl_prec == 0) {
invl_fmt = g_strconcat("%", dur_mag_s, "u", NULL);
full_fmt = g_strconcat("| Duration: ", invl_fmt, ".%6u secs%s|\n", NULL);
spaces_s = &spaces[25 + dur_mag];
printf(full_fmt, dur_secs_orig, dur_nsecs_orig, spaces_s);
g_free(full_fmt);
full_fmt = g_strconcat("| Interval: ", invl_fmt, " secs%s|\n", NULL);
spaces_s = &spaces[18 + dur_mag];
printf(full_fmt, (guint32)(interval/G_GUINT64_CONSTANT(1000000)), spaces_s);
} else {
snprintf(invl_prec_s, 3, "%u", invl_prec);
invl_fmt = g_strconcat("%", dur_mag_s, "u.%0", invl_prec_s, "u", NULL);
full_fmt = g_strconcat("| Duration: ", invl_fmt, " secs%s|\n", NULL);
spaces_s = &spaces[19 + dur_mag + invl_prec];
printf(full_fmt, dur_secs, dur_nsecs/(int)dv, spaces_s);
g_free(full_fmt);
full_fmt = g_strconcat("| Interval: ", invl_fmt, " secs%s|\n", NULL);
spaces_s = &spaces[19 + dur_mag + invl_prec];
printf(full_fmt, (guint32)(interval/G_GUINT64_CONSTANT(1000000)),
(guint32)((interval%G_GUINT64_CONSTANT(1000000))/dv), spaces_s);
}
g_free(full_fmt);
spaces_s = &spaces[2];
printf("|%s|\n", spaces_s);
/* Display the list of filters and their column numbers vertically */
printf("| Col");
for (j=0; j<num_cols; j++) {
printf((j == 0 ? "%2u: " : "| %2u: "), j+1);
if (!iot->filters[j]) {
/*
* An empty (no filter) comma field was specified */
spaces_s = &spaces[16 + 10];
printf("Frames and bytes%s|\n", spaces_s);
} else {
filter = iot->filters[j];
len_filt = (unsigned int) strlen(filter);
/* If the width of the widest filter exceeds the width of the stat table, borderlen has
* been set to 102 bytes above and filters wider than 102 will wrap at 91 bytes. */
if (len_filt+11 <= borderlen) {
printf("%s", filter);
if (len_filt+11 <= borderlen) {
spaces_s = &spaces[len_filt + 10];
printf("%s", spaces_s);
}
printf("|\n");
} else {
gchar *sfilter1, *sfilter2;
const gchar *pos;
gsize len;
unsigned int next_start, max_w = borderlen-11;
do {
if (len_filt > max_w) {
sfilter1 = g_strndup(filter, (gsize) max_w);
/*
* Find the pos of the last space in sfilter1. If a space is found, set
* sfilter2 to the string prior to that space and print it; otherwise, wrap
* the filter at max_w. */
pos = g_strrstr(sfilter1, " ");
if (pos) {
len = (gsize)(pos-sfilter1);
next_start = (unsigned int) len+1;
} else {
len = (gsize) strlen(sfilter1);
next_start = (unsigned int)len;
}
sfilter2 = g_strndup(sfilter1, len);
printf("%s%s|\n", sfilter2, &spaces[len+10]);
g_free(sfilter1);
g_free(sfilter2);
printf("| ");
filter = &filter[next_start];
len_filt = (unsigned int) strlen(filter);
} else {
printf("%s%s|\n", filter, &spaces[strlen(filter)+10]);
break;
}
} while (1);
}
}
}
printf("|-");
for (i=0; i<borderlen-3; i++) {
printf("-");
}
printf("|\n");
/* Display spaces above "Interval (s)" label */
spaces_s = &spaces[borderlen-(invl_col_w-2)];
printf("|%s|", spaces_s);
/* Display column number headers */
for (j=0; j<num_cols; j++) {
item = stat_cols[j];
if (item->calc_type == CALC_TYPE_FRAMES_AND_BYTES)
spaces_s = &spaces[borderlen - (col_w[j].fr + col_w[j].val)] - 3;
else if (item->calc_type == CALC_TYPE_FRAMES)
spaces_s = &spaces[borderlen - col_w[j].fr];
else
spaces_s = &spaces[borderlen - col_w[j].val];
printf("%-2d%s|", j+1, spaces_s);
}
if (tabrow_w < borderlen) {
filler_s = &spaces[tabrow_w+1];
printf("%s|", filler_s);
}
k = 11;
switch (timestamp_get_type()) {
case TS_ABSOLUTE:
printf("\n| Time ");
break;
case TS_ABSOLUTE_WITH_YMD:
case TS_ABSOLUTE_WITH_YDOY:
case TS_UTC_WITH_YMD:
case TS_UTC_WITH_YDOY:
printf("\n| Date and time");
k = 16;
break;
case TS_RELATIVE:
case TS_NOT_SET:
printf("\n| Interval");
break;
default:
break;
}
spaces_s = &spaces[borderlen-(invl_col_w-k)];
printf("%s|", spaces_s);
/* Display the stat label in each column */
for (j=0; j<num_cols; j++) {
type = stat_cols[j]->calc_type;
if (type == CALC_TYPE_FRAMES) {
printcenter (calc_type_table[type].func_name, col_w[j].fr, numpad);
} else if (type == CALC_TYPE_FRAMES_AND_BYTES) {
printcenter ("Frames", col_w[j].fr, numpad);
printcenter ("Bytes", col_w[j].val, numpad);
} else {
printcenter (calc_type_table[type].func_name, col_w[j].val, numpad);
}
}
if (filler_s)
printf("%s|", filler_s);
printf("\n|-");
for (i=0; i<tabrow_w-3; i++)
printf("-");
printf("|");
if (tabrow_w < borderlen)
printf("%s|", &spaces[tabrow_w+1]);
printf("\n");
t = 0;
if (invl_prec == 0 && dur_mag == 1)
full_fmt = g_strconcat("| ", invl_fmt, " <> ", invl_fmt, " |", NULL);
else
full_fmt = g_strconcat("| ", invl_fmt, " <> ", invl_fmt, " |", NULL);
if (interval == 0 || duration == 0) {
num_rows = 0;
} else {
num_rows = (unsigned int)(duration/interval) + ((unsigned int)(duration%interval) > 0 ? 1 : 0);
}
/* Load item_in_column with the first item in each column */
item_in_column = (io_stat_item_t **)g_malloc(sizeof(io_stat_item_t *) * num_cols);
for (j=0; j<num_cols; j++) {
item_in_column[j] = stat_cols[j];
}
/* Display the table values
*
* The outer loop is for time interval rows and the inner loop is for stat column items.*/
for (i=0; i<num_rows; i++) {
if (i == num_rows-1)
last_row = TRUE;
/* Compute the interval for this row */
if (!last_row) {
invl_end = t + interval;
} else {
invl_end = duration;
}
/* Patch for Absolute Time */
/* XXX - has a Y2.038K problem with 32-bit time_t */
the_time = (time_t)(iot->start_time + (t/G_GUINT64_CONSTANT(1000000)));
/* Display the interval for this row */
switch (timestamp_get_type()) {
case TS_ABSOLUTE:
tm_time = localtime(&the_time);
if (tm_time != NULL) {
printf("| %02d:%02d:%02d |",
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("| XX:XX:XX |");
break;
case TS_ABSOLUTE_WITH_YMD:
tm_time = localtime(&the_time);
if (tm_time != NULL) {
printf("| %04d-%02d-%02d %02d:%02d:%02d |",
tm_time->tm_year + 1900,
tm_time->tm_mon + 1,
tm_time->tm_mday,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("| XXXX-XX-XX XX:XX:XX |");
break;
case TS_ABSOLUTE_WITH_YDOY:
tm_time = localtime(&the_time);
if (tm_time != NULL) {
printf("| %04d/%03d %02d:%02d:%02d |",
tm_time->tm_year + 1900,
tm_time->tm_yday + 1,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("| XXXX/XXX XX:XX:XX |");
break;
case TS_UTC:
tm_time = gmtime(&the_time);
if (tm_time != NULL) {
printf("| %02d:%02d:%02d |",
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("| XX:XX:XX |");
break;
case TS_UTC_WITH_YMD:
tm_time = gmtime(&the_time);
if (tm_time != NULL) {
printf("| %04d-%02d-%02d %02d:%02d:%02d |",
tm_time->tm_year + 1900,
tm_time->tm_mon + 1,
tm_time->tm_mday,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("| XXXX-XX-XX XX:XX:XX |");
break;
case TS_UTC_WITH_YDOY:
tm_time = gmtime(&the_time);
if (tm_time != NULL) {
printf("| %04d/%03d %02d:%02d:%02d |",
tm_time->tm_year + 1900,
tm_time->tm_yday + 1,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("| XXXX/XXX XX:XX:XX |");
break;
case TS_RELATIVE:
case TS_NOT_SET:
if (invl_prec == 0) {
if (last_row) {
int maxw;
maxw = dur_mag >= 3 ? dur_mag+1 : 3;
g_free(full_fmt);
snprintf(dur_mag_s, 3, "%u", maxw);
full_fmt = g_strconcat( dur_mag == 1 ? "| " : "| ",
invl_fmt, " <> ", "%-",
dur_mag_s, "s|", NULL);
printf(full_fmt, (guint32)(t/G_GUINT64_CONSTANT(1000000)), "Dur");
} else {
printf(full_fmt, (guint32)(t/G_GUINT64_CONSTANT(1000000)),
(guint32)(invl_end/G_GUINT64_CONSTANT(1000000)));
}
} else {
printf(full_fmt, (guint32)(t/G_GUINT64_CONSTANT(1000000)),
(guint32)(t%G_GUINT64_CONSTANT(1000000) / dv),
(guint32)(invl_end/G_GUINT64_CONSTANT(1000000)),
(guint32)(invl_end%G_GUINT64_CONSTANT(1000000) / dv));
}
break;
/* case TS_DELTA:
case TS_DELTA_DIS:
case TS_EPOCH:
are not implemented */
default:
break;
}
/* Display stat values in each column for this row */
for (j=0; j<num_cols; j++) {
fmt = fmts[j];
item = item_in_column[j];
if (item) {
switch (item->calc_type) {
case CALC_TYPE_FRAMES:
printf(fmt, item->frames);
break;
case CALC_TYPE_BYTES:
case CALC_TYPE_COUNT:
printf(fmt, item->counter);
break;
case CALC_TYPE_FRAMES_AND_BYTES:
printf(fmt, item->frames, item->counter);
break;
case CALC_TYPE_SUM:
case CALC_TYPE_MIN:
case CALC_TYPE_MAX:
ftype = proto_registrar_get_ftype(stat_cols[j]->hf_index);
switch (ftype) {
case FT_FLOAT:
printf(fmt, item->float_counter);
break;
case FT_DOUBLE:
printf(fmt, item->double_counter);
break;
case FT_RELATIVE_TIME:
item->counter = (item->counter + G_GUINT64_CONSTANT(500)) / G_GUINT64_CONSTANT(1000);
printf(fmt,
(int)(item->counter/G_GUINT64_CONSTANT(1000000)),
(int)(item->counter%G_GUINT64_CONSTANT(1000000)));
break;
default:
printf(fmt, item->counter);
break;
}
break;
case CALC_TYPE_AVG:
num = item->num;
if (num == 0)
num = 1;
ftype = proto_registrar_get_ftype(stat_cols[j]->hf_index);
switch (ftype) {
case FT_FLOAT:
printf(fmt, item->float_counter/num);
break;
case FT_DOUBLE:
printf(fmt, item->double_counter/num);
break;
case FT_RELATIVE_TIME:
item->counter = ((item->counter / (guint64)num) + G_GUINT64_CONSTANT(500)) / G_GUINT64_CONSTANT(1000);
printf(fmt,
(int)(item->counter/G_GUINT64_CONSTANT(1000000)),
(int)(item->counter%G_GUINT64_CONSTANT(1000000)));
break;
default:
printf(fmt, item->counter / (guint64)num);
break;
}
break;
case CALC_TYPE_LOAD:
ftype = proto_registrar_get_ftype(stat_cols[j]->hf_index);
switch (ftype) {
case FT_RELATIVE_TIME:
if (!last_row) {
printf(fmt,
(int) (item->counter/interval),
(int)((item->counter%interval)*G_GUINT64_CONSTANT(1000000) / interval));
} else {
printf(fmt,
(int) (item->counter/(invl_end-t)),
(int)((item->counter%(invl_end-t))*G_GUINT64_CONSTANT(1000000) / (invl_end-t)));
}
break;
}
break;
}
if (last_row) {
g_free(fmt);
} else {
item_in_column[j] = item_in_column[j]->next;
}
} else {
printf(fmt, (guint64)0, (guint64)0);
}
}
if (filler_s)
printf("%s|", filler_s);
printf("\n");
t += interval;
}
for (i=0; i<borderlen; i++) {
printf("=");
}
printf("\n");
g_free(iot->items);
g_free(iot->max_vals);
g_free(iot->max_frame);
g_free(iot);
g_free(col_w);
g_free(invl_fmt);
g_free(full_fmt);
g_free(fmts);
g_free(spaces);
g_free(stat_cols);
g_free(item_in_column);
}
static void
register_io_tap(io_stat_t *io, unsigned int i, const char *filter)
{
GString *error_string;
const char *flt;
int j;
size_t namelen;
const char *p, *parenp;
char *field;
header_field_info *hfi;
io->items[i].prev = &io->items[i];
io->items[i].next = NULL;
io->items[i].parent = io;
io->items[i].start_time = 0;
io->items[i].calc_type = CALC_TYPE_FRAMES_AND_BYTES;
io->items[i].frames = 0;
io->items[i].counter = 0;
io->items[i].num = 0;
io->filters[i] = filter;
flt = filter;
field = NULL;
hfi = NULL;
for (j=0; calc_type_table[j].func_name; j++) {
namelen = strlen(calc_type_table[j].func_name);
if (filter && strncmp(filter, calc_type_table[j].func_name, namelen) == 0) {
io->items[i].calc_type = calc_type_table[j].calc_type;
io->items[i].colnum = i;
if (*(filter+namelen) == '(') {
p = filter+namelen+1;
parenp = strchr(p, ')');
if (!parenp) {
fprintf(stderr,
"\ntshark: Closing parenthesis missing from calculated expression.\n");
exit(10);
}
if (io->items[i].calc_type == CALC_TYPE_FRAMES || io->items[i].calc_type == CALC_TYPE_BYTES) {
if (parenp != p) {
fprintf(stderr,
"\ntshark: %s does not require or allow a field name within the parens.\n",
calc_type_table[j].func_name);
exit(10);
}
} else {
if (parenp == p) {
/* bail out if a field name was not specified */
fprintf(stderr, "\ntshark: You didn't specify a field name for %s(*).\n",
calc_type_table[j].func_name);
exit(10);
}
}
field = (char *)g_malloc(parenp-p+1);
memcpy(field, p, parenp-p);
field[parenp-p] = '\0';
flt = parenp + 1;
if (io->items[i].calc_type == CALC_TYPE_FRAMES || io->items[i].calc_type == CALC_TYPE_BYTES)
break;
hfi = proto_registrar_get_byname(field);
if (!hfi) {
fprintf(stderr, "\ntshark: There is no field named '%s'.\n",
field);
g_free(field);
exit(10);
}
io->items[i].hf_index = hfi->id;
break;
}
} else {
if (io->items[i].calc_type == CALC_TYPE_FRAMES || io->items[i].calc_type == CALC_TYPE_BYTES)
flt = "";
io->items[i].colnum = i;
}
}
if (hfi && !(io->items[i].calc_type == CALC_TYPE_BYTES ||
io->items[i].calc_type == CALC_TYPE_FRAMES ||
io->items[i].calc_type == CALC_TYPE_FRAMES_AND_BYTES)) {
/* check that the type is compatible */
switch (hfi->type) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
case FT_UINT64:
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
case FT_INT64:
/* these types support all calculations */
break;
case FT_FLOAT:
case FT_DOUBLE:
/* these types only support SUM, COUNT, MAX, MIN, AVG */
switch (io->items[i].calc_type) {
case CALC_TYPE_SUM:
case CALC_TYPE_COUNT:
case CALC_TYPE_MAX:
case CALC_TYPE_MIN:
case CALC_TYPE_AVG:
break;
default:
fprintf(stderr,
"\ntshark: %s is a float field, so %s(*) calculations are not supported on it.",
field,
calc_type_table[j].func_name);
exit(10);
}
break;
case FT_RELATIVE_TIME:
/* this type only supports SUM, COUNT, MAX, MIN, AVG, LOAD */
switch (io->items[i].calc_type) {
case CALC_TYPE_SUM:
case CALC_TYPE_COUNT:
case CALC_TYPE_MAX:
case CALC_TYPE_MIN:
case CALC_TYPE_AVG:
case CALC_TYPE_LOAD:
break;
default:
fprintf(stderr,
"\ntshark: %s is a relative-time field, so %s(*) calculations are not supported on it.",
field,
calc_type_table[j].func_name);
exit(10);
}
break;
default:
/*
* XXX - support all operations on floating-point
* numbers?
*/
if (io->items[i].calc_type != CALC_TYPE_COUNT) {
fprintf(stderr,
"\ntshark: %s doesn't have integral values, so %s(*) "
"calculations are not supported on it.\n",
field,
calc_type_table[j].func_name);
exit(10);
}
break;
}
}
g_free(field);
error_string = register_tap_listener("frame", &io->items[i], flt, TL_REQUIRES_PROTO_TREE, NULL,
iostat_packet, i ? NULL : iostat_draw, NULL);
if (error_string) {
g_free(io->items);
g_free(io);
fprintf(stderr, "\ntshark: Couldn't register io,stat tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static void
iostat_init(const char *opt_arg, void *userdata _U_)
{
gdouble interval_float;
guint32 idx = 0;
unsigned int i;
io_stat_t *io;
const gchar *filters, *str, *pos;
if ((*(opt_arg+(strlen(opt_arg)-1)) == ',') ||
(sscanf(opt_arg, "io,stat,%lf%n", &interval_float, (int *)&idx) != 1) ||
(idx < 8)) {
fprintf(stderr, "\ntshark: invalid \"-z io,stat,<interval>[,<filter>][,<filter>]...\" argument\n");
exit(1);
}
filters = opt_arg+idx;
if (*filters) {
if (*filters != ',') {
/* For locale's that use ',' instead of '.', the comma might
* have been consumed during the floating point conversion. */
--filters;
if (*filters != ',') {
fprintf(stderr, "\ntshark: invalid \"-z io,stat,<interval>[,<filter>][,<filter>]...\" argument\n");
exit(1);
}
}
} else
filters = NULL;
switch (timestamp_get_type()) {
case TS_DELTA:
case TS_DELTA_DIS:
case TS_EPOCH:
fprintf(stderr, "\ntshark: invalid -t operand. io,stat only supports -t <r|a|ad|adoy|u|ud|udoy>\n");
exit(1);
default:
break;
}
io = g_new(io_stat_t, 1);
/* If interval is 0, calculate statistics over the whole file by setting the interval to
* G_MAXUINT64 */
if (interval_float == 0) {
io->interval = G_MAXUINT64;
io->invl_prec = 0;
} else {
/* Set interval to the number of us rounded to the nearest integer */
io->interval = (guint64)(interval_float * 1000000.0 + 0.5);
/*
* Determine what interval precision the user has specified */
io->invl_prec = 6;
for (i=10; i<10000000; i*=10) {
if (io->interval%i > 0)
break;
io->invl_prec--;
}
if (io->invl_prec == 0) {
/* The precision is zero but if the user specified one of more zeros after the decimal point,
they want that many decimal places shown in the table for all time intervals except
response time values such as smb.time which always have 6 decimal places of precision.
This feature is useful in cases where for example the duration is 9.1, you specify an
interval of 1 and the last interval becomes "9 <> 9". If the interval is instead set to
1.1, the last interval becomes
last interval is rounded up to value that is greater than the duration. */
const gchar *invl_start = opt_arg+8;
gchar *intv_end;
int invl_len;
intv_end = g_strstr_len(invl_start, -1, ",");
invl_len = (int)(intv_end - invl_start);
invl_start = g_strstr_len(invl_start, invl_len, ".");
if (invl_start != NULL) {
invl_len = (int)(intv_end - invl_start - 1);
if (invl_len)
io->invl_prec = MIN(invl_len, 6);
}
}
}
if (io->interval < 1) {
fprintf(stderr,
"\ntshark: \"-z\" interval must be >=0.000001 seconds or \"0\" for the entire capture duration.\n");
exit(10);
}
/* Find how many ',' separated filters we have */
io->num_cols = 1;
io->start_time = 0;
if (filters && (*filters != '\0')) {
/* Eliminate the first comma. */
filters++;
str = filters;
while ((str = strchr(str, ','))) {
io->num_cols++;
str++;
}
}
io->items = g_new(io_stat_item_t, io->num_cols);
io->filters = (const char **)g_malloc(sizeof(char *) * io->num_cols);
io->max_vals = g_new(guint64, io->num_cols);
io->max_frame = g_new(guint32, io->num_cols);
for (i=0; i<io->num_cols; i++) {
io->max_vals[i] = 0;
io->max_frame[i] = 0;
}
/* Register a tap listener for each filter */
if ((!filters) || (filters[0] == 0)) {
register_io_tap(io, 0, NULL);
} else {
gchar *filter;
i = 0;
str = filters;
do {
pos = (gchar*) strchr(str, ',');
if (pos == str) {
register_io_tap(io, i, NULL);
} else if (pos == NULL) {
str = (const char*) g_strstrip((gchar*)str);
filter = g_strdup(str);
if (*filter)
register_io_tap(io, i, filter);
else
register_io_tap(io, i, NULL);
} else {
filter = (gchar *)g_malloc((pos-str)+1);
(void) g_strlcpy( filter, str, (gsize) ((pos-str)+1));
filter = g_strstrip(filter);
register_io_tap(io, i, (char *) filter);
}
str = pos+1;
i++;
} while (pos);
}
}
static stat_tap_ui iostat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"io,stat",
iostat_init,
0,
NULL
};
void
register_tap_listener_iostat(void)
{
register_stat_tap_ui(&iostat_ui, NULL);
} |
C | wireshark/ui/cli/tap-iousers.c | /* tap-iousers.c
* iostat 2003 Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/timestamp.h>
#include <wsutil/str_util.h>
#include <wsutil/cmdarg_err.h>
#include <ui/cli/tshark-tap.h>
typedef struct _io_users_t {
const char *type;
const char *filter;
conv_hash_t hash;
} io_users_t;
static void
iousers_draw(void *arg)
{
conv_hash_t *hash = (conv_hash_t*)arg;
io_users_t *iu = (io_users_t *)hash->user_data;
conv_item_t *iui;
guint64 last_frames, max_frames;
struct tm * tm_time;
guint i;
gboolean display_ports = (!strncmp(iu->type, "TCP", 3) || !strncmp(iu->type, "UDP", 3) || !strncmp(iu->type, "SCTP", 4)) ? TRUE : FALSE;
printf("================================================================================\n");
printf("%s Conversations\n", iu->type);
printf("Filter:%s\n", iu->filter ? iu->filter : "<No Filter>");
switch (timestamp_get_type()) {
case TS_ABSOLUTE:
case TS_UTC:
printf("%s | <- | | -> | | Total | Absolute Time | Duration |\n",
display_ports ? " " : "");
printf("%s | Frames Size | | Frames Size | | Frames Size | Start | |\n",
display_ports ? " " : "");
break;
case TS_ABSOLUTE_WITH_YMD:
case TS_ABSOLUTE_WITH_YDOY:
case TS_UTC_WITH_YMD:
case TS_UTC_WITH_YDOY:
printf("%s | <- | | -> | | Total | Absolute Date | Duration |\n",
display_ports ? " " : "");
printf("%s | Frames Size | | Frames Size | | Frames Size | Start | |\n",
display_ports ? " " : "");
break;
case TS_EPOCH:
printf("%s | <- | | -> | | Total | Relative | Duration |\n",
display_ports ? " " : "");
printf("%s | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n",
display_ports ? " " : "");
break;
case TS_RELATIVE:
case TS_NOT_SET:
default:
printf("%s | <- | | -> | | Total | Relative | Duration |\n",
display_ports ? " " : "");
printf("%s | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n",
display_ports ? " " : "");
break;
}
max_frames = UINT_MAX;
do {
last_frames = 0;
for (i=0; (iu->hash.conv_array && i < iu->hash.conv_array->len); i++) {
guint64 tot_frames;
iui = &g_array_index(iu->hash.conv_array, conv_item_t, i);
tot_frames = iui->rx_frames + iui->tx_frames;
if ((tot_frames > last_frames) && (tot_frames < max_frames)) {
last_frames = tot_frames;
}
}
for (i=0; (iu->hash.conv_array && i < iu->hash.conv_array->len); i++) {
guint64 tot_frames;
char *src_addr, *dst_addr;
iui = &g_array_index(iu->hash.conv_array, conv_item_t, i);
tot_frames = iui->rx_frames + iui->tx_frames;
if (tot_frames == last_frames) {
char *rx_bytes, *tx_bytes, *total_bytes;
rx_bytes = format_size(iui->rx_bytes, FORMAT_SIZE_UNIT_BYTES, 0);
tx_bytes = format_size(iui->tx_bytes, FORMAT_SIZE_UNIT_BYTES, 0);
total_bytes = format_size(iui->tx_bytes + iui->rx_bytes, FORMAT_SIZE_UNIT_BYTES, 0);
/* XXX - TODO: make name / port resolution configurable (through gbl_resolv_flags?) */
src_addr = get_conversation_address(NULL, &iui->src_address, TRUE);
dst_addr = get_conversation_address(NULL, &iui->dst_address, TRUE);
if (display_ports) {
char *src, *dst, *src_port, *dst_port;
src_port = get_conversation_port(NULL, iui->src_port, iui->ctype, TRUE);
dst_port = get_conversation_port(NULL, iui->dst_port, iui->ctype, TRUE);
src = wmem_strconcat(NULL, src_addr, ":", src_port, NULL);
dst = wmem_strconcat(NULL, dst_addr, ":", dst_port, NULL);
printf("%-26s <-> %-26s %6" PRIu64 " %-9s"
" %6" PRIu64 " %-9s"
" %6" PRIu64 " %-9s ",
src, dst,
iui->rx_frames, rx_bytes,
iui->tx_frames, tx_bytes,
iui->tx_frames+iui->rx_frames,
total_bytes
);
wmem_free(NULL, src_port);
wmem_free(NULL, dst_port);
wmem_free(NULL, src);
wmem_free(NULL, dst);
} else {
printf("%-20s <-> %-20s %6" PRIu64 " %-9s"
" %6" PRIu64 " %-9s"
" %6" PRIu64 " %-9s ",
src_addr, dst_addr,
iui->rx_frames, rx_bytes,
iui->tx_frames, tx_bytes,
iui->tx_frames+iui->rx_frames,
total_bytes
);
}
wmem_free(NULL, src_addr);
wmem_free(NULL, dst_addr);
wmem_free(NULL, rx_bytes);
wmem_free(NULL, tx_bytes);
wmem_free(NULL, total_bytes);
switch (timestamp_get_type()) {
case TS_ABSOLUTE:
tm_time = localtime(&iui->start_abs_time.secs);
if (tm_time != NULL) {
printf("%02d:%02d:%02d",
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("XX:XX:XX");
break;
case TS_ABSOLUTE_WITH_YMD:
tm_time = localtime(&iui->start_abs_time.secs);
if (tm_time != NULL) {
printf("%04d-%02d-%02d %02d:%02d:%02d",
tm_time->tm_year + 1900,
tm_time->tm_mon + 1,
tm_time->tm_mday,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("XXXX-XX-XX XX:XX:XX");
break;
case TS_ABSOLUTE_WITH_YDOY:
tm_time = localtime(&iui->start_abs_time.secs);
if (tm_time != NULL) {
printf("%04d/%03d %02d:%02d:%02d",
tm_time->tm_year + 1900,
tm_time->tm_yday + 1,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("XXXX/XXX XX:XX:XX");
break;
case TS_UTC:
tm_time = gmtime(&iui->start_abs_time.secs);
if (tm_time != NULL) {
printf("%02d:%02d:%02d",
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("XX:XX:XX");
break;
case TS_UTC_WITH_YMD:
tm_time = gmtime(&iui->start_abs_time.secs);
if (tm_time != NULL) {
printf("%04d-%02d-%02d %02d:%02d:%02d",
tm_time->tm_year + 1900,
tm_time->tm_mon + 1,
tm_time->tm_mday,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("XXXX-XX-XX XX:XX:XX");
break;
case TS_UTC_WITH_YDOY:
tm_time = gmtime(&iui->start_abs_time.secs);
if (tm_time != NULL) {
printf("%04d/%03d %02d:%02d:%02d",
tm_time->tm_year + 1900,
tm_time->tm_yday + 1,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
} else
printf("XXXX/XXX XX:XX:XX");
break;
case TS_EPOCH:
printf("%20.9f", nstime_to_sec(&iui->start_abs_time));
break;
case TS_RELATIVE:
case TS_NOT_SET:
default:
printf("%14.9f",
nstime_to_sec(&iui->start_time));
break;
}
printf(" %12.4f\n",
nstime_to_sec(&iui->stop_time) - nstime_to_sec(&iui->start_time));
}
}
max_frames = last_frames;
} while (last_frames);
printf("================================================================================\n");
}
void init_iousers(struct register_ct *ct, const char *filter)
{
io_users_t *iu;
GString *error_string;
iu = g_new0(io_users_t, 1);
iu->type = proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(ct)));
iu->filter = g_strdup(filter);
iu->hash.user_data = iu;
error_string = register_tap_listener(proto_get_protocol_filter_name(get_conversation_proto_id(ct)), &iu->hash, filter, 0, NULL, get_conversation_packet_func(ct), iousers_draw, NULL);
if (error_string) {
g_free(iu);
cmdarg_err("Couldn't register conversations tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-macltestat.c | /* tap-macltestat.c
* Copyright 2011 Martin Mathieson
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-mac-lte.h>
void register_tap_listener_mac_lte_stat(void);
/**********************************************/
/* Table column identifiers and title strings */
enum {
RNTI_COLUMN,
RNTI_TYPE_COLUMN,
UEID_COLUMN,
UL_FRAMES_COLUMN,
UL_BYTES_COLUMN,
UL_BW_COLUMN,
UL_PADDING_PERCENT_COLUMN,
UL_RETX_FRAMES_COLUMN,
DL_FRAMES_COLUMN,
DL_BYTES_COLUMN,
DL_BW_COLUMN,
DL_PADDING_PERCENT_COLUMN,
DL_CRC_FAILED_COLUMN,
DL_CRC_HIGH_CODE_RATE_COLUMN,
DL_CRC_PDSCH_LOST_COLUMN,
DL_CRC_DUPLICATE_NONZERO_RV_COLUMN,
DL_RETX_FRAMES_COLUMN,
NUM_UE_COLUMNS
};
static const gchar *ue_titles[] = { " RNTI", " Type", "UEId",
"UL Frames", "UL Bytes", "UL Mb/sec", " UL Pad %", "UL ReTX",
"DL Frames", "DL Bytes", "DL Mb/sec", " DL Pad %", "DL CRC Fail", "DL CRC HCR", "DL CRC PDSCH Lost", "DL CRC DupNonZeroRV", "DL ReTX"};
/* Stats for one UE */
typedef struct mac_lte_row_data {
/* Key for matching this row */
guint16 rnti;
guint8 rnti_type;
guint16 ueid;
gboolean is_predefined_data;
guint32 UL_frames;
guint32 UL_raw_bytes; /* all bytes */
guint32 UL_total_bytes; /* payload */
nstime_t UL_time_start;
nstime_t UL_time_stop;
guint32 UL_padding_bytes;
guint32 UL_CRC_errors;
guint32 UL_retx_frames;
guint32 DL_frames;
guint32 DL_raw_bytes; /* all bytes */
guint32 DL_total_bytes;
nstime_t DL_time_start;
nstime_t DL_time_stop;
guint32 DL_padding_bytes;
guint32 DL_CRC_failures;
guint32 DL_CRC_high_code_rate;
guint32 DL_CRC_PDSCH_lost;
guint32 DL_CRC_Duplicate_NonZero_RV;
guint32 DL_retx_frames;
} mac_lte_row_data;
/* One row/UE in the UE table */
typedef struct mac_lte_ep {
struct mac_lte_ep *next;
struct mac_lte_row_data stats;
} mac_lte_ep_t;
/* Common channel stats */
typedef struct mac_lte_common_stats {
guint32 all_frames;
guint32 mib_frames;
guint32 sib_frames;
guint32 sib_bytes;
guint32 pch_frames;
guint32 pch_bytes;
guint32 pch_paging_ids;
guint32 rar_frames;
guint32 rar_entries;
guint16 max_ul_ues_in_tti;
guint16 max_dl_ues_in_tti;
} mac_lte_common_stats;
/* Top-level struct for MAC LTE statistics */
typedef struct mac_lte_stat_t {
/* Common stats */
mac_lte_common_stats common_stats;
/* Keep track of unique rntis & ueids */
guint8 used_ueids[65535];
guint8 used_rntis[65535];
guint16 number_of_ueids;
guint16 number_of_rntis;
mac_lte_ep_t *ep_list;
} mac_lte_stat_t;
/* Reset the statistics window */
static void
mac_lte_stat_reset(void *phs)
{
mac_lte_stat_t *mac_lte_stat = (mac_lte_stat_t *)phs;
mac_lte_ep_t *list = mac_lte_stat->ep_list;
/* Reset counts of unique ueids & rntis */
memset(mac_lte_stat->used_ueids, 0, 65535);
mac_lte_stat->number_of_ueids = 0;
memset(mac_lte_stat->used_rntis, 0, 65535);
mac_lte_stat->number_of_rntis = 0;
/* Zero common stats */
memset(&(mac_lte_stat->common_stats), 0, sizeof(mac_lte_common_stats));
if (!list) {
return;
}
mac_lte_stat->ep_list = NULL;
}
/* Allocate a mac_lte_ep_t struct to store info for new UE */
static mac_lte_ep_t *alloc_mac_lte_ep(const struct mac_lte_tap_info *si, packet_info *pinfo _U_)
{
mac_lte_ep_t *ep;
if (!si) {
return NULL;
}
if (!(ep = g_new(mac_lte_ep_t, 1))) {
return NULL;
}
/* Copy SI data into ep->stats */
ep->stats.rnti = si->rnti;
ep->stats.rnti_type = si->rntiType;
ep->stats.ueid = si->ueid;
/* Counts for new UE are all 0 */
ep->stats.UL_frames = 0;
ep->stats.DL_frames = 0;
ep->stats.UL_total_bytes = 0;
ep->stats.UL_raw_bytes = 0;
ep->stats.UL_padding_bytes = 0;
ep->stats.DL_total_bytes = 0;
ep->stats.DL_raw_bytes = 0;
ep->stats.DL_padding_bytes = 0;
ep->stats.UL_CRC_errors = 0;
ep->stats.DL_CRC_failures = 0;
ep->stats.DL_CRC_high_code_rate = 0;
ep->stats.DL_CRC_PDSCH_lost = 0;
ep->stats.DL_CRC_Duplicate_NonZero_RV = 0;
ep->stats.UL_retx_frames = 0;
ep->stats.DL_retx_frames = 0;
ep->next = NULL;
return ep;
}
/* Update counts of unique rntis & ueids */
static void update_ueid_rnti_counts(guint16 rnti, guint16 ueid, mac_lte_stat_t *hs)
{
if (!hs->used_ueids[ueid]) {
hs->used_ueids[ueid] = TRUE;
hs->number_of_ueids++;
}
if (!hs->used_rntis[rnti]) {
hs->used_rntis[rnti] = TRUE;
hs->number_of_rntis++;
}
}
/* Process stat struct for a MAC LTE frame */
static tap_packet_status
mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
const void *phi, tap_flags_t flags _U_)
{
/* Get reference to stat window instance */
mac_lte_stat_t *hs = (mac_lte_stat_t *)phs;
mac_lte_ep_t *tmp = NULL, *te = NULL;
int i;
/* Cast tap info struct */
const struct mac_lte_tap_info *si = (const struct mac_lte_tap_info *)phi;
if (!hs) {
return TAP_PACKET_DONT_REDRAW;
}
hs->common_stats.all_frames++;
/* For common channels, just update global counters */
switch (si->rntiType) {
case P_RNTI:
hs->common_stats.pch_frames++;
hs->common_stats.pch_bytes += si->single_number_of_bytes;
hs->common_stats.pch_paging_ids += si->number_of_paging_ids;
return TAP_PACKET_REDRAW;
case SI_RNTI:
hs->common_stats.sib_frames++;
hs->common_stats.sib_bytes += si->single_number_of_bytes;
return TAP_PACKET_REDRAW;
case NO_RNTI:
hs->common_stats.mib_frames++;
return TAP_PACKET_REDRAW;
case RA_RNTI:
hs->common_stats.rar_frames++;
hs->common_stats.rar_entries += si->number_of_rars;
return TAP_PACKET_REDRAW;
case C_RNTI:
case SPS_RNTI:
/* Drop through for per-UE update */
break;
default:
/* Error */
return TAP_PACKET_DONT_REDRAW;
}
/* Check max UEs/tti counter */
switch (si->direction) {
case DIRECTION_UPLINK:
hs->common_stats.max_ul_ues_in_tti =
MAX(hs->common_stats.max_ul_ues_in_tti, si->ueInTTI);
break;
case DIRECTION_DOWNLINK:
hs->common_stats.max_dl_ues_in_tti =
MAX(hs->common_stats.max_dl_ues_in_tti, si->ueInTTI);
break;
}
/* For per-UE data, must create a new row if none already existing */
if (!hs->ep_list) {
/* Allocate new list */
hs->ep_list = alloc_mac_lte_ep(si, pinfo);
/* Make it the first/only entry */
te = hs->ep_list;
/* Update counts of unique ueids & rntis */
update_ueid_rnti_counts(si->rnti, si->ueid, hs);
} else {
/* Look among existing rows for this RNTI */
for (tmp = hs->ep_list;(tmp != NULL); tmp = tmp->next) {
/* Match only by RNTI and UEId together */
if ((tmp->stats.rnti == si->rnti) &&
(tmp->stats.ueid == si->ueid)) {
te = tmp;
break;
}
}
/* Not found among existing, so create a new one anyway */
if (te == NULL) {
if ((te = alloc_mac_lte_ep(si, pinfo))) {
/* Add new item to end of list */
mac_lte_ep_t *p = hs->ep_list;
while (p->next) {
p = p->next;
}
p->next = te;
te->next = NULL;
/* Update counts of unique ueids & rntis */
update_ueid_rnti_counts(si->rnti, si->ueid, hs);
}
}
}
/* Really should have a row pointer by now */
if (!te) {
return TAP_PACKET_DONT_REDRAW;
}
/* Update entry with details from si */
te->stats.rnti = si->rnti;
te->stats.is_predefined_data = si->isPredefinedData;
/* Uplink */
if (si->direction == DIRECTION_UPLINK) {
if (si->isPHYRetx) {
te->stats.UL_retx_frames++;
return TAP_PACKET_REDRAW;
}
if (si->crcStatusValid && (si->crcStatus != crc_success)) {
te->stats.UL_CRC_errors++;
return TAP_PACKET_REDRAW;
}
/* Update time range */
if (te->stats.UL_frames == 0) {
te->stats.UL_time_start = si->mac_lte_time;
}
te->stats.UL_time_stop = si->mac_lte_time;
te->stats.UL_frames++;
te->stats.UL_raw_bytes += si->raw_length;
te->stats.UL_padding_bytes += si->padding_bytes;
if (si->isPredefinedData) {
te->stats.UL_total_bytes += si->single_number_of_bytes;
}
else {
for (i = 0; i < MAC_LTE_DATA_LCID_COUNT_MAX; i++) {
te->stats.UL_total_bytes += si->bytes_for_lcid[i];
}
}
}
/* Downlink */
else {
if (si->isPHYRetx) {
te->stats.DL_retx_frames++;
return TAP_PACKET_REDRAW;
}
if (si->crcStatusValid && (si->crcStatus != crc_success)) {
switch (si->crcStatus) {
case crc_fail:
te->stats.DL_CRC_failures++;
break;
case crc_high_code_rate:
te->stats.DL_CRC_high_code_rate++;
break;
case crc_pdsch_lost:
te->stats.DL_CRC_PDSCH_lost++;
break;
case crc_duplicate_nonzero_rv:
te->stats.DL_CRC_Duplicate_NonZero_RV++;
break;
default:
/* Something went wrong! */
break;
}
return TAP_PACKET_REDRAW;
}
/* Update time range */
if (te->stats.DL_frames == 0) {
te->stats.DL_time_start = si->mac_lte_time;
}
te->stats.DL_time_stop = si->mac_lte_time;
te->stats.DL_frames++;
te->stats.DL_raw_bytes += si->raw_length;
te->stats.DL_padding_bytes += si->padding_bytes;
if (si->isPredefinedData) {
te->stats.DL_total_bytes += si->single_number_of_bytes;
}
else {
for (i = 0; i < MAC_LTE_DATA_LCID_COUNT_MAX; i++) {
te->stats.DL_total_bytes += si->bytes_for_lcid[i];
}
}
}
return TAP_PACKET_REDRAW;
}
/* Calculate and return a bandwidth figure, in Mbs */
static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, guint32 bytes)
{
/* Can only calculate bandwidth if have time delta */
if (memcmp(start_time, stop_time, sizeof(nstime_t)) != 0) {
float elapsed_ms = (((float)stop_time->secs - (float)start_time->secs) * 1000) +
(((float)stop_time->nsecs - (float)start_time->nsecs) / 1000000);
/* Only really meaningful if have a few frames spread over time...
For now at least avoid dividing by something very close to 0.0 */
if (elapsed_ms < 2.0) {
return 0.0f;
}
return ((bytes * 8) / elapsed_ms) / 1000;
}
else {
return 0.0f;
}
}
/* Output the accumulated stats */
static void
mac_lte_stat_draw(void *phs)
{
gint i;
guint16 number_of_ues = 0;
/* Deref the struct */
mac_lte_stat_t *hs = (mac_lte_stat_t *)phs;
mac_lte_ep_t *list = hs->ep_list, *tmp = 0;
/* System data */
printf("System data:\n");
printf("============\n");
printf("Max UL UEs/TTI: %u Max DL UEs/TTI: %u\n\n",
hs->common_stats.max_ul_ues_in_tti, hs->common_stats.max_dl_ues_in_tti);
/* Common channel data */
printf("Common channel data:\n");
printf("====================\n");
printf("MIBs: %u ", hs->common_stats.mib_frames);
printf("SIB Frames: %u ", hs->common_stats.sib_frames);
printf("SIB Bytes: %u ", hs->common_stats.sib_bytes);
printf("PCH Frames: %u ", hs->common_stats.pch_frames);
printf("PCH Bytes: %u ", hs->common_stats.pch_bytes);
printf("PCH Paging IDs: %u ", hs->common_stats.pch_paging_ids);
printf("RAR Frames: %u ", hs->common_stats.rar_frames);
printf("RAR Entries: %u\n\n", hs->common_stats.rar_entries);
/* Per-UE table entries */
/* Set title to show how many UEs in table */
for (tmp = list; (tmp!=NULL); tmp=tmp->next, number_of_ues++);
printf("UL/DL-SCH data (%u entries - %u unique RNTIs, %u unique UEIds):\n",
number_of_ues, hs->number_of_rntis, hs->number_of_ueids);
printf("==================================================================\n");
/* Show column titles */
for (i=0; i < NUM_UE_COLUMNS; i++) {
printf("%s ", ue_titles[i]);
}
printf("\n");
/* Write a row for each UE */
for (tmp = list; tmp; tmp=tmp->next) {
/* Calculate bandwidth */
float UL_bw = calculate_bw(&tmp->stats.UL_time_start,
&tmp->stats.UL_time_stop,
tmp->stats.UL_total_bytes);
float DL_bw = calculate_bw(&tmp->stats.DL_time_start,
&tmp->stats.DL_time_stop,
tmp->stats.DL_total_bytes);
printf("%5u %7s %5u %10u %9u %10f %10f %8u %10u %9u %10f %10f %12u %11u %18u %20u %8u\n",
tmp->stats.rnti,
(tmp->stats.rnti_type == C_RNTI) ? "C-RNTI" : "SPS-RNTI",
tmp->stats.ueid,
tmp->stats.UL_frames,
tmp->stats.UL_total_bytes,
UL_bw,
tmp->stats.UL_raw_bytes ?
(((float)tmp->stats.UL_padding_bytes / (float)tmp->stats.UL_raw_bytes) * 100.0) :
0.0,
tmp->stats.UL_retx_frames,
tmp->stats.DL_frames,
tmp->stats.DL_total_bytes,
DL_bw,
tmp->stats.DL_raw_bytes ?
(((float)tmp->stats.DL_padding_bytes / (float)tmp->stats.DL_raw_bytes) * 100.0) :
0.0,
tmp->stats.DL_CRC_failures,
tmp->stats.DL_CRC_high_code_rate,
tmp->stats.DL_CRC_PDSCH_lost,
tmp->stats.DL_CRC_Duplicate_NonZero_RV,
tmp->stats.DL_retx_frames);
}
}
/* Create a new MAC LTE stats struct */
static void mac_lte_stat_init(const char *opt_arg, void *userdata _U_)
{
mac_lte_stat_t *hs;
const char *filter = NULL;
GString *error_string;
/* Check for a filter string */
if (strncmp(opt_arg, "mac-lte,stat,", 13) == 0) {
/* Skip those characters from filter to display */
filter = opt_arg + 13;
}
else {
/* No filter */
filter = NULL;
}
/* Create struct */
hs = g_new0(mac_lte_stat_t, 1);
hs->ep_list = NULL;
error_string = register_tap_listener("mac-lte", hs,
filter, 0,
mac_lte_stat_reset,
mac_lte_stat_packet,
mac_lte_stat_draw,
NULL);
if (error_string) {
g_string_free(error_string, TRUE);
g_free(hs);
exit(1);
}
}
static stat_tap_ui mac_lte_stat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"mac-lte,stat",
mac_lte_stat_init,
0,
NULL
};
/* Register this tap listener (need void on own so line register function found) */
void
register_tap_listener_mac_lte_stat(void)
{
register_stat_tap_ui(&mac_lte_stat_ui, NULL);
} |
C | wireshark/ui/cli/tap-protocolinfo.c | /* tap-protocolinfo.c
* protohierstat 2002 Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides Protocol Column Info tap for tshark */
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "epan/epan_dissect.h"
#include "epan/column-utils.h"
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_protocolinfo(void);
typedef struct _pci_t {
char *filter;
int hf_index;
} pci_t;
static tap_packet_status
protocolinfo_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, const void *dummy _U_, tap_flags_t flags _U_)
{
pci_t *rs = (pci_t *)prs;
GPtrArray *gp;
guint i;
char *str;
/*
* XXX - there needs to be a way for "protocolinfo_init()" to
* find out whether the columns are being generated and, if not,
* to report an error and exit, as the whole point of this tap
* is to modify the columns, and if the columns aren't being
* displayed, that makes this tap somewhat pointless.
*
* To prevent a crash, we check whether INFO column is writable
* and, if not, we report that error and exit.
*
* XXX - report the error and just return TAP_PACKET_FAILED?
*/
if (!col_get_writable(pinfo->cinfo, COL_INFO)) {
cmdarg_err("the proto,colinfo tap doesn't work if the INFO column isn't being printed.");
exit(1);
}
gp = proto_get_finfo_ptr_array(edt->tree, rs->hf_index);
if (!gp) {
return TAP_PACKET_DONT_REDRAW;
}
for (i=0; i<gp->len; i++) {
str = (char *)proto_construct_match_selected_string((field_info *)gp->pdata[i], NULL);
if (str) {
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", str);
wmem_free(NULL, str);
}
}
return TAP_PACKET_DONT_REDRAW;
}
static void
protocolinfo_init(const char *opt_arg, void *userdata _U_)
{
pci_t *rs;
const char *field = NULL;
const char *filter = NULL;
header_field_info *hfi;
GString *error_string;
if (!strncmp("proto,colinfo,", opt_arg, 14)) {
filter = opt_arg+14;
field = strchr(filter, ',');
if (field) {
field += 1; /* skip the ',' */
}
}
if (!field) {
cmdarg_err("invalid \"-z proto,colinfo,<filter>,<field>\" argument");
exit(1);
}
hfi = proto_registrar_get_byname(field);
if (!hfi) {
cmdarg_err("Field \"%s\" doesn't exist.", field);
exit(1);
}
rs = g_new(pci_t, 1);
rs->hf_index = hfi->id;
if ((field-filter) > 1) {
rs->filter = (char *)g_malloc(field-filter);
(void) g_strlcpy(rs->filter, filter, (field-filter));
} else {
rs->filter = NULL;
}
error_string = register_tap_listener("frame", rs, rs->filter, TL_REQUIRES_PROTO_TREE, NULL, protocolinfo_packet, NULL, NULL);
if (error_string) {
/* error, we failed to attach to the tap. complain and clean up */
cmdarg_err("Couldn't register proto,colinfo tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
g_free(rs->filter);
g_free(rs);
exit(1);
}
}
static stat_tap_ui protocolinfo_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"proto,colinfo",
protocolinfo_init,
0,
NULL
};
void
register_tap_listener_protocolinfo(void)
{
register_stat_tap_ui(&protocolinfo_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-protohierstat.c | /* tap-protohierstat.c
* protohierstat 2002 Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides ProtocolHierarchyStatistics for tshark */
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "epan/epan_dissect.h"
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <wsutil/cmdarg_err.h>
#include "tap-protohierstat.h"
int pc_proto_id = -1;
void register_tap_listener_protohierstat(void);
phs_t *
new_phs_t(phs_t *parent, const char *filter)
{
phs_t *rs;
rs = g_new(phs_t, 1);
rs->sibling = NULL;
rs->child = NULL;
rs->parent = parent;
rs->filter = NULL;
if (filter != NULL) {
rs->filter = g_strdup(filter);
}
rs->protocol = -1;
rs->proto_name = NULL;
rs->frames = 0;
rs->bytes = 0;
return rs;
}
void
free_phs(phs_t *rs)
{
if (!rs) {
return;
}
if (rs->filter) {
g_free(rs->filter);
rs->filter = NULL;
}
if (rs->sibling)
{
free_phs(rs->sibling);
rs->sibling = NULL;
}
if (rs->child)
{
free_phs(rs->child);
rs->child = NULL;
}
g_free(rs);
}
tap_packet_status
protohierstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, const void *dummy _U_, tap_flags_t flags _U_)
{
phs_t *rs = (phs_t *)prs;
phs_t *tmprs;
proto_node *node;
field_info *fi;
if (!edt) {
return TAP_PACKET_DONT_REDRAW;
}
if (!edt->tree) {
return TAP_PACKET_DONT_REDRAW;
}
if (!edt->tree->first_child) {
return TAP_PACKET_DONT_REDRAW;
}
for (node=edt->tree->first_child; node; node=node->next) {
fi = PNODE_FINFO(node);
/*
* If the first child is a tree of comments, skip over it.
* This keeps us from having a top-level "pkt_comment"
* entry that represents a nonexistent protocol,
* and matches how the GUI treats comments.
*/
if (G_UNLIKELY(fi->hfinfo->id == pc_proto_id)) {
continue;
}
/* first time we saw a protocol at this leaf */
if (rs->protocol == -1) {
rs->protocol = fi->hfinfo->id;
rs->proto_name = fi->hfinfo->abbrev;
rs->frames = 1;
rs->bytes = pinfo->fd->pkt_len;
rs->child = new_phs_t(rs, NULL);
rs = rs->child;
continue;
}
/* find this protocol in the list of siblings */
for (tmprs=rs; tmprs; tmprs=tmprs->sibling) {
if (tmprs->protocol == fi->hfinfo->id) {
break;
}
}
/* not found, then we must add it to the end of the list */
if (!tmprs) {
for (tmprs=rs; tmprs->sibling; tmprs=tmprs->sibling)
;
tmprs->sibling = new_phs_t(rs->parent, NULL);
rs = tmprs->sibling;
rs->protocol = fi->hfinfo->id;
rs->proto_name = fi->hfinfo->abbrev;
} else {
rs = tmprs;
}
rs->frames++;
rs->bytes += pinfo->fd->pkt_len;
if (!rs->child) {
rs->child = new_phs_t(rs, NULL);
}
rs = rs->child;
}
return TAP_PACKET_REDRAW;
}
static void
phs_draw(phs_t *rs, int indentation)
{
int i, stroff;
#define MAXPHSLINE 80
char str[MAXPHSLINE];
for (;rs;rs = rs->sibling) {
if (rs->protocol == -1) {
return;
}
str[0] = 0;
stroff = 0;
for (i=0; i<indentation; i++) {
if (i > 15) {
stroff += snprintf(str+stroff, MAXPHSLINE-stroff, "...");
break;
}
stroff += snprintf(str+stroff, MAXPHSLINE-stroff, " ");
}
snprintf(str+stroff, MAXPHSLINE-stroff, "%s", rs->proto_name);
printf("%-40s frames:%u bytes:%" PRIu64 "\n", str, rs->frames, rs->bytes);
phs_draw(rs->child, indentation+1);
}
}
static void
protohierstat_draw(void *prs)
{
phs_t *rs = (phs_t *)prs;
printf("\n");
printf("===================================================================\n");
printf("Protocol Hierarchy Statistics\n");
printf("Filter: %s\n\n", rs->filter ? rs->filter : "");
phs_draw(rs, 0);
printf("===================================================================\n");
}
static void
protohierstat_init(const char *opt_arg, void *userdata _U_)
{
phs_t *rs;
int pos = 0;
const char *filter = NULL;
GString *error_string;
if (strcmp("io,phs", opt_arg) == 0) {
/* No arguments */
} else if (sscanf(opt_arg, "io,phs,%n", &pos) == 0) {
if (pos) {
filter = opt_arg+pos;
}
} else {
cmdarg_err("invalid \"-z io,phs[,<filter>]\" argument");
exit(1);
}
pc_proto_id = proto_registrar_get_id_byname("pkt_comment");
rs = new_phs_t(NULL, filter);
error_string = register_tap_listener("frame", rs, filter, TL_REQUIRES_PROTO_TREE, NULL, protohierstat_packet, protohierstat_draw, NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
free_phs(rs);
cmdarg_err("Couldn't register io,phs tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui protohierstat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"io,phs",
protohierstat_init,
0,
NULL
};
void
register_tap_listener_protohierstat(void)
{
register_stat_tap_ui(&protohierstat_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C/C++ | wireshark/ui/cli/tap-protohierstat.h | /** @file
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_PROTO_HIER_STAT_H__
#define __TAP_PROTO_HIER_STAT_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern int pc_proto_id;
typedef struct _phs_t {
struct _phs_t *sibling;
struct _phs_t *child;
struct _phs_t *parent;
char *filter;
int protocol;
const char *proto_name;
guint32 frames;
guint64 bytes;
} phs_t;
extern phs_t * new_phs_t(phs_t *parent, const char *filter);
extern void free_phs(phs_t *rs);
extern tap_packet_status protohierstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, const void *dummy _U_, tap_flags_t flags _U_);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_PROTO_HIER_STAT_H__ */
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-rlcltestat.c | /* tap-rlclte_stat.c
* Copyright 2011 Martin Mathieson
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-rlc-lte.h>
void register_tap_listener_rlc_lte_stat(void);
enum {
UEID_COLUMN,
UL_FRAMES_COLUMN,
UL_BYTES_COLUMN,
UL_BW_COLUMN,
UL_ACKS_COLUMN,
UL_NACKS_COLUMN,
UL_MISSING_COLUMN,
DL_FRAMES_COLUMN,
DL_BYTES_COLUMN,
DL_BW_COLUMN,
DL_ACKS_COLUMN,
DL_NACKS_COLUMN,
DL_MISSING_COLUMN,
NUM_UE_COLUMNS
};
static const gchar *ue_titles[] = { " UEId",
"UL Frames", "UL Bytes", " UL Mbs", "UL ACKs", "UL NACKs", "UL Missed",
"DL Frames", "DL Bytes", " DL Mbs", "DL ACKs", "DL NACKs", "DL Missed"};
/* Stats for one UE */
typedef struct rlc_lte_row_data {
/* Key for matching this row */
guint16 ueid;
gboolean is_predefined_data;
guint32 UL_frames;
guint32 UL_total_bytes;
nstime_t UL_time_start;
nstime_t UL_time_stop;
guint32 UL_total_acks;
guint32 UL_total_nacks;
guint32 UL_total_missing;
guint32 DL_frames;
guint32 DL_total_bytes;
nstime_t DL_time_start;
nstime_t DL_time_stop;
guint32 DL_total_acks;
guint32 DL_total_nacks;
guint32 DL_total_missing;
} rlc_lte_row_data;
/* Common channel stats */
typedef struct rlc_lte_common_stats {
guint32 bcch_frames;
guint32 bcch_bytes;
guint32 pcch_frames;
guint32 pcch_bytes;
} rlc_lte_common_stats;
/* One row/UE in the UE table */
typedef struct rlc_lte_ep {
struct rlc_lte_ep *next;
struct rlc_lte_row_data stats;
} rlc_lte_ep_t;
/* Used to keep track of all RLC LTE statistics */
typedef struct rlc_lte_stat_t {
rlc_lte_ep_t *ep_list;
guint32 total_frames;
/* Common stats */
rlc_lte_common_stats common_stats;
} rlc_lte_stat_t;
/* Reset RLC stats */
static void
rlc_lte_stat_reset(void *phs)
{
rlc_lte_stat_t *rlc_lte_stat = (rlc_lte_stat_t *)phs;
rlc_lte_ep_t *list = rlc_lte_stat->ep_list;
rlc_lte_stat->total_frames = 0;
memset(&rlc_lte_stat->common_stats, 0, sizeof(rlc_lte_common_stats));
if (!list) {
return;
}
rlc_lte_stat->ep_list = NULL;
}
/* Allocate a rlc_lte_ep_t struct to store info for new UE */
static rlc_lte_ep_t *alloc_rlc_lte_ep(const struct rlc_lte_tap_info *si, packet_info *pinfo _U_)
{
rlc_lte_ep_t *ep;
if (!si) {
return NULL;
}
if (!(ep = g_new(rlc_lte_ep_t, 1))) {
return NULL;
}
/* Copy SI data into ep->stats */
ep->stats.ueid = si->ueid;
/* Counts for new UE are all 0 */
ep->stats.UL_frames = 0;
ep->stats.DL_frames = 0;
ep->stats.UL_total_bytes = 0;
ep->stats.DL_total_bytes = 0;
memset(&ep->stats.DL_time_start, 0, sizeof(nstime_t));
memset(&ep->stats.DL_time_stop, 0, sizeof(nstime_t));
ep->stats.UL_total_acks = 0;
ep->stats.DL_total_acks = 0;
ep->stats.UL_total_nacks = 0;
ep->stats.DL_total_nacks = 0;
ep->stats.UL_total_missing = 0;
ep->stats.DL_total_missing = 0;
ep->next = NULL;
return ep;
}
/* Process stat struct for a RLC LTE frame */
static tap_packet_status
rlc_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
const void *phi, tap_flags_t flags _U_)
{
/* Get reference to stats struct */
rlc_lte_stat_t *hs = (rlc_lte_stat_t *)phs;
rlc_lte_ep_t *tmp = NULL, *te = NULL;
/* Cast tap info struct */
const struct rlc_lte_tap_info *si = (const struct rlc_lte_tap_info *)phi;
/* Need this */
if (!hs) {
return TAP_PACKET_DONT_REDRAW;
}
/* Inc top-level frame count */
hs->total_frames++;
/* Common channel stats */
switch (si->channelType) {
case CHANNEL_TYPE_BCCH_BCH:
case CHANNEL_TYPE_BCCH_DL_SCH:
hs->common_stats.bcch_frames++;
hs->common_stats.bcch_bytes += si->pduLength;
return TAP_PACKET_REDRAW;
case CHANNEL_TYPE_PCCH:
hs->common_stats.pcch_frames++;
hs->common_stats.pcch_bytes += si->pduLength;
return TAP_PACKET_REDRAW;
default:
break;
}
/* For per-UE data, must create a new row if none already existing */
if (!hs->ep_list) {
/* Allocate new list */
hs->ep_list = alloc_rlc_lte_ep(si, pinfo);
/* Make it the first/only entry */
te = hs->ep_list;
} else {
/* Look among existing rows for this UEId */
for (tmp = hs->ep_list; (tmp != NULL); tmp = tmp->next) {
if (tmp->stats.ueid == si->ueid) {
te = tmp;
break;
}
}
/* Not found among existing, so create a new one anyway */
if (te == NULL) {
if ((te = alloc_rlc_lte_ep(si, pinfo))) {
/* Add new item to end of list */
rlc_lte_ep_t *p = hs->ep_list;
while (p->next) {
p = p->next;
}
p->next = te;
te->next = NULL;
}
}
}
/* Really should have a row pointer by now */
if (!te) {
return TAP_PACKET_DONT_REDRAW;
}
/* Update entry with details from si */
te->stats.ueid = si->ueid;
/* Top-level traffic stats */
if (si->direction == DIRECTION_UPLINK) {
/* Update time range */
if (te->stats.UL_frames == 0) {
te->stats.UL_time_start = si->rlc_lte_time;
}
te->stats.UL_time_stop = si->rlc_lte_time;
te->stats.UL_frames++;
te->stats.UL_total_bytes += si->pduLength;
}
else {
/* Update time range */
if (te->stats.DL_frames == 0) {
te->stats.DL_time_start = si->rlc_lte_time;
}
te->stats.DL_time_stop = si->rlc_lte_time;
te->stats.DL_frames++;
te->stats.DL_total_bytes += si->pduLength;
}
if (si->direction == DIRECTION_UPLINK) {
if (si->isControlPDU) {
te->stats.UL_total_acks++;
}
te->stats.UL_total_nacks += si->noOfNACKs;
te->stats.UL_total_missing += si->missingSNs;
}
else {
if (si->isControlPDU) {
te->stats.DL_total_acks++;
}
te->stats.DL_total_nacks += si->noOfNACKs;
te->stats.DL_total_missing += si->missingSNs;
}
return TAP_PACKET_REDRAW;
}
/* Calculate and return a bandwidth figure, in Mbs */
static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, guint32 bytes)
{
/* Can only calculate bandwidth if have time delta */
if (memcmp(start_time, stop_time, sizeof(nstime_t)) != 0) {
float elapsed_ms = (((float)stop_time->secs - (float)start_time->secs) * 1000) +
(((float)stop_time->nsecs - (float)start_time->nsecs) / 1000000);
/* Only really meaningful if have a few frames spread over time...
For now at least avoid dividing by something very close to 0.0 */
if (elapsed_ms < 2.0) {
return 0.0f;
}
return ((bytes * 8) / elapsed_ms) / 1000;
}
else {
return 0.0f;
}
}
/* (Re)draw RLC stats */
static void
rlc_lte_stat_draw(void *phs)
{
guint16 number_of_ues = 0;
gint i;
/* Look up the statistics struct */
rlc_lte_stat_t *hs = (rlc_lte_stat_t *)phs;
rlc_lte_ep_t *list = hs->ep_list, *tmp = 0;
/* Common channel data */
printf("Common Data:\n");
printf("==============\n");
printf("BCCH Frames: %u BCCH Bytes: %u PCCH Frames: %u PCCH Bytes: %u\n\n",
hs->common_stats.bcch_frames, hs->common_stats.bcch_bytes,
hs->common_stats.pcch_frames, hs->common_stats.pcch_bytes);
/* Per-UE table entries */
/* Set title that shows how many UEs currently in table */
for (tmp = list; (tmp!=NULL); tmp=tmp->next, number_of_ues++);
printf("Per UE Data - %u UEs (%u frames)\n", number_of_ues, hs->total_frames);
printf("==========================================\n");
/* Show column titles */
for (i=0; i < NUM_UE_COLUMNS; i++) {
printf("%s ", ue_titles[i]);
}
printf("\n");
/* For each row/UE in the model */
for (tmp = list; tmp; tmp=tmp->next) {
/* Calculate bandwidth */
float UL_bw = calculate_bw(&tmp->stats.UL_time_start,
&tmp->stats.UL_time_stop,
tmp->stats.UL_total_bytes);
float DL_bw = calculate_bw(&tmp->stats.DL_time_start,
&tmp->stats.DL_time_stop,
tmp->stats.DL_total_bytes);
printf("%5u %10u %9u %10f %8u %9u %10u %10u %9u %10f %8u %9u %10u\n",
tmp->stats.ueid,
tmp->stats.UL_frames,
tmp->stats.UL_total_bytes, UL_bw,
tmp->stats.UL_total_acks,
tmp->stats.UL_total_nacks,
tmp->stats.UL_total_missing,
tmp->stats.DL_frames,
tmp->stats.DL_total_bytes, DL_bw,
tmp->stats.DL_total_acks,
tmp->stats.DL_total_nacks,
tmp->stats.DL_total_missing);
}
}
/* Create a new RLC LTE stats struct */
static void rlc_lte_stat_init(const char *opt_arg, void *userdata _U_)
{
rlc_lte_stat_t *hs;
const char *filter = NULL;
GString *error_string;
/* Check for a filter string */
if (strncmp(opt_arg, "rlc-lte,stat,", 13) == 0) {
/* Skip those characters from filter to display */
filter = opt_arg + 13;
}
else {
/* No filter */
filter = NULL;
}
/* Create top-level struct */
hs = g_new0(rlc_lte_stat_t, 1);
hs->ep_list = NULL;
/**********************************************/
/* Register the tap listener */
/**********************************************/
error_string = register_tap_listener("rlc-lte", hs,
filter, 0,
rlc_lte_stat_reset,
rlc_lte_stat_packet,
rlc_lte_stat_draw,
NULL);
if (error_string) {
g_string_free(error_string, TRUE);
g_free(hs);
exit(1);
}
}
/* Register this tap listener (need void on own so line register function found) */
static stat_tap_ui rlc_lte_stat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"rlc-lte,stat",
rlc_lte_stat_init,
0,
NULL
};
void
register_tap_listener_rlc_lte_stat(void)
{
register_stat_tap_ui(&rlc_lte_stat_ui, NULL);
} |
C | wireshark/ui/cli/tap-rpcprogs.c | /* tap-rpcprogs.c
* rpcstat 2002 Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides rpc call/reply SRT statistics to tshark.
* It is only used by tshark and not wireshark
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-rpc.h>
#include <wsutil/cmdarg_err.h>
#define MICROSECS_PER_SEC 1000000
#define NANOSECS_PER_SEC 1000000000
void register_tap_listener_rpcprogs(void);
/* used to keep track of statistics for a specific program/version */
typedef struct _rpc_program_t {
struct _rpc_program_t *next;
guint32 program;
guint32 version;
int num;
nstime_t min;
nstime_t max;
nstime_t tot;
} rpc_program_t;
static rpc_program_t *prog_list = NULL;
static int already_enabled = 0;
static tap_packet_status
rpcprogs_packet(void *dummy1 _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri, tap_flags_t flags _U_)
{
const rpc_call_info_value *ri = (const rpc_call_info_value *)pri;
nstime_t delta;
rpc_program_t *rp = NULL;
if (!prog_list) {
/* the list was empty */
rp = g_new(rpc_program_t, 1);
rp->next = NULL;
rp->program = ri->prog;
rp->version = ri->vers;
rp->num = 0;
rp->min.secs = 0;
rp->min.nsecs = 0;
rp->max.secs = 0;
rp->max.nsecs = 0;
rp->tot.secs = 0;
rp->tot.nsecs = 0;
prog_list = rp;
} else if ((ri->prog == prog_list->program)
&& (ri->vers == prog_list->version)) {
rp = prog_list;
} else if ( (ri->prog < prog_list->program)
|| ((ri->prog == prog_list->program) && (ri->vers < prog_list->version))) {
/* we should be first entry in list */
rp = g_new(rpc_program_t, 1);
rp->next = prog_list;
rp->program = ri->prog;
rp->version = ri->vers;
rp->num = 0;
rp->min.secs = 0;
rp->min.nsecs = 0;
rp->max.secs = 0;
rp->max.nsecs = 0;
rp->tot.secs = 0;
rp->tot.nsecs = 0;
prog_list = rp;
} else {
/* we go somewhere else in the list */
for (rp=prog_list; rp; rp=rp->next) {
if ((rp->next)
&& (rp->next->program == ri->prog)
&& (rp->next->version == ri->vers)) {
rp = rp->next;
break;
}
if ((!rp->next)
|| (rp->next->program > ri->prog)
|| ( (rp->next->program == ri->prog)
&& (rp->next->version > ri->vers))) {
rpc_program_t *trp;
trp = g_new(rpc_program_t, 1);
trp->next = rp->next;
trp->program = ri->prog;
trp->version = ri->vers;
trp->num = 0;
trp->min.secs = 0;
trp->min.nsecs = 0;
trp->max.secs = 0;
trp->max.nsecs = 0;
trp->tot.secs = 0;
trp->tot.nsecs = 0;
rp->next = trp;
rp = trp;
break;
}
}
}
/* we are only interested in reply packets */
if (ri->request || !rp) {
return TAP_PACKET_DONT_REDRAW;
}
/* calculate time delta between request and reply */
nstime_delta(&delta, &pinfo->abs_ts, &ri->req_time);
if ((rp->max.secs == 0)
&& (rp->max.nsecs == 0) ) {
rp->max.secs = delta.secs;
rp->max.nsecs = delta.nsecs;
}
if ((rp->min.secs == 0)
&& (rp->min.nsecs == 0) ) {
rp->min.secs = delta.secs;
rp->min.nsecs = delta.nsecs;
}
if ( (delta.secs < rp->min.secs)
|| ( (delta.secs == rp->min.secs)
&& (delta.nsecs < rp->min.nsecs) ) ) {
rp->min.secs = delta.secs;
rp->min.nsecs = delta.nsecs;
}
if ( (delta.secs > rp->max.secs)
|| ( (delta.secs == rp->max.secs)
&& (delta.nsecs > rp->max.nsecs) ) ) {
rp->max.secs = delta.secs;
rp->max.nsecs = delta.nsecs;
}
rp->tot.secs += delta.secs;
rp->tot.nsecs += delta.nsecs;
if (rp->tot.nsecs > NANOSECS_PER_SEC) {
rp->tot.nsecs -= NANOSECS_PER_SEC;
rp->tot.secs++;
}
rp->num++;
return TAP_PACKET_REDRAW;
}
static void
rpcprogs_draw(void *dummy _U_)
{
guint64 td;
rpc_program_t *rp;
char str[64];
printf("\n");
printf("==========================================================\n");
printf("ONC-RPC Program Statistics:\n");
printf("Program Version Calls Min SRT Max SRT Avg SRT\n");
for (rp = prog_list;rp;rp = rp->next) {
/* Only display procs with non-zero calls */
if (rp->num == 0) {
continue;
}
/* Scale the average SRT in units of 1us and round to the nearest us. */
td = ((guint64)(rp->tot.secs)) * NANOSECS_PER_SEC + rp->tot.nsecs;
td = ((td / rp->num) + 500) / 1000;
snprintf(str, sizeof(str), "%s(%d)", rpc_prog_name(rp->program), rp->program);
printf("%-15s %2u %6d %3d.%06d %3d.%06d %3" PRIu64 ".%06" PRIu64 "\n",
str,
rp->version,
rp->num,
(int)(rp->min.secs), (rp->min.nsecs+500)/1000,
(int)(rp->max.secs), (rp->max.nsecs+500)/1000,
td/MICROSECS_PER_SEC, td%MICROSECS_PER_SEC
);
}
printf("===================================================================\n");
}
static void
rpcprogs_init(const char *opt_arg _U_, void *userdata _U_)
{
GString *error_string;
if (already_enabled) {
return;
}
already_enabled = 1;
error_string = register_tap_listener("rpc", NULL, NULL, 0, NULL, rpcprogs_packet, rpcprogs_draw, NULL);
if (error_string) {
cmdarg_err("Couldn't register rpc,programs tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui rpcprogs_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"rpc,programs",
rpcprogs_init,
0,
NULL
};
void
register_tap_listener_rpcprogs(void)
{
register_stat_tap_ui(&rpcprogs_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-rtd.c | /* tap-rtd.c
*
* Based on tap-srt.c
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/rtd_table.h>
#include <epan/timestamp.h>
#include <epan/stat_tap_ui.h>
#include <wsutil/cmdarg_err.h>
#include <ui/cli/tshark-tap.h>
typedef struct _rtd_t {
const char *type;
const char *filter;
const value_string* vs_type;
rtd_data_t rtd;
} rtd_t;
static void
rtd_draw(void *arg)
{
rtd_data_t* rtd_data = (rtd_data_t*)arg;
rtd_t* rtd = (rtd_t*)rtd_data->user_data;
gchar* tmp_str;
guint i, j;
/* printing results */
printf("\n");
printf("=====================================================================================================\n");
printf("%s Response Time Delay (RTD) Statistics:\n", rtd->type);
printf("Filter for statistics: %s\n", rtd->filter ? rtd->filter : "");
if (rtd_data->stat_table.num_rtds == 1)
{
printf("Duplicate requests: %u\n", rtd_data->stat_table.time_stats[0].req_dup_num);
printf("Duplicate responses: %u\n", rtd_data->stat_table.time_stats[0].rsp_dup_num);
printf("Open requests: %u\n", rtd_data->stat_table.time_stats[0].open_req_num);
printf("Discarded responses: %u\n", rtd_data->stat_table.time_stats[0].disc_rsp_num);
printf("Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame |\n");
for (i=0; i<rtd_data->stat_table.time_stats[0].num_timestat; i++) {
if (rtd_data->stat_table.time_stats[0].rtd[i].num) {
tmp_str = val_to_str_wmem(NULL, i, rtd->vs_type, "Other (%d)");
printf("%s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u |\n",
tmp_str, rtd_data->stat_table.time_stats[0].rtd[i].num,
nstime_to_msec(&(rtd_data->stat_table.time_stats[0].rtd[i].min)), nstime_to_msec(&(rtd_data->stat_table.time_stats[0].rtd[i].max)),
get_average(&(rtd_data->stat_table.time_stats[0].rtd[i].tot), rtd_data->stat_table.time_stats[0].rtd[i].num),
rtd_data->stat_table.time_stats[0].rtd[i].min_num, rtd_data->stat_table.time_stats[0].rtd[i].max_num
);
wmem_free(NULL, tmp_str);
}
}
}
else
{
printf("Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame | Open Requests | Discarded responses | Duplicate requests | Duplicate responses\n");
for (i=0; i<rtd_data->stat_table.num_rtds; i++) {
for (j=0; j<rtd_data->stat_table.time_stats[i].num_timestat; j++) {
if (rtd_data->stat_table.time_stats[i].rtd[j].num) {
tmp_str = val_to_str_wmem(NULL, i, rtd->vs_type, "Other (%d)");
printf("%s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u | %10u | %10u | %4u (%4.2f%%) | %4u (%4.2f%%) |\n",
tmp_str, rtd_data->stat_table.time_stats[i].rtd[j].num,
nstime_to_msec(&(rtd_data->stat_table.time_stats[i].rtd[j].min)), nstime_to_msec(&(rtd_data->stat_table.time_stats[i].rtd[j].max)),
get_average(&(rtd_data->stat_table.time_stats[i].rtd[j].tot), rtd_data->stat_table.time_stats[i].rtd[j].num),
rtd_data->stat_table.time_stats[i].rtd[j].min_num, rtd_data->stat_table.time_stats[i].rtd[j].max_num,
rtd_data->stat_table.time_stats[i].open_req_num, rtd_data->stat_table.time_stats[i].disc_rsp_num,
rtd_data->stat_table.time_stats[i].req_dup_num,
rtd_data->stat_table.time_stats[i].rtd[j].num?((double)rtd_data->stat_table.time_stats[i].req_dup_num*100)/(double)rtd_data->stat_table.time_stats[i].rtd[j].num:0,
rtd_data->stat_table.time_stats[i].rsp_dup_num,
rtd_data->stat_table.time_stats[i].rtd[j].num?((double)rtd_data->stat_table.time_stats[i].rsp_dup_num*100)/(double)rtd_data->stat_table.time_stats[i].rtd[j].num:0
);
wmem_free(NULL, tmp_str);
}
}
}
}
printf("=====================================================================================================\n");
}
static void
init_rtd_tables(register_rtd_t* rtd, const char *filter)
{
GString *error_string;
rtd_t* ui;
ui = g_new0(rtd_t, 1);
ui->type = proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd)));
ui->filter = g_strdup(filter);
ui->vs_type = get_rtd_value_string(rtd);
ui->rtd.user_data = ui;
rtd_table_dissector_init(rtd, &ui->rtd.stat_table, NULL, NULL);
error_string = register_tap_listener(get_rtd_tap_listener_name(rtd), &ui->rtd, filter, 0, NULL, get_rtd_packet_func(rtd), rtd_draw, NULL);
if (error_string) {
free_rtd_table(&ui->rtd.stat_table);
cmdarg_err("Couldn't register srt tap: %s", error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static void
dissector_rtd_init(const char *opt_arg, void* userdata)
{
register_rtd_t *rtd = (register_rtd_t*)userdata;
const char *filter=NULL;
char* err = NULL;
rtd_table_get_filter(rtd, opt_arg, &filter, &err);
if (err != NULL)
{
cmdarg_err("%s", err);
g_free(err);
exit(1);
}
init_rtd_tables(rtd, filter);
}
/* Set GUI fields for register_rtd list */
bool
register_rtd_tables(const void *key _U_, void *value, void *userdata _U_)
{
register_rtd_t *rtd = (register_rtd_t*)value;
stat_tap_ui ui_info;
gchar *cli_string;
cli_string = rtd_table_get_tap_string(rtd);
ui_info.group = REGISTER_STAT_GROUP_RESPONSE_TIME;
ui_info.title = NULL; /* construct this from the protocol info? */
ui_info.cli_string = cli_string;
ui_info.tap_init_cb = dissector_rtd_init;
ui_info.nparams = 0;
ui_info.params = NULL;
register_stat_tap_ui(&ui_info, rtd);
g_free(cli_string);
return FALSE;
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-rtp.c | /* tap-rtp.c
* RTP TAP for tshark
*
* Copyright 2008, Ericsson AB
* By Balint Reczey <[email protected]>
*
* based on ui/gtk/rtp_stream_dlg.c
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* This TAP provides statistics for RTP streams
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/value_string.h>
#include <epan/tap.h>
#include <epan/rtp_pt.h>
#include <epan/stat_tap_ui.h>
#include <epan/addr_resolv.h>
#include "ui/rtp_stream.h"
#include "ui/tap-rtp-common.h"
void register_tap_listener_rtpstreams(void);
static void rtpstreams_stat_draw_cb(rtpstream_tapinfo_t *tapinfo);
/* The one and only global rtpstream_tapinfo_t structure for tshark and wireshark.
*/
static rtpstream_tapinfo_t the_tapinfo_struct =
{ NULL, rtpstreams_stat_draw_cb, NULL,
NULL, 0, NULL, NULL, 0, TAP_ANALYSE, NULL, NULL, NULL, FALSE, FALSE
};
static void
rtpstreams_stat_draw_cb(rtpstream_tapinfo_t *tapinfo _U_)
{
GList *list;
rtpstream_info_t *strinfo;
rtpstream_info_calc_t calc;
char *savelocale;
printf("========================= RTP Streams ========================\n");
printf("%13s %13s %15s %5s %15s %5s %10s %16s %5s %12s %15s %15s %15s %15s %15s %15s %s\n",
"Start time", "End time", "Src IP addr", "Port", "Dest IP addr", "Port", "SSRC", "Payload", "Pkts", "Lost",
"Min Delta(ms)", "Mean Delta(ms)", "Max Delta(ms)", "Min Jitter(ms)", "Mean Jitter(ms)", "Max Jitter(ms)", "Problems?");
/* save the current locale */
savelocale = g_strdup(setlocale(LC_NUMERIC, NULL));
/* switch to "C" locale to avoid problems with localized decimal separators
in snprintf("%f") functions */
setlocale(LC_NUMERIC, "C");
list = the_tapinfo_struct.strinfo_list;
list = g_list_first(list);
while (list)
{
strinfo = (rtpstream_info_t*)(list->data);
rtpstream_info_calculate(strinfo, &calc);
printf("%13.6f %13.6f %15s %5u %15s %5u 0x%08X %16s %5u %5d (%.1f%%) %15.3f %15.3f %15.3f %15.3f %15.3f %15.3f %s\n",
nstime_to_sec(&(strinfo->start_rel_time)),
nstime_to_sec(&(strinfo->stop_rel_time)),
calc.src_addr_str,
calc.src_port,
calc.dst_addr_str,
calc.dst_port,
calc.ssrc,
calc.all_payload_type_names,
calc.packet_count,
calc.lost_num,
calc.lost_perc,
calc.min_delta,
calc.mean_delta,
calc.max_delta,
calc.min_jitter,
calc.mean_jitter,
calc.max_jitter,
(calc.problem)?"X":"");
rtpstream_info_calc_free(&calc);
list = g_list_next(list);
}
printf("==============================================================\n");
/* restore previous locale setting */
setlocale(LC_NUMERIC, savelocale);
g_free(savelocale);
}
static void
rtpstreams_stat_init(const char *opt_arg _U_, void *userdata _U_)
{
register_tap_listener_rtpstream(&the_tapinfo_struct, NULL, NULL);
}
static stat_tap_ui rtpstreams_stat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"rtp,streams",
rtpstreams_stat_init,
0,
NULL
};
void
register_tap_listener_rtpstreams(void)
{
register_stat_tap_ui(&rtpstreams_stat_ui, NULL);
} |
C | wireshark/ui/cli/tap-rtspstat.c | /* tap-rtspstat.c
* tap-rtspstat March 2011
*
* Stephane GORSE (Orange Labs / France Telecom)
* Copied from Jean-Michel FAYARD's works (HTTP)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/value_string.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-rtsp.h>
#include <wsutil/wslog.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_rtspstat(void);
/* used to keep track of the statictics for an entire program interface */
typedef struct _rtsp_stats_t {
char *filter;
GHashTable *hash_responses;
GHashTable *hash_requests;
} rtspstat_t;
/* used to keep track of the stats for a specific response code
* for example it can be { 3, 404, "Not Found" ,...}
* which means we captured 3 reply rtsp/1.1 404 Not Found */
typedef struct _rtsp_response_code_t {
guint32 packets; /* 3 */
guint response_code; /* 404 */
const gchar *name; /* Not Found */
rtspstat_t *sp;
} rtsp_response_code_t;
/* used to keep track of the stats for a specific request string */
typedef struct _rtsp_request_methode_t {
gchar *response; /* eg. : SETUP */
guint32 packets;
rtspstat_t *sp;
} rtsp_request_methode_t;
/* insert some entries */
static void
rtsp_init_hash( rtspstat_t *sp)
{
int i;
sp->hash_responses = g_hash_table_new(g_direct_hash, g_direct_equal);
for (i=0 ; rtsp_status_code_vals[i].strptr ; i++ )
{
rtsp_response_code_t *sc = g_new (rtsp_response_code_t, 1);
sc->packets = 0;
sc->response_code = rtsp_status_code_vals[i].value;
sc->name = rtsp_status_code_vals[i].strptr;
sc->sp = sp;
g_hash_table_insert( sc->sp->hash_responses, GINT_TO_POINTER(rtsp_status_code_vals[i].value), sc);
}
sp->hash_requests = g_hash_table_new( g_str_hash, g_str_equal);
}
static void
rtsp_draw_hash_requests( gchar *key _U_ , rtsp_request_methode_t *data, gchar * format)
{
if (data->packets == 0)
return;
printf( format, data->response, data->packets);
}
static void
rtsp_draw_hash_responses( gpointer* key _U_ , rtsp_response_code_t *data, char * format)
{
if (data == NULL) {
ws_warning("No data available, key=%d\n", GPOINTER_TO_INT(key));
exit(EXIT_FAILURE);
}
if (data->packets == 0)
return;
/* " RTSP %3d %-35s %9d packets", */
printf(format, data->response_code, data->name, data->packets );
}
/* NOT USED at this moment */
/*
static void
rtsp_free_hash( gpointer key, gpointer value, gpointer user_data _U_ )
{
g_free(key);
g_free(value);
}
*/
static void
rtsp_reset_hash_responses(gchar *key _U_ , rtsp_response_code_t *data, gpointer ptr _U_ )
{
data->packets = 0;
}
static void
rtsp_reset_hash_requests(gchar *key _U_ , rtsp_request_methode_t *data, gpointer ptr _U_ )
{
data->packets = 0;
}
static void
rtspstat_reset(void *psp )
{
rtspstat_t *sp = (rtspstat_t *)psp;
g_hash_table_foreach( sp->hash_responses, (GHFunc)rtsp_reset_hash_responses, NULL);
g_hash_table_foreach( sp->hash_requests, (GHFunc)rtsp_reset_hash_requests, NULL);
}
static tap_packet_status
rtspstat_packet(void *psp , packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri, tap_flags_t flags _U_)
{
const rtsp_info_value_t *value = (const rtsp_info_value_t *)pri;
rtspstat_t *sp = (rtspstat_t *) psp;
/* We are only interested in reply packets with a status code */
/* Request or reply packets ? */
if (value->response_code != 0) {
rtsp_response_code_t *sc;
sc = (rtsp_response_code_t *)g_hash_table_lookup(
sp->hash_responses,
GINT_TO_POINTER(value->response_code));
if (sc == NULL) {
gint key;
/* non standard status code ; we classify it as others
* in the relevant category (Informational,Success,Redirection,Client Error,Server Error)
*/
int i = value->response_code;
if ((i < 100) || (i >= 600)) {
return TAP_PACKET_DONT_REDRAW;
}
else if (i < 200) {
key = 199; /* Hopefully, this status code will never be used */
}
else if (i < 300) {
key = 299;
}
else if (i < 400) {
key = 399;
}
else if (i < 500) {
key = 499;
}
else {
key = 599;
}
sc = (rtsp_response_code_t *)g_hash_table_lookup(
sp->hash_responses,
GINT_TO_POINTER(key));
if (sc == NULL)
return TAP_PACKET_DONT_REDRAW;
}
sc->packets++;
}
else if (value->request_method) {
rtsp_request_methode_t *sc;
sc = (rtsp_request_methode_t *)g_hash_table_lookup(
sp->hash_requests,
value->request_method);
if (sc == NULL) {
sc = g_new(rtsp_request_methode_t, 1);
sc->response = g_strdup( value->request_method );
sc->packets = 1;
sc->sp = sp;
g_hash_table_insert( sp->hash_requests, sc->response, sc);
} else {
sc->packets++;
}
} else {
return TAP_PACKET_DONT_REDRAW;
}
return TAP_PACKET_REDRAW;
}
static void
rtspstat_draw(void *psp )
{
rtspstat_t *sp = (rtspstat_t *)psp;
printf("\n");
printf("===================================================================\n");
if (!sp->filter || !sp->filter[0])
printf("RTSP Statistics\n");
else
printf("RTSP Statistics with filter %s\n", sp->filter);
printf("* RTSP Response Status Codes Packets\n");
g_hash_table_foreach( sp->hash_responses, (GHFunc)rtsp_draw_hash_responses,
(gpointer)" %3d %-35s %9d\n");
printf("* RTSP Request Methods Packets\n");
g_hash_table_foreach( sp->hash_requests, (GHFunc)rtsp_draw_hash_requests,
(gpointer)" %-39s %9d\n");
printf("===================================================================\n");
}
/* When called, this function will create a new instance of rtspstat.
*/
static void
rtspstat_init(const char *opt_arg, void *userdata _U_)
{
rtspstat_t *sp;
const char *filter = NULL;
GString *error_string;
if (!strncmp (opt_arg, "rtsp,stat,", 10)) {
filter = opt_arg+10;
} else {
filter = NULL;
}
sp = g_new(rtspstat_t, 1);
sp->filter = g_strdup(filter);
/*g_hash_table_foreach( rtsp_status, (GHFunc)rtsp_reset_hash_responses, NULL);*/
error_string = register_tap_listener(
"rtsp",
sp,
filter,
0,
rtspstat_reset,
rtspstat_packet,
rtspstat_draw,
NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(sp->filter);
g_free(sp);
cmdarg_err("Couldn't register rtsp,stat tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
rtsp_init_hash(sp);
}
static stat_tap_ui rtspstat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"rtsp,stat",
rtspstat_init,
0,
NULL
};
void
register_tap_listener_rtspstat(void)
{
register_stat_tap_ui(&rtspstat_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-sctpchunkstat.c | /* tap_sctpchunkstat.c
* SCTP chunk counter for wireshark
* Copyright 2005 Oleg Terletsky <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/value_string.h>
#include <epan/dissectors/packet-sctp.h>
#include <epan/to_str.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_sctpstat(void);
typedef struct sctp_ep {
struct sctp_ep *next;
address src;
address dst;
guint16 sport;
guint16 dport;
guint32 chunk_count[256];
} sctp_ep_t;
/* used to keep track of the statistics for an entire program interface */
typedef struct _sctpstat_t {
char *filter;
guint32 number_of_packets;
sctp_ep_t *ep_list;
} sctpstat_t;
#define CHUNK_TYPE_OFFSET 0
#define CHUNK_TYPE(x)(tvb_get_guint8((x), CHUNK_TYPE_OFFSET))
static void
sctpstat_reset(void *phs)
{
sctpstat_t *sctp_stat = (sctpstat_t *)phs;
sctp_ep_t *list = (sctp_ep_t *)sctp_stat->ep_list;
sctp_ep_t *tmp = NULL;
guint16 chunk_type;
if (!list)
return;
for (tmp = list; tmp; tmp = tmp->next)
for (chunk_type = 0; chunk_type < 256; chunk_type++)
tmp->chunk_count[chunk_type] = 0;
sctp_stat->number_of_packets = 0;
}
static sctp_ep_t *
alloc_sctp_ep(const struct _sctp_info *si)
{
sctp_ep_t *ep;
guint16 chunk_type;
if (!si)
return NULL;
if (!(ep = g_new(sctp_ep_t, 1)))
return NULL;
copy_address(&ep->src, &si->ip_src);
copy_address(&ep->dst, &si->ip_dst);
ep->sport = si->sport;
ep->dport = si->dport;
ep->next = NULL;
for (chunk_type = 0; chunk_type < 256; chunk_type++)
ep->chunk_count[chunk_type] = 0;
return ep;
}
static tap_packet_status
sctpstat_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *phi, tap_flags_t flags _U_)
{
sctpstat_t *hs = (sctpstat_t *)phs;
sctp_ep_t *tmp = NULL, *te = NULL;
const struct _sctp_info *si = (const struct _sctp_info *)phi;
guint32 tvb_number;
guint8 chunk_type;
if (!hs)
return (TAP_PACKET_DONT_REDRAW);
hs->number_of_packets++;
if (!hs->ep_list) {
hs->ep_list = alloc_sctp_ep(si);
te = hs->ep_list;
} else {
for (tmp = hs->ep_list; tmp; tmp = tmp->next)
{
if ((!cmp_address(&tmp->src, &si->ip_src)) &&
(!cmp_address(&tmp->dst, &si->ip_dst)) &&
(tmp->sport == si->sport) &&
(tmp->dport == si->dport))
{
te = tmp;
break;
}
}
if (!te) {
if ((te = alloc_sctp_ep(si))) {
te->next = hs->ep_list;
hs->ep_list = te;
}
}
}
if (!te)
return (TAP_PACKET_DONT_REDRAW);
if (si->number_of_tvbs > 0) {
chunk_type = CHUNK_TYPE(si->tvb[0]);
if ((chunk_type == SCTP_INIT_CHUNK_ID) ||
(chunk_type == SCTP_INIT_ACK_CHUNK_ID)) {
te->chunk_count[chunk_type]++;
} else {
for (tvb_number = 0; tvb_number < si->number_of_tvbs; tvb_number++)
te->chunk_count[CHUNK_TYPE(si->tvb[tvb_number])]++;
}
}
return (TAP_PACKET_REDRAW);
}
static void
sctpstat_draw(void *phs)
{
sctpstat_t *hs = (sctpstat_t *)phs;
sctp_ep_t *list = hs->ep_list, *tmp;
char *src_addr, *dst_addr;
printf("-------------------------------------------- SCTP Statistics --------------------------------------------------------------------------\n");
printf("| Total packets RX/TX %u\n", hs->number_of_packets);
printf("---------------------------------------------------------------------------------------------------------------------------------------\n");
printf("| Source IP |PortA| Dest. IP |PortB| DATA | SACK | HBEAT |HBEATACK| INIT | INITACK| COOKIE |COOKIACK| ABORT | ERROR |\n");
printf("---------------------------------------------------------------------------------------------------------------------------------------\n");
for (tmp = list; tmp; tmp = tmp->next) {
src_addr = (char*)address_to_str(NULL, &tmp->src);
dst_addr = (char*)address_to_str(NULL, &tmp->dst);
printf("|%15s|%5u|%15s|%5u|%8u|%8u|%8u|%8u|%8u|%8u|%8u|%8u|%8u|%8u|\n",
src_addr, tmp->sport,
dst_addr, tmp->dport,
tmp->chunk_count[SCTP_DATA_CHUNK_ID],
tmp->chunk_count[SCTP_SACK_CHUNK_ID],
tmp->chunk_count[SCTP_HEARTBEAT_CHUNK_ID],
tmp->chunk_count[SCTP_HEARTBEAT_ACK_CHUNK_ID],
tmp->chunk_count[SCTP_INIT_CHUNK_ID],
tmp->chunk_count[SCTP_INIT_ACK_CHUNK_ID],
tmp->chunk_count[SCTP_COOKIE_ECHO_CHUNK_ID],
tmp->chunk_count[SCTP_COOKIE_ACK_CHUNK_ID],
tmp->chunk_count[SCTP_ABORT_CHUNK_ID],
tmp->chunk_count[SCTP_ERROR_CHUNK_ID]);
wmem_free(NULL, src_addr);
wmem_free(NULL, dst_addr);
}
printf("---------------------------------------------------------------------------------------------------------------------------------------\n");
}
static void
sctpstat_init(const char *opt_arg, void *userdata _U_)
{
sctpstat_t *hs;
GString *error_string;
hs = g_new(sctpstat_t, 1);
if (!strncmp(opt_arg, "sctp,stat,", 11)) {
hs->filter = g_strdup(opt_arg+11);
} else {
hs->filter = NULL;
}
hs->ep_list = NULL;
hs->number_of_packets = 0;
sctpstat_reset(hs);
error_string = register_tap_listener("sctp", hs, hs->filter, 0, NULL, sctpstat_packet, sctpstat_draw, NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(hs->filter);
g_free(hs);
cmdarg_err("Couldn't register sctp,stat tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui sctpstat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"sctp,stat",
sctpstat_init,
0,
NULL
};
void
register_tap_listener_sctpstat(void)
{
register_stat_tap_ui(&sctpstat_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-simple_stattable.c | /* tap-simpletable.c
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/timestamp.h>
#include <epan/stat_tap_ui.h>
#include <wsutil/cmdarg_err.h>
#include <ui/cli/tshark-tap.h>
typedef struct _table_stat_t {
const char *filter;
stat_data_t stats;
} table_stat_t;
static void
simple_draw(void *arg)
{
stat_data_t* stat_data = (stat_data_t*)arg;
table_stat_t* stats = (table_stat_t*)stat_data->user_data;
size_t i;
guint table_index, element, field_index;
stat_tap_table_item* field;
stat_tap_table* table;
stat_tap_table_item_type* field_data;
gchar fmt_string[250];
/* printing results */
printf("\n");
printf("=====================================================================================================\n");
printf("%s:\n", stat_data->stat_tap_data->title);
printf("Filter for statistics: %s\n", stats->filter ? stats->filter : "");
for (i = 0, field = stat_data->stat_tap_data->fields; i < stat_data->stat_tap_data->nfields; i++, field++)
{
printf("%s |", field->column_name);
}
printf("\n");
/* To iterate is human, and to recurse is divine. I am human */
for (table_index = 0; table_index < stat_data->stat_tap_data->tables->len; table_index++)
{
table = g_array_index(stat_data->stat_tap_data->tables, stat_tap_table*, table_index);
printf("%s\n", table->title);
for (element = 0; element < table->num_elements; element++)
{
for (field_index = 0, field = stat_data->stat_tap_data->fields; field_index < table->num_fields; field_index++, field++)
{
field_data = stat_tap_get_field_data(table, element, field_index);
if (field_data->type == TABLE_ITEM_NONE) /* Nothing for us here */
break;
snprintf(fmt_string, sizeof(fmt_string), "%s |", field->field_format);
switch(field->type)
{
case TABLE_ITEM_UINT:
printf(fmt_string, field_data->value.uint_value);
break;
case TABLE_ITEM_INT:
printf(fmt_string, field_data->value.int_value);
break;
case TABLE_ITEM_STRING:
printf(fmt_string, field_data->value.string_value);
break;
case TABLE_ITEM_FLOAT:
printf(fmt_string, field_data->value.float_value);
break;
case TABLE_ITEM_ENUM:
printf(fmt_string, field_data->value.enum_value);
break;
case TABLE_ITEM_NONE:
break;
}
}
printf("\n");
}
}
printf("=====================================================================================================\n");
}
static void simple_finish(void *tapdata)
{
stat_data_t *stat_data = (stat_data_t *)tapdata;
g_free(stat_data->user_data);
}
static void
init_stat_table(stat_tap_table_ui *stat_tap, const char *filter)
{
GString *error_string;
table_stat_t* ui;
ui = g_new0(table_stat_t, 1);
ui->filter = g_strdup(filter);
ui->stats.stat_tap_data = stat_tap;
ui->stats.user_data = ui;
stat_tap->stat_tap_init_cb(stat_tap);
error_string = register_tap_listener(stat_tap->tap_name, &ui->stats,
filter, 0, NULL, stat_tap->packet_func, simple_draw,
simple_finish);
if (error_string) {
/* free_rtd_table(&ui->rtd.stat_table); */
cmdarg_err("Couldn't register tap: %s", error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static void
simple_stat_init(const char *opt_arg, void* userdata)
{
stat_tap_table_ui *stat_tap = (stat_tap_table_ui*)userdata;
const char *filter=NULL;
char* err = NULL;
stat_tap_get_filter(stat_tap, opt_arg, &filter, &err);
if (err != NULL)
{
cmdarg_err("%s", err);
g_free(err);
exit(1);
}
init_stat_table(stat_tap, filter);
}
bool
register_simple_stat_tables(const void *key, void *value, void *userdata _U_)
{
stat_tap_table_ui *stat_tap = (stat_tap_table_ui*)value;
stat_tap_ui ui_info;
ui_info.group = stat_tap->group;
ui_info.title = stat_tap->title; /* construct this from the protocol info? */
ui_info.cli_string = (const char *)key;
ui_info.tap_init_cb = simple_stat_init;
ui_info.nparams = stat_tap->nparams;
ui_info.params = stat_tap->params;
register_stat_tap_ui(&ui_info, stat_tap);
return FALSE;
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-sipstat.c | /* tap_sipstat.c
* sip message counter for wireshark
*
* Copied from ui/gtk/sip_stat.c and tap-httpstat.c
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/value_string.h>
#include <epan/dissectors/packet-sip.h>
#include <wsutil/wslog.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_sipstat(void);
/* used to keep track of the statictics for an entire program interface */
typedef struct _sip_stats_t {
char *filter;
guint32 packets; /* number of sip packets, including continuations */
guint32 resent_packets;
guint32 average_setup_time;
guint32 max_setup_time;
guint32 min_setup_time;
guint32 no_of_completed_calls;
guint64 total_setup_time;
GHashTable *hash_responses;
GHashTable *hash_requests;
} sipstat_t;
/* used to keep track of the stats for a specific response code
* for example it can be { 3, 404, "Not Found" ,...}
* which means we captured 3 reply sip/1.1 404 Not Found */
typedef struct _sip_response_code_t {
guint32 packets; /* 3 */
guint response_code; /* 404 */
const gchar *name; /* Not Found */
sipstat_t *sp;
} sip_response_code_t;
/* used to keep track of the stats for a specific request string */
typedef struct _sip_request_method_t {
gchar *response; /* eg. : INVITE */
guint32 packets;
sipstat_t *sp;
} sip_request_method_t;
/* Create tables for responses and requests */
static void
sip_init_hash(sipstat_t *sp)
{
int i;
/* Create responses table */
sp->hash_responses = g_hash_table_new(g_int_hash, g_int_equal);
/* Add all response codes */
for (i=0; sip_response_code_vals[i].strptr; i++)
{
gint *key = g_new (gint, 1);
sip_response_code_t *sc = g_new (sip_response_code_t, 1);
*key = sip_response_code_vals[i].value;
sc->packets = 0;
sc->response_code = *key;
sc->name = sip_response_code_vals[i].strptr;
sc->sp = sp;
g_hash_table_insert(sc->sp->hash_responses, key, sc);
}
/* Create empty requests table */
sp->hash_requests = g_hash_table_new(g_str_hash, g_str_equal);
}
static void
sip_draw_hash_requests( gchar *key _U_, sip_request_method_t *data, gchar *format)
{
if (data->packets == 0)
return;
printf( format, data->response, data->packets);
}
static void
sip_draw_hash_responses( gint *key _U_ , sip_response_code_t *data, char *format)
{
if (data == NULL) {
ws_warning("C'est quoi ce borderl key=%d\n", *key);
exit(EXIT_FAILURE);
}
if (data->packets == 0)
return;
printf(format, data->response_code, data->name, data->packets );
}
/* NOT USED at this moment */
/*
static void
sip_free_hash( gpointer key, gpointer value, gpointer user_data _U_ )
{
g_free(key);
g_free(value);
}
*/
static void
sip_reset_hash_responses(gchar *key _U_ , sip_response_code_t *data, gpointer ptr _U_ )
{
data->packets = 0;
}
static void
sip_reset_hash_requests(gchar *key _U_ , sip_request_method_t *data, gpointer ptr _U_ )
{
data->packets = 0;
}
static void
sipstat_reset(void *psp )
{
sipstat_t *sp = (sipstat_t *)psp;
if (sp) {
sp->packets = 0;
sp->resent_packets = 0;
sp->average_setup_time = 0;
sp->max_setup_time = 0;
sp->min_setup_time = 0;
sp->no_of_completed_calls = 0;
sp->total_setup_time = 0;
g_hash_table_foreach( sp->hash_responses, (GHFunc)sip_reset_hash_responses, NULL);
g_hash_table_foreach( sp->hash_requests, (GHFunc)sip_reset_hash_requests, NULL);
}
}
/* Main entry point to SIP tap */
static tap_packet_status
sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri, tap_flags_t flags _U_)
{
const sip_info_value_t *value = (const sip_info_value_t *)pri;
sipstat_t *sp = (sipstat_t *)psp;
/* Total number of packets, including continuation packets */
sp->packets++;
/* Calculate average setup time */
if (value->setup_time) {
sp->no_of_completed_calls++;
/* Check if it's the first value */
if ( sp->total_setup_time == 0 ) {
sp->average_setup_time = value->setup_time;
sp->total_setup_time = value->setup_time;
sp->max_setup_time = value->setup_time;
sp->min_setup_time = value->setup_time;
}else{
sp->total_setup_time = sp->total_setup_time + value->setup_time;
if (sp->max_setup_time < value->setup_time) {
sp->max_setup_time = value->setup_time;
}
if (sp->min_setup_time > value->setup_time) {
sp->min_setup_time = value->setup_time;
}
/* Calculate average */
sp->average_setup_time = (guint32)(sp->total_setup_time / sp->no_of_completed_calls);
}
}
/* Update resent count if flag set */
if (value->resend)
{
sp->resent_packets++;
}
/* Looking at both requests and responses */
if (value->response_code != 0)
{
/* Responses */
guint key;
sip_response_code_t *sc;
/* Look up response code in hash table */
key = value->response_code;
sc = (sip_response_code_t *)g_hash_table_lookup(sp->hash_responses, &key);
if (sc == NULL)
{
/* Non-standard status code ; we classify it as others
* in the relevant category
* (Informational,Success,Redirection,Client Error,Server Error,Global Failure)
*/
int i = value->response_code;
if ((i < 100) || (i >= 700))
{
/* Forget about crazy values */
return TAP_PACKET_DONT_REDRAW;
}
else if (i < 200)
{
key = 199; /* Hopefully, this status code will never be used */
}
else if (i < 300)
{
key = 299;
}
else if (i < 400)
{
key = 399;
}
else if (i < 500)
{
key = 499;
}
else if (i < 600)
{
key = 599;
}
else
{
key = 699;
}
/* Now look up this fallback code to get its text description */
sc = (sip_response_code_t *)g_hash_table_lookup(sp->hash_responses, &key);
if (sc == NULL)
{
return TAP_PACKET_DONT_REDRAW;
}
}
sc->packets++;
}
else if (value->request_method)
{
/* Requests */
sip_request_method_t *sc;
/* Look up the request method in the table */
sc = (sip_request_method_t *)g_hash_table_lookup(sp->hash_requests, value->request_method);
if (sc == NULL)
{
/* First of this type. Create structure and initialise */
sc = g_new(sip_request_method_t, 1);
sc->response = g_strdup(value->request_method);
sc->packets = 1;
sc->sp = sp;
/* Insert it into request table */
g_hash_table_insert(sp->hash_requests, sc->response, sc);
}
else
{
/* Already existed, just update count for that method */
sc->packets++;
}
/* g_free(value->request_method); */
}
else
{
/* No request method set. Just ignore */
return TAP_PACKET_DONT_REDRAW;
}
return TAP_PACKET_REDRAW;
}
static void
sipstat_draw(void *psp )
{
sipstat_t *sp = (sipstat_t *)psp;
printf("\n");
printf("===================================================================\n");
if (sp->filter == NULL)
printf("SIP Statistics\n");
else
printf("SIP Statistics with filter %s\n", sp->filter);
printf("\nNumber of SIP messages: %u", sp->packets);
printf("\nNumber of resent SIP messages: %u\n", sp->resent_packets);
printf( "\n* SIP Status Codes in reply packets\n");
g_hash_table_foreach(sp->hash_responses, (GHFunc)sip_draw_hash_responses,
(gpointer)" SIP %3d %-15s : %5d Packets\n");
printf("\n* List of SIP Request methods\n");
g_hash_table_foreach(sp->hash_requests, (GHFunc)sip_draw_hash_requests,
(gpointer)" %-15s : %5d Packets\n");
printf( "\n* Average setup time %u ms\n Min %u ms\n Max %u ms\n", sp->average_setup_time, sp->min_setup_time, sp->max_setup_time);
printf("===================================================================\n");
}
static void
sipstat_init(const char *opt_arg, void *userdata _U_)
{
sipstat_t *sp;
const char *filter = NULL;
GString *error_string;
if (strncmp (opt_arg, "sip,stat,", 9) == 0) {
filter = opt_arg+9;
} else {
filter = NULL;
}
sp = g_new0(sipstat_t, 1);
sp->filter = g_strdup(filter);
/*g_hash_table_foreach( sip_status, (GHFunc)sip_reset_hash_responses, NULL);*/
error_string = register_tap_listener(
"sip",
sp,
filter,
0,
sipstat_reset,
sipstat_packet,
sipstat_draw,
NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(sp->filter);
g_free(sp);
cmdarg_err("Couldn't register sip,stat tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
sp->packets = 0;
sp->resent_packets = 0;
sip_init_hash(sp);
}
static stat_tap_ui sipstat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"sip,stat",
sipstat_init,
0,
NULL
};
void
register_tap_listener_sipstat(void)
{
register_stat_tap_ui(&sipstat_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-smbsids.c | /* tap-smbsids.c
* smbstat 2003 Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/dissectors/packet-smb-sidsnooping.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/value_string.h>
#include <epan/dissectors/packet-smb.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_smbsids(void);
static tap_packet_status
smbsids_packet(void *pss _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *psi _U_, tap_flags_t flags _U_)
{
return TAP_PACKET_REDRAW;
}
static void
enum_sids(gpointer key, gpointer value, gpointer userdata _U_)
{
const char *sid = (const char *)key;
const char *name = (const char *)value;
printf("%-60s %s\n", sid, name);
}
static void
smbsids_draw(void *pss _U_)
{
printf("\n");
printf("===================================================================\n");
printf("SMB SID List:\n");
g_hash_table_foreach(sid_name_table, enum_sids, NULL);
printf("===================================================================\n");
}
static void
smbsids_init(const char *opt_arg _U_, void *userdata _U_)
{
GString *error_string;
if (!sid_name_snooping) {
fprintf(stderr, "The -z smb,sids function needs SMB/SID-Snooping to be enabled.\n");
fprintf(stderr, "Either enable Edit/Preferences/Protocols/SMB/Snoop SID name mappings in wireshark\n");
fprintf(stderr, "or override the preference file by specifying\n");
fprintf(stderr, " -o \"smb.sid_name_snooping=TRUE\"\n");
fprintf(stderr, "on the tshark command line.\n");
exit(1);
}
error_string = register_tap_listener("smb", NULL, NULL, 0, NULL, smbsids_packet, smbsids_draw, NULL);
if (error_string) {
cmdarg_err("Couldn't register smb,sids tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui smbsids_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"smb,sids",
smbsids_init,
0,
NULL
};
void
register_tap_listener_smbsids(void)
{
register_stat_tap_ui(&smbsids_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-srt.c | /* tap-srt.c
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <epan/packet.h>
#include <epan/srt_table.h>
#include <epan/timestamp.h>
#include <epan/stat_tap_ui.h>
#include <wsutil/cmdarg_err.h>
#include <ui/cli/tshark-tap.h>
#define NANOSECS_PER_SEC 1000000000
typedef struct _srt_t {
const char *type;
const char *filter;
srt_data_t data;
} srt_t;
static void
draw_srt_table_data(srt_stat_table *rst, gboolean draw_footer, const char *subfilter)
{
int i;
guint64 td;
guint64 sum;
if (rst->num_procs > 0) {
if (rst->filter_string != NULL && subfilter != NULL) {
printf("Filter: %s and (%s)\n", rst->filter_string, subfilter);
} else if (subfilter != NULL) {
/* Print (subfilter) to disambiguate from just rst->filter_string. */
printf("Filter: (%s)\n", subfilter);
} else {
printf("Filter: %s\n", rst->filter_string ? rst->filter_string : "");
}
printf("Index %-22s Calls Min SRT Max SRT Avg SRT Sum SRT\n", (rst->proc_column_name != NULL) ? rst->proc_column_name : "Procedure");
}
for(i=0;i<rst->num_procs;i++){
/* ignore procedures with no calls (they don't have rows) */
if(rst->procedures[i].stats.num==0){
continue;
}
/* Scale the average SRT in units of 1us and round to the nearest us.
tot.secs is a time_t which may be 32 or 64 bits (or even floating)
depending uon the platform. After casting tot.secs to 64 bits, it
would take a capture with a duration of over 136 *years* to
overflow the secs portion of td. */
td = ((guint64)(rst->procedures[i].stats.tot.secs))*NANOSECS_PER_SEC + rst->procedures[i].stats.tot.nsecs;
sum = (td + 500) / 1000;
td = ((td / rst->procedures[i].stats.num) + 500) / 1000;
printf("%5d %-22s %6u %3d.%06d %3d.%06d %3d.%06d %3d.%06d\n",
i, rst->procedures[i].procedure,
rst->procedures[i].stats.num,
(int)rst->procedures[i].stats.min.secs, (rst->procedures[i].stats.min.nsecs+500)/1000,
(int)rst->procedures[i].stats.max.secs, (rst->procedures[i].stats.max.nsecs+500)/1000,
(int)(td/1000000), (int)(td%1000000),
(int)(sum/1000000), (int)(sum%1000000)
);
}
if (draw_footer)
printf("==================================================================\n");
}
static void
srt_draw(void *arg)
{
guint i = 0;
srt_data_t* data = (srt_data_t*)arg;
srt_t *ui = (srt_t *)data->user_data;
srt_stat_table *srt_table;
gboolean need_newline = FALSE;
printf("\n");
printf("===================================================================\n");
printf("%s SRT Statistics:\n", ui->type);
srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
draw_srt_table_data(srt_table, data->srt_array->len == 1, ui->filter);
if (srt_table->num_procs > 0) {
need_newline = TRUE;
}
for (i = 1; i < data->srt_array->len; i++)
{
if (need_newline)
{
printf("\n");
need_newline = FALSE;
}
srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
draw_srt_table_data(srt_table, i == data->srt_array->len-1, ui->filter);
if (srt_table->num_procs > 0) {
need_newline = TRUE;
}
}
}
static GArray* global_srt_array;
static void
init_srt_tables(register_srt_t* srt, const char *filter)
{
srt_t *ui;
GString *error_string;
ui = g_new0(srt_t, 1);
ui->type = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt)));
ui->filter = g_strdup(filter);
ui->data.srt_array = global_srt_array;
ui->data.user_data = ui;
error_string = register_tap_listener(get_srt_tap_listener_name(srt), &ui->data, filter, 0, NULL, get_srt_packet_func(srt), srt_draw, NULL);
if (error_string) {
free_srt_table(srt, global_srt_array);
g_free(ui);
cmdarg_err("Couldn't register srt tap: %s", error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static void
dissector_srt_init(const char *opt_arg, void* userdata)
{
register_srt_t *srt = (register_srt_t*)userdata;
const char *filter=NULL;
char* err;
srt_table_get_filter(srt, opt_arg, &filter, &err);
if (err != NULL)
{
gchar* cmd_str = srt_table_get_tap_string(srt);
cmdarg_err("invalid \"-z %s,%s\" argument", cmd_str, err);
g_free(cmd_str);
g_free(err);
exit(1);
}
/* Need to create the SRT array now */
global_srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*));
srt_table_dissector_init(srt, global_srt_array);
init_srt_tables(srt, filter);
}
/* Set GUI fields for register_srt list */
bool
register_srt_tables(const void *key _U_, void *value, void *userdata _U_)
{
register_srt_t *srt = (register_srt_t*)value;
const char* short_name = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt)));
stat_tap_ui ui_info;
gchar *cli_string;
/* XXX - CAMEL dissector hasn't been converted over due seemingly different tap packet
handling functions. So let the existing TShark CAMEL tap keep its registration */
if (strcmp(short_name, "CAMEL") == 0)
return FALSE;
cli_string = srt_table_get_tap_string(srt);
ui_info.group = REGISTER_STAT_GROUP_RESPONSE_TIME;
ui_info.title = NULL; /* construct this from the protocol info? */
ui_info.cli_string = cli_string;
ui_info.tap_init_cb = dissector_srt_init;
ui_info.nparams = 0;
ui_info.params = NULL;
register_stat_tap_ui(&ui_info, srt);
g_free(cli_string);
return FALSE;
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-stats_tree.c | /* tap-stats_tree.c
* tshark's tap implememntation of stats_tree
* 2005, Luis E. G. Ontanon
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include <wsutil/report_message.h>
#include <epan/stats_tree_priv.h>
#include <epan/stat_tap_ui.h>
void register_tap_listener_stats_tree_stat(void);
/* actually unused */
struct _st_node_pres {
void *dummy;
};
struct _tree_pres {
void **dummy;
};
struct _tree_cfg_pres {
gchar *init_string;
};
static void
draw_stats_tree(void *psp)
{
stats_tree *st = (stats_tree *)psp;
GString *s;
s= stats_tree_format_as_str(st, ST_FORMAT_PLAIN, stats_tree_get_default_sort_col(st),
stats_tree_is_default_sort_DESC(st));
printf("%s", s->str);
g_string_free(s, TRUE);
}
static void
init_stats_tree(const char *opt_arg, void *userdata _U_)
{
char *abbr = stats_tree_get_abbr(opt_arg);
GString *error_string;
stats_tree_cfg *cfg = NULL;
stats_tree *st = NULL;
const char* filter = NULL;
size_t len;
if (abbr) {
cfg = stats_tree_get_cfg_by_abbr(abbr);
if (cfg != NULL) {
len = strlen(cfg->pr->init_string);
if (strncmp(opt_arg, cfg->pr->init_string, len) == 0) {
if (opt_arg[len] == ',') {
filter = opt_arg + len + 1;
}
st = stats_tree_new(cfg, NULL, filter);
} else {
report_failure("Wrong stats_tree (%s) found when looking at ->init_string", abbr);
return;
}
} else {
report_failure("no such stats_tree (%s) found in stats_tree registry", abbr);
return;
}
g_free(abbr);
} else {
report_failure("could not obtain stats_tree from arg '%s'", opt_arg);
return;
}
error_string = register_tap_listener(st->cfg->tapname,
st,
st->filter,
st->cfg->flags,
stats_tree_reset,
stats_tree_packet,
draw_stats_tree,
NULL);
if (error_string) {
report_failure("stats_tree for: %s failed to attach to the tap: %s", cfg->name, error_string->str);
return;
}
if (cfg->init) cfg->init(st);
}
static void
register_stats_tree_tap (gpointer k _U_, gpointer v, gpointer p _U_)
{
stats_tree_cfg *cfg = (stats_tree_cfg *)v;
stat_tap_ui ui_info;
cfg->pr = wmem_new(wmem_epan_scope(), tree_cfg_pres);
cfg->pr->init_string = wmem_strdup_printf(wmem_epan_scope(), "%s,tree", cfg->abbr);
ui_info.group = REGISTER_STAT_GROUP_GENERIC;
ui_info.title = NULL;
ui_info.cli_string = cfg->pr->init_string;
ui_info.tap_init_cb = init_stats_tree;
ui_info.nparams = 0;
ui_info.params = NULL;
register_stat_tap_ui(&ui_info, NULL);
}
static void
free_tree_presentation(stats_tree *st)
{
g_free(st->pr);
}
void
register_tap_listener_stats_tree_stat(void)
{
stats_tree_presentation(register_stats_tree_tap, NULL,
free_tree_presentation, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-sv.c | /* tap-sv.c
* Copyright 2008 Michael Bernhard
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-sv.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_sv(void);
static tap_packet_status
sv_packet(void *prs _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri, tap_flags_t flags _U_)
{
int i;
const sv_frame_data * sv_data = (const sv_frame_data *)pri;
printf("%f %u ", nstime_to_sec(&pinfo->rel_ts), sv_data->smpCnt);
for (i = 0; i < sv_data->num_phsMeas; i++) {
printf("%d ", sv_data->phsMeas[i].value);
}
printf("\n");
return TAP_PACKET_DONT_REDRAW;
}
static void
svstat_init(const char *opt_arg _U_, void *userdata _U_)
{
GString *error_string;
error_string = register_tap_listener(
"sv",
NULL,
NULL,
0,
NULL,
sv_packet,
NULL,
NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
cmdarg_err("Couldn't register sv,stat tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui svstat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"sv",
svstat_init,
0,
NULL
};
void
register_tap_listener_sv(void)
{
register_stat_tap_ui(&svstat_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-voip.c | /* tap-voip.c
* voip 2023 Niels Widger
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <glib.h>
#include "epan/packet_info.h"
#include "epan/value_string.h"
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/addr_resolv.h>
#include "ui/voip_calls.h"
#include "ui/rtp_stream.h"
#include "epan/sequence_analysis.h"
#include "tap-voip.h"
/* HACKY HACKY
*
* The cf_retap_packets call doesn't seem to be necessary
* when doing VOIP stuff, so it's OK if it's a NOP, it shouldn't get called.
*
* ... I don't think.
*/
#include "file.h"
cf_read_status_t
cf_retap_packets(capture_file *cf)
{
(void)cf;
return CF_READ_OK;
}
voip_calls_tapinfo_t tapinfo_;
int voip_conv_sel[VOIP_CONV_NUM];
void voip_stat_init_tapinfo(void)
{
memset(&tapinfo_, 0, sizeof(tapinfo_));
tapinfo_.callsinfos = g_queue_new();
/* fs_option FLOW_ALL shows the same info as the "SIP Flows" Wireshark tool
* FLOW_ONLY_INVITES shows the same thing as "VoIP Flows" in Wireshark.
* not totally sure what this really means right now. I believe we want FLOW_ONLY_INVITES?
* this matches the Wireshark menu options and shows fewer streams.
*/
tapinfo_.fs_option = FLOW_ONLY_INVITES;
// add graph analysis
tapinfo_.graph_analysis = sequence_analysis_info_new();
tapinfo_.graph_analysis->name = "voip";
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*
*/ |
C/C++ | wireshark/ui/cli/tap-voip.h | /** @file
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TAP_VOIP_H__
#define __TAP_VOIP_H__
#include "ui/voip_calls.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* store the chosen calls in a bit-array */
#define VOIP_CONV_BITS (sizeof(int) * 8)
#define VOIP_CONV_NUM ((1<<(sizeof(guint16) * 8))/VOIP_CONV_BITS)
#define VOIP_CONV_MAX (VOIP_CONV_BITS * VOIP_CONV_NUM)
extern voip_calls_tapinfo_t tapinfo_;
extern int voip_conv_sel[VOIP_CONV_NUM];
extern void voip_stat_init_tapinfo(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_VOIP_H__ */
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C | wireshark/ui/cli/tap-wspstat.c | /* tap-wspstat.c
* wspstat 2003 Jean-Michel FAYARD
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* This module provides WSP statistics to tshark.
* It is only used by tshark and not wireshark
*
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/value_string.h>
#include <epan/dissectors/packet-wsp.h>
#include <wsutil/cmdarg_err.h>
void register_tap_listener_wspstat(void);
/* used to keep track of the stats for a specific PDU type*/
typedef struct _wsp_pdu_t {
const gchar *type;
guint32 packets;
} wsp_pdu_t;
/* used to keep track of SRT statistics */
typedef struct _wsp_status_code_t {
const gchar *name;
guint32 packets;
} wsp_status_code_t;
/* used to keep track of the statictics for an entire program interface */
typedef struct _wsp_stats_t {
char *filter;
wsp_pdu_t *pdu_stats;
guint32 num_pdus;
GHashTable *hash;
} wspstat_t;
static void
wsp_reset_hash(gchar *key _U_ , wsp_status_code_t *data, gpointer ptr _U_)
{
data->packets = 0;
}
static void
wsp_print_statuscode(gpointer key, wsp_status_code_t *data, char *format)
{
if (data && (data->packets != 0))
printf(format, GPOINTER_TO_INT(key), data->packets , data->name);
}
static void
wsp_free_hash_table( gpointer key, gpointer value, gpointer user_data _U_ )
{
g_free(key);
g_free(value);
}
static void
wspstat_reset(void *psp)
{
wspstat_t *sp = (wspstat_t *)psp;
guint32 i;
for (i=1; i<=sp->num_pdus; i++)
{
sp->pdu_stats[i].packets = 0;
}
g_hash_table_foreach( sp->hash, (GHFunc)wsp_reset_hash, NULL);
}
/* This callback is invoked whenever the tap system has seen a packet
* we might be interested in.
* The function is to be used to only update internal state information
* in the *tapdata structure, and if there were state changes which requires
* the window to be redrawn, return 1 and (*draw) will be called sometime
* later.
*
* We didn't apply a filter when we registered so we will be called for
* ALL packets and not just the ones we are collecting stats for.
*
*/
static gint
pdut2index(gint pdut)
{
if (pdut <= 0x09)
return pdut;
if (pdut >= 0x40) {
if (pdut <= 0x44) {
return pdut - 54;
} else if (pdut == 0x60 || pdut == 0x61) {
return pdut - 81;
}
}
return 0;
}
static gint
index2pdut(gint pdut)
{
if (pdut <= 0x09)
return pdut;
if (pdut <= 14)
return pdut + 54;
if (pdut <= 16)
return pdut + 81;
return 0;
}
static tap_packet_status
wspstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri, tap_flags_t flags _U_)
{
wspstat_t *sp = (wspstat_t *)psp;
const wsp_info_value_t *value = (const wsp_info_value_t *)pri;
gint idx = pdut2index(value->pdut);
tap_packet_status retour = TAP_PACKET_DONT_REDRAW;
if (value->status_code != 0) {
wsp_status_code_t *sc;
sc = (wsp_status_code_t *)g_hash_table_lookup(
sp->hash,
GINT_TO_POINTER(value->status_code));
if (!sc) {
sc = g_new(wsp_status_code_t, 1);
sc -> packets = 1;
sc -> name = NULL;
g_hash_table_insert(
sp->hash,
GINT_TO_POINTER(value->status_code),
sc);
} else {
sc->packets++;
}
retour = TAP_PACKET_REDRAW;
}
if (idx != 0) {
sp->pdu_stats[idx].packets++;
retour = TAP_PACKET_REDRAW;
}
return retour;
}
/* This callback is used when tshark wants us to draw/update our
* data to the output device. Since this is tshark only output is
* stdout.
* TShark will only call this callback once, which is when tshark has
* finished reading all packets and exists.
* If used with wireshark this may be called any time, perhaps once every 3
* seconds or so.
* This function may even be called in parallell with (*reset) or (*draw)
* so make sure there are no races. The data in the rpcstat_t can thus change
* beneath us. Beware.
*/
static void
wspstat_draw(void *psp)
{
wspstat_t *sp = (wspstat_t *)psp;
guint32 i;
printf("\n");
printf("===================================================================\n");
printf("WSP Statistics:\n");
printf("%-23s %9s || %-23s %9s\n", "PDU Type", "Packets", "PDU Type", "Packets");
for (i=1; i <= ((sp->num_pdus+1)/2); i++)
{
guint32 ii = i+sp->num_pdus/2;
printf("%-23s %9u", sp->pdu_stats[i ].type, sp->pdu_stats[i ].packets);
printf(" || ");
if (ii< (sp->num_pdus) )
printf("%-23s %9u\n", sp->pdu_stats[ii].type, sp->pdu_stats[ii].packets);
else
printf("\n");
}
printf("\nStatus code in reply packets\n");
printf( "Status Code Packets Description\n");
g_hash_table_foreach( sp->hash, (GHFunc) wsp_print_statuscode,
(gpointer)" 0x%02X %9d %s\n" ) ;
printf("===================================================================\n");
}
/* When called, this function will create a new instance of wspstat.
* program and version are whick onc-rpc program/version we want to
* collect statistics for.
* This function is called from tshark when it parses the -z wsp, arguments
* and it creates a new instance to store statistics in and registers this
* new instance for the wsp tap.
*/
static void
wspstat_init(const char *opt_arg, void *userdata _U_)
{
wspstat_t *sp;
const char *filter = NULL;
guint32 i;
GString *error_string;
wsp_status_code_t *sc;
const value_string *wsp_vals_status_p;
if (!strncmp (opt_arg, "wsp,stat,", 9)) {
filter = opt_arg+9;
} else {
filter = NULL;
}
sp = g_new(wspstat_t, 1);
sp->hash = g_hash_table_new(g_direct_hash, g_direct_equal);
wsp_vals_status_p = VALUE_STRING_EXT_VS_P(&wsp_vals_status_ext);
for (i=0; wsp_vals_status_p[i].strptr; i++ )
{
gint *key;
sc = g_new(wsp_status_code_t, 1);
key = g_new(gint, 1);
sc->packets = 0;
sc->name = wsp_vals_status_p[i].strptr;
*key = wsp_vals_status_p[i].value;
g_hash_table_insert(
sp->hash,
key,
sc);
}
sp->num_pdus = 16;
sp->pdu_stats = g_new(wsp_pdu_t, (sp->num_pdus+1));
sp->filter = g_strdup(filter);
for (i=0; i<sp->num_pdus; i++)
{
sp->pdu_stats[i].packets = 0;
sp->pdu_stats[i].type = try_val_to_str_ext( index2pdut( i ), &wsp_vals_pdu_type_ext) ;
}
error_string = register_tap_listener(
"wsp",
sp,
filter,
0,
wspstat_reset,
wspstat_packet,
wspstat_draw,
NULL);
if (error_string) {
/* error, we failed to attach to the tap. clean up */
g_free(sp->pdu_stats);
g_free(sp->filter);
g_hash_table_foreach( sp->hash, (GHFunc) wsp_free_hash_table, NULL ) ;
g_hash_table_destroy( sp->hash );
g_free(sp);
cmdarg_err("Couldn't register wsp,stat tap: %s",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
}
}
static stat_tap_ui wspstat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"wsp,stat",
wspstat_init,
0,
NULL
};
void
register_tap_listener_wspstat(void)
{
register_stat_tap_ui(&wspstat_ui, NULL);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/ |
C/C++ | wireshark/ui/cli/tshark-tap.h | /** @file
*
* Registation tap hooks for TShark
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __TSHARK_TAP_H__
#define __TSHARK_TAP_H__
#include <epan/conversation_table.h>
extern void init_iousers(struct register_ct* ct, const char *filter);
extern void init_endpoints(struct register_ct* ct, const char *filter);
extern bool register_srt_tables(const void *key, void *value, void *userdata);
extern bool register_rtd_tables(const void *key, void *value, void *userdata);
extern bool register_simple_stat_tables(const void *key, void *value, void *userdata);
#endif /* __TSHARK_TAP_H__ */ |
Text | wireshark/ui/logray/CMakeLists.txt | # CMakeLists.txt
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <[email protected]>
# Copyright 1998 Gerald Combs
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
if(USE_qt6)
set(qtver "6")
else()
set(qtver "5")
endif()
ADD_CUSTOM_CMAKE_INCLUDE()
set(WIRESHARK_WIDGET_HEADERS
../qt/widgets/additional_toolbar.h
../qt/widgets/apply_line_edit.h
../qt/widgets/byte_view_text.h
../qt/widgets/capture_filter_combo.h
../qt/widgets/capture_filter_edit.h
../qt/widgets/clickable_label.h
../qt/widgets/copy_from_profile_button.h
../qt/widgets/detachable_tabwidget.h
../qt/widgets/display_filter_combo.h
../qt/widgets/display_filter_edit.h
../qt/widgets/dissector_syntax_line_edit.h
../qt/widgets/dissector_tables_view.h
../qt/widgets/drag_drop_toolbar.h
../qt/widgets/drag_label.h
../qt/widgets/editor_file_dialog.h
../qt/widgets/elided_label.h
../qt/widgets/expert_info_view.h
../qt/widgets/export_objects_view.h
../qt/widgets/field_filter_edit.h
../qt/widgets/filter_expression_toolbar.h
../qt/widgets/find_line_edit.h
../qt/widgets/interface_toolbar_lineedit.h
../qt/widgets/label_stack.h
../qt/widgets/overlay_scroll_bar.h
../qt/widgets/packet_list_header.h
../qt/widgets/path_selection_edit.h
../qt/widgets/pref_module_view.h
../qt/widgets/profile_tree_view.h
../qt/widgets/range_syntax_lineedit.h
../qt/widgets/splash_overlay.h
../qt/widgets/stock_icon_tool_button.h
../qt/widgets/syntax_line_edit.h
../qt/widgets/wireless_timeline.h # Required by PacketListModel
../qt/widgets/tabnav_tree_view.h
../qt/widgets/traffic_tab.h
../qt/widgets/traffic_tree.h
../qt/widgets/traffic_types_list.h
../qt/widgets/wireshark_file_dialog.h
)
set (LOGRAY_WIDGET_HEADERS ${WIRESHARK_WIDGET_HEADERS})
set(WIRESHARK_3RD_PARTY_WIDGET_HEADERS
../qt/widgets/qcustomplot.h
)
set (LOGRAY_3RD_PARTY_WIDGET_HEADERS ${WIRESHARK_3RD_PARTY_WIDGET_HEADERS})
set(WIRESHARK_MANAGER_HEADERS
../qt/manager/preference_manager.h
../qt/manager/wireshark_preference.h
)
set (LOGRAY_MANAGER_HEADERS ${WIRESHARK_MANAGER_HEADERS})
set(WIRESHARK_UTILS_HEADERS
../qt/utils/color_utils.h
../qt/utils/data_printer.h
../qt/utils/field_information.h
../qt/utils/frame_information.h
../qt/utils/idata_printable.h
../qt/utils/proto_node.h
../qt/utils/qt_ui_utils.h
../qt/utils/stock_icon.h
../qt/utils/tango_colors.h
../qt/utils/variant_pointer.h
../qt/utils/wireshark_mime_data.h
../qt/utils/wireshark_zip_helper.h
)
set (LOGRAY_UTILS_HEADERS ${WIRESHARK_UTILS_HEADERS})
set(WIRESHARK_MODEL_HEADERS
../qt/models/astringlist_list_model.h
../qt/models/atap_data_model.h
../qt/models/cache_proxy_model.h
../qt/models/coloring_rules_delegate.h
../qt/models/coloring_rules_model.h
../qt/models/column_list_model.h
../qt/models/decode_as_delegate.h
../qt/models/decode_as_model.h
../qt/models/dissector_tables_model.h
../qt/models/enabled_protocols_model.h
../qt/models/expert_info_model.h
../qt/models/expert_info_proxy_model.h
../qt/models/export_objects_model.h
../qt/models/fileset_entry_model.h
../qt/models/filter_list_model.h
../qt/models/info_proxy_model.h
../qt/models/interface_sort_filter_model.h
../qt/models/interface_tree_cache_model.h
../qt/models/interface_tree_model.h
../qt/models/numeric_value_chooser_delegate.h
../qt/models/packet_list_model.h
../qt/models/packet_list_record.h
../qt/models/path_selection_delegate.h
../qt/models/percent_bar_delegate.h
../qt/models/pref_delegate.h
../qt/models/pref_models.h
../qt/models/profile_model.h
../qt/models/proto_tree_model.h
../qt/models/related_packet_delegate.h
../qt/models/resolved_addresses_models.h
../qt/models/sparkline_delegate.h
../qt/models/supported_protocols_model.h
../qt/models/timeline_delegate.h
../qt/models/tree_model_helpers.h
../qt/models/uat_delegate.h
../qt/models/uat_model.h
../qt/models/url_link_delegate.h
)
set (LOGRAY_MODEL_HEADERS ${WIRESHARK_MODEL_HEADERS})
# All .h files which inherit from QObject aka which use the Q_OBJECT macro
# need to go here.
set(WIRESHARK_QT_HEADERS
../qt/about_dialog.h
../qt/accordion_frame.h
../qt/address_editor_frame.h
../qt/byte_view_tab.h
../qt/capture_file_dialog.h
../qt/capture_file_properties_dialog.h
../qt/capture_file.h
../qt/capture_filter_syntax_worker.h
../qt/capture_options_dialog.h
../qt/capture_preferences_frame.h
../qt/coloring_rules_dialog.h
../qt/column_editor_frame.h
../qt/column_preferences_frame.h
../qt/compiled_filter_output.h
../qt/conversation_colorize_action.h
../qt/conversation_dialog.h
../qt/conversation_hash_tables_dialog.h
../qt/decode_as_dialog.h
../qt/display_filter_expression_dialog.h
../qt/dissector_tables_dialog.h
../qt/enabled_protocols_dialog.h
../qt/endpoint_dialog.h
../qt/expert_info_dialog.h
../qt/export_dissection_dialog.h
../qt/export_object_action.h
../qt/export_object_dialog.h
../qt/export_pdu_dialog.h
../qt/extcap_argument_file.h
../qt/extcap_argument_multiselect.h
../qt/extcap_argument.h
../qt/extcap_options_dialog.h
../qt/file_set_dialog.h
../qt/filter_action.h
../qt/filter_dialog.h
../qt/filter_dialog.h
../qt/filter_expression_frame.h
../qt/follow_stream_action.h
../qt/font_color_preferences_frame.h
../qt/funnel_statistics.h
../qt/funnel_string_dialog.h
../qt/funnel_text_dialog.h
../qt/geometry_state_dialog.h
../qt/glib_mainloop_on_qeventloop.h
../qt/import_text_dialog.h
../qt/interface_frame.h
../qt/interface_toolbar_reader.h
../qt/interface_toolbar.h
../qt/io_console_dialog.h
../qt/io_graph_dialog.h
../qt/layout_preferences_frame.h
../qt/main_application.h
../qt/main_status_bar.h
../qt/main_window_preferences_frame.h
../qt/main_window.h
../qt/manage_interfaces_dialog.h
../qt/module_preferences_scroll_area.h
../qt/packet_comment_dialog.h
../qt/packet_diagram.h
../qt/packet_dialog.h
../qt/packet_format_group_box.h
../qt/packet_list.h
../qt/packet_range_group_box.h
../qt/preference_editor_frame.h
../qt/preferences_dialog.h
../qt/print_dialog.h
../qt/profile_dialog.h
../qt/progress_frame.h
../qt/proto_tree.h
../qt/protocol_hierarchy_dialog.h
../qt/protocol_preferences_menu.h
../qt/recent_file_status.h
../qt/resolved_addresses_dialog.h
../qt/response_time_delay_dialog.h
../qt/rsa_keys_frame.h
../qt/search_frame.h
# XXX Depends on RTP Stream Dialog
# ../qt/sequence_diagram.h
# ../qt/sequence_dialog.h
../qt/show_packet_bytes_dialog.h
../qt/simple_statistics_dialog.h
../qt/stats_tree_dialog.h
../qt/supported_protocols_dialog.h
../qt/tabnav_tree_widget.h
../qt/tap_parameter_dialog.h
../qt/tcp_stream_dialog.h
../qt/time_shift_dialog.h
../qt/traffic_table_dialog.h
../qt/uat_dialog.h
../qt/uat_frame.h
../qt/welcome_page.h
../qt/wireshark_dialog.h
../qt/${WIRESHARK_CUSTOM_QT_HEADERS}
)
if(ENABLE_PCAP)
list(APPEND WIRESHARK_QT_HEADERS
../qt/capture_info_dialog.h
)
if(HAVE_PCAP_REMOTE)
list(APPEND WIRESHARK_QT_HEADERS
../qt/remote_capture_dialog.h
../qt/remote_settings_dialog.h
)
endif()
endif()
set (LOGRAY_QT_HEADERS
logray_application.h
logray_main_window.h
${WIRESHARK_QT_HEADERS}
)
set(WIRESHARK_WIDGET_SRCS
../qt/widgets/additional_toolbar.cpp
../qt/widgets/apply_line_edit.cpp
../qt/widgets/byte_view_text.cpp
../qt/widgets/capture_filter_combo.cpp
../qt/widgets/capture_filter_edit.cpp
../qt/widgets/clickable_label.cpp
../qt/widgets/copy_from_profile_button.cpp
../qt/widgets/detachable_tabwidget.cpp
../qt/widgets/display_filter_combo.cpp
../qt/widgets/display_filter_edit.cpp
../qt/widgets/dissector_syntax_line_edit.cpp
../qt/widgets/dissector_tables_view.cpp
../qt/widgets/drag_drop_toolbar.cpp
../qt/widgets/drag_label.cpp
../qt/widgets/editor_file_dialog.cpp
../qt/widgets/elided_label.cpp
../qt/widgets/expert_info_view.cpp
../qt/widgets/export_objects_view.cpp
../qt/widgets/field_filter_edit.cpp
../qt/widgets/filter_expression_toolbar.cpp
../qt/widgets/find_line_edit.cpp
../qt/widgets/interface_toolbar_lineedit.cpp
../qt/widgets/label_stack.cpp
../qt/widgets/overlay_scroll_bar.cpp
../qt/widgets/packet_list_header.cpp
../qt/widgets/path_selection_edit.cpp
../qt/widgets/pref_module_view.cpp
../qt/widgets/profile_tree_view.cpp
../qt/widgets/range_syntax_lineedit.cpp
../qt/widgets/splash_overlay.cpp
../qt/widgets/stock_icon_tool_button.cpp
../qt/widgets/syntax_line_edit.cpp
../qt/widgets/wireless_timeline.cpp # Required by PacketListModel
../qt/widgets/tabnav_tree_view.cpp
../qt/widgets/traffic_tab.cpp
../qt/widgets/traffic_tree.cpp
../qt/widgets/traffic_types_list.cpp
../qt/widgets/wireshark_file_dialog.cpp
)
set (LOGRAY_WIDGET_SRCS ${WIRESHARK_WIDGET_SRCS})
set(WIRESHARK_3RD_PARTY_WIDGET_SRCS
../qt/widgets/qcustomplot.cpp
)
set (LOGRAY_3RD_PARTY_WIDGET_SRCS ${WIRESHARK_3RD_PARTY_WIDGET_SRCS})
set(WIRESHARK_MANAGER_SRCS
../qt/manager/preference_manager.cpp
../qt/manager/wireshark_preference.cpp
)
set (LOGRAY_MANAGER_SRCS ${WIRESHARK_MANAGER_SRCS})
set(WIRESHARK_UTILS_SRCS
../qt/utils/color_utils.cpp
../qt/utils/data_printer.cpp
../qt/utils/field_information.cpp
../qt/utils/frame_information.cpp
../qt/utils/proto_node.cpp
../qt/utils/qt_ui_utils.cpp
../qt/utils/stock_icon.cpp
../qt/utils/wireshark_mime_data.cpp
../qt/utils/wireshark_zip_helper.cpp
)
set (LOGRAY_UTILS_SRCS ${WIRESHARK_UTILS_SRCS})
set(WIRESHARK_MODEL_SRCS
../qt/models/astringlist_list_model.cpp
../qt/models/atap_data_model.cpp
../qt/models/cache_proxy_model.cpp
../qt/models/coloring_rules_delegate.cpp
../qt/models/coloring_rules_model.cpp
../qt/models/column_list_model.cpp
../qt/models/decode_as_delegate.cpp
../qt/models/decode_as_model.cpp
../qt/models/dissector_tables_model.cpp
../qt/models/enabled_protocols_model.cpp
../qt/models/expert_info_model.cpp
../qt/models/expert_info_proxy_model.cpp
../qt/models/export_objects_model.cpp
../qt/models/fileset_entry_model.cpp
../qt/models/filter_list_model.cpp
../qt/models/info_proxy_model.cpp
../qt/models/interface_sort_filter_model.cpp
../qt/models/interface_tree_cache_model.cpp
../qt/models/interface_tree_model.cpp
../qt/models/numeric_value_chooser_delegate.cpp
../qt/models/packet_list_model.cpp
../qt/models/packet_list_record.cpp
../qt/models/path_selection_delegate.cpp
../qt/models/percent_bar_delegate.cpp
../qt/models/pref_delegate.cpp
../qt/models/pref_models.cpp
../qt/models/profile_model.cpp
../qt/models/proto_tree_model.cpp
../qt/models/related_packet_delegate.cpp
../qt/models/resolved_addresses_models.cpp
../qt/models/sparkline_delegate.cpp
../qt/models/supported_protocols_model.cpp
../qt/models/timeline_delegate.cpp
../qt/models/uat_delegate.cpp
../qt/models/uat_model.cpp
../qt/models/url_link_delegate.cpp
)
set (LOGRAY_MODEL_SRCS ${WIRESHARK_MODEL_SRCS})
set(WIRESHARK_QT_SRC
../qt/about_dialog.cpp
../qt/accordion_frame.cpp
../qt/address_editor_frame.cpp
../qt/byte_view_tab.cpp
../qt/capture_file_dialog.cpp
../qt/capture_file_properties_dialog.cpp
../qt/capture_file.cpp
../qt/capture_filter_syntax_worker.cpp
../qt/capture_options_dialog.cpp
../qt/capture_preferences_frame.cpp
../qt/coloring_rules_dialog.cpp
../qt/column_editor_frame.cpp
../qt/column_preferences_frame.cpp
../qt/compiled_filter_output.cpp
../qt/conversation_colorize_action.cpp
../qt/conversation_dialog.cpp
../qt/conversation_hash_tables_dialog.cpp
../qt/decode_as_dialog.cpp
../qt/display_filter_expression_dialog.cpp
../qt/dissector_tables_dialog.cpp
../qt/enabled_protocols_dialog.cpp
../qt/endpoint_dialog.cpp
../qt/export_dissection_dialog.cpp
../qt/export_object_action.cpp
../qt/export_object_dialog.cpp
../qt/export_pdu_dialog.cpp
../qt/extcap_argument_file.cpp
../qt/extcap_argument_multiselect.cpp
../qt/extcap_argument.cpp
../qt/extcap_options_dialog.cpp
../qt/file_set_dialog.cpp
../qt/filter_action.cpp
../qt/filter_dialog.cpp
../qt/filter_expression_frame.cpp
../qt/follow_stream_action.cpp
../qt/font_color_preferences_frame.cpp
../qt/funnel_string_dialog.cpp
../qt/funnel_text_dialog.cpp
../qt/geometry_state_dialog.cpp
../qt/glib_mainloop_on_qeventloop.cpp
../qt/import_text_dialog.cpp
../qt/interface_frame.cpp
../qt/interface_toolbar_reader.cpp
../qt/interface_toolbar.cpp
../qt/io_console_dialog.cpp
../qt/layout_preferences_frame.cpp
../qt/main_application.cpp
../qt/main_status_bar.cpp
../qt/main_window_layout.cpp
../qt/main_window_preferences_frame.cpp
../qt/main_window.cpp
../qt/manage_interfaces_dialog.cpp
../qt/module_preferences_scroll_area.cpp
../qt/packet_comment_dialog.cpp
../qt/packet_diagram.cpp
../qt/packet_dialog.cpp
../qt/packet_format_group_box.cpp
../qt/packet_list.cpp
../qt/packet_range_group_box.cpp
../qt/preference_editor_frame.cpp
../qt/preferences_dialog.cpp
../qt/print_dialog.cpp
../qt/profile_dialog.cpp
../qt/progress_frame.cpp
../qt/proto_tree.cpp
../qt/protocol_hierarchy_dialog.cpp
../qt/protocol_preferences_menu.cpp
../qt/recent_file_status.cpp
../qt/resolved_addresses_dialog.cpp
../qt/response_time_delay_dialog.cpp
../qt/rsa_keys_frame.cpp
../qt/search_frame.cpp
# XXX Depends on RTP Stream Dialog
# ../qt/sequence_diagram.cpp
# ../qt/sequence_dialog.cpp
../qt/show_packet_bytes_dialog.cpp
../qt/simple_dialog.cpp
../qt/simple_statistics_dialog.cpp
../qt/supported_protocols_dialog.cpp
../qt/tabnav_tree_widget.cpp
../qt/tap_parameter_dialog.cpp
../qt/tcp_stream_dialog.cpp
../qt/time_shift_dialog.cpp
../qt/traffic_table_dialog.cpp
../qt/uat_dialog.cpp
../qt/uat_frame.cpp
../qt/welcome_page.cpp
../qt/wireshark_dialog.cpp
../qt/${WIRESHARK_CUSTOM_QT_SRCS}
)
if(ENABLE_PCAP)
list(APPEND WIRESHARK_QT_SRC
../qt/capture_info_dialog.cpp
)
if(HAVE_PCAP_REMOTE)
list(APPEND WIRESHARK_QT_SRC
../qt/remote_capture_dialog.cpp
../qt/remote_settings_dialog.cpp
)
endif()
endif()
set (LOGRAY_QT_SRC
logray_application.cpp
logray_main.cpp
logray_main_window.cpp
logray_main_window_slots.cpp
${WIRESHARK_QT_SRC})
set(WIRESHARK_QT_TAP_SRC
${CMAKE_CURRENT_SOURCE_DIR}/../qt/expert_info_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../qt/funnel_statistics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../qt/io_graph_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../qt/stats_tree_dialog.cpp
${WIRESHARK_CUSTOM_TAP_SRC}
)
set (LOGRAY_QT_TAP_SRC ${WIRESHARK_QT_TAP_SRC})
set(WIRESHARK_QT_FILES
${WIRESHARK_QT_SRC}
${WIRESHARK_QT_TAP_SRC}
)
set (LOGRAY_QT_FILES ${WIRESHARK_QT_FILES})
set(WIRESHARK_QT_UI
../qt/about_dialog.ui
../qt/address_editor_frame.ui
../qt/capture_file_properties_dialog.ui
../qt/capture_info_dialog.ui
../qt/capture_options_dialog.ui
../qt/capture_preferences_frame.ui
../qt/coloring_rules_dialog.ui
../qt/column_editor_frame.ui
../qt/column_preferences_frame.ui
../qt/compiled_filter_output.ui
../qt/conversation_hash_tables_dialog.ui
../qt/decode_as_dialog.ui
../qt/display_filter_expression_dialog.ui
../qt/dissector_tables_dialog.ui
../qt/enabled_protocols_dialog.ui
../qt/expert_info_dialog.ui
../qt/export_object_dialog.ui
../qt/export_pdu_dialog.ui
../qt/extcap_options_dialog.ui
../qt/file_set_dialog.ui
../qt/filter_dialog.ui
../qt/filter_expression_frame.ui
../qt/font_color_preferences_frame.ui
../qt/funnel_string_dialog.ui
../qt/funnel_text_dialog.ui
../qt/import_text_dialog.ui
../qt/interface_frame.ui
../qt/interface_toolbar.ui
../qt/io_console_dialog.ui
../qt/io_graph_dialog.ui
../qt/layout_preferences_frame.ui
../qt/main_window_preferences_frame.ui
../qt/manage_interfaces_dialog.ui
../qt/module_preferences_scroll_area.ui
../qt/packet_comment_dialog.ui
../qt/packet_dialog.ui
../qt/packet_format_group_box.ui
../qt/packet_range_group_box.ui
../qt/preference_editor_frame.ui
../qt/preferences_dialog.ui
../qt/print_dialog.ui
../qt/profile_dialog.ui
../qt/progress_frame.ui
../qt/protocol_hierarchy_dialog.ui
../qt/resolved_addresses_dialog.ui
../qt/rsa_keys_frame.ui
../qt/search_frame.ui
# XXX Depends on RTP Stream Dialog
# ../qt/sequence_dialog.ui
../qt/show_packet_bytes_dialog.ui
../qt/supported_protocols_dialog.ui
../qt/tap_parameter_dialog.ui
../qt/tcp_stream_dialog.ui
../qt/time_shift_dialog.ui
../qt/traffic_table_dialog.ui
../qt/uat_dialog.ui
../qt/uat_frame.ui
../qt/welcome_page.ui
../qt/widgets/splash_overlay.ui
)
if(HAVE_PCAP_REMOTE)
list(APPEND WIRESHARK_QT_UI
../qt/remote_capture_dialog.ui
../qt/remote_settings_dialog.ui
)
endif()
set (LOGRAY_QT_UI
logray_main_window.ui
${WIRESHARK_QT_UI}
)
set(WIRESHARK_QT_TS
../qt/wireshark_de.ts
../qt/wireshark_en.ts # lupdate -pluralonly
../qt/wireshark_es.ts
../qt/wireshark_fr.ts
../qt/wireshark_it.ts
../qt/wireshark_ja_JP.ts
../qt/wireshark_pl.ts
../qt/wireshark_ru.ts
../qt/wireshark_sv.ts
../qt/wireshark_tr_TR.ts
../qt/wireshark_uk.ts
../qt/wireshark_zh_CN.ts
)
set(LOGRAY_QT_TS
logray_en.ts
${WIRESHARK_QT_TS}
)
foreach(_file ${LOGRAY_QT_TS})
get_filename_component(_qresource ${_file} NAME_WE)
set(_qresource_qm "${_qresource}.qm")
set(i18n_qresource "${i18n_qresource}\n <file>${_qresource_qm}</file>")
endforeach()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/i18n.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc)
set(LOGRAY_QT_QRC
../../resources/about.qrc
../../resources/languages/languages.qrc
../../resources/layout.qrc
../../resources/lricon.qrc
../../resources/stock_icons.qrc
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
)
if(NOT Qt${qtver}Widgets_VERSION VERSION_LESS "5.9")
# Drop the file modification time of source files from generated files
# to help with reproducible builds. We do not use QFileInfo.lastModified
# so this has no unwanted side effects. This mtime started appearing in
# Qt 5.8. The option to force the old file format without mtime was
# added in Qt 5.9. See https://bugreports.qt.io/browse/QTBUG-58769.
# Force the compression algorithm to zlib, since zstd requires format
# version 3. See https://gitlab.com/wireshark/wireshark/-/issues/18100.
# Use the number of dashes for each argument as documented at
# https://doc.qt.io/qt-6/rcc.html.
set(CMAKE_AUTORCC_OPTIONS --format-version 1)
if(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "5.13")
list(APPEND CMAKE_AUTORCC_OPTIONS -compress-algo zlib)
endif()
endif()
if (USE_qt6)
QT6_ADD_TRANSLATION(LOGRAY_QT_QM ${LOGRAY_QT_TS} OPTIONS -silent)
elseif(NOT Qt${qtver}Widgets_VERSION VERSION_LESS "5.11")
QT5_ADD_TRANSLATION(LOGRAY_QT_QM ${LOGRAY_QT_TS} OPTIONS -silent)
else()
QT5_ADD_TRANSLATION(LOGRAY_QT_QM ${LOGRAY_QT_TS})
endif()
add_custom_target(
logray_translations
DEPENDS
${LOGRAY_QT_QM}
)
set_target_properties(logray_translations PROPERTIES FOLDER "UI")
set_source_files_properties(
${LOGRAY_QT_FILES}
PROPERTIES
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
)
set_source_files_properties(
logray-tap-register.c
PROPERTIES
SKIP_AUTOGEN ON
)
add_definitions(${QT_DEFINITIONS})
register_tap_files(logray-tap-register.c
${LOGRAY_QT_TAP_SRC}
)
source_group("ui\\UIC Files" FILES ${LOGRAY_QT_UI})
source_group("ui\\qrc" FILES ${LOGRAY_QT_QRC})
source_group("ui\\Header" FILES ${LOGRAY_QT_HEADERS})
source_group("ui\\Widget Header" FILES ${LOGRAY_WIDGET_HEADERS})
source_group("ui\\Widget Source" FILES ${LOGRAY_WIDGET_SRCS})
source_group("ui\\Utils Headers Files" FILES ${LOGRAY_UTILS_HEADERS})
source_group("ui\\Utils Source" FILES ${LOGRAY_UTILS_SRCS})
source_group("ui\\Models Headers" FILES ${LOGRAY_MODEL_HEADERS})
source_group("ui\\Models Source" FILES ${LOGRAY_MODEL_SRCS})
source_group("ui\\Manager Headers" FILES ${LOGRAY_MANAGER_HEADERS})
source_group("ui\\Manager Source" FILES ${LOGRAY_MANAGER_SRCS})
add_library(ui_logray OBJECT
#Included so that Visual Studio can properly put header files in solution
${LOGRAY_QT_HEADERS}
${LOGRAY_WIDGET_HEADERS}
${LOGRAY_3RD_PARTY_WIDGET_HEADERS}
${LOGRAY_MANAGER_HEADERS}
${LOGRAY_UTILS_HEADERS}
${LOGRAY_MODEL_HEADERS}
${LOGRAY_QT_SRC}
${LOGRAY_WIDGET_SRCS}
${LOGRAY_3RD_PARTY_WIDGET_SRCS}
${LOGRAY_MANAGER_SRCS}
${LOGRAY_UTILS_SRCS}
${LOGRAY_MODEL_SRCS}
# For AUTOUIC and AUTORCC.
${LOGRAY_QT_UI}
${LOGRAY_QT_QRC}
${LOGRAY_QT_TAP_SRC}
logray-tap-register.c
)
target_include_directories(ui_logray
SYSTEM PRIVATE
# Include Qt before anything else, see the comment about
# QT5_INCLUDE_DIRS in the top-level CMakeLists.txt
# Basically, qt@5 headers should be prioritized over qt@6 which
# would be found due to GCRYPT_INCLUDE_DIRS=/usr/local/include
${QT5_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
${MINIZIP_INCLUDE_DIRS}
${PCAP_INCLUDE_DIRS}
${SPEEXDSP_INCLUDE_DIRS}
${WINSPARKLE_INCLUDE_DIRS}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../qt
)
if(USE_qt6)
target_link_libraries(ui_logray PUBLIC
Qt6::Widgets
Qt6::Core5Compat
Qt6::Concurrent
Qt6::PrintSupport
)
if(Qt6Multimedia_FOUND)
target_link_libraries(ui_logray PUBLIC Qt6::Multimedia)
endif()
endif()
target_compile_definitions(ui_logray
PUBLIC
${QT5_COMPILE_DEFINITIONS}
)
set_target_properties(ui_logray PROPERTIES
LINK_FLAGS "${WS_LINK_FLAGS}"
FOLDER "UI"
AUTOMOC ON
AUTOUIC ON
AUTORCC ON
# Ensure .qm files are generated before autogenerating i18n.qrc
AUTOGEN_TARGET_DEPENDS "${LOGRAY_QT_QM}"
)
if(MSVC)
set_target_properties(ui_logray PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
endif()
CHECKAPI(
NAME
ui-qt-logray
SWITCHES
--nocheck-shadow
SOURCES
# QCustomPlot (LOGRAY_3RD_PARTY_WIDGET_{HEADERS,SRCS}) uses
# prohibited APIs.
${LOGRAY_QT_HEADERS}
${LOGRAY_WIDGET_HEADERS}
${LOGRAY_MANAGER_HEADERS}
${LOGRAY_UTILS_HEADERS}
${LOGRAY_MODEL_HEADERS}
${LOGRAY_QT_SRC}
${LOGRAY_WIDGET_SRCS}
${LOGRAY_MANAGER_SRCS}
${LOGRAY_UTILS_SRCS}
${LOGRAY_MODEL_SRCS}
${LOGRAY_QT_TAP_SRC}
)
#
# Editor modelines - https://www.wireshark.org/tools/modelines.html
#
# Local variables:
# c-basic-offset: 8
# tab-width: 8
# indent-tabs-mode: t
# End:
#
# vi: set shiftwidth=8 tabstop=8 noexpandtab:
# :indentSize=8:tabSize=8:noTabs=false:
# |
C++ | wireshark/ui/logray/logray_application.cpp | /* logray_application.cpp
*
* Logray - Event log analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "logray_application.h"
#include "extcap.h"
#include "ui/iface_lists.h"
#include "ui/ws_ui_util.h"
LograyApplication *lwApp = NULL;
LograyApplication::LograyApplication(int &argc, char **argv) :
MainApplication(argc, argv)
{
lwApp = this;
Q_INIT_RESOURCE(lricon);
setApplicationName("Logray");
setDesktopFileName(QStringLiteral("org.wireshark.Logray"));
}
LograyApplication::~LograyApplication()
{
lwApp = NULL;
}
void LograyApplication::refreshLocalInterfaces()
{
extcap_clear_interfaces();
#ifdef HAVE_LIBPCAP
GList * filter_list = NULL;
filter_list = g_list_append(filter_list, GUINT_TO_POINTER((guint) IF_EXTCAP));
scan_local_interfaces_filtered(filter_list, main_window_update);
g_list_free(filter_list);
emit localInterfaceListChanged();
#endif
}
void LograyApplication::initializeIcons()
{
// Do this as late as possible in order to allow time for
// MimeDatabaseInitThread to do its work.
QList<int> icon_sizes = QList<int>() << 16 << 24 << 32 << 48 << 64 << 128 << 256 << 512 << 1024;
foreach (int icon_size, icon_sizes) {
QString icon_path = QString(":/lricon/lricon%1.png").arg(icon_size);
normal_icon_.addFile(icon_path);
icon_path = QString(":/lricon/lriconcap%1.png").arg(icon_size);
capture_icon_.addFile(icon_path);
}
} |
C/C++ | wireshark/ui/logray/logray_application.h | /** @file
*
* Logray - Event log analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef LOGRAY_APPLICATION_H
#define LOGRAY_APPLICATION_H
#include <main_application.h>
// To do:
// - Remove SequenceDiagram dependency on RTPStreamDialog
// - Remove PacketListModel dependency on WirelessTimeline
class LograyApplication : public MainApplication
{
public:
explicit LograyApplication(int &argc, char **argv);
~LograyApplication();
void refreshLocalInterfaces() override;
private:
void initializeIcons() override;
};
extern LograyApplication *lwApp;
#endif // LOGRAY_APPLICATION_H |
wireshark/ui/logray/logray_en.ts | <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en">
<context>
<name>Abbreviation</name>
<message>
<source></source>
<comment>for "not applicable"</comment>
<translation></translation>
</message>
</context>
<context>
<name>AboutDialog</name>
<message>
<source>About Wireshark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wireshark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><span size=\"x-large\" weight=\"bold\">Network Protocol Analyzer</span></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy the version information to the clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy To Clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Authors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Authors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Folders</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter by path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No plugins found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter by type:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Keyboard Shortcuts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Shortcuts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Acknowledgments</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>License</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The directory does not exist</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Should the directory %1 be created?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The directory could not be created</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The directory %1 could not be created.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show in Finder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show in Folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>Copy Row(s)</source>
<translation type="unfinished">
<numerusform>Copy Row</numerusform>
<numerusform>Copy Rows</numerusform>
</translation>
</message>
</context>
<context>
<name>AddressEditorFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name Resolution Preferences…</source>
<oldsource>Name Resolution Preferences...</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Address:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can't assign %1 to %2.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AdvancedPrefsModel</name>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Status</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Value</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ApplyLineEdit</name>
<message>
<source>Apply changes</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AuthorListModel</name>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Email</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BluetoothAttServerAttributesDialog</name>
<message>
<source>Bluetooth ATT Server Attributes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Handle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UUID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UUID Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Devices</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove duplicates</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy Cell</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy Rows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark/Unmark Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ctrl-M</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark/Unmark Cell</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Table Image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PNG Image (*.png)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BluetoothDeviceDialog</name>
<message>
<source>Bluetooth Device</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>BD_ADDR</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>OUI</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Class of Device</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LMP Version</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LMP Subversion</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manufacturer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>HCI Version</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>HCI Revision</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scan</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Authentication</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Encryption</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ACL MTU</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ACL Total Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCO MTU</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCO Total Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LE ACL MTU</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LE ACL Total Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LE ISO MTU</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LE ISO Total Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inquiry Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Page Timeout</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Simple Pairing Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Voice Setting</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Changes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 changes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy Cell</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy Rows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark/Unmark Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ctrl-M</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark/Unmark Cell</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bluetooth Device - %1%2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>enabled</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>disabled</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 ms (%2 slots)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Table Image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PNG Image (*.png)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BluetoothDevicesDialog</name>
<message>
<source>Bluetooth Devices</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>BD_ADDR</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>OUI</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LMP Version</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LMP Subversion</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manufacturer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>HCI Version</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>HCI Revision</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Is Local Adapter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show information steps</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 items; Right click for more option; Double click for device details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy Cell</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy Rows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark/Unmark Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ctrl-M</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark/Unmark Cell</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>true</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Table Image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PNG Image (*.png)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BluetoothHciSummaryDialog</name>
<message>
<source>Bluetooth HCI Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>OGF</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>OCF</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Opcode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Event</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Subevent</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Status</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reason</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Occurrence</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Link Control Commands</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x01</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Link Policy Commands</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x02</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Controller & Baseband Commands</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x03</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Informational Parameters</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x04</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Status Parameters</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x05</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Testing Commands</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x06</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LE Controller Commands</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x08</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bluetooth Logo Testing Commands</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x3E</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vendor-Specific Commands</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0x3F</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown OGF</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Events</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware Errors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Results filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Adapters</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy Cell</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy Rows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark/Unmark Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ctrl+M</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark/Unmark Cell</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Adapter %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Frame %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pending</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Table Image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PNG Image (*.png)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ByteViewTab</name>
<message>
<source>Packet bytes</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ByteViewText</name>
<message>
<source>Allow hover selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show bytes as hexadecimal</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as bits</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show text based on packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as ASCII</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as EBCDIC</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CaptureFile</name>
<message>
<source> [closing]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> [closed]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CaptureFileDialog</name>
<message>
<source>This capture file contains comments.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The file format you chose doesn't support comments. Do you want to save the capture in a format that supports comments or discard the comments and save in the format you chose?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Discard comments and save</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save in another format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No file format in which it can be saved supports comments. Do you want to discard the comments and save in the format you chose?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Files (</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Capture Files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Format:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Size:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start / elapsed:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Automatically detect file type</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%1, error after %Ln packet(s)</source>
<oldsource>%1, error after %2 packets</oldsource>
<translation type="vanished">
<numerusform>%1, error after %Ln packet</numerusform>
<numerusform>%1, error after %Ln packets</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%1, timed out at %Ln packet(s)</source>
<oldsource>%1, timed out at %2 packets</oldsource>
<translation type="vanished">
<numerusform>%1, timed out at %Ln packet</numerusform>
<numerusform>%1, timed out at %Ln packets</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%1, %Ln packet(s)</source>
<translation type="vanished">
<numerusform>%1, %Ln packet</numerusform>
<numerusform>%1, %Ln packets</numerusform>
</translation>
</message>
<message>
<source>Prepend packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Insert packets from the selected file before the current file. Packet timestamps will be ignored.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Merge chronologically</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Insert packets in chronological order.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Append packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Insert packets from the selected file after the current file. Packet timestamps will be ignored.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Read filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Compress with g&zip</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open Capture File</source>
<oldsource>Wireshark: Open Capture File</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Capture File As</source>
<oldsource>Wireshark: Save Capture File As</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export Specified Packets</source>
<oldsource>Wireshark: Export Specified Packets</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export as:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Merge Capture File</source>
<oldsource>Wireshark: Merge Capture File</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown file type returned by save as dialog.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please report this as a Wireshark issue at https://gitlab.com/wireshark/wireshark/-/issues.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown file format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>error opening file</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%1, error after %Ln data record(s)</source>
<oldsource>%1, error after %Ln record(s)</oldsource>
<translation type="unfinished">
<numerusform>%1, error after %Ln data record</numerusform>
<numerusform>%1, error after %Ln data records</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%1, timed out at %Ln data record(s)</source>
<translation type="unfinished">
<numerusform>%1, timed out at %Ln data record</numerusform>
<numerusform>%1, timed out at %Ln data records</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%1, %Ln data record(s)</source>
<translation type="unfinished">
<numerusform>%1, %Ln data record</numerusform>
<numerusform>%1, %Ln data records</numerusform>
</translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CaptureFilePropertiesDialog</name>
<message>
<source>Details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture file comments</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy To Clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Comments</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture File Properties</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Length</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hash (SHA256)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hash (RIPEMD160)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hash (SHA1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Encapsulation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Snapshot length</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Last packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Elapsed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Section %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hardware</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>OS</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Application</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interface</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Dropped packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Link type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet size limit (snaplen)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>none</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Measurement</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Captured</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Displayed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Marked</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time span, s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average pps</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average packet size, B</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average bytes/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average bits/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Section Comment</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Comments</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><p>Frame %1: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Created by Wireshark %1
</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CaptureFilterCombo</name>
<message>
<source>Capture filter selector</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CaptureFilterEdit</name>
<message>
<source>Capture filter entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manage saved bookmarks.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply this filter string to the display.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Multiple filters selected. Override them here or leave this blank to preserve them.</source>
<extracomment>This is a very long concept that needs to fit into a short space.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source><p>The interfaces you have selected have different capture filters. Typing a filter here will override them. Doing nothing will preserve them.</p></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a capture filter %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save this filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove this filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manage Capture Filters</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CaptureInfoDialog</name>
<message>
<source>Capture Information</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 packets, %2:%3:%4</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CaptureInfoModel</name>
<message>
<source>Other</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CaptureOptionsDialog</name>
<message>
<source>Input</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interface</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Traffic</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Link-layer Header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Promiscuous</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Snaplen (B)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Buffer (MB)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Monitor Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>You probably want to enable this. Usually a network card will only capture the traffic sent to its own network address. If you want to capture all traffic that the network card can &quot;see&quot;, mark this option. See the FAQ for some more details of capturing packets from a switched network.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable promiscuous mode on all interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show and hide interfaces, add comments, and manage pipes and remote interfaces.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manage Interfaces…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture filter for selected interfaces:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Compile BPFs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Output</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Enter the file name to which captured data will be written. By default, a temporary file will be used.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture to a permanent file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>File:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Browse…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Output format:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>pcapng</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>pcap</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Instead of using a single capture file, multiple files will be created.</p><p>The generated file names will contain an incrementing number and the start time of the capture.</p><p>NOTE: If enabled, at least one of the new-file criteria MUST be selected.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Create a new file automatically…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>after</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the next file after the specified number of packets have been captured.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the next file after the file size exceeds the specified file size.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>kilobytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>megabytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>gigabytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the next file when the time capturing to the current file exceeds the specified time.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>minutes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>hours</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>when time is a multiple of</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the next file when the (wall clock) time is an even multiple of the specified interval.
For example, use 1 hour to have a new file created every hour on the hour.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>compression</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>gzip</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>After capturing has switched to the next file and the given number of files has exceeded, the oldest file will be removed.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use a ring buffer with </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Using this option will show the captured packets immediately on the main screen. Please note: this will slow down capturing, so increased packet drops might appear.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Update list of packets in real-time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>This will scroll the &quot;Packet List&quot; automatically to the latest captured packet, when the &quot;Update list of packets in real-time&quot; option is used.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Automatically scroll during live capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Show the capture info dialog while capturing.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show capture information during live capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name Resolution</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Perform MAC layer name resolution while capturing.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolve MAC addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Perform network layer name resolution while capturing.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolve network names</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Perform transport layer name resolution while capturing.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolve transport names</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop capture automatically after…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Stop capturing after the specified number of packets have been captured.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop capturing after the specified number of packets have been captured.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Stop capturing after the specified number of files have been created.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Stop capturing after the specified amount of data has been captured.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop capturing after the specified amount of data has been captured.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop capturing after the specified amount of time has passed.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Leave blank to use a temporary file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Specify a Capture File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1: %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Multiple files: Requested filesize too large. The filesize cannot be greater than 2 GiB.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Multiple files: No capture file name given. You must specify a filename if you want to use multiple files.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Multiple files: No file limit given. You must specify a file size, interval, or number of packets for each file.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CapturePreferencesFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Default interface</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>You probably want to enable this. Usually a network card will only capture the traffic sent to its own network address. If you want to capture all traffic that the network card can &quot;see&quot;, mark this option. See the FAQ for some more details of capturing packets from a switched network.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture packets in promiscuous mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Capture packets in the next-generation capture file format.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture packets in pcapng format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Update the list of packets while capture is in progress. This can result in dropped packets on high-speed networks.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Update list of packets in real time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Keep the packet list scrolled to the bottom while capturing.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Automatic scrolling in live capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Don't load interfaces on startup</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disable external capture interfaces</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ColoringRulesDelegate</name>
<message>
<source>the "@" symbol will be ignored.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ColoringRulesDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add a new coloring rule.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete this coloring rule.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Duplicate this coloring rule.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear all coloring rules.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set the foreground color for this rule.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Foreground</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set the background color for this rule.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Background</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set the display filter using this rule.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply as filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a file and add its filters to the end of the list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save filters in a file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Coloring Rules %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy coloring rules from another profile.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Double click to edit. Drag to move. Rules are processed in order until a match is found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Coloring Rules</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export %1 Coloring Rules</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Your coloring rules file contains unknown rules</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wireshark doesn't recognize one or more of your coloring rules. They have been disabled.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ColoringRulesModel</name>
<message>
<source>New coloring rule</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to save coloring rules: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ColumnEditorFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Title:</source>
<oldsource>Title</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type:</source>
<oldsource>Type</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fields:</source>
<oldsource>Fields</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Occurrence:</source>
<oldsource>Occurrence</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing fields.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid fields.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid occurrence value.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ColumnListModel</name>
<message>
<source>Displayed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Title</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fields</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Field Occurrence</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Column</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ColumnPreferencesFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add a new column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete selected column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show displayed columns only</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset all changes</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CompiledFilterOutput</name>
<message>
<source>Compiled Filter Output</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy filter text to the clipboard.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConversationDialog</name>
<message>
<source>Follow Stream…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Follow a TCP or UDP stream.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Graph…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Graph a TCP conversation.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ConversationHashTablesDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Conversation Hash Tables</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CopyFromProfileButton</name>
<message>
<source>Copy from</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy entries from another profile.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>System default</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DataPrinter</name>
<message>
<source>Copy Bytes as Hex + ASCII Dump</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy packet bytes as a hex and ASCII dump.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as Hex Dump</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy packet bytes as a hex dump.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as Printable Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy only the printable text in the packet.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as a Hex Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy packet bytes as a stream of hex.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as Raw Binary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy packet bytes as application/octet-stream MIME data.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as Escaped String</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy packet bytes as an escaped string.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DecodeAsDialog</name>
<message>
<source>Change the dissection behavior for a protocol.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove this dissection behavior.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this dissection behavior.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear all dissection behaviors.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Decode As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DecodeAsModel</name>
<message>
<source>Match using this field</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current"Decode As" behavior</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Default "Decode As" behavior</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Change behavior when the protocol field matches this value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>String</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Integer, base </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><none></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GUID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Field</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Default</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DisplayFilterCombo</name>
<message>
<source>Display filter selector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select from previously used filters.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DisplayFilterEdit</name>
<message>
<source>Display filter entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manage saved bookmarks.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Filter Expression…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply a display filter %1 <%2/></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a display filter %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left align buttons</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply a read filter %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current filter: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid filter: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save this filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove this filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manage Display Filters</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter Button Preferences...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DisplayFilterExpressionDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a field to start building a display filter.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Field Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Search the list of field names.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Relations can be used to restrict fields to specific values. Each relation does the following:</p><table border="0" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;" cellspacing="2" cellpadding="0"><tr><td><p align="center"><span style=" font-weight:600;">is present</span></p></td><td><p>Match any packet that contains this field</p></td></tr><tr><td><p align="center"><span style=" font-weight:600;">==, !=, etc.</span></p></td><td><p>Compare the field to a specific value.</p></td></tr><tr><td><p align="center"><span style=" font-weight:600;">contains, matches</span></p></td><td><p>Check the field against a string (contains) or a regular expression (matches)</p></td></tr><tr><td><p align="center"><span style=" font-weight:600;">in</span></p></td><td><p>Compare the field to a specific set of values</p></td></tr></table></body></html>
</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Relation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Match against this value.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>If the field you have selected has a known set of valid values they will be listed here.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Predefined Values</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>If the field you have selected covers a range of bytes (e.g. you have selected a protocol) you can restrict the match to a range of bytes here.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Range (offset:length)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Filter Expression</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a field name to get started</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click OK to insert this filter</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DissectorTablesDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Dissector Tables</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DissectorTablesProxyModel</name>
<message>
<source>Table Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>String</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Dissector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Integer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Protocol</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Short Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Table Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Selector Name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EnabledProtocolsDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>Disabling a protocol prevents higher layer protocols from being displayed</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>in</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disable All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enabled Protocols</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Everywhere</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Only Protocols</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Only Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Only enabled protocols</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Only disabled protocols</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>any protocol</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>non-heuristic protocols</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>heuristic protocols</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EnabledProtocolsModel</name>
<message>
<source>Protocol</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EndpointDialog</name>
<message>
<source>Map</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Draw IPv4 or IPv6 endpoints on a map.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open in browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Map file error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No endpoints available to map</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to create temporary file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Endpoints Map</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to save map file %1.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EthernetAddressModel</name>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All entries</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hosts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ethernet Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ethernet Manufacturers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ethernet Well-Known Addresses</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExpertInfoDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit to Display Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Group by summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search expert summaries.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show…</source>
<oldsource>Show...</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show error packets.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show warning packets.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Note</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show note packets.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show chat packets.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comment</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show comment packets.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expert Information</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Collapse All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expand All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture file closed.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No display filter set.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit information to "%1".</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter: "%1"</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExpertInfoProxyModel</name>
<message>
<source>Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Severity</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Protocol</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Count</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExportDissectionDialog</name>
<message>
<source>Export Packet Dissections</source>
<oldsource>Wireshark: Export Packet Dissections</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export As:</source>
<oldsource>Export as:</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Plain text (*.txt)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comma Separated Values - summary (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PSML - summary (*.psml, *.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PDML - details (*.pdml, *.xml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JSON (*.json)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>C Arrays - bytes (*.c, *.h)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExportObjectDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Content Type:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Searching for objects</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Text Filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Only display entries containing this string</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Preview</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Content-Types</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 object list</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Object As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save All Objects In…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExportObjectModel</name>
<message>
<source>Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hostname</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Content Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filename</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExportPDUDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExtArgSelector</name>
<message>
<source>Reload data</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExtcapArgumentFileSelection</name>
<message>
<source>Clear</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Files (</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select File</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ExtcapOptionsDialog</name>
<message>
<source>Interface Options</source>
<oldsource>Extcap Interface Options</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Default</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Extcap Help cannot be found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The help for the extcap interface %1 cannot be found. Given file: %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save parameter(s) on capture start</source>
<translation type="unfinished">Save parameter on capture start</translation>
</message>
</context>
<context>
<name>FieldFilterEdit</name>
<message>
<source>Display filter entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a field %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid filter: </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FileSetDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Directory:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No files in Set</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No capture loaded</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln File(s) in Set</source>
<oldsource>%1 File%2 in Set</oldsource>
<translation>
<numerusform>%Ln File in Set</numerusform>
<numerusform>%Ln Files in Set</numerusform>
</translation>
</message>
</context>
<context>
<name>FilesetEntryModel</name>
<message>
<source>Open this capture file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filename</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Created</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Modified</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Size</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FilterAction</name>
<message>
<source>Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Not Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…and Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…or Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…and not Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…or not Selected</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FilterDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Create a new filter.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove this filter.</source>
<oldsource>Remove this profile.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this filter.</source>
<oldsource>Copy this profile.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture Filters</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Filters</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>New capture filter</source>
<extracomment>This text is automatically filled in when a new filter is created</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>New display filter</source>
<extracomment>This text is automatically filled in when a new filter is created</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FilterExpressionFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter Buttons Preferences…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Label:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a description for the filter button</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a filter expression to be applied</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comment:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a comment for the filter button</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing label.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing filter expression.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid filter expression.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FilterExpressionToolBar</name>
<message>
<source>Filter Button Preferences...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disable</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FilterListModel</name>
<message>
<source>Filter Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter Expression</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FindLineEdit</name>
<message>
<source>Textual Find</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Regular Expression Find</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FolderListModel</name>
<message>
<source>"File" dialogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>capture files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Temp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>untitled capture files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Personal configuration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Global configuration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>dfilters, preferences, ethers, …</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>dfilters, preferences, manuf, …</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>System</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ethers, ipxnets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Program</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>program files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Personal Plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>binary plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Global Plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Personal Lua Plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>lua scripts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Global Lua Plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Extcap Plugins search path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Personal Extcap path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Global Extcap path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MaxMind DB path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MaxMind DB database search path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MIB/PIB path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SMI MIB/PIB search path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>macOS Extras</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Extra macOS packages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Location</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Typical Files</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FollowStreamDialog</name>
<message>
<source>Filter Out This Stream</source>
<oldsource>Hide this stream</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln client pkt(s), </source>
<translation type="vanished">
<numerusform>%Ln client pkt, </numerusform>
<numerusform>%Ln client pkts, </numerusform>
</translation>
</message>
<message numerus="yes">
<source>%Ln server pkt(s), </source>
<translation type="vanished">
<numerusform>%Ln server pkt, </numerusform>
<numerusform>%Ln server pkts, </numerusform>
</translation>
</message>
<message>
<source>ASCII</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>C Arrays</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>EBCDIC</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hex Dump</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UTF-8</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Raw</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Back</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet %1. </source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln <span style="color: %1; background-color:%2">client</span> pkt(s), </source>
<translation>
<numerusform>%Ln <span style="color: %1; background-color:%2">client</span> pkt, </numerusform>
<numerusform>%Ln <span style="color: %1; background-color:%2">client</span> pkts, </numerusform>
</translation>
</message>
<message numerus="yes">
<source>%Ln <span style="color: %1; background-color:%2">server</span> pkt(s), </source>
<translation>
<numerusform>%Ln <span style="color: %1; background-color:%2">server</span> pkt, </numerusform>
<numerusform>%Ln <span style="color: %1; background-color:%2">server</span> pkts, </numerusform>
</translation>
</message>
<message numerus="yes">
<source>%Ln turn(s).</source>
<translation>
<numerusform>%Ln turn.</numerusform>
<numerusform>%Ln turns.</numerusform>
</translation>
</message>
<message>
<source> Click to select.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Regex Find:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No capture file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please make sure you have a capture file opened.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error following stream.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture file invalid.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please make sure you have a %1 packet selected.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>QUIC streams not found on the selected packet.</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln total sub stream(s).</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
</translation>
</message>
<message numerus="yes">
<source>Total number of QUIC connections: %Ln</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
</translation>
</message>
<message numerus="yes">
<source>Max QUIC Stream ID for the selected connection: %Ln</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
</translation>
</message>
<message>
<source>No streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Entire conversation (%1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Follow %1 Stream (%2)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error creating filter for this stream.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Stream Content As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[Stream output truncated]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A transport or network layer header is needed.</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln total stream(s).</source>
<translation type="unfinished">
<numerusform>%Ln stream.</numerusform>
<numerusform>%Ln total streams.</numerusform>
</translation>
</message>
<message>
<source>File closed.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Follow Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hint.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show data as</source>
<oldsource>Show and save data as</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Substream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find &Next</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FontColorPreferencesFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Main window font:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select Font</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Colors:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>System Default</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Solid</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample ignored packet text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample marked packet text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample active selected item</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Style:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gradient</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample inactive selected item</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample "Follow Stream" client text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample "Follow Stream" server text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample valid filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample invalid filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample warning filter</source>
<oldsource>Sample deprecated filter</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Example GIF query packets have jumbo window sizes</source>
<extracomment>These are pangrams. Feel free to replace with nonsense text that spans your alphabet. https://en.wikipedia.org/wiki/Pangram</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lazy badgers move unique waxy jellyfish packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Font</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FunnelStringDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FunnelTextDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Enter some text or a regular expression. It will be highlighted above.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Highlight:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GsmMapSummaryDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GSM MAP Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Length</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Snapshot length</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Last packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Elapsed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invokes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total number of Invokes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average number of Invokes per second</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total number of bytes for Invokes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average number of bytes per Invoke</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Return Results</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total number of Return Results</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average number of Return Results per second</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total number of bytes for Return Results</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average number of bytes per Return Result</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Totals</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total number of GSM MAP messages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average number of GSM MAP messages per second</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total number of bytes for GSM MAP messages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average number of bytes per GSM MAP message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>IOGraphDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body>
<h3>Valuable and amazing time-saving keyboard shortcuts</h3>
<table><tbody>
<tr><th>+</th><td>Zoom in</td></th>
<tr><th>-</th><td>Zoom out</td></th>
<tr><th>x</th><td>Zoom in X axis</td></th>
<tr><th>X</th><td>Zoom out X axis</td></th>
<tr><th>y</th><td>Zoom in Y axis</td></th>
<tr><th>Y</th><td>Zoom out Y axis</td></th>
<tr><th>0</th><td>Reset graph to its initial state</td></th>
<tr><th>→</th><td>Move right 10 pixels</td></th>
<tr><th>←</th><td>Move left 10 pixels</td></th>
<tr><th>↑</th><td>Move up 10 pixels</td></th>
<tr><th>↓</th><td>Move down 10 pixels</td></th>
<tr><th><i>Shift+</i>→</th><td>Move right 1 pixel</td></th>
<tr><th><i>Shift+</i>←</th><td>Move left 1 pixel</td></th>
<tr><th><i>Shift+</i>↑</th><td>Move up 1 pixel</td></th>
<tr><th><i>Shift+</i>↓</th><td>Move down 1 pixel</td></th>
<tr><th>g</th><td>Go to packet under cursor</td></th>
<tr><th>z</th><td>Toggle mouse drag / zoom</td></th>
<tr><th>t</th><td>Toggle capture / session time origin</td></th>
<tr><th>Space</th><td>Toggle crosshairs</td></th>
</tbody></table>
</body></html></source>
<oldsource><html><head/><body>
<h3>Valuable and amazing time-saving keyboard shortcuts</h3>
<table><tbody>
<tr><th>+</th><td>Zoom in</td></th>
<tr><th>-</th><td>Zoom out</td></th>
<tr><th>0</th><td>Reset graph to its initial state</td></th>
<tr><th>→</th><td>Move right 10 pixels</td></th>
<tr><th>←</th><td>Move left 10 pixels</td></th>
<tr><th>↑</th><td>Move up 10 pixels</td></th>
<tr><th>↓</th><td>Move down 10 pixels</td></th>
<tr><th><i>Shift+</i>→</th><td>Move right 1 pixel</td></th>
<tr><th><i>Shift+</i>←</th><td>Move left 1 pixel</td></th>
<tr><th><i>Shift+</i>↑</th><td>Move up 1 pixel</td></th>
<tr><th><i>Shift+</i>↓</th><td>Move down 1 pixel</td></th>
<tr><th>g</th><td>Go to packet under cursor</td></th>
<tr><th>z</th><td>Toggle mouse drag / zoom</td></th>
<tr><th>t</th><td>Toggle capture / session time origin</td></th>
<tr><th>Space</th><td>Toggle crosshairs</td></th>
</tbody></table>
</body></html></oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove this graph.</source>
<oldsource>Remove this dissection behavior.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add a new graph.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Duplicate this graph.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear all graphs.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mouse</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Drag using the mouse button.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>drags</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select using the mouse button.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>zooms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interval</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time of day</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Log scale</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Automatic Update</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset the graph to its initial state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>+</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>-</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move down 1 Pixel</source>
<oldsource>Move down 1 pixel</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Packet Under Cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to packet currently under the cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Drag / Zoom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle mouse drag / zoom behavior</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Z</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture / Session Time Origin</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle capture / session time origin</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>T</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Crosshairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle crosshairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Space</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In X Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>X</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out X Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+X</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In Y Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out Y Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 sec</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>10 sec</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 min</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>10 min</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time (s)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>I/O Graphs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy graphs from another profile.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>2 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>5 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>10 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>20 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>50 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>100 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>200 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>500 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>2 sec</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>5 sec</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wireshark I/O Graphs: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filtered packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TCP Errors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hover over the graph for details.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No packets in interval</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click to select packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 (%2s%3).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Release to zoom, x = %1 to %2, y = %3 to %4</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to select range.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click to select a portion of the graph.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Document Format (*.pdf)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Network Graphics (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Windows Bitmap (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JPEG File Interchange Format (*.jpeg *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comma Separated Values (*.csv)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph As…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Iax2AnalysisDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p><span style=" font-size:medium; font-weight:600;">Forward</span></p><p><span style=" font-size:medium; font-weight:600;">Reverse</span></p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Forward</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delta (ms)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Jitter (ms)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bandwidth</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Status</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Length</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reverse</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Show or hide forward jitter values.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Forward Jitter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Show or hide forward difference values.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Forward Difference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Show or hide reverse jitter values.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reverse Jitter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Show or hide reverse difference values.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reverse Difference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the audio data for both channels.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Forward Stream Audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the forward stream audio data.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reverse Stream Audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the reverse stream audio data.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save both tables as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Forward Stream CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the forward table as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reverse Stream CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the reverse table as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the graph image.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select the corresponding packet in the packet list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Problem Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next problem packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>N</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>IAX2 Stream Analysis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to save RTP data.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please select an IAX2 packet.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> G: Go to packet, N: Next problem packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Document Format (*.pdf)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Network Graphics (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Windows Bitmap (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JPEG File Interchange Format (*.jpeg *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can't save in a file: Wrong length of captured packets.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can't save in a file: File I/O problem.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save forward stream audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save reverse stream audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sun Audio (*.au)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>;;Raw (*.raw)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to save in that format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to save %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Saving %1…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Analyzing IAX2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save forward stream CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save reverse stream CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comma-separated values (*.csv)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ImportTextDialog</name>
<message>
<source>File:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set name of text file to import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Browse for text file to import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Browse…</source>
<oldsource>Browse...</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hex Dump</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import a standard hex dump as exported by Wireshark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Offsets in the text file are in octal notation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Octal</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Offsets:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Offsets in the text file are in hexadecimal notation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hexadecimal</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Offsets in the text file are in decimal notation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Decimal</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Regular Expression</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import a file formatted according to a custom regular expression</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet format regular expression</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Perl compatible regular expression capturing a single packet in the file with named groups identifieing data to import. Anchors ^ and $ also match before/after newlines </p><p>Required is only a data group, also supported are time, dir and seqno.</p><p>Regex flags: DUPNAMES, MULTILINE and NOEMPTY</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This is regexHintLabel, it will be set to default_regex_hint</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data encoding:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>How data is encoded</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>encodingRegexExample</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of characters indicating incoming packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>iI<</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of characters indicating outgoing packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>oO></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timestamp format:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Whether or not the file contains information indicating the direction (inbound or outbound) of the packet.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Direction indication:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ExportPDU</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maximum frame length:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Encapsulation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The text file has no offset</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>recommended regex:</small></i></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The format in which to parse timestamps in the text file (e.g. %H:%M:%S.). Format specifiers are based on strptime(3)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>The format in which to parse timestamps in the text file (e.g. %H:%M:%S.%f).</p><p>Format specifiers are based on strptime(3) with the addition of %f for second fractions. The precision of %f is determined from its length.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%H:%M:%S.%f</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>timestampExampleLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Encapsulation Type:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Encapsulation type of the frames in the import capture file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Dissector</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The UDP, TCP or SCTP source port for each frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The SCTP DATA payload protocol identifier for each frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The UDP, TCP or SCTP destination port for each frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prefix each frame with an Ethernet header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ethernet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prefix each frame with an Ethernet, IPv4 and SCTP header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCTP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PPI:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Protocol (dec):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Leave frames unchanged</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No dummy header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tag:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prefix each frame with an Ethernet, IPv4 and UDP header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UDP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Source port:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The Ethertype value of each frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prefix each frame with an Ethernet, IPv4 and TCP header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TCP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The SCTP verification tag for each frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Destination port:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ethertype (hex):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The IPv4 protocol ID for each frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prefix each frame with an Ethernet, IPv4 and SCTP (DATA) header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCTP (Data)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prefix each frame with an Ethernet and IPv4 header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>IPv4</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The dissector to use for each frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The maximum size of the frames to write to the import capture file (max 256kiB)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Supported fields are data, dir, time, seqno</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Missing capturing group data (use (?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import From Hex Dump</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import Text File</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>InterfaceFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wired</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>AirPCAP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pipe</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>STDIN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bluetooth</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wireless</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Dial-Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>USB</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>External Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Virtual</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remote interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show hidden interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>External capture interfaces disabled.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><p>Local interfaces are unavailable because no packet capture driver is installed.</p><p>You can fix this by installing <a href="https://nmap.org/npcap/">Npcap</a> or <a href="https://www.winpcap.org/install/default.htm">WinPcap</a>.</p></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><p>Local interfaces are unavailable because the packet capture driver isn't loaded.</p><p>You can fix this by running <pre>net start npcap</pre> if you have Npcap installed or <pre>net start npf</pre> if you have WinPcap installed. Both commands must be run as Administrator.</p></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><p>You don't have permission to capture on local interfaces.</p><p>You can fix this by <a href="file://%1">installing ChmodBPF</a>.</p></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>You don't have permission to capture on local interfaces.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No interfaces found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interfaces not loaded (due to preference). Go to Capture </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start capture</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>InterfaceSortFilterModel</name>
<message>
<source>No interfaces to be displayed. %1 interfaces hidden.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>InterfaceToolbar</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select interface</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interface</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>InterfaceToolbarLineEdit</name>
<message>
<source>Apply changes</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>InterfaceTreeModel</name>
<message>
<source>Show</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Friendly Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interface Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No interfaces found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This version of Wireshark was built without packet capture support.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Local Pipe Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comment</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Link-Layer Header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Promiscuous</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Snaplen (B)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Buffer (MB)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Monitor Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Extcap interface: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No capture filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture filter</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LBMLBTRMTransportDialog</name>
<message>
<source>LBT-RM Transport Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sources</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Address/Transport</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX data frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX data bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX data frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX data rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF count/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF frames/count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF frames/count/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF</source>
<extracomment>Nak ConFirmation</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM</source>
<extracomment>Session Message</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sequence numbers for transport</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>XXXXX:XXX.XXX.XXX.XXX:XXXXX:XXXXXXXX:XXX.XXX.XXX.XXX:XXXXX</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SQN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SQN/Reason</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Receivers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK sequence numbers for transport</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Regenerate statistics using this display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy the tree as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy the tree as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the data frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the data bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the data frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RX data frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RX data bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RX data frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF count column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the data rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RX data rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF count/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF frames/count column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF frames/count/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the SM frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the SM bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the SM frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the SM rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto-resize columns to content</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resize columns to content size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LBT-RM Statistics failed to attach to tap</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LBMLBTRUTransportDialog</name>
<message>
<source>LBT-RU Transport Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sources</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Address/Transport/Client</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX data frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX data bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX data frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX data rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF frames/count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF count/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF frames/count/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RST frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RST bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RST frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RST rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data SQN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RX Data SQN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NCF SQN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SM SQN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RST reason</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>details for transport</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>XXXXX:XXX.XXX.XXX.XXX:XXXXX:XXXXXXXX:XXX.XXX.XXX.XXX:XXXXX</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SQN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reason</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SQN/Reason</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Receivers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Address/Transport</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK frames/count</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK count/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK frames/count/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ACK frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ACK bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ACK frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ACK rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CREQ frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CREQ bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CREQ frames/bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CREQ rate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NAK SQN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ACK SQN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CREQ request</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Regenerate statistics using this display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy the tree as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy the tree as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the data frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the data bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the data frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the data rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RX data frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RX data bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RX data frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RX data rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF count column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF count/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF frames/count column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF frames/count/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the SM frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the SM bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the SM frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the SM rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RST frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RST bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RST frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the RST rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NAK frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NAK count column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NAK bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NAK frames/count column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NAK count/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NAK frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NAK frames/count/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NAK rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the ACK frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the ACK bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the ACK frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the ACK rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the CREQ frames column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the CREQ bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the CREQ frames/bytes column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the CREQ rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto-resize columns to content</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resize columns to content size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the NCF rate column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LBT-RU Statistics failed to attach to tap</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LBMStreamDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Endpoint A</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Endpoint B</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Messages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Last Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Regenerate statistics using this display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy the tree as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy the tree as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LBM Stream failed to attach to tap</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LBMUIMFlowDialog</name>
<message numerus="yes">
<source>%Ln node(s)</source>
<translation type="obsolete">
<numerusform>%Ln node</numerusform>
<numerusform>%Ln nodes</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%Ln item(s)</source>
<translation type="obsolete">
<numerusform>%Ln item</numerusform>
<numerusform>%Ln items</numerusform>
</translation>
</message>
</context>
<context>
<name>LayoutPreferencesFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pane 1:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet List</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pane 2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pane 3:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet List settings:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet separator</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show column definition in column context menu</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable mouse-over colorization</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Status Bar settings:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show selected packet number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show file load time</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LteMacStatisticsDialog</name>
<message>
<source>LTE Mac Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Include SR frames in filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Include RACH frames in filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MAC Statistics</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LteRlcGraphDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body>
<h3>Valuable and amazing time-saving keyboard shortcuts</h3>
<table><tbody>
<tr><th>+</th><td>Zoom in</td></th>
<tr><th>-</th><td>Zoom out</td></th>
<tr><th>0</th><td>Reset graph to its initial state</td></th>
<tr><th>→</th><td>Move right 10 pixels</td></th>
<tr><th>←</th><td>Move left 10 pixels</td></th>
<tr><th>↑</th><td>Move up 10 pixels</td></th>
<tr><th>↓</th><td>Move down 10 pixels</td></th>
<tr><th><i>Shift+</i>→</th><td>Move right 1 pixel</td></th>
<tr><th><i>Shift+</i>←</th><td>Move left 1 pixel</td></th>
<tr><th><i>Shift+</i>↑</th><td>Move up 1 pixel</td></th>
<tr><th><i>Shift+</i>↓</th><td>Move down 1 pixel</td></th>
<tr><th>g</th><td>Go to packet under cursor</td></th>
<tr><th>z</th><td>Toggle mouse drag / zoom</td></th>
<tr><th>t</th><td>Toggle capture / session time origin</td></th>
<tr><th>Space</th><td>Toggle crosshairs</td></th>
</tbody></table>
</body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mouse</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Drag using the mouse button.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>drags</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select using the mouse button.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>zooms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Reset the graph to its initial state.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Switch the direction of the connection (view the opposite flow).</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch Direction</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset the graph to its initial state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>+</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>-</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move down 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Drag / Zoom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle mouse drag / zoom behavior</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Z</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Crosshairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle crosshairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Space</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 100 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PgUp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PgDown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Packet Under Cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to packet currently under the cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In X Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>X</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out Y Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In Y Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out X Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+X</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch direction (swap between UL and DL)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>D</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sequence Number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LTE RLC Graph (UE=%1 chan=%2%3 %4 - %5)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LTE RLC Graph - no channel selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 %2 (%3s seq %4 len %5)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click to select packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Release to zoom, x = %1 to %2, y = %3 to %4</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to select range.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click to select a portion of the graph.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Document Format (*.pdf)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Network Graphics (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Windows Bitmap (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JPEG File Interchange Format (*.jpeg *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph As…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LteRlcStatisticsDialog</name>
<message>
<source>LTE RLC Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Include SR frames in filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Include RACH frames in filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use RLC frames only from MAC frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL Frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL MB/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL ACKs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL NACKs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL Missing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL Frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL MB/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL ACKs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL NACKs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL Missing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RLC Statistics</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainStatusBar</name>
<message>
<source>Ready to load or capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ready to load file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the Capture File Properties dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Profile: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manage Profiles…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>New…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>from zip file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>from directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> is the highest expert information level</source>
<oldsource> is the highest expert info level</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>ERROR</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WARNING</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NOTE</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CHAT</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No expert information</source>
<oldsource>No expert info</oldsource>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln byte(s)</source>
<oldsource>, %1 bytes</oldsource>
<translation>
<numerusform>%Ln byte</numerusform>
<numerusform>%Ln bytes</numerusform>
</translation>
</message>
<message>
<source>Byte %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes %1-%2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Selected Packet: %1 %2 </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets: %1 %4 Displayed: %2 (%3%)</source>
<oldsource>Packets: %1 %4 Displayed: %2 %4 Marked: %3</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source> %1 Selected: %2 (%3%)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> %1 Marked: %2 (%3%)</source>
<oldsource> %1 Dropped: %2</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source> %1 Dropped: %2 (%3%)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> %1 Ignored: %2 (%3%)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> %1 Comments: %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> %1 Load time: %2:%3.%4</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>selected personal profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>all personal profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets: %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWelcome</name>
<message numerus="yes">
<source>%n interface(s) shown, %1 hidden</source>
<oldsource>%Ln interface(s) shown</oldsource>
<translation type="obsolete">
<numerusform>%n interface shown, %1 hidden</numerusform>
<numerusform>%n interfaces shown, %1 hidden</numerusform>
</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<source>Wireshark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>File Set</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export Packet Dissections</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export Objects</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Zoom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Time Display Format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manual pages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply as Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare as Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>900000000</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Go</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&View</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Analyze</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Follow</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Topics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Queues</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UIM</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Telephon&y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTSP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Edit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Comments</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Main Toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Filter Toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open a capture file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Quit Wireshark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Start</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start capturing packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>S&top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop capturing packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No files found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Contents</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wireshark Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TShark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rawshark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Dumpcap</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mergecap</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Editcap</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Text2pcap</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Website</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Downloads</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wiki</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample Captures</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&About Wireshark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ask (Q&&A)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the previous packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the first packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Last Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the last packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>E&xpand Subtrees</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expand the current packet detail</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Expand All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expand packet details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Collapse &All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Collapse all packet details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to specified packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Merge one or more files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import a file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as a different file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export specified packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List Files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Reload</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture options</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture filters</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Refresh Interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Refresh interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Restart</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Restart current capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As &CSV…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As "C" &Arrays…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As P&SML XML…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As P&DML XML…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As &JSON…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Field Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Close this capture file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interface Toolbars</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Colorize Conversation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Internals</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Additional Toolbars</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Conversation Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Osmux</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Tools</source>
<oldsource>Tools</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wireless Toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Help contents</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>FAQs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Packet in Conversation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next packet in this conversation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous Packet in Conversation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the previous packet in this conversation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Packet In History</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next packet in your selection history</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous Packet In History</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the previous packet in your selection history</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Collapse Subtrees</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Collapse the current packet detail</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to Packet…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Merge…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Import from Hex Dump…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save this capture file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save &As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export Specified Packets…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export Packet &Bytes…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Print…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reload this file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reload as File Format/Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this item's description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this item's field name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this item's value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this item as a display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply as Column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Create a packet list column from the selected field.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find a packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find the next packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find the previous packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Mark/Unmark Packet(s)</source>
<oldsource>&Mark/Unmark Packet</oldsource>
<translation type="unfinished">&Mark/Unmark Packet</translation>
</message>
<message>
<source>Mark All Displayed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark all displayed packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmark all displayed packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Mark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next marked packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous Mark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the previous marked packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Ignore/Unignore Packet(s)</source>
<oldsource>&Ignore/Unignore Packet</oldsource>
<translation type="unfinished">&Ignore/Unignore Packet</translation>
</message>
<message>
<source>Ignore All Displayed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ignore all displayed packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set/Unset Time Reference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set or unset a time reference for this packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unset All Time References</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove all time references</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Time Reference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next time reference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous Time Reference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the previous time reference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift or change packet timestamps</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete All Packet Comments</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove all packet comments in the capture file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Configuration Profiles…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Configuration profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manage your configuration profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manage Wireshark's preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture File Properties</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture file properties</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Protocol Hierarchy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show a summary of protocols present in the capture file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capinfos</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reordercap</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time Sequence (Stevens)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TCP time sequence graph (Stevens)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Throughput</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Round Trip Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TCP round trip time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Window Scaling</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time Sequence (tcptrace)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TCP time sequence graph (tcptrace)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Analyse this Association</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show All Associations</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Flow Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Flow sequence diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets sorted by Instance ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets sorted by IP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets sorted by object type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets sorted by service</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Counter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Requests</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Load Distribution</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Lengths</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet length statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reload Lua Plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reload Lua plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Advertisements by Topic</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Advertisements by Source</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Advertisements by Transport</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Queries by Topic</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Queries by Receiver</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wildcard Queries by Pattern</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wildcard Queries by Receiver</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Advertisements by Queue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Queries by Queue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LBT-RM</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LBT-RU</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter this Association</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&I/O Graphs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Conversations</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Endpoints</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shrink the main window text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Return the main window text to its normal size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset Layout</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset appearance layout to default size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet &Diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the packet diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show each conversation hash table</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show each dissector table and its entries</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the currently supported protocols and display filter fields</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MAC Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LTE MAC statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RLC Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LTE RLC statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LTE RLC graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MTP3 Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MTP3 summary statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bluetooth Devices</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bluetooth HCI Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Filter &Expression…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Filter Expression…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No GSM statistics registered</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No LTE statistics registered</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No MTP3 statistics registered</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>IAX2 Stream Analysis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show Packet Bytes…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to &Linked Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add a display filter button.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Full Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Options…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Wireless</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture &Filters…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As Plain &Text…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As Plain &Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As &CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As &YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Visible Items</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Visible Selected Tree Items</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Filter &Macros…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Find Packet…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find Ne&xt</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find Pre&vious</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark or unmark each selected packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ignore or unignore each selected packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>U&nignore All Displayed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unignore all displayed packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time Shift…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Preferences…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TCP throughput</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TCP Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UDP Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Request Sequences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Decode &As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export PDUs to File…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Create graphs based on display filter fields</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Main Toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the main toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Filter Toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the display filter toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Conversations at different protocol levels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Endpoints at different protocol levels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Colorize Packet List</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Draw packets using your coloring rules</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Zoom In</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enlarge the main window text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Normal Size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resize Columns</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resize packet list columns to fit contents</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Date and Time of Day (1970-01-01 01:02:03.123456)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet times as the date and time of day.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Year, Day of Year, and Time of Day (1970/001 01:02:03.123456)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet times as the year, day of the year and time of day.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time of Day (01:02:03.123456)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Seconds Since 1970-01-01</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet times as the seconds since the UNIX / POSIX epoch (1970-01-01).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Seconds Since Beginning of Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Seconds Since Previous Captured Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet times as the seconds since the previous captured packet.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Seconds Since Previous Displayed Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet times as the seconds since the previous displayed packet.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UTC Date and Time of Day (1970-01-01 01:02:03.123456)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet times as the UTC date and time of day.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UTC Year, Day of Year, and Time of Day (1970/001 01:02:03.123456)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet times as the UTC year, day of the year and time of day.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UTC Time of Day (01:02:03.123456)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show packet times as the UTC time of day.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Automatic (from capture file)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use the time precision indicated in the capture file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tenths of a second</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hundredths of a second</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Milliseconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Microseconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Nanoseconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Seconds With Hours and Minutes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display seconds with hours and minutes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolve &Physical Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show names for known MAC addresses. Lookups use a local database.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolve &Network Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show names for known IPv4, IPv6, and IPX addresses. Lookups can generate network traffic.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolve &Transport Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show names for known TCP, UDP, and SCTP services. Lookups can generate traffic on some systems.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wire&less Toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the wireless toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Status Bar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the status bar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet &List</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the packet list</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet &Details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the packet details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet &Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the packet bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Conversation Hash Tables</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Dissector Tables</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Supported Protocols</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MAP Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GSM MAP summary statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RLC &Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Coloring Rules…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show Linked Packet in New Window</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Coloring Rule…</source>
<oldsource>New Conversation Rule…</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTP Stream Analysis for selected stream. Press CTRL key for adding reverse stream too.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTP Player</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Play selected stream. Press CTRL key for playing reverse stream too.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>IA&X2 Stream Analysis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enabled Protocols…</source>
<oldsource>Enable Protocols…</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wiki Protocol Page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the Wireshark wiki page for this protocol.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter Field Reference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the display filter reference page for this filter field.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the packet referenced by the selected field.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&VoIP Calls</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open &Recent</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name Resol&ution</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Service &Response Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&RTP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>S&CTP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&ANSI</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&GSM</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&LTE</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&MTP3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Open</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Quit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display &Filters…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Unmark All Displayed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All VoIP Calls</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SIP &Flows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SIP Flows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTP Streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit the packet list coloring rules.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bluetooth ATT Server Attributes</source>
<oldsource>ATT Server Attributes</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show Packet in New &Window</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show this packet in a separate window.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the linked packet in a separate window.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto Scroll in Li&ve Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Automatically scroll to the last packet during a live capture.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expert Information</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show expert notifications</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add an expression to the display filter.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>REGISTER_STAT_GROUP_UNSORTED</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start of "REGISTER_STAT_GROUP_UNSORTED"</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No ANSI statistics registered</source>
<oldsource>No tools registered</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolved Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show each table of resolved addresses as copyable text.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark the current conversation with its own color.</source>
<oldsource>Mark the current coversation with its own color.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &4</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &5</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &6</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &7</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &8</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color &9</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Color 1&0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Create a new coloring rule based on this field.</source>
<oldsource>Create a new coloring rule based on this conversation.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset Colorization</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset colorized conversations.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTP Stream Analysis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit Resolved Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Manually edit a name resolution entry.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable and disable specific protocols</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> before quitting</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save packets before merging?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A temporary capture file can't be merged.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save changes in "%1" before merging?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Changes must be saved before the files can be merged.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid Display Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid Read Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The filter expression %1 isn't a valid read filter. (%2).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> before importing a capture</source>
<oldsource> before importing a new capture</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to export to "%1".</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>You cannot export packets to the current capture file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you want to save the changes you've made%1?</source>
<oldsource>Do you want to save the captured packets</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Your captured packets will be lost if you don't save them.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you want to save the changes you've made to the capture file "%1"%2?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Your changes will be lost if you don't save them.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Check for Updates…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to drop files during capture.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown file type returned by merge dialog.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please report this as a Wireshark issue at https://gitlab.com/wireshark/wireshark/-/issues.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown file type returned by export dialog.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you want to stop the capture and save the captured packets%1?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do you want to save the captured packets%1?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save before Continue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop and Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop and Quit &without Saving</source>
<oldsource>Stop and Quit without Saving</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Quit &without Saving</source>
<oldsource>Quit without Saving</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>There is no "rtp.ssrc" field in this version of Wireshark.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please select an RTPv2 packet with an SSRC value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SSRC value not found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show or hide the toolbar</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Continue &without Saving</source>
<oldsource>Continue without Saving</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop and Continue &without Saving</source>
<oldsource>Stop and Continue without Saving</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>The Wireshark Network Analyzer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capturing from %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> before opening another file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Merging files.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1: %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear Menu</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> before closing the file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export Selected Packet Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Keys</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>Export SSL Session Keys (%Ln key(s))</source>
<oldsource>Export SSL Session Keys (%1 key%2</oldsource>
<translation type="vanished">
<numerusform>Export SSL Session Keys (%Ln key)</numerusform>
<numerusform>Export SSL Session Keys (%Ln keys)</numerusform>
</translation>
</message>
<message>
<source>Raw data (*.bin *.dat *.raw);;All Files (</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Couldn't copy text. Try another item.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to remove all packet comments?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to build conversation filter.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> before reloading the file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error compiling filter for this conversation.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No previous/next packet in conversation.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No interface selected.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Saving %1…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid capture filter.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>(empty comment)</source>
<comment>placeholder for empty comment</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add New Comment…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit "%1"</source>
<comment>edit packet comment</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete "%1"</source>
<comment>delete packet comment</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete packet comments</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>Delete comments from %n packet(s)</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
</translation>
</message>
<message>
<source> before starting a new capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> before reloading Lua plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please wait while Wireshark is initializing…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No filter available. Try another %1.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>item</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The "%1" column already exists.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The "%1" column already exists as "%2".</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTP packet search failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Interface Selected.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> before restarting the capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wiki Page for %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><p>The Wireshark Wiki is maintained by the community.</p><p>The page you are about to load might be wonderful, incomplete, wrong, or nonexistent.</p><p>Proceed to the wiki?</p></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reloading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rescanning</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindowPreferencesFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Checking this will save the size, position, and maximized state of the main window.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remember main window size and placement</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open files in</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This folder:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Browse…</source>
<oldsource>Browse...</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>The most recently used folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show up to</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>filter entries</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>recent files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Confirm unsaved capture files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display autocompletion for filter text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Main toolbar style:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Icons only</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Text only</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Icons & Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Window title</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Custom window title to be appended to the existing title<br/>%F = file path of the capture file<br/>%P = profile name<br/>%S = a conditional separator (&quot; - &quot;) that only shows when surrounded by variables with values or static text<br/>%V = version info</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepend window title</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Custom window title to be prepended to the existing title<br/>%F = file path of the capture file<br/>%P = profile name<br/>%S = a conditional separator (&quot; - &quot;) that only shows when surrounded by variables with values or static text<br/>%V = version info</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Language: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use system setting</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open Files In</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ManageInterfacesDialog</name>
<message>
<source>Manage Interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Click the checkbox to hide or show a hidden interface.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Local Interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Add a pipe to capture from or remove an existing pipe from the list.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pipes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Add a new pipe using default settings.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Remove the selected pipe from the list.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remote Interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Host / Device URL</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Add a remote host and its interfaces</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Remove the selected host from the list.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remote Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i></i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This version of Wireshark does not save pipe settings.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This version of Wireshark does not save remote settings.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This version of Wireshark does not support remote interfaces.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Pipe</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ModulePreferencesScrollArea</name>
<message>
<source>ScrollArea</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Mtp3SummaryDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MTP3 Summary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Length</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Snapshot length</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Last packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Elapsed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Service Indicator (SI) Totals</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SI</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MSUs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MSUs/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes/MSU</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Totals</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total MSUs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Total Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average Bytes/MSU</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Average Bytes/s</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PacketCommentDialog</name>
<message>
<source>Edit Packet Comment</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add Packet Comment</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PacketDiagram</name>
<message>
<source>Packet diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show Field Values</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Diagram As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as Raster Image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as SVG</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Network Graphics (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Windows Bitmap (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JPEG File Interchange Format (*.jpeg *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Scalable Vector Graphics (*.svg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph As…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PacketDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i></i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[%1 closed] </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Byte %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes %1-%2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PacketFormatGroupBox</name>
<message>
<source>GroupBox</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Packet summary lines similar to the packet list</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Summary line</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Include column headings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Packet details similar to the protocol tree</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Details:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Export only top-level packet detail items</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All co&llapsed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Expand and collapse packet details as they are currently displayed.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As displa&yed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Export all packet detail items</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All e&xpanded</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Export a hexdump of the packet data similar to the packet bytes view</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PacketList</name>
<message>
<source>Protocol Preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Summary as Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Decode As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Frame %1: %2
</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[ Comment text exceeds %1. Stopping. ]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PacketListHeader</name>
<message>
<source>Align Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Align Center</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Align Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit Column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resize to Contents</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Column Preferences…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resize Column to Width…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolve Names</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove this Column</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Column %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Width:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PacketListModel</name>
<message>
<source>Sorting "%1"…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PacketRangeGroupBox</name>
<message>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Range</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>-</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Displayed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Marked packets only</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Range:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove &ignored packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>First &to last marked</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&All packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Selected packets only</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Captured</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PathChooserDelegate</name>
<message>
<source>Browse</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open Pipe</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PluginListModel</name>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Version</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Path</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PortsModel</name>
<message>
<source>All entries</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PreferenceEditorFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>a preference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Browse…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open %1 preferences…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid value.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PreferencesDialog</name>
<message>
<source>Search:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Preferences</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PrefsModel</name>
<message>
<source>Advanced</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Appearance</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Layout</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Columns</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Font and Colors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expert</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter Buttons</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RSA Keys</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PrintDialog</name>
<message>
<source>Packet Format</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print each packet on a new page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Print capture file information on each page</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture information header</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Use the &quot;+&quot; and &quot;-&quot; keys to zoom the preview in and out. Use the &quot;0&quot; key to reset the zoom level.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p><span style=" font-size:small; font-style:italic;">+ and - zoom, 0 resets</span></p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet Range</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Print…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Page &Setup…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 %2 total packets, %3 shown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to print to %1.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProfileDialog</name>
<message>
<source>Search for profile …</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Create a new profile using default settings.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Remove this profile. System provided profiles cannot be removed. The default profile will be reset upon deletion.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this profile.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Configuration Profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import</source>
<comment>noun</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export</source>
<comment>noun</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>New profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Profile Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exporting profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No profiles found for export</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select zip file for export</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>… %Ln selected personal profile(s)</source>
<translation type="vanished">
<numerusform>… %Ln selected personal profile</numerusform>
<numerusform>… %Ln selected personal profiles</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%Ln selected personal profile(s)</source>
<translation>
<numerusform>%Ln selected personal profile</numerusform>
<numerusform>%Ln selected personal profiles</numerusform>
</translation>
</message>
<message>
<source>An import of profiles is not allowed, while changes are pending</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>An import is pending to be saved. Additional imports are not allowed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>An export of profiles is only allowed for personal profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>An export of profiles is not allowed, while changes are pending</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln profile(s) exported</source>
<translation>
<numerusform>%Ln profile exported</numerusform>
<numerusform>%Ln profiles exported</numerusform>
</translation>
</message>
<message>
<source>Select zip file for import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select directory for import</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zip File (*.zip)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>from zip file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>from directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>all personal profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>An error has occurred while exporting profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No profiles found for import in %1</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln profile(s) imported</source>
<translation>
<numerusform>%Ln profile imported</numerusform>
<numerusform>%Ln profiles imported</numerusform>
</translation>
</message>
<message numerus="yes">
<source>, %Ln profile(s) skipped</source>
<translation>
<numerusform>, %Ln profile skipped</numerusform>
<numerusform>, %Ln profiles skipped</numerusform>
</translation>
</message>
<message>
<source>Importing profiles</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln profile(s) selected</source>
<translation type="obsolete">
<numerusform>%Ln profile selected</numerusform>
<numerusform>%Ln profiles selected</numerusform>
</translation>
</message>
</context>
<context>
<name>ProfileModel</name>
<message>
<source>Resetting to default</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Imported profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This is a system provided profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A profile change for this name is pending</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> (See: %1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This is an invalid profile definition</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A profile already exists with this name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A profile with this name is being deleted</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Created from default settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>system provided</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>deleted</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>copy</source>
<comment>noun</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Exporting profiles while changes are pending is not allowed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No profiles found to export</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can't delete profile directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A profile name cannot contain the following characters: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A profile name cannot contain the '/' character</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A profile cannot start or end with a period (.)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Default</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Global</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Personal</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Renamed from: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copied from: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>renamed to %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProfileSortModel</name>
<message>
<source>All profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Personal profiles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Global profiles</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProgressFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProtoTree</name>
<message>
<source>Packet details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Not a field or protocol</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No field reference available for text labels.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expand Subtrees</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Collapse Subtrees</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expand All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Collapse All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Visible Items</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Visible Selected Tree Items</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Field Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>As Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wiki Protocol Page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter Field Reference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copied </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wiki Page for %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><p>The Wireshark Wiki is maintained by the community.</p><p>The page you are about to load might be wonderful, incomplete, wrong, or nonexistent.</p><p>Proceed to the wiki?</p></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Colorize with Filter</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProtocolHierarchyDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Protocol</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Percent Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Percent Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bits/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>End Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>End Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>End Bits/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy stream list as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy stream list as YAML.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Protocol Hierarchy Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No display filter.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter: %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProtocolPreferencesMenu</name>
<message>
<source>Protocol Preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No protocol preferences available</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disable %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 has no preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open %1 preferences…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<source>Average Throughput (bits/s)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Round Trip Time (ms)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Segment Length (B)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sequence Number (B)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time (s)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Window Size (B)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[no capture file]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Conversation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bars show the relative timeline for each conversation.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Endpoint</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply as Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare as Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Colorize</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Look Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UNKNOWN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Not Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…and Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…or Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…and not Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…or not Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>B </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Any </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Don't show this message again.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Multiple problems found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 (%L2%)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No entries.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 entries.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Base station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><Broadcast></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><Hidden></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>BSSID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Beacons</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Data Pkts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Protection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pkts Sent</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pkts Received</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comment</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wrong sequence number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Payload changed to PT=%1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Incorrect timestamp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Marker missing?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>C-RNTI</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SPS-RNTI</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RNTI</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UEId</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL Frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL MB/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL Padding %</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UL Re TX</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL Frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL MB/s</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL Padding %</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL CRC Failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DL ReTX</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 4</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 5</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 6</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 7</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 8</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 9</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 10</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 32</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 33</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 34</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 35</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 36</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 37</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>LCID 38</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TM</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UM</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>AM</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Predef</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown (%1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CCCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SRB-%1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DRB-%1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UE Id</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Priority</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>default</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DLT %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid Display Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The filter expression %1 isn't a valid display filter. (%2).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No remote interfaces found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PCAP not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Default</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Changed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Has this preference been changed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Default value is empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gap in dissection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Browse…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject::QObject</name>
<message>
<source>CCCH</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RemoteCaptureDialog</name>
<message>
<source>Remote Interface</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Host:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Port:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Authentication</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Null authentication</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password authentication</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Username:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear list</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No remote interfaces found.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PCAP not found</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RemoteSettingsDialog</name>
<message>
<source>Remote Capture Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do not capture own RPCAP traffic</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use UDP for data transfer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sampling Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 of</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1 every </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>milliseconds</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ResolvedAddressesDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hosts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search for entry (min 3 characters)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ports</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search for port or name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture File Comments</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comment</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the comment.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>IPv4 Hash Table</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the IPv4 hash table entries.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>IPv6 Hash Table</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the IPv6 hash table entries.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show all address types.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hide All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hide all address types.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>IPv4 and IPv6 Addresses (hosts)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show resolved IPv4 and IPv6 host names in "hosts" format.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Port names (services)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show resolved port names in "services" format.</source>
<oldsource>Show resolved port names names in "servies" format.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ethernet Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show resolved Ethernet addresses in "ethers" format.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ethernet Well-Known Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show well-known Ethernet addresses in "ethers" format.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ethernet Manufacturers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show Ethernet manufacturers in "ethers" format.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[no file]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resolved Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source># Resolved addresses found in %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source># Comments
#
# </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ResponseTimeDelayDialog</name>
<message>
<source>%1 Response Time Delay Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Messages</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Min SRT</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Max SRT</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Avg SRT</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Min in Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Max in Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open Requests</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Discarded Responses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Repeated Requests</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Repeated Responses</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RsaKeysFrame</name>
<message>
<source>RSA Keys</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RSA private keys are loaded from a file or PKCS #11 token.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add new keyfile…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add new token…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove key</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PKCS #11 provider libraries.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add new provider…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove provider</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add PKCS #11 token or key</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No new PKCS #11 tokens or keys found, consider adding a PKCS #11 provider.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select a new PKCS #11 token or key</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PKCS #11 token or key</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter PIN or password for %1 (it will be stored unencrypted)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter PIN or password for key</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Key could not be added: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RSA private key (*.pem *.p12 *.pfx *.key);;All Files (</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select RSA private key file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Libraries (*.dll)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Libraries (*.so)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select PKCS #11 Provider Library</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Changes will apply after a restart</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PKCS #11 provider %1 will be removed after the next restart.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RtpAnalysisDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sequence</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delta (ms)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Jitter (ms)</source>
<oldsource>Jitter</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Skew</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bandwidth</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Marker</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Status</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stream %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stream %1 Jitter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stream %1 Difference</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stream %1 Delta</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> %1 streams, </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save one stream CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save all stream's CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Analyze</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the analysis window for the selected stream(s)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Set List</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Add to List</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Remove from List</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Replace existing list in RTP Analysis Dialog with new one</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add new set to existing list in RTP Analysis Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove selected streams from list in RTP Analysis Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Export</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open export menu</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save tables as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Current Tab Stream CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the table on the current tab as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Tab Streams CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the table from all tabs as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the graph image.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select the corresponding packet in the packet list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Problem Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next problem packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>N</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare &Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare a filter matching the selected stream(s).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Current Tab</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare a filter matching current tab.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&All Tabs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare a filter matching all tabs.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTP Stream Analysis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> G: Go to packet, N: Next problem packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Document Format (*.pdf)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Network Graphics (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Windows Bitmap (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JPEG File Interchange Format (*.jpeg *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comma-separated values (*.csv)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RtpAudioStream</name>
<message>
<source>%1 does not support PCM at %2. Preferred format is %3</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RtpPlayerDialog</name>
<message>
<source>RTP Player</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Play</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Source Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Source Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Destination Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Destination Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SSRC</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Setup Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time Span (s)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Payloads</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>No audio</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start playback of all unmuted streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pause/unpause playback</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop playback</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable/disable skipping of silence during playback</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Min silence:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Minimum silence duration to skip in seconds</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Output Device:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Output Audio Rate:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Jitter Buffer:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The simulated jitter buffer in milliseconds.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Playback Timing:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><strong>Jitter Buffer</strong>: Use jitter buffer to simulate the RTP stream as heard by the end user.
<br/>
<strong>RTP Timestamp</strong>: Use RTP Timestamp instead of the arriving packet time. This will not reproduce the RTP stream as the user heard it, but is useful when the RTP is being tunneled and the original packet timing is missing.
<br/>
<strong>Uninterrupted Mode</strong>: Ignore the RTP Timestamp. Play the stream as it is completed. This is useful when the RTP timestamp is missing.</source>
<oldsource><strong>Jitter Buffer</strong>: Use jitter buffer to simulate the RTP stream as heard by the end user.
<br/>
<strong>RTP Timestamp</strong>: Use RTP Timestamp instead of the arriving packet time. This will not reproduce the RTP stream as the user heard it, but is useful when the RTP is being tunneled and the original packet timing is missing.
<br/>
<strong>Uniterrupted Mode</strong>: Ignore the RTP Timestamp. Play the stream as it is completed. This is useful when the RTP timestamp is missing.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Jitter Buffer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTP Timestamp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Uninterrupted Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>View the timestamps as time of day (checked) or seconds since beginning of capture (unchecked).</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time of Day</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Export</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export audio of all unmuted selected channels or export payload of one channel.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From &cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save audio data started at the cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Stream Synchronized Audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save audio data synchronized to start of the earliest stream.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&File Synchronized Audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save audio data synchronized to start of the capture file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Payload</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save RTP payload of selected stream.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset the graph to its initial state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Setup Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to setup packet of stream currently under the cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mute</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mute selected streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unmute selected streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert muting of selected streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Route audio to left channel of selected streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Route audio to left and right channel of selected streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Route audio to right channel of selected streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove Streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove selected streams from the list</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select all</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Play/Pause</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start playing or pause playing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop playing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>I&naudible streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select/Deselect inaudible streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inaudible streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Select</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select inaudible streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Deselect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deselect inaudible streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare &Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare a filter matching the selected stream(s).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>R&efresh streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Read captured packets from capture in progress to player</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SR (Hz)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sample rate of codec</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PR (Hz)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Play rate of decoded audio (depends e. g. on selected sound card)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 1 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 1 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Packet Under Cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to packet currently under the cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Play the stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left + Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert Muting</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No devices available</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Audio Routing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Play Streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open RTP player dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Set playlist</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Replace existing playlist in RTP Player with new one</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Add to playlist</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add new set to existing playlist in RTP Player</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Remove from playlist</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove selected streams from playlist in RTP Player</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Decoding streams...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Out of Sequence</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Jitter Drops</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wrong Timestamps</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inserted Silence</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Double click on cell to change audio routing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>, %1 selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>, %1 not muted</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>, start: %1. Double click on graph to set start of playback.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>, start: %1, cursor: %2. Press "G" to go to packet %3. Double click on graph to set start of playback.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Playback of stream %1 failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Automatic</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>WAV (*.wav)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sun Audio (*.au)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Raw (*.raw)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save payload</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No stream selected or none of selected streams provide audio</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All selected streams must use same play rate. Manual set of Output Audio Rate might help.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No streams are suitable for save</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can't write header of AU file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can't write header of WAV file</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Payload save works with just one audio stream.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Double click to change audio routing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Preparing to play...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RtpStreamDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Source Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Source Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Destination Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Destination Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SSRC</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Duration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Payload</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Max Delta (ms)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Max Jitter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mean Jitter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Status</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Only show conversations matching the current display filter</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit to display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time of Day</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find &Reverse</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare &Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Export</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Analyze</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the analysis window for the selected stream(s) and add it to it</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find the reverse stream matching the selected forward stream.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Min Delta (ms)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mean Delta (ms)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Min Jitter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All forward/reverse stream actions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>R</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find All &Pairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select all streams which are paired in forward/reverse relation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+R</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find Only &Singles</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find all streams which don't have paired reverse stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Ctrl+R</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mark the packets of the selected stream(s).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>M</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select all</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Setup</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the setup packet for this stream.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare a filter matching the selected stream(s).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>P</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export the stream payload as rtpdump</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>E</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cop&y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open copy menu</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy stream list as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy stream list as YAML.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTP Streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>, %1 selected, %2 total packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save RTPDump As…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SCTPAllAssocsDialog</name>
<message>
<source>Wireshark - SCTP Associations</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Port 1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Port 2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of DATA Chunks</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter Selected Association</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Analyze</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset the graph to its initial state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>+</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>-</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next stream in the capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PgUp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the previous stream in the capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PgDown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch Direction</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch direction (swap TCP endpoints)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>D</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Packet Under Cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to packet currently under the cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Drag / Zoom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle mouse drag / zoom behavior</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Z</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Relative / Absolute Sequence Numbers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle relative / absolute sequence numbers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>S</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture / Session Time Origin</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle capture / session time origin</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>T</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Crosshairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle crosshairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Space</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Round Trip Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the Round Trip Time graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Throughput</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the Throughput graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time / Sequence (Stevens)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the Stevens-style Time / Sequence graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Window Scaling</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the Window Scaling graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>5</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time / Sequence (tcptrace)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the tcptrace-style Time / Sequence graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>4</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SCTPAssocAnalyseDialog</name>
<message>
<source>Wireshark - Analyse Association</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TabWidget</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chunk Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter Association</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of Data Chunks from EP2 to EP1: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Checksum Type:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of Data Chunks from EP1 to EP2: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of Data Bytes from EP1 to EP2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of Data Bytes from EP2 to EP1: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Endpoint 1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Graph TSN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Graph Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Requested Number of Inbound Streams:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Port:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sent Verification Tag:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Minimum Number of Inbound Streams:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Complete List of IP addresses from INIT Chunk:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Minimum Number of Outbound Streams:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Graph Arwnd</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Endpoint 2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Complete List of IP addresses from INIT_ACK Chunk:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Provided Number of Outbound Streams:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCTP Analyse Association: %1 Port1 %2 Port2 %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Association found for this packet.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not find SCTP Association with id: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Complete list of IP addresses from INIT Chunk:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Complete list of IP addresses from INIT_ACK Chunk:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of Used IP Addresses</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Used Number of Inbound Streams:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Used Number of Outbound Streams:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SCTPChunkStatisticsDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Association</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Endpoint 1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Endpoint 2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Chunk Type Order</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hide Chunk Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove the chunk type from the table</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chunk Type Preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the chunk type preferences dialog to show or hide other chunk types</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show All Registered Chunk Types</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show all chunk types with defined names</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCTP Chunk Statistics: %1 Port1 %2 Port2 %3</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SCTPGraphArwndDialog</name>
<message>
<source>SCTP Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset to full size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p><br/></p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>goToPacket</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCTP Data and Adv. Rec. Window over Time: %1 Port1 %2 Port2 %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Data Chunks sent</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Arwnd</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>time [secs]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Advertised Receiver Window [Bytes]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>Graph %1: a_rwnd=%2 Time=%3 secs </i></small></source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SCTPGraphByteDialog</name>
<message>
<source>SCTP Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset to full size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p><br/></p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>goToPacket</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCTP Data and Adv. Rec. Window over Time: %1 Port1 %2 Port2 %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Data Chunks sent</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>time [secs]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Received Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>Graph %1: Received bytes=%2 Time=%3 secs </i></small></source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SCTPGraphDialog</name>
<message>
<source>SCTP Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Relative TSNs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Only SACKs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Only TSNs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show both</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset to full size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>goToPacket</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCTP TSNs and SACKs over Time: %1 Port1 %2 Port2 %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Data Chunks sent</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CumTSNAck</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gap Ack</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NR Gap Ack</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Duplicate Ack</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TSN</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>time [secs]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TSNs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>%1: %2 Time: %3 secs </i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Document Format (*.pdf)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Network Graphics (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Windows Bitmap (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JPEG File Interchange Format (*.jpeg *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph As…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ScsiServiceResponseTimeDialog</name>
<message>
<source><small><i>Select a command and enter a filter if desired, then press Apply.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Command:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SCSI Service Response Times</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SearchFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Search the Info column of the packet list (summary pane), decoded packet display labels (tree view pane) or the ASCII-converted packet data (hex view pane).</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet list</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet details</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Search for strings containing narrow (UTF-8 and ASCII) or wide (UTF-16) characters.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Narrow & Wide</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Narrow (UTF-8 / ASCII)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wide (UTF-16)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Case sensitive</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Search for data using display filter syntax (e.g. ip.addr==10.1.1.1), a hexadecimal string (e.g. fffffda5), a plain string (e.g. My String) or a regular expression (e.g. colou?r).</p></body></html></source>
<oldsource><html><head/><body><p>Search for data using display filter syntax (e.g. ip.addr==10.1.1.1), a hexadecimal string (e.g. fffffda5) or a plain string (e.g. My String).</p></body></html></oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hex value</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>String</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Regular Expression</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No valid search type selected. Please report this to the development team.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid filter.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>That filter doesn't test anything.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>That's not a valid hex string.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>You didn't specify any text for which to search.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No valid character set selected. Please report this to the development team.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No valid search area selected. Please report this to the development team.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Searching for %1…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No packet contained those bytes.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No packet contained that string in its Info column.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No packet contained that string in its dissected display.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No packet contained that string in its converted data.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No packet matched that filter.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SequenceDialog</name>
<message>
<source>Call Flow</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comment</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No data</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%Ln node(s)</source>
<translation type="unfinished">
<numerusform>%Ln node</numerusform>
<numerusform>%Ln nodes</numerusform>
</translation>
</message>
<message numerus="yes">
<source>%Ln item(s)</source>
<translation type="unfinished">
<numerusform>%Ln item</numerusform>
<numerusform>%Ln items</numerusform>
</translation>
</message>
<message>
<source>Portable Document Format (*.pdf)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Network Graphics (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Windows Bitmap (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JPEG File Interchange Format (*.jpeg *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ASCII (*.txt)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Flow</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body>
<h3>Valuable and amazing time-saving keyboard shortcuts</h3>
<table><tbody>
<tr><th>+</th><td>Zoom in</td></th>
<tr><th>-</th><td>Zoom out</td></th>
<tr><th>0</th><td>Reset graph to its initial state</td></th>
<tr><th>→</th><td>Move right 10 pixels</td></th>
<tr><th>←</th><td>Move left 10 pixels</td></th>
<tr><th>↑</th><td>Move up 10 pixels</td></th>
<tr><th>↓</th><td>Move down 10 pixels</td></th>
<tr><th><i>Shift+</i>→</th><td>Move right 1 pixel</td></th>
<tr><th><i>Shift+</i>←</th><td>Move left 1 pixel</td></th>
<tr><th><i>Shift+</i>↑</th><td>Move up 1 pixel</td></th>
<tr><th><i>Shift+</i>↓</th><td>Move down 1 pixel</td></th>
<tr><th>g</th><td>Go to packet under cursor</td></th>
<tr><th>n</th><td>Go to the next packet</td></th>
<tr><th>p</th><td>Go to the previous packet</td></th>
</tbody></table>
</body></html></source>
<oldsource><html><head/><body>
<h3>Valuable and amazing time-saving keyboard shortcuts</h3>
<table><tbody>
<tr><th>0</th><td>Reset graph to its initial state</td></th>
<tr><th>→</th><td>Move right 10 pixels</td></th>
<tr><th>←</th><td>Move left 10 pixels</td></th>
<tr><th>↑</th><td>Move up 10 pixels</td></th>
<tr><th>↓</th><td>Move down 10 pixels</td></th>
<tr><th><i>Shift+</i>→</th><td>Move right 1 pixel</td></th>
<tr><th><i>Shift+</i>←</th><td>Move left 1 pixel</td></th>
<tr><th><i>Shift+</i>↑</th><td>Move up 1 pixel</td></th>
<tr><th><i>Shift+</i>↓</th><td>Move down 1 pixel</td></th>
<tr><th>g</th><td>Go to packet under cursor</td></th>
<tr><th>n</th><td>Go to the next packet</td></th>
<tr><th>p</th><td>Go to the previous packet</td></th>
</tbody></table>
</body></html></oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Only show flows matching the current display filter</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit to display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Flow type:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Addresses:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Any</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Network</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset Diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset &Diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset the diagram to its initial state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Reset Diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset the diagram to its initial state</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&Export</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export diagram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>+</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>-</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Packet Under Cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to packet currently under the cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Flows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show flows for all packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TCP Flows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show only TCP flow information</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Next Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>N</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Previous Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the previous packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>P</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select RTP Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select RTP stream in RTP Streams dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>S</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deselect RTP Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deselect RTP stream in RTP Streams dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>D</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShortcutListModel</name>
<message>
<source>Shortcut</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShowPacketBytesDialog</name>
<message>
<source>Show Packet Bytes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hint.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Decode as</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show as</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>End</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Find &Next</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>Frame %1, %2, %Ln byte(s).</source>
<translation type="unfinished">
<numerusform>Frame %1, %2, %Ln byte.</numerusform>
<numerusform>Frame %1, %2, %Ln bytes.</numerusform>
</translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Base64</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Compressed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hex Digits</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Quoted-Printable</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ROT13</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ASCII</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ASCII & Control</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>C Array</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>EBCDIC</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Hex Dump</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>HTML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Raw</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UTF-8</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Selected Packet Bytes As…</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>Displaying %Ln byte(s).</source>
<translation type="unfinished">
<numerusform>Displaying %Ln byte.</numerusform>
<numerusform>Displaying %Ln bytes.</numerusform>
</translation>
</message>
<message>
<source>Regex Find:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ShowPacketBytesTextEdit</name>
<message>
<source>Show Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show All</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SplashOverlay</name>
<message>
<source>Initializing dissectors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Initializing tap listeners</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Initializing external capture plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Registering dissectors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Registering plugins</source>
<oldsource>Registering dissector</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Handing off dissectors</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Handing off plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Loading Lua plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Removing Lua plugins</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Loading module preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Finding local interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>(Unknown action)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatsTreeDialog</name>
<message>
<source>Configuration not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to find configuration for %1.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SupportedProtocolsDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Search the list of field names.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>Gathering protocol information…</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Supported Protocols</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 protocols, %2 fields.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SupportedProtocolsModel</name>
<message>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SyntaxLineEdit</name>
<message>
<source>"%1" is deprecated in favour of "%2". See Help section 6.4.8 for details.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>TCPStreamDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body>
<h3>Valuable and amazing time-saving keyboard shortcuts</h3>
<table><tbody>
<tr><th>+</th><td>Zoom in</td></th>
<tr><th>-</th><td>Zoom out</td></th>
<tr><th>x</th><td>Zoom in X axis</td></th>
<tr><th>X</th><td>Zoom out X axis</td></th>
<tr><th>y</th><td>Zoom in Y axis</td></th>
<tr><th>Y</th><td>Zoom out Y axis</td></th>
<tr><th>0</th><td>Reset graph to its initial state</td></th>
<tr><th>→</th><td>Move right 10 pixels</td></th>
<tr><th>←</th><td>Move left 10 pixels</td></th>
<tr><th>↑</th><td>Move up 10 pixels</td></th>
<tr><th>↓</th><td>Move down 10 pixels</td></th>
<tr><th><i>Shift+</i>→</th><td>Move right 1 pixel</td></th>
<tr><th><i>Shift+</i>←</th><td>Move left 1 pixel</td></th>
<tr><th><i>Shift+</i>↑</th><td>Move up 1 pixel</td></th>
<tr><th><i>Shift+</i>↓</th><td>Move down 1 pixel</td></th>
<tr><th><i>Pg Up</i></th><td>Next stream</td></th>
<tr><th><i>Pg Dn</i></th><td>Previous stream</td></th>
<tr><th>d</th><td>Switch direction (swap TCP endpoints)</td></th>
<tr><th>g</th><td>Go to packet under cursor</td></th>
<tr><th>z</th><td>Toggle mouse drag / zoom</td></th>
<tr><th>s</th><td>Toggle relative / absolute sequence numbers</td></th>
<tr><th>t</th><td>Toggle capture / session time origin</td></th>
<tr><th>Space</th><td>Toggle crosshairs</td></th>
<tr><th>1</th><td>Round Trip Time graph</td></th>
<tr><th>2</th><td>Throughput graph</td></th>
<tr><th>3</th><td>Stevens-style Time / Sequence graph</td></th>
<tr><th>4</th><td>tcptrace-style Time / Sequence graph</td></th>
<tr><th>5</th><td>Window Scaling graph</td></th>
</tbody></table>
</body></html></source>
<oldsource><html><head/><body>
<h3>Valuable and amazing time-saving keyboard shortcuts</h3>
<table><tbody>
<tr><th>+</th><td>Zoom in</td></th>
<tr><th>-</th><td>Zoom out</td></th>
<tr><th>0</th><td>Reset graph to its initial state</td></th>
<tr><th>→</th><td>Move right 10 pixels</td></th>
<tr><th>←</th><td>Move left 10 pixels</td></th>
<tr><th>↑</th><td>Move up 10 pixels</td></th>
<tr><th>↓</th><td>Move down 10 pixels</td></th>
<tr><th><i>Shift+</i>→</th><td>Move right 1 pixel</td></th>
<tr><th><i>Shift+</i>←</th><td>Move left 1 pixel</td></th>
<tr><th><i>Shift+</i>↑</th><td>Move up 1 pixel</td></th>
<tr><th><i>Shift+</i>↓</th><td>Move down 1 pixel</td></th>
<tr><th><i>Pg Up</i></th><td>Next stream</td></th>
<tr><th><i>Pg Dn</i></th><td>Previous stream</td></th>
<tr><th>d</th><td>Switch direction (swap TCP endpoints)</td></th>
<tr><th>g</th><td>Go to packet under cursor</td></th>
<tr><th>z</th><td>Toggle mouse drag / zoom</td></th>
<tr><th>s</th><td>Toggle relative / absolute sequence numbers</td></th>
<tr><th>t</th><td>Toggle capture / session time origin</td></th>
<tr><th>Space</th><td>Toggle crosshairs</td></th>
<tr><th>1</th><td>Round Trip Time graph</td></th>
<tr><th>2</th><td>Throughput graph</td></th>
<tr><th>3</th><td>Stevens-style Time / Sequence graph</td></th>
<tr><th>4</th><td>tcptrace-style Time / Sequence graph</td></th>
<tr><th>5</th><td>Window Scaling graph</td></th>
</tbody></table>
</body></html></oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>Mouse over for shortcuts</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MA Window (s)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Allow SACK segments as well as data packets to be selected by clicking on the graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select SACKs</source>
<oldsource>select SACKs</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Switch the direction of the connection (view the opposite flow).</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch Direction</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Mouse</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Drag using the mouse button.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>drags</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select using the mouse button.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>zooms</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display Round Trip Time vs Sequence Number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RTT By Sequence Number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display graph of Segment Length vs Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Segment Length</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display graph of Mean Transmitted Bytes vs Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display graph of Mean ACKed Bytes vs Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Goodput</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display graph of Receive Window Size vs Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Rcv Win</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display graph of Outstanding Bytes vs Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bytes Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Reset the graph to its initial state.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset Graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset the graph to its initial state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>+</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>-</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 10 Pixels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Up 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Up</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Left 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Left</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Right 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Right</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move Down 1 Pixel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Down</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Next Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the next stream in the capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PgUp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Previous Stream</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to the previous stream in the capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PgDown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch direction (swap TCP endpoints)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>D</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go To Packet Under Cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Go to packet currently under the cursor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Drag / Zoom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle mouse drag / zoom behavior</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Z</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Relative / Absolute Sequence Numbers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle relative / absolute sequence numbers</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>S</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture / Session Time Origin</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle capture / session time origin</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>T</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Crosshairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle crosshairs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Space</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Round Trip Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the Round Trip Time graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Throughput</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the Throughput graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time / Sequence (Stevens)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the Stevens-style Time / Sequence graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>3</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Window Scaling</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the Window Scaling graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>5</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time / Sequence (tcptrace)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Switch to the tcptrace-style Time / Sequence graph</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>4</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In X Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>X</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out X Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+X</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom In Y Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Zoom Out Y Axis</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Shift+Y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Capture Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 %2 pkts, %3 %4 %5 pkts, %6 </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sequence Numbers (Stevens)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sequence Numbers (tcptrace)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> (MA)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> (%1 Segment MA)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> [not enough data]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> for %1:%2 %3 %4:%5</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 %2 (%3s len %4 seq %5 ack %6 win %7)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click to select packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Release to zoom, x = %1 to %2, y = %3 to %4</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to select range.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Click to select a portion of the graph.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Document Format (*.pdf)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Portable Network Graphics (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Windows Bitmap (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>JPEG File Interchange Format (*.jpeg *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Graph As…</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>TapParameterDialog</name>
<message>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Item</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><small><i>A hint.</i></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Regenerate statistics using this display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy a text representation of the tree to the clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save as…</source>
<oldsource>Save as...</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save the displayed data in various formats</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Collapse All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expand All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Statistics As…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Plain text file (*.txt);;Comma separated values (*.csv);;XML document (*.xml);;YAML document (*.yaml)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Plain text file (*.txt)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error saving file %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>TimeShiftDialog</name>
<message>
<source>Shift all packets by</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p><span style=" font-size:small; font-style:italic;">[-][[hh:]mm:]ss[.ddd] </span></p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set the time for packet</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>to</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…then set packet</source>
<oldsource>...then set packet</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>and extrapolate the time for all other packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p align="right"><span style=" font-size:small; font-style:italic;">[YYYY-MM-DD] hh:mm:ss[.ddd] </span></p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Undo all shifts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time Shift</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Frame numbers must be between 1 and %1.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid frame number.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time shifting is not available capturing packets.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>TrafficTableDialog</name>
<message>
<source><html><head/><body><p>Show resolved addresses and port names rather than plain values. The corresponding name resolution preference must be enabled.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name resolution</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Only show conversations matching the current display filter</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit to display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Show absolute times in the start time column.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Absolute start time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Add and remove conversation types.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>%1 Types</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy all values of this page to the clipboard in CSV (Comma Separated Values) format.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy all values of this page to the clipboard in the YAML data serialization format.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UatDialog</name>
<message>
<source>Create a new entry.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove this entry.</source>
<oldsource>Remove this profile.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this entry.</source>
<oldsource>Copy this profile.</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move entry up.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move entry down.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear all entries.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown User Accessible Table</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>UatFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Create a new entry.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove this entry.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy this entry.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move entry up.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move entry down.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear all entries.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy entries from another profile.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy from</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown User Accessible Table</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VoipCallsDialog</name>
<message>
<source><small></small></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Only show conversations matching the current display filter</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit to display filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Time of Day</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Flow &Sequence</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show flow sequence for selected call(s).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare &Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prepare a filter matching the selected calls(s).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cop&y</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open copy menu</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select all</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>None</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invert selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select related RTP streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select RTP streams related to selected calls in RTP Streams dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>S</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deselect related RTP Streams</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>D</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Display time as time of day</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy stream list as CSV.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy stream list as YAML.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SIP Flows</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>VoIP Calls</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>as CSV</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>as YAML</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>VoipCallsInfoModel</name>
<message>
<source>On</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tunneling: %1 Fast Start: %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Stop Time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Initial Speaker</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>From</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>To</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Protocol</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Duration</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>State</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Comments</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WelcomePage</name>
<message>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p><span style=" font-size:large;">Welcome to Wireshark</span></p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Open a file on your file system</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><h2>Open</h2></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Recent capture files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Capture files that have been opened previously</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Capture live packets from your network.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><h2>Capture</h2></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>…using this filter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interface list</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of available capture interfaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><h2>Learn</h2></source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head>
<style>
a:link {
color: palette(text);
text-decoration: none;
}
a:hover {
color: palette(text);
text-decoration: underline;
}
</style>
</head>
<body>
<table><tr>
<th><a href="https://www.wireshark.org/docs/wsug_html_chunked/">User's Guide</a></th>
<td style="padding-left: 8px; padding-right: 8px;">·</td>
<th><a href="https://gitlab.com/wireshark/wireshark/-/wikis/">Wiki</a></th>
<td style="padding-left: 8px; padding-right: 8px;">·</td>
<th><a href="https://ask.wireshark.org/">Questions and Answers</a></th>
<td style="padding-left: 8px; padding-right: 8px;">·</td>
<th><a href="https://www.wireshark.org/lists/">Mailing Lists</a></th>
</tr></table>
</body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show in Finder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show in Folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All interfaces shown</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%n interface(s) shown, %1 hidden</source>
<translation type="unfinished">
<numerusform>%n interface shown, %1 hidden</numerusform>
<numerusform>%n interfaces shown, %1 hidden</numerusform>
</translation>
</message>
<message>
<source>You are sniffing the glue that holds the Internet together using Wireshark </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>You are running Wireshark </source>
<translation type="unfinished"></translation>
</message>
<message>
<source> You receive automatic updates.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> You have disabled automatic updates.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy file path</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove from list</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WirelessFrame</name>
<message>
<source>Frame</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Interface</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Set the 802.11 channel.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>When capturing, show all frames, ones that have a valid frame check sequence (FCS), or ones with an invalid FCS.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>FCS Filter</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>All Frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Valid Frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid Frames</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wireless controls are not supported in this version of Wireshark.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>External Helper</source>
<translation type="unfinished"></translation>
</message>
<message>
<source><html><head/><body><p>Show the IEEE 802.11 preferences, including decryption keys.</p></body></html></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>802.11 Preferences</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>AirPcap Control Panel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the AirPcap Control Panel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to set channel or offset.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to set FCS validation behavior.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WirelessTimeline</name>
<message>
<source>Packet number %1 does not include TSF timestamp, not showing timeline.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Packet number %u has large negative jump in TSF, not showing timeline. Perhaps TSF reference point is set wrong?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WiresharkDialog</name>
<message>
<source>Failed to attach to tap "%1"</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WlanStatisticsDialog</name>
<message>
<source>Wireless LAN Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>SSID</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Percent Packets</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Percent Retry</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Probe Reqs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Probe Resp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auths</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Retry</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deauths</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Other</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS> |
|
C++ | wireshark/ui/logray/logray_main.cpp | /* logray_main.cpp
*
* Logray - Event log analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <glib.h>
#include <locale.h>
#ifdef _WIN32
#include <windows.h>
#include <tchar.h>
#include <wchar.h>
#include <shellapi.h>
#include <wsutil/console_win32.h>
#endif
#include <ws_exit_codes.h>
#include <wsutil/clopts_common.h>
#include <wsutil/cmdarg_err.h>
#include <ui/urls.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <wsutil/socket.h>
#include <wsutil/wslog.h>
#ifdef HAVE_PLUGINS
#include <wsutil/plugins.h>
#endif
#include <wsutil/report_message.h>
#include <wsutil/please_report_bug.h>
#include <wsutil/unicode-utils.h>
#include <wsutil/version_info.h>
#include <epan/addr_resolv.h>
#include <epan/ex-opt.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/column.h>
#include <epan/disabled_protos.h>
#include <epan/prefs.h>
#ifdef HAVE_KERBEROS
#include <epan/packet.h>
#include <epan/asn1.h>
#include <epan/dissectors/packet-kerberos.h>
#endif
#include <wsutil/codecs.h>
#include <extcap.h>
/* general (not Qt specific) */
#include "file.h"
#include "epan/color_filters.h"
#include "epan/rtd_table.h"
#include "epan/srt_table.h"
#include "ui/alert_box.h"
#include "ui/iface_lists.h"
#include "ui/language.h"
#include "ui/persfilepath_opt.h"
#include "ui/recent.h"
#include "ui/simple_dialog.h"
#include "ui/util.h"
#include "ui/dissect_opts.h"
#include "ui/commandline.h"
#include "ui/capture_ui_utils.h"
#include "ui/preference_utils.h"
#include "ui/software_update.h"
#include "ui/taps.h"
#include "ui/qt/conversation_dialog.h"
#include "ui/qt/utils/color_utils.h"
#include "ui/qt/coloring_rules_dialog.h"
#include "ui/qt/endpoint_dialog.h"
#include "ui/qt/glib_mainloop_on_qeventloop.h"
#include "ui/logray/logray_main_window.h"
#include "ui/qt/simple_dialog.h"
#include "ui/qt/simple_statistics_dialog.h"
#include <ui/qt/widgets/splash_overlay.h>
#include "ui/logray/logray_application.h"
#include "capture/capture-pcap-util.h"
#include <QMessageBox>
#include <QScreen>
#ifdef _WIN32
# include "capture/capture-wpcap.h"
# include <wsutil/file_util.h>
#endif /* _WIN32 */
#ifdef HAVE_AIRPCAP
# include <capture/airpcap.h>
# include <capture/airpcap_loader.h>
//# include "airpcap_dlg.h"
//# include "airpcap_gui_utils.h"
#endif
#include "epan/crypt/dot11decrypt_ws.h"
/* Handle the addition of View menu items without request */
#if defined(Q_OS_MAC)
#include <ui/macosx/cocoa_bridge.h>
#endif
#include <ui/qt/utils/qt_ui_utils.h>
//#define DEBUG_STARTUP_TIME 1
/* update the main window */
void main_window_update(void)
{
LograyApplication::processEvents();
}
void exit_application(int status) {
if (lwApp) {
lwApp->quit();
}
exit(status);
}
/*
* Report an error in command-line arguments.
*
* On Windows, Wireshark is built for the Windows subsystem, and runs
* without a console, so we create a console on Windows to receive the
* output.
*
* See create_console(), in ui/win32/console_win32.c, for an example
* of code to check whether we need to create a console.
*
* On UN*Xes:
*
* If Wireshark is run from the command line, its output either goes
* to the terminal or to wherever the standard error was redirected.
*
* If Wireshark is run by executing it as a remote command, e.g. with
* ssh, its output either goes to whatever socket was set up for the
* remote command's standard error or to wherever the standard error
* was redirected.
*
* If Wireshark was run from the GUI, e.g. by double-clicking on its
* icon or on a file that it opens, there are no guarantees as to
* where the standard error went. It could be going to /dev/null
* (current macOS), or to a socket to systemd for the journal, or
* to a log file in the user's home directory, or to the "console
* device" ("workstation console"), or....
*
* Part of determining that, at least for locally-run Wireshark,
* is to try to open /dev/tty to determine whether the process
* has a controlling terminal. (It fails, at a minimum, for
* Wireshark launched from the GUI under macOS, Ubuntu with GNOME,
* and Ubuntu with KDE; in all cases, an attempt to open /dev/tty
* fails with ENXIO.) If it does have a controlling terminal,
* write to the standard error, otherwise assume that the standard
* error might not go anywhere that the user will be able to see.
* That doesn't handle the "run by ssh" case, however; that will
* not have a controlling terminal. (This means running it by
* remote execution, not by remote login.) Perhaps there's an
* environment variable to check there.
*/
// xxx copied from ../gtk/main.c
static void
logray_cmdarg_err(const char *fmt, va_list ap)
{
#ifdef _WIN32
create_console();
#endif
fprintf(stderr, "logray: ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
}
/*
* Report additional information for an error in command-line arguments.
* Creates a console on Windows.
*/
// xxx copied from ../gtk/main.c
static void
logray_cmdarg_err_cont(const char *fmt, va_list ap)
{
#ifdef _WIN32
create_console();
#endif
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
}
void
gather_wireshark_qt_compiled_info(feature_list l)
{
#ifdef QT_VERSION
with_feature(l, "Qt %s", QT_VERSION_STR);
#else
with_feature(l, "Qt (version unknown)");
#endif
gather_caplibs_compile_info(l);
epan_gather_compile_info(l);
#ifdef QT_MULTIMEDIA_LIB
with_feature(l, "QtMultimedia");
#else
without_feature(l, "QtMultimedia");
#endif
const char *update_info = software_update_info();
if (update_info) {
with_feature(l, "automatic updates using %s", update_info);
} else {
without_feature(l, "automatic updates");
}
#ifdef _WIN32
#ifdef HAVE_AIRPCAP
gather_airpcap_compile_info(l);
#else
without_feature(l, "AirPcap");
#endif
#endif /* _WIN32 */
#ifdef HAVE_MINIZIP
with_feature(l, "Minizip");
#else
without_feature(l, "Minizip");
#endif
}
void
gather_wireshark_runtime_info(feature_list l)
{
with_feature(l, "Qt %s", qVersion());
#ifdef HAVE_LIBPCAP
gather_caplibs_runtime_info(l);
#endif
epan_gather_runtime_info(l);
#ifdef HAVE_AIRPCAP
gather_airpcap_runtime_info(l);
#endif
if (mainApp) {
// Display information
const char *display_mode = ColorUtils::themeIsDark() ? "dark" : "light";
with_feature(l, "%s display mode", display_mode);
int hidpi_count = 0;
foreach (QScreen *screen, mainApp->screens()) {
if (screen->devicePixelRatio() > 1.0) {
hidpi_count++;
}
}
if (hidpi_count == mainApp->screens().count()) {
with_feature(l, "HiDPI");
} else if (hidpi_count) {
with_feature(l, "mixed DPI");
} else {
without_feature(l, "HiDPI");
}
}
}
static void
qt_log_message_handler(QtMsgType type, const QMessageLogContext &, const QString &msg)
{
enum ws_log_level log_level = LOG_LEVEL_DEBUG;
switch (type) {
case QtInfoMsg:
log_level = LOG_LEVEL_INFO;
break;
// We want qDebug() messages to show up at our default log level.
case QtDebugMsg:
case QtWarningMsg:
log_level = LOG_LEVEL_WARNING;
break;
case QtCriticalMsg:
log_level = LOG_LEVEL_CRITICAL;
break;
case QtFatalMsg:
log_level = LOG_LEVEL_ERROR;
break;
default:
break;
}
ws_log(LOG_DOMAIN_QTUI, log_level, "%s", qUtf8Printable(msg));
}
#ifdef HAVE_LIBPCAP
/* Check if there's something important to tell the user during startup.
* We want to do this *after* showing the main window so that any windows
* we pop up will be above the main window.
*/
static void
check_and_warn_user_startup()
{
gchar *cur_user, *cur_group;
/* Tell the user not to run as root. */
if (running_with_special_privs() && recent.privs_warn_if_elevated) {
cur_user = get_cur_username();
cur_group = get_cur_groupname();
simple_message_box(ESD_TYPE_WARN, &recent.privs_warn_if_elevated,
"Running as user \"%s\" and group \"%s\".\n"
"This could be dangerous.\n\n"
"If you're running Wireshark this way in order to perform live capture, "
"you may want to be aware that there is a better way documented at\n"
WS_WIKI_URL("CaptureSetup/CapturePrivileges"), cur_user, cur_group);
g_free(cur_user);
g_free(cur_group);
}
}
#endif
#ifdef _WIN32
// Try to avoid library search path collisions. QCoreApplication will
// search QT_INSTALL_PREFIX/plugins for platform DLLs before searching
// the application directory. If
//
// - You have Qt version 5.x.y installed in the default location
// (C:\Qt\5.x) on your machine.
//
// and
//
// - You install Wireshark that was built on a machine with Qt version
// 5.x.z installed in the default location.
//
// Qt5Core.dll will load qwindows.dll from your local C:\Qt\5.x\...\plugins
// directory. This may not be compatible with qwindows.dll from that
// same path on the build machine. At any rate, loading DLLs from paths
// you don't control is ill-advised. We work around this by removing every
// path except our application directory.
static inline void
win32_reset_library_path(void)
{
QString app_path = QDir(get_progfile_dir()).path();
foreach (QString path, QCoreApplication::libraryPaths()) {
QCoreApplication::removeLibraryPath(path);
}
QCoreApplication::addLibraryPath(app_path);
}
#endif
#ifdef Q_OS_MAC
// Try to work around
//
// https://gitlab.com/wireshark/wireshark/-/issues/17075
//
// aka
//
// https://bugreports.qt.io/browse/QTBUG-87014
//
// The fix at
//
// https://codereview.qt-project.org/c/qt/qtbase/+/322228/3/src/plugins/platforms/cocoa/qnsview_drawing.mm
//
// enables layer backing if we're running on Big Sur OR we're running on
// Catalina AND we were built with the Catalina SDK. Enable layer backing
// here by setting QT_MAC_WANTS_LAYER=1, but only if we're running on Big
// Sur and our version of Qt doesn't have a fix for QTBUG-87014.
#include <QOperatingSystemVersion>
static inline void
macos_enable_layer_backing(void)
{
// At the time of this writing, the QTBUG-87014 for layerEnabledByMacOS is...
//
// ...in https://github.com/qt/qtbase/blob/5.12/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/5.12.10/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...in https://github.com/qt/qtbase/blob/5.15/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/5.15.2/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/6.0/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/6.0.0/src/plugins/platforms/cocoa/qnsview_drawing.mm
//
// We'll assume that it will be fixed in 5.12.11, 5.15.3, and 6.0.1.
// Note that we only ship LTS versions of Qt with our macOS packages.
// Feel free to add other versions if needed.
#if \
(QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(5, 12, 11) \
|| (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) \
|| (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 1)) \
)
QOperatingSystemVersion os_ver = QOperatingSystemVersion::current();
int major_ver = os_ver.majorVersion();
int minor_ver = os_ver.minorVersion();
if ( (major_ver == 10 && minor_ver >= 16) || major_ver >= 11 ) {
if (qgetenv("QT_MAC_WANTS_LAYER").isEmpty()) {
qputenv("QT_MAC_WANTS_LAYER", "1");
}
}
#endif
}
#endif
/* And now our feature presentation... [ fade to music ] */
int main(int argc, char *qt_argv[])
{
LograyMainWindow *main_w;
#ifdef _WIN32
LPWSTR *wc_argv;
int wc_argc;
#endif
int ret_val = EXIT_SUCCESS;
char **argv = qt_argv;
char *rf_path;
int rf_open_errno;
#ifdef HAVE_LIBPCAP
gchar *err_str, *err_str_secondary;;
#else
#ifdef _WIN32
#ifdef HAVE_AIRPCAP
gchar *err_str;
#endif
#endif
#endif
gchar *err_msg = NULL;
df_error_t *df_err = NULL;
QString dfilter, read_filter;
#ifdef HAVE_LIBPCAP
int caps_queries = 0;
#endif
/* Start time in microseconds */
guint64 start_time = g_get_monotonic_time();
static const struct report_message_routines wireshark_report_routines = {
vfailure_alert_box,
vwarning_alert_box,
open_failure_alert_box,
read_failure_alert_box,
write_failure_alert_box,
cfile_open_failure_alert_box,
cfile_dump_open_failure_alert_box,
cfile_read_failure_alert_box,
cfile_write_failure_alert_box,
cfile_close_failure_alert_box
};
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/*
* See:
*
* issue #16908;
*
* https://doc.qt.io/qt-5/qvector.html#maximum-size-and-out-of-memory-conditions
*
* https://forum.qt.io/topic/114950/qvector-realloc-throwing-sigsegv-when-very-large-surface3d-is-rendered
*
* for why we're doing this; the widget we use for the packet list
* uses QVector, so those limitations apply to it.
*
* Apparently, this will be fixed in Qt 6:
*
* https://github.com/qt/qtbase/commit/215ca735341b9487826023a7983382851ce8bf26
*
* https://github.com/qt/qtbase/commit/2a6cdec718934ca2cc7f6f9c616ebe62f6912123#diff-724f419b0bb0487c2629bb16cf534c4b268ddcee89b5177189b607f940cfd83dR192
*
* Hopefully QList won't cause any performance hits relative to
* QVector.
*
* We pick 53 million records as a value that should avoid the problem;
* see the Wireshark issue for why that value was chosen.
*/
cf_set_max_records(53000000);
#endif
#ifdef Q_OS_MAC
macos_enable_layer_backing();
#endif
cmdarg_err_init(logray_cmdarg_err, logray_cmdarg_err_cont);
/* Initialize log handler early so we can have proper logging during startup. */
ws_log_init("logray", vcmdarg_err);
/* For backward compatibility with GLib logging and Wireshark 3.4. */
ws_log_console_writer_set_use_stdout(TRUE);
qInstallMessageHandler(qt_log_message_handler);
#ifdef _WIN32
restore_pipes();
#endif
#ifdef DEBUG_STARTUP_TIME
prefs.gui_console_open = console_open_always;
#endif /* DEBUG_STARTUP_TIME */
#if defined(Q_OS_MAC)
/* Disable automatic addition of tab menu entries in view menu */
CocoaBridge::cleanOSGeneratedMenuItems();
#endif
/*
* Set the C-language locale to the native environment and set the
* code page to UTF-8 on Windows.
*/
#ifdef _WIN32
setlocale(LC_ALL, ".UTF-8");
#else
setlocale(LC_ALL, "");
#endif
#ifdef _WIN32
//
// On Windows, QCoreApplication has its own WinMain(), which gets the
// command line using GetCommandLineW(), breaks it into individual
// arguments using CommandLineToArgvW(), and then "helpfully"
// converts those UTF-16LE arguments into strings in the local code
// page.
//
// We don't want that, because not all file names can be represented
// in the local code page, so we do the same, but we convert the
// strings into UTF-8.
//
wc_argv = CommandLineToArgvW(GetCommandLineW(), &wc_argc);
if (wc_argv) {
argc = wc_argc;
argv = arg_list_utf_16to8(wc_argc, wc_argv);
LocalFree(wc_argv);
} /* XXX else bail because something is horribly, horribly wrong? */
create_app_running_mutex();
#endif /* _WIN32 */
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, WS_EXIT_INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
/*
* Get credential information for later use, and drop privileges
* before doing anything else.
* Let the user know if anything happened.
*/
init_process_policies();
relinquish_special_privs_perm();
/*
* Attempt to get the pathname of the directory containing the
* executable file.
*/
/* configuration_init_error = */ configuration_init(argv[0], "Logray");
/* ws_log(NULL, LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir()); */
#ifdef _WIN32
ws_init_dll_search_path();
/* Load wpcap if possible. Do this before collecting the run-time version information */
load_wpcap();
#ifdef HAVE_AIRPCAP
/* Load the airpcap.dll. This must also be done before collecting
* run-time version information. */
load_airpcap();
#if 0
airpcap_dll_ret_val = load_airpcap();
switch (airpcap_dll_ret_val) {
case AIRPCAP_DLL_OK:
/* load the airpcap interfaces */
g_airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
if (g_airpcap_if_list == NULL || g_list_length(g_airpcap_if_list) == 0) {
if (err == CANT_GET_AIRPCAP_INTERFACE_LIST && err_str != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Failed to open Airpcap Adapters.");
g_free(err_str);
}
airpcap_if_active = NULL;
} else {
/* select the first as default (THIS SHOULD BE CHANGED) */
airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
}
break;
/*
* XXX - Maybe we need to warn the user if one of the following happens???
*/
case AIRPCAP_DLL_OLD:
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_OLD\n");
break;
case AIRPCAP_DLL_ERROR:
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_ERROR\n");
break;
case AIRPCAP_DLL_NOT_FOUND:
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DDL_NOT_FOUND\n");
break;
}
#endif
#endif /* HAVE_AIRPCAP */
#endif /* _WIN32 */
/* Get the compile-time version information string */
ws_init_version_info("Logray", gather_wireshark_qt_compiled_info,
gather_wireshark_runtime_info);
init_report_message("Logray", &wireshark_report_routines);
/* Create the user profiles directory */
if (create_profiles_dir(&rf_path) == -1) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not create profiles directory\n\"%s\": %s.",
rf_path, g_strerror(errno));
g_free (rf_path);
}
profile_store_persconffiles(TRUE);
recent_init();
/* Read the profile independent recent file. We have to do this here so we can */
/* set the profile before it can be set from the command line parameter */
if (!recent_read_static(&rf_path, &rf_open_errno)) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open common recent file\n\"%s\": %s.",
rf_path, g_strerror(rf_open_errno));
g_free(rf_path);
}
commandline_early_options(argc, argv);
#ifdef _WIN32
win32_reset_library_path();
#endif
// Handle DPI scaling on Windows. This causes problems in at least
// one case on X11 and we don't yet support Android.
// We do the equivalent on macOS by setting NSHighResolutionCapable
// in Info.plist.
// Note that this enables Windows 8.1-style Per-monitor DPI
// awareness but not Windows 10-style Per-monitor v2 awareness.
// https://doc.qt.io/qt-5/scalability.html
// https://doc.qt.io/qt-5/highdpi.html
// https://bugreports.qt.io/browse/QTBUG-53022 - The device pixel ratio is pretty much bogus on Windows.
// https://bugreports.qt.io/browse/QTBUG-55510 - Windows have wrong size
#if defined(Q_OS_WIN)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
/* Create The Wireshark app */
LograyApplication ls_app(argc, qt_argv);
/* initialize the funnel mini-api */
// xxx qtshark
//initialize_funnel_ops();
Dot11DecryptInitContext(&dot11decrypt_ctx);
QString cf_name;
unsigned int in_file_type = WTAP_TYPE_AUTO;
err_msg = ws_init_sockets();
if (err_msg != NULL)
{
cmdarg_err("%s", err_msg);
g_free(err_msg);
cmdarg_err_cont("%s", please_report_bug());
ret_val = WS_EXIT_INIT_FAILED;
goto clean_exit;
}
/* Read the profile dependent (static part) of the recent file. */
/* Only the static part of it will be read, as we don't have the gui now to fill the */
/* recent lists which is done in the dynamic part. */
/* We have to do this already here, so command line parameters can overwrite these values. */
if (!recent_read_profile_static(&rf_path, &rf_open_errno)) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open recent file\n\"%s\": %s.",
rf_path, g_strerror(rf_open_errno));
g_free(rf_path);
}
lwApp->applyCustomColorsFromRecent();
// Initialize our language
read_language_prefs();
lwApp->loadLanguage(language);
/* ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_DEBUG, "Translator %s", language); */
// Init the main window (and splash)
main_w = new(LograyMainWindow);
main_w->show();
// Setup GLib mainloop on Qt event loop to enable GLib and GIO watches
GLibMainloopOnQEventLoop::setup(main_w);
// We may not need a queued connection here but it would seem to make sense
// to force the issue.
main_w->connect(&ls_app, SIGNAL(openCaptureFile(QString,QString,unsigned int)),
main_w, SLOT(openCaptureFile(QString,QString,unsigned int)));
main_w->connect(&ls_app, &LograyApplication::openCaptureOptions,
main_w, &LograyMainWindow::showCaptureOptionsDialog);
/* Init the "Open file" dialog directory */
/* (do this after the path settings are processed) */
if (recent.gui_fileopen_remembered_dir &&
test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) {
lwApp->setLastOpenDir(recent.gui_fileopen_remembered_dir);
} else {
lwApp->setLastOpenDir(get_persdatafile_dir());
}
#ifdef DEBUG_STARTUP_TIME
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "set_console_log_handler, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
#ifdef HAVE_LIBPCAP
/* Set the initial values in the capture options. This might be overwritten
by preference settings and then again by the command line parameters. */
capture_opts_init(&global_capture_opts);
#endif
/*
* Libwiretap must be initialized before libwireshark is, so that
* dissection-time handlers for file-type-dependent blocks can
* register using the file type/subtype value for the file type.
*/
wtap_init(TRUE);
splash_update(RA_DISSECTORS, NULL, NULL);
#ifdef DEBUG_STARTUP_TIME
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling epan init, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
/* Register all dissectors; we must do this before checking for the
"-G" flag, as the "-G" flag dumps information registered by the
dissectors, and we must do it before we read the preferences, in
case any dissectors register preferences. */
if (!epan_init(splash_update, NULL, TRUE)) {
SimpleDialog::displayQueuedMessages(main_w);
ret_val = WS_EXIT_INIT_FAILED;
goto clean_exit;
}
#ifdef DEBUG_STARTUP_TIME
/* epan_init resets the preferences */
prefs.gui_console_open = console_open_always;
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "epan done, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
/* Register all audio codecs. */
codecs_init();
// Read the dynamic part of the recent file. This determines whether or
// not the recent list appears in the main window so the earlier we can
// call this the better.
if (!recent_read_dynamic(&rf_path, &rf_open_errno)) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open recent file\n\"%s\": %s.",
rf_path, g_strerror(rf_open_errno));
g_free(rf_path);
}
lwApp->refreshRecentCaptures();
splash_update(RA_LISTENERS, NULL, NULL);
#ifdef DEBUG_STARTUP_TIME
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Register all tap listeners, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
/* Register all tap listeners; we do this before we parse the arguments,
as the "-z" argument can specify a registered tap. */
register_all_tap_listeners(tap_reg_listener);
conversation_table_set_gui_info(init_conversation_table);
endpoint_table_set_gui_info(init_endpoint_table);
// srt_table_iterate_tables(register_service_response_tables, NULL);
// rtd_table_iterate_tables(register_response_time_delay_tables, NULL);
stat_tap_iterate_tables(register_simple_stat_tables, NULL);
if (ex_opt_count("read_format") > 0) {
in_file_type = open_info_name_to_type(ex_opt_get_next("read_format"));
}
#ifdef DEBUG_STARTUP_TIME
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling extcap_register_preferences, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
splash_update(RA_EXTCAP, NULL, NULL);
extcap_register_preferences();
splash_update(RA_PREFERENCES, NULL, NULL);
#ifdef DEBUG_STARTUP_TIME
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling module preferences, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
global_commandline_info.prefs_p = ls_app.readConfigurationFiles(false);
/* Now get our args */
commandline_other_options(argc, argv, TRUE);
/* Convert some command-line parameters to QStrings */
if (global_commandline_info.cf_name != NULL)
cf_name = QString(global_commandline_info.cf_name);
if (global_commandline_info.rfilter != NULL)
read_filter = QString(global_commandline_info.rfilter);
if (global_commandline_info.dfilter != NULL)
dfilter = QString(global_commandline_info.dfilter);
timestamp_set_type(recent.gui_time_format);
timestamp_set_precision(recent.gui_time_precision);
timestamp_set_seconds_type (recent.gui_seconds_format);
#ifdef HAVE_LIBPCAP
#ifdef DEBUG_STARTUP_TIME
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling fill_in_local_interfaces, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
splash_update(RA_INTERFACES, NULL, NULL);
if (!global_commandline_info.cf_name && !prefs.capture_no_interface_load) {
/* Allow only extcap interfaces to be found */
GList * filter_list = NULL;
filter_list = g_list_append(filter_list, GUINT_TO_POINTER((guint) IF_EXTCAP));
fill_in_local_interfaces_filtered(filter_list, main_window_update);
g_list_free(filter_list);
}
if (global_commandline_info.list_link_layer_types)
caps_queries |= CAPS_QUERY_LINK_TYPES;
if (global_commandline_info.list_timestamp_types)
caps_queries |= CAPS_QUERY_TIMESTAMP_TYPES;
if (global_commandline_info.start_capture || caps_queries) {
/* We're supposed to do a live capture or get a list of link-layer/timestamp
types for a live capture device; if the user didn't specify an
interface to use, pick a default. */
ret_val = capture_opts_default_iface_if_necessary(&global_capture_opts,
((global_commandline_info.prefs_p->capture_device) && (*global_commandline_info.prefs_p->capture_device != '\0')) ? get_if_name(global_commandline_info.prefs_p->capture_device) : NULL);
if (ret_val != 0) {
goto clean_exit;
}
}
/*
* If requested, list the link layer types and/or time stamp types
* and exit.
*/
if (caps_queries) {
guint i;
#ifdef _WIN32
create_console();
#endif /* _WIN32 */
/* Get the list of link-layer types for the capture devices. */
ret_val = EXIT_SUCCESS;
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
interface_options *interface_opts;
if_capabilities_t *caps;
char *auth_str = NULL;
interface_opts = &g_array_index(global_capture_opts.ifaces, interface_options, i);
#ifdef HAVE_PCAP_REMOTE
if (interface_opts->auth_type == CAPTURE_AUTH_PWD) {
auth_str = g_strdup_printf("%s:%s", interface_opts->auth_username, interface_opts->auth_password);
}
#endif
caps = capture_get_if_capabilities(interface_opts->name, interface_opts->monitor_mode,
auth_str, &err_str, &err_str_secondary, NULL);
g_free(auth_str);
if (caps == NULL) {
cmdarg_err("%s%s%s", err_str, err_str_secondary ? "\n" : "", err_str_secondary ? err_str_secondary : "");
g_free(err_str);
g_free(err_str_secondary);
ret_val = WS_EXIT_INVALID_CAPABILITY;
break;
}
ret_val = capture_opts_print_if_capabilities(caps, interface_opts,
caps_queries);
free_if_capabilities(caps);
if (ret_val != EXIT_SUCCESS) {
break;
}
}
#ifdef _WIN32
destroy_console();
#endif /* _WIN32 */
goto clean_exit;
}
capture_opts_trim_snaplen(&global_capture_opts, MIN_PACKET_SIZE);
capture_opts_trim_ring_num_files(&global_capture_opts);
#endif /* HAVE_LIBPCAP */
/* Notify all registered modules that have had any of their preferences
changed either from one of the preferences file or from the command
line that their preferences have changed. */
#ifdef DEBUG_STARTUP_TIME
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling prefs_apply_all, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
prefs_apply_all();
prefs_to_capture_opts();
lwApp->emitAppSignal(LograyApplication::PreferencesChanged);
#ifdef HAVE_LIBPCAP
if ((global_capture_opts.num_selected == 0) &&
(prefs.capture_device != NULL)) {
guint i;
interface_t *device;
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i);
if (!device->hidden && strcmp(device->display_name, prefs.capture_device) == 0) {
device->selected = TRUE;
global_capture_opts.num_selected++;
break;
}
}
}
#endif
/*
* Enabled and disabled protocols and heuristic dissectors as per
* command-line options.
*/
if (!setup_enabled_and_disabled_protocols()) {
ret_val = WS_EXIT_INVALID_OPTION;
goto clean_exit;
}
build_column_format_array(&CaptureFile::globalCapFile()->cinfo, global_commandline_info.prefs_p->num_cols, TRUE);
lwApp->emitAppSignal(LograyApplication::ColumnsChanged); // We read "recent" widths above.
lwApp->emitAppSignal(LograyApplication::RecentPreferencesRead); // Must be emitted after PreferencesChanged.
lwApp->setMonospaceFont(prefs.gui_font_name);
/* For update of WindowTitle (When use gui.window_title preference) */
main_w->setWSWindowTitle();
if (!color_filters_init(&err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
}
lwApp->allSystemsGo();
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Logray is up and ready to go, elapsed time %.3fs", (float) (g_get_monotonic_time() - start_time) / 1000000);
SimpleDialog::displayQueuedMessages(main_w);
/* User could specify filename, or display filter, or both */
if (!dfilter.isEmpty())
main_w->filterPackets(dfilter, false);
if (!cf_name.isEmpty()) {
if (main_w->openCaptureFile(cf_name, read_filter, in_file_type)) {
/* Open stat windows; we do so after creating the main window,
to avoid Qt warnings, and after successfully opening the
capture file, so we know we have something to compute stats
on, and after registering all dissectors, so that MATE will
have registered its field array and we can have a tap filter
with one of MATE's late-registered fields as part of the
filter. */
start_requested_stats();
if (global_commandline_info.go_to_packet != 0) {
/* Jump to the specified frame number, kept for backward
compatibility. */
cf_goto_frame(CaptureFile::globalCapFile(), global_commandline_info.go_to_packet);
} else if (global_commandline_info.jfilter != NULL) {
dfilter_t *jump_to_filter = NULL;
/* try to compile given filter */
if (!dfilter_compile(global_commandline_info.jfilter, &jump_to_filter, &df_err)) {
// Similar code in MainWindow::mergeCaptureFile().
QMessageBox::warning(main_w, QObject::tr("Invalid Display Filter"),
QObject::tr("The filter expression %1 isn't a valid display filter. (%2).")
.arg(global_commandline_info.jfilter, df_err->msg),
QMessageBox::Ok);
df_error_free(&df_err);
} else {
/* Filter ok, jump to the first packet matching the filter
conditions. Default search direction is forward, but if
option d was given, search backwards */
cf_find_packet_dfilter(CaptureFile::globalCapFile(), jump_to_filter, global_commandline_info.jump_backwards);
}
}
}
}
#ifdef HAVE_LIBPCAP
else {
if (global_commandline_info.start_capture) {
if (global_capture_opts.save_file != NULL) {
/* Save the directory name for future file dialogs. */
/* (get_dirname overwrites filename) */
gchar *s = g_strdup(global_capture_opts.save_file);
set_last_open_dir(get_dirname(s));
g_free(s);
}
/* "-k" was specified; start a capture. */
check_and_warn_user_startup();
/* If no user interfaces were specified on the command line,
copy the list of selected interfaces to the set of interfaces
to use for this capture. */
if (global_capture_opts.ifaces->len == 0)
collect_ifaces(&global_capture_opts);
CaptureFile::globalCapFile()->window = main_w;
if (capture_start(&global_capture_opts, global_commandline_info.capture_comments,
main_w->captureSession(), main_w->captureInfoData(),
main_window_update)) {
/* The capture started. Open stat windows; we do so after creating
the main window, to avoid GTK warnings, and after successfully
opening the capture file, so we know we have something to compute
stats on, and after registering all dissectors, so that MATE will
have registered its field array and we can have a tap filter with
one of MATE's late-registered fields as part of the filter. */
start_requested_stats();
}
}
/* if the user didn't supply a capture filter, use the one to filter out remote connections like SSH */
if (!global_commandline_info.start_capture && !global_capture_opts.default_options.cfilter) {
global_capture_opts.default_options.cfilter = g_strdup(get_conn_cfilter());
}
}
#endif /* HAVE_LIBPCAP */
// UAT and UI settings files used in configuration profiles which are used
// in Qt dialogs are not registered during startup because they only get
// loaded when the dialog is shown. Register them here.
profile_register_persconffile("io_graphs");
profile_register_persconffile("import_hexdump.json");
profile_store_persconffiles(FALSE);
// If the lwApp->exec() event loop exits cleanly, we call
// LograyApplication::cleanup().
ret_val = lwApp->exec();
lwApp = NULL;
// Many widgets assume that they always have valid epan data, so this
// must be called before epan_cleanup().
// XXX We need to clean up the Lua GUI here. We currently paper over
// this in FunnelStatistics::~FunnelStatistics, which leaks memory.
delete main_w;
recent_cleanup();
epan_cleanup();
extcap_cleanup();
Dot11DecryptDestroyContext(&dot11decrypt_ctx);
ws_cleanup_sockets();
#ifdef _WIN32
/* For some unknown reason, the "atexit()" call in "create_console()"
doesn't arrange that "destroy_console()" be called when we exit,
so we call it here if a console was created. */
destroy_console();
#endif /* _WIN32 */
clean_exit:
#ifdef HAVE_LIBPCAP
capture_opts_cleanup(&global_capture_opts);
#endif
col_cleanup(&CaptureFile::globalCapFile()->cinfo);
codecs_cleanup();
wtap_cleanup();
free_progdirs();
commandline_options_free();
exit_application(ret_val);
} |
C++ | wireshark/ui/logray/logray_main_window.cpp | /* logray_main_window.cpp
*
* Logray - Event log analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "main_application.h"
#include "logray_main_window.h"
/*
* The generated Ui_LograyMainWindow::setupUi() can grow larger than our configured limit,
* so turn off -Wframe-larger-than= for ui_main_window.h.
*/
DIAG_OFF(frame-larger-than=)
#include <ui_logray_main_window.h>
DIAG_ON(frame-larger-than=)
#include <epan/addr_resolv.h>
#include "epan/conversation_filter.h"
#include <epan/epan_dissect.h>
#include <wsutil/filesystem.h>
#include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>
#include <wsutil/version_info.h>
#include <epan/prefs.h>
#include <epan/stats_tree_priv.h>
#include <epan/plugin_if.h>
#include <epan/export_object.h>
#include <frame_tvbuff.h>
#include "ui/iface_toolbar.h"
#ifdef HAVE_LIBPCAP
#include "ui/capture.h"
#include <capture/capture_session.h>
#endif
#include "ui/alert_box.h"
#ifdef HAVE_LIBPCAP
#include "ui/capture_ui_utils.h"
#endif
#include "ui/capture_globals.h"
#include "ui/main_statusbar.h"
#include "ui/recent.h"
#include "ui/recent_utils.h"
#include "ui/util.h"
#include "ui/preference_utils.h"
#include "byte_view_tab.h"
#ifdef HAVE_LIBPCAP
#include "capture_options_dialog.h"
#endif
#include "conversation_colorize_action.h"
#include "export_dissection_dialog.h"
#include "export_object_action.h"
#include "file_set_dialog.h"
#include "filter_dialog.h"
#include "funnel_statistics.h"
#include "import_text_dialog.h"
#include "interface_toolbar.h"
#include "packet_diagram.h"
#include "packet_list.h"
#include "proto_tree.h"
#include "simple_dialog.h"
#include "tap_parameter_dialog.h"
#include <ui/qt/widgets/additional_toolbar.h>
#include <ui/qt/widgets/display_filter_edit.h>
#include <ui/qt/widgets/filter_expression_toolbar.h>
#include <ui/qt/utils/color_utils.h>
#include <ui/qt/utils/qt_ui_utils.h>
#include <ui/qt/utils/stock_icon.h>
#include <ui/qt/utils/variant_pointer.h>
#include <QAction>
#include <QActionGroup>
#include <QIntValidator>
#include <QKeyEvent>
#include <QList>
#include <QMessageBox>
#include <QMetaObject>
#include <QMimeData>
#include <QTabWidget>
#include <QTextCodec>
#include <QToolButton>
#include <QTreeWidget>
#include <QUrl>
//menu_recent_file_write_all
// If we ever add support for multiple windows this will need to be replaced.
static LograyMainWindow *gbl_cur_main_window_ = NULL;
static void plugin_if_mainwindow_apply_filter(GHashTable * data_set)
{
if (!gbl_cur_main_window_ || !data_set)
return;
if (g_hash_table_lookup_extended(data_set, "filter_string", NULL, NULL)) {
QString filter((const char *)g_hash_table_lookup(data_set, "filter_string"));
gbl_cur_main_window_->filterPackets(filter);
}
}
static void plugin_if_mainwindow_preference(GHashTable * data_set)
{
if (!gbl_cur_main_window_ || !data_set)
return;
const char * module_name;
const char * pref_name;
const char * pref_value;
DIAG_OFF_CAST_AWAY_CONST
if (g_hash_table_lookup_extended(data_set, "pref_module", NULL, (gpointer *)&module_name) &&
g_hash_table_lookup_extended(data_set, "pref_key", NULL, (gpointer *)&pref_name) &&
g_hash_table_lookup_extended(data_set, "pref_value", NULL, (gpointer *)&pref_value))
{
unsigned int changed_flags = prefs_store_ext(module_name, pref_name, pref_value);
if (changed_flags) {
mainApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged);
mainApp->emitAppSignal(WiresharkApplication::PreferencesChanged);
}
}
DIAG_ON_CAST_AWAY_CONST
}
static void plugin_if_mainwindow_gotoframe(GHashTable * data_set)
{
if (!gbl_cur_main_window_ || !data_set)
return;
gpointer framenr;
if (g_hash_table_lookup_extended(data_set, "frame_nr", NULL, &framenr)) {
if (GPOINTER_TO_UINT(framenr) != 0)
gbl_cur_main_window_->gotoFrame(GPOINTER_TO_UINT(framenr));
}
}
#ifdef HAVE_LIBPCAP
static void plugin_if_mainwindow_get_ws_info(GHashTable * data_set)
{
if (!gbl_cur_main_window_ || !data_set)
return;
ws_info_t *ws_info = NULL;
if (!g_hash_table_lookup_extended(data_set, "ws_info", NULL, (void**)&ws_info))
return;
CaptureFile *cfWrap = gbl_cur_main_window_->captureFile();
capture_file *cf = cfWrap->capFile();
ws_info->ws_info_supported = true;
/* If we have a filename attached to ws_info clear it */
if (ws_info->cf_filename != NULL)
{
g_free(ws_info->cf_filename);
ws_info->cf_filename = NULL;
}
/* Determine the true state of the capture file. We return the true state in
the ws_info structure and DON'T CHANGE the cf->state as we don't want to cause problems
with code that follows this. */
if (cf)
{
if (cf->filename)
{
/* As we have a cf->filename we'll use the name and the state */
ws_info->cf_filename = g_strdup(cf->filename);
ws_info->cf_state = cf->state;
}
else
{
/* When we come through here the cf->state can show FILE_READ_DONE even though the
file is actually closed (no filename). A better fix would be to have a
FILE_CLOSE_PENDING state but that involves a lot of code change elsewhere. */
ws_info->cf_state = FILE_CLOSED;
}
}
if (!ws_info->cf_filename)
{
/* We may have a filename associated with the main window so let's use it */
QString fileNameString = gbl_cur_main_window_->getMwFileName();
if (fileNameString.length())
{
QByteArray ba = fileNameString.toLatin1();
const char *c_file_name = ba.data();
ws_info->cf_filename = g_strdup(c_file_name);
}
}
if (cf) {
ws_info->cf_count = cf->count;
QList<int> rows = gbl_cur_main_window_->selectedRows();
frame_data * fdata = NULL;
if (rows.count() > 0)
fdata = gbl_cur_main_window_->frameDataForRow(rows.at(0));
if (cf->state == FILE_READ_DONE && fdata) {
ws_info->cf_framenr = fdata->num;
ws_info->frame_passed_dfilter = (fdata->passed_dfilter == 1);
}
else {
ws_info->cf_framenr = 0;
ws_info->frame_passed_dfilter = FALSE;
}
}
else
{
/* Initialise the other ws_info structure values */
ws_info->cf_count = 0;
ws_info->cf_framenr = 0;
ws_info->frame_passed_dfilter = FALSE;
}
}
#endif /* HAVE_LIBPCAP */
static void plugin_if_mainwindow_get_frame_data(GHashTable* data_set)
{
if (!gbl_cur_main_window_ || !data_set)
return;
plugin_if_frame_data_cb extract_cb;
void* user_data;
void** ret_value_ptr;
if (g_hash_table_lookup_extended(data_set, "extract_cb", NULL, (void**)&extract_cb) &&
g_hash_table_lookup_extended(data_set, "user_data", NULL, (void**)&user_data) &&
g_hash_table_lookup_extended(data_set, "ret_value_ptr", NULL, (void**)&ret_value_ptr))
{
QList<int> rows = gbl_cur_main_window_->selectedRows();
if (rows.count() > 0) {
frame_data* fdata = gbl_cur_main_window_->frameDataForRow(rows.at(0));
if (fdata) {
*ret_value_ptr = extract_cb(fdata, user_data);
}
}
}
}
static void plugin_if_mainwindow_get_capture_file(GHashTable* data_set)
{
if (!gbl_cur_main_window_ || !data_set)
return;
plugin_if_capture_file_cb extract_cb;
void* user_data;
void** ret_value_ptr;
if (g_hash_table_lookup_extended(data_set, "extract_cb", NULL, (void**)&extract_cb) &&
g_hash_table_lookup_extended(data_set, "user_data", NULL, (void**)&user_data) &&
g_hash_table_lookup_extended(data_set, "ret_value_ptr", NULL, (void**)&ret_value_ptr))
{
CaptureFile* cfWrap = gbl_cur_main_window_->captureFile();
capture_file* cf = cfWrap->capFile();
if (cf) {
*ret_value_ptr = extract_cb(cf, user_data);
}
}
}
static void plugin_if_mainwindow_update_toolbars(GHashTable * data_set)
{
if (!gbl_cur_main_window_ || !data_set)
return;
if (g_hash_table_lookup_extended(data_set, "toolbar_name", NULL, NULL)) {
QString toolbarName((const char *)g_hash_table_lookup(data_set, "toolbar_name"));
gbl_cur_main_window_->removeAdditionalToolbar(toolbarName);
}
}
static void mainwindow_add_toolbar(const iface_toolbar *toolbar_entry)
{
if (gbl_cur_main_window_ && toolbar_entry)
{
gbl_cur_main_window_->addInterfaceToolbar(toolbar_entry);
}
}
static void mainwindow_remove_toolbar(const gchar *menu_title)
{
if (gbl_cur_main_window_ && menu_title)
{
gbl_cur_main_window_->removeInterfaceToolbar(menu_title);
}
}
QMenu* LograyMainWindow::findOrAddMenu(QMenu *parent_menu, QString& menu_text) {
QList<QAction *> actions = parent_menu->actions();
QList<QAction *>::const_iterator i;
for (i = actions.constBegin(); i != actions.constEnd(); ++i) {
if ((*i)->text()==menu_text) {
return (*i)->menu();
}
}
// If we get here there menu entry was not found, add a sub menu
return parent_menu->addMenu(menu_text);
}
LograyMainWindow::LograyMainWindow(QWidget *parent) :
MainWindow(parent),
main_ui_(new Ui::LograyMainWindow),
previous_focus_(NULL),
file_set_dialog_(NULL),
show_hide_actions_(NULL),
time_display_actions_(NULL),
time_precision_actions_(NULL),
funnel_statistics_(NULL),
freeze_focus_(NULL),
was_maximized_(false),
capture_stopping_(false),
capture_filter_valid_(false)
#ifdef HAVE_LIBPCAP
, capture_options_dialog_(NULL)
, info_data_()
#endif
#if defined(Q_OS_MAC)
, dock_menu_(NULL)
#endif
{
if (!gbl_cur_main_window_) {
connect(mainApp, SIGNAL(openStatCommandDialog(QString, const char*, void*)),
this, SLOT(openStatCommandDialog(QString, const char*, void*)));
connect(mainApp, SIGNAL(openTapParameterDialog(QString, const QString, void*)),
this, SLOT(openTapParameterDialog(QString, const QString, void*)));
}
gbl_cur_main_window_ = this;
#ifdef HAVE_LIBPCAP
capture_input_init(&cap_session_, CaptureFile::globalCapFile());
#endif
findTextCodecs();
// setpUi calls QMetaObject::connectSlotsByName(this). connectSlotsByName
// iterates over *all* of our children, looking for matching "on_" slots.
// The fewer children we have at this point the better.
main_ui_->setupUi(this);
#ifdef HAVE_SOFTWARE_UPDATE
update_action_ = new QAction(tr("Check for Updates…"), main_ui_->menuHelp);
#endif
menu_groups_ = QList<register_stat_group_t>()
<< REGISTER_LOG_ANALYZE_GROUP_UNSORTED
<< REGISTER_LOG_STAT_GROUP_UNSORTED;
setWindowIcon(mainApp->normalIcon());
setTitlebarForCaptureFile();
setMenusForCaptureFile();
setForCapturedPackets(false);
setMenusForFileSet(false);
interfaceSelectionChanged();
loadWindowGeometry();
#ifndef HAVE_LUA
main_ui_->actionAnalyzeReloadLuaPlugins->setVisible(false);
#endif
qRegisterMetaType<FilterAction::Action>("FilterAction::Action");
qRegisterMetaType<FilterAction::ActionType>("FilterAction::ActionType");
connect(this, SIGNAL(filterAction(QString, FilterAction::Action, FilterAction::ActionType)),
this, SLOT(queuedFilterAction(QString, FilterAction::Action, FilterAction::ActionType)),
Qt::QueuedConnection);
//To prevent users use features before initialization complete
//Otherwise unexpected problems may occur
setFeaturesEnabled(false);
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(setFeaturesEnabled()));
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(applyGlobalCommandLineOptions()));
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(zoomText()));
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(initViewColorizeMenu()));
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(addStatsPluginsToMenu()));
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(addDynamicMenus()));
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(addPluginIFStructures()));
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(initConversationMenus()));
connect(mainApp, SIGNAL(appInitialized()), this, SLOT(initExportObjectsMenus()));
connect(mainApp, SIGNAL(profileChanging()), this, SLOT(saveWindowGeometry()));
connect(mainApp, SIGNAL(preferencesChanged()), this, SLOT(layoutPanes()));
connect(mainApp, SIGNAL(preferencesChanged()), this, SLOT(layoutToolbars()));
connect(mainApp, SIGNAL(preferencesChanged()), this, SLOT(updatePreferenceActions()));
connect(mainApp, SIGNAL(preferencesChanged()), this, SLOT(zoomText()));
connect(mainApp, SIGNAL(preferencesChanged()), this, SLOT(setTitlebarForCaptureFile()));
connect(mainApp, SIGNAL(updateRecentCaptureStatus(const QString &, qint64, bool)), this, SLOT(updateRecentCaptures()));
updateRecentCaptures();
#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
connect(mainApp, SIGNAL(softwareUpdateRequested()), this, SLOT(softwareUpdateRequested()),
Qt::BlockingQueuedConnection);
connect(mainApp, SIGNAL(softwareUpdateClose()), this, SLOT(close()),
Qt::BlockingQueuedConnection);
#endif
df_combo_box_ = new DisplayFilterCombo(this);
funnel_statistics_ = new FunnelStatistics(this, capture_file_);
connect(df_combo_box_, &QComboBox::editTextChanged, funnel_statistics_, &FunnelStatistics::displayFilterTextChanged);
connect(funnel_statistics_, &FunnelStatistics::setDisplayFilter, this, &LograyMainWindow::setDisplayFilter);
connect(funnel_statistics_, SIGNAL(openCaptureFile(QString, QString)),
this, SLOT(openCaptureFile(QString, QString)));
file_set_dialog_ = new FileSetDialog(this);
connect(file_set_dialog_, SIGNAL(fileSetOpenCaptureFile(QString)),
this, SLOT(openCaptureFile(QString)));
initMainToolbarIcons();
main_ui_->displayFilterToolBar->insertWidget(main_ui_->actionNewDisplayFilterExpression, df_combo_box_);
// Make sure filter expressions overflow into a menu instead of a
// larger toolbar. We do this by adding them to a child toolbar.
// https://bugreports.qt.io/browse/QTBUG-2472
FilterExpressionToolBar *filter_expression_toolbar_ = new FilterExpressionToolBar(this);
connect(filter_expression_toolbar_, &FilterExpressionToolBar::filterPreferences, this, &LograyMainWindow::onFilterPreferences);
connect(filter_expression_toolbar_, &FilterExpressionToolBar::filterSelected, this, &LograyMainWindow::onFilterSelected);
connect(filter_expression_toolbar_, &FilterExpressionToolBar::filterEdit, this, &LograyMainWindow::onFilterEdit);
main_ui_->displayFilterToolBar->addWidget(filter_expression_toolbar_);
main_ui_->goToFrame->hide();
connect(main_ui_->goToFrame, SIGNAL(visibilityChanged(bool)),
main_ui_->actionGoGoToPacket, SLOT(setChecked(bool)));
// XXX For some reason the cursor is drawn funny with an input mask set
// https://bugreports.qt-project.org/browse/QTBUG-7174
main_ui_->searchFrame->hide();
connect(main_ui_->searchFrame, SIGNAL(visibilityChanged(bool)),
main_ui_->actionEditFindPacket, SLOT(setChecked(bool)));
main_ui_->addressEditorFrame->hide();
main_ui_->columnEditorFrame->hide();
main_ui_->preferenceEditorFrame->hide();
main_ui_->filterExpressionFrame->hide();
#ifndef HAVE_LIBPCAP
main_ui_->menuCapture->setEnabled(false);
#endif
// Set OS specific shortcuts for fullscreen mode
#if defined(Q_OS_MAC)
main_ui_->actionViewFullScreen->setShortcut(QKeySequence::FullScreen);
#else
main_ui_->actionViewFullScreen->setShortcut(QKeySequence(Qt::Key_F11));
#endif
#if defined(Q_OS_MAC)
main_ui_->goToPacketLabel->setAttribute(Qt::WA_MacSmallSize, true);
main_ui_->goToLineEdit->setAttribute(Qt::WA_MacSmallSize, true);
main_ui_->goToGo->setAttribute(Qt::WA_MacSmallSize, true);
main_ui_->goToCancel->setAttribute(Qt::WA_MacSmallSize, true);
connect(main_ui_->goToGo, &QPushButton::pressed, this, &LograyMainWindow::goToGoClicked);
connect(main_ui_->goToCancel, &QPushButton::pressed, this, &LograyMainWindow::goToCancelClicked);
main_ui_->actionEditPreferences->setMenuRole(QAction::PreferencesRole);
#endif // Q_OS_MAC
// A billion-1 is equivalent to the inputMask 900000000 previously used
// Avoid QValidator::Intermediate values by using a top value of all 9's
#define MAX_GOTO_LINE 999999999
QIntValidator *goToLineQiv = new QIntValidator(0,MAX_GOTO_LINE,this);
main_ui_->goToLineEdit->setValidator(goToLineQiv);
#ifdef HAVE_SOFTWARE_UPDATE
QAction *update_sep = main_ui_->menuHelp->insertSeparator(main_ui_->actionHelpAbout);
main_ui_->menuHelp->insertAction(update_sep, update_action_);
connect(update_action_, SIGNAL(triggered()), this, SLOT(checkForUpdates()));
#endif
master_split_.setObjectName("splitterMaster");
extra_split_.setObjectName("splitterExtra");
master_split_.setChildrenCollapsible(false);
extra_split_.setChildrenCollapsible(false);
main_ui_->mainStack->addWidget(&master_split_);
empty_pane_.setObjectName("emptyPane");
empty_pane_.setVisible(false);
packet_list_ = new PacketList(&master_split_);
connect(packet_list_, SIGNAL(framesSelected(QList<int>)), this, SLOT(setMenusForSelectedPacket()));
connect(packet_list_, SIGNAL(framesSelected(QList<int>)), this, SIGNAL(framesSelected(QList<int>)));
QAction *action = main_ui_->menuPacketComment->addAction(tr("Add New Comment…"));
connect(action, &QAction::triggered, this, &LograyMainWindow::addPacketComment);
action->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_C));
connect(main_ui_->menuPacketComment, SIGNAL(aboutToShow()), this, SLOT(setEditCommentsMenu()));
proto_tree_ = new ProtoTree(&master_split_);
proto_tree_->installEventFilter(this);
packet_list_->setProtoTree(proto_tree_);
packet_list_->installEventFilter(this);
packet_diagram_ = new PacketDiagram(&master_split_);
main_stack_ = main_ui_->mainStack;
welcome_page_ = main_ui_->welcomePage;
main_status_bar_ = main_ui_->statusBar;
connect(proto_tree_, &ProtoTree::fieldSelected,
this, &LograyMainWindow::fieldSelected);
connect(packet_list_, &PacketList::fieldSelected,
this, &LograyMainWindow::fieldSelected);
connect(this, &LograyMainWindow::fieldSelected,
this, &LograyMainWindow::setMenusForSelectedTreeRow);
connect(this, &LograyMainWindow::fieldSelected,
main_ui_->statusBar, &MainStatusBar::selectedFieldChanged);
connect(this, &LograyMainWindow::fieldHighlight,
main_ui_->statusBar, &MainStatusBar::highlightedFieldChanged);
connect(mainApp, &WiresharkApplication::captureActive,
this, &LograyMainWindow::captureActive);
byte_view_tab_ = new ByteViewTab(&master_split_);
// Packet list and proto tree must exist before these are called.
setMenusForSelectedPacket();
setMenusForSelectedTreeRow();
initShowHideMainWidgets();
initTimeDisplayFormatMenu();
initTimePrecisionFormatMenu();
initFreezeActions();
updatePreferenceActions();
updateRecentActions();
setForCaptureInProgress(false);
setTabOrder(df_combo_box_->lineEdit(), packet_list_);
setTabOrder(packet_list_, proto_tree_);
connect(&capture_file_, SIGNAL(captureEvent(CaptureEvent)),
this, SLOT(captureEventHandler(CaptureEvent)));
connect(&capture_file_, SIGNAL(captureEvent(CaptureEvent)),
mainApp, SLOT(captureEventHandler(CaptureEvent)));
connect(&capture_file_, SIGNAL(captureEvent(CaptureEvent)),
main_ui_->statusBar, SLOT(captureEventHandler(CaptureEvent)));
connect(mainApp, SIGNAL(freezePacketList(bool)),
packet_list_, SLOT(freezePacketList(bool)));
connect(mainApp, SIGNAL(columnsChanged()),
packet_list_, SLOT(columnsChanged()));
connect(mainApp, SIGNAL(preferencesChanged()),
packet_list_, SLOT(preferencesChanged()));
connect(mainApp, SIGNAL(recentPreferencesRead()),
this, SLOT(applyRecentPaneGeometry()));
connect(mainApp, SIGNAL(recentPreferencesRead()),
this, SLOT(updateRecentActions()));
connect(mainApp, SIGNAL(packetDissectionChanged()),
this, SLOT(redissectPackets()), Qt::QueuedConnection);
connect(mainApp, SIGNAL(checkDisplayFilter()),
this, SLOT(checkDisplayFilter()));
connect(mainApp, SIGNAL(fieldsChanged()),
this, SLOT(fieldsChanged()));
connect(mainApp, SIGNAL(reloadLuaPlugins()),
this, SLOT(reloadLuaPlugins()));
connect(main_ui_->mainStack, SIGNAL(currentChanged(int)),
this, SLOT(mainStackChanged(int)));
connect(welcome_page_, SIGNAL(startCapture(QStringList)),
this, SLOT(startCapture(QStringList)));
connect(welcome_page_, SIGNAL(recentFileActivated(QString)),
this, SLOT(openCaptureFile(QString)));
connect(main_ui_->addressEditorFrame, &AddressEditorFrame::redissectPackets,
this, &LograyMainWindow::redissectPackets);
connect(main_ui_->addressEditorFrame, &AddressEditorFrame::showNameResolutionPreferences,
this, &LograyMainWindow::showPreferencesDialog);
connect(main_ui_->preferenceEditorFrame, &PreferenceEditorFrame::showProtocolPreferences,
this, &LograyMainWindow::showPreferencesDialog);
connect(main_ui_->filterExpressionFrame, &FilterExpressionFrame::showPreferencesDialog,
this, &LograyMainWindow::showPreferencesDialog);
connect(main_ui_->filterExpressionFrame, &FilterExpressionFrame::filterExpressionsChanged,
filter_expression_toolbar_, &FilterExpressionToolBar::filterExpressionsChanged);
/* Connect change of capture file */
connect(this, &LograyMainWindow::setCaptureFile,
main_ui_->searchFrame, &SearchFrame::setCaptureFile);
connect(this, &LograyMainWindow::setCaptureFile,
main_ui_->statusBar, &MainStatusBar::setCaptureFile);
connect(this, &LograyMainWindow::setCaptureFile,
packet_list_, &PacketList::setCaptureFile);
connect(this, &LograyMainWindow::setCaptureFile,
proto_tree_, &ProtoTree::setCaptureFile);
connect(mainApp, SIGNAL(zoomMonospaceFont(QFont)),
packet_list_, SLOT(setMonospaceFont(QFont)));
connect(mainApp, SIGNAL(zoomMonospaceFont(QFont)),
proto_tree_, SLOT(setMonospaceFont(QFont)));
connectFileMenuActions();
connectEditMenuActions();
connectViewMenuActions();
connectGoMenuActions();
connectCaptureMenuActions();
connectAnalyzeMenuActions();
connectStatisticsMenuActions();
connectHelpMenuActions();
connect(packet_list_, SIGNAL(packetDissectionChanged()),
this, SLOT(redissectPackets()));
connect(packet_list_, SIGNAL(showColumnPreferences(QString)),
this, SLOT(showPreferencesDialog(QString)));
connect(packet_list_, SIGNAL(showProtocolPreferences(QString)),
this, SLOT(showPreferencesDialog(QString)));
connect(packet_list_, SIGNAL(editProtocolPreference(preference*, pref_module*)),
main_ui_->preferenceEditorFrame, SLOT(editPreference(preference*, pref_module*)));
connect(packet_list_, SIGNAL(editColumn(int)), this, SLOT(showColumnEditor(int)));
connect(main_ui_->columnEditorFrame, SIGNAL(columnEdited()),
packet_list_, SLOT(columnsChanged()));
connect(packet_list_, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(openPacketDialog()));
connect(packet_list_, SIGNAL(packetListScrolled(bool)),
main_ui_->actionGoAutoScroll, SLOT(setChecked(bool)));
connect(proto_tree_, SIGNAL(openPacketInNewWindow(bool)),
this, SLOT(openPacketDialog(bool)));
connect(proto_tree_, SIGNAL(showProtocolPreferences(QString)),
this, SLOT(showPreferencesDialog(QString)));
connect(proto_tree_, SIGNAL(editProtocolPreference(preference*, pref_module*)),
main_ui_->preferenceEditorFrame, SLOT(editPreference(preference*, pref_module*)));
connect(main_ui_->statusBar, &MainStatusBar::showExpertInfo, this, [=]() {
statCommandExpertInfo(NULL, NULL);
});
connect(main_ui_->statusBar, &MainStatusBar::stopLoading,
&capture_file_, &CaptureFile::stopLoading);
connect(main_ui_->statusBar, &MainStatusBar::editCaptureComment,
main_ui_->actionStatisticsCaptureFileProperties, &QAction::trigger);
connect(main_ui_->menuApplyAsFilter, &QMenu::aboutToShow,
this, &LograyMainWindow::filterMenuAboutToShow);
connect(main_ui_->menuPrepareAFilter, &QMenu::aboutToShow,
this, &LograyMainWindow::filterMenuAboutToShow);
#ifdef HAVE_LIBPCAP
QTreeWidget *iface_tree = findChild<QTreeWidget *>("interfaceTree");
if (iface_tree) {
connect(iface_tree, SIGNAL(itemSelectionChanged()),
this, SLOT(interfaceSelectionChanged()));
}
connect(main_ui_->welcomePage, SIGNAL(captureFilterSyntaxChanged(bool)),
this, SLOT(captureFilterSyntaxChanged(bool)));
connect(this, SIGNAL(showExtcapOptions(QString&, bool)),
this, SLOT(showExtcapOptionsDialog(QString&, bool)));
connect(this->welcome_page_, SIGNAL(showExtcapOptions(QString&, bool)),
this, SLOT(showExtcapOptionsDialog(QString&, bool)));
#endif // HAVE_LIBPCAP
/* Create plugin_if hooks */
plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_APPLY, plugin_if_mainwindow_apply_filter);
plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_PREPARE, plugin_if_mainwindow_apply_filter);
plugin_if_register_gui_cb(PLUGIN_IF_PREFERENCE_SAVE, plugin_if_mainwindow_preference);
plugin_if_register_gui_cb(PLUGIN_IF_GOTO_FRAME, plugin_if_mainwindow_gotoframe);
#ifdef HAVE_LIBPCAP
plugin_if_register_gui_cb(PLUGIN_IF_GET_WS_INFO, plugin_if_mainwindow_get_ws_info);
#endif
plugin_if_register_gui_cb(PLUGIN_IF_GET_FRAME_DATA, plugin_if_mainwindow_get_frame_data);
plugin_if_register_gui_cb(PLUGIN_IF_GET_CAPTURE_FILE, plugin_if_mainwindow_get_capture_file);
plugin_if_register_gui_cb(PLUGIN_IF_REMOVE_TOOLBAR, plugin_if_mainwindow_update_toolbars);
/* Register Interface Toolbar callbacks */
iface_toolbar_register_cb(mainwindow_add_toolbar, mainwindow_remove_toolbar);
/* Show tooltips on menu items that go to websites */
main_ui_->actionHelpMPWireshark->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_WIRESHARK)));
main_ui_->actionHelpMPWireshark_Filter->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_WIRESHARK_FILTER)));
main_ui_->actionHelpMPCapinfos->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_CAPINFOS)));
main_ui_->actionHelpMPDumpcap->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_DUMPCAP)));
main_ui_->actionHelpMPEditcap->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_EDITCAP)));
main_ui_->actionHelpMPMergecap->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_MERGECAP)));
main_ui_->actionHelpMPRawshark->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_RAWSHARK)));
main_ui_->actionHelpMPReordercap->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_REORDERCAP)));
main_ui_->actionHelpMPText2pcap->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_TEXT2PCAP)));
main_ui_->actionHelpMPTShark->setToolTip(gchar_free_to_qstring(topic_action_url(LOCALPAGE_MAN_TSHARK)));
main_ui_->actionHelpContents->setToolTip(gchar_free_to_qstring(topic_action_url(ONLINEPAGE_USERGUIDE)));
main_ui_->actionHelpWebsite->setToolTip(gchar_free_to_qstring(topic_action_url(ONLINEPAGE_HOME)));
main_ui_->actionHelpFAQ->setToolTip(gchar_free_to_qstring(topic_action_url(ONLINEPAGE_FAQ)));
main_ui_->actionHelpAsk->setToolTip(gchar_free_to_qstring(topic_action_url(ONLINEPAGE_ASK)));
main_ui_->actionHelpDownloads->setToolTip(gchar_free_to_qstring(topic_action_url(ONLINEPAGE_DOWNLOAD)));
main_ui_->actionHelpWiki->setToolTip(gchar_free_to_qstring(topic_action_url(ONLINEPAGE_WIKI)));
main_ui_->actionHelpSampleCaptures->setToolTip(gchar_free_to_qstring(topic_action_url(ONLINEPAGE_SAMPLE_CAPTURES)));
showWelcome();
}
LograyMainWindow::~LograyMainWindow()
{
disconnect(main_ui_->mainStack, 0, 0, 0);
#ifndef Q_OS_MAC
// Below dialogs inherit GeometryStateDialog
// For reasons described in geometry_state_dialog.h no parent is set when
// instantiating the dialogs and as a resul objects are not automatically
// freed by its parent. Free then here explicitly to avoid leak and numerous
// Valgrind complaints.
delete file_set_dialog_;
#ifdef HAVE_LIBPCAP
delete capture_options_dialog_;
#endif
#endif
delete main_ui_;
}
QMenu *LograyMainWindow::createPopupMenu()
{
QMenu *menu = new QMenu();
menu->addAction(main_ui_->actionViewMainToolbar);
menu->addAction(main_ui_->actionViewFilterToolbar);
if (!main_ui_->menuInterfaceToolbars->actions().isEmpty()) {
QMenu *submenu = menu->addMenu(main_ui_->menuInterfaceToolbars->title());
foreach(QAction *action, main_ui_->menuInterfaceToolbars->actions()) {
submenu->addAction(action);
}
}
if (!main_ui_->menuAdditionalToolbars->actions().isEmpty()) {
QMenu *subMenu = menu->addMenu(main_ui_->menuAdditionalToolbars->title());
foreach(QAction *action, main_ui_->menuAdditionalToolbars->actions()) {
subMenu->addAction(action);
}
}
menu->addAction(main_ui_->actionViewStatusBar);
menu->addSeparator();
menu->addAction(main_ui_->actionViewPacketList);
menu->addAction(main_ui_->actionViewPacketDetails);
menu->addAction(main_ui_->actionViewPacketBytes);
menu->addAction(main_ui_->actionViewPacketDiagram);
return menu;
}
void LograyMainWindow::addInterfaceToolbar(const iface_toolbar *toolbar_entry)
{
QMenu *menu = main_ui_->menuInterfaceToolbars;
bool visible = g_list_find_custom(recent.interface_toolbars, toolbar_entry->menu_title, (GCompareFunc)strcmp) ? true : false;
QString title = QString().fromUtf8(toolbar_entry->menu_title);
QAction *action = new QAction(title, menu);
action->setEnabled(true);
action->setCheckable(true);
action->setChecked(visible);
action->setToolTip(tr("Show or hide the toolbar"));
QAction *before = NULL;
foreach(QAction *action, menu->actions()) {
// Ensure we add the menu entries in sorted order
if (action->text().compare(title, Qt::CaseInsensitive) > 0) {
before = action;
break;
}
}
menu->insertAction(before, action);
InterfaceToolbar *interface_toolbar = new InterfaceToolbar(this, toolbar_entry);
connect(mainApp, SIGNAL(appInitialized()), interface_toolbar, SLOT(interfaceListChanged()));
connect(mainApp, SIGNAL(localInterfaceListChanged()), interface_toolbar, SLOT(interfaceListChanged()));
QToolBar *toolbar = new QToolBar(this);
toolbar->addWidget(interface_toolbar);
toolbar->setMovable(false);
toolbar->setVisible(visible);
action->setData(QVariant::fromValue(toolbar));
addToolBar(Qt::TopToolBarArea, toolbar);
insertToolBarBreak(toolbar);
if (show_hide_actions_) {
show_hide_actions_->addAction(action);
}
menu->menuAction()->setVisible(true);
}
void LograyMainWindow::removeInterfaceToolbar(const gchar *menu_title)
{
QMenu *menu = main_ui_->menuInterfaceToolbars;
QAction *action = NULL;
QMap<QAction *, QWidget *>::iterator i;
QString title = QString().fromUtf8(menu_title);
foreach(action, menu->actions()) {
if (title.compare(action->text()) == 0) {
break;
}
}
if (action) {
if (show_hide_actions_) {
show_hide_actions_->removeAction(action);
}
menu->removeAction(action);
QToolBar *toolbar = action->data().value<QToolBar *>();
removeToolBar(toolbar);
delete action;
delete toolbar;
}
menu->menuAction()->setVisible(!menu->actions().isEmpty());
}
bool LograyMainWindow::eventFilter(QObject *obj, QEvent *event) {
// The user typed some text. Start filling in a filter.
// We may need to be more choosy here. We just need to catch events for the packet list,
// proto tree, and main welcome widgets.
if (event->type() == QEvent::KeyPress) {
QKeyEvent *kevt = static_cast<QKeyEvent *>(event);
if (kevt->text().length() > 0 && kevt->text()[0].isPrint() &&
!(kevt->modifiers() & Qt::ControlModifier)) {
df_combo_box_->lineEdit()->insert(kevt->text());
df_combo_box_->lineEdit()->setFocus();
return true;
}
}
return QMainWindow::eventFilter(obj, event);
}
bool LograyMainWindow::event(QEvent *event)
{
switch (event->type()) {
case QEvent::ApplicationPaletteChange:
initMainToolbarIcons();
break;
default:
break;
}
return QMainWindow::event(event);
}
void LograyMainWindow::keyPressEvent(QKeyEvent *event) {
// Explicitly focus on the display filter combo.
if (event->modifiers() & Qt::ControlModifier && event->key() == Qt::Key_Slash) {
df_combo_box_->setFocus(Qt::ShortcutFocusReason);
return;
}
if (mainApp->focusWidget() == main_ui_->goToLineEdit) {
if (event->modifiers() == Qt::NoModifier) {
if (event->key() == Qt::Key_Escape) {
goToCancelClicked();
} else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
goToGoClicked();
}
}
return; // goToLineEdit didn't want it and we don't either.
}
// Move up & down the packet list.
if (event->key() == Qt::Key_F7) {
packet_list_->goPreviousPacket();
} else if (event->key() == Qt::Key_F8) {
packet_list_->goNextPacket();
}
// Move along, citizen.
QMainWindow::keyPressEvent(event);
}
void LograyMainWindow::closeEvent(QCloseEvent *event) {
saveWindowGeometry();
/* If we're in the middle of stopping a capture, don't do anything;
the user can try deleting the window after the capture stops. */
if (capture_stopping_) {
event->ignore();
return;
}
QString before_what(tr(" before quitting"));
if (!testCaptureFileClose(before_what, Quit)) {
event->ignore();
return;
}
#ifdef HAVE_LIBPCAP
if (capture_options_dialog_) capture_options_dialog_->close();
#endif
// Make sure we kill any open dumpcap processes.
delete welcome_page_;
// One of the many places we assume one main window.
if (!mainApp->isInitialized()) {
// If we're still initializing, QCoreApplication::quit() won't
// exit properly because we are not in the event loop. This
// means that the application won't clean up after itself. We
// might want to call mainApp->processEvents() during startup
// instead so that we can do a normal exit here.
exit(0);
}
mainApp->quit();
// When the main loop is not yet running (i.e. when openCaptureFile is
// executing in main.cpp), the above quit action has no effect.
// Schedule a quit action for the next execution of the main loop.
QMetaObject::invokeMethod(mainApp, "quit", Qt::QueuedConnection);
}
// XXX On windows the drag description is "Copy". It should be "Open" or
// "Merge" as appropriate. It looks like we need access to IDataObject in
// order to set DROPDESCRIPTION.
void LograyMainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (!event->mimeData()->hasUrls())
{
event->ignore();
return;
}
if (!main_ui_->actionFileOpen->isEnabled()) {
// We could alternatively call setAcceptDrops(!capture_in_progress)
// in setMenusForCaptureInProgress but that wouldn't provide feedback.
mainApp->pushStatus(WiresharkApplication::TemporaryStatus, tr("Unable to drop files during capture."));
event->setDropAction(Qt::IgnoreAction);
event->ignore();
return;
}
bool have_files = false;
foreach(QUrl drag_url, event->mimeData()->urls()) {
if (!drag_url.toLocalFile().isEmpty()) {
have_files = true;
break;
}
}
if (have_files) {
event->acceptProposedAction();
}
}
void LograyMainWindow::dropEvent(QDropEvent *event)
{
if (!event->mimeData()->hasUrls())
{
event->ignore();
return;
}
QList<QByteArray> local_files;
int max_dropped_files = 100; // Arbitrary
foreach(QUrl drop_url, event->mimeData()->urls()) {
QString drop_file = drop_url.toLocalFile();
if (!drop_file.isEmpty()) {
local_files << drop_file.toUtf8();
if (local_files.size() >= max_dropped_files) {
break;
}
}
}
event->acceptProposedAction();
if (local_files.size() < 1) {
event->ignore();
return;
}
event->accept();
if (local_files.size() == 1) {
openCaptureFile(local_files.at(0));
return;
}
const char **in_filenames = g_new(const char *, local_files.size());
char *tmpname = NULL;
for (int i = 0; i < local_files.size(); i++) {
in_filenames[i] = local_files.at(i).constData();
}
/* merge the files in chronological order */
if (cf_merge_files_to_tempfile(this, global_capture_opts.temp_dir, &tmpname, static_cast<int>(local_files.size()),
in_filenames,
wtap_pcapng_file_type_subtype(),
FALSE) == CF_OK) {
/* Merge succeeded; close the currently-open file and try
to open the merged capture file. */
openCaptureFile(tmpname, QString(), WTAP_TYPE_AUTO, TRUE);
}
g_free(tmpname);
g_free(in_filenames);
}
// Apply recent settings to the main window geometry.
// We haven't loaded the preferences at this point so we assume that the
// position and size preference are enabled.
// Note we might end up with unexpected screen geometries if the user
// unplugs or plugs in a monitor:
// https://bugreports.qt.io/browse/QTBUG-44213
void LograyMainWindow::loadWindowGeometry()
{
int min_sensible_dimension = 200;
#ifndef Q_OS_MAC
if (recent.gui_geometry_main_maximized) {
setWindowState(Qt::WindowMaximized);
} else
#endif
{
QRect recent_geom(recent.gui_geometry_main_x, recent.gui_geometry_main_y,
recent.gui_geometry_main_width, recent.gui_geometry_main_height);
if (!rect_on_screen(recent_geom)) {
// We're not visible on any screens. See if we can move onscreen
// without resizing.
recent_geom.moveTo(50, 50); // recent.c defaults to 20.
}
if (!rect_on_screen(recent_geom)) {
// Give up and use the default geometry.
return;
}
// if (prefs.gui_geometry_save_position) {
move(recent_geom.topLeft());
// }
if (// prefs.gui_geometry_save_size &&
recent_geom.width() > min_sensible_dimension &&
recent_geom.height() > min_sensible_dimension) {
resize(recent_geom.size());
}
}
}
void LograyMainWindow::saveWindowGeometry()
{
if (prefs.gui_geometry_save_position) {
recent.gui_geometry_main_x = pos().x();
recent.gui_geometry_main_y = pos().y();
}
if (prefs.gui_geometry_save_size) {
recent.gui_geometry_main_width = size().width();
recent.gui_geometry_main_height = size().height();
}
if (prefs.gui_geometry_save_maximized) {
// On macOS this is false when it shouldn't be
recent.gui_geometry_main_maximized = isMaximized();
}
if (master_split_.sizes().length() > 0) {
recent.gui_geometry_main_upper_pane = master_split_.sizes()[0];
}
if (master_split_.sizes().length() > 2) {
recent.gui_geometry_main_lower_pane = master_split_.sizes()[1];
} else if (extra_split_.sizes().length() > 0) {
recent.gui_geometry_main_lower_pane = extra_split_.sizes()[0];
}
}
// Our event loop becomes nested whenever we call update_progress_dlg, which
// includes several places in file.c. The GTK+ UI stays out of trouble by
// showing a modal progress dialog. We attempt to do the equivalent below by
// disabling parts of the main window. At a minumum the ProgressFrame in the
// main status bar must remain accessible.
//
// We might want to do this any time the main status bar progress frame is
// shown and hidden.
void LograyMainWindow::freeze()
{
freeze_focus_ = mainApp->focusWidget();
// XXX Alternatively we could just disable and enable the main menu.
for (int i = 0; i < freeze_actions_.size(); i++) {
QAction *action = freeze_actions_[i].first;
freeze_actions_[i].second = action->isEnabled();
action->setEnabled(false);
}
main_ui_->centralWidget->setEnabled(false);
}
void LograyMainWindow::thaw()
{
main_ui_->centralWidget->setEnabled(true);
for (int i = 0; i < freeze_actions_.size(); i++) {
freeze_actions_[i].first->setEnabled(freeze_actions_[i].second);
}
if (freeze_focus_) freeze_focus_->setFocus();
freeze_focus_ = NULL;
}
void LograyMainWindow::mergeCaptureFile()
{
QString file_name = "";
QString read_filter = "";
dfilter_t *rfcode = NULL;
int err;
if (!capture_file_.capFile())
return;
if (prefs.gui_ask_unsaved) {
if (cf_has_unsaved_data(capture_file_.capFile())) {
QMessageBox msg_dialog;
gchar *display_basename;
int response;
msg_dialog.setIcon(QMessageBox::Question);
/* This file has unsaved data; ask the user whether to save
the capture. */
if (capture_file_.capFile()->is_tempfile) {
msg_dialog.setText(tr("Save packets before merging?"));
msg_dialog.setInformativeText(tr("A temporary capture file can't be merged."));
} else {
/*
* Format the message.
*/
display_basename = g_filename_display_basename(capture_file_.capFile()->filename);
msg_dialog.setText(QString(tr("Save changes in \"%1\" before merging?")).arg(display_basename));
g_free(display_basename);
msg_dialog.setInformativeText(tr("Changes must be saved before the files can be merged."));
}
msg_dialog.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
msg_dialog.setDefaultButton(QMessageBox::Save);
response = msg_dialog.exec();
switch (response) {
case QMessageBox::Save:
/* Save the file but don't close it */
saveCaptureFile(capture_file_.capFile(), false);
break;
case QMessageBox::Cancel:
default:
/* Don't do the merge. */
return;
}
}
}
for (;;) {
CaptureFileDialog merge_dlg(this, capture_file_.capFile());
int file_type;
cf_status_t merge_status;
char *in_filenames[2];
char *tmpname;
if (merge_dlg.merge(file_name, read_filter)) {
df_error_t *df_err = NULL;
if (!dfilter_compile(qUtf8Printable(read_filter), &rfcode, &df_err)) {
/* Not valid. Tell the user, and go back and run the file
selection box again once they dismiss the alert. */
// Similar to commandline_info.jfilter section in main().
QMessageBox::warning(this, tr("Invalid Read Filter"),
QString(tr("The filter expression %1 isn't a valid read filter. (%2).").arg(read_filter, df_err->msg)),
QMessageBox::Ok);
df_error_free(&df_err);
continue;
}
} else {
return;
}
file_type = capture_file_.capFile()->cd_t;
/* Try to merge or append the two files */
if (merge_dlg.mergeType() == 0) {
/* chronological order */
in_filenames[0] = g_strdup(capture_file_.capFile()->filename);
in_filenames[1] = qstring_strdup(file_name);
merge_status = cf_merge_files_to_tempfile(this, global_capture_opts.temp_dir, &tmpname, 2, in_filenames, file_type, FALSE);
} else if (merge_dlg.mergeType() <= 0) {
/* prepend file */
in_filenames[0] = qstring_strdup(file_name);
in_filenames[1] = g_strdup(capture_file_.capFile()->filename);
merge_status = cf_merge_files_to_tempfile(this, global_capture_opts.temp_dir, &tmpname, 2, in_filenames, file_type, TRUE);
} else {
/* append file */
in_filenames[0] = g_strdup(capture_file_.capFile()->filename);
in_filenames[1] = qstring_strdup(file_name);
merge_status = cf_merge_files_to_tempfile(this, global_capture_opts.temp_dir, &tmpname, 2, in_filenames, file_type, TRUE);
}
g_free(in_filenames[0]);
g_free(in_filenames[1]);
if (merge_status != CF_OK) {
dfilter_free(rfcode);
g_free(tmpname);
continue;
}
cf_close(capture_file_.capFile());
/* Try to open the merged capture file. */
CaptureFile::globalCapFile()->window = this;
if (cf_open(CaptureFile::globalCapFile(), tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) != CF_OK) {
/* We couldn't open it; fail. */
CaptureFile::globalCapFile()->window = NULL;
dfilter_free(rfcode);
g_free(tmpname);
return;
}
/* Attach the new read filter to "cf" ("cf_open()" succeeded, so
it closed the previous capture file, and thus destroyed any
previous read filter attached to "cf"). */
cf_set_rfcode(CaptureFile::globalCapFile(), rfcode);
switch (cf_read(CaptureFile::globalCapFile(), /*reloading=*/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:
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return (without changing the last containing
directory). */
g_free(tmpname);
return;
}
/* Save the name of the containing directory specified in the path name. */
mainApp->setLastOpenDirFromFilename(tmpname);
g_free(tmpname);
main_ui_->statusBar->showExpert();
return;
}
}
void LograyMainWindow::importCaptureFile() {
ImportTextDialog import_dlg;
QString before_what(tr(" before importing a capture"));
if (!testCaptureFileClose(before_what))
return;
import_dlg.exec();
if (import_dlg.result() != QDialog::Accepted) {
showWelcome();
return;
}
openCaptureFile(import_dlg.capfileName());
}
bool LograyMainWindow::saveCaptureFile(capture_file *cf, bool dont_reopen) {
QString file_name;
gboolean discard_comments;
if (cf->is_tempfile) {
/* This is a temporary capture file, so saving it means saving
it to a permanent file. Prompt the user for a location
to which to save it. Don't require that the file format
support comments - if it's a temporary capture file, it's
probably pcapng, which supports comments and, if it's
not pcapng, let the user decide what they want to do
if they've added comments. */
return saveAsCaptureFile(cf, FALSE, dont_reopen);
} else {
if (cf->unsaved_changes) {
cf_write_status_t status;
/* This is not a temporary capture file, but it has unsaved
changes, so saving it means doing a "safe save" on top
of the existing file, in the same format - no UI needed
unless the file has comments and the file's format doesn't
support them.
If the file has comments, does the file's format support them?
If not, ask the user whether they want to discard the comments
or choose a different format. */
switch (CaptureFileDialog::checkSaveAsWithComments(this, cf, cf->cd_t)) {
case SAVE:
/* The file can be saved in the specified format as is;
just drive on and save in the format they selected. */
discard_comments = FALSE;
break;
case SAVE_WITHOUT_COMMENTS:
/* The file can't be saved in the specified format as is,
but it can be saved without the comments, and the user
said "OK, discard the comments", so save it in the
format they specified without the comments. */
discard_comments = TRUE;
break;
case SAVE_IN_ANOTHER_FORMAT:
/* There are file formats in which we can save this that
support comments, and the user said not to delete the
comments. Do a "Save As" so the user can select
one of those formats and choose a file name. */
return saveAsCaptureFile(cf, TRUE, dont_reopen);
case CANCELLED:
/* The user said "forget it". Just return. */
return false;
default:
/* Squelch warnings that discard_comments is being used
uninitialized. */
ws_assert_not_reached();
return false;
}
/* XXX - cf->filename might get freed out from under us, because
the code path through which cf_save_records() goes currently
closes the current file and then opens and reloads the saved file,
so make a copy and free it later. */
file_name = cf->filename;
status = cf_save_records(cf, qUtf8Printable(file_name), cf->cd_t, cf->compression_type,
discard_comments, dont_reopen);
switch (status) {
case CF_WRITE_OK:
/* The save succeeded; we're done.
If we discarded comments, redraw the packet list to reflect
any packets that no longer have comments. If we had unsaved
changes, redraw the packet list, because saving a time
shift zeroes out the frame.offset_shift field.
If we had a color filter based on frame data, recolor. */
/* XXX: If there is a filter based on those, we want to force
a rescan with the current filter (we don't actually
need to redissect.)
*/
if (discard_comments || cf->unsaved_changes) {
if (color_filters_use_proto(proto_get_id_by_filter_name("frame"))) {
packet_list_->recolorPackets();
} else {
packet_list_->redrawVisiblePackets();
}
}
cf->unsaved_changes = false; //we just saved so we signal that we have no unsaved changes
updateForUnsavedChanges(); // we update the title bar to remove the *
break;
case CF_WRITE_ERROR:
/* The write failed.
XXX - OK, what do we do now? Let them try a
"Save As", in case they want to try to save to a
different directory or file system? */
break;
case CF_WRITE_ABORTED:
/* The write was aborted; just drive on. */
return false;
}
}
/* Otherwise just do nothing. */
}
return true;
}
bool LograyMainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments, bool dont_reopen) {
QString file_name = "";
int file_type;
wtap_compression_type compression_type;
cf_write_status_t status;
gchar *dirname;
gboolean discard_comments = FALSE;
if (!cf) {
return false;
}
for (;;) {
CaptureFileDialog save_as_dlg(this, cf);
/* If the file has comments, does the format the user selected
support them? If not, ask the user whether they want to
discard the comments or choose a different format. */
switch (save_as_dlg.saveAs(file_name, must_support_comments)) {
case SAVE:
/* The file can be saved in the specified format as is;
just drive on and save in the format they selected. */
discard_comments = FALSE;
break;
case SAVE_WITHOUT_COMMENTS:
/* The file can't be saved in the specified format as is,
but it can be saved without the comments, and the user
said "OK, discard the comments", so save it in the
format they specified without the comments. */
discard_comments = TRUE;
break;
case SAVE_IN_ANOTHER_FORMAT:
/* There are file formats in which we can save this that
support comments, and the user said not to delete the
comments. The combo box of file formats has had the
formats that don't support comments trimmed from it,
so run the dialog again, to let the user decide
whether to save in one of those formats or give up. */
must_support_comments = TRUE;
continue;
case CANCELLED:
/* The user said "forget it". Just get rid of the dialog box
and return. */
return false;
}
file_type = save_as_dlg.selectedFileType();
if (file_type == WTAP_FILE_TYPE_SUBTYPE_UNKNOWN) {
/* This "should not happen". */
QMessageBox msg_dialog;
msg_dialog.setIcon(QMessageBox::Critical);
msg_dialog.setText(tr("Unknown file type returned by merge dialog."));
msg_dialog.setInformativeText(tr("Please report this as a Wireshark issue at https://gitlab.com/wireshark/wireshark/-/issues."));
msg_dialog.exec();
return false;
}
compression_type = save_as_dlg.compressionType();
#ifdef Q_OS_WIN
// the Windows dialog does not fixup extensions, do it manually here.
fileAddExtension(file_name, file_type, compression_type);
#endif // Q_OS_WIN
//#ifndef _WIN32
// /* If the file exists and it's user-immutable or not writable,
// ask the user whether they want to override that. */
// if (!file_target_unwritable_ui(top_level, qUtf8Printable(file_name))) {
// /* They don't. Let them try another file name or cancel. */
// continue;
// }
//#endif
/* Attempt to save the file */
status = cf_save_records(cf, qUtf8Printable(file_name), file_type, compression_type,
discard_comments, dont_reopen);
switch (status) {
case CF_WRITE_OK:
/* The save succeeded; we're done. */
/* Save the directory name for future file dialogs. */
dirname = qstring_strdup(file_name); /* Overwrites cf_name */
set_last_open_dir(get_dirname(dirname));
g_free(dirname);
/* If we discarded comments, redraw the packet list to reflect
any packets that no longer have comments. If we had unsaved
changes, redraw the packet list, because saving a time
shift zeroes out the frame.offset_shift field.
If we had a color filter based on frame data, recolor. */
/* XXX: If there is a filter based on those, we want to force
a rescan with the current filter (we don't actually
need to redissect.)
*/
if (discard_comments || cf->unsaved_changes) {
if (color_filters_use_proto(proto_get_id_by_filter_name("frame"))) {
packet_list_->recolorPackets();
} else {
packet_list_->redrawVisiblePackets();
}
}
cf->unsaved_changes = false; //we just saved so we signal that we have no unsaved changes
updateForUnsavedChanges(); // we update the title bar to remove the *
/* Add this filename to the list of recent files in the "Recent Files" submenu */
add_menu_recent_capture_file(qUtf8Printable(file_name));
return true;
case CF_WRITE_ERROR:
/* The save failed; let the user try again. */
continue;
case CF_WRITE_ABORTED:
/* The user aborted the save; just return. */
return false;
}
}
return true;
}
void LograyMainWindow::exportSelectedPackets() {
QString file_name = "";
int file_type;
wtap_compression_type compression_type;
packet_range_t range;
cf_write_status_t status;
gchar *dirname;
bool discard_comments = false;
if (!capture_file_.capFile())
return;
/* Init the packet range */
packet_range_init(&range, capture_file_.capFile());
range.process_filtered = TRUE;
range.include_dependents = TRUE;
QList<int> rows = packet_list_->selectedRows(true);
QStringList entries;
foreach (int row, rows)
entries << QString::number(row);
QString selRange = entries.join(",");
for (;;) {
CaptureFileDialog esp_dlg(this, capture_file_.capFile());
/* If the file has comments, does the format the user selected
support them? If not, ask the user whether they want to
discard the comments or choose a different format. */
switch (esp_dlg.exportSelectedPackets(file_name, &range, selRange)) {
case SAVE:
/* The file can be saved in the specified format as is;
just drive on and save in the format they selected. */
discard_comments = FALSE;
break;
case SAVE_WITHOUT_COMMENTS:
/* The file can't be saved in the specified format as is,
but it can be saved without the comments, and the user
said "OK, discard the comments", so save it in the
format they specified without the comments. */
discard_comments = TRUE;
break;
case SAVE_IN_ANOTHER_FORMAT:
/* There are file formats in which we can save this that
support comments, and the user said not to delete the
comments. The combo box of file formats has had the
formats that don't support comments trimmed from it,
so run the dialog again, to let the user decide
whether to save in one of those formats or give up. */
continue;
case CANCELLED:
/* The user said "forget it". Just get rid of the dialog box
and return. */
goto cleanup;
}
/*
* Check that we're not going to save on top of the current
* capture file.
* We do it here so we catch all cases ...
* Unfortunately, the file requester gives us an absolute file
* name and the read file name may be relative (if supplied on
* the command line). From Joerg Mayer.
*/
if (files_identical(capture_file_.capFile()->filename, qUtf8Printable(file_name))) {
QMessageBox msg_box;
gchar *display_basename = g_filename_display_basename(qUtf8Printable(file_name));
msg_box.setIcon(QMessageBox::Critical);
msg_box.setText(QString(tr("Unable to export to \"%1\".").arg(display_basename)));
msg_box.setInformativeText(tr("You cannot export packets to the current capture file."));
msg_box.setStandardButtons(QMessageBox::Ok);
msg_box.setDefaultButton(QMessageBox::Ok);
msg_box.exec();
g_free(display_basename);
continue;
}
file_type = esp_dlg.selectedFileType();
if (file_type == WTAP_FILE_TYPE_SUBTYPE_UNKNOWN) {
/* This "should not happen". */
QMessageBox msg_box;
msg_box.setIcon(QMessageBox::Critical);
msg_box.setText(tr("Unknown file type returned by export dialog."));
msg_box.setInformativeText(tr("Please report this as a Wireshark issue at https://gitlab.com/wireshark/wireshark/-/issues."));
msg_box.exec();
goto cleanup;
}
compression_type = esp_dlg.compressionType();
#ifdef Q_OS_WIN
// the Windows dialog does not fixup extensions, do it manually here.
fileAddExtension(file_name, file_type, compression_type);
#endif // Q_OS_WIN
//#ifndef _WIN32
// /* If the file exists and it's user-immutable or not writable,
// ask the user whether they want to override that. */
// if (!file_target_unwritable_ui(top_level, qUtf8Printable(file_name))) {
// /* They don't. Let them try another file name or cancel. */
// continue;
// }
//#endif
/* Attempt to save the file */
status = cf_export_specified_packets(capture_file_.capFile(), qUtf8Printable(file_name), &range, file_type, compression_type);
switch (status) {
case CF_WRITE_OK:
/* The save succeeded; we're done. */
/* Save the directory name for future file dialogs. */
dirname = qstring_strdup(file_name); /* Overwrites cf_name */
set_last_open_dir(get_dirname(dirname));
g_free(dirname);
/* If we discarded comments, redraw the packet list to reflect
any packets that no longer have comments. */
/* XXX: Why? We're exporting some packets to a new file but not
changing our current capture file, that shouldn't change the
current packet list. */
if (discard_comments)
packet_list_->redrawVisiblePackets();
/* Add this filename to the list of recent files in the "Recent Files" submenu */
add_menu_recent_capture_file(qUtf8Printable(file_name));
goto cleanup;
case CF_WRITE_ERROR:
/* The save failed; let the user try again. */
continue;
case CF_WRITE_ABORTED:
/* The user aborted the save; just return. */
goto cleanup;
}
}
cleanup:
packet_range_cleanup(&range);
}
void LograyMainWindow::exportDissections(export_type_e export_type) {
capture_file *cf = capture_file_.capFile();
g_return_if_fail(cf);
QList<int> rows = packet_list_->selectedRows(true);
QStringList entries;
foreach (int row, rows)
entries << QString::number(row);
QString selRange = entries.join(",");
ExportDissectionDialog *ed_dlg = new ExportDissectionDialog(this, cf, export_type, selRange);
ed_dlg->setWindowModality(Qt::ApplicationModal);
ed_dlg->setAttribute(Qt::WA_DeleteOnClose);
ed_dlg->show();
}
#ifdef Q_OS_WIN
/*
* Ensure that:
*
* If the file is to be compressed:
*
* if there is a set of extensions used by the file type to be used,
* the file name has one of those extensions followed by the extension
* for the compression type to be used;
*
* otherwise, the file name has the extension for the compression type
* to be used;
*
* otherwise:
*
* if there is a set of extensions used by the file type to be used,
* the file name has one of those extensions.
*/
void LograyMainWindow::fileAddExtension(QString &file_name, int file_type, wtap_compression_type compression_type) {
QString file_name_lower;
GSList *extensions_list;
const char *compressed_file_extension;
gboolean add_extension_for_file_type;
/* Lower-case the file name, so the extension matching is case-insensitive. */
file_name_lower = file_name.toLower();
/* Get a list of all extensions used for this file type; don't
include the ones with compression type extensions, as we
only want to check for the extension for the compression
type we'll be using. */
extensions_list = wtap_get_file_extensions_list(file_type, FALSE);
/* Get the extension for the compression type we'll be using;
NULL is returned if the type isn't supported or compression
is not being done. */
compressed_file_extension = wtap_compression_type_extension(compression_type);
if (extensions_list != NULL) {
GSList *extension;
/* This file type has one or more extensions.
Start out assuming we need to add the default one. */
add_extension_for_file_type = TRUE;
/* OK, see if the file has one of those extensions, followed
by the appropriate compression type extension if it's to be
compressed. */
for (extension = extensions_list; extension != NULL;
extension = g_slist_next(extension)) {
QString file_suffix = QString(".") + (char *)extension->data;
if (compressed_file_extension != NULL)
file_suffix += QString(".") + compressed_file_extension;
if (file_name_lower.endsWith(file_suffix)) {
/*
* The file name has one of the extensions for this file
* type, followed by a compression type extension if
* appropriate, so we don't need to add an extension for
* the file type or the compression type.
*/
add_extension_for_file_type = FALSE;
break;
}
}
} else {
/* We have no extensions for this file type. Just check
to see if we need to add an extension for the compressed
file type.
Start out assuming we do. */
add_extension_for_file_type = TRUE;
if (compressed_file_extension != NULL) {
QString file_suffix = QString(".") + compressed_file_extension;
if (file_name_lower.endsWith(file_suffix)) {
/*
* The file name has the appropriate compressed file extension,
* so we don't need to add an extension for the compression
* type.
*/
add_extension_for_file_type = FALSE;
}
}
}
/*
* If we need to add an extension for the file type or compressed
* file type, do so.
*/
if (add_extension_for_file_type) {
if (wtap_default_file_extension(file_type) != NULL) {
/* This file type has a default extension; append it. */
file_name += QString(".") + wtap_default_file_extension(file_type);
}
if (compression_type != WTAP_UNCOMPRESSED) {
/*
* The file is to be compressed, so append the extension for
* its compression type.
*/
file_name += QString(".") + compressed_file_extension;
}
}
}
#endif // Q_OS_WIN
bool LograyMainWindow::testCaptureFileClose(QString before_what, FileCloseContext context) {
bool capture_in_progress = false;
bool do_close_file = false;
if (!capture_file_.capFile() || capture_file_.capFile()->state == FILE_CLOSED)
return true; /* Already closed, nothing to do */
if (capture_file_.capFile()->read_lock) {
/*
* If the file is being redissected, we cannot stop the capture since
* that would crash and burn "cf_read", so stop early. Ideally all
* callers should be modified to check this condition and act
* accordingly (ignore action or queue it up), so print a warning.
*/
ws_warning("Refusing to close \"%s\" which is being read.", capture_file_.capFile()->filename);
return false;
}
#ifdef HAVE_LIBPCAP
if (capture_file_.capFile()->state == FILE_READ_IN_PROGRESS ||
capture_file_.capFile()->state == FILE_READ_PENDING) {
/*
* FILE_READ_IN_PROGRESS is true if we're reading a capture file
* *or* if we're doing a live capture. From the capture file itself we
* cannot differentiate the cases, so check the current capture session.
* FILE_READ_PENDING is only used for a live capture, but it doesn't
* hurt to check it here.
*/
capture_in_progress = captureSession()->state != CAPTURE_STOPPED;
}
#endif
if (prefs.gui_ask_unsaved) {
if (cf_has_unsaved_data(capture_file_.capFile())) {
QMessageBox msg_dialog;
QString question;
QString infotext;
QPushButton *save_button;
QPushButton *discard_button;
msg_dialog.setIcon(QMessageBox::Question);
msg_dialog.setWindowTitle("Unsaved packets" UTF8_HORIZONTAL_ELLIPSIS);
/* This file has unsaved data or there's a capture in
progress; ask the user whether to save the data. */
if (capture_in_progress && context != Restart) {
question = tr("Do you want to stop the capture and save the captured packets%1?").arg(before_what);
infotext = tr("Your captured packets will be lost if you don't save them.");
} else if (capture_file_.capFile()->is_tempfile) {
if (context == Reload) {
// Reloading a tempfile will keep the packets, so this is not unsaved packets
question = tr("Do you want to save the changes you've made%1?").arg(before_what);
infotext = tr("Your changes will be lost if you don't save them.");
} else {
question = tr("Do you want to save the captured packets%1?").arg(before_what);
infotext = tr("Your captured packets will be lost if you don't save them.");
}
} else {
// No capture in progress and not a tempfile, so this is not unsaved packets
gchar *display_basename = g_filename_display_basename(capture_file_.capFile()->filename);
question = tr("Do you want to save the changes you've made to the capture file \"%1\"%2?").arg(display_basename, before_what);
infotext = tr("Your changes will be lost if you don't save them.");
g_free(display_basename);
}
msg_dialog.setText(question);
msg_dialog.setInformativeText(infotext);
// XXX Text comes from ui/gtk/stock_icons.[ch]
// Note that the button roles differ from the GTK+ version.
// Cancel = RejectRole
// Save = AcceptRole
// Don't Save = DestructiveRole
msg_dialog.addButton(QMessageBox::Cancel);
if (capture_in_progress) {
QString save_button_text;
if (context == Restart) {
save_button_text = tr("Save before Continue");
} else {
save_button_text = tr("Stop and Save");
}
save_button = msg_dialog.addButton(save_button_text, QMessageBox::AcceptRole);
} else {
save_button = msg_dialog.addButton(QMessageBox::Save);
}
msg_dialog.setDefaultButton(save_button);
QString discard_button_text;
if (capture_in_progress) {
switch (context) {
case Quit:
discard_button_text = tr("Stop and Quit &without Saving");
break;
case Restart:
discard_button_text = tr("Continue &without Saving");
break;
default:
discard_button_text = tr("Stop and Continue &without Saving");
break;
}
} else {
switch (context) {
case Quit:
discard_button_text = tr("Quit &without Saving");
break;
case Restart:
default:
discard_button_text = tr("Continue &without Saving");
break;
}
}
discard_button = msg_dialog.addButton(discard_button_text, QMessageBox::DestructiveRole);
#if defined(Q_OS_MAC)
/*
* In macOS, the "default button" is not necessarily the
* button that has the input focus; Enter/Return activates
* the default button, and the spacebar activates the button
* that has the input focus, and they might be different
* buttons.
*
* In a "do you want to save" dialog, for example, the
* "save" button is the default button, and the "don't
* save" button has the input focus, so you can press
* Enter/Return to save or space not to save (or Escape
* to dismiss the dialog).
*
* In Qt terms, this means "no auto-default", as auto-default
* makes the button with the input focus the default button,
* so that Enter/Return will activate it.
*/
QList<QAbstractButton *> buttons = msg_dialog.buttons();
for (int i = 0; i < buttons.size(); ++i) {
QPushButton *button = static_cast<QPushButton *>(buttons.at(i));;
button->setAutoDefault(false);
}
/*
* It also means that the "don't save" button should be the one
* initially given the focus.
*/
discard_button->setFocus();
#endif
msg_dialog.exec();
/* According to the Qt doc:
* when using QMessageBox with custom buttons, exec() function returns an opaque value.
*
* Therefore we should use clickedButton() to determine which button was clicked. */
if (msg_dialog.clickedButton() == save_button) {
#ifdef HAVE_LIBPCAP
/* If there's a capture in progress, we have to stop the capture
and then do the save. */
if (capture_in_progress)
captureStop();
#endif
/* Save the file and close it */
// XXX if no packets were captured, any unsaved comments set by
// the user are silently discarded because capFile() is null.
if (capture_file_.capFile() && saveCaptureFile(capture_file_.capFile(), true) == false)
return false;
do_close_file = true;
} else if (msg_dialog.clickedButton() == discard_button) {
/* Just close the file, discarding changes */
do_close_file = true;
} else {
// cancelButton or some other unspecified button
return false;
}
} else {
/* Unchanged file or capturing with no packets */
do_close_file = true;
}
} else {
/* User asked not to be bothered by those prompts, just close it.
XXX - should that apply only to saving temporary files? */
do_close_file = true;
}
/*
* Are we done with this file and should we close the file?
*/
if (do_close_file) {
#ifdef HAVE_LIBPCAP
/* If there's a capture in progress, we have to stop the capture
and then do the close. */
if (capture_in_progress)
captureStop();
else if (capture_file_.capFile() && capture_file_.capFile()->state == FILE_READ_IN_PROGRESS) {
/*
* When an offline capture is being read, mark it as aborted.
* cf_read will be responsible for actually closing the capture.
*
* We cannot just invoke cf_close here since cf_read is up in the
* call chain. (update_progress_dlg can end up processing the Quit
* event from the user which then ends up here.)
* See also the above "read_lock" check.
*/
capture_file_.capFile()->state = FILE_READ_ABORTED;
return true;
}
#endif
/* Clear MainWindow file name details */
gbl_cur_main_window_->setMwFileName("");
/* captureStop() will close the file if not having any packets */
if (capture_file_.capFile() && context != Restart && context != Reload)
// Don't really close if Restart or Reload
cf_close(capture_file_.capFile());
}
return true; /* File closed */
}
void LograyMainWindow::captureStop() {
stopCapture();
while (capture_file_.capFile() && (capture_file_.capFile()->state == FILE_READ_IN_PROGRESS ||
capture_file_.capFile()->state == FILE_READ_PENDING)) {
WiresharkApplication::processEvents();
}
}
void LograyMainWindow::findTextCodecs() {
const QList<int> mibs = QTextCodec::availableMibs();
QRegularExpression ibmRegExp("^IBM([0-9]+).*$");
QRegularExpression iso8859RegExp("^ISO-8859-([0-9]+).*$");
QRegularExpression windowsRegExp("^WINDOWS-([0-9]+).*$");
QRegularExpressionMatch match;
for (int mib : mibs) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
// QTextCodec::availableMibs() returns a list of hard-coded MIB
// numbers, it doesn't check if they are really available. ICU data may
// not have been compiled with support for all encodings.
if (!codec) {
continue;
}
QString key = codec->name().toUpper();
char rank;
if (key.localeAwareCompare("IBM") < 0) {
rank = 1;
} else if ((match = ibmRegExp.match(key)).hasMatch()) {
rank = match.captured(1).size(); // Up to 5
} else if (key.localeAwareCompare("ISO-8859-") < 0) {
rank = 6;
} else if ((match = iso8859RegExp.match(key)).hasMatch()) {
rank = 6 + match.captured(1).size(); // Up to 6 + 2
} else if (key.localeAwareCompare("WINDOWS-") < 0) {
rank = 9;
} else if ((match = windowsRegExp.match(key)).hasMatch()) {
rank = 9 + match.captured(1).size(); // Up to 9 + 4
} else {
rank = 14;
}
// This doesn't perfectly well order the IBM codecs because it's
// annoying to properly place IBM00858 and IBM00924 in the middle of
// code page numbers not zero padded to 5 digits.
// We could manipulate the key further to have more commonly used
// charsets earlier. IANA MIB ordering would be unxpected:
// https://www.iana.org/assignments/character-sets/character-sets.xml
// For data about use in HTTP (other protocols can be quite different):
// https://w3techs.com/technologies/overview/character_encoding
key.prepend(char('0' + rank));
// We use a map here because, due to backwards compatibility,
// the same QTextCodec may be returned for multiple MIBs, which
// happens for GBK/GB2312, EUC-KR/windows-949/UHC, and others.
text_codec_map_.insert(key, codec);
}
}
void LograyMainWindow::initMainToolbarIcons()
{
// Normally 16 px. Reflects current GTK+ behavior and other Windows apps.
int icon_size = style()->pixelMetric(QStyle::PM_SmallIconSize);
#if !defined(Q_OS_WIN)
// Force icons to 24x24 for now, otherwise actionFileOpen looks wonky.
// The macOS HIG specifies 32-pixel icons but they're a little too
// large IMHO.
icon_size = icon_size * 3 / 2;
#endif
main_ui_->mainToolBar->setIconSize(QSize(icon_size, icon_size));
// Toolbar actions. The GNOME HIG says that we should have a menu icon for each
// toolbar item but that clutters up our menu. Set menu icons sparingly.
main_ui_->actionCaptureStart->setIcon(StockIcon("x-capture-start-circle"));
main_ui_->actionCaptureStop->setIcon(StockIcon("x-capture-stop"));
main_ui_->actionCaptureRestart->setIcon(StockIcon("x-capture-restart-circle"));
main_ui_->actionCaptureOptions->setIcon(StockIcon("x-capture-options"));
// Menu icons are disabled in main_window.ui for these items.
main_ui_->actionFileOpen->setIcon(StockIcon("document-open"));
main_ui_->actionFileSave->setIcon(StockIcon("x-capture-file-save"));
main_ui_->actionFileClose->setIcon(StockIcon("x-capture-file-close"));
main_ui_->actionViewReload->setIcon(StockIcon("x-capture-file-reload"));
main_ui_->actionEditFindPacket->setIcon(StockIcon("edit-find"));
main_ui_->actionGoPreviousPacket->setIcon(StockIcon("go-previous"));
main_ui_->actionGoNextPacket->setIcon(StockIcon("go-next"));
main_ui_->actionGoGoToPacket->setIcon(StockIcon("go-jump"));
main_ui_->actionGoFirstPacket->setIcon(StockIcon("go-first"));
main_ui_->actionGoLastPacket->setIcon(StockIcon("go-last"));
main_ui_->actionGoPreviousConversationPacket->setIcon(StockIcon("go-previous"));
main_ui_->actionGoNextConversationPacket->setIcon(StockIcon("go-next"));
#if defined(Q_OS_MAC)
main_ui_->actionGoPreviousConversationPacket->setShortcut(QKeySequence(Qt::META | Qt::Key_Comma));
main_ui_->actionGoNextConversationPacket->setShortcut(QKeySequence(Qt::META | Qt::Key_Period));
#endif
main_ui_->actionGoPreviousHistoryPacket->setIcon(StockIcon("go-previous"));
main_ui_->actionGoNextHistoryPacket->setIcon(StockIcon("go-next"));
main_ui_->actionGoAutoScroll->setIcon(StockIcon("x-stay-last"));
main_ui_->actionViewColorizePacketList->setIcon(StockIcon("x-colorize-packets"));
QList<QKeySequence> zi_seq = main_ui_->actionViewZoomIn->shortcuts();
zi_seq << QKeySequence(Qt::CTRL | Qt::Key_Equal);
main_ui_->actionViewZoomIn->setIcon(StockIcon("zoom-in"));
main_ui_->actionViewZoomIn->setShortcuts(zi_seq);
main_ui_->actionViewZoomOut->setIcon(StockIcon("zoom-out"));
main_ui_->actionViewNormalSize->setIcon(StockIcon("zoom-original"));
main_ui_->actionViewResizeColumns->setIcon(StockIcon("x-resize-columns"));
main_ui_->actionNewDisplayFilterExpression->setIcon(StockIcon("list-add"));
}
void LograyMainWindow::initShowHideMainWidgets()
{
if (show_hide_actions_) {
return;
}
show_hide_actions_ = new QActionGroup(this);
QMap<QAction *, QWidget *> shmw_actions;
show_hide_actions_->setExclusive(false);
shmw_actions[main_ui_->actionViewMainToolbar] = main_ui_->mainToolBar;
shmw_actions[main_ui_->actionViewFilterToolbar] = main_ui_->displayFilterToolBar;
shmw_actions[main_ui_->actionViewStatusBar] = main_ui_->statusBar;
shmw_actions[main_ui_->actionViewPacketList] = packet_list_;
shmw_actions[main_ui_->actionViewPacketDetails] = proto_tree_;
shmw_actions[main_ui_->actionViewPacketBytes] = byte_view_tab_;
shmw_actions[main_ui_->actionViewPacketDiagram] = packet_diagram_;
foreach(QAction *shmwa, shmw_actions.keys()) {
shmwa->setData(QVariant::fromValue(shmw_actions[shmwa]));
show_hide_actions_->addAction(shmwa);
}
// Initial hide the Interface Toolbar submenu
main_ui_->menuInterfaceToolbars->menuAction()->setVisible(false);
/* Initially hide the additional toolbars menus */
main_ui_->menuAdditionalToolbars->menuAction()->setVisible(false);
connect(show_hide_actions_, SIGNAL(triggered(QAction*)), this, SLOT(showHideMainWidgets(QAction*)));
}
void LograyMainWindow::initTimeDisplayFormatMenu()
{
if (time_display_actions_) {
return;
}
time_display_actions_ = new QActionGroup(this);
td_actions[main_ui_->actionViewTimeDisplayFormatDateYMDandTimeOfDay] = TS_ABSOLUTE_WITH_YMD;
td_actions[main_ui_->actionViewTimeDisplayFormatDateYDOYandTimeOfDay] = TS_ABSOLUTE_WITH_YDOY;
td_actions[main_ui_->actionViewTimeDisplayFormatTimeOfDay] = TS_ABSOLUTE;
td_actions[main_ui_->actionViewTimeDisplayFormatSecondsSinceEpoch] = TS_EPOCH;
td_actions[main_ui_->actionViewTimeDisplayFormatSecondsSinceBeginningOfCapture] = TS_RELATIVE;
td_actions[main_ui_->actionViewTimeDisplayFormatSecondsSincePreviousCapturedPacket] = TS_DELTA;
td_actions[main_ui_->actionViewTimeDisplayFormatSecondsSincePreviousDisplayedPacket] = TS_DELTA_DIS;
td_actions[main_ui_->actionViewTimeDisplayFormatUTCDateYMDandTimeOfDay] = TS_UTC_WITH_YMD;
td_actions[main_ui_->actionViewTimeDisplayFormatUTCDateYDOYandTimeOfDay] = TS_UTC_WITH_YDOY;
td_actions[main_ui_->actionViewTimeDisplayFormatUTCTimeOfDay] = TS_UTC;
foreach(QAction* tda, td_actions.keys()) {
tda->setData(QVariant::fromValue(td_actions[tda]));
time_display_actions_->addAction(tda);
}
connect(time_display_actions_, SIGNAL(triggered(QAction*)), this, SLOT(setTimestampFormat(QAction*)));
}
void LograyMainWindow::initTimePrecisionFormatMenu()
{
if (time_precision_actions_) {
return;
}
time_precision_actions_ = new QActionGroup(this);
tp_actions[main_ui_->actionViewTimeDisplayFormatPrecisionAutomatic] = TS_PREC_AUTO;
tp_actions[main_ui_->actionViewTimeDisplayFormatPrecisionSeconds] = TS_PREC_FIXED_SEC;
tp_actions[main_ui_->actionViewTimeDisplayFormatPrecisionDeciseconds] = TS_PREC_FIXED_DSEC;
tp_actions[main_ui_->actionViewTimeDisplayFormatPrecisionCentiseconds] = TS_PREC_FIXED_CSEC;
tp_actions[main_ui_->actionViewTimeDisplayFormatPrecisionMilliseconds] = TS_PREC_FIXED_MSEC;
tp_actions[main_ui_->actionViewTimeDisplayFormatPrecisionMicroseconds] = TS_PREC_FIXED_USEC;
tp_actions[main_ui_->actionViewTimeDisplayFormatPrecisionNanoseconds] = TS_PREC_FIXED_NSEC;
foreach(QAction* tpa, tp_actions.keys()) {
tpa->setData(QVariant::fromValue(tp_actions[tpa]));
time_precision_actions_->addAction(tpa);
}
connect(time_precision_actions_, SIGNAL(triggered(QAction*)), this, SLOT(setTimestampPrecision(QAction*)));
}
// Menu items which will be disabled when we freeze() and whose state will
// be restored when we thaw(). Add to the list as needed.
void LograyMainWindow::initFreezeActions()
{
QList<QAction *> freeze_actions = QList<QAction *>()
<< main_ui_->actionFileClose
<< main_ui_->actionViewReload
<< main_ui_->actionEditMarkPacket
<< main_ui_->actionEditMarkAllDisplayed
<< main_ui_->actionEditUnmarkAllDisplayed
<< main_ui_->actionEditIgnorePacket
<< main_ui_->actionEditIgnoreAllDisplayed
<< main_ui_->actionEditUnignoreAllDisplayed
<< main_ui_->actionEditSetTimeReference
<< main_ui_->actionEditUnsetAllTimeReferences;
foreach(QAction *action, freeze_actions) {
freeze_actions_ << QPair<QAction *, bool>(action, false);
}
}
void LograyMainWindow::initConversationMenus()
{
int i;
QList<QAction *> cc_actions = QList<QAction *>()
<< main_ui_->actionViewColorizeConversation1 << main_ui_->actionViewColorizeConversation2
<< main_ui_->actionViewColorizeConversation3 << main_ui_->actionViewColorizeConversation4
<< main_ui_->actionViewColorizeConversation5 << main_ui_->actionViewColorizeConversation6
<< main_ui_->actionViewColorizeConversation7 << main_ui_->actionViewColorizeConversation8
<< main_ui_->actionViewColorizeConversation9 << main_ui_->actionViewColorizeConversation10;
for (GList *conv_filter_list_entry = log_conv_filter_list; conv_filter_list_entry; conv_filter_list_entry = gxx_list_next(conv_filter_list_entry)) {
// Main menu items
conversation_filter_t* conv_filter = gxx_list_data(conversation_filter_t *, conv_filter_list_entry);
ConversationAction *conv_action = new ConversationAction(main_ui_->menuConversationFilter, conv_filter);
main_ui_->menuConversationFilter->addAction(conv_action);
connect(this, SIGNAL(packetInfoChanged(_packet_info*)), conv_action, SLOT(setPacketInfo(_packet_info*)));
connect(conv_action, SIGNAL(triggered()), this, SLOT(applyConversationFilter()), Qt::QueuedConnection);
// Packet list context menu items
packet_list_->conversationMenu()->addAction(conv_action);
QMenu *submenu = packet_list_->colorizeMenu()->addMenu(conv_action->text());
i = 1;
foreach(QAction *cc_action, cc_actions) {
conv_action = new ConversationAction(submenu, conv_filter);
conv_action->setText(cc_action->text());
conv_action->setIcon(cc_action->icon());
conv_action->setColorNumber(i++);
submenu->addAction(conv_action);
connect(this, SIGNAL(packetInfoChanged(_packet_info*)), conv_action, SLOT(setPacketInfo(_packet_info*)));
connect(conv_action, SIGNAL(triggered()), this, SLOT(colorizeActionTriggered()));
}
conv_action = new ConversationAction(submenu, conv_filter);
conv_action->setText(main_ui_->actionViewColorizeNewColoringRule->text());
submenu->addAction(conv_action);
connect(this, SIGNAL(packetInfoChanged(_packet_info*)), conv_action, SLOT(setPacketInfo(_packet_info*)));
connect(conv_action, SIGNAL(triggered()), this, SLOT(colorizeActionTriggered()));
// Proto tree conversation menu is filled in in ProtoTree::contextMenuEvent.
// We should probably do that here.
}
// Proto tree colorization items
i = 1;
ColorizeAction *colorize_action;
foreach(QAction *cc_action, cc_actions) {
colorize_action = new ColorizeAction(proto_tree_->colorizeMenu());
colorize_action->setText(cc_action->text());
colorize_action->setIcon(cc_action->icon());
colorize_action->setColorNumber(i++);
proto_tree_->colorizeMenu()->addAction(colorize_action);
connect(this, SIGNAL(fieldFilterChanged(QByteArray)), colorize_action, SLOT(setFieldFilter(QByteArray)));
connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeActionTriggered()));
}
colorize_action = new ColorizeAction(proto_tree_->colorizeMenu());
colorize_action->setText(main_ui_->actionViewColorizeNewColoringRule->text());
proto_tree_->colorizeMenu()->addAction(colorize_action);
connect(this, SIGNAL(fieldFilterChanged(QByteArray)), colorize_action, SLOT(setFieldFilter(QByteArray)));
connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeActionTriggered()));
}
bool LograyMainWindow::addExportObjectsMenuItem(const void *, void *value, void *userdata)
{
register_eo_t *eo = (register_eo_t*)value;
LograyMainWindow *window = (LograyMainWindow*)userdata;
ExportObjectAction *export_action = new ExportObjectAction(window->main_ui_->menuFileExportObjects, eo);
window->main_ui_->menuFileExportObjects->addAction(export_action);
//initially disable until a file is loaded (then file signals will take over)
export_action->setEnabled(false);
connect(&window->capture_file_, SIGNAL(captureEvent(CaptureEvent)), export_action, SLOT(captureFileEvent(CaptureEvent)));
connect(export_action, SIGNAL(triggered()), window, SLOT(applyExportObject()));
return FALSE;
}
void LograyMainWindow::initExportObjectsMenus()
{
eo_iterate_tables(addExportObjectsMenuItem, this);
}
// Titlebar
void LograyMainWindow::setTitlebarForCaptureFile()
{
if (capture_file_.capFile() && capture_file_.capFile()->filename) {
setWSWindowTitle(QString("[*]%1").arg(capture_file_.fileDisplayName()));
//
// XXX - on non-Mac platforms, put in the application
// name? Or do so only for temporary files?
//
if (!capture_file_.capFile()->is_tempfile) {
//
// Set the file path; that way, for macOS, it'll set the
// "proxy icon".
//
setWindowFilePath(capture_file_.filePath());
}
setWindowModified(cf_has_unsaved_data(capture_file_.capFile()));
} else {
/* We have no capture file. */
setWSWindowTitle();
}
}
QString LograyMainWindow::replaceWindowTitleVariables(QString title)
{
title.replace("%P", get_profile_name());
title.replace("%V", get_ws_vcs_version_info());
if (title.contains("%F")) {
// %F is file path of the capture file.
if (capture_file_.capFile()) {
// get_dirname() will overwrite the argument so make a copy first
char *filename = g_strdup(capture_file_.capFile()->filename);
QString file(get_dirname(filename));
g_free(filename);
#ifndef _WIN32
// Substitute HOME with ~
QString homedir(g_getenv("HOME"));
if (!homedir.isEmpty()) {
homedir.remove(QRegularExpression("[/]+$"));
file.replace(homedir, "~");
}
#endif
title.replace("%F", file);
} else {
// No file loaded, no folder name
title.remove("%F");
}
}
if (title.contains("%S")) {
// %S is a conditional separator (" - ") that only shows when surrounded by variables
// with values or static text. Remove repeating, leading and trailing separators.
title.replace(QRegularExpression("(%S)+"), "%S");
title.remove(QRegularExpression("^%S|%S$"));
#ifdef __APPLE__
// On macOS we separate with a unicode em dash
title.replace("%S", " " UTF8_EM_DASH " ");
#else
title.replace("%S", " - ");
#endif
}
return title;
}
void LograyMainWindow::setWSWindowTitle(QString title)
{
if (title.isEmpty()) {
title = tr("The Logray System Log Analyzer");
}
if (prefs.gui_prepend_window_title && prefs.gui_prepend_window_title[0]) {
QString custom_title = replaceWindowTitleVariables(prefs.gui_prepend_window_title);
if (custom_title.length() > 0) {
title.prepend(QString("[%1] ").arg(custom_title));
}
}
if (prefs.gui_window_title && prefs.gui_window_title[0]) {
QString custom_title = replaceWindowTitleVariables(prefs.gui_window_title);
if (custom_title.length() > 0) {
#ifdef __APPLE__
// On macOS we separate the titles with a unicode em dash
title.append(QString(" %1 %2").arg(UTF8_EM_DASH).arg(custom_title));
#else
title.append(QString(" [%1]").arg(custom_title));
#endif
}
}
setWindowTitle(title);
setWindowFilePath(NULL);
}
void LograyMainWindow::setTitlebarForCaptureInProgress()
{
if (capture_file_.capFile()) {
setWSWindowTitle(tr("Capturing from %1").arg(cf_get_tempfile_source(capture_file_.capFile())));
} else {
/* We have no capture in progress. */
setWSWindowTitle();
}
}
// Menu state
/* Enable or disable menu items based on whether you have a capture file
you've finished reading and, if you have one, whether it's been saved
and whether it could be saved except by copying the raw packet data. */
void LograyMainWindow::setMenusForCaptureFile(bool force_disable)
{
bool enable = true;
bool can_write = false;
bool can_save = false;
bool can_save_as = false;
if (force_disable || capture_file_.capFile() == NULL || capture_file_.capFile()->state == FILE_READ_IN_PROGRESS || capture_file_.capFile()->state == FILE_READ_PENDING) {
/* We have no capture file or we're currently reading a file */
enable = false;
} else {
/* We have a capture file. Can we write or save? */
can_write = cf_can_write_with_wiretap(capture_file_.capFile());
can_save = cf_can_save(capture_file_.capFile());
can_save_as = cf_can_save_as(capture_file_.capFile());
}
main_ui_->actionViewReload_as_File_Format_or_Capture->setEnabled(enable);
main_ui_->actionFileMerge->setEnabled(can_write);
main_ui_->actionFileClose->setEnabled(enable);
main_ui_->actionFileSave->setEnabled(can_save);
main_ui_->actionFileSaveAs->setEnabled(can_save_as);
main_ui_->actionStatisticsCaptureFileProperties->setEnabled(enable);
/*
* "Export Specified Packets..." should be available only if
* we can write the file out in at least one format.
*/
main_ui_->actionFileExportPackets->setEnabled(can_write);
main_ui_->actionFileExportAsCArrays->setEnabled(enable);
main_ui_->actionFileExportAsCSV->setEnabled(enable);
main_ui_->actionFileExportAsPDML->setEnabled(enable);
main_ui_->actionFileExportAsPlainText->setEnabled(enable);
main_ui_->actionFileExportAsPSML->setEnabled(enable);
main_ui_->actionFileExportAsJSON->setEnabled(enable);
main_ui_->actionFileExportPDU->setEnabled(enable);
foreach(QAction *eo_action, main_ui_->menuFileExportObjects->actions()) {
eo_action->setEnabled(enable);
}
main_ui_->actionViewReload->setEnabled(enable);
#ifdef HAVE_SOFTWARE_UPDATE
// We might want to enable or disable automatic checks here as well.
update_action_->setEnabled(!can_save);
#endif
}
void LograyMainWindow::setMenusForCaptureInProgress(bool capture_in_progress) {
/* Either a capture was started or stopped; in either case, it's not
in the process of stopping, so allow quitting. */
main_ui_->actionFileOpen->setEnabled(!capture_in_progress);
main_ui_->menuOpenRecentCaptureFile->setEnabled(!capture_in_progress);
main_ui_->actionFileExportAsCArrays->setEnabled(capture_in_progress);
main_ui_->actionFileExportAsCSV->setEnabled(capture_in_progress);
main_ui_->actionFileExportAsPDML->setEnabled(capture_in_progress);
main_ui_->actionFileExportAsPlainText->setEnabled(capture_in_progress);
main_ui_->actionFileExportAsPSML->setEnabled(capture_in_progress);
main_ui_->actionFileExportAsJSON->setEnabled(capture_in_progress);
main_ui_->actionFileExportPDU->setEnabled(!capture_in_progress);
foreach(QAction *eo_action, main_ui_->menuFileExportObjects->actions()) {
eo_action->setEnabled(capture_in_progress);
}
main_ui_->menuFileSet->setEnabled(!capture_in_progress);
main_ui_->actionFileQuit->setEnabled(true);
#ifdef HAVE_SOFTWARE_UPDATE
// We might want to enable or disable automatic checks here as well.
update_action_->setEnabled(!capture_in_progress);
#endif
main_ui_->actionStatisticsCaptureFileProperties->setEnabled(capture_in_progress);
// XXX Fix packet list heading menu sensitivity
// set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortAscending",
// !capture_in_progress);
// set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortDescending",
// !capture_in_progress);
// set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/NoSorting",
// !capture_in_progress);
#ifdef HAVE_LIBPCAP
main_ui_->actionCaptureOptions->setEnabled(!capture_in_progress);
main_ui_->actionCaptureStart->setEnabled(!capture_in_progress);
main_ui_->actionCaptureStart->setChecked(capture_in_progress);
main_ui_->actionCaptureStop->setEnabled(capture_in_progress);
main_ui_->actionCaptureRestart->setEnabled(capture_in_progress);
main_ui_->actionCaptureRefreshInterfaces->setEnabled(!capture_in_progress);
#endif /* HAVE_LIBPCAP */
}
void LograyMainWindow::setMenusForCaptureStopping() {
main_ui_->actionFileQuit->setEnabled(false);
#ifdef HAVE_SOFTWARE_UPDATE
update_action_->setEnabled(false);
#endif
main_ui_->actionStatisticsCaptureFileProperties->setEnabled(false);
#ifdef HAVE_LIBPCAP
main_ui_->actionCaptureStart->setChecked(false);
main_ui_->actionCaptureStop->setEnabled(false);
main_ui_->actionCaptureRestart->setEnabled(false);
#endif /* HAVE_LIBPCAP */
}
void LograyMainWindow::setForCapturedPackets(bool have_captured_packets)
{
main_ui_->actionFilePrint->setEnabled(have_captured_packets);
// set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Print",
// have_captured_packets);
main_ui_->actionEditFindPacket->setEnabled(have_captured_packets);
main_ui_->actionEditFindNext->setEnabled(have_captured_packets);
main_ui_->actionEditFindPrevious->setEnabled(have_captured_packets);
main_ui_->actionGoGoToPacket->setEnabled(have_captured_packets);
main_ui_->actionGoPreviousPacket->setEnabled(have_captured_packets);
main_ui_->actionGoNextPacket->setEnabled(have_captured_packets);
main_ui_->actionGoFirstPacket->setEnabled(have_captured_packets);
main_ui_->actionGoLastPacket->setEnabled(have_captured_packets);
main_ui_->actionGoNextConversationPacket->setEnabled(have_captured_packets);
main_ui_->actionGoPreviousConversationPacket->setEnabled(have_captured_packets);
main_ui_->actionViewZoomIn->setEnabled(have_captured_packets);
main_ui_->actionViewZoomOut->setEnabled(have_captured_packets);
main_ui_->actionViewNormalSize->setEnabled(have_captured_packets);
main_ui_->actionViewResizeColumns->setEnabled(have_captured_packets);
main_ui_->actionStatisticsCaptureFileProperties->setEnabled(have_captured_packets);
main_ui_->actionStatisticsProtocolHierarchy->setEnabled(have_captured_packets);
main_ui_->actionStatisticsIOGraph->setEnabled(have_captured_packets);
}
void LograyMainWindow::setMenusForFileSet(bool enable_list_files) {
bool enable_next = fileset_get_next() != NULL && enable_list_files;
bool enable_prev = fileset_get_previous() != NULL && enable_list_files;
main_ui_->actionFileSetListFiles->setEnabled(enable_list_files);
main_ui_->actionFileSetNextFile->setEnabled(enable_next);
main_ui_->actionFileSetPreviousFile->setEnabled(enable_prev);
}
void LograyMainWindow::setWindowIcon(const QIcon &icon) {
mainApp->setWindowIcon(icon);
QMainWindow::setWindowIcon(icon);
}
void LograyMainWindow::updateForUnsavedChanges() {
setTitlebarForCaptureFile();
setMenusForCaptureFile();
}
void LograyMainWindow::changeEvent(QEvent* event)
{
if (0 != event)
{
switch (event->type())
{
case QEvent::LanguageChange:
main_ui_->retranslateUi(this);
// make sure that the "Clear Menu" item is retranslated
mainApp->emitAppSignal(WiresharkApplication::RecentCapturesChanged);
break;
case QEvent::LocaleChange: {
QString locale = QLocale::system().name();
locale.truncate(locale.lastIndexOf('_'));
mainApp->loadLanguage(locale);
}
break;
case QEvent::WindowStateChange:
main_ui_->actionViewFullScreen->setChecked(this->isFullScreen());
break;
default:
break;
}
}
QMainWindow::changeEvent(event);
}
/* Update main window items based on whether there's a capture in progress. */
void LograyMainWindow::setForCaptureInProgress(bool capture_in_progress, bool handle_toolbars, GArray *ifaces)
{
setMenusForCaptureInProgress(capture_in_progress);
#ifdef HAVE_LIBPCAP
packet_list_->setCaptureInProgress(capture_in_progress, main_ui_->actionGoAutoScroll->isChecked());
// set_capture_if_dialog_for_capture_in_progress(capture_in_progress);
#endif
if (handle_toolbars) {
QList<InterfaceToolbar *> toolbars = findChildren<InterfaceToolbar *>();
foreach(InterfaceToolbar *toolbar, toolbars) {
if (capture_in_progress) {
toolbar->startCapture(ifaces);
} else {
toolbar->stopCapture();
}
}
}
}
void LograyMainWindow::addMenuActions(QList<QAction *> &actions, int menu_group)
{
foreach(QAction *action, actions) {
switch (menu_group) {
case REGISTER_LOG_ANALYZE_GROUP_UNSORTED:
case REGISTER_LOG_STAT_GROUP_UNSORTED:
main_ui_->menuStatistics->insertAction(
main_ui_->actionStatistics_REGISTER_STAT_GROUP_UNSORTED,
action);
break;
// case REGISTER_TOOLS_GROUP_UNSORTED:
// {
// // Allow the creation of submenus. Mimics the behavor of
// // ui/gtk/main_menubar.c:add_menu_item_to_main_menubar
// // and GtkUIManager.
// //
// // For now we limit the insanity to the "Tools" menu.
// QStringList menu_path = action->text().split('/');
// QMenu *cur_menu = main_ui_->menuTools;
// while (menu_path.length() > 1) {
// QString menu_title = menu_path.takeFirst();
// QMenu *submenu = cur_menu->findChild<QMenu *>(menu_title.toLower(), Qt::FindDirectChildrenOnly);
// if (!submenu) {
// submenu = cur_menu->addMenu(menu_title);
// submenu->setObjectName(menu_title.toLower());
// }
// cur_menu = submenu;
// }
// action->setText(menu_path.last());
// cur_menu->addAction(action);
// break;
// }
default:
// Skip packet items.
return;
}
// Connect each action type to its corresponding slot. We to
// distinguish various types of actions. Setting their objectName
// seems to work OK.
if (action->objectName() == TapParameterDialog::actionName()) {
connect(action, SIGNAL(triggered(bool)), this, SLOT(openTapParameterDialog()));
} else if (action->objectName() == FunnelStatistics::actionName()) {
connect(action, SIGNAL(triggered(bool)), funnel_statistics_, SLOT(funnelActionTriggered()));
}
}
}
void LograyMainWindow::removeMenuActions(QList<QAction *> &actions, int menu_group)
{
foreach(QAction *action, actions) {
switch (menu_group) {
case REGISTER_LOG_ANALYZE_GROUP_UNSORTED:
case REGISTER_LOG_STAT_GROUP_UNSORTED:
main_ui_->menuStatistics->removeAction(action);
break;
// case REGISTER_TOOLS_GROUP_UNSORTED:
// {
// // Allow removal of submenus.
// // For now we limit the insanity to the "Tools" menu.
// QStringList menu_path = action->text().split('/');
// QMenu *cur_menu = main_ui_->menuTools;
// while (menu_path.length() > 1) {
// QString menu_title = menu_path.takeFirst();
// QMenu *submenu = cur_menu->findChild<QMenu *>(menu_title.toLower(), Qt::FindDirectChildrenOnly);
// cur_menu = submenu;
// }
// cur_menu->removeAction(action);
// break;
// }
default:
// qDebug() << "FIX: Remove" << action->text() << "from the menu";
break;
}
}
}
void LograyMainWindow::addDynamicMenus()
{
// Fill in each menu
foreach(register_stat_group_t menu_group, menu_groups_) {
QList<QAction *>actions = mainApp->dynamicMenuGroupItems(menu_group);
addMenuActions(actions, menu_group);
}
}
void LograyMainWindow::reloadDynamicMenus()
{
foreach(register_stat_group_t menu_group, menu_groups_) {
QList<QAction *>actions = mainApp->removedMenuGroupItems(menu_group);
removeMenuActions(actions, menu_group);
actions = mainApp->addedMenuGroupItems(menu_group);
addMenuActions(actions, menu_group);
}
mainApp->clearAddedMenuGroupItems();
mainApp->clearRemovedMenuGroupItems();
}
void LograyMainWindow::externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint depth)
{
QAction * itemAction = Q_NULLPTR;
ext_menubar_t * item = Q_NULLPTR;
GList * children = Q_NULLPTR;
/* There must exists an xpath parent */
Q_ASSERT(subMenu != NULL);
/* If the depth counter exceeds, something must have gone wrong */
Q_ASSERT(depth < EXT_MENUBAR_MAX_DEPTH);
children = menu->children;
/* Iterate the child entries */
while (children && children->data) {
item = gxx_list_data(ext_menubar_t *, children);
if (item->type == EXT_MENUBAR_MENU) {
/* Handle Submenu entry */
this->externalMenuHelper(item, subMenu->addMenu(item->label), depth++);
} else if (item->type == EXT_MENUBAR_SEPARATOR) {
subMenu->addSeparator();
} else if (item->type == EXT_MENUBAR_ITEM || item->type == EXT_MENUBAR_URL) {
itemAction = subMenu->addAction(item->name);
itemAction->setData(QVariant::fromValue(static_cast<void *>(item)));
itemAction->setText(item->label);
connect(itemAction, &QAction::triggered, this, &LograyMainWindow::externalMenuItemTriggered);
}
/* Iterate Loop */
children = gxx_list_next(children);
}
}
QMenu * LograyMainWindow::searchSubMenu(QString objectName)
{
QList<QMenu*> lst;
if (objectName.length() > 0) {
QString searchName = QString("menu") + objectName;
lst = main_ui_->menuBar->findChildren<QMenu*>();
foreach(QMenu* m, lst) {
if (QString::compare(m->objectName(), searchName) == 0)
return m;
}
}
return 0;
}
void LograyMainWindow::addPluginIFStructures()
{
GList *user_menu = ext_menubar_get_entries();
while (user_menu && user_menu->data) {
QMenu *subMenu = Q_NULLPTR;
ext_menu_t *menu = gxx_list_data(ext_menu_t *, user_menu);
/* On this level only menu items should exist. Not doing an assert here,
* as it could be an honest mistake */
if (menu->type != EXT_MENUBAR_MENU) {
user_menu = gxx_list_next(user_menu);
continue;
}
/* Create main submenu and add it to the menubar */
if (menu->parent_menu) {
QMenu *sortUnderneath = searchSubMenu(QString(menu->parent_menu));
if (sortUnderneath)
subMenu = sortUnderneath->addMenu(menu->label);
}
if (!subMenu)
subMenu = main_ui_->menuBar->addMenu(menu->label);
/* This will generate the action structure for each menu. It is recursive,
* therefore a sub-routine, and we have a depth counter to prevent endless loops. */
this->externalMenuHelper(menu, subMenu, 0);
/* Iterate Loop */
user_menu = gxx_list_next(user_menu);
}
int cntToolbars = 0;
QMenu *tbMenu = main_ui_->menuAdditionalToolbars;
GList *if_toolbars = ext_toolbar_get_entries();
while (if_toolbars && if_toolbars->data) {
ext_toolbar_t *toolbar = gxx_list_data(ext_toolbar_t*, if_toolbars);
if (toolbar->type != EXT_TOOLBAR_BAR) {
if_toolbars = gxx_list_next(if_toolbars);
continue;
}
bool visible = g_list_find_custom(recent.gui_additional_toolbars, toolbar->name, reinterpret_cast<GCompareFunc>(strcmp)) ? true : false;
AdditionalToolBar *ifToolBar = AdditionalToolBar::create(this, toolbar);
if (ifToolBar) {
ifToolBar->setVisible(visible);
QAction *iftbAction = new QAction(QString(toolbar->name), this);
iftbAction->setToolTip(toolbar->tooltip);
iftbAction->setEnabled(true);
iftbAction->setCheckable(true);
iftbAction->setChecked(visible);
iftbAction->setToolTip(tr("Show or hide the toolbar"));
iftbAction->setData(VariantPointer<ext_toolbar_t>::asQVariant(toolbar));
QAction *before = Q_NULLPTR;
foreach(QAction *action, tbMenu->actions()) {
/* Ensure we add the menu entries in sorted order */
if (action->text().compare(toolbar->name, Qt::CaseInsensitive) > 0) {
before = action;
break;
}
}
tbMenu->insertAction(before, iftbAction);
addToolBar(Qt::TopToolBarArea, ifToolBar);
insertToolBarBreak(ifToolBar);
if (show_hide_actions_)
show_hide_actions_->addAction(iftbAction);
cntToolbars++;
}
if_toolbars = gxx_list_next(if_toolbars);
}
if (cntToolbars)
tbMenu->menuAction()->setVisible(true);
}
void LograyMainWindow::removeAdditionalToolbar(QString toolbarName)
{
if (toolbarName.length() == 0)
return;
QList<QToolBar *> toolbars = findChildren<QToolBar *>();
foreach(QToolBar *tb, toolbars) {
AdditionalToolBar *ifToolBar = dynamic_cast<AdditionalToolBar *>(tb);
if (ifToolBar && ifToolBar->menuName().compare(toolbarName)) {
GList *entry = g_list_find_custom(recent.gui_additional_toolbars, qUtf8Printable(ifToolBar->menuName()), reinterpret_cast<GCompareFunc>(strcmp));
if (entry) {
recent.gui_additional_toolbars = g_list_remove(recent.gui_additional_toolbars, entry->data);
}
QList<QAction *> actions = main_ui_->menuAdditionalToolbars->actions();
foreach(QAction *action, actions) {
ext_toolbar_t *item = VariantPointer<ext_toolbar_t>::asPtr(action->data());
if (item && ifToolBar->menuName().compare(item->name)) {
if (show_hide_actions_)
show_hide_actions_->removeAction(action);
main_ui_->menuAdditionalToolbars->removeAction(action);
}
}
break;
}
}
}
QString LograyMainWindow::getMwFileName()
{
return mwFileName_;
}
void LograyMainWindow::setMwFileName(QString fileName)
{
mwFileName_ = fileName;
return;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.