forked from osmocom/wireshark
remove #include "globals.h" and access to global cfile, use access functions and capture_opts instead
svn path=/trunk/; revision=13283
This commit is contained in:
parent
b1d285c375
commit
9f171b0485
23
capture.c
23
capture.c
|
@ -61,7 +61,6 @@
|
||||||
#include "alert_box.h"
|
#include "alert_box.h"
|
||||||
#include "simple_dialog.h"
|
#include "simple_dialog.h"
|
||||||
#include <epan/prefs.h>
|
#include <epan/prefs.h>
|
||||||
#include "globals.h"
|
|
||||||
#include "conditions.h"
|
#include "conditions.h"
|
||||||
#include "ringbuffer.h"
|
#include "ringbuffer.h"
|
||||||
|
|
||||||
|
@ -128,10 +127,10 @@ capture_open_output(capture_options *capture_opts, const char *save_file, gboole
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close the old file */
|
/* close the old file */
|
||||||
cf_close(&cfile);
|
cf_close(capture_opts->cf);
|
||||||
g_assert(capture_opts->save_file == NULL);
|
g_assert(capture_opts->save_file == NULL);
|
||||||
capture_opts->save_file = capfile_name;
|
capture_opts->save_file = capfile_name;
|
||||||
/* cfile.save_file is "g_free"ed later, which is equivalent to
|
/* capture_opts.save_file is "g_free"ed later, which is equivalent to
|
||||||
"g_free(capfile_name)". */
|
"g_free(capfile_name)". */
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -154,7 +153,7 @@ do_capture(capture_options *capture_opts, const char *save_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
title = g_strdup_printf("%s: Capturing - Ethereal",
|
title = g_strdup_printf("%s: Capturing - Ethereal",
|
||||||
get_interface_descriptive_name(cfile.iface));
|
get_interface_descriptive_name(cf_get_iface(capture_opts->cf)));
|
||||||
if (capture_opts->sync_mode) {
|
if (capture_opts->sync_mode) {
|
||||||
/* sync mode: do the capture in a child process */
|
/* sync mode: do the capture in a child process */
|
||||||
ret = sync_pipe_do_capture(capture_opts, is_tempfile);
|
ret = sync_pipe_do_capture(capture_opts, is_tempfile);
|
||||||
|
@ -199,7 +198,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* Capture succeeded; attempt to read in the capture file. */
|
/* Capture succeeded; attempt to read in the capture file. */
|
||||||
if ((err = cf_open(capture_opts->save_file, is_tempfile, &cfile)) != 0) {
|
if ((err = cf_open(capture_opts->save_file, is_tempfile, capture_opts->cf)) != 0) {
|
||||||
/* We're not doing a capture any more, so we don't have a save
|
/* We're not doing a capture any more, so we don't have a save
|
||||||
file. */
|
file. */
|
||||||
if (capture_opts->multi_files_on) {
|
if (capture_opts->multi_files_on) {
|
||||||
|
@ -212,7 +211,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the read filter to NULL. */
|
/* Set the read filter to NULL. */
|
||||||
cfile.rfcode = NULL;
|
cf_set_rfcode(capture_opts->cf, NULL);
|
||||||
|
|
||||||
/* Get the packet-drop statistics.
|
/* Get the packet-drop statistics.
|
||||||
|
|
||||||
|
@ -233,7 +232,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
|
||||||
thus not have to set them here - "cf_read()" will get them from
|
thus not have to set them here - "cf_read()" will get them from
|
||||||
the file and use them. */
|
the file and use them. */
|
||||||
if (stats_known) {
|
if (stats_known) {
|
||||||
cfile.drops_known = TRUE;
|
cf_set_drops_known(capture_opts->cf, TRUE);
|
||||||
|
|
||||||
/* XXX - on some systems, libpcap doesn't bother filling in
|
/* XXX - on some systems, libpcap doesn't bother filling in
|
||||||
"ps_ifdrop" - it doesn't even set it to zero - so we don't
|
"ps_ifdrop" - it doesn't even set it to zero - so we don't
|
||||||
|
@ -243,9 +242,9 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
|
||||||
several statistics - perhaps including various interface
|
several statistics - perhaps including various interface
|
||||||
error statistics - and would tell us which of them it
|
error statistics - and would tell us which of them it
|
||||||
supplies, allowing us to display only the ones it does. */
|
supplies, allowing us to display only the ones it does. */
|
||||||
cfile.drops = stats.ps_drop;
|
cf_set_drops(capture_opts->cf, stats.ps_drop);
|
||||||
}
|
}
|
||||||
switch (cf_read(&cfile)) {
|
switch (cf_read(capture_opts->cf)) {
|
||||||
|
|
||||||
case READ_SUCCESS:
|
case READ_SUCCESS:
|
||||||
case READ_ERROR:
|
case READ_ERROR:
|
||||||
|
@ -271,13 +270,13 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
|
||||||
capture_opts->save_file = NULL;
|
capture_opts->save_file = NULL;
|
||||||
|
|
||||||
/* if we didn't captured even a single packet, close the file again */
|
/* if we didn't captured even a single packet, close the file again */
|
||||||
if(cfile.count == 0) {
|
if(cf_packet_count(capture_opts->cf) == 0) {
|
||||||
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
|
||||||
"%sNo packets captured!%s\n\n"
|
"%sNo packets captured!%s\n\n"
|
||||||
"As no data was captured, closing the %scapture file!",
|
"As no data was captured, closing the %scapture file!",
|
||||||
simple_dialog_primary_start(), simple_dialog_primary_end(),
|
simple_dialog_primary_start(), simple_dialog_primary_end(),
|
||||||
(cfile.is_tempfile) ? "temporary " : "");
|
(cf_is_tempfile(capture_opts->cf)) ? "temporary " : "");
|
||||||
cf_close(&cfile);
|
cf_close(capture_opts->cf);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
14
file.c
14
file.c
|
@ -714,6 +714,14 @@ cf_packet_count(capture_file *cf)
|
||||||
return cf->count;
|
return cf->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* XXX - use a macro instead? */
|
||||||
|
/* XXX - move iface this to capture_opts? */
|
||||||
|
gchar *
|
||||||
|
cf_get_iface(capture_file *cf)
|
||||||
|
{
|
||||||
|
return cf->iface;
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX - use a macro instead? */
|
/* XXX - use a macro instead? */
|
||||||
gboolean
|
gboolean
|
||||||
cf_is_tempfile(capture_file *cf)
|
cf_is_tempfile(capture_file *cf)
|
||||||
|
@ -733,6 +741,12 @@ void cf_set_drops(capture_file *cf, guint32 drops)
|
||||||
cf->drops = drops;
|
cf->drops = drops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode)
|
||||||
|
{
|
||||||
|
cf->rfcode = rfcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
color_filter_t *colorf;
|
color_filter_t *colorf;
|
||||||
epan_dissect_t *edt;
|
epan_dissect_t *edt;
|
||||||
|
|
2
file.h
2
file.h
|
@ -56,6 +56,8 @@ int cf_packet_count(capture_file *cf);
|
||||||
gboolean cf_is_tempfile(capture_file *cf);
|
gboolean cf_is_tempfile(capture_file *cf);
|
||||||
void cf_set_drops_known(capture_file *cf, gboolean drops_known);
|
void cf_set_drops_known(capture_file *cf, gboolean drops_known);
|
||||||
void cf_set_drops(capture_file *cf, guint32 drops);
|
void cf_set_drops(capture_file *cf, guint32 drops);
|
||||||
|
gchar *cf_get_iface(capture_file *cf);
|
||||||
|
void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
|
cf_merge_files(const char *out_filename, int out_fd, int in_file_count,
|
||||||
|
|
Loading…
Reference in New Issue