aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_access.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2012-04-25 12:33:23 +0000
committerAnders Broman <anders.broman@ericsson.com>2012-04-25 12:33:23 +0000
commit102991bf0f159ca04237138abc02c3954c97c965 (patch)
treea60fd0bc1373296d072a0abc32764058c555d7cc /wiretap/file_access.c
parentee3910f6cedbc93dce0fe08ed440484153694cf6 (diff)
Handle wtap_dump_fdopen() as wtap_dump_open() eg call
wtap_dump_fdopen_ng() and add a dummy IDB to be able to write pcapng files. Solves https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6969 mergecap: Can't open or create <FILENAME>: Internal error. We might want to add a SHB comment from mergecap giving the merged filenames or something like that, Merging of pcapng files is a different issue, idealy we should probably start using several SHB:s in that case. svn path=/trunk/; revision=42230
Diffstat (limited to 'wiretap/file_access.c')
-rw-r--r--wiretap/file_access.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 1a903a5d59..23e17a4bcc 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1088,6 +1088,12 @@ wtap_dumper* wtap_dump_open_ng(const char *filename, int filetype, int encap,
wtap_dumper* wtap_dump_fdopen(int fd, int filetype, int encap, int snaplen,
gboolean compressed, int *err)
{
+ return wtap_dump_fdopen_ng(fd, filetype, encap, snaplen, compressed, NULL, NULL, err);
+}
+
+wtap_dumper* wtap_dump_fdopen_ng(int fd, int filetype, int encap, int snaplen,
+ gboolean compressed, wtapng_section_t *shb_hdr, wtapng_iface_descriptions_t *idb_inf, int *err)
+{
wtap_dumper *wdh;
WFILE_T fh;
@@ -1112,6 +1118,36 @@ wtap_dumper* wtap_dump_fdopen(int fd, int filetype, int encap, int snaplen,
}
#endif
+ /* Set Section Header Block data */
+ wdh->shb_hdr = shb_hdr;
+ /* Set Interface Description Block data */
+ if ((idb_inf != NULL) && (idb_inf->number_of_interfaces > 0)) {
+ wdh->number_of_interfaces = idb_inf->number_of_interfaces;
+ wdh->interface_data = idb_inf->interface_data;
+ } else {
+ wtapng_if_descr_t descr;
+
+ descr.wtap_encap = encap;
+ descr.time_units_per_second = 0;
+ descr.link_type = wtap_wtap_encap_to_pcap_encap(encap);
+ descr.snap_len = snaplen;
+ descr.opt_comment = NULL;
+ descr.if_name = NULL;
+ descr.if_description = NULL;
+ descr.if_speed = 0;
+ descr.if_tsresol = 6;
+ descr.if_filter_str= NULL;
+ descr.bpf_filter_len= 0;
+ descr.if_filter_bpf_bytes= NULL;
+ descr.if_os = NULL;
+ descr.if_fcslen = -1;
+ descr.num_stat_entries = 0; /* Number of ISB:s */
+ descr.interface_statistics = NULL;
+ wdh->number_of_interfaces= 1;
+ wdh->interface_data= g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
+ g_array_append_val(wdh->interface_data, descr);
+ }
+
/* In case "fopen()" fails but doesn't set "errno", set "errno"
to a generic "the open failed" error. */
errno = WTAP_ERR_CANT_OPEN;