{
cf_reset_state(cf);
+ cleanup_dissection();
+
cf_callback_invoke(cf_cb_file_closed, cf);
}
cf_status_t cf_status;
cf_status = cf_open(cf, fname, is_tempfile, err);
- if (cf_status == CF_OK) {
- cf_callback_invoke(cf_cb_live_capture_started, cf);
- }
return cf_status;
}
int fd;
struct stat cf_stat;
+
+ if(cf->wth == NULL) {
+ cf_close(cf);
+ return CF_READ_ERROR;
+ }
+
packet_list_freeze();
while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
WTAP_ENCAP_PER_PACKET). */
cf->lnk_t = wtap_file_encap(cf->wth);
- cf_callback_invoke(cf_cb_live_capture_finished, cf);
-
if (*err != 0) {
/* We got an error reading the capture file.
XXX - pop up a dialog box? */
}
#endif /* HAVE_LIBPCAP */
+
+/* update the f_len field */
+cf_update_f_len(capture_file *cf) {
+ int fd;
+ struct stat cf_stat;
+
+
+ fd = wtap_fd(cf->wth);
+ if (fstat(fd, &cf_stat) >= 0) {
+ cf->f_len = cf_stat.st_size;
+ }
+}
+
+
const gchar *
cf_get_display_name(capture_file *cf)
{
return cf->is_tempfile;
}
+void cf_set_tempfile(capture_file *cf, gboolean is_tempfile)
+{
+ cf->is_tempfile = is_tempfile;
+}
+
+
/* XXX - use a macro instead? */
void cf_set_drops_known(capture_file *cf, gboolean drops_known)
{
cf->rfcode = rfcode;
}
-typedef struct {
- color_filter_t *colorf;
- epan_dissect_t *edt;
-} apply_color_filter_args;
-
-/*
- * If no color filter has been applied, apply this one.
- * (The "if no color filter has been applied" is to handle the case where
- * more than one color filter matches the packet.)
- */
-static void
-apply_color_filter(gpointer filter_arg, gpointer argp)
-{
- color_filter_t *colorf = filter_arg;
- apply_color_filter_args *args = argp;
-
- if (colorf->c_colorfilter != NULL && args->colorf == NULL) {
- if (dfilter_apply_edt(colorf->c_colorfilter, args->edt))
- args->colorf = colorf;
- }
-}
-
static int
add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
union wtap_pseudo_header *pseudo_header, const guchar *buf,
gboolean refilter)
{
- apply_color_filter_args args;
gint row;
gboolean create_proto_tree = FALSE;
epan_dissect_t *edt;
/* just add some value here until we know if it is being displayed or not */
fdata->cum_bytes = cum_bytes + fdata->pkt_len;
- /* We don't yet have a color filter to apply. */
- args.colorf = NULL;
-
/* If we don't have the time stamp of the first packet in the
capture, it's because this is the first packet. Save the time
stamp of this packet as the time stamp of the first packet. */
allocate a protocol tree root node, so that we'll construct
a protocol tree against which a filter expression can be
evaluated. */
- if ((cf->dfcode != NULL && refilter) || filter_list != NULL
+ if ((cf->dfcode != NULL && refilter) || color_filters_used()
|| num_tap_filters != 0)
create_proto_tree = TRUE;
if (cf->dfcode != NULL && refilter) {
epan_dissect_prime_dfilter(edt, cf->dfcode);
}
- if (filter_list) {
- filter_list_prime_edt(edt);
+ if (color_filters_used()) {
+ color_filters_prime_edt(edt);
}
tap_queue_init(edt);
epan_dissect_run(edt, pseudo_header, buf, fdata, &cf->cinfo);
If we don't have a display filter, set "passed_dfilter" to 1. */
if (cf->dfcode != NULL) {
if (refilter) {
- if (cf->dfcode != NULL)
- fdata->flags.passed_dfilter = dfilter_apply_edt(cf->dfcode, edt) ? 1 : 0;
- else
- fdata->flags.passed_dfilter = 1;
+ fdata->flags.passed_dfilter = dfilter_apply_edt(cf->dfcode, edt) ? 1 : 0;
}
} else
fdata->flags.passed_dfilter = 1;
- /* If we have color filters, and the frame is to be displayed, apply
- the color filters. */
- if (fdata->flags.passed_dfilter) {
- if (filter_list != NULL) {
- args.edt = edt;
- g_slist_foreach(filter_list, apply_color_filter, &args);
- }
- }
-
-
if( (fdata->flags.passed_dfilter)
|| (edt->pi.fd->flags.ref_time) ){
/* This frame either passed the display filter list or is marked as
row = packet_list_append(cf->cinfo.col_data, fdata);
- /* If the packet matches a color filter,
- * store matching color_filter_t object in frame data. */
- if (filter_list != NULL && (args.colorf != NULL)) {
- /* add the matching colorfilter to the frame data */
- fdata->color_filter = args.colorf;
- /* If packet is marked, use colors from preferences */
- if (fdata->flags.marked) {
- packet_list_set_colors(row, &prefs.gui_marked_fg, &prefs.gui_marked_bg);
- } else /* if (filter_list != NULL && (args.colorf != NULL)) */ {
- packet_list_set_colors(row, &(args.colorf->fg_color),
- &(args.colorf->bg_color));
- }
- } else {
- /* No color filter match */
- fdata->color_filter = NULL;
+ /* colorize packet: if packet is marked, use preferences,
+ otherwise try to apply color filters */
if (fdata->flags.marked) {
+ fdata->color_filter = NULL;
packet_list_set_colors(row, &prefs.gui_marked_fg, &prefs.gui_marked_bg);
+ } else {
+ fdata->color_filter = color_filters_colorize_packet(row, edt);
}
- }
/* Set the time of the previous displayed frame to the time of this
frame. */
int err;
gboolean do_copy;
wtap_dumper *pdh;
- struct stat infile, outfile;
save_callback_args_t callback_args;
cf_callback_invoke(cf_cb_file_safe_started, (gpointer) fname);
- /*
- * Check that the from file is not the same as to file
- * We do it here so we catch all cases ...
- * Unfortunately, the file requester gives us an absolute file
- * name and the read file name may be relative (if supplied on
- * the command line). From Joerg Mayer.
- *
- * This is a bit tricky on win32. The st_ino field is documented as:
- * "The inode, and therefore st_ino, has no meaning in the FAT, ..."
- * but it *is* set to zero if stat() returns without an error,
- * so this is working, but maybe not quite the way expected. ULFL
- */
- infile.st_ino = 1; /* These prevent us from getting equality */
- outfile.st_ino = 2; /* If one or other of the files is not accessible */
- stat(cf->filename, &infile);
- stat(fname, &outfile);
- if (infile.st_ino == outfile.st_ino) {
+ /* don't write over an existing file. */
+ /* this should've been already checked by our caller, just to be sure... */
+ if (file_exists(fname)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%sCapture file: \"%s\" already exists!%s\n\n"
"Please choose a different filename.",