forked from osmocom/wireshark
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:
parent
e12753d5f6
commit
a1372f6d01
|
@ -179,7 +179,7 @@ typedef enum {
|
||||||
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;
|
||||||
|
@ -202,7 +202,7 @@ typedef struct _capture_info {
|
||||||
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;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
2
cfile.h
2
cfile.h
|
@ -74,7 +74,7 @@ typedef struct _capture_file {
|
||||||
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 */
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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,
|
||||||
¶ms,
|
¶ms,
|
||||||
&open_err);
|
&open_err);
|
||||||
if (!current_session.pdh) {
|
if (!current_session.pdh) {
|
||||||
|
|
|
@ -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. */
|
||||||
|
|
|
@ -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, ¶ms, &err);
|
d = wtap_dump_open(filename, filetype, WTAP_UNCOMPRESSED, ¶ms, &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, ¶ms, &err);
|
d = wtap_dump_open(filename, filetype, WTAP_UNCOMPRESSED, ¶ms, &err);
|
||||||
|
|
||||||
if (! d ) {
|
if (! d ) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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, ¶ms, &err);
|
extcap_dumper.dumper.wtap = wtap_dump_open(fifo, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC, WTAP_UNCOMPRESSED, ¶ms, &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
26
file.c
|
@ -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, ¶ms, &err);
|
pdh = wtap_dump_open(fname_new, save_format, compression_type, ¶ms,
|
||||||
|
&err);
|
||||||
} else {
|
} else {
|
||||||
pdh = wtap_dump_open(fname, save_format, compressed, ¶ms, &err);
|
pdh = wtap_dump_open(fname, save_format, compression_type, ¶ms, &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, ¶ms, &err);
|
pdh = wtap_dump_open(fname_new, save_format, compression_type, ¶ms,
|
||||||
|
&err);
|
||||||
} else {
|
} else {
|
||||||
pdh = wtap_dump_open(fname, save_format, compressed, ¶ms, &err);
|
pdh = wtap_dump_open(fname, save_format, compression_type, ¶ms, &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
9
file.h
|
@ -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.
|
||||||
|
|
|
@ -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, ¶ms, &err);
|
||||||
¶ms, &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, ¶ms, &err);
|
||||||
¶ms, &err);
|
|
||||||
example->filename = produce_filename;
|
example->filename = produce_filename;
|
||||||
}
|
}
|
||||||
if (!example->dump) {
|
if (!example->dump) {
|
||||||
|
|
|
@ -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, ¶ms, &err);
|
pdh = wtap_dump_open_stdout(wtap_file_type_subtype(wth), WTAP_UNCOMPRESSED, ¶ms, &err);
|
||||||
} else {
|
} else {
|
||||||
pdh = wtap_dump_open(outfile, wtap_file_type_subtype(wth), FALSE, ¶ms, &err);
|
pdh = wtap_dump_open(outfile, wtap_file_type_subtype(wth), WTAP_UNCOMPRESSED, ¶ms, &err);
|
||||||
}
|
}
|
||||||
g_free(params.idb_inf);
|
g_free(params.idb_inf);
|
||||||
params.idb_inf = NULL;
|
params.idb_inf = NULL;
|
||||||
|
|
8
tshark.c
8
tshark.c
|
@ -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, ¶ms,
|
||||||
¶ms, &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, ¶ms,
|
||||||
¶ms, &err);
|
&err);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(params.idb_inf);
|
g_free(params.idb_inf);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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, ¶ms, &err);
|
import_info_.wdh = wtap_dump_open_tempfile(&tmpname, "import", WTAP_FILE_TYPE_SUBTYPE_PCAP, WTAP_UNCOMPRESSED, ¶ms, &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) {
|
||||||
|
|
|
@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -58,7 +58,7 @@ typedef struct _summary_tally {
|
||||||
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 */
|
||||||
|
|
|
@ -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, ¶ms, &err);
|
WTAP_UNCOMPRESSED, ¶ms, &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, ¶ms, &err);
|
WTAP_UNCOMPRESSED, ¶ms, &err);
|
||||||
}
|
}
|
||||||
if (exp_pdu_tap_data->wdh == NULL) {
|
if (exp_pdu_tap_data->wdh == NULL) {
|
||||||
g_assert(err != 0);
|
g_assert(err != 0);
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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, ¶ms,
|
||||||
¶ms, 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 */, ¶ms, err);
|
WTAP_UNCOMPRESSED, ¶ms, 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 */, ¶ms, err);
|
pdh = wtap_dump_open_stdout(file_type, WTAP_UNCOMPRESSED, ¶ms, 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);
|
||||||
|
|
|
@ -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, ¶ms, &exp_pdu_file_err);
|
WTAP_UNCOMPRESSED, ¶ms,
|
||||||
|
&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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 *,
|
||||||
|
|
Loading…
Reference in New Issue