/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.108 2000/06/15 08:02:20 guy Exp $
+ * $Id: capture.c,v 1.109 2000/06/27 04:35:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
if (capfile_name != NULL) {
/* Try to open/create the specified file for use as a capture buffer. */
- cf.save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT, 0600);
+ cfile.save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT, 0600);
is_tempfile = FALSE;
} else {
/* Choose a random name for the capture buffer */
- cf.save_file_fd = create_tempfile(tmpname, sizeof tmpname, "ether");
+ cfile.save_file_fd = create_tempfile(tmpname, sizeof tmpname, "ether");
capfile_name = g_strdup(tmpname);
is_tempfile = TRUE;
}
- if (cf.save_file_fd == -1) {
+ if (cfile.save_file_fd == -1) {
simple_dialog(ESD_TYPE_WARN, NULL,
"The file to which the capture would be saved (\"%s\")"
"could not be opened: %s.", capfile_name, strerror(errno));
return;
}
- close_cap_file(&cf, info_bar);
- g_assert(cf.save_file == NULL);
- cf.save_file = capfile_name;
+ close_cap_file(&cfile, info_bar);
+ g_assert(cfile.save_file == NULL);
+ cfile.save_file = capfile_name;
if (sync_mode) { /* do the capture in a child process */
int fork_child;
char *filterstring;
#endif
- sprintf(ssnap,"%d",cf.snap); /* in lieu of itoa */
- sprintf(scount,"%d",cf.count);
- sprintf(save_file_fd,"%d",cf.save_file_fd);
+ sprintf(ssnap,"%d",cfile.snap); /* in lieu of itoa */
+ sprintf(scount,"%d",cfile.count);
+ sprintf(save_file_fd,"%d",cfile.save_file_fd);
#ifdef _WIN32
/* Create a pipe for the child process */
if(_pipe(sync_pipe, 512, O_BINARY) < 0) {
/* Couldn't create the pipe between parent and child. */
error = errno;
- unlink(cf.save_file);
- g_free(cf.save_file);
- cf.save_file = NULL;
+ unlink(cfile.save_file);
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
simple_dialog(ESD_TYPE_WARN, NULL, "Couldn't create sync pipe: %s",
strerror(error));
return;
/* Convert pipe write handle to a string and pass to child */
itoa(sync_pipe[WRITE], sync_pipe_fd, 10);
/* Convert filter string to a quote delimited string */
- filterstring = g_new(char, strlen(cf.cfilter) + 3);
- sprintf(filterstring, "\"%s\"", cf.cfilter);
- filterstring[strlen(cf.cfilter) + 2] = 0;
+ filterstring = g_new(char, strlen(cfile.cfilter) + 3);
+ sprintf(filterstring, "\"%s\"", cfile.cfilter);
+ filterstring[strlen(cfile.cfilter) + 2] = 0;
/* Spawn process */
- fork_child = spawnlp(_P_NOWAIT, ethereal_path, CHILD_NAME, "-i", cf.iface,
- "-w", cf.save_file, "-W", save_file_fd,
+ fork_child = spawnlp(_P_NOWAIT, ethereal_path, CHILD_NAME, "-i", cfile.iface,
+ "-w", cfile.save_file, "-W", save_file_fd,
"-c", scount, "-s", ssnap,
"-Z", sync_pipe_fd,
- strlen(cf.cfilter) == 0 ? (const char *)NULL : "-f",
- strlen(cf.cfilter) == 0 ? (const char *)NULL : filterstring,
+ strlen(cfile.cfilter) == 0 ? (const char *)NULL : "-f",
+ strlen(cfile.cfilter) == 0 ? (const char *)NULL : filterstring,
(const char *)NULL);
g_free(filterstring);
/* Keep a copy for later evaluation by _cwait() */
if (pipe(sync_pipe) < 0) {
/* Couldn't create the pipe between parent and child. */
error = errno;
- unlink(cf.save_file);
- g_free(cf.save_file);
- cf.save_file = NULL;
+ unlink(cfile.save_file);
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
simple_dialog(ESD_TYPE_WARN, NULL, "Couldn't create sync pipe: %s",
strerror(error));
return;
close(1);
dup(sync_pipe[WRITE]);
close(sync_pipe[READ]);
- execlp(ethereal_path, CHILD_NAME, "-i", cf.iface,
- "-w", cf.save_file, "-W", save_file_fd,
+ execlp(ethereal_path, CHILD_NAME, "-i", cfile.iface,
+ "-w", cfile.save_file, "-W", save_file_fd,
"-c", scount, "-s", ssnap,
"-m", medium_font, "-b", bold_font,
- (cf.cfilter == NULL)? 0 : "-f",
- (cf.cfilter == NULL)? 0 : cf.cfilter,
+ (cfile.cfilter == NULL)? 0 : "-f",
+ (cfile.cfilter == NULL)? 0 : cfile.cfilter,
(const char *)NULL);
snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
ethereal_path, strerror(errno));
/* Close the save file FD, as we won't be using it - we'll be opening
it and reading the save file through Wiretap. */
- close(cf.save_file_fd);
+ close(cfile.save_file_fd);
if (fork_child == -1) {
/* We couldn't even create the child process. */
error = errno;
close(sync_pipe[READ]);
- unlink(cf.save_file);
- g_free(cf.save_file);
- cf.save_file = NULL;
+ unlink(cfile.save_file);
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
simple_dialog(ESD_TYPE_WARN, NULL, "Couldn't create child process: %s",
strerror(error));
return;
and report the failure.
XXX - reap the child process and report the status in detail. */
close(sync_pipe[READ]);
- unlink(cf.save_file);
- g_free(cf.save_file);
- cf.save_file = NULL;
+ unlink(cfile.save_file);
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
simple_dialog(ESD_TYPE_WARN, NULL, "Capture child process died");
return;
}
Close the read side of the sync pipe, remove the capture file,
and report the failure. */
close(sync_pipe[READ]);
- unlink(cf.save_file);
- g_free(cf.save_file);
- cf.save_file = NULL;
+ unlink(cfile.save_file);
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
simple_dialog(ESD_TYPE_WARN, NULL,
"Capture child process sent us a bad message");
return;
}
if (byte_count == 0) {
/* Success. Open the capture file, and set up to read it. */
- err = start_tail_cap_file(cf.save_file, is_tempfile, &cf);
+ err = start_tail_cap_file(cfile.save_file, is_tempfile, &cfile);
if (err == 0) {
/* We were able to open and set up to read the capture file;
arrange that our callback be called whenever it's possible
GDK_INPUT_READ|GDK_INPUT_EXCEPTION,
cap_file_input_cb,
NULL,
- (gpointer) &cf,
+ (gpointer) &cfile,
NULL);
#endif
} else {
/* We weren't able to open the capture file; complain, and
close the sync pipe. */
simple_dialog(ESD_TYPE_WARN, NULL,
- file_open_error_message(err, FALSE), cf.save_file);
+ file_open_error_message(err, FALSE), cfile.save_file);
/* Close the sync pipe. */
close(sync_pipe[READ]);
/* Don't unlink the save file - leave it around, for debugging
purposes. */
- g_free(cf.save_file);
- cf.save_file = NULL;
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
}
} else {
/* Failure - the child process sent us a message indicating
close(sync_pipe[READ]);
/* Get rid of the save file - the capture never started. */
- unlink(cf.save_file);
- g_free(cf.save_file);
- cf.save_file = NULL;
+ unlink(cfile.save_file);
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
}
}
} else {
}
if (capture_succeeded) {
/* Capture succeeded; read in the capture file. */
- if ((err = open_cap_file(cf.save_file, is_tempfile, &cf)) == 0) {
+ if ((err = open_cap_file(cfile.save_file, is_tempfile, &cfile)) == 0) {
/* Set the read filter to NULL. */
- cf.rfcode = NULL;
- err = read_cap_file(&cf);
+ cfile.rfcode = NULL;
+ err = read_cap_file(&cfile);
}
}
/* We're not doing a capture any more, so we don't have a save
file. */
- g_free(cf.save_file);
- cf.save_file = NULL;
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
}
}
gtk_timeout_remove(cap_timer_id);
/* And call the real handler */
- cap_file_input_cb((gpointer) &cf, 0, 0);
+ cap_file_input_cb((gpointer) &cfile, 0, 0);
/* Return false so that the timer is not run again */
return FALSE;
ld.go = TRUE;
ld.counts.total = 0;
- ld.max = cf.count;
+ ld.max = cfile.count;
ld.linktype = WTAP_ENCAP_UNKNOWN;
ld.sync_packets = 0;
ld.counts.sctp = 0;
ld.pdh = NULL;
/* Open the network interface to capture from it. */
- pch = pcap_open_live(cf.iface, cf.snap, 1, CAP_READ_TIMEOUT, err_str);
+ pch = pcap_open_live(cfile.iface, cfile.snap, 1, CAP_READ_TIMEOUT, err_str);
if (pch == NULL) {
/* Well, we couldn't start the capture.
goto error;
}
- if (cf.cfilter) {
+ if (cfile.cfilter) {
/* A capture filter was specified; set it up. */
- if (pcap_lookupnet (cf.iface, &netnum, &netmask, err_str) < 0) {
+ if (pcap_lookupnet (cfile.iface, &netnum, &netmask, err_str) < 0) {
snprintf(errmsg, sizeof errmsg,
"Can't use filter: Couldn't obtain netmask info (%s).", err_str);
goto error;
}
- if (pcap_compile(pch, &cf.fcode, cf.cfilter, 1, netmask) < 0) {
+ if (pcap_compile(pch, &cfile.fcode, cfile.cfilter, 1, netmask) < 0) {
snprintf(errmsg, sizeof errmsg, "Unable to parse filter string (%s).",
pcap_geterr(pch));
goto error;
}
- if (pcap_setfilter(pch, &cf.fcode) < 0) {
+ if (pcap_setfilter(pch, &cfile.fcode) < 0) {
snprintf(errmsg, sizeof errmsg, "Can't install filter (%s).",
pcap_geterr(pch));
goto error;
" that Ethereal doesn't support.");
goto error;
}
- ld.pdh = wtap_dump_fdopen(cf.save_file_fd, WTAP_FILE_PCAP,
+ ld.pdh = wtap_dump_fdopen(cfile.save_file_fd, WTAP_FILE_PCAP,
ld.linktype, pcap_snapshot(pch), &err);
if (ld.pdh == NULL) {
if (err < 0) {
sprintf(errmsg, "The file to which the capture would be"
" saved (\"%s\") could not be opened: Error %d.",
- cf.save_file, err);
+ cfile.save_file, err);
} else {
sprintf(errmsg, "The file to which the capture would be"
" saved (\"%s\") could not be opened: %s.",
- cf.save_file, strerror(err));
+ cfile.save_file, strerror(err));
}
break;
}
simple_dialog(ESD_TYPE_WARN, NULL,
"The file to which the capture was being"
" saved (\"%s\") could not be closed: %s.",
- cf.save_file, wtap_strerror(err));
+ cfile.save_file, wtap_strerror(err));
break;
}
}
error:
/* We can't use the save file, and we have no wtap_dump stream
to close in order to close it, so close the FD directly. */
- close(cf.save_file_fd);
+ close(cfile.save_file_fd);
/* We couldn't even start the capture, so get rid of the capture
file. */
- unlink(cf.save_file); /* silently ignore error */
- g_free(cf.save_file);
- cf.save_file = NULL;
+ unlink(cfile.save_file); /* silently ignore error */
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
if (capture_child) {
/* This is the child process for a sync mode capture.
Send the error message to our parent, so they can display a
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.189 2000/05/19 23:06:06 gram Exp $
+ * $Id: file.c,v 1.190 2000/06/27 04:35:44 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
sizeof(frame_data),
FRAME_DATA_CHUNK_SIZE * sizeof(frame_data),
G_ALLOC_AND_FREE);
+ g_assert(cf->plist_chunk);
return (0);
/* globals.h
* Global defines, etc.
*
- * $Id: globals.h,v 1.17 2000/01/25 04:31:16 guy Exp $
+ * $Id: globals.h,v 1.18 2000/06/27 04:35:45 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
extern FILE *data_out_file;
extern packet_info pi;
-extern capture_file cf;
+extern capture_file cfile;
extern guint main_ctx, file_ctx;
extern gchar comp_info_str[256];
extern gchar *ethereal_path;
/* capture_dlg.c
* Routines for packet capture windows
*
- * $Id: capture_dlg.c,v 1.26 2000/06/15 08:02:42 guy Exp $
+ * $Id: capture_dlg.c,v 1.27 2000/06/27 04:35:57 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
if_cb = gtk_combo_new();
if (if_list != NULL)
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);
+ if (cfile.iface)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cfile.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(if_hb), if_cb, FALSE, FALSE, 0);
gtk_widget_show(count_lb);
count_list = g_list_append(count_list, count_item1);
- if (cf.count) {
- snprintf(count_item2, 15, "%d", cf.count);
+ if (cfile.count) {
+ snprintf(count_item2, 15, "%d", cfile.count);
count_list = g_list_append(count_list, count_item2);
}
gtk_widget_show(filter_bt);
filter_te = gtk_entry_new();
- if (cf.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cf.cfilter);
+ if (cfile.cfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cfile.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);
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,
+ adj = (GtkAdjustment *) gtk_adjustment_new((float) cfile.snap,
MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
snap_sb = gtk_spin_button_new (adj, 0, 0);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
g_free(if_name);
return;
}
- if (cf.iface)
- g_free(cf.iface);
- cf.iface = g_strdup(if_name);
+ if (cfile.iface)
+ g_free(cfile.iface);
+ cfile.iface = g_strdup(if_name);
g_free(if_text);
- /* XXX - don't try to get clever and set "cf.filter" to NULL if the
+ /* XXX - don't try to get clever and set "cfile.filter" to NULL if the
filter string is empty, as an indication that we don't have a filter
and thus don't have to set a filter when capturing - the version of
libpcap in Red Hat Linux 6.1, and versions based on later patches
no filter is set, which means no packets arrive as input on that
socket, which means Ethereal never sees any packets. */
filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
- if (cf.cfilter)
- g_free(cf.cfilter);
+ if (cfile.cfilter)
+ g_free(cfile.cfilter);
g_assert(filter_text != NULL);
- cf.cfilter = g_strdup(filter_text);
+ cfile.cfilter = g_strdup(filter_text);
save_file = gtk_entry_get_text(GTK_ENTRY(file_te));
if (save_file && save_file[0]) {
save_file = NULL;
}
- cf.count = atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(count_cb)->entry)));
+ cfile.count = atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(count_cb)->entry)));
- cf.snap = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
- if (cf.snap < 1)
- cf.snap = WTAP_MAX_PACKET_SIZE;
- else if (cf.snap < MIN_PACKET_SIZE)
- cf.snap = MIN_PACKET_SIZE;
+ cfile.snap = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
+ if (cfile.snap < 1)
+ cfile.snap = WTAP_MAX_PACKET_SIZE;
+ else if (cfile.snap < MIN_PACKET_SIZE)
+ cfile.snap = MIN_PACKET_SIZE;
sync_mode = GTK_TOGGLE_BUTTON (sync_cb)->active;
/* color_dlg.c
* Definitions for dialog boxes for color filters
*
- * $Id: color_dlg.c,v 1.2 2000/02/12 08:42:26 guy Exp $
+ * $Id: color_dlg.c,v 1.3 2000/06/27 04:35:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
reactivate_window(colorize_win);
} else {
/* Create a new "Colorize Display" dialog. */
- colorize_win = colorize_dialog_new(cf.colors);
+ colorize_win = colorize_dialog_new(cfile.colors);
}
}
gpointer user_data)
{
/* colorize list */
- colorize_packets(&cf);
+ colorize_packets(&cfile);
/* Destroy the dialog box. */
gtk_widget_destroy(colorize_win);
color_apply_cb (GtkButton *button,
gpointer user_data)
{
- colorize_packets(&cf);
+ colorize_packets(&cfile);
}
/* Create an "Edit color filter" dialog for a given color filter, and
colorf->fg_color = new_fg_color;
colorf->bg_color = new_bg_color;
gtk_clist_set_foreground(GTK_CLIST(color_filters),
- cf.colors->row_selected, &new_fg_color);
+ cfile.colors->row_selected, &new_fg_color);
gtk_clist_set_background(GTK_CLIST(color_filters),
- cf.colors->row_selected, &new_bg_color);
+ cfile.colors->row_selected, &new_bg_color);
if(colorf->c_colorfilter != NULL)
dfilter_destroy(colorf->c_colorfilter);
colorf->c_colorfilter = compiled_filter;
/* gtk_clist_set_text frees old text (if any) and allocates new space */
gtk_clist_set_text(GTK_CLIST(color_filters),
- cf.colors->row_selected, 0, filter_name);
+ cfile.colors->row_selected, 0, filter_name);
gtk_clist_set_text(GTK_CLIST(color_filters),
- cf.colors->row_selected, 1, filter_text);
+ cfile.colors->row_selected, 1, filter_text);
/* Destroy the dialog box. */
gtk_widget_destroy(dialog);
/* display_opts.c
* Routines for packet display windows
*
- * $Id: display_opts.c,v 1.7 2000/05/08 05:51:37 guy Exp $
+ * $Id: display_opts.c,v 1.8 2000/06/27 04:35:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#include "ui_util.h"
#include "dlg_utils.h"
-extern capture_file cf;
+extern capture_file cfile;
extern GtkWidget *packet_list;
/* Display callback data keys */
gtk_widget_destroy(GTK_WIDGET(parent_w));
- change_time_formats(&cf);
+ change_time_formats(&cfile);
}
static void
E_DISPLAY_IP_DSCP_KEY);
g_ip_dscp_actif = (GTK_TOGGLE_BUTTON (button)->active);
- change_time_formats(&cf);
+ change_time_formats(&cfile);
}
static void
if (timestamp_type != prev_timestamp_type) {
timestamp_type = prev_timestamp_type;
- change_time_formats(&cf);
+ change_time_formats(&cfile);
}
gtk_grab_remove(GTK_WIDGET(parent_w));
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.24 2000/06/02 03:35:39 gram Exp $
+ * $Id: file_dlg.c,v 1.25 2000/06/27 04:36:00 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
}
/* Try to open the capture file. */
- if ((err = open_cap_file(cf_name, FALSE, &cf)) != 0) {
+ if ((err = open_cap_file(cf_name, FALSE, &cfile)) != 0) {
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can, after they
dismiss the alert box popped up for the open error,
/* Attach the new read filter to "cf" ("open_cap_file()" succeeded, so
it closed the previous capture file, and thus destroyed any
previous read filter attached to "cf"). */
- cf.rfcode = rfcode;
+ cfile.rfcode = rfcode;
/* Set the global resolving variable */
resolv_cb = gtk_object_get_data(GTK_OBJECT(w), E_FILE_RESOLVE_KEY);
gtk_widget_hide(GTK_WIDGET (fs));
gtk_widget_destroy(GTK_WIDGET (fs));
- err = read_cap_file(&cf);
+ err = read_cap_file(&cfile);
/* Save the name of the containing directory specified in the path name,
if any; we can write over cf_name, which is a good thing, given that
"get_dirname()" does write over its argument. */
/* Close a file */
void
file_close_cmd_cb(GtkWidget *widget, gpointer data) {
- close_cap_file(&cf, info_bar);
+ close_cap_file(&cfile, info_bar);
}
void
file_save_cmd_cb(GtkWidget *w, gpointer data) {
/* If the file's already been saved, do nothing. */
- if (cf.user_saved)
+ if (cfile.user_saved)
return;
/* Do a "Save As". */
/* To save a file with Wiretap, Wiretap has to handle that format,
and its code to handle that format must be able to write a file
with this file's encapsulation type. */
- return wtap_dump_can_open(ft) && wtap_dump_can_write_encap(ft, cf.lnk_t);
+ return wtap_dump_can_open(ft) && wtap_dump_can_write_encap(ft, cfile.lnk_t);
}
/* Generate a list of the file types we can save this file as.
/* Check all file types. */
index = 0;
for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) {
- if (filtered || ft != cf.cd_t) {
+ if (filtered || ft != cfile.cd_t) {
/* Filtered, or a different file type. We have to use Wiretap. */
if (!can_save_with_wiretap(ft))
continue; /* We can't. */
/* Default to saving all packets, in the file's current format. */
filtered = FALSE;
- filetype = cf.cd_t;
+ filetype = cfile.cd_t;
file_save_as_w = gtk_file_selection_new ("Ethereal: Save Capture File As");
gtk_signal_connect(GTK_OBJECT(file_save_as_w), "destroy",
/* Write out the packets (all, or only the ones that are currently
displayed) to the file with the specified name. */
- save_cap_file(cf_name, &cf, filtered, filetype);
+ save_cap_file(cf_name, &cfile, filtered, filetype);
/* If "save_cap_file()" saved the file name we handed it, it saved
a copy, so we should free up our copy. */
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)));
+ if (cfile.dfilter)
+ g_free(cfile.dfilter);
+ cfile.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te)));
/* If the file could be opened, "open_cap_file()" calls "close_cap_file()"
to get rid of state for the old capture file before filling in state
a temporary file, mark it as not being a temporary file, and then
reopen it as the type of file it was.
- Also, "close_cap_file()" will free "cf.filename", so we must make
+ Also, "close_cap_file()" will free "cfile.filename", so we must make
a copy of it first. */
- filename = strdup(cf.filename);
- is_tempfile = cf.is_tempfile;
- cf.is_tempfile = FALSE;
- if (open_cap_file(filename, is_tempfile, &cf) == 0)
- read_cap_file(&cf);
+ filename = strdup(cfile.filename);
+ is_tempfile = cfile.is_tempfile;
+ cfile.is_tempfile = FALSE;
+ if (open_cap_file(filename, is_tempfile, &cfile) == 0)
+ read_cap_file(&cfile);
else {
- /* The open failed, so "cf.is_tempfile" wasn't set to "is_tempfile".
- Instead, the file was left open, so we should restore "cf.is_tempfile"
+ /* The open failed, so "cfile.is_tempfile" wasn't set to "is_tempfile".
+ Instead, the file was left open, so we should restore "cfile.is_tempfile"
ourselves.
XXX - change the menu? Presumably "open_cap_file()" will do that;
make sure it does! */
- cf.is_tempfile = is_tempfile;
+ cfile.is_tempfile = is_tempfile;
}
/* "open_cap_file()" made a copy of the file name we handed it, so
we should free up our copy. */
/* find_dlg.c
* Routines for "find frame" window
*
- * $Id: find_dlg.c,v 1.10 2000/05/08 04:53:20 guy Exp $
+ * $Id: find_dlg.c,v 1.11 2000/06/27 04:36:00 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
gtk_widget_show(filter_bt);
filter_te = gtk_entry_new();
- if (cf.sfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cf.sfilter);
+ if (cfile.sfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cfile.sfilter);
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);
forward_rb = dlg_radio_button_new_with_label_with_mnemonic(NULL, "_Forward",
accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(forward_rb), !cf.sbackward);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(forward_rb), !cfile.sbackward);
gtk_box_pack_start(GTK_BOX(direction_hb), forward_rb, TRUE, TRUE, 0);
gtk_widget_show(forward_rb);
backward_rb = dlg_radio_button_new_with_label_with_mnemonic(
gtk_radio_button_group(GTK_RADIO_BUTTON(forward_rb)),
"_Backward", accel_group);
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(backward_rb), cf.sbackward);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(backward_rb), cfile.sbackward);
gtk_box_pack_start(GTK_BOX(direction_hb), backward_rb, TRUE, TRUE, 0);
gtk_widget_show(backward_rb);
/*
* Remember the filter.
*/
- if (cf.sfilter)
- g_free(cf.sfilter);
- cf.sfilter = g_strdup(filter_text);
+ if (cfile.sfilter)
+ g_free(cfile.sfilter);
+ cfile.sfilter = g_strdup(filter_text);
- cf.sbackward = GTK_TOGGLE_BUTTON (backward_rb)->active;
+ cfile.sbackward = GTK_TOGGLE_BUTTON (backward_rb)->active;
- if (!find_packet(&cf, sfcode)) {
+ if (!find_packet(&cfile, sfcode)) {
/* We didn't find the packet. */
simple_dialog(ESD_TYPE_WARN, NULL, "No packet matched that filter.");
return;
/* goto_dlg.c
* Routines for "go to frame" window
*
- * $Id: goto_dlg.c,v 1.6 2000/05/02 08:04:31 guy Exp $
+ * $Id: goto_dlg.c,v 1.7 2000/06/27 04:36:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
return;
}
- switch (goto_frame(&cf, fnumber)) {
+ switch (goto_frame(&cfile, fnumber)) {
case NO_SUCH_FRAME:
simple_dialog(ESD_TYPE_WARN, NULL, "There is no frame with that frame number.");
/* main.c
*
- * $Id: main.c,v 1.122 2000/06/24 05:06:29 guy Exp $
+ * $Id: main.c,v 1.123 2000/06/27 04:36:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
FILE *data_out_file = NULL;
packet_info pi;
-capture_file cf;
+capture_file cfile;
GtkWidget *top_level, *packet_list, *tree_view, *byte_view,
*prog_bar, *info_bar, *tv_scrollw, *pkt_scrollw;
static GtkWidget *bv_scrollw;
gtk_entry_set_text(GTK_ENTRY(filter_te), follow_filter);
/* Run the display filter so it goes in effect. */
- filter_packets(&cf, follow_filter);
+ filter_packets(&cfile, follow_filter);
/* the data_out_file should now be full of the streams information */
fclose( data_out_file );
break;
#endif
default:
- c = cf.pd + finfo_selected->start;
+ c = cfile.pd + finfo_selected->start;
buf = g_malloc0(32 + finfo_selected->length * 3);
ptr = buf;
gtk_entry_set_text(GTK_ENTRY(filter_te), buf);
/* Run the display filter so it goes in effect. */
- filter_packets(&cf, buf);
+ filter_packets(&cfile, buf);
/* Don't g_free(buf) here. filter_packets() will do it the next time it's called */
}
/* 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 (filter_packets(&cf, g_strdup(s))) {
+ if (filter_packets(&cfile, g_strdup(s))) {
li = g_list_first(filter_list);
while (li) {
if (li->data && strcmp(s, li->data) == 0)
gtk_entry_set_text(GTK_ENTRY(filter_te), "");
}
- filter_packets(&cf, NULL);
+ filter_packets(&cfile, NULL);
}
/* GTKClist compare routine, overrides default to allow numeric comparison */
double num1 = atof(text1);
double num2 = atof(text2);
- gint col_fmt = cf.cinfo.col_fmt[clist->sort_column];
+ gint col_fmt = cfile.cinfo.col_fmt[clist->sort_column];
if ((col_fmt == COL_NUMBER) || (col_fmt == COL_REL_TIME) || (col_fmt == COL_DELTA_TIME) ||
((col_fmt == COL_CLS_TIME) && (timestamp_type == RELATIVE)) ||
packet_list_select_cb(GtkWidget *w, gint row, gint col, gpointer evt) {
blank_packetinfo();
- select_packet(&cf, row);
+ select_packet(&cfile, row);
}
static void
packet_list_unselect_cb(GtkWidget *w, gint row, gint col, gpointer evt) {
- unselect_packet(&cf);
+ unselect_packet(&cfile);
}
static void
finfo_selected = finfo;
- packet_hex_print(GTK_TEXT(byte_view), cf.pd, cf.current_frame->cap_len,
- finfo->start, finfo->length, cf.current_frame->flags.encoding);
+ packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len,
+ finfo->start, finfo->length, cfile.current_frame->flags.encoding);
}
static void
tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user_data)
{
finfo_selected = NULL;
- packet_hex_print(GTK_TEXT(byte_view), cf.pd, cf.current_frame->cap_len,
- -1, -1, cf.current_frame->flags.encoding);
+ packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len,
+ -1, -1, cfile.current_frame->flags.encoding);
}
void collapse_all_cb(GtkWidget *widget, gpointer data) {
- if (cf.protocol_tree)
- collapse_all_tree(cf.protocol_tree, tree_view);
+ if (cfile.protocol_tree)
+ collapse_all_tree(cfile.protocol_tree, tree_view);
}
void expand_all_cb(GtkWidget *widget, gpointer data) {
- if (cf.protocol_tree)
- expand_all_tree(cf.protocol_tree, tree_view);
+ if (cfile.protocol_tree)
+ expand_all_tree(cfile.protocol_tree, tree_view);
}
void resolve_name_cb(GtkWidget *widget, gpointer data) {
- if (cf.protocol_tree) {
+ if (cfile.protocol_tree) {
int tmp = g_resolving_actif;
g_resolving_actif = 1;
gtk_clist_clear ( GTK_CLIST(tree_view) );
- proto_tree_draw(cf.protocol_tree, tree_view);
+ proto_tree_draw(cfile.protocol_tree, tree_view);
g_resolving_actif = tmp;
}
}
set_plist_sel_browse(gboolean val)
{
if (finfo_selected)
- unselect_packet(&cf);
+ unselect_packet(&cfile);
/* Yeah, GTK uses "browse" in the case where we do not, but oh well. I think
* "browse" in Ethereal makes more sense than "SINGLE" in GTK+ */
which we'd call here, and another routine that
calls that routine and also cleans up the UI, which
we'd call elsewhere? */
- close_cap_file(&cf, info_bar);
+ close_cap_file(&cfile, info_bar);
+ fprintf( stderr, "file_quit_cmd_cb: About to call gtk_main_quit()\n");
/* Exit by leaving the main loop, so that any quit functions
we registered get called. */
gtk_main_quit();
}
/* Initialize the capture file struct */
- cf.plist = NULL;
- cf.plist_end = NULL;
- cf.wth = NULL;
- cf.filename = NULL;
- cf.user_saved = FALSE;
- cf.is_tempfile = FALSE;
- cf.rfcode = NULL;
- cf.dfilter = NULL;
- cf.dfcode = NULL;
+ cfile.plist = NULL;
+ cfile.plist_end = NULL;
+ cfile.wth = NULL;
+ cfile.filename = NULL;
+ cfile.user_saved = FALSE;
+ cfile.is_tempfile = FALSE;
+ cfile.rfcode = NULL;
+ cfile.dfilter = NULL;
+ cfile.dfcode = NULL;
#ifdef HAVE_LIBPCAP
- cf.cfilter = g_strdup(EMPTY_FILTER);
+ cfile.cfilter = g_strdup(EMPTY_FILTER);
#endif
- cf.iface = NULL;
- cf.save_file = NULL;
- cf.save_file_fd = -1;
- cf.snap = WTAP_MAX_PACKET_SIZE;
- cf.count = 0;
- cf.cinfo.num_cols = prefs->num_cols;
- cf.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols);
- cf.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cf.cinfo.num_cols);
- cf.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols);
- cf.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols);
- cf.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols);
+ cfile.iface = NULL;
+ cfile.save_file = NULL;
+ cfile.save_file_fd = -1;
+ cfile.snap = WTAP_MAX_PACKET_SIZE;
+ cfile.count = 0;
+ cfile.cinfo.num_cols = prefs->num_cols;
+ cfile.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols);
+ cfile.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cfile.cinfo.num_cols);
+ cfile.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols);
+ cfile.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
+ cfile.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
/* Assemble the compile-time options */
snprintf(comp_info_str, 256,
break;
case 'c': /* Capture xxx packets */
#ifdef HAVE_LIBPCAP
- cf.count = atoi(optarg);
+ cfile.count = atoi(optarg);
#else
capture_option_specified = TRUE;
arg_error = TRUE;
break;
case 'f':
#ifdef HAVE_LIBPCAP
- if (cf.cfilter)
- g_free(cf.cfilter);
- cf.cfilter = g_strdup(optarg);
+ if (cfile.cfilter)
+ g_free(cfile.cfilter);
+ cfile.cfilter = g_strdup(optarg);
#else
capture_option_specified = TRUE;
arg_error = TRUE;
break;
case 'i': /* Use interface xxx */
#ifdef HAVE_LIBPCAP
- cf.iface = g_strdup(optarg);
+ cfile.iface = g_strdup(optarg);
#else
capture_option_specified = TRUE;
arg_error = TRUE;
break;
case 's': /* Set the snapshot (capture) length */
#ifdef HAVE_LIBPCAP
- cf.snap = atoi(optarg);
+ cfile.snap = atoi(optarg);
#else
capture_option_specified = TRUE;
arg_error = TRUE;
break;
case 'W': /* Write to capture file FD xxx */
#ifdef HAVE_LIBPCAP
- cf.save_file_fd = atoi(optarg);
+ cfile.save_file_fd = atoi(optarg);
#else
capture_option_specified = TRUE;
arg_error = TRUE;
if (start_capture) {
/* We're supposed to do a live capture; did the user specify an interface
to use? */
- if (cf.iface == NULL) {
+ if (cfile.iface == NULL) {
/* No - pick the first one from the list of interfaces. */
if_list = get_interface_list(&err, err_str);
if (if_list == NULL) {
}
exit(2);
}
- cf.iface = g_strdup(if_list->data); /* first interface */
+ cfile.iface = g_strdup(if_list->data); /* first interface */
free_interface_list(if_list);
}
}
if (capture_child) {
- if (cf.save_file_fd == -1) {
+ if (cfile.save_file_fd == -1) {
/* XXX - send this to the standard output as something our parent
should put in an error message box? */
fprintf(stderr, "%s: \"-W\" flag not specified\n", CHILD_NAME);
#endif
/* Build the column format array */
- for (i = 0; i < cf.cinfo.num_cols; i++) {
- cf.cinfo.col_fmt[i] = get_column_format(i);
- cf.cinfo.col_title[i] = g_strdup(get_column_title(i));
- cf.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) *
+ for (i = 0; i < cfile.cinfo.num_cols; i++) {
+ cfile.cinfo.col_fmt[i] = get_column_format(i);
+ cfile.cinfo.col_title[i] = g_strdup(get_column_title(i));
+ cfile.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) *
NUM_COL_FMTS);
- get_column_format_matches(cf.cinfo.fmt_matx[i], cf.cinfo.col_fmt[i]);
- if (cf.cinfo.col_fmt[i] == COL_INFO)
- cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN);
+ get_column_format_matches(cfile.cinfo.fmt_matx[i], cfile.cinfo.col_fmt[i]);
+ if (cfile.cinfo.col_fmt[i] == COL_INFO)
+ cfile.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN);
else
- cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ cfile.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
}
- if (cf.snap < 1)
- cf.snap = WTAP_MAX_PACKET_SIZE;
- else if (cf.snap < MIN_PACKET_SIZE)
- cf.snap = MIN_PACKET_SIZE;
+ if (cfile.snap < 1)
+ cfile.snap = WTAP_MAX_PACKET_SIZE;
+ else if (cfile.snap < MIN_PACKET_SIZE)
+ cfile.snap = MIN_PACKET_SIZE;
rc_file = (gchar *) g_malloc(strlen(get_home_dir()) + strlen(RC_FILE) + 4);
sprintf(rc_file, "%s/%s", get_home_dir(), RC_FILE);
gtk_widget_show(top_level);
set_menus_for_capture_file(FALSE);
- cf.colors = colfilter_new();
+ cfile.colors = colfilter_new();
/* If we were given the name of a capture file, read it in now;
we defer it until now, so that, if we can't open it, and pop
}
}
if (!rfilter_parse_failed) {
- if ((err = open_cap_file(cf_name, FALSE, &cf)) == 0) {
+ if ((err = open_cap_file(cf_name, FALSE, &cfile)) == 0) {
/* "open_cap_file()" succeeded, so it closed the previous
capture file, and thus destroyed any previous read filter
attached to "cf". */
- cf.rfcode = rfcode;
- err = read_cap_file(&cf);
+ cfile.rfcode = rfcode;
+ err = read_cap_file(&cfile);
/* Save the name of the containing directory specified in the
path name, if any; we can write over cf_name, which is a
good thing, given that "get_dirname()" does write over its
last_open_dir = s;
} else {
dfilter_destroy(rfcode);
- cf.rfcode = NULL;
+ cfile.rfcode = NULL;
}
}
}
gtk_widget_show(pkt_scrollw);
gtk_paned_add1(GTK_PANED(u_pane), pkt_scrollw);
- packet_list = gtk_clist_new_with_titles(cf.cinfo.num_cols, cf.cinfo.col_title);
+ packet_list = gtk_clist_new_with_titles(cfile.cinfo.num_cols, cfile.cinfo.col_title);
gtk_container_add(GTK_CONTAINER(pkt_scrollw), packet_list);
set_plist_sel_browse(prefs->gui_plist_sel_browse);
GTK_SIGNAL_FUNC(packet_list_select_cb), NULL);
gtk_signal_connect(GTK_OBJECT(packet_list), "unselect_row",
GTK_SIGNAL_FUNC(packet_list_unselect_cb), NULL);
- for (i = 0; i < cf.cinfo.num_cols; i++) {
- if (get_column_resize_type(cf.cinfo.col_fmt[i]) != RESIZE_MANUAL)
+ for (i = 0; i < cfile.cinfo.num_cols; i++) {
+ if (get_column_resize_type(cfile.cinfo.col_fmt[i]) != RESIZE_MANUAL)
gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, TRUE);
/* Right-justify the packet number column. */
- if (cf.cinfo.col_fmt[i] == COL_NUMBER)
+ if (cfile.cinfo.col_fmt[i] == COL_NUMBER)
gtk_clist_set_column_justification(GTK_CLIST(packet_list), i,
GTK_JUSTIFY_RIGHT);
/* Save static column sizes to use during a "-S" capture, so that
the columns don't resize during a live capture. */
- cf.cinfo.col_width[i] = gdk_string_width(pl_style->font,
+ cfile.cinfo.col_width[i] = gdk_string_width(pl_style->font,
get_column_longest_string(get_column_format(i)));
}
gtk_widget_set_usize(packet_list, -1, pl_size);
*
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet_win.c,v 1.8 2000/05/19 23:06:32 gram Exp $
+ * $Id: packet_win.c,v 1.9 2000/06/27 04:36:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
/* data from the packet_list GtkCList */
/* Find what row this packet is in. */
row = gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
- cf.current_frame);
+ cfile.current_frame);
g_assert(row != -1);
- for( i = 0; i < cf.cinfo.num_cols; ++i){
+ for( i = 0; i < cfile.cinfo.num_cols; ++i){
if ( gtk_clist_get_text(GTK_CLIST( packet_list),
row, i, &TextPtr)){
/* Allocate data structure to represent this window. */
DataPtr = (struct PacketWinData *) g_malloc(sizeof(struct PacketWinData));
- DataPtr->cap_len = cf.current_frame->cap_len;
- DataPtr->encoding = cf.current_frame->flags.encoding;
- memcpy(&DataPtr->pseudo_header, &cf.pseudo_header, sizeof DataPtr->pseudo_header);
+ DataPtr->cap_len = cfile.current_frame->cap_len;
+ DataPtr->encoding = cfile.current_frame->flags.encoding;
+ memcpy(&DataPtr->pseudo_header, &cfile.pseudo_header, sizeof DataPtr->pseudo_header);
DataPtr->pd = g_malloc(DataPtr->cap_len);
- memcpy(DataPtr->pd, cf.pd, DataPtr->cap_len);
+ memcpy(DataPtr->pd, cfile.pd, DataPtr->cap_len);
DataPtr->protocol_tree = proto_tree_create_root();
proto_tree_is_visible = TRUE;
- dissect_packet(&DataPtr->pseudo_header, DataPtr->pd, cf.current_frame,
+ dissect_packet(&DataPtr->pseudo_header, DataPtr->pd, cfile.current_frame,
DataPtr->protocol_tree);
proto_tree_is_visible = FALSE;
DataPtr->main = main_w;
/* print_dlg.c
* Dialog boxes for printing
*
- * $Id: print_dlg.c,v 1.17 2000/05/08 07:13:40 guy Exp $
+ * $Id: print_dlg.c,v 1.18 2000/06/27 04:36:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
gtk_widget_destroy(GTK_WIDGET(parent_w));
/* Now print the packets */
- if (!print_packets(&cf, &print_args)) {
+ if (!print_packets(&cfile, &print_args)) {
if (print_args.to_file)
simple_dialog(ESD_TYPE_WARN, NULL,
file_write_error_message(errno), print_args.dest);
print_args.print_summary = FALSE;
print_args.print_hex = FALSE;
print_args.expand_all = TRUE;
- proto_tree_print(TRUE, &print_args, (GNode*) cf.protocol_tree, cf.pd,
- cf.current_frame, fh);
+ proto_tree_print(TRUE, &print_args, (GNode*) cfile.protocol_tree, cfile.pd,
+ cfile.current_frame, fh);
print_finale(fh, prefs.pr_format);
close_print_dest(print_args.to_file, fh);
}
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.94 2000/05/31 05:07:57 guy Exp $
+ * $Id: packet.c,v 1.95 2000/06/27 04:35:45 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#include "plugins.h"
-extern capture_file cf;
+extern capture_file cfile;
static int proto_frame = -1;
static int hf_frame_arrival_time = -1;
/* summary.c
* Routines for capture file summary info
*
- * $Id: summary.c,v 1.17 2000/04/13 20:39:18 gram Exp $
+ * $Id: summary.c,v 1.18 2000/06/27 04:35:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
st->filtered_count = 0;
/* initialize the tally */
- if (cf.plist != NULL) {
- first_frame = cf.plist;
+ if (cfile.plist != NULL) {
+ first_frame = cfile.plist;
st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
- cur_glist = cf.plist;
+ cur_glist = cfile.plist;
- for (i = 0; i < cf.count; i++) {
+ for (i = 0; i < cfile.count; i++) {
cur_frame = cur_glist;
tally_frame_data(cur_frame, st);
cur_glist = cur_glist->next;
}
}
- st->filename = cf.filename;
- st->file_length = cf.f_len;
- st->encap_type = cf.cd_t;
- st->snap = cf.snap;
- st->elapsed_time = secs_usecs(cf.esec, cf.eusec);
- st->packet_count = cf.count;
- st->drops = cf.drops;
- st->iface = cf.iface;
- st->dfilter = cf.dfilter;
+ st->filename = cfile.filename;
+ st->file_length = cfile.f_len;
+ st->encap_type = cfile.cd_t;
+ st->snap = cfile.snap;
+ st->elapsed_time = secs_usecs(cfile.esec, cfile.eusec);
+ st->packet_count = cfile.count;
+ st->drops = cfile.drops;
+ st->iface = cfile.iface;
+ st->dfilter = cfile.dfilter;
#ifdef HAVE_LIBPCAP
- st->cfilter = cf.cfilter;
+ st->cfilter = cfile.cfilter;
#else
st->cfilter = NULL;
#endif
/* tethereal.c
*
- * $Id: tethereal.c,v 1.30 2000/06/15 07:49:25 guy Exp $
+ * $Id: tethereal.c,v 1.31 2000/06/27 04:35:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
static gchar *col_info(frame_data *, gint);
packet_info pi;
-capture_file cf;
+capture_file cfile;
FILE *data_out_file = NULL;
guint main_ctx, file_ctx;
ts_type timestamp_type = RELATIVE;
}
/* Initialize the capture file struct */
- cf.plist = NULL;
- cf.plist_end = NULL;
- cf.wth = NULL;
- cf.filename = NULL;
- cf.user_saved = FALSE;
- cf.is_tempfile = FALSE;
- cf.rfcode = NULL;
- cf.dfilter = NULL;
- cf.dfcode = NULL;
+ cfile.plist = NULL;
+ cfile.plist_end = NULL;
+ cfile.wth = NULL;
+ cfile.filename = NULL;
+ cfile.user_saved = FALSE;
+ cfile.is_tempfile = FALSE;
+ cfile.rfcode = NULL;
+ cfile.dfilter = NULL;
+ cfile.dfcode = NULL;
#ifdef HAVE_LIBPCAP
- cf.cfilter = g_strdup("");
+ cfile.cfilter = g_strdup("");
#endif
- cf.iface = NULL;
- cf.save_file = NULL;
- cf.save_file_fd = -1;
- cf.snap = WTAP_MAX_PACKET_SIZE;
- cf.count = 0;
- cf.cinfo.num_cols = prefs->num_cols;
- cf.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols);
- cf.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cf.cinfo.num_cols);
- cf.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cf.cinfo.num_cols);
- cf.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols);
- cf.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cf.cinfo.num_cols);
+ cfile.iface = NULL;
+ cfile.save_file = NULL;
+ cfile.save_file_fd = -1;
+ cfile.snap = WTAP_MAX_PACKET_SIZE;
+ cfile.count = 0;
+ cfile.cinfo.num_cols = prefs->num_cols;
+ cfile.cinfo.col_fmt = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols);
+ cfile.cinfo.fmt_matx = (gboolean **) g_malloc(sizeof(gboolean *) * cfile.cinfo.num_cols);
+ cfile.cinfo.col_width = (gint *) g_malloc(sizeof(gint) * cfile.cinfo.num_cols);
+ cfile.cinfo.col_title = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
+ cfile.cinfo.col_data = (gchar **) g_malloc(sizeof(gchar *) * cfile.cinfo.num_cols);
/* Assemble the compile-time options */
snprintf(comp_info_str, 256,
case 'f':
#ifdef HAVE_LIBPCAP
capture_filter_specified = TRUE;
- cf.cfilter = g_strdup(optarg);
+ cfile.cfilter = g_strdup(optarg);
#else
capture_option_specified = TRUE;
arg_error = TRUE;
break;
case 'i': /* Use interface xxx */
#ifdef HAVE_LIBPCAP
- cf.iface = g_strdup(optarg);
+ cfile.iface = g_strdup(optarg);
#else
capture_option_specified = TRUE;
arg_error = TRUE;
break;
case 's': /* Set the snapshot (capture) length */
#ifdef HAVE_LIBPCAP
- cf.snap = atoi(optarg);
+ cfile.snap = atoi(optarg);
#else
capture_option_specified = TRUE;
arg_error = TRUE;
exit(0);
break;
case 'w': /* Write to capture file xxx */
- cf.save_file = g_strdup(optarg);
+ cfile.save_file = g_strdup(optarg);
break;
case 'V': /* Verbose */
verbose = TRUE;
"tethereal: Capture filters were specified both with \"-f\" and with additional command-line arguments\n");
exit(2);
}
- cf.cfilter = get_args_as_string(argc, argv, optind);
+ cfile.cfilter = get_args_as_string(argc, argv, optind);
#else
capture_option_specified = TRUE;
#endif
print_usage();
/* Build the column format array */
- for (i = 0; i < cf.cinfo.num_cols; i++) {
- cf.cinfo.col_fmt[i] = get_column_format(i);
- cf.cinfo.col_title[i] = g_strdup(get_column_title(i));
- cf.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) *
+ for (i = 0; i < cfile.cinfo.num_cols; i++) {
+ cfile.cinfo.col_fmt[i] = get_column_format(i);
+ cfile.cinfo.col_title[i] = g_strdup(get_column_title(i));
+ cfile.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) *
NUM_COL_FMTS);
- get_column_format_matches(cf.cinfo.fmt_matx[i], cf.cinfo.col_fmt[i]);
- if (cf.cinfo.col_fmt[i] == COL_INFO)
- cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN);
+ get_column_format_matches(cfile.cinfo.fmt_matx[i], cfile.cinfo.col_fmt[i]);
+ if (cfile.cinfo.col_fmt[i] == COL_INFO)
+ cfile.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN);
else
- cf.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ cfile.cinfo.col_data[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
}
- if (cf.snap < 1)
- cf.snap = WTAP_MAX_PACKET_SIZE;
- else if (cf.snap < MIN_PACKET_SIZE)
- cf.snap = MIN_PACKET_SIZE;
+ if (cfile.snap < 1)
+ cfile.snap = WTAP_MAX_PACKET_SIZE;
+ else if (cfile.snap < MIN_PACKET_SIZE)
+ cfile.snap = MIN_PACKET_SIZE;
dissect_init(); /* Init anything that needs initializing */
exit(2);
}
}
- cf.rfcode = rfcode;
+ cfile.rfcode = rfcode;
if (cf_name) {
- err = open_cap_file(cf_name, FALSE, &cf);
+ err = open_cap_file(cf_name, FALSE, &cfile);
if (err != 0) {
dissect_cleanup();
exit(2);
}
- err = load_cap_file(&cf, out_file_type);
+ err = load_cap_file(&cfile, out_file_type);
if (err != 0) {
dissect_cleanup();
exit(2);
do we have support for live captures? */
#ifdef HAVE_LIBPCAP
/* Yes; did the user specify an interface to use? */
- if (cf.iface == NULL) {
+ if (cfile.iface == NULL) {
/* No - pick the first one from the list of interfaces. */
if_list = get_interface_list(&err, err_str);
if (if_list == NULL) {
}
exit(2);
}
- cf.iface = g_strdup(if_list->data); /* first interface */
+ cfile.iface = g_strdup(if_list->data); /* first interface */
free_interface_list(if_list);
}
capture(packet_count, out_file_type);
ld.pdh = NULL;
/* Open the network interface to capture from it. */
- ld.pch = pcap_open_live(cf.iface, cf.snap, 1, 1000, err_str);
+ ld.pch = pcap_open_live(cfile.iface, cfile.snap, 1, 1000, err_str);
if (ld.pch == NULL) {
/* Well, we couldn't start the capture.
goto error;
}
- if (cf.cfilter) {
+ if (cfile.cfilter) {
/* A capture filter was specified; set it up. */
- if (pcap_lookupnet (cf.iface, &netnum, &netmask, err_str) < 0) {
+ if (pcap_lookupnet (cfile.iface, &netnum, &netmask, err_str) < 0) {
snprintf(errmsg, sizeof errmsg,
"Can't use filter: Couldn't obtain netmask info (%s).", err_str);
goto error;
}
- if (pcap_compile(ld.pch, &cf.fcode, cf.cfilter, 1, netmask) < 0) {
+ if (pcap_compile(ld.pch, &cfile.fcode, cfile.cfilter, 1, netmask) < 0) {
snprintf(errmsg, sizeof errmsg, "Unable to parse filter string (%s).",
pcap_geterr(ld.pch));
goto error;
}
- if (pcap_setfilter(ld.pch, &cf.fcode) < 0) {
+ if (pcap_setfilter(ld.pch, &cfile.fcode) < 0) {
snprintf(errmsg, sizeof errmsg, "Can't install filter (%s).",
pcap_geterr(ld.pch));
goto error;
}
ld.linktype = wtap_pcap_encap_to_wtap_encap(pcap_datalink(ld.pch));
- if (cf.save_file != NULL) {
+ if (cfile.save_file != NULL) {
/* Set up to write to the capture file. */
if (ld.linktype == WTAP_ENCAP_UNKNOWN) {
strcpy(errmsg, "The network you're capturing from is of a type"
" that Tethereal doesn't support.");
goto error;
}
- ld.pdh = wtap_dump_open(cf.save_file, out_file_type,
+ ld.pdh = wtap_dump_open(cfile.save_file, out_file_type,
ld.linktype, pcap_snapshot(ld.pch), &err);
if (ld.pdh == NULL) {
if (err < 0) {
sprintf(errmsg, "The file to which the capture would be"
" written (\"%s\") could not be opened: Error %d.",
- cf.save_file, err);
+ cfile.save_file, err);
} else {
sprintf(errmsg, "The file to which the capture would be"
" written (\"%s\") could not be opened: %s.",
- cf.save_file, strerror(err));
+ cfile.save_file, strerror(err));
}
break;
}
#endif
/* Let the user know what interface was chosen. */
- printf("Capturing on %s\n", cf.iface);
+ printf("Capturing on %s\n", cfile.iface);
inpkts = pcap_loop(ld.pch, packet_count, capture_pcap_cb, (u_char *) &ld);
pcap_close(ld.pch);
return TRUE;
error:
- g_free(cf.save_file);
- cf.save_file = NULL;
+ g_free(cfile.save_file);
+ cfile.save_file = NULL;
fprintf(stderr, "tethereal: %s\n", errmsg);
if (ld.pch != NULL)
pcap_close(ld.pch);
whdr.len = phdr->len;
whdr.pkt_encap = ld->linktype;
- args.cf = &cf;
+ args.cf = &cfile;
args.pdh = ld->pdh;
if (ld->pdh) {
wtap_dispatch_cb_write((u_char *)&args, &whdr, 0, NULL, pd);
- cf.count++;
- printf("\r%u ", cf.count);
+ cfile.count++;
+ printf("\r%u ", cfile.count);
fflush(stdout);
} else {
wtap_dispatch_cb_print((u_char *)&args, &whdr, 0, NULL, pd);