Use an enum for compression types in various interfaces.

This:

1) means that we don't have to flag the compression argument with a
comment to indicate what it means (FALSE doesn't obviously say "not
compressed", WTAP_UNCOMPRESSED does);

2) leaves space in the interfaces in question for additional compression
types.

(No, this is not part 1 of an implementation of additional compression
types, it's just an API cleanup.  Implementing additional compression
types involves significant work in libwiretap, as well as UI changes to
replace "compress the file" checkboxes with something to indicate *how*
to compress the file, or to always use some other form of compression).

Change-Id: I1d23dc720be10158e6b34f97baa247ba8a537abf
Reviewed-on: https://code.wireshark.org/review/30660
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-11-15 20:06:36 -08:00
parent e12753d5f6
commit a1372f6d01
33 changed files with 276 additions and 248 deletions

View File

@ -177,41 +177,41 @@ typedef enum {
} order_t; } order_t;
typedef struct _capture_info { typedef struct _capture_info {
const char *filename; const char *filename;
guint16 file_type; guint16 file_type;
gboolean iscompressed; wtap_compression_type compression_type;
int file_encap; int file_encap;
int file_tsprec; int file_tsprec;
gint64 filesize; gint64 filesize;
wtap_block_t shb; wtap_block_t shb;
guint64 packet_bytes; guint64 packet_bytes;
gboolean times_known; gboolean times_known;
nstime_t start_time; nstime_t start_time;
int start_time_tsprec; int start_time_tsprec;
nstime_t stop_time; nstime_t stop_time;
int stop_time_tsprec; int stop_time_tsprec;
guint32 packet_count; guint32 packet_count;
gboolean snap_set; /* If set in capture file header */ gboolean snap_set; /* If set in capture file header */
guint32 snaplen; /* value from the capture file header */ guint32 snaplen; /* value from the capture file header */
guint32 snaplen_min_inferred; /* If caplen < len for 1 or more rcds */ guint32 snaplen_min_inferred; /* If caplen < len for 1 or more rcds */
guint32 snaplen_max_inferred; /* ... */ guint32 snaplen_max_inferred; /* ... */
gboolean drops_known; gboolean drops_known;
guint32 drop_count; guint32 drop_count;
nstime_t duration; nstime_t duration;
int duration_tsprec; int duration_tsprec;
double packet_rate; double packet_rate;
double packet_size; double packet_size;
double data_rate; /* in bytes */ double data_rate; /* in bytes/s */
gboolean know_order; gboolean know_order;
order_t order; order_t order;
int *encap_counts; /* array of per_packet encap counts; array has one entry per wtap_encap type */ int *encap_counts; /* array of per_packet encap counts; array has one entry per wtap_encap type */
guint num_interfaces; /* number of IDBs, and thus size of interface_packet_counts array */ guint num_interfaces; /* number of IDBs, and thus size of interface_packet_counts array */
GArray *interface_packet_counts; /* array of per_packet interface_id counts; one entry per file IDB */ GArray *interface_packet_counts; /* array of per_packet interface_id counts; one entry per file IDB */
guint32 pkt_interface_id_unknown; /* counts if packet interface_id didn't match a known one */ guint32 pkt_interface_id_unknown; /* counts if packet interface_id didn't match a known one */
GArray *idb_info_strings; /* array of IDB info strings */ GArray *idb_info_strings; /* array of IDB info strings */
} capture_info; } capture_info;
static char *decimal_point; static char *decimal_point;
@ -585,7 +585,7 @@ print_stats(const gchar *filename, capture_info *cf_info)
if (filename) printf ("File name: %s\n", filename); if (filename) printf ("File name: %s\n", filename);
if (cap_file_type) printf ("File type: %s%s\n", if (cap_file_type) printf ("File type: %s%s\n",
file_type_string, file_type_string,
cf_info->iscompressed ? " (gzip compressed)" : ""); cf_info->compression_type == WTAP_GZIP_COMPRESSED ? " (gzip compressed)" : "");
if (cap_file_encap) { if (cap_file_encap) {
printf ("File encapsulation: %s\n", file_encap_string); printf ("File encapsulation: %s\n", file_encap_string);
@ -1241,7 +1241,7 @@ process_cap_file(wtap *wth, const char *filename)
/* File Type */ /* File Type */
cf_info.file_type = wtap_file_type_subtype(wth); cf_info.file_type = wtap_file_type_subtype(wth);
cf_info.iscompressed = wtap_iscompressed(wth); cf_info.compression_type = wtap_get_compression_type(wth);
/* File Encapsulation */ /* File Encapsulation */
cf_info.file_encap = wtap_file_encap(wth); cf_info.file_encap = wtap_file_encap(wth);

108
cfile.h
View File

@ -63,67 +63,67 @@ struct packet_provider_data {
}; };
typedef struct _capture_file { typedef struct _capture_file {
epan_t *epan; epan_t *epan;
file_state state; /* Current state of capture file */ file_state state; /* Current state of capture file */
gchar *filename; /* Name of capture file */ gchar *filename; /* Name of capture file */
gchar *source; /* Temp file source, e.g. "Pipe from elsewhere" */ gchar *source; /* Temp file source, e.g. "Pipe from elsewhere" */
gboolean is_tempfile; /* Is capture file a temporary file? */ gboolean is_tempfile; /* Is capture file a temporary file? */
gboolean unsaved_changes; /* Does the capture file have changes that have not been saved? */ gboolean unsaved_changes; /* Does the capture file have changes that have not been saved? */
gboolean stop_flag; /* Stop current processing (loading, searching, etc.) */ gboolean stop_flag; /* Stop current processing (loading, searching, etc.) */
gint64 f_datalen; /* Size of capture file data (uncompressed) */ gint64 f_datalen; /* Size of capture file data (uncompressed) */
guint16 cd_t; /* File type of capture file */ guint16 cd_t; /* File type of capture file */
unsigned int open_type; /* open_routine index+1 used, if selected, or WTAP_TYPE_AUTO */ unsigned int open_type; /* open_routine index+1 used, if selected, or WTAP_TYPE_AUTO */
gboolean iscompressed; /* TRUE if the file is compressed */ wtap_compression_type compression_type; /* Compression type of the file, or uncompressed */
int lnk_t; /* File link-layer type; could be WTAP_ENCAP_PER_PACKET */ int lnk_t; /* File link-layer type; could be WTAP_ENCAP_PER_PACKET */
GArray *linktypes; /* Array of packet link-layer types */ GArray *linktypes; /* Array of packet link-layer types */
guint32 count; /* Total number of frames */ guint32 count; /* Total number of frames */
guint64 packet_comment_count; /* Number of comments in frames (could be >1 per frame... */ guint64 packet_comment_count; /* Number of comments in frames (could be >1 per frame... */
guint32 displayed_count; /* Number of displayed frames */ guint32 displayed_count; /* Number of displayed frames */
guint32 marked_count; /* Number of marked frames */ guint32 marked_count; /* Number of marked frames */
guint32 ignored_count; /* Number of ignored frames */ guint32 ignored_count; /* Number of ignored frames */
guint32 ref_time_count; /* Number of time referenced frames */ guint32 ref_time_count; /* Number of time referenced frames */
gboolean drops_known; /* TRUE if we know how many packets were dropped */ gboolean drops_known; /* TRUE if we know how many packets were dropped */
guint32 drops; /* Dropped packets */ guint32 drops; /* Dropped packets */
nstime_t elapsed_time; /* Elapsed time */ nstime_t elapsed_time; /* Elapsed time */
int snap; /* Maximum captured packet length; 0 if unknown */ int snap; /* Maximum captured packet length; 0 if unknown */
dfilter_t *rfcode; /* Compiled read filter program */ dfilter_t *rfcode; /* Compiled read filter program */
dfilter_t *dfcode; /* Compiled display filter program */ dfilter_t *dfcode; /* Compiled display filter program */
gchar *dfilter; /* Display filter string */ gchar *dfilter; /* Display filter string */
gboolean redissecting; /* TRUE if currently redissecting (cf_redissect_packets) */ gboolean redissecting; /* TRUE if currently redissecting (cf_redissect_packets) */
gboolean read_lock; /* TRUE if currently processing a file (cf_read) */ gboolean read_lock; /* TRUE if currently processing a file (cf_read) */
rescan_type redissection_queued; /* Queued redissection type. */ rescan_type redissection_queued; /* Queued redissection type. */
/* search */ /* search */
gchar *sfilter; /* Filter, hex value, or string being searched */ gchar *sfilter; /* Filter, hex value, or string being searched */
gboolean hex; /* TRUE if "Hex value" search was last selected */ gboolean hex; /* TRUE if "Hex value" search was last selected */
gboolean string; /* TRUE if "String" search was last selected */ gboolean string; /* TRUE if "String" search was last selected */
gboolean summary_data; /* TRUE if "String" search in "Packet list" (Info column) was last selected */ gboolean summary_data; /* TRUE if "String" search in "Packet list" (Info column) was last selected */
gboolean decode_data; /* TRUE if "String" search in "Packet details" was last selected */ gboolean decode_data; /* TRUE if "String" search in "Packet details" was last selected */
gboolean packet_data; /* TRUE if "String" search in "Packet data" was last selected */ gboolean packet_data; /* TRUE if "String" search in "Packet data" was last selected */
guint32 search_pos; /* Byte position of last byte found in a hex search */ guint32 search_pos; /* Byte position of last byte found in a hex search */
guint32 search_len; /* Length of bytes matching the search */ guint32 search_len; /* Length of bytes matching the search */
gboolean case_type; /* TRUE if case-insensitive text search */ gboolean case_type; /* TRUE if case-insensitive text search */
GRegex *regex; /* Set if regular expression search */ GRegex *regex; /* Set if regular expression search */
search_charset_t scs_type; /* Character set for text search */ search_charset_t scs_type; /* Character set for text search */
search_direction dir; /* Direction in which to do searches */ search_direction dir; /* Direction in which to do searches */
gboolean search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */ gboolean search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
/* packet data */ /* packet data */
wtap_rec rec; /* Record header */ wtap_rec rec; /* Record header */
Buffer buf; /* Record data */ Buffer buf; /* Record data */
/* packet provider */ /* packet provider */
struct packet_provider_data provider; struct packet_provider_data provider;
/* frames */ /* frames */
guint32 first_displayed; /* Frame number of first frame displayed */ guint32 first_displayed; /* Frame number of first frame displayed */
guint32 last_displayed; /* Frame number of last frame displayed */ guint32 last_displayed; /* Frame number of last frame displayed */
column_info cinfo; /* Column formatting information */ column_info cinfo; /* Column formatting information */
frame_data *current_frame; /* Frame data for current frame */ frame_data *current_frame; /* Frame data for current frame */
gint current_row; /* Row number for current frame */ gint current_row; /* Row number for current frame */
epan_dissect_t *edt; /* Protocol dissection for currently selected packet */ epan_dissect_t *edt; /* Protocol dissection for currently selected packet */
field_info *finfo_selected; /* Field info for currently selected field */ field_info *finfo_selected; /* Field info for currently selected field */
gpointer window; /* Top-level window associated with file */ gpointer window; /* Top-level window associated with file */
gulong computed_elapsed; /* Elapsed time to load the file (in msec). */ gulong computed_elapsed; /* Elapsed time to load the file (in msec). */
guint32 cum_bytes; guint32 cum_bytes;
} capture_file; } capture_file;
extern void cap_file_init(capture_file *cf); extern void cap_file_init(capture_file *cf);

View File

@ -98,6 +98,7 @@ libwiretap.so.0 libwiretap0 #MINVER#
wtap_get_all_file_extensions_list@Base 2.6.2 wtap_get_all_file_extensions_list@Base 2.6.2
wtap_get_buf_ptr@Base 2.5.1 wtap_get_buf_ptr@Base 2.5.1
wtap_get_bytes_dumped@Base 1.9.1 wtap_get_bytes_dumped@Base 1.9.1
wtap_get_compression_type@Base 2.9.0
wtap_get_debug_if_descr@Base 1.99.9 wtap_get_debug_if_descr@Base 1.99.9
wtap_get_file_extension_type_extensions@Base 1.12.0~rc1 wtap_get_file_extension_type_extensions@Base 1.12.0~rc1
wtap_get_file_extension_type_name@Base 1.12.0~rc1 wtap_get_file_extension_type_name@Base 1.12.0~rc1
@ -110,7 +111,6 @@ libwiretap.so.0 libwiretap0 #MINVER#
wtap_has_open_info@Base 1.12.0~rc1 wtap_has_open_info@Base 1.12.0~rc1
wtap_init@Base 2.3.0 wtap_init@Base 2.3.0
wtap_cleanup@Base 2.3.0 wtap_cleanup@Base 2.3.0
wtap_iscompressed@Base 1.9.1
wtap_open_offline@Base 1.9.1 wtap_open_offline@Base 1.9.1
wtap_opttype_register_custom_block_type@Base 2.1.2 wtap_opttype_register_custom_block_type@Base 2.1.2
wtap_opttypes_initialize@Base 2.1.2 wtap_opttypes_initialize@Base 2.1.2

View File

@ -942,12 +942,10 @@ editcap_dump_open(const char *filename, const wtap_dump_params *params,
if (strcmp(filename, "-") == 0) { if (strcmp(filename, "-") == 0) {
/* Write to the standard output. */ /* Write to the standard output. */
pdh = wtap_dump_open_stdout(out_file_type_subtype, pdh = wtap_dump_open_stdout(out_file_type_subtype, WTAP_UNCOMPRESSED,
FALSE /* compressed */,
params, write_err); params, write_err);
} else { } else {
pdh = wtap_dump_open(filename, out_file_type_subtype, pdh = wtap_dump_open(filename, out_file_type_subtype, WTAP_UNCOMPRESSED,
FALSE /* compressed */,
params, write_err); params, write_err);
} }
return pdh; return pdh;

View File

@ -1168,7 +1168,7 @@ snort_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
params.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD; params.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
current_session.pdh = wtap_dump_fdopen(current_session.in, current_session.pdh = wtap_dump_fdopen(current_session.in,
WTAP_FILE_TYPE_SUBTYPE_PCAP, WTAP_FILE_TYPE_SUBTYPE_PCAP,
FALSE, /* compressed */ WTAP_UNCOMPRESSED,
&params, &params,
&open_err); &open_err);
if (!current_session.pdh) { if (!current_session.pdh) {

View File

@ -337,8 +337,8 @@ WSLUA_METAMETHOD CaptureInfoConst__tostring(lua_State* L) {
lua_pushstring(L,"CaptureInfoConst pointer is NULL!"); lua_pushstring(L,"CaptureInfoConst pointer is NULL!");
} else { } else {
wtap_dumper *wdh = fi->wdh; wtap_dumper *wdh = fi->wdh;
lua_pushfstring(L, "CaptureInfoConst: file_type_subtype=%d, snaplen=%d, encap=%d, compressed=%d", lua_pushfstring(L, "CaptureInfoConst: file_type_subtype=%d, snaplen=%d, encap=%d, compression_type=%d",
wdh->file_type_subtype, wdh->snaplen, wdh->encap, wdh->compressed); wdh->file_type_subtype, wdh->snaplen, wdh->encap, wdh->compression_type);
} }
WSLUA_RETURN(1); /* String of debug information. */ WSLUA_RETURN(1); /* String of debug information. */

View File

@ -208,7 +208,7 @@ WSLUA_CONSTRUCTOR Dumper_new(lua_State* L) {
wtap_dump_params params = WTAP_DUMP_PARAMS_INIT; wtap_dump_params params = WTAP_DUMP_PARAMS_INIT;
params.encap = encap; params.encap = encap;
d = wtap_dump_open(filename, filetype, FALSE, &params, &err); d = wtap_dump_open(filename, filetype, WTAP_UNCOMPRESSED, &params, &err);
if (! d ) { if (! d ) {
/* WSLUA_ERROR("Error while opening file for writing"); */ /* WSLUA_ERROR("Error while opening file for writing"); */
@ -372,7 +372,7 @@ WSLUA_METHOD Dumper_new_for_current(lua_State* L) {
encap = lua_pinfo->rec->rec_header.packet_header.pkt_encap; encap = lua_pinfo->rec->rec_header.packet_header.pkt_encap;
params.encap = encap; params.encap = encap;
d = wtap_dump_open(filename, filetype, FALSE, &params, &err); d = wtap_dump_open(filename, filetype, WTAP_UNCOMPRESSED, &params, &err);
if (! d ) { if (! d ) {
switch (err) { switch (err) {

View File

@ -477,7 +477,7 @@ static int File_get_compressed(lua_State* L) {
if (file_is_reader(f)) { if (file_is_reader(f)) {
lua_pushboolean(L, file_iscompressed(f->file)); lua_pushboolean(L, file_iscompressed(f->file));
} else { } else {
lua_pushboolean(L, f->wdh->compressed); lua_pushboolean(L, f->wdh->compression_type != WTAP_UNCOMPRESSED);
} }
return 1; return 1;
} }

View File

@ -450,7 +450,7 @@ static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) {
params.encap = encap; params.encap = encap;
params.snaplen = PACKET_LENGTH; params.snaplen = PACKET_LENGTH;
extcap_dumper.dumper.wtap = wtap_dump_open(fifo, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC, FALSE, &params, &err); extcap_dumper.dumper.wtap = wtap_dump_open(fifo, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC, WTAP_UNCOMPRESSED, &params, &err);
if (!extcap_dumper.dumper.wtap) { if (!extcap_dumper.dumper.wtap) {
cfile_dump_open_failure_message("androiddump", fifo, err, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC); cfile_dump_open_failure_message("androiddump", fifo, err, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC);
exit(EXIT_CODE_CANNOT_SAVE_WIRETAP_DUMP); exit(EXIT_CODE_CANNOT_SAVE_WIRETAP_DUMP);

26
file.c
View File

@ -547,9 +547,9 @@ cf_read(capture_file *cf, gboolean reloading)
else else
cf_callback_invoke(cf_cb_file_read_started, cf); cf_callback_invoke(cf_cb_file_read_started, cf);
/* Record whether the file is compressed. /* Record the file's compression type.
XXX - do we know this at open time? */ XXX - do we know this at open time? */
cf->iscompressed = wtap_iscompressed(cf->provider.wth); cf->compression_type = wtap_get_compression_type(cf->provider.wth);
/* The packet list window will be empty until the file is completly loaded */ /* The packet list window will be empty until the file is completly loaded */
packet_list_freeze(); packet_list_freeze();
@ -4228,9 +4228,9 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
cf_callback_invoke(cf_cb_file_rescan_started, cf); cf_callback_invoke(cf_cb_file_rescan_started, cf);
/* Record whether the file is compressed. /* Record the file's compression type.
XXX - do we know this at open time? */ XXX - do we know this at open time? */
cf->iscompressed = wtap_iscompressed(cf->provider.wth); cf->compression_type = wtap_get_compression_type(cf->provider.wth);
/* Find the size of the file. */ /* Find the size of the file. */
size = wtap_file_size(cf->provider.wth, NULL); size = wtap_file_size(cf->provider.wth, NULL);
@ -4333,8 +4333,8 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
cf_write_status_t cf_write_status_t
cf_save_records(capture_file *cf, const char *fname, guint save_format, cf_save_records(capture_file *cf, const char *fname, guint save_format,
gboolean compressed, gboolean discard_comments, wtap_compression_type compression_type,
gboolean dont_reopen) gboolean discard_comments, gboolean dont_reopen)
{ {
gchar *err_info; gchar *err_info;
gchar *fname_new = NULL; gchar *fname_new = NULL;
@ -4364,7 +4364,7 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
addr_lists = get_addrinfo_list(); addr_lists = get_addrinfo_list();
if (save_format == cf->cd_t && compressed == cf->iscompressed if (save_format == cf->cd_t && compression_type == cf->compression_type
&& !discard_comments && !cf->unsaved_changes && !discard_comments && !cf->unsaved_changes
&& (wtap_addrinfo_list_empty(addr_lists) || !wtap_dump_has_name_resolution(save_format))) { && (wtap_addrinfo_list_empty(addr_lists) || !wtap_dump_has_name_resolution(save_format))) {
/* We're saving in the format it's already in, and we're not discarding /* We're saving in the format it's already in, and we're not discarding
@ -4470,9 +4470,10 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
we *HAVE* to do that, otherwise we're overwriting the file we *HAVE* to do that, otherwise we're overwriting the file
from which we're reading the packets that we're writing!) */ from which we're reading the packets that we're writing!) */
fname_new = g_strdup_printf("%s~", fname); fname_new = g_strdup_printf("%s~", fname);
pdh = wtap_dump_open(fname_new, save_format, compressed, &params, &err); pdh = wtap_dump_open(fname_new, save_format, compression_type, &params,
&err);
} else { } else {
pdh = wtap_dump_open(fname, save_format, compressed, &params, &err); pdh = wtap_dump_open(fname, save_format, compression_type, &params, &err);
} }
/* XXX idb_inf is documented to be used until wtap_dump_close. */ /* XXX idb_inf is documented to be used until wtap_dump_close. */
g_free(params.idb_inf); g_free(params.idb_inf);
@ -4691,7 +4692,7 @@ fail:
cf_write_status_t cf_write_status_t
cf_export_specified_packets(capture_file *cf, const char *fname, cf_export_specified_packets(capture_file *cf, const char *fname,
packet_range_t *range, guint save_format, packet_range_t *range, guint save_format,
gboolean compressed) wtap_compression_type compression_type)
{ {
gchar *fname_new = NULL; gchar *fname_new = NULL;
int err; int err;
@ -4726,9 +4727,10 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
we *HAVE* to do that, otherwise we're overwriting the file we *HAVE* to do that, otherwise we're overwriting the file
from which we're reading the packets that we're writing!) */ from which we're reading the packets that we're writing!) */
fname_new = g_strdup_printf("%s~", fname); fname_new = g_strdup_printf("%s~", fname);
pdh = wtap_dump_open(fname_new, save_format, compressed, &params, &err); pdh = wtap_dump_open(fname_new, save_format, compression_type, &params,
&err);
} else { } else {
pdh = wtap_dump_open(fname, save_format, compressed, &params, &err); pdh = wtap_dump_open(fname, save_format, compression_type, &params, &err);
} }
/* XXX idb_inf is documented to be used until wtap_dump_close. */ /* XXX idb_inf is documented to be used until wtap_dump_close. */
g_free(params.idb_inf); g_free(params.idb_inf);

9
file.h
View File

@ -234,7 +234,7 @@ gboolean cf_has_unsaved_data(capture_file *cf);
* @param cf the capture file to save to * @param cf the capture file to save to
* @param fname the filename to save to * @param fname the filename to save to
* @param save_format the format of the file to save (libpcap, ...) * @param save_format the format of the file to save (libpcap, ...)
* @param compressed whether to gzip compress the file * @param compression_type type of compression to use when writing, if any
* @param discard_comments TRUE if we should discard comments if the save * @param discard_comments TRUE if we should discard comments if the save
* succeeds (because we saved in a format that doesn't support * succeeds (because we saved in a format that doesn't support
* comments) * comments)
@ -243,7 +243,8 @@ gboolean cf_has_unsaved_data(capture_file *cf);
* @return one of cf_write_status_t * @return one of cf_write_status_t
*/ */
cf_write_status_t cf_save_records(capture_file * cf, const char *fname, cf_write_status_t cf_save_records(capture_file * cf, const char *fname,
guint save_format, gboolean compressed, guint save_format,
wtap_compression_type compression_type,
gboolean discard_comments, gboolean discard_comments,
gboolean dont_reopen); gboolean dont_reopen);
@ -258,14 +259,14 @@ cf_write_status_t cf_save_records(capture_file * cf, const char *fname,
* @param fname the filename to write to * @param fname the filename to write to
* @param range the range of packets to write * @param range the range of packets to write
* @param save_format the format of the file to write (libpcap, ...) * @param save_format the format of the file to write (libpcap, ...)
* @param compressed whether to gzip compress the file * @param compression_type type of compression to use when writing, if any
* @return one of cf_write_status_t * @return one of cf_write_status_t
*/ */
cf_write_status_t cf_export_specified_packets(capture_file *cf, cf_write_status_t cf_export_specified_packets(capture_file *cf,
const char *fname, const char *fname,
packet_range_t *range, packet_range_t *range,
guint save_format, guint save_format,
gboolean compressed); wtap_compression_type compression_type);
/** /**
* Get a displayable name of the capture file. * Get a displayable name of the capture file.

View File

@ -667,13 +667,11 @@ int randpkt_example_init(randpkt_example* example, char* produce_filename, int p
if (strcmp(produce_filename, "-") == 0) { if (strcmp(produce_filename, "-") == 0) {
/* Write to the standard output. */ /* Write to the standard output. */
example->dump = wtap_dump_open_stdout(WTAP_FILE_TYPE_SUBTYPE_PCAP, example->dump = wtap_dump_open_stdout(WTAP_FILE_TYPE_SUBTYPE_PCAP,
FALSE /* compressed */, WTAP_UNCOMPRESSED, &params, &err);
&params, &err);
example->filename = "the standard output"; example->filename = "the standard output";
} else { } else {
example->dump = wtap_dump_open(produce_filename, WTAP_FILE_TYPE_SUBTYPE_PCAP, example->dump = wtap_dump_open(produce_filename, WTAP_FILE_TYPE_SUBTYPE_PCAP,
FALSE /* compressed */, WTAP_UNCOMPRESSED, &params, &err);
&params, &err);
example->filename = produce_filename; example->filename = produce_filename;
} }
if (!example->dump) { if (!example->dump) {

View File

@ -287,9 +287,9 @@ main(int argc, char *argv[])
/* Open outfile (same filetype/encap as input file) */ /* Open outfile (same filetype/encap as input file) */
if (strcmp(outfile, "-") == 0) { if (strcmp(outfile, "-") == 0) {
pdh = wtap_dump_open_stdout(wtap_file_type_subtype(wth), FALSE, &params, &err); pdh = wtap_dump_open_stdout(wtap_file_type_subtype(wth), WTAP_UNCOMPRESSED, &params, &err);
} else { } else {
pdh = wtap_dump_open(outfile, wtap_file_type_subtype(wth), FALSE, &params, &err); pdh = wtap_dump_open(outfile, wtap_file_type_subtype(wth), WTAP_UNCOMPRESSED, &params, &err);
} }
g_free(params.idb_inf); g_free(params.idb_inf);
params.idb_inf = NULL; params.idb_inf = NULL;

View File

@ -3115,11 +3115,11 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
tshark_debug("tshark: writing format type %d, to %s", out_file_type, save_file); tshark_debug("tshark: writing format type %d, to %s", out_file_type, save_file);
if (strcmp(save_file, "-") == 0) { if (strcmp(save_file, "-") == 0) {
/* Write to the standard output. */ /* Write to the standard output. */
pdh = wtap_dump_open_stdout(out_file_type, FALSE /* compressed */, pdh = wtap_dump_open_stdout(out_file_type, WTAP_UNCOMPRESSED, &params,
&params, &err); &err);
} else { } else {
pdh = wtap_dump_open(save_file, out_file_type, FALSE /* compressed */, pdh = wtap_dump_open(save_file, out_file_type, WTAP_UNCOMPRESSED, &params,
&params, &err); &err);
} }
g_free(params.idb_inf); g_free(params.idb_inf);

View File

@ -247,8 +247,8 @@ int CaptureFileDialog::selectedFileType() {
return file_type_; return file_type_;
} }
bool CaptureFileDialog::isCompressed() { wtap_compression_type CaptureFileDialog::compressionType() {
return compressed_; return compression_type_;
} }
int CaptureFileDialog::open(QString &file_name, unsigned int &type) { int CaptureFileDialog::open(QString &file_name, unsigned int &type) {
@ -271,7 +271,7 @@ check_savability_t CaptureFileDialog::saveAs(QString &file_name, bool must_suppo
GString *fname = g_string_new(file_name.toUtf8().constData()); GString *fname = g_string_new(file_name.toUtf8().constData());
gboolean wsf_status; gboolean wsf_status;
wsf_status = win32_save_as_file((HWND)parentWidget()->effectiveWinId(), cap_file_, fname, &file_type_, &compressed_, must_support_all_comments); wsf_status = win32_save_as_file((HWND)parentWidget()->effectiveWinId(), cap_file_, fname, &file_type_, &compression_type_, must_support_all_comments);
file_name = fname->str; file_name = fname->str;
g_string_free(fname, TRUE); g_string_free(fname, TRUE);
@ -287,7 +287,7 @@ check_savability_t CaptureFileDialog::exportSelectedPackets(QString &file_name,
GString *fname = g_string_new(file_name.toUtf8().constData()); GString *fname = g_string_new(file_name.toUtf8().constData());
gboolean wespf_status; gboolean wespf_status;
wespf_status = win32_export_specified_packets_file((HWND)parentWidget()->effectiveWinId(), cap_file_, fname, &file_type_, &compressed_, range); wespf_status = win32_export_specified_packets_file((HWND)parentWidget()->effectiveWinId(), cap_file_, fname, &file_type_, &compression_type_, range);
file_name = fname->str; file_name = fname->str;
g_string_free(fname, TRUE); g_string_free(fname, TRUE);
@ -493,9 +493,9 @@ void CaptureFileDialog::fixFilenameExtension()
} }
// Fixup the new suffix based on compression availability. // Fixup the new suffix based on compression availability.
if (!isCompressed() && new_suffix.endsWith(".gz")) { if (compressionType() != WTAP_GZIP_COMPRESSED && new_suffix.endsWith(".gz")) {
new_suffix.chop(3); new_suffix.chop(3);
} else if (isCompressed() && valid_extensions.contains(new_suffix + ".gz")) { } else if (compressionType() == WTAP_GZIP_COMPRESSED && valid_extensions.contains(new_suffix + ".gz")) {
new_suffix += ".gz"; new_suffix += ".gz";
} }
@ -559,8 +559,8 @@ int CaptureFileDialog::selectedFileType() {
return type_hash_.value(selectedNameFilter(), -1); return type_hash_.value(selectedNameFilter(), -1);
} }
bool CaptureFileDialog::isCompressed() { wtap_compression_type CaptureFileDialog::compressionType() {
return compress_.isChecked(); return compress_.isChecked() ? WTAP_GZIP_COMPRESSED : WTAP_UNCOMPRESSED;
} }
void CaptureFileDialog::addDisplayFilterEdit() { void CaptureFileDialog::addDisplayFilterEdit() {
@ -585,7 +585,8 @@ void CaptureFileDialog::addFormatTypeSelector(QVBoxLayout &v_box) {
void CaptureFileDialog::addGzipControls(QVBoxLayout &v_box) { void CaptureFileDialog::addGzipControls(QVBoxLayout &v_box) {
compress_.setText(tr("Compress with g&zip")); compress_.setText(tr("Compress with g&zip"));
if (cap_file_->iscompressed && wtap_dump_can_compress(default_ft_)) { if (cap_file_->compression_type == WTAP_GZIP_COMPRESSED &&
wtap_dump_can_compress(default_ft_)) {
compress_.setChecked(true); compress_.setChecked(true);
} else { } else {
compress_.setChecked(false); compress_.setChecked(false);

View File

@ -68,7 +68,7 @@ public:
int mergeType(); int mergeType();
int selectedFileType(); int selectedFileType();
bool isCompressed(); wtap_compression_type compressionType();
private: private:
capture_file *cap_file_; capture_file *cap_file_;
@ -119,7 +119,7 @@ private:
#else // Q_OS_WIN #else // Q_OS_WIN
int file_type_; int file_type_;
int merge_type_; int merge_type_;
gboolean compressed_; wtap_compression_type compression_type_;
#endif // Q_OS_WIN #endif // Q_OS_WIN
signals: signals:

View File

@ -177,7 +177,7 @@ QString CaptureFilePropertiesDialog::summaryToHtml()
<< table_row_end; << table_row_end;
QString format_str = wtap_file_type_subtype_string(summary.file_type); QString format_str = wtap_file_type_subtype_string(summary.file_type);
if (summary.iscompressed) { if (summary.compression_type == WTAP_GZIP_COMPRESSED) {
format_str.append(tr(" (gzip compressed)")); format_str.append(tr(" (gzip compressed)"));
} }
out << table_row_begin out << table_row_begin

View File

@ -107,7 +107,7 @@ QString GsmMapSummaryDialog::summaryToHtml()
<< table_row_end; << table_row_end;
QString format_str = wtap_file_type_subtype_string(summary.file_type); QString format_str = wtap_file_type_subtype_string(summary.file_type);
if (summary.iscompressed) { if (summary.compression_type == WTAP_GZIP_COMPRESSED) {
format_str.append(tr(" (gzip compressed)")); format_str.append(tr(" (gzip compressed)"));
} }
out << table_row_begin out << table_row_begin

View File

@ -125,7 +125,7 @@ void ImportTextDialog::convertTextFile() {
params.encap = import_info_.encapsulation; params.encap = import_info_.encapsulation;
params.snaplen = import_info_.max_frame_length; params.snaplen = import_info_.max_frame_length;
/* Use a random name for the temporary import buffer */ /* Use a random name for the temporary import buffer */
import_info_.wdh = wtap_dump_open_tempfile(&tmpname, "import", WTAP_FILE_TYPE_SUBTYPE_PCAP, FALSE, &params, &err); import_info_.wdh = wtap_dump_open_tempfile(&tmpname, "import", WTAP_FILE_TYPE_SUBTYPE_PCAP, WTAP_UNCOMPRESSED, &params, &err);
capfile_name_.append(tmpname ? tmpname : "temporary file"); capfile_name_.append(tmpname ? tmpname : "temporary file");
qDebug() << capfile_name_ << ":" << import_info_.wdh << import_info_.encapsulation << import_info_.max_frame_length; qDebug() << capfile_name_ << ":" << import_info_.wdh << import_info_.encapsulation << import_info_.max_frame_length;
if (import_info_.wdh == NULL) { if (import_info_.wdh == NULL) {

View File

@ -1364,7 +1364,7 @@ bool MainWindow::saveCaptureFile(capture_file *cf, bool dont_reopen) {
closes the current file and then opens and reloads the saved file, closes the current file and then opens and reloads the saved file,
so make a copy and free it later. */ so make a copy and free it later. */
file_name = cf->filename; file_name = cf->filename;
status = cf_save_records(cf, qUtf8Printable(file_name), cf->cd_t, cf->iscompressed, status = cf_save_records(cf, qUtf8Printable(file_name), cf->cd_t, cf->compression_type,
discard_comments, dont_reopen); discard_comments, dont_reopen);
switch (status) { switch (status) {
@ -1400,7 +1400,7 @@ bool MainWindow::saveCaptureFile(capture_file *cf, bool dont_reopen) {
bool MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments, bool dont_reopen) { bool MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments, bool dont_reopen) {
QString file_name = ""; QString file_name = "";
int file_type; int file_type;
gboolean compressed; wtap_compression_type compression_type;
cf_write_status_t status; cf_write_status_t status;
gchar *dirname; gchar *dirname;
gboolean discard_comments = FALSE; gboolean discard_comments = FALSE;
@ -1447,11 +1447,11 @@ bool MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments,
return false; return false;
} }
file_type = save_as_dlg.selectedFileType(); file_type = save_as_dlg.selectedFileType();
compressed = save_as_dlg.isCompressed(); compression_type = save_as_dlg.compressionType();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// the Windows dialog does not fixup extensions, do it manually here. // the Windows dialog does not fixup extensions, do it manually here.
fileAddExtension(file_name, file_type, compressed); fileAddExtension(file_name, file_type, compression_type);
#endif // Q_OS_WIN #endif // Q_OS_WIN
//#ifndef _WIN32 //#ifndef _WIN32
@ -1464,7 +1464,7 @@ bool MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments,
//#endif //#endif
/* Attempt to save the file */ /* Attempt to save the file */
status = cf_save_records(cf, qUtf8Printable(file_name), file_type, compressed, status = cf_save_records(cf, qUtf8Printable(file_name), file_type, compression_type,
discard_comments, dont_reopen); discard_comments, dont_reopen);
switch (status) { switch (status) {
@ -1500,7 +1500,7 @@ bool MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments,
void MainWindow::exportSelectedPackets() { void MainWindow::exportSelectedPackets() {
QString file_name = ""; QString file_name = "";
int file_type; int file_type;
gboolean compressed; wtap_compression_type compression_type;
packet_range_t range; packet_range_t range;
cf_write_status_t status; cf_write_status_t status;
gchar *dirname; gchar *dirname;
@ -1574,10 +1574,10 @@ void MainWindow::exportSelectedPackets() {
} }
file_type = esp_dlg.selectedFileType(); file_type = esp_dlg.selectedFileType();
compressed = esp_dlg.isCompressed(); compression_type = esp_dlg.compressionType();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// the Windows dialog does not fixup extensions, do it manually here. // the Windows dialog does not fixup extensions, do it manually here.
fileAddExtension(file_name, file_type, compressed); fileAddExtension(file_name, file_type, compression_type);
#endif // Q_OS_WIN #endif // Q_OS_WIN
//#ifndef _WIN32 //#ifndef _WIN32
@ -1590,7 +1590,7 @@ void MainWindow::exportSelectedPackets() {
//#endif //#endif
/* Attempt to save the file */ /* Attempt to save the file */
status = cf_export_specified_packets(capture_file_.capFile(), qUtf8Printable(file_name), &range, file_type, compressed); status = cf_export_specified_packets(capture_file_.capFile(), qUtf8Printable(file_name), &range, file_type, compression_type);
switch (status) { switch (status) {
case CF_WRITE_OK: case CF_WRITE_OK:
@ -1630,7 +1630,7 @@ void MainWindow::exportDissections(export_type_e export_type) {
} }
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
void MainWindow::fileAddExtension(QString &file_name, int file_type, bool compressed) { void MainWindow::fileAddExtension(QString &file_name, int file_type, wtap_compression_type compression_type) {
QString file_name_lower; QString file_name_lower;
GSList *extensions_list; GSList *extensions_list;
gboolean add_extension; gboolean add_extension;
@ -1678,7 +1678,7 @@ void MainWindow::fileAddExtension(QString &file_name, int file_type, bool compre
if (add_extension) { if (add_extension) {
if (wtap_default_file_extension(file_type) != NULL) { if (wtap_default_file_extension(file_type) != NULL) {
file_name += tr(".") + wtap_default_file_extension(file_type); file_name += tr(".") + wtap_default_file_extension(file_type);
if (compressed) { if (compression_type == WTAP_GZIP_COMPRESSED) {
file_name += ".gz"; file_name += ".gz";
} }
} }

View File

@ -241,7 +241,7 @@ private:
void exportDissections(export_type_e export_type); void exportDissections(export_type_e export_type);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
void fileAddExtension(QString &file_name, int file_type, bool compressed); void fileAddExtension(QString &file_name, int file_type, wtap_compression_type compression_type);
#endif // Q_OS_WIN #endif // Q_OS_WIN
bool testCaptureFileClose(QString before_what, FileCloseContext context = Default); bool testCaptureFileClose(QString before_what, FileCloseContext context = Default);
void captureStop(); void captureStop();

View File

@ -111,7 +111,7 @@ QString Mtp3SummaryDialog::summaryToHtml()
<< table_row_end; << table_row_end;
QString format_str = wtap_file_type_subtype_string(summary.file_type); QString format_str = wtap_file_type_subtype_string(summary.file_type);
if (summary.iscompressed) { if (summary.compression_type == WTAP_GZIP_COMPRESSED) {
format_str.append(tr(" (gzip compressed)")); format_str.append(tr(" (gzip compressed)"));
} }
out << table_row_begin out << table_row_begin

View File

@ -155,7 +155,7 @@ summary_fill_in(capture_file *cf, summary_tally *st)
st->filename = cf->filename; st->filename = cf->filename;
st->file_length = cf->f_datalen; st->file_length = cf->f_datalen;
st->file_type = cf->cd_t; st->file_type = cf->cd_t;
st->iscompressed = cf->iscompressed; st->compression_type = cf->compression_type;
st->is_tempfile = cf->is_tempfile; st->is_tempfile = cf->is_tempfile;
st->file_encap_type = cf->lnk_t; st->file_encap_type = cf->lnk_t;
st->packet_encap_types = cf->linktypes; st->packet_encap_types = cf->linktypes;

View File

@ -33,42 +33,42 @@ typedef struct iface_summary_info_tag {
#define HASH_STR_SIZE (65) /* Max hash size * 2 + '\0' */ #define HASH_STR_SIZE (65) /* Max hash size * 2 + '\0' */
typedef struct _summary_tally { typedef struct _summary_tally {
guint64 bytes; /**< total bytes */ guint64 bytes; /**< total bytes */
double start_time; /**< seconds, with msec resolution */ double start_time; /**< seconds, with msec resolution */
double stop_time; /**< seconds, with msec resolution */ double stop_time; /**< seconds, with msec resolution */
double elapsed_time; /**< seconds, with msec resolution, double elapsed_time; /**< seconds, with msec resolution,
includes time before first packet includes time before first packet
and after last packet */ and after last packet */
guint32 marked_count; /**< number of marked packets */ guint32 marked_count; /**< number of marked packets */
guint32 marked_count_ts; /**< number of time-stamped marked packets */ guint32 marked_count_ts; /**< number of time-stamped marked packets */
guint64 marked_bytes; /**< total bytes in the marked packets */ guint64 marked_bytes; /**< total bytes in the marked packets */
double marked_start; /**< time in seconds, with msec resolution */ double marked_start; /**< time in seconds, with msec resolution */
double marked_stop; /**< time in seconds, with msec resolution */ double marked_stop; /**< time in seconds, with msec resolution */
guint32 ignored_count; /**< number of ignored packets */ guint32 ignored_count; /**< number of ignored packets */
guint32 packet_count; /**< total number of packets in trace */ guint32 packet_count; /**< total number of packets in trace */
guint32 packet_count_ts; /**< total number of time-stamped packets in trace */ guint32 packet_count_ts; /**< total number of time-stamped packets in trace */
guint32 filtered_count; /**< number of filtered packets */ guint32 filtered_count; /**< number of filtered packets */
guint32 filtered_count_ts; /**< number of time-stamped filtered packets */ guint32 filtered_count_ts; /**< number of time-stamped filtered packets */
guint64 filtered_bytes; /**< total bytes in the filtered packets */ guint64 filtered_bytes; /**< total bytes in the filtered packets */
double filtered_start; /**< time in seconds, with msec resolution */ double filtered_start; /**< time in seconds, with msec resolution */
double filtered_stop; /**< time in seconds, with msec resolution */ double filtered_stop; /**< time in seconds, with msec resolution */
const char *filename; /**< path of capture file */ const char *filename; /**< path of capture file */
gint64 file_length; /**< file length in bytes */ gint64 file_length; /**< file length in bytes */
gchar file_sha256[HASH_STR_SIZE]; /**< SHA256 hash of capture file */ gchar file_sha256[HASH_STR_SIZE]; /**< SHA256 hash of capture file */
gchar file_rmd160[HASH_STR_SIZE]; /**< RIPEMD160 hash of capture file */ gchar file_rmd160[HASH_STR_SIZE]; /**< RIPEMD160 hash of capture file */
gchar file_sha1[HASH_STR_SIZE]; /**< SHA1 hash of capture file */ gchar file_sha1[HASH_STR_SIZE]; /**< SHA1 hash of capture file */
int file_type; /**< wiretap file type */ int file_type; /**< wiretap file type */
int iscompressed; /**< TRUE if file is compressed */ wtap_compression_type compression_type; /**< compression type of file, or uncompressed */
int file_encap_type; /**< wiretap encapsulation type for file */ int file_encap_type; /**< wiretap encapsulation type for file */
GArray *packet_encap_types; /**< wiretap encapsulation types for packets */ GArray *packet_encap_types; /**< wiretap encapsulation types for packets */
int snap; /**< Maximum captured packet length; 0 if not known */ int snap; /**< Maximum captured packet length; 0 if not known */
gboolean drops_known; /**< TRUE if number of packet drops is known */ gboolean drops_known; /**< TRUE if number of packet drops is known */
guint64 drops; /**< number of packet drops */ guint64 drops; /**< number of packet drops */
const char *dfilter; /**< display filter */ const char *dfilter; /**< display filter */
gboolean is_tempfile; gboolean is_tempfile;
/* capture related, use summary_fill_in_capture() to get values */ /* capture related, use summary_fill_in_capture() to get values */
GArray *ifaces; GArray *ifaces;
gboolean legacy; gboolean legacy;
} summary_tally; } summary_tally;
extern void extern void

View File

@ -148,10 +148,10 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
}; };
if (fd == 1) { if (fd == 1) {
exp_pdu_tap_data->wdh = wtap_dump_open_stdout(WTAP_FILE_TYPE_SUBTYPE_PCAPNG, exp_pdu_tap_data->wdh = wtap_dump_open_stdout(WTAP_FILE_TYPE_SUBTYPE_PCAPNG,
FALSE, &params, &err); WTAP_UNCOMPRESSED, &params, &err);
} else { } else {
exp_pdu_tap_data->wdh = wtap_dump_fdopen(fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, exp_pdu_tap_data->wdh = wtap_dump_fdopen(fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG,
FALSE, &params, &err); WTAP_UNCOMPRESSED, &params, &err);
} }
if (exp_pdu_tap_data->wdh == NULL) { if (exp_pdu_tap_data->wdh == NULL) {
g_assert(err != 0); g_assert(err != 0);

View File

@ -315,7 +315,8 @@ win32_check_save_as_with_comments(HWND parent, capture_file *cf, int file_type)
gboolean gboolean
win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_type, win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_type,
gboolean *compressed, gboolean must_support_all_comments) wtap_compression_type *compression_type,
gboolean must_support_all_comments)
{ {
guint32 required_comment_types; guint32 required_comment_types;
GArray *savable_file_types; GArray *savable_file_types;
@ -324,7 +325,7 @@ win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_t
int ofnsize = sizeof(OPENFILENAME); int ofnsize = sizeof(OPENFILENAME);
BOOL gsfn_ok; BOOL gsfn_ok;
if (!file_name || !file_type || !compressed) if (!file_name || !file_type || !compression_type)
return FALSE; return FALSE;
if (file_name->len > 0) { if (file_name->len > 0) {
@ -375,7 +376,7 @@ win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_t
g_string_printf(file_name, "%s", utf_16to8(file_name16)); g_string_printf(file_name, "%s", utf_16to8(file_name16));
/* What file format was specified? */ /* What file format was specified? */
*file_type = g_array_index(savable_file_types, int, ofn->nFilterIndex - 1); *file_type = g_array_index(savable_file_types, int, ofn->nFilterIndex - 1);
*compressed = g_compressed; *compression_type = g_compressed ? WTAP_GZIP_COMPRESSED : WTAP_UNCOMPRESSED;
} else { } else {
/* User cancelled or closed the dialog, or an error occurred. */ /* User cancelled or closed the dialog, or an error occurred. */
if (CommDlgExtendedError() != 0) { if (CommDlgExtendedError() != 0) {
@ -451,7 +452,7 @@ gboolean
win32_export_specified_packets_file(HWND h_wnd, capture_file *cf, win32_export_specified_packets_file(HWND h_wnd, capture_file *cf,
GString *file_name, GString *file_name,
int *file_type, int *file_type,
gboolean *compressed, wtap_compression_type *compression_type,
packet_range_t *range) { packet_range_t *range) {
GArray *savable_file_types; GArray *savable_file_types;
OPENFILENAME *ofn; OPENFILENAME *ofn;
@ -459,7 +460,7 @@ win32_export_specified_packets_file(HWND h_wnd, capture_file *cf,
int ofnsize = sizeof(OPENFILENAME); int ofnsize = sizeof(OPENFILENAME);
BOOL gsfn_ok; BOOL gsfn_ok;
if (!file_name || !file_type || !compressed || !range) if (!file_name || !file_type || !compression_type || !range)
return FALSE; return FALSE;
if (file_name->len > 0) { if (file_name->len > 0) {
@ -506,7 +507,7 @@ win32_export_specified_packets_file(HWND h_wnd, capture_file *cf,
g_string_printf(file_name, "%s", utf_16to8(file_name16)); g_string_printf(file_name, "%s", utf_16to8(file_name16));
/* What file format was specified? */ /* What file format was specified? */
*file_type = g_array_index(savable_file_types, int, ofn->nFilterIndex - 1); *file_type = g_array_index(savable_file_types, int, ofn->nFilterIndex - 1);
*compressed = g_compressed; *compression_type = g_compressed ? WTAP_GZIP_COMPRESSED : WTAP_UNCOMPRESSED;
} else { } else {
/* User cancelled or closed the dialog, or an error occurred. */ /* User cancelled or closed the dialog, or an error occurred. */
if (CommDlgExtendedError() != 0) { if (CommDlgExtendedError() != 0) {

View File

@ -67,7 +67,7 @@ check_savability_t win32_check_save_as_with_comments(HWND parent, capture_file *
* @param cf capture_file Structure for the capture to be saved * @param cf capture_file Structure for the capture to be saved
* @param file_name File name. May be empty. * @param file_name File name. May be empty.
* @param file_type Wiretap file type. * @param file_type Wiretap file type.
* @param compressed Compress the file with gzip. * @param compression_type Compression type to use, or uncompressed.
* @param must_support_comments TRUE if the file format list should * @param must_support_comments TRUE if the file format list should
* include only file formats that support comments * include only file formats that support comments
* *
@ -75,7 +75,7 @@ check_savability_t win32_check_save_as_with_comments(HWND parent, capture_file *
*/ */
gboolean win32_save_as_file(HWND h_wnd, capture_file *cf, gboolean win32_save_as_file(HWND h_wnd, capture_file *cf,
GString *file_name, int *file_type, GString *file_name, int *file_type,
gboolean *compressed, wtap_compression_type *compression_type,
gboolean must_support_comments); gboolean must_support_comments);
/** Open the "Export Specified Packets" dialog box. /** Open the "Export Specified Packets" dialog box.
@ -84,7 +84,7 @@ gboolean win32_save_as_file(HWND h_wnd, capture_file *cf,
* @param cf capture_file Structure for the capture to be saved * @param cf capture_file Structure for the capture to be saved
* @param file_name File name. May be empty. * @param file_name File name. May be empty.
* @param file_type Wiretap file type. * @param file_type Wiretap file type.
* @param compressed Compress the file with gzip. * @param compression_type Compression type to use, or uncompressed.
* @param range Range of packets to export. * @param range Range of packets to export.
* *
* @return TRUE if packets were discarded when saving, FALSE otherwise * @return TRUE if packets were discarded when saving, FALSE otherwise
@ -93,7 +93,7 @@ gboolean win32_export_specified_packets_file(HWND h_wnd,
capture_file *cf, capture_file *cf,
GString *file_name, GString *file_name,
int *file_type, int *file_type,
gboolean *compressed, wtap_compression_type *compression_type,
packet_range_t *range); packet_range_t *range);

View File

@ -2222,17 +2222,19 @@ wtap_dump_supports_comment_types(int file_type_subtype, guint32 comment_types)
return FALSE; return FALSE;
} }
static gboolean wtap_dump_open_check(int file_type_subtype, int encap, gboolean comressed, int *err); static gboolean wtap_dump_open_check(int file_type_subtype, int encap, gboolean compressed, int *err);
static wtap_dumper* wtap_dump_alloc_wdh(int file_type_subtype, int encap, int snaplen, static wtap_dumper* wtap_dump_alloc_wdh(int file_type_subtype, int encap, int snaplen,
gboolean compressed, int *err); wtap_compression_type compression_type,
static gboolean wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype, gboolean compressed, int *err); int *err);
static gboolean wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype,
int *err);
static WFILE_T wtap_dump_file_open(wtap_dumper *wdh, const char *filename); static WFILE_T wtap_dump_file_open(wtap_dumper *wdh, const char *filename);
static WFILE_T wtap_dump_file_fdopen(wtap_dumper *wdh, int fd); static WFILE_T wtap_dump_file_fdopen(wtap_dumper *wdh, int fd);
static int wtap_dump_file_close(wtap_dumper *wdh); static int wtap_dump_file_close(wtap_dumper *wdh);
static wtap_dumper * static wtap_dumper *
wtap_dump_init_dumper(int file_type_subtype, gboolean compressed, wtap_dump_init_dumper(int file_type_subtype, wtap_compression_type compression_type,
const wtap_dump_params *params, int *err) const wtap_dump_params *params, int *err)
{ {
wtap_dumper *wdh; wtap_dumper *wdh;
@ -2241,12 +2243,16 @@ wtap_dump_init_dumper(int file_type_subtype, gboolean compressed,
GArray *interfaces = params->idb_inf ? params->idb_inf->interface_data : NULL; GArray *interfaces = params->idb_inf ? params->idb_inf->interface_data : NULL;
/* Check whether we can open a capture file with that file type /* Check whether we can open a capture file with that file type
and that encapsulation. */ and that encapsulation, and, if the compression type isn't
if (!wtap_dump_open_check(file_type_subtype, params->encap, compressed, err)) "uncompressed", whether we can write a *compressed* file
of that file type. */
if (!wtap_dump_open_check(file_type_subtype, params->encap,
(compression_type != WTAP_UNCOMPRESSED), err))
return NULL; return NULL;
/* Allocate a data structure for the output stream. */ /* Allocate a data structure for the output stream. */
wdh = wtap_dump_alloc_wdh(file_type_subtype, params->encap, params->snaplen, compressed, err); wdh = wtap_dump_alloc_wdh(file_type_subtype, params->encap,
params->snaplen, compression_type, err);
if (wdh == NULL) if (wdh == NULL)
return NULL; /* couldn't allocate it */ return NULL; /* couldn't allocate it */
@ -2309,13 +2315,15 @@ wtap_dump_init_dumper(int file_type_subtype, gboolean compressed,
wtap_dumper * wtap_dumper *
wtap_dump_open(const char *filename, int file_type_subtype, wtap_dump_open(const char *filename, int file_type_subtype,
gboolean compressed, const wtap_dump_params *params, int *err) wtap_compression_type compression_type, const wtap_dump_params *params,
int *err)
{ {
wtap_dumper *wdh; wtap_dumper *wdh;
WFILE_T fh; WFILE_T fh;
/* Allocate and initialize a data structure for the output stream. */ /* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, compressed, params, err); wdh = wtap_dump_init_dumper(file_type_subtype, compression_type, params,
err);
if (wdh == NULL) if (wdh == NULL)
return NULL; return NULL;
@ -2330,7 +2338,7 @@ wtap_dump_open(const char *filename, int file_type_subtype,
} }
wdh->fh = fh; wdh->fh = fh;
if (!wtap_dump_open_finish(wdh, file_type_subtype, compressed, err)) { if (!wtap_dump_open_finish(wdh, file_type_subtype, err)) {
/* Get rid of the file we created; we couldn't finish /* Get rid of the file we created; we couldn't finish
opening it. */ opening it. */
wtap_dump_file_close(wdh); wtap_dump_file_close(wdh);
@ -2343,7 +2351,7 @@ wtap_dump_open(const char *filename, int file_type_subtype,
wtap_dumper * wtap_dumper *
wtap_dump_open_tempfile(char **filenamep, const char *pfx, wtap_dump_open_tempfile(char **filenamep, const char *pfx,
int file_type_subtype, gboolean compressed, int file_type_subtype, wtap_compression_type compression_type,
const wtap_dump_params *params, int *err) const wtap_dump_params *params, int *err)
{ {
int fd; int fd;
@ -2355,7 +2363,8 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx,
*filenamep = NULL; *filenamep = NULL;
/* Allocate and initialize a data structure for the output stream. */ /* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, compressed, params, err); wdh = wtap_dump_init_dumper(file_type_subtype, compression_type, params,
err);
if (wdh == NULL) if (wdh == NULL)
return NULL; return NULL;
@ -2380,7 +2389,7 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx,
} }
wdh->fh = fh; wdh->fh = fh;
if (!wtap_dump_open_finish(wdh, file_type_subtype, compressed, err)) { if (!wtap_dump_open_finish(wdh, file_type_subtype, err)) {
/* Get rid of the file we created; we couldn't finish /* Get rid of the file we created; we couldn't finish
opening it. */ opening it. */
wtap_dump_file_close(wdh); wtap_dump_file_close(wdh);
@ -2392,14 +2401,15 @@ wtap_dump_open_tempfile(char **filenamep, const char *pfx,
} }
wtap_dumper * wtap_dumper *
wtap_dump_fdopen(int fd, int file_type_subtype, gboolean compressed, wtap_dump_fdopen(int fd, int file_type_subtype, wtap_compression_type compression_type,
const wtap_dump_params *params, int *err) const wtap_dump_params *params, int *err)
{ {
wtap_dumper *wdh; wtap_dumper *wdh;
WFILE_T fh; WFILE_T fh;
/* Allocate and initialize a data structure for the output stream. */ /* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, compressed, params, err); wdh = wtap_dump_init_dumper(file_type_subtype, compression_type, params,
err);
if (wdh == NULL) if (wdh == NULL)
return NULL; return NULL;
@ -2414,7 +2424,7 @@ wtap_dump_fdopen(int fd, int file_type_subtype, gboolean compressed,
} }
wdh->fh = fh; wdh->fh = fh;
if (!wtap_dump_open_finish(wdh, file_type_subtype, compressed, err)) { if (!wtap_dump_open_finish(wdh, file_type_subtype, err)) {
wtap_dump_file_close(wdh); wtap_dump_file_close(wdh);
g_free(wdh); g_free(wdh);
return NULL; return NULL;
@ -2423,7 +2433,7 @@ wtap_dump_fdopen(int fd, int file_type_subtype, gboolean compressed,
} }
wtap_dumper * wtap_dumper *
wtap_dump_open_stdout(int file_type_subtype, gboolean compressed, wtap_dump_open_stdout(int file_type_subtype, wtap_compression_type compression_type,
const wtap_dump_params *params, int *err) const wtap_dump_params *params, int *err)
{ {
int new_fd; int new_fd;
@ -2455,7 +2465,8 @@ wtap_dump_open_stdout(int file_type_subtype, gboolean compressed,
} }
#endif #endif
wdh = wtap_dump_fdopen(new_fd, file_type_subtype, compressed, params, err); wdh = wtap_dump_fdopen(new_fd, file_type_subtype, compression_type,
params, err);
if (wdh == NULL) { if (wdh == NULL) {
/* Failed; close the new FD */ /* Failed; close the new FD */
ws_close(new_fd); ws_close(new_fd);
@ -2499,7 +2510,8 @@ wtap_dump_open_check(int file_type_subtype, int encap, gboolean compressed, int
} }
static wtap_dumper * static wtap_dumper *
wtap_dump_alloc_wdh(int file_type_subtype, int encap, int snaplen, gboolean compressed, int *err) wtap_dump_alloc_wdh(int file_type_subtype, int encap, int snaplen,
wtap_compression_type compression_type, int *err)
{ {
wtap_dumper *wdh; wtap_dumper *wdh;
@ -2512,21 +2524,21 @@ wtap_dump_alloc_wdh(int file_type_subtype, int encap, int snaplen, gboolean comp
wdh->file_type_subtype = file_type_subtype; wdh->file_type_subtype = file_type_subtype;
wdh->snaplen = snaplen; wdh->snaplen = snaplen;
wdh->encap = encap; wdh->encap = encap;
wdh->compressed = compressed; wdh->compression_type = compression_type;
wdh->wslua_data = NULL; wdh->wslua_data = NULL;
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t)); wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
return wdh; return wdh;
} }
static gboolean static gboolean
wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype, gboolean compressed, int *err) wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype, int *err)
{ {
int fd; int fd;
gboolean cant_seek; gboolean cant_seek;
/* Can we do a seek on the file descriptor? /* Can we do a seek on the file descriptor?
If not, note that fact. */ If not, note that fact. */
if(compressed) { if (wdh->compression_type != WTAP_UNCOMPRESSED) {
cant_seek = TRUE; cant_seek = TRUE;
} else { } else {
fd = ws_fileno((FILE *)wdh->fh); fd = ws_fileno((FILE *)wdh->fh);
@ -2572,7 +2584,7 @@ void
wtap_dump_flush(wtap_dumper *wdh) wtap_dump_flush(wtap_dumper *wdh)
{ {
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
if(wdh->compressed) { if (wdh->compression_type == WTAP_GZIP_COMPRESSED) {
gzwfile_flush((GZWFILE_T)wdh->fh); gzwfile_flush((GZWFILE_T)wdh->fh);
} else } else
#endif #endif
@ -2647,7 +2659,7 @@ gboolean wtap_dump_get_needs_reload(wtap_dumper *wdh) {
static WFILE_T static WFILE_T
wtap_dump_file_open(wtap_dumper *wdh, const char *filename) wtap_dump_file_open(wtap_dumper *wdh, const char *filename)
{ {
if(wdh->compressed) { if (wdh->compression_type == WTAP_GZIP_COMPRESSED) {
return gzwfile_open(filename); return gzwfile_open(filename);
} else { } else {
return ws_fopen(filename, "wb"); return ws_fopen(filename, "wb");
@ -2666,7 +2678,7 @@ wtap_dump_file_open(wtap_dumper *wdh _U_, const char *filename)
static WFILE_T static WFILE_T
wtap_dump_file_fdopen(wtap_dumper *wdh, int fd) wtap_dump_file_fdopen(wtap_dumper *wdh, int fd)
{ {
if(wdh->compressed) { if (wdh->compression_type == WTAP_GZIP_COMPRESSED) {
return gzwfile_fdopen(fd); return gzwfile_fdopen(fd);
} else { } else {
return ws_fdopen(fd, "wb"); return ws_fdopen(fd, "wb");
@ -2687,7 +2699,7 @@ wtap_dump_file_write(wtap_dumper *wdh, const void *buf, size_t bufsize, int *err
size_t nwritten; size_t nwritten;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
if (wdh->compressed) { if (wdh->compression_type == WTAP_GZIP_COMPRESSED) {
nwritten = gzwfile_write((GZWFILE_T)wdh->fh, buf, (unsigned int) bufsize); nwritten = gzwfile_write((GZWFILE_T)wdh->fh, buf, (unsigned int) bufsize);
/* /*
* gzwfile_write() returns 0 on error. * gzwfile_write() returns 0 on error.
@ -2721,7 +2733,7 @@ static int
wtap_dump_file_close(wtap_dumper *wdh) wtap_dump_file_close(wtap_dumper *wdh)
{ {
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
if(wdh->compressed) if (wdh->compression_type == WTAP_GZIP_COMPRESSED)
return gzwfile_close((GZWFILE_T)wdh->fh); return gzwfile_close((GZWFILE_T)wdh->fh);
else else
#endif #endif
@ -2732,7 +2744,7 @@ gint64
wtap_dump_file_seek(wtap_dumper *wdh, gint64 offset, int whence, int *err) wtap_dump_file_seek(wtap_dumper *wdh, gint64 offset, int whence, int *err)
{ {
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
if(wdh->compressed) { if (wdh->compression_type != WTAP_UNCOMPRESSED) {
*err = WTAP_ERR_CANT_SEEK_COMPRESSED; *err = WTAP_ERR_CANT_SEEK_COMPRESSED;
return -1; return -1;
} else } else
@ -2753,7 +2765,7 @@ wtap_dump_file_tell(wtap_dumper *wdh, int *err)
{ {
gint64 rval; gint64 rval;
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
if(wdh->compressed) { if (wdh->compression_type != WTAP_UNCOMPRESSED) {
*err = WTAP_ERR_CANT_SEEK_COMPRESSED; *err = WTAP_ERR_CANT_SEEK_COMPRESSED;
return -1; return -1;
} else } else

View File

@ -1022,8 +1022,8 @@ merge_files(const gchar* out_filename, const int file_type,
params.shb_hdrs = shb_hdrs; params.shb_hdrs = shb_hdrs;
params.idb_inf = idb_inf; params.idb_inf = idb_inf;
} }
pdh = wtap_dump_open(out_filename, file_type, FALSE /* compressed */, pdh = wtap_dump_open(out_filename, file_type, WTAP_UNCOMPRESSED, &params,
&params, err); err);
if (pdh == NULL) { if (pdh == NULL) {
merge_close_in_files(in_file_count, in_files); merge_close_in_files(in_file_count, in_files);
g_free(in_files); g_free(in_files);
@ -1126,7 +1126,7 @@ merge_files_to_tempfile(gchar **out_filenamep, const char *pfx,
params.idb_inf = idb_inf; params.idb_inf = idb_inf;
} }
pdh = wtap_dump_open_tempfile(out_filenamep, pfx, file_type, pdh = wtap_dump_open_tempfile(out_filenamep, pfx, file_type,
FALSE /* compressed */, &params, err); WTAP_UNCOMPRESSED, &params, err);
if (pdh == NULL) { if (pdh == NULL) {
merge_close_in_files(in_file_count, in_files); merge_close_in_files(in_file_count, in_files);
g_free(in_files); g_free(in_files);
@ -1223,7 +1223,7 @@ merge_files_to_stdout(const int file_type, const char *const *in_filenames,
params.shb_hdrs = shb_hdrs; params.shb_hdrs = shb_hdrs;
params.idb_inf = idb_inf; params.idb_inf = idb_inf;
} }
pdh = wtap_dump_open_stdout(file_type, FALSE /* compressed */, &params, err); pdh = wtap_dump_open_stdout(file_type, WTAP_UNCOMPRESSED, &params, err);
if (pdh == NULL) { if (pdh == NULL) {
merge_close_in_files(in_file_count, in_files); merge_close_in_files(in_file_count, in_files);
g_free(in_files); g_free(in_files);

View File

@ -799,7 +799,8 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
.idb_inf = idb_inf, .idb_inf = idb_inf,
}; };
wdh_exp_pdu = wtap_dump_fdopen(import_file_fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, wdh_exp_pdu = wtap_dump_fdopen(import_file_fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG,
FALSE, &params, &exp_pdu_file_err); WTAP_UNCOMPRESSED, &params,
&exp_pdu_file_err);
if (wdh_exp_pdu == NULL) { if (wdh_exp_pdu == NULL) {
result = WTAP_OPEN_ERROR; result = WTAP_OPEN_ERROR;
goto end; goto end;

View File

@ -88,7 +88,7 @@ struct wtap_dumper {
int file_type_subtype; int file_type_subtype;
int snaplen; int snaplen;
int encap; int encap;
gboolean compressed; wtap_compression_type compression_type;
gboolean needs_reload; /* TRUE if the file requires re-loading after saving with wtap */ gboolean needs_reload; /* TRUE if the file requires re-loading after saving with wtap */
gint64 bytes_dumped; gint64 bytes_dumped;

View File

@ -77,10 +77,13 @@ wtap_file_type_subtype(wtap *wth)
return wth->file_type_subtype; return wth->file_type_subtype;
} }
gboolean wtap_compression_type
wtap_iscompressed(wtap *wth) wtap_get_compression_type(wtap *wth)
{ {
return file_iscompressed((wth->fh == NULL) ? wth->random_fh : wth->fh); gboolean is_compressed;
is_compressed = file_iscompressed((wth->fh == NULL) ? wth->random_fh : wth->fh);
return is_compressed ? WTAP_GZIP_COMPRESSED : WTAP_UNCOMPRESSED;
} }
guint guint

View File

@ -1690,6 +1690,14 @@ void wtap_rec_init(wtap_rec *rec);
WS_DLL_PUBLIC WS_DLL_PUBLIC
void wtap_rec_cleanup(wtap_rec *rec); void wtap_rec_cleanup(wtap_rec *rec);
/*
* Types of compression for a file, including "none".
*/
typedef enum {
WTAP_UNCOMPRESSED,
WTAP_GZIP_COMPRESSED
} wtap_compression_type;
/*** get various information snippets about the current file ***/ /*** get various information snippets about the current file ***/
/** Return an approximation of the amount of data we've read sequentially /** Return an approximation of the amount of data we've read sequentially
@ -1699,7 +1707,7 @@ gint64 wtap_read_so_far(wtap *wth);
WS_DLL_PUBLIC WS_DLL_PUBLIC
gint64 wtap_file_size(wtap *wth, int *err); gint64 wtap_file_size(wtap *wth, int *err);
WS_DLL_PUBLIC WS_DLL_PUBLIC
gboolean wtap_iscompressed(wtap *wth); wtap_compression_type wtap_get_compression_type(wtap *wth);
WS_DLL_PUBLIC WS_DLL_PUBLIC
guint wtap_snapshot_length(wtap *wth); /* per file */ guint wtap_snapshot_length(wtap *wth); /* per file */
WS_DLL_PUBLIC WS_DLL_PUBLIC
@ -1897,14 +1905,15 @@ void wtap_dump_params_cleanup(wtap_dump_params *params);
* *
* @param filename The new file's name. * @param filename The new file's name.
* @param file_type_subtype The WTAP_FILE_TYPE_SUBTYPE_XXX file type. * @param file_type_subtype The WTAP_FILE_TYPE_SUBTYPE_XXX file type.
* @param compressed True if file should be compressed. * @param compression_type Type of compression to use when writing, if any
* @param params The per-file information for this file. * @param params The per-file information for this file.
* @param[out] err Will be set to an error code on failure. * @param[out] err Will be set to an error code on failure.
* @return The newly created dumper object, or NULL on failure. * @return The newly created dumper object, or NULL on failure.
*/ */
WS_DLL_PUBLIC WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype, wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype,
gboolean compressed, const wtap_dump_params *params, int *err); wtap_compression_type compression_type, const wtap_dump_params *params,
int *err);
/** /**
* @brief Creates a dumper for a temporary file. * @brief Creates a dumper for a temporary file.
@ -1913,14 +1922,14 @@ wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype,
* pathname of the temporary file; it's allocated with g_malloc() * pathname of the temporary file; it's allocated with g_malloc()
* @param pfx A string to be used as the prefix for the temporary file name * @param pfx A string to be used as the prefix for the temporary file name
* @param file_type_subtype The WTAP_FILE_TYPE_SUBTYPE_XXX file type. * @param file_type_subtype The WTAP_FILE_TYPE_SUBTYPE_XXX file type.
* @param compressed True if file should be compressed. * @param compression_type Type of compression to use when writing, if any
* @param params The per-file information for this file. * @param params The per-file information for this file.
* @param[out] err Will be set to an error code on failure. * @param[out] err Will be set to an error code on failure.
* @return The newly created dumper object, or NULL on failure. * @return The newly created dumper object, or NULL on failure.
*/ */
WS_DLL_PUBLIC WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_tempfile(char **filenamep, const char *pfx, wtap_dumper* wtap_dump_open_tempfile(char **filenamep, const char *pfx,
int file_type_subtype, gboolean compressed, int file_type_subtype, wtap_compression_type compression_type,
const wtap_dump_params *params, int *err); const wtap_dump_params *params, int *err);
/** /**
@ -1928,14 +1937,15 @@ wtap_dumper* wtap_dump_open_tempfile(char **filenamep, const char *pfx,
* *
* @param fd The file descriptor for which the dumper should be created. * @param fd The file descriptor for which the dumper should be created.
* @param file_type_subtype The WTAP_FILE_TYPE_SUBTYPE_XXX file type. * @param file_type_subtype The WTAP_FILE_TYPE_SUBTYPE_XXX file type.
* @param compressed True if file should be compressed. * @param compression_type Type of compression to use when writing, if any
* @param params The per-file information for this file. * @param params The per-file information for this file.
* @param[out] err Will be set to an error code on failure. * @param[out] err Will be set to an error code on failure.
* @return The newly created dumper object, or NULL on failure. * @return The newly created dumper object, or NULL on failure.
*/ */
WS_DLL_PUBLIC WS_DLL_PUBLIC
wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype, wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype,
gboolean compressed, const wtap_dump_params *params, int *err); wtap_compression_type compression_type, const wtap_dump_params *params,
int *err);
/** /**
* @brief Creates a dumper for the standard output. * @brief Creates a dumper for the standard output.
@ -1943,14 +1953,15 @@ wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype,
* @param file_type_subtype The WTAP_FILE_TYPE_SUBTYPE_XXX file type. * @param file_type_subtype The WTAP_FILE_TYPE_SUBTYPE_XXX file type.
* @param encap The WTAP_ENCAP_XXX encapsulation type (WTAP_ENCAP_PER_PACKET for multi) * @param encap The WTAP_ENCAP_XXX encapsulation type (WTAP_ENCAP_PER_PACKET for multi)
* @param snaplen The maximum packet capture length. * @param snaplen The maximum packet capture length.
* @param compressed True if file should be compressed. * @param compression_type Type of compression to use when writing, if any
* @param params The per-file information for this file. * @param params The per-file information for this file.
* @param[out] err Will be set to an error code on failure. * @param[out] err Will be set to an error code on failure.
* @return The newly created dumper object, or NULL on failure. * @return The newly created dumper object, or NULL on failure.
*/ */
WS_DLL_PUBLIC WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_stdout(int file_type_subtype, wtap_dumper* wtap_dump_open_stdout(int file_type_subtype,
gboolean compressed, const wtap_dump_params *params, int *err); wtap_compression_type compression_type, const wtap_dump_params *params,
int *err);
WS_DLL_PUBLIC WS_DLL_PUBLIC
gboolean wtap_dump(wtap_dumper *, const wtap_rec *, const guint8 *, gboolean wtap_dump(wtap_dumper *, const wtap_rec *, const guint8 *,