h501 \
hnbap \
inap \
+ kerberos \
ldap \
logotypecertextn \
lte-rrc \
gsm_map \
h248 \
inap \
+ kerberos \
ldap \
logotypecertextn \
mms \
cd ansi_map
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
+ cd ansi_tcap
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
+ cd ..
cd camel
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
cd dap
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
- cd disp
+ cd dop
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
- cd dop
+ cd disp
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
cd dsp
cd ftam
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
- cd goose
+ cd gnm
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
- cd gnm
+ cd goose
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
cd gsm_map
cd inap
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
+ cd kerberos
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
+ cd ..
cd ldap
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
- cd lte-rrc
+ cd logotypecertextn
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
- cd logotypecertextn
+ cd lte-rrc
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
cd mms
cd ros
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
- cd rtse
- $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
- cd ..
cd rrc
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
cd rrlp
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
+ cd rtse
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
+ cd ..
cd rua
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
cd x509sat
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
cd ..
+ cd x721
+ $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
+ cd ..
distclean: clean
dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
+AC_PROG_CXX
AC_PROG_CPP
dnl Work around libtool bug (fixed in the version 1.5a?)
AC_DEFUN([AC_PROVIDE_AC_LIBTOOL_DLOPEN], )
# programs to be built with GTK+.
#
if test "x$enable_wireshark" = "xyes"; then
- AM_PATH_GTK_2_0(2.4.0, CFLAGS="$CFLAGS $GTK_CFLAGS", GTK_OK=no, gthread)
+ AM_PATH_GTK_2_0(2.4.0,
+ [
+ CFLAGS="$CFLAGS $GTK_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
+ ], GTK_OK=no, gthread)
else
GTK_OK=no
fi
wireshark_bin=""
wireshark_man=""
# Use GLIB_CFLAGS
- AM_PATH_GLIB_2_0(2.4.0, CFLAGS="$CFLAGS $GLIB_CFLAGS", AC_MSG_ERROR(GLib 2.4 or later distribution not found.), gmodule)
+ AM_PATH_GLIB_2_0(2.4.0,
+ [
+ CFLAGS="$CFLAGS $GLIB_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $GLIB_CFLAGS"
+ ], AC_MSG_ERROR(GLib 2.4 or later distribution not found.), gmodule)
else
#
# We have GTK+, and thus will be building Wireshark unless the
*/
#ifdef HAVE_LIBGCRYPT
static gint
-compute_ascii_key(gchar **ascii_key, gchar *key)
+compute_ascii_key(gchar **ascii_key, const gchar *key)
{
guint key_len = 0;
gint hex_digit;
}
(*ascii_key)[j] = (guchar)hex_digit;
j++;
- }
- else
- {
- /*
- * Key has an even number of characters, so we treat each
- * pair of hex digits as a single byte value.
- */
- key_len = ((guint) strlen(key) - 2) / 2;
+ }
+ else
+ {
+ /*
+ * Key has an even number of characters, so we treat each
+ * pair of hex digits as a single byte value.
+ */
+ key_len = ((guint) strlen(key) - 2) / 2;
*ascii_key = (gchar *) g_malloc ((key_len + 1)* sizeof(gchar));
- }
-
- while(i < (strlen(key) -1))
- {
- hex_digit = g_ascii_xdigit_value(key[i]);
- i++;
- if (hex_digit == -1)
- {
- g_free(*ascii_key);
- *ascii_key = NULL;
- return -1; /* not a valid hex digit */
- }
- key_byte = ((guchar)hex_digit) << 4;
- hex_digit = g_ascii_xdigit_value(key[i]);
- i++;
- if (hex_digit == -1)
- {
- g_free(*ascii_key);
- *ascii_key = NULL;
- return -1; /* not a valid hex digit */
- }
- key_byte |= (guchar)hex_digit;
- (*ascii_key)[j] = key_byte;
- j++;
- }
- (*ascii_key)[j] = '\0';
+ }
+
+ while(i < (strlen(key) -1))
+ {
+ hex_digit = g_ascii_xdigit_value(key[i]);
+ i++;
+ if (hex_digit == -1)
+ {
+ g_free(*ascii_key);
+ *ascii_key = NULL;
+ return -1; /* not a valid hex digit */
+ }
+ key_byte = ((guchar)hex_digit) << 4;
+ hex_digit = g_ascii_xdigit_value(key[i]);
+ i++;
+ if (hex_digit == -1)
+ {
+ g_free(*ascii_key);
+ *ascii_key = NULL;
+ return -1; /* not a valid hex digit */
+ }
+ key_byte |= (guchar)hex_digit;
+ (*ascii_key)[j] = key_byte;
+ j++;
+ }
+ (*ascii_key)[j] = '\0';
}
else if((strlen(key) == 2) && (key[0] == '0') && ((key[1] == 'x') || (key[1] == 'X')))
}
else
*authentication_key_len = (guint)key_len;
- key_len = compute_ascii_key(encryption_key, (gchar *)sad -> table[i].encryption_key);
+ key_len = compute_ascii_key(encryption_key, sad -> table[i].encryption_key);
if (key_len == -1)
{
/* Bad key; XXX - report this */
gboolean got_cookie = FALSE;
guchar secret[MAX_KEY_SIZE];
guint secret_len = 0;
- gchar *icookie_pfx = "| ICOOKIE: ";
- gchar *enc_key_pfx = "| enc key: ";
+ static const gchar icookie_pfx[] = "| ICOOKIE: ";
+ static const gchar enc_key_pfx[] = "| enc key: ";
gchar *pos, *endpos;
- gint icpfx_len = (gint) strlen(icookie_pfx);
- gint ec_len = (gint) strlen(enc_key_pfx);
gint i;
address null_addr;
unsigned long hexval;
if (log_f) {
while (fgets(line, MAX_PLUTO_LINE, log_f)) {
- if (strncmp(line, icookie_pfx, icpfx_len) == 0) {
+ if (strncmp(line, icookie_pfx, sizeof icookie_pfx - 1) == 0) {
secret_len = 0;
- pos = line + icpfx_len;
+ pos = line + sizeof icookie_pfx - 1;
for (i = 0; i < COOKIE_SIZE; i++) {
hexval = strtoul(pos, &endpos, 16);
if (endpos == pos)
}
if (i == COOKIE_SIZE)
got_cookie = TRUE;
- } else if (strncmp(line, enc_key_pfx, ec_len) == 0) {
- pos = line + ec_len;
+ } else if (strncmp(line, enc_key_pfx, sizeof enc_key_pfx - 1) == 0) {
+ pos = line + sizeof enc_key_pfx - 1;
for (; secret_len < MAX_KEY_SIZE; secret_len++) {
hexval = strtoul(pos, &endpos, 16);
if (endpos == pos)
#ifdef HAVE_LIBGCRYPT
static guint
isakmp_hash_func(gconstpointer c) {
- guint8 *i_cookie = (guint8 *) c;
+ const guint8 *i_cookie = (guint8 *) c;
guint val = 0, keychunk, i;
/* XOR our icookie down to the size of a guint */
D(3,("\tModule: %s", smiModule->name));
+ /* TODO: Check libsmi version at compile time and disable this
+ * workaround for libsmi versions where this problem is fixed.
+ * Currently there is no such version. :-(
+ */
+ if (smiModule->conformance == 1)
+ report_failure("Stopped processing module %s due to "
+ "error(s) to prevent potential crash in libsmi.\n"
+ "Module's conformance level: %d.\n"
+ "See details at: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560325\n",
+ smiModule->name, smiModule->conformance);
+ continue;
+
for (smiNode = smiGetFirstNode(smiModule, SMI_NODEKIND_ANY);
smiNode;
smiNode = smiGetNextNode(smiNode, SMI_NODEKIND_ANY)) {
#endif
/* Capture callback data keys */
-#define E_CAP_IFACE_KEY "cap_iface"
-#define E_CAP_IFACE_IP_KEY "cap_iface_ip"
-#define E_CAP_SNAP_CB_KEY "cap_snap_cb"
-#define E_CAP_LT_OM_KEY "cap_lt_om"
-#define E_CAP_LT_OM_LABEL_KEY "cap_lt_om_label"
+#define E_CAP_IFACE_KEY "cap_iface"
+#define E_CAP_IFACE_IP_KEY "cap_iface_ip"
+#define E_CAP_SNAP_CB_KEY "cap_snap_cb"
+#define E_CAP_LT_OM_KEY "cap_lt_om"
+#define E_CAP_LT_OM_LABEL_KEY "cap_lt_om_label"
#ifdef _WIN32
-#define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
+#define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
#endif
-#define E_CAP_SNAP_SB_KEY "cap_snap_sb"
-#define E_CAP_PROMISC_KEY "cap_promisc"
-#define E_CAP_PCAP_NG_KEY "cap_pcap_ng"
-#define E_CAP_FILT_KEY "cap_filter_te"
-#define E_CAP_FILE_TE_KEY "cap_file_te"
-#define E_CAP_MULTI_FILES_ON_CB_KEY "cap_multi_files_on_cb"
-#define E_CAP_RING_FILESIZE_CB_KEY "cap_ring_filesize_cb"
-#define E_CAP_RING_FILESIZE_SB_KEY "cap_ring_filesize_sb"
-#define E_CAP_RING_FILESIZE_OM_KEY "cap_ring_filesize_om"
-#define E_CAP_FILE_DURATION_CB_KEY "cap_file_duration_cb"
-#define E_CAP_FILE_DURATION_SB_KEY "cap_file_duration_sb"
-#define E_CAP_FILE_DURATION_OM_KEY "cap_file_duration_om"
-#define E_CAP_RING_NBF_CB_KEY "cap_ring_nbf_cb"
-#define E_CAP_RING_NBF_SB_KEY "cap_ring_nbf_sb"
-#define E_CAP_RING_NBF_LB_KEY "cap_ring_nbf_lb"
-#define E_CAP_STOP_FILES_CB_KEY "cap_stop_files_cb"
-#define E_CAP_STOP_FILES_SB_KEY "cap_stop_files_sb"
-#define E_CAP_STOP_FILES_LB_KEY "cap_stop_files_lb"
-#define E_CAP_SYNC_KEY "cap_sync"
-#define E_CAP_AUTO_SCROLL_KEY "cap_auto_scroll"
-#define E_CAP_HIDE_INFO_KEY "cap_hide_info"
-#define E_CAP_STOP_PACKETS_CB_KEY "cap_stop_packets_cb"
-#define E_CAP_STOP_PACKETS_SB_KEY "cap_stop_packets_sb"
-#define E_CAP_STOP_PACKETS_LB_KEY "cap_stop_packets_lb"
-#define E_CAP_STOP_FILESIZE_CB_KEY "cap_stop_filesize_cb"
-#define E_CAP_STOP_FILESIZE_SB_KEY "cap_stop_filesize_sb"
-#define E_CAP_STOP_FILESIZE_OM_KEY "cap_stop_filesize_om"
-#define E_CAP_STOP_DURATION_CB_KEY "cap_stop_duration_cb"
-#define E_CAP_STOP_DURATION_SB_KEY "cap_stop_duration_sb"
-#define E_CAP_STOP_DURATION_OM_KEY "cap_stop_duration_om"
-#define E_CAP_M_RESOLVE_KEY "cap_m_resolve"
-#define E_CAP_N_RESOLVE_KEY "cap_n_resolve"
-#define E_CAP_T_RESOLVE_KEY "cap_t_resolve"
+#define E_CAP_SNAP_SB_KEY "cap_snap_sb"
+#define E_CAP_PROMISC_KEY "cap_promisc"
+#define E_CAP_PCAP_NG_KEY "cap_pcap_ng"
+#define E_CAP_FILT_KEY "cap_filter_te"
+#define E_CAP_FILE_TE_KEY "cap_file_te"
+#define E_CAP_MULTI_FILES_ON_CB_KEY "cap_multi_files_on_cb"
+#define E_CAP_RING_FILESIZE_CB_KEY "cap_ring_filesize_cb"
+#define E_CAP_RING_FILESIZE_SB_KEY "cap_ring_filesize_sb"
+#define E_CAP_RING_FILESIZE_CBX_KEY "cap_ring_filesize_cbx"
+#define E_CAP_FILE_DURATION_CB_KEY "cap_file_duration_cb"
+#define E_CAP_FILE_DURATION_SB_KEY "cap_file_duration_sb"
+#define E_CAP_FILE_DURATION_CBX_KEY "cap_file_duration_cbx"
+#define E_CAP_RING_NBF_CB_KEY "cap_ring_nbf_cb"
+#define E_CAP_RING_NBF_SB_KEY "cap_ring_nbf_sb"
+#define E_CAP_RING_NBF_LB_KEY "cap_ring_nbf_lb"
+#define E_CAP_STOP_FILES_CB_KEY "cap_stop_files_cb"
+#define E_CAP_STOP_FILES_SB_KEY "cap_stop_files_sb"
+#define E_CAP_STOP_FILES_LB_KEY "cap_stop_files_lb"
+#define E_CAP_SYNC_KEY "cap_sync"
+#define E_CAP_AUTO_SCROLL_KEY "cap_auto_scroll"
+#define E_CAP_HIDE_INFO_KEY "cap_hide_info"
+#define E_CAP_STOP_PACKETS_CB_KEY "cap_stop_packets_cb"
+#define E_CAP_STOP_PACKETS_SB_KEY "cap_stop_packets_sb"
+#define E_CAP_STOP_PACKETS_LB_KEY "cap_stop_packets_lb"
+#define E_CAP_STOP_FILESIZE_CB_KEY "cap_stop_filesize_cb"
+#define E_CAP_STOP_FILESIZE_SB_KEY "cap_stop_filesize_sb"
+#define E_CAP_STOP_FILESIZE_CBX_KEY "cap_stop_filesize_cbx"
+#define E_CAP_STOP_DURATION_CB_KEY "cap_stop_duration_cb"
+#define E_CAP_STOP_DURATION_SB_KEY "cap_stop_duration_sb"
+#define E_CAP_STOP_DURATION_CBX_KEY "cap_stop_duration_cbx"
+#define E_CAP_M_RESOLVE_KEY "cap_m_resolve"
+#define E_CAP_N_RESOLVE_KEY "cap_n_resolve"
+#define E_CAP_T_RESOLVE_KEY "cap_t_resolve"
#ifdef HAVE_PCAP_REMOTE
-#define E_CAP_IFTYPE_CB_KEY "cap_iftype_cb"
-#define E_CAP_IF_LIST_KEY "cap_if_list"
-#define E_CAP_DATATX_UDP_CB_KEY "cap_datatx_udp_cb"
-#define E_CAP_NOCAP_RPCAP_CB_KEY "cap_nocap_rpcap_cb"
-#define E_CAP_REMOTE_DIALOG_PTR_KEY "cap_remote_dialog"
-#define E_CAP_REMOTE_CALLER_PTR_KEY "cap_remote_caller"
-#define E_REMOTE_HOST_TE_KEY "cap_remote_host"
-#define E_REMOTE_PORT_TE_KEY "cap_remote_port"
-#define E_REMOTE_AUTH_NULL_KEY "cap_remote_auth_null"
-#define E_REMOTE_AUTH_PASSWD_KEY "cap_remote_auth_passwd"
-#define E_REMOTE_USERNAME_LB_KEY "cap_remote_username_lb"
-#define E_REMOTE_USERNAME_TE_KEY "cap_remote_username_te"
-#define E_REMOTE_PASSWD_LB_KEY "cap_remote_passwd_lb"
-#define E_REMOTE_PASSWD_TE_KEY "cap_remote_passwd_te"
-#define E_CAP_OM_IFTYPE_VALUE_KEY "cap_om_iftype_value"
-#define E_CAP_OM_PREV_IFTYPE_VALUE_KEY "cap_om_prev_iftype_value"
-#define E_CAP_OM_IFTYPE_NOUPDATE_KEY "cap_om_iftype_noupdate"
-#define E_OPT_REMOTE_BT_KEY "cap_remote_opt_bt"
-#define E_OPT_REMOTE_DIALOG_PTR_KEY "cap_remote_opt_dialog"
-#define E_OPT_REMOTE_CALLER_PTR_KEY "cap_remote_opt_caller"
+#define E_CAP_IFTYPE_CBX_KEY "cap_iftype_cbx"
+#define E_CAP_IF_LIST_KEY "cap_if_list"
+#define E_CAP_DATATX_UDP_CB_KEY "cap_datatx_udp_cb"
+#define E_CAP_NOCAP_RPCAP_CB_KEY "cap_nocap_rpcap_cb"
+#define E_CAP_REMOTE_DIALOG_PTR_KEY "cap_remote_dialog"
+#define E_CAP_REMOTE_CALLER_PTR_KEY "cap_remote_caller"
+#define E_REMOTE_HOST_TE_KEY "cap_remote_host"
+#define E_REMOTE_PORT_TE_KEY "cap_remote_port"
+#define E_REMOTE_AUTH_NULL_KEY "cap_remote_auth_null"
+#define E_REMOTE_AUTH_PASSWD_KEY "cap_remote_auth_passwd"
+#define E_REMOTE_USERNAME_LB_KEY "cap_remote_username_lb"
+#define E_REMOTE_USERNAME_TE_KEY "cap_remote_username_te"
+#define E_REMOTE_PASSWD_LB_KEY "cap_remote_passwd_lb"
+#define E_REMOTE_PASSWD_TE_KEY "cap_remote_passwd_te"
+#define E_CAP_CBX_IFTYPE_VALUE_KEY "cap_cbx_iftype_value"
+#define E_CAP_CBX_PREV_IFTYPE_VALUE_KEY "cap_cbx_prev_iftype_value"
+#define E_CAP_CBX_IFTYPE_NOUPDATE_KEY "cap_cbx_iftype_noupdate"
+#define E_OPT_REMOTE_BT_KEY "cap_remote_opt_bt"
+#define E_OPT_REMOTE_DIALOG_PTR_KEY "cap_remote_opt_dialog"
+#define E_OPT_REMOTE_CALLER_PTR_KEY "cap_remote_opt_caller"
#endif
#ifdef HAVE_PCAP_SETSAMPLING
-#define E_CAP_SAMP_NONE_RB_KEY "cap_samp_none_rb"
-#define E_CAP_SAMP_COUNT_RB_KEY "cap_samp_count_rb"
-#define E_CAP_SAMP_COUNT_SB_KEY "cap_samp_count_sb"
-#define E_CAP_SAMP_TIMER_RB_KEY "cap_samp_timer_rb"
-#define E_CAP_SAMP_TIMER_SB_KEY "cap_samp_timer_sb"
+#define E_CAP_SAMP_NONE_RB_KEY "cap_samp_none_rb"
+#define E_CAP_SAMP_COUNT_RB_KEY "cap_samp_count_rb"
+#define E_CAP_SAMP_COUNT_SB_KEY "cap_samp_count_sb"
+#define E_CAP_SAMP_TIMER_RB_KEY "cap_samp_timer_rb"
+#define E_CAP_SAMP_TIMER_SB_KEY "cap_samp_timer_sb"
#endif
-#define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value"
+#define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value"
/*
#ifdef HAVE_PCAP_REMOTE
static void
-select_if_type_cb(GtkComboBox *iftype_cb, gpointer data);
+select_if_type_cb(GtkComboBox *iftype_cbx, gpointer data);
static void
capture_remote_cb(GtkWidget *w, gboolean focus_username);
GSList *curr_ip;
if_addr_t *ip_addr;
#ifdef HAVE_PCAP_REMOTE
- GtkWidget *iftype_cb;
+ GtkWidget *iftype_cbx;
int iftype;
#endif
#ifdef HAVE_AIRPCAP
* Try to get the list of known interfaces.
*/
#ifdef HAVE_PCAP_REMOTE
- iftype_cb = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CB_KEY);
- iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cb),
- E_CAP_OM_IFTYPE_VALUE_KEY));
+ iftype_cbx = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CBX_KEY);
+ iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cbx),
+ E_CAP_CBX_IFTYPE_VALUE_KEY));
if (iftype >= CAPTURE_IFREMOTE)
if_list = (GList *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY);
else
/* create one of the duration options */
/* (and select the matching unit depending on the given value) */
-static GtkWidget *time_unit_option_menu_new(guint32 value) {
+static GtkWidget *time_unit_combo_box_new(guint32 value) {
GtkWidget *unit_combo_box;
int i;
for(i=0;i<MAX_TIME_UNITS;i++){
gtk_combo_box_append_text (GTK_COMBO_BOX (unit_combo_box), time_unit_name[i]);
}
- /* the selected menu item can't be changed, once the option_menu
- is created, so set the matching menu item now */
+ /* the selected combo_box item can't be changed, once the combo_box
+ is created, so set the matching combo_box item now */
/* days */
if(value >= 60 * 60 * 24) {
gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), TIME_UNIT_DAY);
}
/* convert time value from raw to displayed (e.g. 60s -> 1min) */
-static guint32 time_unit_option_menu_convert_value(
+static guint32 time_unit_combo_box_convert_value(
guint32 value)
{
/* days */
}
/* get raw value from unit and value fields */
-static guint32 time_unit_option_menu_get_value(
+static guint32 time_unit_combo_box_get_value(
GtkWidget *unit_combo_box,
guint32 value)
{
/* create one of the size options */
/* (and select the matching unit depending on the given value) */
-static GtkWidget *size_unit_option_menu_new(guint32 value) {
+static GtkWidget *size_unit_combo_box_new(guint32 value) {
GtkWidget *unit_combo_box;
int i;
gtk_combo_box_append_text (GTK_COMBO_BOX (unit_combo_box), size_unit_name[i]);
}
- /* the selected menu item can't be changed, once the option_menu
- is created, so set the matching menu item now */
+ /* the selected combo_box item can't be changed, once the combo_box
+ is created, so set the matching combo_box item now */
/* gigabytes */
if(value >= 1024 * 1024) {
gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), SIZE_UNIT_GIGABYTES);
}
/* convert size value from raw to displayed (e.g. 1024 Bytes -> 1 KB) */
-static guint32 size_unit_option_menu_set_value(
+static guint32 size_unit_combo_box_set_value(
guint32 value)
{
/* gigabytes */
}
/* get raw value from unit and value fields */
-static guint32 size_unit_option_menu_convert_value(
+static guint32 size_unit_combo_box_convert_value(
GtkWidget *unit_combo_box,
guint32 value)
{
#endif
static void
-iftype_combo_add_remote_separators (GtkWidget *iftype_cb)
+iftype_combo_box_add_remote_separators (GtkWidget *iftype_cbx)
{
#if GTK_CHECK_VERSION(2,6,0)
- gtk_combo_box_append_text(GTK_COMBO_BOX(iftype_cb), REMOTE_HOST_SEPARATOR);
- gtk_combo_box_append_text(GTK_COMBO_BOX(iftype_cb), REMOTE_HOST_SEPARATOR);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(iftype_cbx), REMOTE_HOST_SEPARATOR);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(iftype_cbx), REMOTE_HOST_SEPARATOR);
#endif
- gtk_combo_box_append_text(GTK_COMBO_BOX(iftype_cb), "Clear list");
+ gtk_combo_box_append_text(GTK_COMBO_BOX(iftype_cbx), "Clear list");
}
static void
-iftype_combo_add (GtkWidget *iftype_cb)
+iftype_combo_box_add (GtkWidget *iftype_cbx)
{
GtkTreeModel *model;
GtkTreeIter iter;
if (!rh) {
rh = g_malloc0 (sizeof (*rh));
if (g_hash_table_size (remote_host_list) == 0) {
- iftype_combo_add_remote_separators (iftype_cb);
+ iftype_combo_box_add_remote_separators (iftype_cbx);
}
- gtk_combo_box_insert_text(GTK_COMBO_BOX(iftype_cb), pos, global_capture_opts.remote_host);
+ gtk_combo_box_insert_text(GTK_COMBO_BOX(iftype_cbx), pos, global_capture_opts.remote_host);
rh->remote_host = g_strdup (global_capture_opts.remote_host);
create_new = TRUE;
} else {
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(iftype_cb));
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(iftype_cbx));
if (gtk_tree_model_get_iter_first(model, &iter)) {
/* Skip the first entries */
for (i = 0; i < REMOTE_HOST_START; i++)
g_hash_table_insert (remote_host_list, g_strdup (global_capture_opts.remote_host), rh);
}
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_IFTYPE_VALUE_KEY, GINT_TO_POINTER(pos));
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_IFTYPE_NOUPDATE_KEY, GINT_TO_POINTER(1));
- gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cb), pos);
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_IFTYPE_NOUPDATE_KEY, GINT_TO_POINTER(0));
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_VALUE_KEY, GINT_TO_POINTER(pos));
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_NOUPDATE_KEY, GINT_TO_POINTER(1));
+ gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cbx), pos);
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_NOUPDATE_KEY, GINT_TO_POINTER(0));
}
static void
-iftype_combo_add_remote_host (gpointer key, gpointer value _U_, gpointer user)
+iftype_combo_box_add_remote_host (gpointer key, gpointer value _U_, gpointer user_data)
{
- gtk_combo_box_insert_text(GTK_COMBO_BOX(user), REMOTE_HOST_START, key);
+ gtk_combo_box_insert_text(GTK_COMBO_BOX(user_data), REMOTE_HOST_START, key);
if (global_capture_opts.src_type == CAPTURE_IFREMOTE) {
/* Ensure we select the correct entry */
if (strcmp ((char *)key, global_capture_opts.remote_host) == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(user), REMOTE_HOST_START);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(user_data), REMOTE_HOST_START);
}
}
}
static GtkWidget *
iftype_combo_box_new(void)
{
- GtkWidget *iftype_cb;
+ GtkWidget *iftype_cbx;
unsigned int i;
- iftype_cb = gtk_combo_box_new_text();
+ iftype_cbx = gtk_combo_box_new_text();
for (i = 0; i < sizeof(iftype) / sizeof(iftype[0]); i++) {
- gtk_combo_box_append_text(GTK_COMBO_BOX(iftype_cb), iftype[i].name);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(iftype_cbx), iftype[i].name);
}
if (g_hash_table_size (remote_host_list) > 0) {
/* Add remote hosts */
- iftype_combo_add_remote_separators (iftype_cb);
- g_hash_table_foreach (remote_host_list, iftype_combo_add_remote_host, iftype_cb);
+ iftype_combo_box_add_remote_separators (iftype_cbx);
+ g_hash_table_foreach (remote_host_list, iftype_combo_box_add_remote_host, iftype_cbx);
}
if (global_capture_opts.src_type == CAPTURE_IFLOCAL) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cb), CAPTURE_IFLOCAL);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cbx), CAPTURE_IFLOCAL);
} else {
- int iftype = gtk_combo_box_get_active(GTK_COMBO_BOX(iftype_cb));
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_IFTYPE_VALUE_KEY, GINT_TO_POINTER(iftype));
+ int iftype = gtk_combo_box_get_active(GTK_COMBO_BOX(iftype_cbx));
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_VALUE_KEY, GINT_TO_POINTER(iftype));
}
- g_signal_connect(iftype_cb, "changed", G_CALLBACK(select_if_type_cb), NULL);
+ g_signal_connect(iftype_cbx, "changed", G_CALLBACK(select_if_type_cb), NULL);
- return iftype_cb;
+ return iftype_cbx;
}
#if GTK_CHECK_VERSION(2,6,0)
static void
update_interface_list()
{
- GtkWidget *if_cb, *iftype_cb, *remote_bt;
+ GtkWidget *if_cb, *iftype_cbx, *remote_bt;
GList *if_list, *combo_list;
int iftype, prev_iftype, err;
gchar *err_str;
return;
if_cb = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- iftype_cb = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CB_KEY);
- remote_bt = g_object_get_data(G_OBJECT(iftype_cb), E_OPT_REMOTE_BT_KEY);
- iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cb),
- E_CAP_OM_IFTYPE_VALUE_KEY));
+ iftype_cbx = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CBX_KEY);
+ remote_bt = g_object_get_data(G_OBJECT(iftype_cbx), E_OPT_REMOTE_BT_KEY);
+ iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cbx),
+ E_CAP_CBX_IFTYPE_VALUE_KEY));
if_list = (GList *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY);
if (if_list) {
if (iftype >= CAPTURE_IFREMOTE) {
/* Fall back to previous interface list */
- simple_dialog_set_cb(dialog, error_list_remote_interface_cb, iftype_cb);
- prev_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cb),
- E_CAP_OM_PREV_IFTYPE_VALUE_KEY));
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_IFTYPE_VALUE_KEY, GINT_TO_POINTER(prev_iftype));
+ simple_dialog_set_cb(dialog, error_list_remote_interface_cb, iftype_cbx);
+ prev_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cbx),
+ E_CAP_CBX_PREV_IFTYPE_VALUE_KEY));
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_VALUE_KEY, GINT_TO_POINTER(prev_iftype));
return;
}
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), "");
} else if (iftype == CAPTURE_IFREMOTE) {
/* New remote interface */
- iftype_combo_add (iftype_cb);
+ iftype_combo_box_add (iftype_cbx);
}
combo_list = build_capture_combo_list(if_list, TRUE);
gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
capture_remote_ok_cb(GtkWidget *win _U_, GtkWidget *remote_w)
{
GtkWidget *host_te, *port_te, *auth_pwd_rb, *username_te, *passwd_te,
- *auth_null_rb, *auth_passwd_rb, *iftype_cb;
+ *auth_null_rb, *auth_passwd_rb, *iftype_cbx;
int prev_iftype;
if (remote_w == NULL)
passwd_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_PASSWD_TE_KEY);
auth_null_rb = (GtkWidget *) g_object_get_data(G_OBJECT(remote_w), E_REMOTE_AUTH_NULL_KEY);
auth_passwd_rb = (GtkWidget *) g_object_get_data(G_OBJECT(remote_w), E_REMOTE_AUTH_PASSWD_KEY);
- iftype_cb = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CB_KEY);
- prev_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cb),
- E_CAP_OM_IFTYPE_VALUE_KEY));
+ iftype_cbx = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CBX_KEY);
+ prev_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cbx),
+ E_CAP_CBX_IFTYPE_VALUE_KEY));
g_free(global_capture_opts.remote_host);
global_capture_opts.remote_host = g_strdup(gtk_entry_get_text(GTK_ENTRY(host_te)));
global_capture_opts.auth_password =
g_strdup(gtk_entry_get_text(GTK_ENTRY(passwd_te)));
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_PREV_IFTYPE_VALUE_KEY,
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_PREV_IFTYPE_VALUE_KEY,
GINT_TO_POINTER(prev_iftype));
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_IFTYPE_VALUE_KEY,
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_VALUE_KEY,
GINT_TO_POINTER(CAPTURE_IFREMOTE));
window_destroy(GTK_WIDGET(remote_w));
static void
capture_remote_cancel_cb(GtkWidget *win, gpointer data)
{
- GtkWidget *iftype_cb;
+ GtkWidget *iftype_cbx;
int old_iftype;
- iftype_cb = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CB_KEY);
- old_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cb),
- E_CAP_OM_PREV_IFTYPE_VALUE_KEY));
- gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cb), old_iftype);
+ iftype_cbx = g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CBX_KEY);
+ old_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cbx),
+ E_CAP_CBX_PREV_IFTYPE_VALUE_KEY));
+ gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cbx), old_iftype);
window_cancel_button_cb (win, data);
}
*file_fr, *file_vb,
*file_hb, *file_bt, *file_lb, *file_te,
*multi_tb, *multi_files_on_cb,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
- *file_duration_cb, *file_duration_sb, *file_duration_om,
+ *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_cbx,
+ *file_duration_cb, *file_duration_sb, *file_duration_cbx,
*ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
*stop_files_cb, *stop_files_sb, *stop_files_lb,
*limit_fr, *limit_vb, *limit_tb,
*stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
+ *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_cbx,
+ *stop_duration_cb, *stop_duration_sb, *stop_duration_cbx,
*display_fr, *display_vb,
*sync_cb, *auto_scroll_cb, *hide_info_cb,
GtkWidget *decryption_cb;
#endif
#ifdef HAVE_PCAP_REMOTE
- GtkWidget *iftype_cb;
+ GtkWidget *iftype_cbx;
GtkWidget *remote_bt;
#endif
GtkTooltips *tooltips;
remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
}
- iftype_cb = iftype_combo_box_new();
+ iftype_cbx = iftype_combo_box_new();
#if GTK_CHECK_VERSION(2,6,0)
- gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (iftype_cb),
+ gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (iftype_cbx),
iftype_combo_is_separator, NULL, NULL);
#endif
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CB_KEY, iftype_cb);
- gtk_tooltips_set_tip(tooltips, iftype_cb,
+ g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CBX_KEY, iftype_cbx);
+ gtk_tooltips_set_tip(tooltips, iftype_cbx,
"Choose to capture from local or remote interfaces.", NULL);
- gtk_box_pack_start(GTK_BOX(if_hb), iftype_cb, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(if_hb), iftype_cbx, FALSE, FALSE, 0);
#endif
if_cb = gtk_combo_new();
/* Both the callback and the data are global */
g_signal_connect(remote_bt,"clicked", G_CALLBACK(options_remote_cb),NULL);
- g_object_set_data(G_OBJECT(iftype_cb), E_OPT_REMOTE_BT_KEY, remote_bt);
+ g_object_set_data(G_OBJECT(iftype_cbx), E_OPT_REMOTE_BT_KEY, remote_bt);
if (global_capture_opts.src_type == CAPTURE_IFREMOTE) {
gtk_widget_set_sensitive(remote_bt, TRUE);
gtk_widget_set_size_request(ring_filesize_sb, 80, -1);
gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_sb, 1, 2, row, row+1);
- ring_filesize_om = size_unit_option_menu_new(global_capture_opts.autostop_filesize);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_om, 2, 3, row, row+1);
+ ring_filesize_cbx = size_unit_combo_box_new(global_capture_opts.autostop_filesize);
+ gtk_table_attach_defaults(GTK_TABLE(multi_tb), ring_filesize_cbx, 2, 3, row, row+1);
- value = size_unit_option_menu_set_value(global_capture_opts.autostop_filesize);
+ value = size_unit_combo_box_set_value(global_capture_opts.autostop_filesize);
gtk_adjustment_set_value(ring_filesize_adj, (gfloat) value);
row++;
gtk_widget_set_size_request(file_duration_sb, 80, -1);
gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_sb, 1, 2, row, row+1);
- file_duration_om = time_unit_option_menu_new(global_capture_opts.file_duration);
- gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_om, 2, 3, row, row+1);
+ file_duration_cbx = time_unit_combo_box_new(global_capture_opts.file_duration);
+ gtk_table_attach_defaults(GTK_TABLE(multi_tb), file_duration_cbx, 2, 3, row, row+1);
- value = time_unit_option_menu_convert_value(global_capture_opts.file_duration);
+ value = time_unit_combo_box_convert_value(global_capture_opts.file_duration);
gtk_adjustment_set_value(file_duration_adj, (gfloat) value);
row++;
gtk_widget_set_size_request(stop_filesize_sb, 80, -1);
gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_sb, 1, 2, row, row+1);
- stop_filesize_om = size_unit_option_menu_new(global_capture_opts.autostop_filesize);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_om, 2, 3, row, row+1);
+ stop_filesize_cbx = size_unit_combo_box_new(global_capture_opts.autostop_filesize);
+ gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_filesize_cbx, 2, 3, row, row+1);
- value = size_unit_option_menu_set_value(global_capture_opts.autostop_filesize);
+ value = size_unit_combo_box_set_value(global_capture_opts.autostop_filesize);
gtk_adjustment_set_value(stop_filesize_adj, (gfloat) value);
row++;
gtk_widget_set_size_request(stop_duration_sb, 80, -1);
gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_sb, 1, 2, row, row+1);
- stop_duration_om = time_unit_option_menu_new(global_capture_opts.autostop_duration);
- gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_om, 2, 3, row, row+1);
+ stop_duration_cbx = time_unit_combo_box_new(global_capture_opts.autostop_duration);
+ gtk_table_attach_defaults(GTK_TABLE(limit_tb), stop_duration_cbx, 2, 3, row, row+1);
- value = time_unit_option_menu_convert_value(global_capture_opts.autostop_duration);
+ value = time_unit_combo_box_convert_value(global_capture_opts.autostop_duration);
gtk_adjustment_set_value(stop_duration_adj, (gfloat) value);
row++;
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_NBF_LB_KEY, ringbuffer_nbf_lb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_CB_KEY, ring_filesize_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_SB_KEY, ring_filesize_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_OM_KEY, ring_filesize_om);
+ g_object_set_data(G_OBJECT(cap_open_w), E_CAP_RING_FILESIZE_CBX_KEY, ring_filesize_cbx);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_CB_KEY, file_duration_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_SB_KEY, file_duration_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_OM_KEY, file_duration_om);
+ g_object_set_data(G_OBJECT(cap_open_w), E_CAP_FILE_DURATION_CBX_KEY, file_duration_cbx);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_SYNC_KEY, sync_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_AUTO_SCROLL_KEY, auto_scroll_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_HIDE_INFO_KEY, hide_info_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_PACKETS_LB_KEY, stop_packets_lb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_CB_KEY, stop_filesize_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_SB_KEY, stop_filesize_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_OM_KEY, stop_filesize_om);
+ g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILESIZE_CBX_KEY, stop_filesize_cbx);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_CB_KEY, stop_duration_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_SB_KEY, stop_duration_sb);
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_OM_KEY, stop_duration_om);
+ g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_DURATION_CBX_KEY, stop_duration_cbx);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_CB_KEY, stop_files_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_SB_KEY, stop_files_sb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_STOP_FILES_LB_KEY, stop_files_lb);
/* user selected an interface type (local/remote), convert to internal value) */
static void
-select_if_type_cb(GtkComboBox *iftype_cb, gpointer data _U_)
+select_if_type_cb(GtkComboBox *iftype_cbx, gpointer data _U_)
{
- int new_iftype = gtk_combo_box_get_active(GTK_COMBO_BOX(iftype_cb));
- int old_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cb),
- E_CAP_OM_IFTYPE_VALUE_KEY));
- int no_update = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cb),
- E_CAP_OM_IFTYPE_NOUPDATE_KEY));
+ int new_iftype = gtk_combo_box_get_active(GTK_COMBO_BOX(iftype_cbx));
+ int old_iftype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cbx),
+ E_CAP_CBX_IFTYPE_VALUE_KEY));
+ int no_update = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cbx),
+ E_CAP_CBX_IFTYPE_NOUPDATE_KEY));
gint num_remote = g_hash_table_size (remote_host_list);
if (new_iftype == CAPTURE_IFREMOTE) {
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_PREV_IFTYPE_VALUE_KEY,
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_PREV_IFTYPE_VALUE_KEY,
GINT_TO_POINTER(old_iftype));
- capture_remote_cb(GTK_WIDGET(iftype_cb), FALSE);
+ capture_remote_cb(GTK_WIDGET(iftype_cbx), FALSE);
} else if (new_iftype != old_iftype) {
if (new_iftype > CAPTURE_IFREMOTE) {
#if GTK_CHECK_VERSION(2,6,0)
- if (new_iftype == num_remote + 4) {
+ if (new_iftype == num_remote + 4)
#else
- if (new_iftype == num_remote + 2) {
+ if (new_iftype == num_remote + 2)
#endif
+ {
/* The user selected the "Clear list" entry */
new_iftype = CAPTURE_IFLOCAL;
- gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cb), new_iftype);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(iftype_cbx), new_iftype);
g_hash_table_foreach_remove (remote_host_list, free_remote_host, NULL);
num_remote += 3;
while (num_remote--) /* Remove separator lines and "Clear" item */
- gtk_combo_box_remove_text (iftype_cb, 2);
+ gtk_combo_box_remove_text (iftype_cbx, 2);
} else {
struct remote_host *rh;
gchar *string;
#if GTK_CHECK_VERSION(2,6,0)
- string = gtk_combo_box_get_active_text (GTK_COMBO_BOX(iftype_cb));
+ string = gtk_combo_box_get_active_text (GTK_COMBO_BOX(iftype_cbx));
#else
GtkTreeModel *model;
GtkTreeIter iter;
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(iftype_cb));
- gtk_combo_box_get_active_iter(GTK_COMBO_BOX(iftype_cb), &iter);
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(iftype_cbx));
+ gtk_combo_box_get_active_iter(GTK_COMBO_BOX(iftype_cbx), &iter);
gtk_tree_model_get(model, &iter, 0, &string, -1);
#endif
rh = g_hash_table_lookup (remote_host_list, string);
global_capture_opts.auth_type = rh->auth_type;
if (global_capture_opts.auth_type == CAPTURE_AUTH_PWD && strlen(rh->auth_username) == 0) {
/* Empty username, ask for one */
- capture_remote_cb(GTK_WIDGET(iftype_cb), TRUE);
+ capture_remote_cb(GTK_WIDGET(iftype_cbx), TRUE);
no_update = TRUE;
} else {
/* Already entered username and password */
}
}
if (!no_update) {
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_PREV_IFTYPE_VALUE_KEY,
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_PREV_IFTYPE_VALUE_KEY,
GINT_TO_POINTER(old_iftype));
- g_object_set_data(G_OBJECT(iftype_cb), E_CAP_OM_IFTYPE_VALUE_KEY,
+ g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_VALUE_KEY,
GINT_TO_POINTER(new_iftype));
update_interface_list();
}
*file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
*linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb,
*stop_packets_cb, *stop_packets_sb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
- *file_duration_cb, *file_duration_sb, *file_duration_om,
+ *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_cbx,
+ *stop_duration_cb, *stop_duration_sb, *stop_duration_cbx,
+ *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_cbx,
+ *file_duration_cb, *file_duration_sb, *file_duration_cbx,
*stop_files_cb, *stop_files_sb,
*m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
#ifdef HAVE_PCAP_REMOTE
- GtkWidget *iftype_cb;
+ GtkWidget *iftype_cbx;
#endif
#ifdef _WIN32
GtkWidget *buffer_size_sb;
gchar *dirname;
gint32 tmp;
- if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
+ if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
#ifdef HAVE_PCAP_REMOTE
- iftype_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFTYPE_CB_KEY);
+ iftype_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFTYPE_CBX_KEY);
#endif
- snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
- snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
- linktype_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_LT_OM_KEY);
+ snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
+ snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
+ linktype_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_LT_OM_KEY);
#ifdef _WIN32
buffer_size_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_BUFFER_SIZE_SB_KEY);
#endif
promisc_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_PROMISC_KEY);
pcap_ng_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_PCAP_NG_KEY);
- filter_cm = g_object_get_data(G_OBJECT(top_level), E_CFILTER_CM_KEY);
- filter_te = GTK_COMBO(filter_cm)->entry;
- file_te = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_TE_KEY);
+ filter_cm = g_object_get_data(G_OBJECT(top_level), E_CFILTER_CM_KEY);
+ filter_te = GTK_COMBO(filter_cm)->entry;
+ file_te = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_TE_KEY);
multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
- ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
- ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
- ring_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_OM_KEY);
- file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
- file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
- file_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_OM_KEY);
+ ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
+ ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
+ ring_filesize_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CBX_KEY);
+ file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
+ file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
+ file_duration_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CBX_KEY);
sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
- stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
- stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
- stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
- stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
- stop_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_OM_KEY);
- stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
- stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
- stop_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_OM_KEY);
+ stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
+ stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
+ stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
+ stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
+ stop_filesize_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CBX_KEY);
+ stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
+ stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
+ stop_duration_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CBX_KEY);
stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
m_resolv_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_M_RESOLVE_KEY);
#ifdef HAVE_PCAP_REMOTE
global_capture_opts.src_type = (capture_source)
- GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cb), E_CAP_OM_IFTYPE_VALUE_KEY));
+ GPOINTER_TO_INT(g_object_get_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_VALUE_KEY));
if (global_capture_opts.src_type > CAPTURE_IFREMOTE)
global_capture_opts.src_type = CAPTURE_IFREMOTE;
#endif
global_capture_opts.autostop_duration =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_duration_sb));
global_capture_opts.autostop_duration =
- time_unit_option_menu_get_value(stop_duration_om, global_capture_opts.autostop_duration);
+ time_unit_combo_box_get_value(stop_duration_cbx, global_capture_opts.autostop_duration);
}
global_capture_opts.real_time_mode =
global_capture_opts.file_duration =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(file_duration_sb));
global_capture_opts.file_duration =
- time_unit_option_menu_get_value(file_duration_om, global_capture_opts.file_duration);
+ time_unit_combo_box_get_value(file_duration_cbx, global_capture_opts.file_duration);
}
global_capture_opts.has_autostop_files =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb));
if (global_capture_opts.has_autostop_filesize) {
tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ring_filesize_sb));
- tmp = size_unit_option_menu_convert_value(ring_filesize_om, tmp);
+ tmp = size_unit_combo_box_convert_value(ring_filesize_cbx, tmp);
if(tmp != 0) {
global_capture_opts.autostop_filesize = tmp;
} else {
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb));
if (global_capture_opts.has_autostop_filesize) {
tmp = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_filesize_sb));
- tmp = size_unit_option_menu_convert_value(stop_filesize_om, tmp);
+ tmp = size_unit_combo_box_convert_value(stop_filesize_cbx, tmp);
if(tmp != 0) {
global_capture_opts.autostop_filesize = tmp;
} else {
GtkWidget *if_cb,
*snap_cb, *snap_sb,
*multi_files_on_cb, *ringbuffer_nbf_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_lb,
- *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_om,
- *file_duration_cb, *file_duration_sb, *file_duration_om,
+ *ring_filesize_cb, *ring_filesize_sb, *ring_filesize_cbx,
+ *file_duration_cb, *file_duration_sb, *file_duration_cbx,
*sync_cb, *auto_scroll_cb, *hide_info_cb,
*stop_packets_cb, *stop_packets_sb, *stop_packets_lb,
- *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_om,
- *stop_duration_cb, *stop_duration_sb, *stop_duration_om,
+ *stop_filesize_cb, *stop_filesize_sb, *stop_filesize_cbx,
+ *stop_duration_cb, *stop_duration_sb, *stop_duration_cbx,
*stop_files_cb, *stop_files_sb, *stop_files_lb;
if_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_IFACE_KEY);
snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_CB_KEY);
snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SNAP_SB_KEY);
- multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
+ multi_files_on_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_MULTI_FILES_ON_CB_KEY);
ringbuffer_nbf_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_CB_KEY);
ringbuffer_nbf_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_SB_KEY);
ringbuffer_nbf_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_NBF_LB_KEY);
- ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
- ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
- ring_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_OM_KEY);
- file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
- file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
- file_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_OM_KEY);
+ ring_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CB_KEY);
+ ring_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_SB_KEY);
+ ring_filesize_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_RING_FILESIZE_CBX_KEY);
+ file_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CB_KEY);
+ file_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_SB_KEY);
+ file_duration_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_FILE_DURATION_CBX_KEY);
sync_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_SYNC_KEY);
auto_scroll_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_AUTO_SCROLL_KEY);
hide_info_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_HIDE_INFO_KEY);
stop_packets_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_CB_KEY);
stop_packets_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_SB_KEY);
stop_packets_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_PACKETS_LB_KEY);
- stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
- stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
- stop_filesize_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_OM_KEY);
- stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
- stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
- stop_duration_om = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_OM_KEY);
+ stop_filesize_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CB_KEY);
+ stop_filesize_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_SB_KEY);
+ stop_filesize_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILESIZE_CBX_KEY);
+ stop_duration_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CB_KEY);
+ stop_duration_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_SB_KEY);
+ stop_duration_cbx = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_DURATION_CBX_KEY);
stop_files_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_CB_KEY);
stop_files_sb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_SB_KEY);
stop_files_lb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CAP_STOP_FILES_LB_KEY);
gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),
+ gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cbx),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ring_filesize_cb)));
/* The ring duration spinbox is sensitive if the "Next capture file
gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),
+ gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cbx),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_duration_cb)));
gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cbx), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(stop_files_sb),
gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cb), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_sb),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_om),FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(ring_filesize_cbx),FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cb), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(file_duration_sb),FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(file_duration_om),FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(file_duration_cbx),FALSE);
/* The maximum file size spinbox is sensitive if the "Stop capture
after N kilobytes" checkbox is on. */
gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cb), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_sb),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_om),
+ gtk_widget_set_sensitive(GTK_WIDGET(stop_filesize_cbx),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_filesize_cb)));
gtk_widget_set_sensitive(GTK_WIDGET(stop_files_cb), FALSE);
after N seconds" checkbox is on. */
gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_sb),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
- gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_om),
+ gtk_widget_set_sensitive(GTK_WIDGET(stop_duration_cbx),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_duration_cb)));
}
GtkWidget *filter_tb;
GList *dfilter_list = NULL;
GtkTooltips *tooltips;
- GtkToolItem *filter_bt, *filter_add_expr_bt, *filter_reset,
- *filter_apply, *item;
+ GtkToolItem *filter_bt, *filter_add_expr_bt, *filter_reset;
+ GtkToolItem *filter_apply, *item;
/* Display filter construct dialog has an Apply button, and "OK" not
gtk_toolbar_set_orientation(GTK_TOOLBAR(filter_tb),
GTK_ORIENTATION_HORIZONTAL);
- g_object_set_data(G_OBJECT(top_level), E_TB_FILTER_KEY, filter_tb);
+ g_object_set_data(G_OBJECT(top_level), E_TB_FILTER_KEY, filter_tb);
gtk_widget_show(filter_tb);
/* Create the "Filter:" button */
- filter_bt = gtk_tool_button_new_from_stock (WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
+ filter_bt = gtk_tool_button_new_from_stock (WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &args);
gtk_widget_show(GTK_WIDGET (filter_bt));
g_object_set_data(G_OBJECT(top_level), E_FILT_BT_PTR_KEY, filter_bt);
- gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
- filter_bt,
- -1);
- gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_bt),
- "Open the \"Display Filter\" dialog, to edit/apply filters",
- "Private");
+ gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
+ filter_bt,
+ -1);
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_bt),
+ "Open the \"Display Filter\" dialog, to edit/apply filters",
+ "Private");
/* Create the filter combobox */
filter_cm = gtk_combo_new();
gtk_widget_set_size_request(filter_cm, 400, -1);
gtk_widget_show(filter_cm);
- item = gtk_tool_item_new ();
- gtk_container_add (GTK_CONTAINER (item), filter_cm);
- gtk_widget_show (GTK_WIDGET (item));
+ item = gtk_tool_item_new ();
+ gtk_container_add (GTK_CONTAINER (item), filter_cm);
+ gtk_widget_show (GTK_WIDGET (item));
- gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
- item,
- -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
+ item,
+ -1);
/* setting a tooltip for a combobox will do nothing, so add it to the corresponding text entry */
gtk_tooltips_set_tip(tooltips, filter_te,
"Enter a display filter, or choose one of your recently used filters. "
- "The background color of this field is changed by a continuous syntax check (green is valid, red is invalid, yellow may have unexpected results).",
+ "The background color of this field is changed by a continuous syntax check "
+ "(green is valid, red is invalid, yellow may have unexpected results).",
NULL);
/* Create the "Add Expression..." button, to pop up a dialog
g_signal_connect(filter_add_expr_bt, "clicked", G_CALLBACK(filter_add_expr_bt_cb), filter_tb);
gtk_widget_show(GTK_WIDGET(filter_add_expr_bt));
- gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
- filter_add_expr_bt,
- -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
+ filter_add_expr_bt,
+ -1);
- gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_add_expr_bt),
- "Add an expression to this filter string",
- "Private");
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_add_expr_bt),
+ "Add an expression to this filter string",
+ "Private");
/* Create the "Clear" button */
filter_reset = gtk_tool_button_new_from_stock(WIRESHARK_STOCK_CLEAR_EXPRESSION);
g_object_set_data(G_OBJECT(filter_reset), E_DFILTER_TE_KEY, filter_te);
g_signal_connect(filter_reset, "clicked", G_CALLBACK(filter_reset_cb), NULL);
gtk_widget_show(GTK_WIDGET(filter_reset));
- gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
- filter_reset,
- -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
+ filter_reset,
+ -1);
- gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_reset),
- "Clear this filter string and update the display",
- "Private");
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_reset),
+ "Clear this filter string and update the display",
+ "Private");
/* Create the "Apply" button */
filter_apply = gtk_tool_button_new_from_stock(WIRESHARK_STOCK_APPLY_EXPRESSION);
g_signal_connect(filter_apply, "clicked", G_CALLBACK(filter_activate_cb), filter_te);
gtk_widget_show(GTK_WIDGET(filter_apply));
- gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
- filter_apply,
- -1);
+ gtk_toolbar_insert(GTK_TOOLBAR(filter_tb),
+ filter_apply,
+ -1);
- gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_apply),
- "Apply this filter string to the display",
- "Private");
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), GTK_WIDGET(filter_apply),
+ "Apply this filter string to the display",
+ "Private");
/* Sets the text entry widget pointer as the E_DILTER_TE_KEY data
* of any widget that ends up calling a callback which needs
g_list_length(dfilter_list) < prefs.gui_recent_df_entries_max &&
g_list_find_custom(dfilter_list, s, dfilter_entry_match) == NULL) {
- dfilter_list = g_list_append(dfilter_list, s);
- s = NULL;
- g_object_set_data(G_OBJECT(filter_cm), E_DFILTER_FL_KEY, dfilter_list);
- gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), dfilter_list);
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(filter_cm)->entry), g_list_first(dfilter_list)->data);
+ dfilter_list = g_list_append(dfilter_list, s);
+ s = NULL;
+ g_object_set_data(G_OBJECT(filter_cm), E_DFILTER_FL_KEY, dfilter_list);
+ gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), dfilter_list);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(filter_cm)->entry), g_list_first(dfilter_list)->data);
}
g_free(s);
* of the combo box GList to the user's recent file */
void
dfilter_recent_combo_write_all(FILE *rf) {
- GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY);
- GList *dfilter_list = g_object_get_data(G_OBJECT(filter_cm), E_DFILTER_FL_KEY);
- GList *li;
- guint max_count = 0;
+ GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY);
+ GList *dfilter_list = g_object_get_data(G_OBJECT(filter_cm), E_DFILTER_FL_KEY);
+ GList *li;
+ guint max_count = 0;
- /* write all non empty display filter strings to the recent file (until max count) */
- li = g_list_first(dfilter_list);
- while ( li && (max_count++ < prefs.gui_recent_df_entries_max) ) {
- if (strlen(li->data)) {
- fprintf (rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", (char *)li->data);
+ /* write all non empty display filter strings to the recent file (until max count) */
+ li = g_list_first(dfilter_list);
+ while ( li && (max_count++ < prefs.gui_recent_df_entries_max) ) {
+ if (strlen(li->data)) {
+ fprintf (rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", (char *)li->data);
+ }
+ li = li->next;
}
- li = li->next;
- }
}
/* empty the combobox entry field */
void
dfilter_combo_add_empty(void) {
- GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY);
+ GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY);
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(filter_cm)->entry), "");
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(filter_cm)->entry), "");
}
/* add a display filter coming from the user's recent file to the dfilter combo box */
gboolean
dfilter_combo_add_recent(gchar *s) {
- GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY);
- char *dup;
+ GtkWidget *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY);
+ char *dup;
- dup = g_strdup(s);
+ dup = g_strdup(s);
- return dfilter_combo_add(filter_cm, dup);
+ return dfilter_combo_add(filter_cm, dup);
}
/* call cf_filter_packets() and add this filter string to the recent filter list */
gboolean
main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
{
- GtkCombo *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY);
- GList *dfilter_list = g_object_get_data(G_OBJECT(filter_cm), E_DFILTER_FL_KEY);
- gboolean free_filter = TRUE;
- char *s;
- cf_status_t cf_status;
-
- s = g_strdup(dftext);
-
- cf_status = cf_filter_packets(cf, s, force);
- if (!s)
- return (cf_status == CF_OK);
-
- /* GtkCombos don't let us get at their list contents easily, so we maintain
- our own filter list, and feed it to gtk_combo_set_popdown_strings when
- a new filter is added. */
- if (cf_status == CF_OK && strlen(s) > 0) {
- GList *li;
+ GtkCombo *filter_cm = g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY);
+ GList *dfilter_list = g_object_get_data(G_OBJECT(filter_cm), E_DFILTER_FL_KEY);
+ gboolean free_filter = TRUE;
+ char *s;
+ cf_status_t cf_status;
- while ((li = g_list_find_custom(dfilter_list, s, dfilter_entry_match)) != NULL)
- /* Delete old/duplicate entry now. We'll re-add it later */
- dfilter_list = g_list_delete_link(dfilter_list, li);
+ s = g_strdup(dftext);
- /* trim list size first */
- while (g_list_length(dfilter_list) >= prefs.gui_recent_df_entries_max)
- dfilter_list = g_list_delete_link(dfilter_list, g_list_last(dfilter_list));
+ cf_status = cf_filter_packets(cf, s, force);
+ if (!s)
+ return (cf_status == CF_OK);
- free_filter = FALSE;
- /* Push the filter to the front of the list */
- dfilter_list = g_list_prepend(dfilter_list, s);
- g_object_set_data(G_OBJECT(filter_cm), E_DFILTER_FL_KEY, dfilter_list);
- gtk_combo_set_popdown_strings(filter_cm, dfilter_list);
- gtk_entry_set_text(GTK_ENTRY(filter_cm->entry), g_list_first(dfilter_list)->data);
- }
+ /* GtkCombos don't let us get at their list contents easily, so we maintain
+ our own filter list, and feed it to gtk_combo_set_popdown_strings when
+ a new filter is added. */
+ if (cf_status == CF_OK && strlen(s) > 0) {
+ GList *li;
+
+ while ((li = g_list_find_custom(dfilter_list, s, dfilter_entry_match)) != NULL)
+ /* Delete old/duplicate entry now. We'll re-add it later */
+ dfilter_list = g_list_delete_link(dfilter_list, li);
+
+ /* trim list size first */
+ while (g_list_length(dfilter_list) >= prefs.gui_recent_df_entries_max)
+ dfilter_list = g_list_delete_link(dfilter_list, g_list_last(dfilter_list));
+
+ free_filter = FALSE;
+ /* Push the filter to the front of the list */
+ dfilter_list = g_list_prepend(dfilter_list, s);
+ g_object_set_data(G_OBJECT(filter_cm), E_DFILTER_FL_KEY, dfilter_list);
+ gtk_combo_set_popdown_strings(filter_cm, dfilter_list);
+ gtk_entry_set_text(GTK_ENTRY(filter_cm->entry), g_list_first(dfilter_list)->data);
+ }
- if (free_filter)
- g_free(s);
+ if (free_filter)
+ g_free(s);
- return (cf_status == CF_OK);
+ return (cf_status == CF_OK);
}
g_signal_connect(eb, "enter-notify-event", G_CALLBACK(welcome_item_enter_cb), NULL);
g_signal_connect(eb, "leave-notify-event", G_CALLBACK(welcome_item_leave_cb), NULL);
- g_signal_connect(eb, "button-press-event", G_CALLBACK(callback), callback_data);
+ g_signal_connect(eb, "button-release-event", G_CALLBACK(callback), callback_data);
/* icon */
w = gtk_image_new_from_stock(stock_item, GTK_ICON_SIZE_LARGE_TOOLBAR);
capture_prefs_show(void)
{
GtkWidget *main_tb, *main_vb;
- GtkWidget *if_cb, *if_lb, *promisc_cb, *pcap_ng_cb, *sync_cb, *auto_scroll_cb, *show_info_cb;
+ GtkWidget *if_cbxe, *if_lb, *promisc_cb, *pcap_ng_cb, *sync_cb, *auto_scroll_cb, *show_info_cb;
GtkWidget *ifopts_lb, *ifopts_bt;
GList *if_list, *combo_list;
int err;
gtk_misc_set_alignment(GTK_MISC(if_lb), 1.0f, 0.5f);
gtk_widget_show(if_lb);
- if_cb = gtk_combo_new();
+ if_cbxe = gtk_combo_box_entry_new_text();
/*
* XXX - what if we can't get the list?
*/
combo_list = build_capture_combo_list(if_list, FALSE);
free_interface_list(if_list);
if (combo_list != NULL) {
- gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), combo_list);
- free_capture_combo_list(combo_list);
+ GList *combo_entry;
+ for (combo_entry = combo_list; combo_entry != NULL; combo_entry = g_list_next(combo_entry)) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(if_cbxe), combo_entry->data);
+ }
+ }
+ if (prefs.capture_device) {
+ gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(if_cbxe))),
+ prefs.capture_device);
}
- if (prefs.capture_device)
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
- prefs.capture_device);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), if_cb, 1, 2, row, row+1);
+ else if (combo_list != NULL) {
+ gtk_combo_box_set_active(GTK_COMBO_BOX(if_cbxe), 0);
+ }
+ free_capture_combo_list(combo_list);
+
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), if_cbxe, 1, 2, row, row+1);
tooltips_text = "The default interface to be captured from.";
gtk_tooltips_set_tip(tooltips, if_lb, tooltips_text, NULL);
- gtk_tooltips_set_tip(tooltips, GTK_COMBO(if_cb)->entry, tooltips_text, NULL);
- gtk_widget_show(if_cb);
- g_object_set_data(G_OBJECT(main_vb), DEVICE_KEY, if_cb);
+ gtk_tooltips_set_tip(tooltips, gtk_bin_get_child(GTK_BIN(if_cbxe)), tooltips_text, NULL);
+ gtk_widget_show(if_cbxe);
+ g_object_set_data(G_OBJECT(main_vb), DEVICE_KEY, if_cbxe);
row++;
/* Interface properties */
void
capture_prefs_fetch(GtkWidget *w)
{
- GtkWidget *if_cb, *promisc_cb, *pcap_ng_cb, *sync_cb, *auto_scroll_cb, *show_info_cb;
+ GtkWidget *if_cbxe, *promisc_cb, *pcap_ng_cb, *sync_cb, *auto_scroll_cb, *show_info_cb;
gchar *if_text;
- if_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), DEVICE_KEY);
+ if_cbxe = (GtkWidget *)g_object_get_data(G_OBJECT(w), DEVICE_KEY);
promisc_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), PROM_MODE_KEY);
pcap_ng_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), PCAP_NG_KEY);
- sync_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), CAPTURE_REAL_TIME_KEY);
+ sync_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), CAPTURE_REAL_TIME_KEY);
auto_scroll_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), AUTO_SCROLL_KEY);
show_info_cb = (GtkWidget *)g_object_get_data(G_OBJECT(w), SHOW_INFO_KEY);
g_free(prefs.capture_device);
prefs.capture_device = NULL;
}
- if_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry)));
+ if_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(if_cbxe)))));
/* Strip out white space */
g_strstrip(if_text);
/* If there was nothing but white space, treat that as an
if (!hs->show_mac) {
offset += g_snprintf(buffer+offset, MAX_FILTER_LEN-offset, "not mac-lte and ");
}
+ else {
+ offset += g_snprintf(buffer+offset, MAX_FILTER_LEN-offset, "mac-lte and ");
+ }
/* UEId */
offset += g_snprintf(buffer+offset, MAX_FILTER_LEN-offset, "(rlc-lte.ueid == %u) and ", ueid);
import getopt
import traceback
-import lex
-import yacc
+from ply import lex
+from ply import yacc
# OID name -> number conversion table
oid_names = {
+typedef struct {
+ guint32 nframes;
+} _5views_dump_t;
+
static const int wtap_encap[] = {
-1, /* WTAP_ENCAP_UNKNOWN -> unsupported */
CST_5VW_CAPTURE_ETH_FILEID, /* WTAP_ENCAP_ETHERNET -> Ehernet Ethernet */
failure */
gboolean _5views_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
{
+ _5views_dump_t *_5views;
/* We can't fill in all the fields in the file header, as we
haven't yet written any packets. As we'll have to rewrite
/* This is a 5Views file */
wdh->subtype_write = _5views_dump;
wdh->subtype_close = _5views_dump_close;
- wdh->dump._5views = (_5views_dump_t *)g_malloc(sizeof(_5views_dump_t));
- wdh->dump._5views->nframes = 0;
+ _5views = (_5views_dump_t *)g_malloc(sizeof(_5views_dump_t));
+ wdh->priv = (void *)_5views;
+ _5views->nframes = 0;
return TRUE;
}
const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err)
{
-
+ _5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
size_t nwritten;
static t_5VW_TimeStamped_Header HeaderFrame;
return FALSE;
}
- wdh->dump._5views->nframes ++;
+ _5views->nframes ++;
return TRUE;
}
static gboolean _5views_dump_close(wtap_dumper *wdh, int *err)
{
+ _5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
t_5VW_Capture_Header file_hdr;
size_t nwritten;
file_hdr.HeaderNbFrames.Nb = htoles(1); /* Number of elements */
/* fill in the number of frames saved */
- file_hdr.TramesStockeesInFile = htolel(wdh->dump._5views->nframes);
+ file_hdr.TramesStockeesInFile = htolel(_5views->nframes);
/* Write the file header. */
nwritten = fwrite(&file_hdr, 1, sizeof(t_5VW_Capture_Header), wdh->fh);
guint32 lower;
} airopeek_utime;
+typedef struct {
+ gboolean has_fcs;
+} airopeek9_t;
+
static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean airopeekv9_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static void airopeekv9_close(wtap *wth);
static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err)
{
WTAP_ENCAP_IEEE_802_11_WITH_RADIO
};
#define NUM_AIROPEEK9_ENCAPS (sizeof airopeek9_encap / sizeof airopeek9_encap[0])
+ airopeek9_t *airopeek9;
wtap_file_read_unknown_bytes(&ap_hdr, sizeof(ap_hdr), wth->fh, err);
wth->file_encap = file_encap;
wth->subtype_read = airopeekv9_read;
wth->subtype_seek_read = airopeekv9_seek_read;
- wth->subtype_close = airopeekv9_close;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
- wth->capture.airopeek9 = (airopeek9_t *)g_malloc(sizeof(airopeek9_t));
+ airopeek9 = (airopeek9_t *)g_malloc(sizeof(airopeek9_t));
+ wth->priv = (void *)airopeek9;
switch (mediaSubType) {
case AIROPEEK_V9_NST_ETHERNET:
case AIROPEEK_V9_NST_802_11:
case AIROPEEK_V9_NST_802_11_2:
- wth->capture.airopeek9->has_fcs = FALSE;
+ airopeek9->has_fcs = FALSE;
break;
case AIROPEEK_V9_NST_802_11_WITH_FCS:
- wth->capture.airopeek9->has_fcs = TRUE;
+ airopeek9->has_fcs = TRUE;
break;
}
static gboolean airopeekv9_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
+ airopeek9_t *airopeek9 = (airopeek9_t *)wth->priv;
hdr_info_t hdr_info;
int hdrlen;
double t;
* whether to supply it as an FCS or discard it.
*/
wth->pseudo_header.ieee_802_11 = hdr_info.ieee_802_11;
- if (wth->capture.airopeek9->has_fcs)
+ if (airopeek9->has_fcs)
wth->pseudo_header.ieee_802_11.fcs_len = 4;
else {
wth->pseudo_header.ieee_802_11.fcs_len = 0;
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info)
{
+ airopeek9_t *airopeek9 = (airopeek9_t *)wth->priv;
hdr_info_t hdr_info;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
pseudo_header->ieee_802_11 = hdr_info.ieee_802_11;
- if (wth->capture.airopeek9->has_fcs)
+ if (airopeek9->has_fcs)
pseudo_header->ieee_802_11.fcs_len = 4;
else
pseudo_header->ieee_802_11.fcs_len = 0;
wtap_file_read_expected_bytes(pd, length, wth->random_fh, err);
return TRUE;
}
-
-static void
-airopeekv9_close(wtap *wth)
-{
- g_free(wth->capture.airopeek9);
-}
void init_parse_ascend(void);
void ascend_init_lexer(FILE_T fh);
-int parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr,
+typedef enum {
+ PARSED_RECORD,
+ PARSED_NONRECORD,
+ PARSE_FAILED
+} parse_t;
+parse_t parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr,
ascend_pkthdr *hdr, gint64 *start_of_data);
#endif /* ! __ASCEND_INT_H__ */
start_time = 0; /* we haven't see a date/time yet */
}
-/* Parse the capture file. Return the offset of the next packet, or zero
- if there is none. */
-int
+/* Parse the capture file.
+ Returns:
+ PARSED_RECORD if we got a packet
+ PARSED_NONRECORD if the parser succeeded but didn't see a packet
+ PARSE_FAILED if the parser failed. */
+parse_t
parse_ascend(FILE_T fh, guint8 *pd, struct ascend_phdr *phdr,
ascend_pkthdr *hdr, gint64 *start_of_data)
{
header->len = wirelen;
}
- return 1;
+ return PARSED_RECORD;
}
/* Didn't see any data. Still, perhaps the parser was happy. */
if (retval)
- return 0;
+ return PARSE_FAILED;
else
- return 1;
+ return PARSED_NONRECORD;
}
void
{ ASCEND_PFX_ETHER, "ETHER" },
};
+typedef struct {
+ time_t inittime;
+ int adjusted;
+ gint64 next_packet_seek_start;
+} ascend_t;
+
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_head, guint8 *pd, int len,
int *err, gchar **err_info);
-static void ascend_close(wtap *wth);
/* Seeks to the beginning of the next packet, and returns the
byte offset at which the header for that packet begins.
guint8 buf[ASCEND_MAX_PKT_LEN];
ascend_pkthdr header;
gint64 dummy_seek_start;
+ ascend_t *ascend;
/* We haven't yet allocated a data structure for our private stuff;
set the pointer to null, so that "ascend_seek()" knows not to
fill it in. */
- wth->capture.ascend = NULL;
+ wth->priv = NULL;
offset = ascend_seek(wth, err);
if (offset == -1) {
/* Do a trial parse of the first packet just found to see if we might really have an Ascend file */
init_parse_ascend();
- if (! parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header, &dummy_seek_start)) {
+ if (parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header,
+ &dummy_seek_start) != PARSED_RECORD) {
return 0;
}
wth->snapshot_length = ASCEND_MAX_PKT_LEN;
wth->subtype_read = ascend_read;
wth->subtype_seek_read = ascend_seek_read;
- wth->subtype_close = ascend_close;
- wth->capture.ascend = g_malloc(sizeof(ascend_t));
+ ascend = (ascend_t *)g_malloc(sizeof(ascend_t));
+ wth->priv = (void *)ascend;
/* The first packet we want to read is the one that "ascend_seek()"
just found; start searching for it at the offset at which it
found it. */
- wth->capture.ascend->next_packet_seek_start = offset;
+ ascend->next_packet_seek_start = offset;
/* MAXen and Pipelines report the time since reboot. In order to keep
from reporting packet times near the epoch, we subtract the first
*/
if (fstat(wth->fd, &statbuf) == -1) {
*err = errno;
- g_free(wth->capture.ascend);
+ g_free(ascend);
return -1;
}
- wth->capture.ascend->inittime = statbuf.st_ctime;
- wth->capture.ascend->adjusted = 0;
+ ascend->inittime = statbuf.st_ctime;
+ ascend->adjusted = 0;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
init_parse_ascend();
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
+ ascend_t *ascend = (ascend_t *)wth->priv;
gint64 offset;
guint8 *buf = buffer_start_ptr(wth->frame_buffer);
ascend_pkthdr header;
packet's header, to just after the last packet's header (ie. at the
start of the last packet's data). We have to get past the last
packet's header because we might mistake part of it for a new header. */
- if (file_seek(wth->fh, wth->capture.ascend->next_packet_seek_start,
+ if (file_seek(wth->fh, ascend->next_packet_seek_start,
SEEK_SET, err) == -1)
return FALSE;
offset = ascend_seek(wth, err);
if (offset == -1)
return FALSE;
- if (! parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header, &(wth->capture.ascend->next_packet_seek_start))) {
+ if (parse_ascend(wth->fh, buf, &wth->pseudo_header.ascend, &header,
+ &(ascend->next_packet_seek_start)) != PARSED_RECORD) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
return FALSE;
config_pseudo_header(&wth->pseudo_header);
- if (! wth->capture.ascend->adjusted) {
- wth->capture.ascend->adjusted = 1;
+ if (! ascend->adjusted) {
+ ascend->adjusted = 1;
if (header.start_time != 0) {
/*
* Capture file contained a date and time.
* We do this only if this is the very first packet we've seen -
- * i.e., if "wth->capture.ascend->adjusted" is false - because
+ * i.e., if "ascend->adjusted" is false - because
* if we get a date and time after the first packet, we can't
* go back and adjust the time stamps of the packets we've already
* processed, and basing the time stamps of this and following
* ctime of the capture file means times before this and after
* this can't be compared.
*/
- wth->capture.ascend->inittime = header.start_time;
+ ascend->inittime = header.start_time;
}
- if (wth->capture.ascend->inittime > header.secs)
- wth->capture.ascend->inittime -= header.secs;
+ if (ascend->inittime > header.secs)
+ ascend->inittime -= header.secs;
}
- wth->phdr.ts.secs = header.secs + wth->capture.ascend->inittime;
+ wth->phdr.ts.secs = header.secs + ascend->inittime;
wth->phdr.ts.nsecs = header.usecs * 1000;
wth->phdr.caplen = header.caplen;
wth->phdr.len = header.len;
}
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
- union wtap_pseudo_header *pseudo_head, guint8 *pd, int len,
+ union wtap_pseudo_header *pseudo_head, guint8 *pd, int len _U_,
int *err, gchar **err_info)
{
- /* don't care for length. */
- (void) len;
+ ascend_t *ascend = (ascend_t *)wth->priv;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- if (! parse_ascend(wth->random_fh, pd, &pseudo_head->ascend, NULL, &(wth->capture.ascend->next_packet_seek_start))) {
+ if (parse_ascend(wth->random_fh, pd, &pseudo_head->ascend, NULL,
+ &(ascend->next_packet_seek_start)) != PARSED_RECORD) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
return FALSE;
config_pseudo_header(pseudo_head);
return TRUE;
}
-
-static void ascend_close(wtap *wth)
-{
- g_free(wth->capture.ascend);
-}
static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header,
const guchar *pd, int *err);
-static gboolean catapult_dct2000_dump_close(wtap_dumper *wdh, int *err);
/************************************************************/
g_hash_table_new(packet_offset_hash_func, packet_offset_equal);
/* Set this wtap to point to the file_externals */
- wth->capture.generic = (void*)file_externals;
+ wth->priv = (void*)file_externals;
*err = errno;
return 1;
/* Get wtap external structure for this wtap */
dct2000_file_externals_t *file_externals =
- (dct2000_file_externals_t*)wth->capture.generic;
+ (dct2000_file_externals_t*)wth->priv;
/* There *has* to be an entry for this wth */
if (!file_externals) {
{
/* Get externals for this file */
dct2000_file_externals_t *file_externals =
- (dct2000_file_externals_t*)wth->capture.generic;
+ (dct2000_file_externals_t*)wth->priv;
/* The entry *has* to be found */
if (!file_externals) {
free_line_prefix_info, NULL);
/* Free up its line prefix table */
g_hash_table_destroy(file_externals->packet_prefix_table);
-
- /* Can now free this too */
- g_free(file_externals);
}
/* Dump functions */
/***************************/
+typedef struct {
+ gboolean first_packet_written;
+ struct wtap_nstime start_time;
+} dct2000_dump_t;
+
/*****************************************************/
/* The file that we are writing to has been opened. */
/* Set other dump callbacks. */
{
/* Fill in other dump callbacks */
wdh->subtype_write = catapult_dct2000_dump;
- wdh->subtype_close = catapult_dct2000_dump_close;
return TRUE;
}
line_prefix_info_t *prefix = NULL;
gchar time_string[16];
gboolean is_comment;
+ dct2000_dump_t *dct2000;
/******************************************************/
/* Get the file_externals structure for this file */
/* Find wtap external structure for this wtap */
dct2000_file_externals_t *file_externals =
- (dct2000_file_externals_t*)pseudo_header->dct2000.wth->capture.generic;
+ (dct2000_file_externals_t*)pseudo_header->dct2000.wth->priv;
- if (wdh->dump.dct2000 == NULL) {
+ dct2000 = (dct2000_dump_t *)wdh->priv;
+ if (dct2000 == NULL) {
/* Write out saved first line */
if (!do_fwrite(file_externals->firstline, 1, file_externals->firstline_length, wdh->fh, err)) {
}
/* Allocate the dct2000-specific dump structure */
- wdh->dump.dct2000 = g_malloc(sizeof(dct2000_dump_t));
+ dct2000 = (dct2000_dump_t *)g_malloc(sizeof(dct2000_dump_t));
+ wdh->priv = (void *)dct2000;
/* Copy time of beginning of file */
- wdh->dump.dct2000->start_time.secs = file_externals->start_secs;
- wdh->dump.dct2000->start_time.nsecs =
+ dct2000->start_time.secs = file_externals->start_secs;
+ dct2000->start_time.nsecs =
(file_externals->start_usecs * 1000);
/* Set flag do don't write header out again */
- wdh->dump.dct2000->first_packet_written = TRUE;
+ dct2000->first_packet_written = TRUE;
}
is_comment = (strstr(prefix->before_time, "/////") != NULL);
/* Calculate time of this packet to write, relative to start of dump */
- if (phdr->ts.nsecs >= wdh->dump.dct2000->start_time.nsecs) {
+ if (phdr->ts.nsecs >= dct2000->start_time.nsecs) {
g_snprintf(time_string, 16, "%ld.%04d",
- (long)(phdr->ts.secs - wdh->dump.dct2000->start_time.secs),
- (phdr->ts.nsecs - wdh->dump.dct2000->start_time.nsecs) / 100000);
+ (long)(phdr->ts.secs - dct2000->start_time.secs),
+ (phdr->ts.nsecs - dct2000->start_time.nsecs) / 100000);
}
else {
g_snprintf(time_string, 16, "%ld.%04u",
- (long)(phdr->ts.secs - wdh->dump.dct2000->start_time.secs-1),
- ((1000000000 + (phdr->ts.nsecs / 100000)) - (wdh->dump.dct2000->start_time.nsecs / 100000)) % 10000);
+ (long)(phdr->ts.secs - dct2000->start_time.secs-1),
+ ((1000000000 + (phdr->ts.nsecs / 100000)) - (dct2000->start_time.nsecs / 100000)) % 10000);
}
/* Write out the calculated timestamp */
}
-/******************************************************/
-/* Close a file we've been writing to. */
-/******************************************************/
-static gboolean catapult_dct2000_dump_close(wtap_dumper *wdh _U_, int *err _U_)
-{
- return TRUE;
-}
-
-
-
-
/****************************/
/* Private helper functions */
/****************************/
static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
int *err, gchar **err_info);
-static void csids_close(wtap *wth);
struct csids_header {
guint32 seconds; /* seconds since epoch */
guint16 caplen; /* the capture length */
};
+typedef struct {
+ gboolean byteswapped;
+} csids_t;
+
/* XXX - return -1 on I/O error and actually do something with 'err'. */
int csids_open(wtap *wth, int *err, gchar **err_info _U_)
{
gboolean byteswap = FALSE;
struct csids_header hdr;
+ csids_t *csids;
/* check the file to make sure it is a csids file. */
bytesRead = file_read( &hdr, 1, sizeof( struct csids_header), wth->fh );
return -1;
wth->data_offset = 0;
- wth->capture.csids = g_malloc(sizeof(csids_t));
- wth->capture.csids->byteswapped = byteswap;
+ csids = (csids_t *)g_malloc(sizeof(csids_t));
+ wth->priv = (void *)csids;
+ csids->byteswapped = byteswap;
wth->file_encap = WTAP_ENCAP_RAW_IP;
wth->file_type = WTAP_FILE_CSIDS;
wth->snapshot_length = 0; /* not known */
wth->subtype_read = csids_read;
wth->subtype_seek_read = csids_seek_read;
- wth->subtype_close = csids_close;
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
return 1;
static gboolean csids_read(wtap *wth, int *err, gchar **err_info _U_,
gint64 *data_offset)
{
+ csids_t *csids = (csids_t *)wth->priv;
guint8 *buf;
int bytesRead = 0;
struct csids_header hdr;
wth->phdr.ts.secs = hdr.seconds;
wth->phdr.ts.nsecs = 0;
- if( wth->capture.csids->byteswapped ) {
+ if( csids->byteswapped ) {
PBSWAP16(buf); /* the ip len */
PBSWAP16(buf+2); /* ip id */
PBSWAP16(buf+4); /* ip flags and fragoff */
int *err,
gchar **err_info)
{
+ csids_t *csids = (csids_t *)wth->priv;
int bytesRead;
struct csids_header hdr;
return FALSE;
}
- if( wth->capture.csids->byteswapped ) {
+ if( csids->byteswapped ) {
PBSWAP16(pd); /* the ip len */
PBSWAP16(pd+2); /* ip id */
PBSWAP16(pd+4); /* ip flags and fragoff */
return TRUE;
}
-
-static void
-csids_close(wtap *wth)
-{
- g_free(wth->capture.csids);
-}
#define NUM_ETHERPEEK_ENCAPS \
(sizeof (etherpeek_encap) / sizeof (etherpeek_encap[0]))
+typedef struct {
+ struct timeval reference_time;
+} etherpeek_t;
+
static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean etherpeek_seek_read_v7(wtap *wth, gint64 seek_off,
static gboolean etherpeek_seek_read_v56(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static void etherpeek_close(wtap *wth);
int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_)
{
etherpeek_header_t ep_hdr;
struct timeval reference_time;
int file_encap;
+ etherpeek_t *etherpeek;
/* EtherPeek files do not start with a magic value large enough
* to be unique; hence we use the following algorithm to determine
* At this point we have recognised the file type and have populated
* the whole ep_hdr structure in host byte order.
*/
- wth->capture.etherpeek = g_malloc(sizeof(etherpeek_t));
- wth->capture.etherpeek->reference_time = reference_time;
- wth->subtype_close = etherpeek_close;
+ etherpeek = (etherpeek_t *)g_malloc(sizeof(etherpeek_t));
+ wth->priv = (void *)etherpeek;
+ etherpeek->reference_time = reference_time;
switch (ep_hdr.master.version) {
case 5:
}
wth->snapshot_length = 0; /* not available in header */
- wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wth->tsprecision = WTAP_FILE_TSPREC_USEC;
return 1;
}
-static void etherpeek_close(wtap *wth)
-{
- g_free(wth->capture.etherpeek);
-}
-
static gboolean etherpeek_read_v7(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
static gboolean etherpeek_read_v56(wtap *wth, int *err, gchar **err_info _U_,
gint64 *data_offset)
{
+ etherpeek_t *etherpeek = (etherpeek_t *)wth->priv;
guchar ep_pkt[ETHERPEEK_V56_PKT_SIZE];
guint16 length;
guint16 sliceLength;
wth->phdr.len = length;
wth->phdr.caplen = sliceLength;
/* timestamp is in milliseconds since reference_time */
- wth->phdr.ts.secs = wth->capture.etherpeek->reference_time.tv_sec
+ wth->phdr.ts.secs = etherpeek->reference_time.tv_sec
+ (timestamp / 1000);
wth->phdr.ts.nsecs = 1000 * (timestamp % 1000) * 1000;
wth->subtype_sequential_close = NULL;
wth->subtype_close = NULL;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
+ wth->priv = NULL;
init_open_routines();
wdh->encap = encap;
wdh->compressed = compressed;
wdh->bytes_dumped = 0;
- wdh->dump.opaque = NULL;
+ wdh->priv = NULL;
wdh->subtype_write = NULL;
wdh->subtype_close = NULL;
return wdh;
/* as we don't close stdout, at least try to flush it */
wtap_dump_flush(wdh);
}
- if (wdh->dump.opaque != NULL)
- g_free(wdh->dump.opaque);
+ if (wdh->priv != NULL)
+ g_free(wdh->priv);
g_free(wdh);
return ret;
}
#include "i4b_trace.h"
#include "i4btrace.h"
+typedef struct {
+ gboolean byte_swapped;
+} i4btrace_t;
+
static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
static gboolean i4b_read_rec_data(FILE_T fh, guchar *pd, int length, int *err);
static void i4b_set_pseudo_header(i4b_trace_hdr_t *hdr,
union wtap_pseudo_header *pseudo_header);
-static void i4btrace_close(wtap *wth);
/*
* Test some fields in the header to see if they make sense.
int bytes_read;
i4b_trace_hdr_t hdr;
gboolean byte_swapped = FALSE;
+ i4btrace_t *i4btrace;
/* I4B trace files have no magic in the header... Sigh */
errno = WTAP_ERR_CANT_READ;
/* Get capture start time */
wth->file_type = WTAP_FILE_I4BTRACE;
- wth->capture.i4btrace = g_malloc(sizeof(i4btrace_t));
+ i4btrace = (i4btrace_t *)g_malloc(sizeof(i4btrace_t));
+ wth->priv = (void *)i4btrace;
wth->subtype_read = i4btrace_read;
wth->subtype_seek_read = i4btrace_seek_read;
- wth->subtype_close = i4btrace_close;
wth->snapshot_length = 0; /* not known */
- wth->capture.i4btrace->byte_swapped = byte_swapped;
+ i4btrace->byte_swapped = byte_swapped;
wth->file_encap = WTAP_ENCAP_ISDN;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
static void
i4b_byte_swap_header(wtap *wth, i4b_trace_hdr_t *hdr)
{
- if (wth->capture.i4btrace->byte_swapped) {
+ i4btrace_t *i4btrace = (i4btrace_t *)wth->priv;
+
+ if (i4btrace->byte_swapped) {
/*
* Byte-swap the header.
*/
break;
}
}
-
-static void
-i4btrace_close(wtap *wth)
-{
- g_free(wth->capture.i4btrace);
-}
/* Save trace format for passing between packets */
iseries = (iseries_t *) g_malloc (sizeof (iseries_t));
- wth->capture.generic = iseries;
+ wth->priv = (void *)iseries;
iseries->have_date = FALSE;
iseries->format = format;
iseries->tcp_formatted = FALSE;
static gint64
iseries_seek_next_packet (wtap * wth, int *err)
{
+ iseries_t *iseries = (iseries_t *)wth->priv;
char buf[ISERIES_LINE_LENGTH];
int line;
gint64 cur_off;
long buflen;
- iseries_t *iseries = (iseries_t *)wth->capture.generic;
/*
* Seeks to the beginning of the next packet, and returns the
union wtap_pseudo_header *pseudo_header, guint8 * pd,
int *err, gchar ** err_info)
{
+ iseries_t *iseries = (iseries_t *)wth->priv;
gint64 cur_off;
gboolean isValid, isCurrentPacket, IPread, TCPread, isDATA;
int num_items_scanned, line, pktline, buflen, i;
guint8 *buf;
char *tcpdatabuf, *workbuf, *asciibuf;
struct tm tm;
- iseries_t *iseries = (iseries_t *)wth->capture.generic;
/*
* Check for packet headers in first 3 lines this should handle page breaks
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
wth->subtype_read = jpeg_jfif_read;
wth->subtype_seek_read = jpeg_jfif_seek_read;
- wth->subtype_close = NULL;
wth->snapshot_length = 0;
-
- wth->capture.generic = NULL;
}
}
static const guint8 k12_file_magic[] = { 0x00, 0x00, 0x02, 0x00 ,0x12, 0x05, 0x00, 0x10 };
-struct _k12_t {
+typedef struct {
guint32 file_len;
guint32 num_of_records; /* XXX: not sure about this */
GHashTable* src_by_name; /* k12_srcdsc_recs by stack_name */
Buffer extra_info; /* Buffer to hold per packet extra information */
-};
+} k12_t;
typedef struct _k12_src_desc_t {
guint32 input;
}
static gboolean k12_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset) {
+ k12_t *k12 = (k12_t *)wth->priv;
k12_src_desc_t* src_desc;
guint8* buffer = NULL;
gint64 offset;
src_id = pntohl(buffer + K12_RECORD_SRC_ID);
- if ( ! (src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(src_id))) ) {
+ if ( ! (src_desc = g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(src_id))) ) {
/*
* Some records from K15 files have a port ID of an undeclared
* interface which happens to be the only one with the first byte changed.
* If the lookup of the interface record fails we'll mask it
* and retry.
*/
- src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(src_id&K12_RECORD_SRC_ID_MASK));
+ src_desc = g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(src_id&K12_RECORD_SRC_ID_MASK));
}
K12_DBG(5,("k12_read: record type=%x src_id=%x",type,src_id));
memcpy(buffer_start_ptr(wth->frame_buffer), buffer + K12_PACKET_FRAME, wth->phdr.caplen);
/* extra information need by some protocols */
- buffer_assure_space(&(wth->capture.k12->extra_info), extra_len);
- memcpy(buffer_start_ptr(&(wth->capture.k12->extra_info)),
+ buffer_assure_space(&(k12->extra_info), extra_len);
+ memcpy(buffer_start_ptr(&(k12->extra_info)),
buffer + K12_PACKET_FRAME + wth->phdr.caplen, extra_len);
- wth->pseudo_header.k12.extra_info = (void*)buffer_start_ptr(&(wth->capture.k12->extra_info));
+ wth->pseudo_header.k12.extra_info = (void*)buffer_start_ptr(&(k12->extra_info));
wth->pseudo_header.k12.extra_length = extra_len;
wth->pseudo_header.k12.input = src_id;
}
- wth->pseudo_header.k12.stuff = wth->capture.k12;
+ wth->pseudo_header.k12.stuff = k12;
return TRUE;
}
static gboolean k12_seek_read(wtap *wth, gint64 seek_off, union wtap_pseudo_header *pseudo_header, guchar *pd, int length, int *err _U_, gchar **err_info _U_) {
+ k12_t *k12 = (k12_t *)wth->priv;
k12_src_desc_t* src_desc;
guint8* buffer;
gint len;
memcpy(pd, buffer + K12_PACKET_FRAME, length);
extra_len = len - K12_PACKET_FRAME - length;
- buffer_assure_space(&(wth->capture.k12->extra_info), extra_len);
- memcpy(buffer_start_ptr(&(wth->capture.k12->extra_info)),
+ buffer_assure_space(&(k12->extra_info), extra_len);
+ memcpy(buffer_start_ptr(&(k12->extra_info)),
buffer + K12_PACKET_FRAME + length, extra_len);
- wth->pseudo_header.k12.extra_info = (void*)buffer_start_ptr(&(wth->capture.k12->extra_info));
+ wth->pseudo_header.k12.extra_info = (void*)buffer_start_ptr(&(k12->extra_info));
wth->pseudo_header.k12.extra_length = extra_len;
if (pseudo_header) {
- pseudo_header->k12.extra_info = (void*)buffer_start_ptr(&(wth->capture.k12->extra_info));
+ pseudo_header->k12.extra_info = (void*)buffer_start_ptr(&(k12->extra_info));
pseudo_header->k12.extra_length = extra_len;
}
input = pntohl(buffer + K12_RECORD_SRC_ID);
K12_DBG(5,("k12_seek_read: input=%.8x",input));
- if ( ! (src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(input))) ) {
+ if ( ! (src_desc = g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(input))) ) {
/*
* Some records from K15 files have a port ID of an undeclared
* interface which happens to be the only one with the first byte changed.
* If the lookup of the interface record fails we'll mask it
* and retry.
*/
- src_desc = g_hash_table_lookup(wth->capture.k12->src_by_id,GUINT_TO_POINTER(input&K12_RECORD_SRC_ID_MASK));
+ src_desc = g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(input&K12_RECORD_SRC_ID_MASK));
}
if (src_desc) {
if (pseudo_header) {
pseudo_header->k12.input = input;
- pseudo_header->k12.stuff = wth->capture.k12;
+ pseudo_header->k12.stuff = k12;
}
wth->pseudo_header.k12.input = input;
- wth->pseudo_header.k12.stuff = wth->capture.k12;
+ wth->pseudo_header.k12.stuff = k12;
K12_DBG(5,("k12_seek_read: DONE OK"));
}
static void k12_close(wtap *wth) {
- destroy_k12_file_data(wth->capture.k12);
+ k12_t *k12 = (k12_t *)wth->priv;
+
+ destroy_k12_file_data(k12);
+ wth->priv = NULL; /* destroy_k12_file_data freed it */
#ifdef DEBUG_K12
K12_DBG(5,("k12_close: CLOSED"));
if (env_file) fclose(dbg_out);
if ( len <= 0 ) {
K12_DBG(1,("k12_open: BAD HEADER RECORD",len));
+ destroy_k12_file_data(file_data);
+ g_free(file_data);
return -1;
}
*/
if (file_seek(wth->fh, offset, SEEK_SET, err) == -1) {
destroy_k12_file_data(file_data);
+ g_free(file_data);
return -1;
}
K12_DBG(5,("k12_open: FIRST PACKET offset=%x",offset));
g_free(rec);
K12_DBG(5,("k12_open: failed (name_len == 0 || stack_len == 0 "
"|| 0x20 + extra_len + name_len + stack_len > rec_len) extra_len=%i name_len=%i stack_len=%i"));
+ destroy_k12_file_data(file_data);
+ g_free(file_data);
return 0;
}
wth->subtype_read = k12_read;
wth->subtype_seek_read = k12_seek_read;
wth->subtype_close = k12_close;
- wth->capture.k12 = file_data;
+ wth->priv = (void *)file_data;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
return 1;
}
+typedef struct {
+ guint32 file_len;
+ guint32 num_of_records;
+ guint32 file_offset;
+} k12_dump_t;
+
int k12_dump_can_write_encap(int encap) {
if (encap == WTAP_ENCAP_PER_PACKET)
}
static gboolean k12_dump_record(wtap_dumper *wdh, guint32 len, guint8* buffer, int *err_p) {
- guint32 junky_offset = (0x2000 - ( (wdh->dump.k12->file_offset - 0x200) % 0x2000 )) % 0x2000;
+ k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
+ guint32 junky_offset = (0x2000 - ( (k12->file_offset - 0x200) % 0x2000 )) % 0x2000;
if (len > junky_offset) {
if (junky_offset) {
if (! do_fwrite(buffer+junky_offset, 1, len - junky_offset, wdh->fh, err_p))
return FALSE;
- wdh->dump.k12->file_offset += len + 0x10;
+ k12->file_offset += len + 0x10;
} else {
if (! do_fwrite(buffer, 1, len, wdh->fh, err_p))
return FALSE;
- wdh->dump.k12->file_offset += len;
+ k12->file_offset += len;
}
- wdh->dump.k12->num_of_records++;
+ k12->num_of_records++;
return TRUE;
}
static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header,
const guchar *pd, int *err) {
+ k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
guint32 len;
union {
guint8 buffer[0x2000];
} record;
} obj;
- if (wdh->dump.k12->num_of_records == 0) {
+ if (k12->num_of_records == 0) {
k12_t* file_data = pseudo_header->k12.stuff;
/* XXX: We'll assume that any fwrite errors in k12_dump_src_setting will */
/* repeat during the final k12_dump_record at the end of k12_dump */
static const guint8 k12_eof[] = {0xff,0xff};
static gboolean k12_dump_close(wtap_dumper *wdh, int *err) {
+ k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
union {
guint8 b[sizeof(guint32)];
guint32 u;
return FALSE;
}
- d.u = g_htonl(wdh->dump.k12->file_len);
+ d.u = g_htonl(k12->file_len);
if (! do_fwrite(d.b, 1, 4, wdh->fh, err))
return FALSE;
- d.u = g_htonl(wdh->dump.k12->num_of_records);
+ d.u = g_htonl(k12->num_of_records);
if (! do_fwrite(d.b, 1, 4, wdh->fh, err))
return FALSE;
gboolean k12_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err) {
+ k12_dump_t *k12;
if (cant_seek) {
*err = WTAP_ERR_CANT_WRITE_TO_PIPE;
wdh->subtype_write = k12_dump;
wdh->subtype_close = k12_dump_close;
- wdh->dump.k12 = g_malloc(sizeof(k12_dump_t));
- wdh->dump.k12->file_len = 0x200;
- wdh->dump.k12->num_of_records = 0;
- wdh->dump.k12->file_offset = 0x200;
+ k12 = (k12_dump_t *)g_malloc(sizeof(k12_dump_t));
+ wdh->priv = (void *)k12;
+ k12->file_len = 0x200;
+ k12->num_of_records = 0;
+ k12->file_offset = 0x200;
return TRUE;
}
return TRUE;
}
-static void k12text_close(wtap *wth _U_) {
- (void)0;
-}
-
int k12text_open(wtap *wth, int *err, gchar **err_info _U_) {
k12text_reset(wth->fh); /* init lexer buffer and vars set by lexer */
wth->snapshot_length = 0;
wth->subtype_read = k12text_read;
wth->subtype_seek_read = k12text_seek_read;
- wth->subtype_close = k12text_close;
- wth->capture.generic = NULL;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
return 1;
}
-static gboolean k12text_dump_close(wtap_dumper *wdh _U_ , int *err _U_) {
- return TRUE;
-}
-
gboolean k12text_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err) {
if (cant_seek) {
}
wdh->subtype_write = k12text_dump;
- wdh->subtype_close = k12text_dump_close;
return TRUE;
}
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int length,
int *err, gchar **err_info);
-static void lanalyzer_close(wtap *wth);
static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err);
int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
* from a record later in the file. */
wth->file_type = WTAP_FILE_LANALYZER;
lanalyzer = (lanalyzer_t *)g_malloc(sizeof(lanalyzer_t));;
- wth->capture.generic = lanalyzer;
+ wth->priv = (void *)lanalyzer;
wth->subtype_read = lanalyzer_read;
wth->subtype_seek_read = lanalyzer_seek_read;
- wth->subtype_close = lanalyzer_close;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
/* Read records until we find the start of packets */
while (1) {
if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
wth->data_offset += record_length;
if (bytes_read != 4) {
*err = file_error(wth->fh);
if (*err != 0) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return 0;
}
wth->data_offset += 4;
if (bytes_read != sizeof summary) {
*err = file_error(wth->fh);
if (*err != 0) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return 0;
}
wth->data_offset += sizeof summary;
wth->file_encap = WTAP_ENCAP_TOKEN_RING;
break;
default:
- g_free(wth->capture.generic);
+ g_free(wth->priv);
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("lanalyzer: board type %u unknown",
board_type);
/* Go back header number ob ytes so that lanalyzer_read
* can read this header */
if (file_seek(wth->fh, -bytes_read, SEEK_CUR, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
wth->data_offset -= bytes_read;
t = (((guint64)time_low) << 0) + (((guint64)time_med) << 16) +
(((guint64)time_high) << 32);
tsecs = (time_t) (t/2000000);
- lanalyzer = (lanalyzer_t *)wth->capture.generic;
+ lanalyzer = (lanalyzer_t *)wth->priv;
wth->phdr.ts.secs = tsecs + lanalyzer->start;
wth->phdr.ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
return TRUE;
}
-static void
-lanalyzer_close(wtap *wth)
-{
- g_free(wth->capture.generic);
-}
-
/*---------------------------------------------------
* Returns 0 or error
* Write one block with error control
int len;
struct timeval tv;
- LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->dump.opaque);
+ LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
struct timeval td;
int thisSize = phdr->caplen + LA_PacketRecordSize + LA_RecordHeaderSize;
}
((LA_TmpInfo*)tmp)->init = FALSE;
- wdh->dump.opaque = tmp;
- wdh->subtype_write = lanalyzer_dump;
- wdh->subtype_close = lanalyzer_dump_close;
+ wdh->priv = tmp;
+ wdh->subtype_write = lanalyzer_dump;
+ wdh->subtype_close = lanalyzer_dump_close;
/* Some of the fields in the file header aren't known yet so
just skip over it for now. It will be created after all
*---------------------------------------------------*/
static gboolean lanalyzer_dump_header(wtap_dumper *wdh, int *err)
{
- LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->dump.opaque);
+ LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
struct tm *fT = localtime( (time_t *) &(itmp->start.tv_sec));
guint16 board_type = itmp->encap == WTAP_ENCAP_TOKEN_RING
? BOARD_325TR /* LANalyzer Board Type */
static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr);
static gboolean libpcap_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
-static void libpcap_close(wtap *wth);
static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
libpcap->byte_swapped = byte_swapped;
libpcap->version_major = hdr.version_major;
libpcap->version_minor = hdr.version_minor;
- wth->capture.generic = libpcap;
+ wth->priv = (void *)libpcap;
wth->subtype_read = libpcap_read;
wth->subtype_seek_read = libpcap_seek_read;
- wth->subtype_close = libpcap_close;
wth->file_encap = file_encap;
wth->snapshot_length = hdr.snaplen;
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
case THIS_FORMAT:
* Put the seek pointer back, and return success.
*/
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
return 1;
*/
wth->file_type = WTAP_FILE_PCAP_SS990915;
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
} else {
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
case THIS_FORMAT:
* Put the seek pointer back, and return success.
*/
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
return 1;
*/
wth->file_type = WTAP_FILE_PCAP_SS990417;
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
switch (libpcap_try(wth, err)) {
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
case THIS_FORMAT:
* Put the seek pointer back, and return success.
*/
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
return 1;
*/
wth->file_type = WTAP_FILE_PCAP_NOKIA;
if (file_seek(wth->fh, wth->data_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.generic);
+ g_free(wth->priv);
return -1;
}
}
*data_offset = wth->data_offset;
- libpcap = (libpcap_t *)wth->capture.generic;
+ libpcap = (libpcap_t *)wth->priv;
phdr_len = pcap_process_pseudo_header(wth->fh, wth->file_type,
wth->file_encap, libpcap->byte_swapped, packet_size,
TRUE, &wth->phdr, &wth->pseudo_header, err, err_info);
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- libpcap = (libpcap_t *)wth->capture.generic;
+ libpcap = (libpcap_t *)wth->priv;
phdr_len = pcap_process_pseudo_header(wth->random_fh, wth->file_type,
wth->file_encap, libpcap->byte_swapped, length,
FALSE, NULL, pseudo_header, err, err_info);
guint32 temp;
libpcap_t *libpcap;
- libpcap = (libpcap_t *)wth->capture.generic;
+ libpcap = (libpcap_t *)wth->priv;
if (libpcap->byte_swapped) {
/* Byte-swap the record header fields. */
hdr->ts_sec = BSWAP32(hdr->ts_sec);
return TRUE;
}
-static void
-libpcap_close(wtap *wth)
-{
- g_free(wth->capture.generic);
-}
-
/* Returns 0 if we could write the specified encapsulation type,
an error indication otherwise. */
int libpcap_dump_can_write_encap(int encap)
#define PES_PREFIX 1
#define PES_VALID(n) (((n) >> 8 & 0xffffff) == PES_PREFIX)
+typedef struct {
+ struct wtap_nstime now;
+ time_t t0;
+} mpeg_t;
+
static int
mpeg_resync(wtap *wth, int *err, gchar **err_info _U_)
{
mpeg_read(wtap *wth, int *err, gchar **err_info _U_,
gint64 *data_offset)
{
+ mpeg_t *mpeg = (mpeg_t *)wth->priv;
guint32 n;
int bytes_read = mpeg_read_header(wth, err, err_info, &n);
unsigned int packet_size;
- struct wtap_nstime ts = wth->capture.mpeg->now;
+ struct wtap_nstime ts = mpeg->now;
if (bytes_read == -1)
return FALSE;
unsigned ext = (unsigned)((bytes >> 1) & 0x1ff);
guint64 cr = 300 * ts_val + ext;
unsigned rem = (unsigned)(cr % SCRHZ);
- wth->capture.mpeg->now.secs
- = wth->capture.mpeg->t0 + (time_t)(cr / SCRHZ);
- wth->capture.mpeg->now.nsecs
+ mpeg->now.secs
+ = mpeg->t0 + (time_t)(cr / SCRHZ);
+ mpeg->now.nsecs
= (int)(G_GINT64_CONSTANT(1000000000) * rem / SCRHZ);
}
- ts = wth->capture.mpeg->now;
+ ts = mpeg->now;
break;
default:
packet_size = 12;
MPA_UNMARSHAL(&mpa, n);
if (MPA_VALID(&mpa)) {
packet_size = MPA_BYTES(&mpa);
- wth->capture.mpeg->now.nsecs += MPA_DURATION_NS(&mpa);
- if (wth->capture.mpeg->now.nsecs >= 1000000000) {
- wth->capture.mpeg->now.secs++;
- wth->capture.mpeg->now.nsecs -= 1000000000;
+ mpeg->now.nsecs += MPA_DURATION_NS(&mpa);
+ if (mpeg->now.nsecs >= 1000000000) {
+ mpeg->now.secs++;
+ mpeg->now.nsecs -= 1000000000;
}
} else {
packet_size = mpeg_resync(wth, err, err_info);
return mpeg_read_rec_data(wth->random_fh, pd, length, err);
}
-static void
-mpeg_close(wtap *wth)
-{
- g_free(wth->capture.mpeg);
-}
-
struct _mpeg_magic {
size_t len;
const gchar* match;
int bytes_read;
char magic_buf[16];
struct _mpeg_magic* m;
+ mpeg_t *mpeg;
errno = WTAP_ERR_CANT_READ;
bytes_read = file_read(magic_buf, 1, sizeof magic_buf, wth->fh);
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
wth->subtype_read = mpeg_read;
wth->subtype_seek_read = mpeg_seek_read;
- wth->subtype_close = mpeg_close;
wth->snapshot_length = 0;
- wth->capture.mpeg = g_malloc(sizeof(mpeg_t));
- wth->capture.mpeg->now.secs = time(NULL);
- wth->capture.mpeg->now.nsecs = 0;
- wth->capture.mpeg->t0 = wth->capture.mpeg->now.secs;
+ mpeg = (mpeg_t *)g_malloc(sizeof(mpeg_t));
+ wth->priv = (void *)mpeg;
+ mpeg->now.secs = time(NULL);
+ mpeg->now.nsecs = 0;
+ mpeg->t0 = mpeg->now.secs;
return 1;
}
guint16 vci; /* VCI */
};
+typedef struct {
+ time_t start_secs;
+ guint32 start_usecs;
+ guint8 version_major;
+ guint32 *frame_table;
+ guint32 frame_table_size;
+ guint current_frame;
+} netmon_t;
+
static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
static gboolean netmon_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err);
static void netmon_sequential_close(wtap *wth);
-static void netmon_close(wtap *wth);
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err);
#ifdef WORDS_BIGENDIAN
unsigned int i;
#endif
+ netmon_t *netmon;
/* Read in the string that should be at the start of a Network
* Monitor file */
/* This is a netmon file */
wth->file_type = file_type;
- wth->capture.netmon = g_malloc(sizeof(netmon_t));
+ netmon = (netmon_t *)g_malloc(sizeof(netmon_t));
+ wth->priv = (void *)netmon;
wth->subtype_read = netmon_read;
wth->subtype_seek_read = netmon_seek_read;
wth->subtype_sequential_close = netmon_sequential_close;
- wth->subtype_close = netmon_close;
/* NetMon capture file formats v2.1+ use per-packet encapsulation types. NetMon 3 sets the value in
* the header to 1 (Ethernet) for backwards compability. */
tm.tm_min = pletohs(&hdr.ts_min);
tm.tm_sec = pletohs(&hdr.ts_sec);
tm.tm_isdst = -1;
- wth->capture.netmon->start_secs = mktime(&tm);
+ netmon->start_secs = mktime(&tm);
/*
* XXX - what if "secs" is -1? Unlikely, but if the capture was
* done in a time zone that switches between standard and summer
* intervals since 1601-01-01 00:00:00 "UTC", there, instead
* of stuffing a SYSTEMTIME, which is time-zone-dependent, there?).
*/
- wth->capture.netmon->start_usecs = pletohs(&hdr.ts_msec)*1000;
+ netmon->start_usecs = pletohs(&hdr.ts_msec)*1000;
- wth->capture.netmon->version_major = hdr.ver_major;
+ netmon->version_major = hdr.ver_major;
/*
* Get the offset of the frame index table.
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("netmon: frame table length is %u, which is not a multiple of the size of an entry",
frame_table_length);
- g_free(wth->capture.netmon);
+ g_free(netmon);
return -1;
}
if (frame_table_size == 0) {
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("netmon: frame table length is %u, which means it's less than one entry in size",
frame_table_length);
- g_free(wth->capture.netmon);
+ g_free(netmon);
return -1;
}
if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) {
- g_free(wth->capture.netmon);
+ g_free(netmon);
return -1;
}
frame_table = g_malloc(frame_table_length);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
g_free(frame_table);
- g_free(wth->capture.netmon);
+ g_free(netmon);
return -1;
}
- wth->capture.netmon->frame_table_size = frame_table_size;
- wth->capture.netmon->frame_table = frame_table;
+ netmon->frame_table_size = frame_table_size;
+ netmon->frame_table = frame_table;
#ifdef WORDS_BIGENDIAN
/*
#endif
/* Set up to start reading at the first frame. */
- wth->capture.netmon->current_frame = 0;
+ netmon->current_frame = 0;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
return 1;
static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
- netmon_t *netmon = wth->capture.netmon;
+ netmon_t *netmon = (netmon_t *)wth->priv;
guint32 packet_size = 0;
guint32 orig_size = 0;
int bytes_read;
if (netmon->current_frame >= netmon->frame_table_size) {
/* Yes. We won't need the frame table any more;
free it. */
- g_free(wth->capture.netmon->frame_table);
- wth->capture.netmon->frame_table = NULL;
+ g_free(netmon->frame_table);
+ netmon->frame_table = NULL;
*err = 0; /* it's just an EOF, not an error */
return FALSE;
}
static void
netmon_sequential_close(wtap *wth)
{
- if (wth->capture.netmon->frame_table != NULL) {
- g_free(wth->capture.netmon->frame_table);
- wth->capture.netmon->frame_table = NULL;
+ netmon_t *netmon = (netmon_t *)wth->priv;
+
+ if (netmon->frame_table != NULL) {
+ g_free(netmon->frame_table);
+ netmon->frame_table = NULL;
}
}
-/* Close stuff used by the random I/O stream, if any, and free up any
- private data structures. (If there's a "sequential_close" routine
- for a capture file type, it'll be called before the "close" routine
- is called, so we don't have to free the frame table here.) */
-static void
-netmon_close(wtap *wth)
-{
- g_free(wth->capture.netmon);
-}
+typedef struct {
+ gboolean got_first_record_time;
+ struct wtap_nstime first_record_time;
+ guint32 frame_table_offset;
+ guint32 *frame_table;
+ guint frame_table_index;
+ guint frame_table_size;
+} netmon_dump_t;
static const int wtap_encap[] = {
-1, /* WTAP_ENCAP_UNKNOWN -> unsupported */
failure */
gboolean netmon_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
{
+ netmon_dump_t *netmon;
+
/* This is a NetMon file. We can't fill in some fields in the
header until all the packets have been written, so we can't
write to a pipe. */
wdh->subtype_write = netmon_dump;
wdh->subtype_close = netmon_dump_close;
- wdh->dump.netmon = g_malloc(sizeof(netmon_dump_t));
- wdh->dump.netmon->frame_table_offset = CAPTUREFILE_HEADER_SIZE;
- wdh->dump.netmon->got_first_record_time = FALSE;
- wdh->dump.netmon->frame_table = NULL;
- wdh->dump.netmon->frame_table_index = 0;
- wdh->dump.netmon->frame_table_size = 0;
+ netmon = (netmon_dump_t *)g_malloc(sizeof(netmon_dump_t));
+ wdh->priv = (void *)netmon;
+ netmon->frame_table_offset = CAPTUREFILE_HEADER_SIZE;
+ netmon->got_first_record_time = FALSE;
+ netmon->frame_table = NULL;
+ netmon->frame_table_index = 0;
+ netmon->frame_table_size = 0;
return TRUE;
}
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
- netmon_dump_t *netmon = wdh->dump.netmon;
+ netmon_dump_t *netmon = (netmon_dump_t *)wdh->priv;
struct netmonrec_1_x_hdr rec_1_x_hdr;
struct netmonrec_2_x_hdr rec_2_x_hdr;
char *hdrp;
Returns TRUE on success, FALSE on failure. */
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err)
{
- netmon_dump_t *netmon = wdh->dump.netmon;
+ netmon_dump_t *netmon = (netmon_dump_t *)wdh->priv;
size_t n_to_write;
size_t nwritten;
struct netmon_hdr file_hdr;
#undef __TNL
-#define ns_setabstime(wth, AbsoluteTime, RelativeTimems) \
+#define ns_setabstime(nstrace, AbsoluteTime, RelativeTimems) \
do { \
- wth->capture.nstrace->nspm_curtime = AbsoluteTime; \
- wth->capture.nstrace->nspm_curtimemsec += RelativeTimems; \
- wth->capture.nstrace->nspm_curtimelastmsec = wth->capture.nstrace->nspm_curtimemsec; \
+ (nstrace)->nspm_curtime = AbsoluteTime; \
+ (nstrace)->nspm_curtimemsec += RelativeTimems; \
+ (nstrace)->nspm_curtimelastmsec = nstrace->nspm_curtimemsec; \
} while(0)
-#define ns_setrelativetime(wth, RelativeTimems) \
+#define ns_setrelativetime(nstrace, RelativeTimems) \
do { \
guint32 rsec; \
- wth->capture.nstrace->nspm_curtimemsec += RelativeTimems; \
- rsec = (guint32)(wth->capture.nstrace->nspm_curtimemsec - wth->capture.nstrace->nspm_curtimelastmsec)/1000; \
- wth->capture.nstrace->nspm_curtime += rsec; \
- wth->capture.nstrace->nspm_curtimelastmsec += rsec * 1000; \
+ (nstrace)->nspm_curtimemsec += RelativeTimems; \
+ rsec = (guint32)((nstrace)->nspm_curtimemsec - (nstrace)->nspm_curtimelastmsec)/1000; \
+ (nstrace)->nspm_curtime += rsec; \
+ (nstrace)->nspm_curtimelastmsec += rsec * 1000; \
} while (0)
+typedef struct {
+ gchar *pnstrace_buf;
+ gint32 nstrace_buf_offset;
+ gint32 nstrace_buflen;
+ /* Performance Monitor Time variables */
+ guint32 nspm_curtime; /* current time since 1970 */
+ guint64 nspm_curtimemsec; /* current time in mili second */
+ guint64 nspm_curtimelastmsec; /* nspm_curtime last update time in milisec */
+ guint64 nsg_creltime;
+ guint64 file_size;
+} nstrace_t;
+
guint32 nspm_signature_isv10(gchar *sigp);
guint32 nspm_signature_isv20(gchar *sigp);
guint32 nspm_signature_version(wtap*, gchar*, gint32);
gchar *nstrace_buf;
gint64 file_size;
gint32 page_size;
+ nstrace_t *nstrace;
errno = WTAP_ERR_CANT_READ;
wth->subtype_seek_read = nstrace_seek_read;
wth->subtype_close = nstrace_close;
- wth->capture.nstrace = g_malloc(sizeof(nstrace_t));
- wth->capture.nstrace->pnstrace_buf = nstrace_buf;
- wth->capture.nstrace->nstrace_buflen = page_size;
- wth->capture.nstrace->nstrace_buf_offset = 0;
- wth->capture.nstrace->nspm_curtime = 0;
- wth->capture.nstrace->nspm_curtimemsec = 0;
- wth->capture.nstrace->nspm_curtimelastmsec = 0;
- wth->capture.nstrace->nsg_creltime = 0;
- wth->capture.nstrace->file_size = file_size;
+ nstrace = (nstrace_t *)g_malloc(sizeof(nstrace_t));
+ wth->priv = (void *)nstrace;
+ nstrace->pnstrace_buf = nstrace_buf;
+ nstrace->nstrace_buflen = page_size;
+ nstrace->nstrace_buf_offset = 0;
+ nstrace->nspm_curtime = 0;
+ nstrace->nspm_curtimemsec = 0;
+ nstrace->nspm_curtimelastmsec = 0;
+ nstrace->nsg_creltime = 0;
+ nstrace->file_size = file_size;
/* Set the start time by looking for the abstime record */
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
{
*err = file_error(wth->fh);
- g_free(wth->capture.nstrace->pnstrace_buf);
- g_free(wth->capture.nstrace);
+ g_free(nstrace->pnstrace_buf);
+ g_free(nstrace);
return 0;
}
if (page_size != file_read(nstrace_buf, 1, page_size, wth->fh))
{
*err = file_error(wth->fh);
- g_free(wth->capture.nstrace->pnstrace_buf);
- g_free(wth->capture.nstrace);
+ g_free(nstrace->pnstrace_buf);
+ g_free(nstrace);
return 0;
}
/* reset the buffer offset */
- wth->capture.nstrace->nstrace_buf_offset = 0;
+ nstrace->nstrace_buf_offset = 0;
}
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
- wth->phdr.ts.secs = wth->capture.nstrace->nspm_curtime;
+ wth->phdr.ts.secs = nstrace->nspm_curtime;
wth->phdr.ts.nsecs = 0;
*err = 0;
#define nstrace_set_start_time_ver(ver) \
gboolean nstrace_set_start_time_v##ver(wtap *wth) \
{\
- gchar* nstrace_buf = wth->capture.nstrace->pnstrace_buf;\
- gint32 nstrace_buf_offset = wth->capture.nstrace->nstrace_buf_offset;\
- gint32 nstrace_buflen = wth->capture.nstrace->nstrace_buflen;\
+ nstrace_t *nstrace = (nstrace_t *)wth->priv;\
+ gchar* nstrace_buf = nstrace->pnstrace_buf;\
+ gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;\
+ gint32 nstrace_buflen = nstrace->nstrace_buflen;\
do\
{\
while (nstrace_buf_offset < nstrace_buflen)\
switch (nspr_getv##ver##recordtype(fp))\
{\
case NSPR_ABSTIME_V##ver:\
- ns_setabstime(wth, pletohl(&((nspr_abstime_v##ver##_t *) fp)->abs_Time), pletohs(&((nspr_abstime_v##ver##_t *) fp)->abs_RelTime));\
- wth->capture.nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv##ver##recordsize(fp);\
- wth->capture.nstrace->nstrace_buflen = nstrace_buflen;\
+ ns_setabstime(nstrace, pletohl(&((nspr_abstime_v##ver##_t *) fp)->abs_Time), pletohs(&((nspr_abstime_v##ver##_t *) fp)->abs_RelTime));\
+ nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv##ver##recordsize(fp);\
+ nstrace->nstrace_buflen = nstrace_buflen;\
return TRUE;\
case NSPR_UNUSEDSPACE_V10:\
nstrace_buf_offset = nstrace_buflen;\
}\
nstrace_buf_offset = 0;\
wth->data_offset += nstrace_buflen;\
- nstrace_buflen = GET_READ_PAGE_SIZE((wth->capture.nstrace->file_size - wth->data_offset));\
+ nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));\
}while((nstrace_buflen > 0) && (nstrace_buflen == (file_read(nstrace_buf, 1, nstrace_buflen, wth->fh))));\
return FALSE;\
}
*/
gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
-
- guint64 nsg_creltime = wth->capture.nstrace->nsg_creltime;
- gchar *nstrace_buf = wth->capture.nstrace->pnstrace_buf;
- gint32 nstrace_buf_offset = wth->capture.nstrace->nstrace_buf_offset;
- gint32 nstrace_buflen = wth->capture.nstrace->nstrace_buflen;
+ nstrace_t *nstrace = (nstrace_t *)wth->priv;
+ guint64 nsg_creltime = nstrace->nsg_creltime;
+ gchar *nstrace_buf = nstrace->pnstrace_buf;
+ gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;
+ gint32 nstrace_buflen = nstrace->nstrace_buflen;
nspr_pktracefull_v10_t *fp;
nspr_pktracepart_v10_t *pp;
case NSPR_PDPKTRACEFULLRX_V10:
nsg_creltime += ns_hrtime2nsec(pletohl(&fp->fp_RelTimeHr));
- wth->phdr.ts.secs = wth->capture.nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);
+ wth->phdr.ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);
wth->phdr.ts.nsecs = (guint32) (nsg_creltime % 1000000000);
wth->phdr.len = pletohs(&fp->nsprRecordSize);
memcpy(buffer_start_ptr(wth->frame_buffer), fp, wth->phdr.caplen);
*data_offset = wth->data_offset + nstrace_buf_offset;
- wth->capture.nstrace->nstrace_buf_offset = nstrace_buf_offset + wth->phdr.len;
- wth->capture.nstrace->nstrace_buflen = nstrace_buflen;
- wth->capture.nstrace->nsg_creltime = nsg_creltime;
+ nstrace->nstrace_buf_offset = nstrace_buf_offset + wth->phdr.len;
+ nstrace->nstrace_buflen = nstrace_buflen;
+ nstrace->nsg_creltime = nsg_creltime;
return TRUE;
case NSPR_PDPKTRACEPARTRX_V10:
nsg_creltime += ns_hrtime2nsec(pletohl(&pp->pp_RelTimeHr));
- wth->phdr.ts.secs = wth->capture.nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);
+ wth->phdr.ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);
wth->phdr.ts.nsecs = (guint32) (nsg_creltime % 1000000000);
wth->phdr.len = pletohs(&pp->pp_PktSizeOrg) + nspr_pktracepart_v10_s;
memcpy(buffer_start_ptr(wth->frame_buffer), pp, wth->phdr.caplen);
*data_offset = wth->data_offset + nstrace_buf_offset;
- wth->capture.nstrace->nstrace_buf_offset = nstrace_buf_offset + wth->phdr.caplen;
- wth->capture.nstrace->nsg_creltime = nsg_creltime;
- wth->capture.nstrace->nstrace_buflen = nstrace_buflen;
+ nstrace->nstrace_buf_offset = nstrace_buf_offset + wth->phdr.caplen;
+ nstrace->nsg_creltime = nsg_creltime;
+ nstrace->nstrace_buflen = nstrace_buflen;
return TRUE;
case NSPR_ABSTIME_V10:
- ns_setabstime(wth, pletohl(&((nspr_abstime_v10_t *) fp)->abs_Time), pletohl(&((nspr_abstime_v10_t *) fp)->abs_RelTime));
+ ns_setabstime(nstrace, pletohl(&((nspr_abstime_v10_t *) fp)->abs_Time), pletohl(&((nspr_abstime_v10_t *) fp)->abs_RelTime));
nstrace_buf_offset += pletohs(&fp->nsprRecordSize);
break;
case NSPR_RELTIME_V10:
- ns_setrelativetime(wth, ((nspr_abstime_v10_t *) fp)->abs_RelTime);
+ ns_setrelativetime(nstrace, ((nspr_abstime_v10_t *) fp)->abs_RelTime);
nstrace_buf_offset += pletohs(&fp->nsprRecordSize);
break;
nstrace_buf_offset = 0;
wth->data_offset += nstrace_buflen;
- nstrace_buflen = GET_READ_PAGE_SIZE((wth->capture.nstrace->file_size - wth->data_offset));
+ nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));
}while((nstrace_buflen > 0) && (nstrace_buflen == (file_read(nstrace_buf, 1, nstrace_buflen, wth->fh))));
return FALSE;
#define TIMEDEFV20(fp,type) \
do {\
nsg_creltime += ns_hrtime2nsec(pletohl(&fp->type##_RelTimeHr));\
- wth->phdr.ts.secs = wth->capture.nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\
+ wth->phdr.ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\
wth->phdr.ts.nsecs = (guint32) (nsg_creltime % 1000000000);\
}while(0)
buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);\
memcpy(buffer_start_ptr(wth->frame_buffer), fp, wth->phdr.caplen);\
*data_offset = wth->data_offset + nstrace_buf_offset;\
- wth->capture.nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\
- wth->capture.nstrace->nstrace_buflen = nstrace_buflen;\
- wth->capture.nstrace->nsg_creltime = nsg_creltime;\
+ nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\
+ nstrace->nstrace_buflen = nstrace_buflen;\
+ nstrace->nsg_creltime = nsg_creltime;\
wth->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##TYPE;\
return TRUE;\
}while(0)
gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
- guint64 nsg_creltime = wth->capture.nstrace->nsg_creltime;
- gchar *nstrace_buf = wth->capture.nstrace->pnstrace_buf;
- gint32 nstrace_buf_offset = wth->capture.nstrace->nstrace_buf_offset;
- gint32 nstrace_buflen = wth->capture.nstrace->nstrace_buflen;
+ nstrace_t *nstrace = (nstrace_t *)wth->priv;
+ guint64 nsg_creltime = nstrace->nsg_creltime;
+ gchar *nstrace_buf = nstrace->pnstrace_buf;
+ gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;
+ gint32 nstrace_buflen = nstrace->nstrace_buflen;
nspr_pktracefull_v20_t *fp20;
nspr_pktracefull_v21_t *fp21;
{
fp20 = (nspr_pktracefull_v20_t *) &nstrace_buf[nstrace_buf_offset];
nstrace_buf_offset += nspr_getv20recordsize((nspr_hd_v20_t *)fp20);
- ns_setabstime(wth, pletohl(&((nspr_abstime_v20_t *) fp20)->abs_Time), pletohs(&((nspr_abstime_v20_t *) fp20)->abs_RelTime));
+ ns_setabstime(nstrace, pletohl(&((nspr_abstime_v20_t *) fp20)->abs_Time), pletohs(&((nspr_abstime_v20_t *) fp20)->abs_RelTime));
break;
}
case NSPR_RELTIME_V20:
{
fp20 = (nspr_pktracefull_v20_t *) &nstrace_buf[nstrace_buf_offset];
- ns_setrelativetime(wth, pletohs(&((nspr_abstime_v20_t *) fp20)->abs_RelTime));
+ ns_setrelativetime(nstrace, pletohs(&((nspr_abstime_v20_t *) fp20)->abs_RelTime));
nstrace_buf_offset += nspr_getv20recordsize((nspr_hd_v20_t *)fp20);
break;
}
nstrace_buf_offset = 0;
wth->data_offset += nstrace_buflen;
- nstrace_buflen = GET_READ_PAGE_SIZE((wth->capture.nstrace->file_size - wth->data_offset));
+ nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - wth->data_offset));
}while((nstrace_buflen > 0) && (nstrace_buflen == (file_read(nstrace_buf, 1, nstrace_buflen, wth->fh))));
return FALSE;
*/
void nstrace_close(wtap *wth)
{
+ nstrace_t *nstrace = (nstrace_t *)wth->priv;
- g_free(wth->capture.nstrace->pnstrace_buf);
- g_free(wth->capture.nstrace);
- return;
+ g_free(nstrace->pnstrace_buf);
}
+typedef struct {
+ guint16 page_offset;
+ guint16 page_len;
+ guint32 absrec_time;
+} nstrace_dump_t;
+
/* Returns 0 if we could write the specified encapsulation type,
** an error indication otherwise. */
int nstrace_10_dump_can_write_encap(int encap)
** failure */
gboolean nstrace_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err)
{
+ nstrace_dump_t *nstrace;
+
if (cant_seek)
{
*err = WTAP_ERR_CANT_WRITE_TO_PIPE;
wdh->subtype_write = nstrace_dump;
- wdh->dump.nstr = g_malloc(sizeof(nstrace_dump_t));
- wdh->dump.nstr->page_offset = 0;
- wdh->dump.nstr->page_len = NSPR_PAGESIZE;
- wdh->dump.nstr->absrec_time = 0;
+ nstrace = (nstrace_dump_t *)g_malloc(sizeof(nstrace_dump_t));
+ wdh->priv = (void *)nstrace;
+ nstrace->page_offset = 0;
+ nstrace->page_len = NSPR_PAGESIZE;
+ nstrace->absrec_time = 0;
return TRUE;
}
gboolean nstrace_add_signature(wtap_dumper *wdh)
{
+ nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
size_t nwritten;
if (wdh->file_type == WTAP_FILE_NETSCALER_1_0)
return FALSE;
/* Move forward the page offset */
- wdh->dump.nstr->page_offset += (guint16) nwritten;
+ nstrace->page_offset += (guint16) nwritten;
} else if (wdh->file_type == WTAP_FILE_NETSCALER_2_0)
{
return FALSE;
/* Move forward the page offset */
- wdh->dump.nstr->page_offset += (guint16) nwritten;
+ nstrace->page_offset += (guint16) nwritten;
} else
{
gboolean nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const guchar *pd)
{
+ nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
size_t nwritten;
guint64 nsg_creltime;
return FALSE;
/* Move forward the page offset */
- wdh->dump.nstr->page_offset += nspr_abstime_v10_s;
+ nstrace->page_offset += nspr_abstime_v10_s;
} else if (wdh->file_type == WTAP_FILE_NETSCALER_2_0)
{
return FALSE;
/* Move forward the page offset */
- wdh->dump.nstr->page_offset += nspr_abstime_v20_s;
+ nstrace->page_offset += nspr_abstime_v20_s;
} else
{
static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
+ nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
size_t nwritten;
- if (wdh->dump.nstr->page_offset == 0)
+ if (nstrace->page_offset == 0)
{
/* Add the signature record and abs time record */
if (wdh->file_type == WTAP_FILE_NETSCALER_1_0)
if (wdh->file_type == WTAP_FILE_NETSCALER_1_0)
{
- if (wdh->dump.nstr->page_offset + phdr->caplen >= wdh->dump.nstr->page_len)
+ if (nstrace->page_offset + phdr->caplen >= nstrace->page_len)
{
/* Start on the next page */
- if (fseek(wdh->fh, (wdh->dump.nstr->page_len - wdh->dump.nstr->page_offset), SEEK_CUR) == -1)
+ if (fseek(wdh->fh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR) == -1)
{
*err = errno;
return FALSE;
}
- wdh->dump.nstr->page_offset = 0;
+ nstrace->page_offset = 0;
/* Possibly add signature and abstime records and increment offset */
if (nstrace_add_signature(wdh) == FALSE)
return FALSE;
}
- wdh->dump.nstr->page_offset += (guint16) nwritten;
+ nstrace->page_offset += (guint16) nwritten;
} else if (wdh->file_type == WTAP_FILE_NETSCALER_2_0)
{
*err = WTAP_ERR_UNSUPPORTED_FILE_TYPE;
return FALSE;
} else if (wdh->file_type == WTAP_FILE_NETSCALER_2_0)
{
- if (wdh->dump.nstr->page_offset + phdr->caplen >= wdh->dump.nstr->page_len)
+ if (nstrace->page_offset + phdr->caplen >= nstrace->page_len)
{
/* Start on the next page */
- if (fseek(wdh->fh, (wdh->dump.nstr->page_len - wdh->dump.nstr->page_offset), SEEK_CUR) == -1)
+ if (fseek(wdh->fh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR) == -1)
{
*err = errno;
return FALSE;
}
- wdh->dump.nstr->page_offset = 0;
+ nstrace->page_offset = 0;
/* Possibly add signature and abstime records and increment offset */
if (nstrace_add_signature(wdh) == FALSE)
return FALSE;
}
- wdh->dump.nstr->page_offset += (guint16) nwritten;
+ nstrace->page_offset += (guint16) nwritten;
}
break;
/* header is followed by data and once again the total length (2 bytes) ! */
+typedef struct {
+ gboolean is_hpux_11;
+} nettl_t;
+
static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean nettl_seek_read(wtap *wth, gint64 seek_off,
int *err, gchar **err_info, gboolean *fddihack);
static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length,
int *err, gboolean fddihack);
-static void nettl_close(wtap *wth);
static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
guint16 dummy[2];
int subsys;
int bytes_read;
+ nettl_t *nettl;
/* Read in the string that should be at the start of a HP file */
errno = WTAP_ERR_CANT_READ;
/* This is an nettl file */
wth->file_type = WTAP_FILE_NETTL;
- wth->capture.nettl = g_malloc(sizeof(nettl_t));
+ nettl = g_malloc(sizeof(nettl_t));
+ wth->priv = (void *)nettl;
if (file_hdr.os_vers[2] == '1' && file_hdr.os_vers[3] == '1')
- wth->capture.nettl->is_hpux_11 = TRUE;
+ nettl->is_hpux_11 = TRUE;
else
- wth->capture.nettl->is_hpux_11 = FALSE;
+ nettl->is_hpux_11 = FALSE;
wth->subtype_read = nettl_read;
wth->subtype_seek_read = nettl_seek_read;
- wth->subtype_close = nettl_close;
wth->snapshot_length = 0; /* not available */
/* read the first header to take a guess at the file encap */
return -1;
if (bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
- g_free(wth->capture.nettl);
+ g_free(nettl);
return -1;
}
return 0;
}
if (file_seek(wth->fh, FILE_HDR_SIZE, SEEK_SET, err) == -1) {
- g_free(wth->capture.nettl);
+ g_free(nettl);
return -1;
}
wth->data_offset = FILE_HDR_SIZE;
union wtap_pseudo_header *pseudo_header, int *err,
gchar **err_info, gboolean *fddihack)
{
+ nettl_t *nettl = (nettl_t *)wth->priv;
int bytes_read;
struct nettlrec_hdr rec_hdr;
guint16 hdr_len;
*
* And what are the extra two bytes?
*/
- if (wth->capture.nettl->is_hpux_11) {
+ if (nettl->is_hpux_11) {
if (file_seek(fh, 2, SEEK_CUR, err) == -1) return -1;
offset += 2;
}
return TRUE;
}
-static void nettl_close(wtap *wth)
-{
- g_free(wth->capture.nettl);
-}
-
/* Returns 0 if we could write the specified encapsulation type,
an error indication otherwise. nettl files are WTAP_ENCAP_UNKNOWN
guint8 *pd, int length, int *err, char **err_info);
static gboolean skip_to_next_packet(wtap *wth, int offset,
int offset_to_next_packet, int *err, char **err_info);
-static gboolean observer_dump_close(wtap_dumper *wdh, int *err);
static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
return TRUE;
}
+typedef struct {
+ guint64 packet_count;
+ guint8 network_type;
+} niobserver_dump_t;
+
/* Returns 0 if we could write the specified encapsulation type,
an error indication otherwise. */
int network_instruments_dump_can_write_encap(int encap)
char comment[64];
struct tm *current_time;
time_t system_time;
+ niobserver_dump_t *niobserver;
if (cant_seek) {
*err = WTAP_ERR_CANT_WRITE_TO_PIPE;
}
wdh->subtype_write = observer_dump;
- wdh->subtype_close = observer_dump_close;
- wdh->dump.niobserver = g_malloc(sizeof(niobserver_dump_t));
- wdh->dump.niobserver->packet_count = 0;
- wdh->dump.niobserver->network_type = from_wtap_encap[wdh->encap];
+ niobserver = (niobserver_dump_t *)g_malloc(sizeof(niobserver_dump_t));
+ wdh->priv = (void *)niobserver;
+ niobserver->packet_count = 0;
+ niobserver->network_type = from_wtap_encap[wdh->encap];
/* create the file comment */
time(&system_time);
const union wtap_pseudo_header *pseudo_header _U_, const guchar *pd,
int *err)
{
- niobserver_dump_t *niobserver = wdh->dump.niobserver;
+ niobserver_dump_t *niobserver = (niobserver_dump_t *)wdh->priv;
packet_entry_header packet_header;
size_t nwritten;
guint64 capture_nanoseconds;
return TRUE;
}
-
-/* just returns TRUE, there is no clean up needed */
-static gboolean observer_dump_close(wtap_dumper *wdh _U_, int *err _U_)
-{
- return TRUE;
-}
struct netxrayrec_2_x_hdr hdr_2_x;
};
+typedef struct {
+ time_t start_time;
+ double ticks_per_sec;
+ double start_timestamp;
+ gboolean wrapped;
+ guint32 nframes;
+ gint64 start_offset;
+ gint64 end_offset;
+ int version_major;
+ gboolean fcs_valid; /* if packets have valid FCS at the end */
+ guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
+} netxray_t;
+
static gboolean netxray_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
static gboolean netxray_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, union netxrayrec_hdr *hdr);
static gboolean netxray_read_rec_data(FILE_T fh, guint8 *data_ptr,
guint32 packet_size, int *err);
-static void netxray_close(wtap *wth);
static gboolean netxray_dump_1_1(wtap_dumper *wdh,
const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
#define NUM_NETXRAY_ENCAPS (sizeof netxray_encap / sizeof netxray_encap[0])
int file_encap;
guint isdn_type = 0;
+ netxray_t *netxray;
/* Read in the string that should be at the start of a NetXRay
* file */
/* This is a netxray file */
wth->file_type = file_type;
- wth->capture.netxray = g_malloc(sizeof(netxray_t));
+ netxray = (netxray_t *)g_malloc(sizeof(netxray_t));
+ wth->priv = (void *)netxray;
wth->subtype_read = netxray_read;
wth->subtype_seek_read = netxray_seek_read;
- wth->subtype_close = netxray_close;
wth->file_encap = file_encap;
wth->snapshot_length = 0; /* not available in header */
- wth->capture.netxray->start_time = pletohl(&hdr.start_time);
- wth->capture.netxray->ticks_per_sec = ticks_per_sec;
- wth->capture.netxray->start_timestamp = start_timestamp;
- wth->capture.netxray->version_major = version_major;
+ netxray->start_time = pletohl(&hdr.start_time);
+ netxray->ticks_per_sec = ticks_per_sec;
+ netxray->start_timestamp = start_timestamp;
+ netxray->version_major = version_major;
/*
* If frames have an extra 4 bytes of stuff at the end, is
* it an FCS, or just junk?
*/
- wth->capture.netxray->fcs_valid = FALSE;
+ netxray->fcs_valid = FALSE;
switch (file_encap) {
case WTAP_ENCAP_ETHERNET:
*/
if (version_major == 2) {
if (hdr.realtick[1] == 0x34 && hdr.realtick[2] == 0x12)
- wth->capture.netxray->fcs_valid = TRUE;
+ netxray->fcs_valid = TRUE;
}
break;
}
* Remember the ISDN type, as we need it to interpret the
* channel number in ISDN captures.
*/
- wth->capture.netxray->isdn_type = isdn_type;
+ netxray->isdn_type = isdn_type;
/* Remember the offset after the last packet in the capture (which
* isn't necessarily the last packet in the file), as it appears
* there's sometimes crud after it.
* XXX: Remember 'start_offset' to help testing for 'short file' at EOF
*/
- wth->capture.netxray->wrapped = FALSE;
- wth->capture.netxray->nframes = pletohl(&hdr.nframes);
- wth->capture.netxray->start_offset = pletohl(&hdr.start_offset);
- wth->capture.netxray->end_offset = pletohl(&hdr.end_offset);
+ netxray->wrapped = FALSE;
+ netxray->nframes = pletohl(&hdr.nframes);
+ netxray->start_offset = pletohl(&hdr.start_offset);
+ netxray->end_offset = pletohl(&hdr.end_offset);
/* Seek to the beginning of the data records. */
if (file_seek(wth->fh, pletohl(&hdr.start_offset), SEEK_SET, err) == -1) {
- g_free(wth->capture.netxray);
+ g_free(netxray);
return -1;
}
wth->data_offset = pletohl(&hdr.start_offset);
static gboolean netxray_read(wtap *wth, int *err, gchar **err_info _U_,
gint64 *data_offset)
{
+ netxray_t *netxray = (netxray_t *)wth->priv;
guint32 packet_size;
union netxrayrec_hdr hdr;
int hdr_size;
reread:
/* Have we reached the end of the packet data? */
- if (wth->data_offset == wth->capture.netxray->end_offset) {
+ if (wth->data_offset == netxray->end_offset) {
/* Yes. */
*err = 0; /* it's just an EOF, not an error */
return FALSE;
* partial frame header (or partial frame data) record, then the
* netxray_read... functions will detect the short record.
*/
- if (wth->capture.netxray->start_offset < wth->capture.netxray->end_offset) {
+ if (netxray->start_offset < netxray->end_offset) {
*err = WTAP_ERR_SHORT_READ;
return FALSE;
}
- if (!wth->capture.netxray->wrapped) {
+ if (!netxray->wrapped) {
/* Yes. Remember that we did. */
- wth->capture.netxray->wrapped = TRUE;
+ netxray->wrapped = TRUE;
if (file_seek(wth->fh, CAPTUREFILE_HEADER_SIZE,
SEEK_SET, err) == -1)
return FALSE;
/*
* Read the packet data.
*/
- if (wth->capture.netxray->version_major == 0)
+ if (netxray->version_major == 0)
packet_size = pletohs(&hdr.old_hdr.len);
else
packet_size = pletohs(&hdr.hdr_1_x.incl_len);
padding = netxray_set_pseudo_header(wth, pd, packet_size,
&wth->pseudo_header, &hdr);
- if (wth->capture.netxray->version_major == 0) {
+ if (netxray->version_major == 0) {
t = (double)pletohl(&hdr.old_hdr.timelo)
+ (double)pletohl(&hdr.old_hdr.timehi)*4294967296.0;
- t /= wth->capture.netxray->ticks_per_sec;
- t -= wth->capture.netxray->start_timestamp;
- wth->phdr.ts.secs = wth->capture.netxray->start_time + (long)t;
+ t /= netxray->ticks_per_sec;
+ t -= netxray->start_timestamp;
+ wth->phdr.ts.secs = netxray->start_time + (long)t;
wth->phdr.ts.nsecs = (int)((t-(double)(unsigned long)(t))
*1.0e9);
/*
} else {
t = (double)pletohl(&hdr.hdr_1_x.timelo)
+ (double)pletohl(&hdr.hdr_1_x.timehi)*4294967296.0;
- t /= wth->capture.netxray->ticks_per_sec;
- t -= wth->capture.netxray->start_timestamp;
- wth->phdr.ts.secs = wth->capture.netxray->start_time + (time_t)t;
+ t /= netxray->ticks_per_sec;
+ t -= netxray->start_timestamp;
+ wth->phdr.ts.secs = netxray->start_time + (time_t)t;
wth->phdr.ts.nsecs = (int)((t-(double)(unsigned long)(t))
*1.0e9);
/*
netxray_read_rec_header(wtap *wth, FILE_T fh, union netxrayrec_hdr *hdr,
int *err)
{
+ netxray_t *netxray = (netxray_t *)wth->priv;
int bytes_read;
int hdr_size = 0;
/* Read record header. */
- switch (wth->capture.netxray->version_major) {
+ switch (netxray->version_major) {
case 0:
hdr_size = sizeof (struct old_netxrayrec_hdr);
netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
union wtap_pseudo_header *pseudo_header, union netxrayrec_hdr *hdr)
{
+ netxray_t *netxray = (netxray_t *)wth->priv;
guint padding = 0;
/*
* If this is Ethernet, 802.11, ISDN, X.25, or ATM, set the
* pseudo-header.
*/
- switch (wth->capture.netxray->version_major) {
+ switch (netxray->version_major) {
case 1:
switch (wth->file_encap) {
* We have 4 bytes of stuff at the
* end of the frame - FCS, or junk?
*/
- if (wth->capture.netxray->fcs_valid) {
+ if (netxray->fcs_valid) {
/*
* FCS.
*/
* We have 4 bytes of stuff at the
* end of the frame - FCS, or junk?
*/
- if (wth->capture.netxray->fcs_valid) {
+ if (netxray->fcs_valid) {
/*
* FCS.
*/
(hdr->hdr_2_x.xxx[12] & 0x01);
pseudo_header->isdn.channel =
hdr->hdr_2_x.xxx[13] & 0x1F;
- switch (wth->capture.netxray->isdn_type) {
+ switch (netxray->isdn_type) {
case 1:
/*
return TRUE;
}
-static void
-netxray_close(wtap *wth)
-{
- g_free(wth->capture.netxray);
-}
+typedef struct {
+ gboolean first_frame;
+ struct wtap_nstime start;
+ guint32 nframes;
+} netxray_dump_t;
static const struct {
int wtap_encap_value;
failure */
gboolean netxray_dump_open_1_1(wtap_dumper *wdh, gboolean cant_seek, int *err)
{
+ netxray_dump_t *netxray;
+
/* This is a NetXRay file. We can't fill in some fields in the header
until all the packets have been written, so we can't write to a
pipe. */
return FALSE;
}
- wdh->dump.netxray = g_malloc(sizeof(netxray_dump_t));
- wdh->dump.netxray->first_frame = TRUE;
- wdh->dump.netxray->start.secs = 0;
- wdh->dump.netxray->start.nsecs = 0;
- wdh->dump.netxray->nframes = 0;
+ netxray = (netxray_dump_t *)g_malloc(sizeof(netxray_dump_t));
+ wdh->priv = (void *)netxray;
+ netxray->first_frame = TRUE;
+ netxray->start.secs = 0;
+ netxray->start.nsecs = 0;
+ netxray->nframes = 0;
return TRUE;
}
const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err)
{
- netxray_dump_t *netxray = wdh->dump.netxray;
+ netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv;
guint64 timestamp;
guint32 t32;
struct netxrayrec_1_x_hdr rec_hdr;
static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err)
{
char hdr_buf[CAPTUREFILE_HEADER_SIZE - sizeof(netxray_magic)];
- netxray_dump_t *netxray = wdh->dump.netxray;
+ netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv;
guint32 filelen;
struct netxray_hdr file_hdr;
size_t nwritten;
failure */
gboolean netxray_dump_open_2_0(wtap_dumper *wdh, gboolean cant_seek, int *err)
{
+ netxray_dump_t *netxray;
+
/* This is a NetXRay file. We can't fill in some fields in the header
until all the packets have been written, so we can't write to a
pipe. */
return FALSE;
}
- wdh->dump.netxray = g_malloc(sizeof(netxray_dump_t));
- wdh->dump.netxray->first_frame = TRUE;
- wdh->dump.netxray->start.secs = 0;
- wdh->dump.netxray->start.nsecs = 0;
- wdh->dump.netxray->nframes = 0;
+ netxray = (netxray_dump_t *)g_malloc(sizeof(netxray_dump_t));
+ wdh->priv = (void *)netxray;
+ netxray->first_frame = TRUE;
+ netxray->start.secs = 0;
+ netxray->start.nsecs = 0;
+ netxray->nframes = 0;
return TRUE;
}
const union wtap_pseudo_header *pseudo_header _U_,
const guchar *pd, int *err)
{
- netxray_dump_t *netxray = wdh->dump.netxray;
+ netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv;
guint64 timestamp;
guint32 t32;
struct netxrayrec_2_x_hdr rec_hdr;
static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err)
{
char hdr_buf[CAPTUREFILE_HEADER_SIZE - sizeof(netxray_magic)];
- netxray_dump_t *netxray = wdh->dump.netxray;
+ netxray_dump_t *netxray = (netxray_dump_t *)wdh->priv;
guint32 filelen;
struct netxray_hdr file_hdr;
size_t nwritten;
/* This is a ngsniffer file */
ngsniffer = (ngsniffer_t *)g_malloc(sizeof(ngsniffer_t));
- wth->capture.generic = ngsniffer;
+ wth->priv = (void *)ngsniffer;
ngsniffer->maj_vers = maj_vers;
ngsniffer->min_vers = pletohs(&version.min_vers);
guint64 t, tsecs, tpsecs;
guchar *pd;
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
for (;;) {
/*
* Read the record header.
{
ngsniffer_t *ngsniffer;
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (ngsniffer->seq.buf != NULL) {
g_free(ngsniffer->seq.buf);
ngsniffer->seq.buf = NULL;
{
ngsniffer_t *ngsniffer;
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (ngsniffer->rand.buf != NULL)
g_free(ngsniffer->rand.buf);
if (ngsniffer->first_blob != NULL) {
g_list_foreach(ngsniffer->first_blob, free_blob, NULL);
g_list_free(ngsniffer->first_blob);
}
- g_free(ngsniffer);
}
typedef struct {
wdh->subtype_close = ngsniffer_dump_close;
ngsniffer = (ngsniffer_dump_t *)g_malloc(sizeof(ngsniffer_dump_t));
- wdh->dump.opaque = ngsniffer;
+ wdh->priv = (void *)ngsniffer;
ngsniffer->first_frame = TRUE;
ngsniffer->start = 0;
static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
- ngsniffer_dump_t *ngsniffer = (ngsniffer_dump_t *)wdh->dump.opaque;
+ ngsniffer_dump_t *ngsniffer = (ngsniffer_dump_t *)wdh->priv;
struct frame2_rec rec_hdr;
size_t nwritten;
char buf[6];
size_t bytes_to_copy;
size_t bytes_left;
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
if (is_random) {
infile = wth->random_fh;
comp_stream = &ngsniffer->rand;
if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED)
return file_seek(wth->fh, offset, whence, err);
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
switch (whence) {
case SEEK_SET:
if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED)
return file_seek(wth->random_fh, offset, whence, err);
- ngsniffer = (ngsniffer_t *)wth->capture.generic;
+ ngsniffer = (ngsniffer_t *)wth->priv;
switch (whence) {
} interface_data_t;
+typedef struct {
+ gboolean byte_swapped;
+ guint16 version_major;
+ guint16 version_minor;
+ gint8 if_fcslen;
+ GArray *interface_data;
+ guint number_of_interfaces;
+} pcapng_t;
+
static int
pcapng_get_encap(gint id, pcapng_t *pn)
{
int bytes_read;
pcapng_t pn;
wtapng_block_t wblock;
-
+ pcapng_t *pcapng;
/* we don't know the byte swapping of the file yet */
pn.byte_swapped = FALSE;
wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->snapshot_length = 0;
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
- wth->capture.pcapng = (pcapng_t *)g_malloc(sizeof(pcapng_t));
- *wth->capture.pcapng = pn;
+ pcapng = (pcapng_t *)g_malloc(sizeof(pcapng_t));
+ wth->priv = (void *)pcapng;
+ *pcapng = pn;
wth->subtype_read = pcapng_read;
wth->subtype_seek_read = pcapng_seek_read;
wth->subtype_close = pcapng_close;
static gboolean
pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
+ pcapng_t *pcapng = (pcapng_t *)wth->priv;
int bytes_read;
guint64 ts;
wtapng_block_t wblock;
-
pcapng_debug1("pcapng_read: wth->data_offset is initially %" G_GINT64_MODIFIER "u", wth->data_offset);
*data_offset = wth->data_offset;
pcapng_debug1("pcapng_read: *data_offset is initially set to %" G_GINT64_MODIFIER "u", *data_offset);
/* read next block */
while (1) {
- bytes_read = pcapng_read_block(wth->fh, wth->capture.pcapng, &wblock, err, err_info);
+ bytes_read = pcapng_read_block(wth->fh, pcapng, &wblock, err, err_info);
if (bytes_read <= 0) {
pcapng_debug0("pcapng_read: couldn't read packet block");
return FALSE;
wth->phdr.caplen = wblock.data.packet.cap_len - wblock.data.packet.pseudo_header_len;
wth->phdr.len = wblock.data.packet.packet_len - wblock.data.packet.pseudo_header_len;
- if (wblock.data.packet.interface_id < wth->capture.pcapng->number_of_interfaces) {
+ if (wblock.data.packet.interface_id < pcapng->number_of_interfaces) {
interface_data_t int_data;
guint64 time_units_per_second;
gint id;
id = (gint)wblock.data.packet.interface_id;
- int_data = g_array_index(wth->capture.pcapng->interface_data, interface_data_t, id);
+ int_data = g_array_index(pcapng->interface_data, interface_data_t, id);
time_units_per_second = int_data.time_units_per_second;
wth->phdr.pkt_encap = int_data.wtap_encap;
wth->phdr.ts.secs = (time_t)(ts / time_units_per_second);
union wtap_pseudo_header *pseudo_header, guchar *pd, int length _U_,
int *err, gchar **err_info)
{
+ pcapng_t *pcapng = (pcapng_t *)wth->priv;
guint64 bytes_read64;
int bytes_read;
wtapng_block_t wblock;
wblock.file_encap = &wth->file_encap;
/* read the block */
- bytes_read = pcapng_read_block(wth->random_fh, wth->capture.pcapng, &wblock, err, err_info);
+ bytes_read = pcapng_read_block(wth->random_fh, pcapng, &wblock, err, err_info);
if (bytes_read <= 0) {
*err = file_error(wth->random_fh);
pcapng_debug3("pcapng_seek_read: couldn't read packet block (err=%d, errno=%d, bytes_read=%d).",
static void
pcapng_close(wtap *wth)
{
+ pcapng_t *pcapng = (pcapng_t *)wth->priv;
+
pcapng_debug0("pcapng_close: closing file");
- if (wth->capture.pcapng->interface_data != NULL) {
- g_array_free(wth->capture.pcapng->interface_data, TRUE);
+ if (pcapng->interface_data != NULL) {
+ g_array_free(pcapng->interface_data, TRUE);
}
- g_free(wth->capture.pcapng);
}
+typedef struct {
+ GArray *interface_data;
+ guint number_of_interfaces;
+} pcapng_dump_t;
+
static gboolean
pcapng_write_section_header_block(wtap_dumper *wdh, wtapng_block_t *wblock, int *err)
{
{
gint i;
interface_data_t int_data;
-
- for(i = 0; i < (gint)wdh->dump.pcapng->number_of_interfaces; i++) {
- int_data = g_array_index(wdh->dump.pcapng->interface_data, interface_data_t, i);
+ pcapng_dump_t *pcapng = (pcapng_dump_t *)wdh->priv;
+
+ for(i = 0; i < (gint)pcapng->number_of_interfaces; i++) {
+ int_data = g_array_index(pcapng->interface_data, interface_data_t, i);
if (wtap_encap == int_data.wtap_encap) {
return (guint32)i;
}
interface_data_t int_data;
guint32 interface_id;
guint64 ts;
+ pcapng_dump_t *pcapng = (pcapng_dump_t *)wdh->priv;
pcapng_debug2("pcapng_dump: encap = %d (%s)",
phdr->pkt_encap,
return FALSE;
}
- interface_id = wdh->dump.pcapng->number_of_interfaces;
+ interface_id = pcapng->number_of_interfaces;
int_data.wtap_encap = phdr->pkt_encap;
int_data.time_units_per_second = 0;
- g_array_append_val(wdh->dump.pcapng->interface_data, int_data);
- wdh->dump.pcapng->number_of_interfaces++;
+ g_array_append_val(pcapng->interface_data, int_data);
+ pcapng->number_of_interfaces++;
pcapng_debug3("pcapng_dump: added interface description block with index %u for encap = %d (%s).",
interface_id,
Returns TRUE on success, FALSE on failure. */
static gboolean pcapng_dump_close(wtap_dumper *wdh, int *err _U_)
{
+ pcapng_dump_t *pcapng = (pcapng_dump_t *)wdh->priv;
+
pcapng_debug0("pcapng_dump_close");
- g_array_free(wdh->dump.pcapng->interface_data, TRUE);
- wdh->dump.pcapng->number_of_interfaces = 0;
+ g_array_free(pcapng->interface_data, TRUE);
+ pcapng->number_of_interfaces = 0;
return TRUE;
}
pcapng_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
{
wtapng_block_t wblock;
+ pcapng_dump_t *pcapng;
wblock.frame_buffer = NULL;
wblock.pseudo_header = NULL;
/* This is a pcapng file */
wdh->subtype_write = pcapng_dump;
wdh->subtype_close = pcapng_dump_close;
- wdh->dump.pcapng = (pcapng_dump_t *)g_malloc(sizeof(pcapng_dump_t));
- wdh->dump.pcapng->interface_data = g_array_new(FALSE, FALSE, sizeof(interface_data_t));
- wdh->dump.pcapng->number_of_interfaces = 0;
+ pcapng = (pcapng_dump_t *)g_malloc(sizeof(pcapng_dump_t));
+ wdh->priv = (void *)pcapng;
+ pcapng->interface_data = g_array_new(FALSE, FALSE, sizeof(interface_data_t));
+ pcapng->number_of_interfaces = 0;
/* write the section header block */
wblock.type = BLOCK_TYPE_SHB;
if (file_seek(wth->fh, 5, SEEK_SET, err) == -1)
return -1;
- state = wth->capture.generic = g_malloc(sizeof(pppdump_t));
+ state = (pppdump_t *)g_malloc(sizeof(pppdump_t));
+ wth->priv = (void *)state;
state->timestamp = pntohl(&buffer[1]);
state->tenths = 0;
buffer_assure_space(wth->frame_buffer, PPPD_BUF_SIZE);
buf = buffer_start_ptr(wth->frame_buffer);
- state = wth->capture.generic;
+ state = wth->priv;
/* If we have a random stream open, allocate a structure to hold
the information needed to read this packet's data again. */
pkt_id *pid;
gint64 num_bytes_to_skip;
- state = wth->capture.generic;
+ state = wth->priv;
pid = g_ptr_array_index(state->pids, seek_off);
if (!pid) {
{
pppdump_t *state;
- state = wth->capture.generic;
+ state = (pppdump_t *)wth->priv;
if (state->seek_state) { /* should always be TRUE */
g_free(state->seek_state);
}
g_ptr_array_free(state->pids, TRUE);
}
-
- g_free(state);
-
}
/* Local functions to handle file reads and writes */
static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset);
-static void visual_close(wtap *wth);
static gboolean visual_seek_read(wtap *wth, gint64 seek_off,
union wtap_pseudo_header *pseudo_header, guchar *pd, int packet_size,
int *err, gchar **err_info);
/* Set up the pointers to the handlers for this file type */
wth->subtype_read = visual_read;
wth->subtype_seek_read = visual_seek_read;
- wth->subtype_close = visual_close;
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
/* Add Visual-specific information to the wiretap struct for later use. */
- visual = g_malloc(sizeof(struct visual_read_info));
- wth->capture.generic = visual;
+ visual = (struct visual_read_info *)g_malloc(sizeof(struct visual_read_info));
+ wth->priv = (void *)visual;
visual->num_pkts = pletohl(&vfile_hdr.num_pkts);
visual->start_time = ((double) pletohl(&vfile_hdr.start_time)) * 1000000;
visual->current_pkt = 1;
static gboolean visual_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
- struct visual_read_info *visual = wth->capture.generic;
+ struct visual_read_info *visual = (struct visual_read_info *)wth->priv;
guint32 packet_size = 0;
int bytes_read;
struct visual_pkt_hdr vpkt_hdr;
return TRUE;
}
-
-/* Close a file opened for reading. */
-static void visual_close(wtap *wth)
-{
- /* Free the info allocated by a Visual file reader. */
- if (wth->capture.generic)
- g_free(wth->capture.generic);
- wth->capture.generic = 0;
-}
-
-
/* Read packet data for random access.
This gets the packet data and rebuilds the pseudo header so that
the direction flag works. */
/* Create a struct to hold file information for the duration
of the write */
- visual = g_malloc(sizeof(struct visual_write_info));
- wdh->dump.opaque = visual;
+ visual = (struct visual_write_info *)g_malloc(sizeof(struct visual_write_info));
+ wdh->priv = (void *)visual;
visual->index_table_index = 0;
visual->index_table_size = 1024;
visual->index_table = 0;
static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err)
{
- struct visual_write_info * visual = wdh->dump.opaque;
+ struct visual_write_info * visual = wdh->priv;
struct visual_pkt_hdr vpkt_hdr;
size_t hdr_size = sizeof vpkt_hdr;
size_t nwritten;
Returns TRUE on success, FALSE on failure. */
static gboolean visual_dump_close(wtap_dumper *wdh, int *err)
{
- struct visual_write_info * visual = wdh->dump.opaque;
+ struct visual_write_info * visual = wdh->priv;
size_t n_to_write;
size_t nwritten;
struct visual_file_hdr vfile_hdr;
/* Free the memory allocated by a visual file writer. */
static void visual_dump_free(wtap_dumper *wdh)
{
- struct visual_write_info * visual = wdh->dump.opaque;
+ struct visual_write_info * visual = wdh->priv;
if (visual)
{
/* Free the index table memory. */
if (visual->index_table)
g_free(visual->index_table);
-
- /* Free the write file info struct. */
- g_free(visual);
- wdh->dump.opaque = 0;
}
}
#include "wtap.h"
-typedef struct {
- gboolean byte_swapped;
-} i4btrace_t;
-
-typedef struct {
- gboolean is_hpux_11;
-} nettl_t;
-
-typedef struct {
- gboolean byte_swapped;
- guint16 version_major;
- guint16 version_minor;
- gint8 if_fcslen;
- GArray *interface_data;
- guint number_of_interfaces;
-} pcapng_t;
-
-typedef struct {
- time_t start_secs;
- guint32 start_usecs;
- guint8 version_major;
- guint32 *frame_table;
- guint32 frame_table_size;
- guint current_frame;
-} netmon_t;
-
-typedef struct {
- time_t start_time;
- double ticks_per_sec;
- double start_timestamp;
- gboolean wrapped;
- guint32 nframes;
- gint64 start_offset;
- gint64 end_offset;
- int version_major;
- gboolean fcs_valid; /* if packets have valid FCS at the end */
- guint isdn_type; /* 1 = E1 PRI, 2 = T1 PRI, 3 = BRI */
-} netxray_t;
-
-typedef struct {
- time_t inittime;
- int adjusted;
- gint64 next_packet_seek_start;
-} ascend_t;
-
-typedef struct {
- gboolean byteswapped;
-} csids_t;
-
-typedef struct {
- struct timeval reference_time;
-} etherpeek_t;
-
-typedef struct {
- gboolean has_fcs;
-} airopeek9_t;
-
-typedef struct _k12_t k12_t;
-
-typedef struct {
- struct wtap_nstime now;
- time_t t0;
-} mpeg_t;
-
-typedef struct {
- gchar *pnstrace_buf;
- gint32 nstrace_buf_offset;
- gint32 nstrace_buflen;
- /* Performance Monitor Time variables */
- guint32 nspm_curtime; /* current time since 1970 */
- guint64 nspm_curtimemsec; /* current time in mili second */
- guint64 nspm_curtimelastmsec; /* nspm_curtime last update time in milisec */
- guint64 nsg_creltime;
- guint64 file_size;
-} nstrace_t;
-
-
typedef gboolean (*subtype_read_func)(struct wtap*, int*, char**, gint64*);
typedef gboolean (*subtype_seek_read_func)(struct wtap*, gint64, union wtap_pseudo_header*,
guint8*, int, int *, char **);
gint64 data_offset;
- union {
- i4btrace_t *i4btrace;
- nettl_t *nettl;
- netmon_t *netmon;
- netxray_t *netxray;
- ascend_t *ascend;
- csids_t *csids;
- etherpeek_t *etherpeek;
- airopeek9_t *airopeek9;
- k12_t *k12;
- mpeg_t *mpeg;
- nstrace_t *nstrace;
- void *generic;
- pcapng_t *pcapng;
- } capture;
+ void *priv;
subtype_read_func subtype_read;
subtype_seek_read_func subtype_seek_read;
const guchar*, int*);
typedef gboolean (*subtype_close_func)(struct wtap_dumper*, int*);
-typedef struct {
- gboolean first_frame;
- struct wtap_nstime start;
- guint32 nframes;
-} netxray_dump_t;
-
-typedef struct {
- gboolean got_first_record_time;
- struct wtap_nstime first_record_time;
- guint32 frame_table_offset;
- guint32 *frame_table;
- guint frame_table_index;
- guint frame_table_size;
-} netmon_dump_t;
-
-typedef struct {
- guint16 page_offset;
- guint16 page_len;
- guint32 absrec_time;
-} nstrace_dump_t;
-
-typedef struct {
- guint32 nframes;
-} _5views_dump_t;
-
-typedef struct {
- guint64 packet_count;
- guint8 network_type;
-} niobserver_dump_t;
-
-typedef struct {
- guint32 file_len;
- guint32 num_of_records;
- guint32 file_offset;
-} k12_dump_t;
-
-typedef struct {
- gboolean first_packet_written;
- struct wtap_nstime start_time;
-} dct2000_dump_t;
-
-typedef struct {
- GArray *interface_data;
- guint number_of_interfaces;
-} pcapng_dump_t;
-
struct wtap_dumper {
FILE* fh;
int file_type;
gboolean compressed;
gint64 bytes_dumped;
- union {
- void *opaque;
- netmon_dump_t *netmon;
- netxray_dump_t *netxray;
- _5views_dump_t *_5views;
- niobserver_dump_t *niobserver;
- k12_dump_t *k12;
- dct2000_dump_t *dct2000;
- nstrace_dump_t *nstr;
- pcapng_dump_t *pcapng;
- } dump;
+ void *priv;
subtype_write_func subtype_write;
subtype_close_func subtype_close;
if (wth->random_fh != NULL)
file_close(wth->random_fh);
+ if (wth->priv != NULL)
+ g_free(wth->priv);
+
g_free(wth);
}