1999-10-18 12:48:14 +00:00
|
|
|
/* display_opts.c
|
1999-06-19 01:14:51 +00:00
|
|
|
* Routines for packet display windows
|
|
|
|
*
|
2000-05-08 05:51:37 +00:00
|
|
|
* $Id: display_opts.c,v 1.7 2000/05/08 05:51:37 guy Exp $
|
1999-06-19 01:14:51 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
1999-06-19 01:14:51 +00:00
|
|
|
#include <unistd.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
|
|
|
|
1999-06-19 01:14:51 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# ifdef HAVE_STDARG_H
|
|
|
|
# include <stdarg.h>
|
|
|
|
# else
|
|
|
|
# include <varargs.h>
|
|
|
|
# endif
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_SOCKIO_H
|
|
|
|
# include <sys/sockio.h>
|
|
|
|
#endif
|
|
|
|
|
1999-09-29 22:19:24 +00:00
|
|
|
#include "globals.h"
|
1999-06-19 01:14:51 +00:00
|
|
|
#include "timestamp.h"
|
|
|
|
#include "packet.h"
|
|
|
|
#include "file.h"
|
1999-10-18 12:48:14 +00:00
|
|
|
#include "display_opts.h"
|
2000-05-08 05:12:19 +00:00
|
|
|
#include "ui_util.h"
|
2000-05-08 01:23:16 +00:00
|
|
|
#include "dlg_utils.h"
|
1999-06-19 01:14:51 +00:00
|
|
|
|
|
|
|
extern capture_file cf;
|
1999-06-19 01:47:43 +00:00
|
|
|
extern GtkWidget *packet_list;
|
1999-06-19 01:14:51 +00:00
|
|
|
|
|
|
|
/* Display callback data keys */
|
|
|
|
#define E_DISPLAY_TIME_ABS_KEY "display_time_abs"
|
|
|
|
#define E_DISPLAY_TIME_REL_KEY "display_time_rel"
|
|
|
|
#define E_DISPLAY_TIME_DELTA_KEY "display_time_delta"
|
1999-09-19 15:54:54 +00:00
|
|
|
#define E_DISPLAY_AUTO_SCROLL_KEY "display_auto_scroll"
|
1999-09-26 14:40:01 +00:00
|
|
|
#define E_DISPLAY_NAME_RESOLUTION_KEY "display_name_resolution"
|
2000-01-24 04:44:58 +00:00
|
|
|
#define E_DISPLAY_IP_DSCP_KEY "display_ip_dscp"
|
1999-06-19 01:14:51 +00:00
|
|
|
|
|
|
|
static void display_opt_ok_cb(GtkWidget *, gpointer);
|
1999-06-22 22:43:56 +00:00
|
|
|
static void display_opt_apply_cb(GtkWidget *, gpointer);
|
1999-06-19 01:14:51 +00:00
|
|
|
static void display_opt_close_cb(GtkWidget *, gpointer);
|
2000-05-08 05:12:19 +00:00
|
|
|
static void display_opt_destroy_cb(GtkWidget *, gpointer);
|
1999-06-19 01:14:51 +00:00
|
|
|
|
1999-06-24 05:37:04 +00:00
|
|
|
/*
|
2000-05-08 05:12:19 +00:00
|
|
|
* Keep a static pointer to the current "Display Options" window, if any,
|
|
|
|
* so that if somebody tries to do "Display:Options" while there's already
|
|
|
|
* a "Display Options" window up, we just pop up the existing one, rather
|
|
|
|
* than creating a new one.
|
1999-06-24 05:37:04 +00:00
|
|
|
*/
|
2000-05-08 05:12:19 +00:00
|
|
|
static GtkWidget *display_opt_w;
|
|
|
|
|
1999-06-24 05:37:04 +00:00
|
|
|
static ts_type prev_timestamp_type;
|
|
|
|
|
1999-06-19 01:14:51 +00:00
|
|
|
void
|
|
|
|
display_opt_cb(GtkWidget *w, gpointer d) {
|
2000-05-08 05:12:19 +00:00
|
|
|
GtkWidget *button, *main_vb, *bbox, *ok_bt, *apply_bt, *cancel_bt;
|
2000-05-08 04:23:46 +00:00
|
|
|
GtkAccelGroup *accel_group;
|
1999-06-19 01:14:51 +00:00
|
|
|
|
2000-05-08 05:12:19 +00:00
|
|
|
if (display_opt_w != NULL) {
|
|
|
|
/* There's already a "Display Options" dialog box; reactivate it. */
|
|
|
|
reactivate_window(display_opt_w);
|
1999-06-24 05:37:04 +00:00
|
|
|
return;
|
2000-05-08 05:12:19 +00:00
|
|
|
}
|
1999-06-24 05:37:04 +00:00
|
|
|
|
|
|
|
/* Save the current timestamp type, so that "Cancel" can put it back
|
|
|
|
if we've changed it with "Apply". */
|
|
|
|
prev_timestamp_type = timestamp_type;
|
|
|
|
|
1999-06-19 01:14:51 +00:00
|
|
|
display_opt_w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(display_opt_w), "Ethereal: Display Options");
|
2000-05-08 05:12:19 +00:00
|
|
|
gtk_signal_connect(GTK_OBJECT(display_opt_w), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC(display_opt_destroy_cb), NULL);
|
|
|
|
|
2000-05-08 04:23:46 +00:00
|
|
|
/* Accelerator group for the accelerators (or, as they're called in
|
|
|
|
Windows and, I think, in Motif, "mnemonics"; Alt+<key> is a mnemonic,
|
|
|
|
Ctrl+<key> is an accelerator). */
|
|
|
|
accel_group = gtk_accel_group_new();
|
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(display_opt_w), accel_group);
|
|
|
|
|
1999-06-19 01:14:51 +00:00
|
|
|
/* Container for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 3);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
gtk_container_add(GTK_CONTAINER(display_opt_w), main_vb);
|
|
|
|
gtk_widget_show(main_vb);
|
|
|
|
|
2000-05-08 04:23:46 +00:00
|
|
|
button = dlg_radio_button_new_with_label_with_mnemonic(NULL, "_Time of day",
|
|
|
|
accel_group);
|
1999-06-19 03:14:32 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),
|
1999-06-19 01:14:51 +00:00
|
|
|
(timestamp_type == ABSOLUTE));
|
|
|
|
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_TIME_ABS_KEY,
|
|
|
|
button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
|
2000-05-08 04:23:46 +00:00
|
|
|
|
1999-06-19 01:14:51 +00:00
|
|
|
gtk_widget_show(button);
|
|
|
|
|
2000-05-08 04:23:46 +00:00
|
|
|
button = dlg_radio_button_new_with_label_with_mnemonic(
|
1999-06-19 01:14:51 +00:00
|
|
|
gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
|
2000-05-08 04:23:46 +00:00
|
|
|
"Seconds since _beginning of capture", accel_group);
|
1999-06-19 03:14:32 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),
|
1999-06-19 01:14:51 +00:00
|
|
|
(timestamp_type == RELATIVE));
|
|
|
|
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_TIME_REL_KEY,
|
|
|
|
button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
2000-05-08 04:23:46 +00:00
|
|
|
button = dlg_radio_button_new_with_label_with_mnemonic(
|
1999-06-19 01:14:51 +00:00
|
|
|
gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
|
2000-05-08 04:23:46 +00:00
|
|
|
"Seconds since _previous frame", accel_group);
|
1999-06-19 03:14:32 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),
|
1999-06-19 01:14:51 +00:00
|
|
|
(timestamp_type == DELTA));
|
|
|
|
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_TIME_DELTA_KEY,
|
|
|
|
button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(button);
|
1999-09-19 15:54:54 +00:00
|
|
|
|
2000-05-08 04:23:46 +00:00
|
|
|
button = dlg_check_button_new_with_label_with_mnemonic(
|
|
|
|
"_Automatic scrolling in live capture", accel_group);
|
1999-09-19 15:54:54 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), auto_scroll_live);
|
|
|
|
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_AUTO_SCROLL_KEY,
|
|
|
|
button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(button);
|
1999-09-26 14:40:01 +00:00
|
|
|
|
2000-05-08 05:51:37 +00:00
|
|
|
button = dlg_check_button_new_with_label_with_mnemonic(
|
|
|
|
"Enable _name resolution", accel_group);
|
1999-09-26 14:40:01 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), g_resolving_actif);
|
|
|
|
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_NAME_RESOLUTION_KEY,
|
|
|
|
button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(button);
|
1999-06-19 01:14:51 +00:00
|
|
|
|
2000-05-08 04:23:46 +00:00
|
|
|
button = dlg_check_button_new_with_label_with_mnemonic(
|
|
|
|
"Decode IPv4 TOS field as _DiffServ Field", accel_group);
|
2000-01-24 04:44:58 +00:00
|
|
|
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), g_ip_dscp_actif);
|
|
|
|
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_IP_DSCP_KEY,
|
|
|
|
button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
1999-06-22 22:43:56 +00:00
|
|
|
/* Button row: OK, Apply, and Cancel buttons */
|
1999-06-19 01:14:51 +00:00
|
|
|
bbox = gtk_hbutton_box_new();
|
|
|
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
|
|
|
|
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), bbox);
|
|
|
|
gtk_widget_show(bbox);
|
|
|
|
|
|
|
|
ok_bt = gtk_button_new_with_label ("OK");
|
1999-06-21 19:04:35 +00:00
|
|
|
gtk_signal_connect(GTK_OBJECT(ok_bt), "clicked",
|
1999-06-19 01:14:51 +00:00
|
|
|
GTK_SIGNAL_FUNC(display_opt_ok_cb), GTK_OBJECT(display_opt_w));
|
|
|
|
GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), ok_bt, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_grab_default(ok_bt);
|
|
|
|
gtk_widget_show(ok_bt);
|
|
|
|
|
1999-06-22 22:43:56 +00:00
|
|
|
apply_bt = gtk_button_new_with_label ("Apply");
|
|
|
|
gtk_signal_connect(GTK_OBJECT(apply_bt), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC(display_opt_apply_cb), GTK_OBJECT(display_opt_w));
|
|
|
|
GTK_WIDGET_SET_FLAGS(apply_bt, GTK_CAN_DEFAULT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), apply_bt, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(apply_bt);
|
|
|
|
|
1999-06-19 01:14:51 +00:00
|
|
|
cancel_bt = gtk_button_new_with_label ("Cancel");
|
1999-06-21 19:04:35 +00:00
|
|
|
gtk_signal_connect(GTK_OBJECT(cancel_bt), "clicked",
|
1999-06-19 01:14:51 +00:00
|
|
|
GTK_SIGNAL_FUNC(display_opt_close_cb), GTK_OBJECT(display_opt_w));
|
|
|
|
GTK_WIDGET_SET_FLAGS(cancel_bt, GTK_CAN_DEFAULT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), cancel_bt, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(cancel_bt);
|
|
|
|
|
2000-05-08 01:23:16 +00:00
|
|
|
/* Catch the "key_press_event" signal in the window, so that we can catch
|
|
|
|
the ESC key being pressed and act as if the "Cancel" button had
|
|
|
|
been selected. */
|
|
|
|
dlg_set_cancel(display_opt_w, cancel_bt);
|
|
|
|
|
1999-06-19 01:14:51 +00:00
|
|
|
gtk_widget_show(display_opt_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-06-21 19:04:35 +00:00
|
|
|
display_opt_ok_cb(GtkWidget *ok_bt, gpointer parent_w) {
|
1999-06-19 01:47:43 +00:00
|
|
|
GtkWidget *button;
|
1999-06-19 01:14:51 +00:00
|
|
|
|
1999-06-21 19:04:35 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
1999-06-19 01:47:43 +00:00
|
|
|
E_DISPLAY_TIME_ABS_KEY);
|
|
|
|
if (GTK_TOGGLE_BUTTON (button)->active)
|
1999-06-19 01:14:51 +00:00
|
|
|
timestamp_type = ABSOLUTE;
|
1999-06-19 01:47:43 +00:00
|
|
|
|
1999-06-21 19:04:35 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
1999-06-19 01:47:43 +00:00
|
|
|
E_DISPLAY_TIME_REL_KEY);
|
|
|
|
if (GTK_TOGGLE_BUTTON (button)->active)
|
1999-06-19 01:14:51 +00:00
|
|
|
timestamp_type = RELATIVE;
|
1999-06-19 01:47:43 +00:00
|
|
|
|
1999-06-21 19:04:35 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
1999-06-19 01:47:43 +00:00
|
|
|
E_DISPLAY_TIME_DELTA_KEY);
|
|
|
|
if (GTK_TOGGLE_BUTTON (button)->active)
|
1999-06-19 01:14:51 +00:00
|
|
|
timestamp_type = DELTA;
|
|
|
|
|
1999-09-19 15:54:54 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_AUTO_SCROLL_KEY);
|
|
|
|
auto_scroll_live = (GTK_TOGGLE_BUTTON (button)->active);
|
|
|
|
|
1999-09-26 14:40:01 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_NAME_RESOLUTION_KEY);
|
|
|
|
g_resolving_actif = (GTK_TOGGLE_BUTTON (button)->active);
|
|
|
|
|
2000-01-24 04:44:58 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_IP_DSCP_KEY);
|
|
|
|
g_ip_dscp_actif = (GTK_TOGGLE_BUTTON (button)->active);
|
|
|
|
|
1999-06-21 19:04:35 +00:00
|
|
|
gtk_widget_destroy(GTK_WIDGET(parent_w));
|
1999-06-19 01:14:51 +00:00
|
|
|
|
1999-06-22 03:39:07 +00:00
|
|
|
change_time_formats(&cf);
|
1999-06-19 01:14:51 +00:00
|
|
|
}
|
|
|
|
|
1999-06-22 22:43:56 +00:00
|
|
|
static void
|
|
|
|
display_opt_apply_cb(GtkWidget *ok_bt, gpointer parent_w) {
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_TIME_ABS_KEY);
|
|
|
|
if (GTK_TOGGLE_BUTTON (button)->active)
|
|
|
|
timestamp_type = ABSOLUTE;
|
|
|
|
|
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_TIME_REL_KEY);
|
|
|
|
if (GTK_TOGGLE_BUTTON (button)->active)
|
|
|
|
timestamp_type = RELATIVE;
|
|
|
|
|
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_TIME_DELTA_KEY);
|
|
|
|
if (GTK_TOGGLE_BUTTON (button)->active)
|
|
|
|
timestamp_type = DELTA;
|
|
|
|
|
1999-09-19 15:54:54 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_AUTO_SCROLL_KEY);
|
|
|
|
auto_scroll_live = (GTK_TOGGLE_BUTTON (button)->active);
|
|
|
|
|
1999-09-26 14:40:01 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_NAME_RESOLUTION_KEY);
|
|
|
|
g_resolving_actif = (GTK_TOGGLE_BUTTON (button)->active);
|
|
|
|
|
2000-01-24 04:44:58 +00:00
|
|
|
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
|
|
|
|
E_DISPLAY_IP_DSCP_KEY);
|
|
|
|
g_ip_dscp_actif = (GTK_TOGGLE_BUTTON (button)->active);
|
|
|
|
|
1999-06-22 22:43:56 +00:00
|
|
|
change_time_formats(&cf);
|
|
|
|
}
|
|
|
|
|
1999-06-19 01:14:51 +00:00
|
|
|
static void
|
1999-06-21 19:04:35 +00:00
|
|
|
display_opt_close_cb(GtkWidget *close_bt, gpointer parent_w) {
|
1999-06-19 01:14:51 +00:00
|
|
|
|
1999-06-24 05:37:04 +00:00
|
|
|
if (timestamp_type != prev_timestamp_type) {
|
|
|
|
timestamp_type = prev_timestamp_type;
|
|
|
|
change_time_formats(&cf);
|
|
|
|
}
|
|
|
|
|
1999-06-21 19:04:35 +00:00
|
|
|
gtk_grab_remove(GTK_WIDGET(parent_w));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(parent_w));
|
2000-05-08 05:12:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
display_opt_destroy_cb(GtkWidget *win, gpointer user_data)
|
|
|
|
{
|
|
|
|
/* Note that we no longer have a "Display Options" dialog box. */
|
|
|
|
display_opt_w = NULL;
|
1999-06-19 01:14:51 +00:00
|
|
|
}
|