diff options
author | Gerald Combs <gerald@wireshark.org> | 1998-10-12 01:40:57 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 1998-10-12 01:40:57 +0000 |
commit | 0758da11466778cbd377fade6142bbe7c19ceecd (patch) | |
tree | f57ee7de708d072038153022c1ccbd9afa448651 | |
parent | 73e19611fdb5a6b70951c140c0831c72f04beb5c (diff) |
- Added match_strval function to packet.c
- Separated display and capture filters; rearranged some of the look and feel
- Lots of other miscellaneous fixes and updates
svn path=/trunk/; revision=38
-rw-r--r-- | Makefile.am | 15 | ||||
-rw-r--r-- | Makefile.in | 15 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | capture.c | 188 | ||||
-rw-r--r-- | config.h.in | 21 | ||||
-rwxr-xr-x | configure | 202 | ||||
-rw-r--r-- | configure.in | 18 | ||||
-rw-r--r-- | ethereal.c | 94 | ||||
-rw-r--r-- | ethereal.h | 3 | ||||
-rw-r--r-- | file.c | 18 | ||||
-rw-r--r-- | file.h | 5 | ||||
-rw-r--r-- | filter.c | 21 | ||||
-rw-r--r-- | menu.c | 17 | ||||
-rw-r--r-- | menu.h | 3 | ||||
-rw-r--r-- | packet-arp.c | 69 | ||||
-rw-r--r-- | packet.c | 20 | ||||
-rw-r--r-- | packet.h | 6 | ||||
-rw-r--r-- | prefs.c | 48 | ||||
-rw-r--r-- | prefs.h | 13 | ||||
-rw-r--r-- | print.c | 12 | ||||
-rw-r--r-- | util.c | 14 | ||||
-rw-r--r-- | util.h | 10 |
23 files changed, 556 insertions, 261 deletions
diff --git a/Makefile.am b/Makefile.am index 400cf7082d..9f4e6a3a12 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,18 +59,21 @@ ethereal_SOURCES = \ print.h \ ps.h \ resolv.h \ - snprintf.h \ util.h +EXTRA_ethereal_SOURCES = \ + snprintf.c \ + snprintf.h + +ethereal_DEPENDENCIES = @SNPRINTF_O@ +ethereal_LDADD = @SNPRINTF_O@ + ps.c: print.ps rdps ./rdps print.ps ps.c rdps: rdps.c $(CC) -o rdps rdps.c -EXTRA_ethereal_SOURCES = @SNPRINTF_C@ -ethereal_DEPENDENCIES = @SNPRINTF_O@ -LDADD = @SNPRINTF_O@ DISTCLEANFILES = \ rdps \ ps.c @@ -82,6 +85,4 @@ EXTRA_DIST = \ image/icon-excl.xpm \ manuf \ print.ps \ - rdps.c \ - snprintf.c - + rdps.c diff --git a/Makefile.in b/Makefile.in index 58e55fa497..385ef0446e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -131,12 +131,15 @@ ethereal_SOURCES = \ print.h \ ps.h \ resolv.h \ - snprintf.h \ util.h -EXTRA_ethereal_SOURCES = @SNPRINTF_C@ +EXTRA_ethereal_SOURCES = \ + snprintf.c \ + snprintf.h + ethereal_DEPENDENCIES = @SNPRINTF_O@ -LDADD = @SNPRINTF_O@ +ethereal_LDADD = @SNPRINTF_O@ + DISTCLEANFILES = \ rdps \ ps.c @@ -148,8 +151,7 @@ EXTRA_DIST = \ image/icon-excl.xpm \ manuf \ print.ps \ - rdps.c \ - snprintf.c + rdps.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h @@ -168,7 +170,6 @@ packet-ip.o packet-ipv6.o packet-ipx.o packet-ncp.o packet-null.o \ packet-osi.o packet-ospf.o packet-ppp.o packet-raw.o packet-rip.o \ packet-tcp.o packet-tr.o packet-trmac.o packet-udp.o packet-vines.o \ prefs.o print.o ps.o resolv.o util.o -ethereal_LDADD = $(LDADD) ethereal_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @@ -199,7 +200,7 @@ DEP_FILES = .deps/capture.P .deps/ethereal.P .deps/ethertype.P \ .deps/packet-ppp.P .deps/packet-raw.P .deps/packet-rip.P \ .deps/packet-tcp.P .deps/packet-tr.P .deps/packet-trmac.P \ .deps/packet-udp.P .deps/packet-vines.P .deps/packet.P .deps/prefs.P \ -.deps/print.P .deps/ps.P .deps/resolv.P .deps/util.P +.deps/print.P .deps/ps.P .deps/resolv.P .deps/snprintf.P .deps/util.P SOURCES = $(ethereal_SOURCES) $(EXTRA_ethereal_SOURCES) OBJECTS = $(ethereal_OBJECTS) @@ -1,9 +1,10 @@ -Overview of changes in Ethereal 0.3.18: +Overview of changes in Ethereal 0.4.0: * Lots of fixes from Guy Harris * Preferences dialog (Gerald) * OSPF alignment fixes (Gerald) * FDDI support (Laurent, Guy) +* Separate display and capture filters (Gerald) Overview of changes in Ethereal 0.3.17: @@ -1 +1 @@ -0.3.18 +0.4.0 @@ -1,7 +1,7 @@ /* capture.c * Routines for packet capture windows * - * $Id: capture.c,v 1.5 1998/10/10 03:32:02 gerald Exp $ + * $Id: capture.c,v 1.6 1998/10/12 01:40:43 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -54,21 +54,26 @@ #include "capture.h" #include "etypes.h" #include "util.h" +#include "prefs.h" extern capture_file cf; extern GtkWidget *info_bar; extern guint file_ctx; /* File selection data keys */ -const gchar *prep_fs_key = "prep_fs", - *prep_te_key = "prep_te"; +#define E_CAP_PREP_FS_KEY "cap_prep_fs" +#define E_CAP_PREP_TE_KEY "cap_prep_te" /* Capture callback data keys */ -const gchar *cap_iface_key = "cap_iface", - *cap_file_key = "cap_file", - *cap_count_key = "cap_count", - *cap_open_key = "cap_open", - *cap_snap_key = "cap_snap"; +#define E_CAP_IFACE_KEY "cap_iface" +#define E_CAP_FILT_KEY "cap_filter" +#define E_CAP_FILE_KEY "cap_file" +#define E_CAP_COUNT_KEY "cap_count" +#define E_CAP_OPEN_KEY "cap_open" +#define E_CAP_SNAP_KEY "cap_snap" + +/* Capture filter key */ +#define E_CAP_FILT_TE_KEY "cap_filt_te" GList * get_interface_list() { @@ -129,9 +134,10 @@ get_interface_list() { void capture_prep_cb(GtkWidget *w, gpointer d) { GtkWidget *cap_open_w, *if_cb, *if_lb, *file_te, *file_bt, - *count_lb, *count_cb, *main_vb, *top_hb, *middle_hb, - *bottom_hb, *bbox, *ok_bt, *cancel_bt, *capfile_ck, - *snap_lb, *snap_sb; + *count_lb, *count_cb, *main_vb, *if_hb, *count_hb, + *filter_hb, *filter_bt, *filter_te, *file_hb, *caplen_hb, + *bbox, *ok_bt, *cancel_bt, *capfile_ck, *snap_lb, + *snap_sb; GtkAdjustment *adj; GList *if_list, *count_list = NULL; gchar *count_item1 = "0 (Infinite)", count_item2[16]; @@ -145,76 +151,102 @@ capture_prep_cb(GtkWidget *w, gpointer d) { gtk_container_add(GTK_CONTAINER(cap_open_w), main_vb); gtk_widget_show(main_vb); - /* Top row: Interface and count selections */ - top_hb = gtk_hbox_new(FALSE, 1); - gtk_container_add(GTK_CONTAINER(main_vb), top_hb); - gtk_widget_show(top_hb); + /* Interface row */ + if_hb = gtk_hbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(main_vb), if_hb); + gtk_widget_show(if_hb); if_lb = gtk_label_new("Interface:"); - gtk_box_pack_start(GTK_BOX(top_hb), if_lb, FALSE, FALSE, 3); + gtk_box_pack_start(GTK_BOX(if_hb), if_lb, FALSE, FALSE, 0); gtk_widget_show(if_lb); if_list = get_interface_list(); + if_cb = gtk_combo_new(); gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), if_list); if (cf.iface) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cf.iface); else if (if_list) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), if_list->data); - gtk_box_pack_start(GTK_BOX(top_hb), if_cb, FALSE, FALSE, 3); + gtk_box_pack_start(GTK_BOX(if_hb), if_cb, FALSE, FALSE, 0); gtk_widget_show(if_cb); + while (if_list) { g_free(if_list->data); if_list = g_list_remove_link(if_list, if_list); } + /* Count row */ + count_hb = gtk_hbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(main_vb), count_hb); + gtk_widget_show(count_hb); + + count_lb = gtk_label_new("Count:"); + gtk_box_pack_start(GTK_BOX(count_hb), count_lb, FALSE, FALSE, 0); + gtk_widget_show(count_lb); + if (cf.count) { snprintf(count_item2, 15, "%d", cf.count); count_list = g_list_append(count_list, count_item2); } count_list = g_list_append(count_list, count_item1); + count_cb = gtk_combo_new(); gtk_combo_set_popdown_strings(GTK_COMBO(count_cb), count_list); - gtk_box_pack_end(GTK_BOX(top_hb), count_cb, FALSE, FALSE, 3); + gtk_box_pack_start(GTK_BOX(count_hb), count_cb, FALSE, FALSE, 0); gtk_widget_show(count_cb); + while (count_list) count_list = g_list_remove_link(count_list, count_list); - count_lb = gtk_label_new("Count:"); - gtk_box_pack_end(GTK_BOX(top_hb), count_lb, FALSE, FALSE, 3); - gtk_widget_show(count_lb); + /* Filter row */ + filter_hb = gtk_hbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(main_vb), filter_hb); + gtk_widget_show(filter_hb); + + filter_bt = gtk_button_new_with_label("Filter:"); + gtk_signal_connect(GTK_OBJECT(filter_bt), "clicked", + GTK_SIGNAL_FUNC(prefs_cb), (gpointer) E_PR_PG_FILTER); + gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, TRUE, 0); + gtk_widget_show(filter_bt); - /* Middle row: File: button and text entry */ - middle_hb = gtk_hbox_new(FALSE, 1); - gtk_container_add(GTK_CONTAINER(main_vb), middle_hb); - gtk_widget_show(middle_hb); + filter_te = gtk_entry_new(); + if (cf.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cf.cfilter); + gtk_object_set_data(GTK_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te); + gtk_box_pack_start(GTK_BOX(filter_hb), filter_te, TRUE, TRUE, 0); + gtk_widget_show(filter_te); + + /* File row: File: button and text entry */ + file_hb = gtk_hbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(main_vb), file_hb); + gtk_widget_show(file_hb); file_bt = gtk_button_new_with_label("File:"); - gtk_box_pack_start(GTK_BOX(middle_hb), file_bt, FALSE, FALSE, 3); + gtk_box_pack_start(GTK_BOX(file_hb), file_bt, FALSE, FALSE, 0); gtk_widget_show(file_bt); file_te = gtk_entry_new(); if (cf.save_file) gtk_entry_set_text(GTK_ENTRY(file_te), cf.save_file); - gtk_box_pack_start(GTK_BOX(middle_hb), file_te, TRUE, TRUE, 3); + gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 0); gtk_widget_show(file_te); gtk_signal_connect_object(GTK_OBJECT(file_bt), "clicked", GTK_SIGNAL_FUNC(capture_prep_file_cb), GTK_OBJECT(file_te)); - /* Bottom row: Capture file checkbox and snap spinbutton */ - bottom_hb = gtk_hbox_new(FALSE, 1); - gtk_container_add(GTK_CONTAINER(main_vb), bottom_hb); - gtk_widget_show(bottom_hb); - + /* Misc row: Capture file checkbox and snap spinbutton */ + caplen_hb = gtk_hbox_new(FALSE, 3); + gtk_container_add(GTK_CONTAINER(main_vb), caplen_hb); + gtk_widget_show(caplen_hb); + capfile_ck = gtk_check_button_new_with_label("Open file after capture"); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(capfile_ck), TRUE); - gtk_box_pack_start(GTK_BOX(bottom_hb), capfile_ck, FALSE, FALSE, 3); + gtk_box_pack_start(GTK_BOX(caplen_hb), capfile_ck, FALSE, FALSE, 3); gtk_widget_show(capfile_ck); - + snap_lb = gtk_label_new("Capture length"); gtk_misc_set_alignment(GTK_MISC(snap_lb), 0, 0.5); - gtk_box_pack_start(GTK_BOX(bottom_hb), snap_lb, FALSE, FALSE, 6); + gtk_box_pack_start(GTK_BOX(caplen_hb), snap_lb, FALSE, FALSE, 6); gtk_widget_show(snap_lb); adj = (GtkAdjustment *) gtk_adjustment_new((float) cf.snap, 1.0, 4096.0, @@ -222,35 +254,38 @@ capture_prep_cb(GtkWidget *w, gpointer d) { snap_sb = gtk_spin_button_new (adj, 0, 0); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE); gtk_widget_set_usize (snap_sb, 80, 0); - gtk_box_pack_start (GTK_BOX(bottom_hb), snap_sb, FALSE, FALSE, 3); + gtk_box_pack_start (GTK_BOX(caplen_hb), snap_sb, FALSE, FALSE, 3); gtk_widget_show(snap_sb); /* Button row: OK and cancel buttons */ 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"); gtk_signal_connect_object(GTK_OBJECT(ok_bt), "clicked", GTK_SIGNAL_FUNC(capture_prep_ok_cb), GTK_OBJECT(cap_open_w)); - gtk_container_add(GTK_CONTAINER(bbox), ok_bt); -/* GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT); - gtk_widget_grab_default(ok_bt); */ + 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); cancel_bt = gtk_button_new_with_label ("Cancel"); gtk_signal_connect_object(GTK_OBJECT(cancel_bt), "clicked", GTK_SIGNAL_FUNC(capture_prep_close_cb), GTK_OBJECT(cap_open_w)); - gtk_container_add(GTK_CONTAINER(bbox), cancel_bt); + GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT); + gtk_box_pack_start (GTK_BOX (bbox), cancel_bt, TRUE, TRUE, 0); gtk_widget_show(cancel_bt); /* Attach pointers to needed widges to the capture prefs window/object */ - gtk_object_set_data(GTK_OBJECT(cap_open_w), cap_iface_key, if_cb); - gtk_object_set_data(GTK_OBJECT(cap_open_w), cap_file_key, file_te); - gtk_object_set_data(GTK_OBJECT(cap_open_w), cap_count_key, count_cb); - gtk_object_set_data(GTK_OBJECT(cap_open_w), cap_open_key, capfile_ck); - gtk_object_set_data(GTK_OBJECT(cap_open_w), cap_snap_key, snap_sb); + gtk_object_set_data(GTK_OBJECT(cap_open_w), E_CAP_IFACE_KEY, if_cb); + gtk_object_set_data(GTK_OBJECT(cap_open_w), E_CAP_FILT_KEY, filter_te); + gtk_object_set_data(GTK_OBJECT(cap_open_w), E_CAP_FILE_KEY, file_te); + gtk_object_set_data(GTK_OBJECT(cap_open_w), E_CAP_COUNT_KEY, count_cb); + gtk_object_set_data(GTK_OBJECT(cap_open_w), E_CAP_OPEN_KEY, capfile_ck); + gtk_object_set_data(GTK_OBJECT(cap_open_w), E_CAP_SNAP_KEY, snap_sb); gtk_widget_show(cap_open_w); } @@ -261,8 +296,8 @@ capture_prep_file_cb(GtkWidget *w, gpointer te) { fs = gtk_file_selection_new ("Ethereal: Open Save File"); - gtk_object_set_data(GTK_OBJECT(w), prep_fs_key, fs); - gtk_object_set_data(GTK_OBJECT(w), prep_te_key, (GtkWidget *) te); + gtk_object_set_data(GTK_OBJECT(w), E_CAP_PREP_FS_KEY, fs); + gtk_object_set_data(GTK_OBJECT(w), E_CAP_PREP_TE_KEY, (GtkWidget *) te); gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(fs)->ok_button), "clicked", (GtkSignalFunc) cap_prep_fs_ok_cb, w); @@ -278,8 +313,8 @@ void cap_prep_fs_ok_cb(GtkWidget *w, gpointer data) { GtkWidget *fs, *te; - fs = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), prep_fs_key); - te = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), prep_te_key); + fs = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_PREP_FS_KEY); + te = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_PREP_TE_KEY); gtk_entry_set_text(GTK_ENTRY(te), gtk_file_selection_get_filename (GTK_FILE_SELECTION(fs))); @@ -290,25 +325,28 @@ void cap_prep_fs_cancel_cb(GtkWidget *w, gpointer data) { GtkWidget *fs; - fs = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), prep_fs_key); + fs = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_PREP_FS_KEY); gtk_widget_destroy(fs); } void capture_prep_ok_cb(GtkWidget *w, gpointer data) { - GtkWidget *if_cb, *file_te, *count_cb, *open_ck, *snap_sb; + GtkWidget *if_cb, *filter_te, *file_te, *count_cb, *open_ck, *snap_sb; gint open; - if_cb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), cap_iface_key); - file_te = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), cap_file_key); - count_cb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), cap_count_key); - open_ck = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), cap_open_key); - snap_sb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), cap_snap_key); + if_cb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_IFACE_KEY); + filter_te = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_FILT_KEY); + file_te = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_FILE_KEY); + count_cb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_COUNT_KEY); + open_ck = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_OPEN_KEY); + snap_sb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(data), E_CAP_SNAP_KEY); if (cf.iface) g_free(cf.iface); cf.iface = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry))); + if (cf.cfilter) g_free(cf.cfilter); + cf.cfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te))); if (cf.save_file) g_free(cf.save_file); cf.save_file = g_strdup(gtk_entry_get_text(GTK_ENTRY(file_te))); cf.count = @@ -369,12 +407,12 @@ capture(gint open) { } } - if (cf.filter) { + if (cf.cfilter) { if (pcap_lookupnet (cf.iface, &netnum, &netmask, err_str) < 0) { simple_dialog(ESD_TYPE_WARN, NULL, "Can't use filter: Couldn't obtain netmask info."); return; - } else if (pcap_compile(pch, &cf.fcode, cf.filter, 1, netmask) < 0) { + } else if (pcap_compile(pch, &cf.fcode, cf.cfilter, 1, netmask) < 0) { simple_dialog(ESD_TYPE_WARN, NULL, "Unable to parse filter string."); return; } else if (pcap_setfilter(pch, &cf.fcode) < 0) { @@ -512,28 +550,28 @@ capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr, } switch(etype){ - case ETHERTYPE_IP: - iptype = pd[offset + 9]; - switch (iptype) { - case IP_PROTO_TCP: - ld->tcp++; - break; - case IP_PROTO_UDP: - ld->udp++; - break; - case IP_PROTO_OSPF: - ld->ospf++; - break; - default: - ld->other++; - } + case ETHERTYPE_IP: + iptype = pd[offset + 9]; + switch (iptype) { + case IP_PROTO_TCP: + ld->tcp++; + break; + case IP_PROTO_UDP: + ld->udp++; + break; + case IP_PROTO_OSPF: + ld->ospf++; break; + default: + ld->other++; + } + break; case ETHERTYPE_IPX: case ETHERTYPE_IPv6: case ETHERTYPE_ATALK: case ETHERTYPE_VINES: case ETHERTYPE_ARP: default: - ld->other++; + ld->other++; } } diff --git a/config.h.in b/config.h.in index 71da4bec07..3320eae5eb 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated automatically from configure.in by autoheader. */ +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + /* Define if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN @@ -14,14 +17,32 @@ #undef NEED_SNPRINTF_H +/* Define if you have the <fcntl.h> header file. */ +#undef HAVE_FCNTL_H + /* Define if you have the <netinet/in.h> header file. */ #undef HAVE_NETINET_IN_H +/* Define if you have the <stdarg.h> header file. */ +#undef HAVE_STDARG_H + +/* Define if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define if you have the <sys/ioctl.h> header file. */ +#undef HAVE_SYS_IOCTL_H + /* Define if you have the <sys/sockio.h> header file. */ #undef HAVE_SYS_SOCKIO_H +/* Define if you have the <sys/time.h> header file. */ +#undef HAVE_SYS_TIME_H + /* Define if you have the <sys/types.h> header file. */ #undef HAVE_SYS_TYPES_H +/* Define if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + /* Define if you have the pcap library (-lpcap). */ #undef HAVE_LIBPCAP @@ -694,7 +694,7 @@ fi PACKAGE=ethereal -VERSION=0.3.18 +VERSION=0.4.0 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } @@ -1425,24 +1425,166 @@ else fi -# AC_HEADER_STDC -# AC_CHECK_HEADERS(fcntl.h strings.h sys/ioctl.h sys/time.h unistd.h) +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1430: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1435 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1443: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 1460 "configure" +#include "confdefs.h" +#include <string.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 1478 "configure" +#include "confdefs.h" +#include <stdlib.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext <<EOF +#line 1499 "configure" +#include "confdefs.h" +#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +for ac_hdr in fcntl.h strings.h sys/ioctl.h sys/time.h unistd.h stdarg.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1537: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1542 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1547: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + for ac_hdr in sys/sockio.h sys/types.h netinet/in.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1436: checking for $ac_hdr" >&5 +echo "configure:1578: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1441 "configure" +#line 1583 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1446: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1588: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1474,12 +1616,12 @@ done # We need libpcap's AC_LBL_SOCKADDR_SA_LEN test for get_interface_list(). echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6 -echo "configure:1478: checking if sockaddr struct has sa_len member" >&5 +echo "configure:1620: checking if sockaddr struct has sa_len member" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1483 "configure" +#line 1625 "configure" #include "confdefs.h" # include <sys/types.h> @@ -1488,7 +1630,7 @@ int main() { u_int i = sizeof(((struct sockaddr *)0)->sa_len) ; return 0; } EOF -if { (eval echo configure:1492: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1634: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_sockaddr_has_sa_len=yes else @@ -1510,14 +1652,14 @@ EOF # We must know our byte order echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:1514: checking whether byte ordering is bigendian" >&5 +echo "configure:1656: checking whether byte ordering is bigendian" >&5 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext <<EOF -#line 1521 "configure" +#line 1663 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/param.h> @@ -1528,11 +1670,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1532: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1674: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext <<EOF -#line 1536 "configure" +#line 1678 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/param.h> @@ -1543,7 +1685,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1547: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1689: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -1563,7 +1705,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 1567 "configure" +#line 1709 "configure" #include "confdefs.h" main () { /* Are we little or big endian? From Harbison&Steele. */ @@ -1576,7 +1718,7 @@ main () { exit (u.c[sizeof (long) - 1] == 1); } EOF -if { (eval echo configure:1580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -1602,13 +1744,13 @@ fi if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:1606: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:1748: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext <<EOF -#line 1612 "configure" +#line 1754 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -1626,7 +1768,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 1630 "configure" +#line 1772 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -1648,12 +1790,12 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 fi echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:1652: checking for socket" >&5 +echo "configure:1794: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1657 "configure" +#line 1799 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char socket(); below. */ @@ -1676,7 +1818,7 @@ socket(); ; return 0; } EOF -if { (eval echo configure:1680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1822: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_socket=yes" else @@ -1699,13 +1841,15 @@ fi # If there's a system out there that has snprintf and _doesn't_ have vsnprintf, # then this won't work. +SNPRINTF_C="" +SNPRINTF_O="" echo $ac_n "checking for snprintf""... $ac_c" 1>&6 -echo "configure:1704: checking for snprintf" >&5 +echo "configure:1848: checking for snprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_snprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1709 "configure" +#line 1853 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char snprintf(); below. */ @@ -1728,7 +1872,7 @@ snprintf(); ; return 0; } EOF -if { (eval echo configure:1732: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_snprintf=yes" else @@ -1742,15 +1886,19 @@ fi if eval "test \"`echo '$ac_cv_func_'snprintf`\" = yes"; then echo "$ac_t""yes" 1>&6 - SNPRINTF_C="" SNPRINTF_O="" + SNPRINTF_O="" else echo "$ac_t""no" 1>&6 -SNPRINTF_C="snprintf.c" SNPRINTF_O="snprintf.o" cat >> confdefs.h <<\EOF +SNPRINTF_O="snprintf.o" cat >> confdefs.h <<\EOF #define NEED_SNPRINTF_H 1 EOF fi +if test "$ac_cv_func_snprintf" = no ; then + SNPRINTF_C="snprintf.c" + SNPRINTF_O="snprintf.o" +fi diff --git a/configure.in b/configure.in index 4872cc7ddc..2dcdbd9753 100644 --- a/configure.in +++ b/configure.in @@ -1,8 +1,8 @@ -# $Id: configure.in,v 1.6 1998/10/10 03:32:05 gerald Exp $ +# $Id: configure.in,v 1.7 1998/10/12 01:40:46 gerald Exp $ dnl Process this file with autoconf to produce a configure script. AC_INIT(etypes.h) -AM_INIT_AUTOMAKE(ethereal, 0.3.18) +AM_INIT_AUTOMAKE(ethereal, 0.4.0) dnl Check for CPU / vendor / OS AC_CANONICAL_HOST @@ -44,8 +44,8 @@ AC_CHECK_HEADER(net/bpf.h,, AC_MSG_ERROR(Header file net/bpf.h not found.)) AC_CHECK_LIB(pcap, pcap_open_offline,, AC_MSG_ERROR(Library libpcap not found.)) dnl Checks for header files. -# AC_HEADER_STDC -# AC_CHECK_HEADERS(fcntl.h strings.h sys/ioctl.h sys/time.h unistd.h) +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h strings.h sys/ioctl.h sys/time.h unistd.h stdarg.h) AC_CHECK_HEADERS(sys/sockio.h sys/types.h netinet/in.h) @@ -65,8 +65,14 @@ AC_CHECK_FUNC(socket,, AC_MSG_ERROR(Function 'socket' not found.)) # If there's a system out there that has snprintf and _doesn't_ have vsnprintf, # then this won't work. -AC_CHECK_FUNC(snprintf, SNPRINTF_C="" SNPRINTF_O="", - SNPRINTF_C="snprintf.c" SNPRINTF_O="snprintf.o" AC_DEFINE(NEED_SNPRINTF_H)) +SNPRINTF_C="" +SNPRINTF_O="" +AC_CHECK_FUNC(snprintf, SNPRINTF_O="", + SNPRINTF_O="snprintf.o" [AC_DEFINE(NEED_SNPRINTF_H)]) +if test "$ac_cv_func_snprintf" = no ; then + SNPRINTF_C="snprintf.c" + SNPRINTF_O="snprintf.o" +fi AC_SUBST(SNPRINTF_C) AC_SUBST(SNPRINTF_O) diff --git a/ethereal.c b/ethereal.c index 1cb66a3c43..d1707e0f55 100644 --- a/ethereal.c +++ b/ethereal.c @@ -1,6 +1,6 @@ /* ethereal.c * - * $Id: ethereal.c,v 1.4 1998/09/27 22:12:21 gerald Exp $ + * $Id: ethereal.c,v 1.5 1998/10/12 01:40:47 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -23,12 +23,9 @@ * * * To do: - * - Add time stamps to packet list? * - Live browser/capture display * - Graphs - * - Prefs dialog * - Get AIX to work - * - Fix PPP support. * - Check for end of packet in dissect_* routines. * - Playback window * - Multiple window support @@ -67,33 +64,37 @@ #include "resolv.h" #include "follow.h" #include "util.h" +#include "prefs.h" FILE *data_out_file = NULL; packet_info pi; capture_file cf; GtkWidget *file_sel, *packet_list, *tree_view, *byte_view, *prog_bar, - *info_bar; + *info_bar; GdkFont *m_r_font, *m_b_font; guint main_ctx, file_ctx; frame_data *fd; gint start_capture = 0; -const gchar *list_item_data_key = "list_item_data"; - extern pr_opts printer_opts; ts_type timestamp_type = RELATIVE; +#define E_DFILTER_TE_KEY "display_filter_te" + /* Things to do when the OK button is pressed */ void file_sel_ok_cb(GtkWidget *w, GtkFileSelection *fs) { - gchar *cf_name; - int err; - + gchar *cf_name; + int err; + GtkWidget *filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY); + cf_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION (fs))); gtk_widget_hide(GTK_WIDGET (fs)); gtk_widget_destroy(GTK_WIDGET (fs)); + if (cf.dfilter) g_free(cf.dfilter); + cf.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te))); if ((err = load_cap_file(cf_name, &cf)) == 0) chdir(cf_name); g_free(cf_name); @@ -109,19 +110,22 @@ file_progress_cb(gpointer p) { /* Follow a TCP stream */ void -follow_stream_cb( GtkWidget *widget, gpointer data ) { +follow_stream_cb( GtkWidget *w, gpointer data ) { char filename1[128]; GtkWidget *streamwindow, *box, *text, *vscrollbar, *table; + GtkWidget *filter_te = gtk_object_get_data(GTK_OBJECT(w), + E_DFILTER_TE_KEY); if( pi.ipproto == 6 ) { /* we got tcp so we can follow */ /* check to see if we are using a filter */ - if( cf.filter != NULL ) { + if( cf.dfilter != NULL ) { /* get rid of this one */ - g_free( cf.filter ); - cf.filter = NULL; + g_free( cf.dfilter ); + cf.dfilter = NULL; } - /* create a new one */ - cf.filter = build_follow_filter( &pi ); + /* create a new one and set the display filter entry accordingly */ + cf.dfilter = build_follow_filter( &pi ); + gtk_entry_set_text(GTK_ENTRY(filter_te), cf.dfilter); /* reload so it goes in effect. Also we set data_out_file which tells the tcp code to output the data */ close_cap_file( &cf, info_bar, file_ctx); @@ -186,9 +190,9 @@ follow_stream_cb( GtkWidget *widget, gpointer data ) { gtk_text_thaw( GTK_TEXT(text) ); data_out_file = NULL; gtk_widget_show( streamwindow ); - if( cf.filter != NULL ) { - g_free( cf.filter ); - cf.filter = NULL; + if( cf.dfilter != NULL ) { + g_free( cf.dfilter ); + cf.dfilter = NULL; } } else { simple_dialog(ESD_TYPE_WARN, NULL, @@ -199,12 +203,15 @@ follow_stream_cb( GtkWidget *widget, gpointer data ) { /* Open a file */ void -file_open_cmd_cb(GtkWidget *widget, gpointer data) { +file_open_cmd_cb(GtkWidget *w, gpointer data) { file_sel = gtk_file_selection_new ("Ethereal: Open Capture File"); - /* Connect the ok_button to file_ok_sel_cb function */ + /* Connect the ok_button to file_ok_sel_cb function and pass along the + pointer to the filter entry */ gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_sel)->ok_button), "clicked", (GtkSignalFunc) file_sel_ok_cb, file_sel ); + gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(file_sel)->ok_button), + E_DFILTER_TE_KEY, gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY)); /* Connect the cancel_button to destroy the widget */ gtk_signal_connect_object(GTK_OBJECT (GTK_FILE_SELECTION @@ -221,6 +228,17 @@ void file_close_cmd_cb(GtkWidget *widget, gpointer data) { close_cap_file(&cf, info_bar, file_ctx); set_menu_sensitivity("<Main>/File/Close", FALSE); + set_menu_sensitivity("<Main>/File/Reload", FALSE); +} + +/* Reload a file using the current display filter */ +void +file_reload_cmd_cb(GtkWidget *w, gpointer data) { + GtkWidget *filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY); + + if (cf.dfilter) g_free(cf.dfilter); + cf.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te))); + load_cap_file(cf.filename, &cf); } /* Print a packet */ @@ -264,12 +282,12 @@ packet_list_unselect_cb(GtkWidget *w, gint row, gint col, gpointer evt) { void tree_view_cb(GtkWidget *w) { gint start = -1, len = -1; - guint32 tinfo = 0; if (GTK_TREE(w)->selection) { - tinfo = (guint32) gtk_object_get_user_data(GTK_TREE(w)->selection->data); - start = (tinfo >> 16) & 0xffff; - len = tinfo & 0xffff; + start = (gint) gtk_object_get_data(GTK_OBJECT(GTK_TREE(w)->selection->data), + E_TREEINFO_START_KEY); + len = (gint) gtk_object_get_data(GTK_OBJECT(GTK_TREE(w)->selection->data), + E_TREEINFO_LEN_KEY); } gtk_text_freeze(GTK_TEXT(byte_view)); @@ -330,7 +348,7 @@ main(int argc, char *argv[]) extern char *optarg; GtkWidget *window, *main_vbox, *menubar, *u_pane, *l_pane, *bv_table, *bv_hscroll, *bv_vscroll, *stat_hbox, - *tv_scrollw; + *tv_scrollw, *filter_bt, *filter_te; GtkStyle *pl_style; GtkAcceleratorTable *accel; gint col_width, pl_size = 280, tv_size = 95, bv_size = 75; @@ -344,7 +362,8 @@ main(int argc, char *argv[]) cf.plist = NULL; cf.pfh = NULL; cf.fh = NULL; - cf.filter = NULL; + cf.dfilter = NULL; + cf.cfilter = NULL; cf.iface = NULL; cf.save_file = NULL; cf.snap = 68; @@ -470,7 +489,9 @@ main(int argc, char *argv[]) /* Panes for the packet list, tree, and byte view */ u_pane = gtk_vpaned_new(); + gtk_paned_gutter_size(GTK_PANED(u_pane), (GTK_PANED(u_pane))->handle_size); l_pane = gtk_vpaned_new(); + gtk_paned_gutter_size(GTK_PANED(l_pane), (GTK_PANED(l_pane))->handle_size); gtk_container_add(GTK_CONTAINER(main_vbox), u_pane); gtk_widget_show(u_pane); gtk_paned_add2 (GTK_PANED(u_pane), l_pane); @@ -545,16 +566,31 @@ main(int argc, char *argv[]) GTK_FILL, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); gtk_widget_show(bv_vscroll); - /* Progress/info box */ + /* Progress/filter/info box */ stat_hbox = gtk_hbox_new(FALSE, 1); gtk_container_border_width(GTK_CONTAINER(stat_hbox), 0); gtk_box_pack_start(GTK_BOX(main_vbox), stat_hbox, FALSE, TRUE, 0); gtk_widget_show(stat_hbox); prog_bar = gtk_progress_bar_new(); - gtk_box_pack_start(GTK_BOX(stat_hbox), prog_bar, FALSE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(stat_hbox), prog_bar, FALSE, TRUE, 3); gtk_widget_show(prog_bar); + filter_bt = gtk_button_new_with_label("Filter:"); + gtk_signal_connect(GTK_OBJECT(filter_bt), "clicked", + GTK_SIGNAL_FUNC(prefs_cb), (gpointer) E_PR_PG_FILTER); + gtk_box_pack_start(GTK_BOX(stat_hbox), filter_bt, FALSE, TRUE, 0); + gtk_widget_show(filter_bt); + + filter_te = gtk_entry_new(); + gtk_object_set_data(GTK_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te); + gtk_box_pack_start(GTK_BOX(stat_hbox), filter_te, TRUE, TRUE, 3); + gtk_widget_show(filter_te); + set_menu_object_data("<Main>/File/Open", E_DFILTER_TE_KEY, filter_te); + set_menu_object_data("<Main>/File/Reload", E_DFILTER_TE_KEY, filter_te); + set_menu_object_data("<Main>/Tools/Follow TCP Stream", E_DFILTER_TE_KEY, + filter_te); + info_bar = gtk_statusbar_new(); main_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "main"); file_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "file"); diff --git a/ethereal.h b/ethereal.h index 504926eb2e..7dad337227 100644 --- a/ethereal.h +++ b/ethereal.h @@ -1,7 +1,7 @@ /* ethereal.h * Global defines, etc. * - * $Id: ethereal.h,v 1.5 1998/10/10 03:32:05 gerald Exp $ + * $Id: ethereal.h,v 1.6 1998/10/12 01:40:48 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -101,6 +101,7 @@ void follow_stream_cb( GtkWidget *, gpointer); void file_open_cmd_cb(GtkWidget *, gpointer); void file_close_cmd_cb(GtkWidget *, gpointer); void file_quit_cmd_cb(GtkWidget *, gpointer); +void file_reload_cmd_cb(GtkWidget *, gpointer); void file_print_cmd_cb(GtkWidget *, gpointer); void main_realize_cb(GtkWidget *, gpointer); @@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.6 1998/10/10 03:32:06 gerald Exp $ + * $Id: file.c,v 1.7 1998/10/12 01:40:48 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -120,9 +120,10 @@ open_cap_file(char *fname, capture_file *cf) { return 1; } - if (cf->filter) { - if (pcap_compile(cf->pfh, &cf->fcode, cf->filter, 1, 0) < 0) { - simple_dialog(ESD_TYPE_WARN, NULL, "Unable to parse filter string."); + if (cf->dfilter) { + if (pcap_compile(cf->pfh, &cf->fcode, cf->dfilter, 1, 0) < 0) { + simple_dialog(ESD_TYPE_WARN, NULL, "Unable to parse filter string" + "\"%s\".", cf->dfilter); } else if (pcap_setfilter(cf->pfh, &cf->fcode) < 0) { simple_dialog(ESD_TYPE_WARN, NULL, "Can't install filter."); } @@ -197,7 +198,7 @@ close_cap_file(capture_file *cf, GtkWidget *w, guint context) { int load_cap_file(char *fname, capture_file *cf) { gchar *name_ptr, *load_msg, *load_fmt = " Loading: %s..."; - gchar *done_fmt = " File: %s Packets: %d Drops: %d Elapsed: %d.%06ds"; + gchar *done_fmt = " File: %s Drops: %d"; gchar *err_fmt = " Error: Could not load '%s'"; gint timeout; size_t msg_len; @@ -232,15 +233,15 @@ load_cap_file(char *fname, capture_file *cf) { gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx); if (err == 0) { - msg_len = strlen(name_ptr) + strlen(load_fmt) + 64; + msg_len = strlen(name_ptr) + strlen(done_fmt) + 64; load_msg = g_realloc(load_msg, msg_len); - snprintf(load_msg, msg_len, done_fmt, name_ptr, cf->count, cf->drops, - cf->esec, cf->eusec); + snprintf(load_msg, msg_len, done_fmt, name_ptr, cf->count, cf->drops); gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, load_msg); g_free(load_msg); name_ptr[-1] = '\0'; set_menu_sensitivity("<Main>/File/Close", TRUE); + set_menu_sensitivity("<Main>/File/Reload", TRUE); } else { msg_len = strlen(name_ptr) + strlen(err_fmt) + 2; load_msg = g_realloc(load_msg, msg_len); @@ -248,6 +249,7 @@ load_cap_file(char *fname, capture_file *cf) { gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, load_msg); g_free(load_msg); set_menu_sensitivity("<Main>/File/Close", FALSE); + set_menu_sensitivity("<Main>/File/Reload", FALSE); } return err; @@ -1,7 +1,7 @@ /* file.h * Definitions for file structures and routines * - * $Id: file.h,v 1.3 1998/09/17 03:12:25 gerald Exp $ + * $Id: file.h,v 1.4 1998/10/12 01:40:49 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -68,7 +68,8 @@ typedef struct _capture_file { gchar *iface; /* Interface */ gchar *save_file; /* File to write capture data */ pcap_t *pfh; /* Pcap session */ - gchar *filter; /* Pcap filter string */ + gchar *dfilter; /* Display filter string */ + gchar *cfilter; /* Capture filter string */ bpf_prog fcode; /* Compiled filter program */ guint8 pd[4096]; /* Packet data */ GList *plist; /* Packet list */ @@ -1,7 +1,7 @@ /* filter.c * Routines for managing filter sets * - * $Id: filter.c,v 1.4 1998/10/10 03:32:07 gerald Exp $ + * $Id: filter.c,v 1.5 1998/10/12 01:40:50 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -39,8 +39,7 @@ #include "packet.h" #include "file.h" #include "menu.h" - -extern capture_file cf; +#include "prefs.h" const gchar *fn_key = "filter_name"; const gchar *fl_key = "filter_label"; @@ -182,9 +181,11 @@ filter_prefs_show() { gtk_widget_show(nl_item); gtk_object_set_data(GTK_OBJECT(nl_item), fl_key, nl_lb); gtk_object_set_data(GTK_OBJECT(nl_item), fn_key, flp); - if (cf.filter && filt->strval) - if (strcmp(cf.filter, filt->strval) == 0) +/* + if (cf.dfilter && filt->strval) + if (strcmp(cf.dfilter, filt->strval) == 0) l_select = nl_item; + */ flp = flp->next; } @@ -371,19 +372,15 @@ filter_prefs_ok(GtkWidget *w) { GList *flp, *sl; GtkObject *l_item; filter_def *filt; + GtkWidget *mw_filt = gtk_object_get_data(GTK_OBJECT(w), E_FILT_TE_PTR_KEY); - if (cf.filter) { - g_free(cf.filter); - cf.filter = NULL; - } - sl = GTK_LIST(filter_l)->selection; - if (sl) { /* Something was selected */ + if (sl && mw_filt) { /* Place something in the filter box. */ l_item = GTK_OBJECT(sl->data); flp = (GList *) gtk_object_get_data(l_item, fn_key); if (flp) { filt = (filter_def *) flp->data; - cf.filter = g_strdup(filt->strval); + gtk_entry_set_text(GTK_ENTRY(mw_filt), filt->strval); } } @@ -1,7 +1,7 @@ /* menu.c * Menu routines * - * $Id: menu.c,v 1.6 1998/10/10 03:32:09 gerald Exp $ + * $Id: menu.c,v 1.7 1998/10/12 01:40:51 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -61,6 +61,7 @@ static GtkMenuEntry menu_items[] = {"<Main>/File/Close", "<control>W", file_close_cmd_cb, NULL}, {"<Main>/File/Save", "<control>S", NULL, NULL}, {"<Main>/File/Save as", NULL, NULL, NULL}, + {"<Main>/File/Reload", "<control>R", file_reload_cmd_cb, NULL}, {"<Main>/File/<separator>", NULL, NULL, NULL}, {"<Main>/File/Print Packet", "<control>P", file_print_cmd_cb, NULL}, {"<Main>/File/<separator>", NULL, NULL, NULL}, @@ -71,7 +72,7 @@ static GtkMenuEntry menu_items[] = {"<Main>/Edit/<separator>", NULL, NULL, NULL}, {"<Main>/Edit/Find", "<control>F", NULL, NULL}, {"<Main>/Edit/<separator>", NULL, NULL, NULL}, - {"<Main>/Edit/Preferences", NULL, prefs_cb, NULL}, + {"<Main>/Edit/Preferences", NULL, prefs_cb, (gpointer) E_PR_PG_NONE}, {"<Main>/Tools/Capture", "<control>K", capture_prep_cb, NULL}, {"<Main>/Tools/Follow TCP Stream", NULL, follow_stream_cb, NULL}, {"<Main>/Tools/Graph", NULL, NULL, NULL}, @@ -113,6 +114,7 @@ menus_init(void) { set_menu_sensitivity("<Main>/File/Close", FALSE); set_menu_sensitivity("<Main>/File/Save", FALSE); set_menu_sensitivity("<Main>/File/Save as", FALSE); + set_menu_sensitivity("<Main>/File/Reload", FALSE); set_menu_sensitivity("<Main>/Edit/Cut", FALSE); set_menu_sensitivity("<Main>/Edit/Copy", FALSE); set_menu_sensitivity("<Main>/Edit/Paste", FALSE); @@ -129,9 +131,16 @@ void set_menu_sensitivity (gchar *path, gint val) { GtkMenuPath *mp; - if ((mp = gtk_menu_factory_find(factory, path)) != NULL) { + if ((mp = gtk_menu_factory_find(factory, path)) != NULL) gtk_widget_set_sensitive(mp->widget, val); - } +} + +void +set_menu_object_data (gchar *path, gchar *key, gpointer data) { + GtkMenuPath *mp; + + if ((mp = gtk_menu_factory_find(factory, path)) != NULL) + gtk_object_set_data(GTK_OBJECT(mp->widget), key, data); } void @@ -1,7 +1,7 @@ /* menu.h * Menu definitions * - * $Id: menu.h,v 1.2 1998/09/16 03:22:00 gerald Exp $ + * $Id: menu.h,v 1.3 1998/10/12 01:40:51 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -33,6 +33,7 @@ extern "C" { void menus_init (void); void get_main_menu (GtkWidget **, GtkAcceleratorTable **); void set_menu_sensitivity (gchar *, gint); +void set_menu_object_data (gchar *path, gchar *key, gpointer data); void menus_create (GtkMenuEntry *, int); diff --git a/packet-arp.c b/packet-arp.c index f8144b5e3d..1feefb59dd 100644 --- a/packet-arp.c +++ b/packet-arp.c @@ -1,7 +1,7 @@ /* packet-arp.c * Routines for ARP packet disassembly * - * $Id: packet-arp.c,v 1.4 1998/10/10 03:32:10 gerald Exp $ + * $Id: packet-arp.c,v 1.5 1998/10/12 01:40:52 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -46,85 +46,88 @@ void dissect_arp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) { - e_ether_arp *ea; - guint16 ar_hrd, ar_pro, ar_op; + e_ether_arp ea; GtkWidget *arp_tree, *ti; gchar *op_str; - value_string op_vals[] = { ARPOP_REQUEST, "ARP request", - ARPOP_REPLY, "ARP reply", - ARPOP_RREQUEST, "RARP request", - ARPOP_RREPLY, "RARP reply" }; + value_string op_vals[] = { {ARPOP_REQUEST, "ARP request" }, + {ARPOP_REPLY, "ARP reply" }, + {ARPOP_RREQUEST, "RARP request"}, + {ARPOP_RREPLY, "RARP reply" } }; /* To do: Check for {cap len,pkt len} < struct len */ - ea = (e_ether_arp *) &pd[offset]; - ar_hrd = ntohs(ea->ar_hrd); - ar_pro = ntohs(ea->ar_pro); - /* To do: Check for bounds on ar_op */ - ar_op = ntohs(ea->ar_op); + ea.ar_hrd = pntohs(&pd[offset]); + ea.ar_pro = pntohs(&pd[offset + 2]); + ea.ar_hln = (guint8) pd[offset + 4]; + ea.ar_pln = (guint8) pd[offset + 5]; + ea.ar_op = pntohs(&pd[offset + 6]); + memcpy(&ea.arp_sha, &pd[offset + 8], 6); + memcpy(&ea.arp_spa, &pd[offset + 14], 4); + memcpy(&ea.arp_tha, &pd[offset + 18], 6); + memcpy(&ea.arp_tpa, &pd[offset + 24], 4); if (fd->win_info[COL_NUM]) { strcpy(fd->win_info[COL_PROTOCOL], "ARP"); } if (tree) { - if (op_str = match_strval(ar_op, op_vals, 4)) + if ((op_str = match_strval(ea.ar_op, op_vals, 4))) ti = add_item_to_tree(GTK_WIDGET(tree), offset, 28, op_str); else ti = add_item_to_tree(GTK_WIDGET(tree), offset, 28, - "Unkown ARP (opcode 0x%04x)", ar_op); + "Unkown ARP (opcode 0x%04x)", ea.ar_op); arp_tree = gtk_tree_new(); add_subtree(ti, arp_tree, ETT_ARP); add_item_to_tree(arp_tree, offset, 2, - "Hardware type: 0x%04x", ar_hrd); + "Hardware type: 0x%04x", ea.ar_hrd); add_item_to_tree(arp_tree, offset + 2, 2, - "Protocol type: 0x%04x", ar_pro); + "Protocol type: 0x%04x", ea.ar_pro); add_item_to_tree(arp_tree, offset + 4, 1, - "Hardware size: 0x%02x", ea->ar_hln); + "Hardware size: 0x%02x", ea.ar_hln); add_item_to_tree(arp_tree, offset + 5, 1, - "Protocol size: 0x%02x", ea->ar_pln); + "Protocol size: 0x%02x", ea.ar_pln); add_item_to_tree(arp_tree, offset + 6, 2, - "Opcode: 0x%04x (%s)", ar_op, op_str ? op_str : "Unknown"); + "Opcode: 0x%04x (%s)", ea.ar_op, op_str ? op_str : "Unknown"); add_item_to_tree(arp_tree, offset + 8, 6, - "Sender ether: %s", ether_to_str((guint8 *) ea->arp_sha)); + "Sender ether: %s", ether_to_str((guint8 *) ea.arp_sha)); add_item_to_tree(arp_tree, offset + 14, 4, - "Sender IP: %s", ip_to_str((guint8 *) ea->arp_spa)); + "Sender IP: %s", ip_to_str((guint8 *) ea.arp_spa)); add_item_to_tree(arp_tree, offset + 18, 6, - "Target ether: %s", ether_to_str((guint8 *) ea->arp_tha)); + "Target ether: %s", ether_to_str((guint8 *) ea.arp_tha)); add_item_to_tree(arp_tree, offset + 24, 4, - "Target IP: %s", ip_to_str((guint8 *) ea->arp_tpa)); + "Target IP: %s", ip_to_str((guint8 *) ea.arp_tpa)); } - if (ar_pro != ETHERTYPE_IP && fd->win_info[COL_NUM]) { + if (ea.ar_pro != ETHERTYPE_IP && fd->win_info[COL_NUM]) { sprintf(fd->win_info[COL_INFO], "h/w %d (%d) prot %d (%d) op 0x%04x", - ar_hrd, ea->ar_hln, ar_pro, ea->ar_pln, ar_op); + ea.ar_hrd, ea.ar_hln, ea.ar_pro, ea.ar_pln, ea.ar_op); return; } - switch (ar_op) { + switch (ea.ar_op) { case ARPOP_REQUEST: if (fd->win_info[COL_NUM]) { sprintf(fd->win_info[COL_INFO], "Who has %s? Tell %s", - ip_to_str((guint8 *) ea->arp_tpa), ip_to_str((guint8 *) ea->arp_spa)); + ip_to_str((guint8 *) ea.arp_tpa), ip_to_str((guint8 *) ea.arp_spa)); } break; case ARPOP_REPLY: if (fd->win_info[COL_NUM]) { sprintf(fd->win_info[COL_INFO], "%s is at %s", - ip_to_str((guint8 *) ea->arp_spa), - ether_to_str((guint8 *) ea->arp_sha)); + ip_to_str((guint8 *) ea.arp_spa), + ether_to_str((guint8 *) ea.arp_sha)); } break; case ARPOP_RREQUEST: if (fd->win_info[COL_NUM]) { strcpy(fd->win_info[COL_PROTOCOL], "RARP"); sprintf(fd->win_info[COL_INFO], "Who is %s? Tell %s", - ether_to_str((guint8 *) ea->arp_tha), - ether_to_str((guint8 *) ea->arp_sha)); + ether_to_str((guint8 *) ea.arp_tha), + ether_to_str((guint8 *) ea.arp_sha)); } break; case ARPOP_RREPLY: if (fd->win_info[COL_NUM]) { strcpy(fd->win_info[COL_PROTOCOL], "RARP"); sprintf(fd->win_info[COL_INFO], "%s is at %s", - ether_to_str((guint8 *) ea->arp_sha), - ip_to_str((guint8 *) ea->arp_spa)); + ether_to_str((guint8 *) ea.arp_sha), + ip_to_str((guint8 *) ea.arp_spa)); } break; } @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.5 1998/10/10 03:32:16 gerald Exp $ + * $Id: packet.c,v 1.6 1998/10/12 01:40:53 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -36,6 +36,7 @@ #include <stdio.h> #include <stdarg.h> #include <ctype.h> +#include <time.h> #ifdef NEED_SNPRINTF_H # include "snprintf.h" @@ -153,16 +154,15 @@ add_item_to_tree(GtkWidget *tree, gint start, gint len, GtkWidget *ti; va_list ap; gchar label_str[256]; - guint32 t_info; /* This limits us to a max packet size of 65535 bytes. */ /* Are there any systems out there with < 32-bit pointers? */ /* To do: use gtk_object_set_data instead, now that I know it exists. */ - t_info = ((start & 0xffff) << 16) | (len & 0xffff); va_start(ap, format); vsnprintf(label_str, 256, format, ap); ti = gtk_tree_item_new_with_label(label_str); - gtk_object_set_user_data(GTK_OBJECT(ti), (gpointer) t_info); + gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_START_KEY, (gpointer) start); + gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_LEN_KEY, (gpointer) len); gtk_tree_append(GTK_TREE(tree), ti); gtk_widget_show(ti); @@ -194,18 +194,6 @@ collapse_tree(GtkWidget *w, gpointer data) { *val = 0; } -/* decodes the protocol start and length thare are encoded into - the t_info field in add_item_to_tree. */ -void -decode_start_len(GtkTreeItem *ti, gint *pstart, gint *plen) -{ - guint32 t_info; - - t_info = (guint32) gtk_object_get_user_data(GTK_OBJECT(ti)); - *pstart = t_info >> 16; - *plen = t_info & 0xffff; -} - /* Tries to match val against each element in the value_string array vs. Returns the associated string ptr on a match, or NULL on failure. Len is the length of the array. */ @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.11 1998/10/10 03:32:17 gerald Exp $ + * $Id: packet.h,v 1.12 1998/10/12 01:40:53 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -347,16 +347,18 @@ typedef struct _e_udphdr { gchar* ether_to_str(guint8 *); gchar* ip_to_str(guint8 *); void packet_hex_print(GtkText *, guint8 *, gint, gint, gint); +#define E_TREEINFO_START_KEY "tree_info_start" +#define E_TREEINFO_LEN_KEY "tree_info_len" #if __GNUC__ == 2 GtkWidget* add_item_to_tree(GtkWidget *, gint, gint, gchar *, ...) __attribute__((format (printf, 4, 5))); #else GtkWidget* add_item_to_tree(GtkWidget *, gint, gint, gchar *, ...); #endif -void decode_start_len(GtkTreeItem *, gint*, gint*); gchar* match_strval(guint32, value_string*, gint); /* Routines in packet.c */ + void dissect_packet(const u_char *, guint32 ts_secs, guint32 ts_usecs, frame_data *, GtkTree *); void add_subtree(GtkWidget *, GtkWidget*, gint); @@ -1,7 +1,7 @@ /* prefs.c * Routines for handling preferences * - * $Id: prefs.c,v 1.4 1998/10/10 03:32:18 gerald Exp $ + * $Id: prefs.c,v 1.5 1998/10/12 01:40:55 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -42,22 +42,20 @@ extern capture_file cf; -const gchar *print_page_key = "printer_options_page"; -const gchar *filter_page_key = "filter_options_page"; - void -prefs_cb() { +prefs_cb(GtkWidget *w, gpointer sp) { GtkWidget *prefs_w, *main_vb, *top_hb, *bbox, *prefs_nb, *ok_bt, *save_bt, *cancel_bt; GtkWidget *print_pg, *filter_pg; GtkWidget *nlabel, *label; + gint start_page = (gint) sp; prefs_w = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(prefs_w), "Ethereal: Preferences"); /* Container for each row of widgets */ - main_vb = gtk_vbox_new(FALSE, 3); -/* gtk_container_border_width(GTK_CONTAINER(main_vb), 5); */ + main_vb = gtk_vbox_new(FALSE, 5); + gtk_container_border_width(GTK_CONTAINER(main_vb), 5); gtk_container_add(GTK_CONTAINER(prefs_w), main_vb); gtk_widget_show(main_vb); @@ -71,71 +69,81 @@ prefs_cb() { gtk_widget_show(prefs_nb); /* General prefs */ - nlabel = gtk_label_new("Nothing here yet..."); +/* nlabel = gtk_label_new("Nothing here yet..."); gtk_widget_show (nlabel); label = gtk_label_new ("General"); gtk_notebook_append_page (GTK_NOTEBOOK(prefs_nb), nlabel, label); - + */ /* Printing prefs */ print_pg = printer_prefs_show(); - gtk_object_set_data(GTK_OBJECT(prefs_w), print_page_key, print_pg); + gtk_object_set_data(GTK_OBJECT(prefs_w), E_PRINT_PAGE_KEY, print_pg); label = gtk_label_new ("Printing"); gtk_notebook_append_page (GTK_NOTEBOOK(prefs_nb), print_pg, label); /* Filter prefs */ filter_pg = filter_prefs_show(); - gtk_object_set_data(GTK_OBJECT(prefs_w), filter_page_key, filter_pg); + /* Pass along the entry widget pointer from the calling widget */ + gtk_object_set_data(GTK_OBJECT(filter_pg), E_FILT_TE_PTR_KEY, + gtk_object_get_data(GTK_OBJECT(w), E_FILT_TE_PTR_KEY)); + gtk_object_set_data(GTK_OBJECT(prefs_w), E_FILTER_PAGE_KEY, filter_pg); label = gtk_label_new ("Filters"); gtk_notebook_append_page (GTK_NOTEBOOK(prefs_nb), filter_pg, label); + + /* Jump to the specified page, if it was supplied */ + if (start_page > E_PR_PG_NONE) + gtk_notebook_set_page(GTK_NOTEBOOK(prefs_nb), start_page); /* Button row: OK and cancel buttons */ 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"); gtk_signal_connect_object(GTK_OBJECT(ok_bt), "clicked", GTK_SIGNAL_FUNC(prefs_main_ok_cb), GTK_OBJECT(prefs_w)); - gtk_container_add(GTK_CONTAINER(bbox), ok_bt); 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); save_bt = gtk_button_new_with_label ("Save"); gtk_signal_connect_object(GTK_OBJECT(save_bt), "clicked", GTK_SIGNAL_FUNC(prefs_main_save_cb), GTK_OBJECT(prefs_w)); - gtk_container_add(GTK_CONTAINER(bbox), save_bt); + GTK_WIDGET_SET_FLAGS(save_bt, GTK_CAN_DEFAULT); + gtk_box_pack_start (GTK_BOX (bbox), save_bt, TRUE, TRUE, 0); gtk_widget_show(save_bt); cancel_bt = gtk_button_new_with_label ("Cancel"); gtk_signal_connect_object(GTK_OBJECT(cancel_bt), "clicked", GTK_SIGNAL_FUNC(prefs_main_cancel_cb), GTK_OBJECT(prefs_w)); - gtk_container_add(GTK_CONTAINER(bbox), cancel_bt); + 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); - + gtk_widget_show(prefs_w); } void prefs_main_ok_cb(GtkWidget *w, gpointer win) { - printer_prefs_ok(gtk_object_get_data(GTK_OBJECT(win), print_page_key)); - filter_prefs_ok(gtk_object_get_data(GTK_OBJECT(win), filter_page_key)); + printer_prefs_ok(gtk_object_get_data(GTK_OBJECT(win), E_PRINT_PAGE_KEY)); + filter_prefs_ok(gtk_object_get_data(GTK_OBJECT(win), E_FILTER_PAGE_KEY)); gtk_widget_destroy(GTK_WIDGET(win)); } void prefs_main_save_cb(GtkWidget *w, gpointer win) { - filter_prefs_save(gtk_object_get_data(GTK_OBJECT(win), filter_page_key)); + filter_prefs_save(gtk_object_get_data(GTK_OBJECT(win), E_FILTER_PAGE_KEY)); } void prefs_main_cancel_cb(GtkWidget *w, gpointer win) { - printer_prefs_cancel(gtk_object_get_data(GTK_OBJECT(win), print_page_key)); - filter_prefs_cancel(gtk_object_get_data(GTK_OBJECT(win), filter_page_key)); + printer_prefs_cancel(gtk_object_get_data(GTK_OBJECT(win), E_PRINT_PAGE_KEY)); + filter_prefs_cancel(gtk_object_get_data(GTK_OBJECT(win), E_FILTER_PAGE_KEY)); gtk_widget_destroy(GTK_WIDGET(win)); } @@ -1,7 +1,7 @@ /* prefs.h * Definitions for preference handling routines * - * $Id: prefs.h,v 1.2 1998/10/10 03:32:18 gerald Exp $ + * $Id: prefs.h,v 1.3 1998/10/12 01:40:55 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -26,7 +26,16 @@ #ifndef __PREFS_H__ #define __PREFS_H__ -void prefs_cb(); +#define E_PR_PG_NONE -1 +#define E_PR_PG_PRINTING 0 +#define E_PR_PG_FILTER 1 + +#define E_PRINT_PAGE_KEY "printer_options_page" +#define E_FILTER_PAGE_KEY "filter_options_page" + +#define E_FILT_TE_PTR_KEY "filter_te_ptr" + +void prefs_cb(GtkWidget *, gpointer); void prefs_main_ok_cb(GtkWidget *, gpointer); void prefs_main_save_cb(GtkWidget *, gpointer); void prefs_main_cancel_cb(GtkWidget *, gpointer); @@ -1,7 +1,7 @@ /* print.c * Routines for printing packet analysis trees. * - * $Id: print.c,v 1.5 1998/10/10 03:32:19 gerald Exp $ + * $Id: print.c,v 1.6 1998/10/12 01:40:56 gerald Exp $ * * Gilbert Ramirez <gram@verdict.uthscsa.edu> * @@ -345,7 +345,10 @@ void print_tree_text(FILE *fh, const u_char *pd, frame_data *fd, GtkTree *tree) print_tree_text(fh, pd, fd, GTK_TREE(subtree)); } else if (strcmp("Data", text) == 0) { - decode_start_len(GTK_TREE_ITEM(child->data), &data_start, &data_len); + data_start = (gint) gtk_object_get_data(GTK_OBJECT(child->data), + E_TREEINFO_START_KEY); + data_len = (gint) gtk_object_get_data(GTK_OBJECT(child->data), + E_TREEINFO_LEN_KEY); dumpit(fh, &pd[data_start], data_len); } } @@ -457,7 +460,10 @@ void print_tree_ps(FILE *fh, const u_char *pd, frame_data *fd, GtkTree *tree) print_tree_ps(fh, pd, fd, GTK_TREE(subtree)); } else if (strcmp("Data", text) == 0) { - decode_start_len(GTK_TREE_ITEM(child->data), &data_start, &data_len); + data_start = (gint) gtk_object_get_data(GTK_OBJECT(child->data), + E_TREEINFO_START_KEY); + data_len = (gint) gtk_object_get_data(GTK_OBJECT(child->data), + E_TREEINFO_LEN_KEY); print_ps_hex(fh); dumpit_ps(fh, &pd[data_start], data_len); } @@ -1,7 +1,7 @@ /* util.c * Utility routines * - * $Id: util.c,v 1.3 1998/09/27 22:12:46 gerald Exp $ + * $Id: util.c,v 1.4 1998/10/12 01:40:57 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -31,6 +31,7 @@ #include <gtk/gtk.h> +#include <stdarg.h> #include <strings.h> #include "util.h" @@ -52,14 +53,18 @@ const gchar *bm_key = "button mask"; * To do: * - Switch to variable args */ + +#define ESD_MAX_MSG_LEN 1024 void -simple_dialog(gint type, gint *btn_mask, gchar *message) { +simple_dialog(gint type, gint *btn_mask, gchar *msg_format, ...) { GtkWidget *win, *main_vb, *top_hb, *type_pm, *msg_label, *bbox, *ok_btn, *cancel_btn; GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; GdkColormap *cmap; + va_list ap; + gchar message[ESD_MAX_MSG_LEN]; /* Main window */ win = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -86,6 +91,10 @@ simple_dialog(gint type, gint *btn_mask, gchar *message) { gtk_container_add(GTK_CONTAINER(top_hb), type_pm); gtk_widget_show(type_pm); + /* Load our vararg list into the message string */ + va_start(ap, msg_format); + vsnprintf(message, ESD_MAX_MSG_LEN, msg_format, ap); + msg_label = gtk_label_new(message); gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL); gtk_container_add(GTK_CONTAINER(top_hb), msg_label); @@ -110,6 +119,7 @@ simple_dialog(gint type, gint *btn_mask, gchar *message) { gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked", GTK_SIGNAL_FUNC(simple_dialog_cancel_cb), (gpointer) win); gtk_container_add(GTK_CONTAINER(bbox), cancel_btn); + GTK_WIDGET_SET_FLAGS(cancel_btn, GTK_CAN_DEFAULT); gtk_widget_show(cancel_btn); } @@ -1,7 +1,7 @@ /* util.h * Utility definitions * - * $Id: util.h,v 1.3 1998/09/27 22:12:46 gerald Exp $ + * $Id: util.h,v 1.4 1998/10/12 01:40:57 gerald Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -39,7 +39,13 @@ extern "C" { #define ESD_BTN_OK 0 #define ESD_BTN_CANCEL 1 -void simple_dialog(gint, gint *, gchar *); +#if __GNUC__ == 2 +void simple_dialog(gint, gint *, gchar *, ...) + __attribute__((format (printf, 3, 4))); +#else +void simple_dialog(gint, gint *, gchar *, ...); +#endif + void simple_dialog_cancel_cb(GtkWidget *, gpointer); #ifdef __cplusplus |