summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2015-07-20 10:35:06 -0400
committerAnders Broman <a.broman58@gmail.com>2015-08-06 03:32:13 +0000
commit910438b17f3f8b9ca9cfdbb87b3daf49dd7eb9a0 (patch)
treef57b1dd36c4e20cd7b9758476cb862b74cd1a320 /file.c
parent1420f3df6376f45157b7f363c6c07da3a9ac6f29 (diff)
downloadwireshark-910438b17f3f8b9ca9cfdbb87b3daf49dd7eb9a0.tar.gz
Pcapng: support Name Resolution Block options
Make pcapng decode options in an NRB during read, and store the comment option, and write it back out as well. Also make it handle plugin handlers for unknown options in received NRB(s). Change-Id: I81863ef8d85cb1c8b5ba6673ba0e562efe77714f Reviewed-on: https://code.wireshark.org/review/9723 Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'file.c')
-rw-r--r--file.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/file.c b/file.c
index 1183a169a2..449269fbc4 100644
--- a/file.c
+++ b/file.c
@@ -1317,6 +1317,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
}
shb_hdr->section_length = -1;
/* options */
+ /* TODO: handle comments from each file being merged */
shb_hdr->opt_comment = g_string_free(comment_gstr, FALSE); /* NULL if not available */
shb_hdr->shb_hardware = NULL; /* NULL if not available, UTF-8 string containing the */
/* description of the hardware used to create this section. */
@@ -1325,6 +1326,8 @@ cf_merge_files(char **out_filenamep, int in_file_count,
shb_hdr->shb_user_appl = g_strdup("Wireshark"); /* NULL if not available, UTF-8 string containing the name */
/* of the application used to create this section. */
+ /* TODO: handle name resolution info from each file being merged */
+
/* create fake IDB info */
idb_inf = g_new(wtapng_iface_descriptions_t,1);
/* TODO make this the number of DIFFERENT encapsulation types
@@ -1366,7 +1369,8 @@ cf_merge_files(char **out_filenamep, int in_file_count,
pdh = wtap_dump_fdopen_ng(out_fd, file_type,
selected_frame_type,
merge_max_snapshot_length(in_file_count, in_files),
- FALSE /* compressed */, shb_hdr, idb_inf /* wtapng_iface_descriptions_t *idb_inf */, &open_err);
+ FALSE /* compressed */, shb_hdr, idb_inf /* wtapng_iface_descriptions_t *idb_inf */,
+ NULL, &open_err);
if (pdh == NULL) {
ws_close(out_fd);
@@ -4671,12 +4675,15 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
or moving the capture file, we have to do it by writing the packets
out in Wiretap. */
- wtapng_section_t *shb_hdr = NULL;
+ wtapng_section_t *shb_hdr = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
+ wtapng_name_res_t *nrb_hdr = NULL;
int encap;
+ /* XXX: what free's this shb_hdr? */
shb_hdr = wtap_file_get_shb_info(cf->wth);
idb_inf = wtap_file_get_idb_info(cf->wth);
+ nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
/* Determine what file encapsulation type we should use. */
encap = wtap_dump_file_encap_type(cf->linktypes);
@@ -4691,10 +4698,10 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
from which we're reading the packets that we're writing!) */
fname_new = g_strdup_printf("%s~", fname);
pdh = wtap_dump_open_ng(fname_new, save_format, encap, cf->snap,
- compressed, shb_hdr, idb_inf, &err);
+ compressed, shb_hdr, idb_inf, nrb_hdr, &err);
} else {
pdh = wtap_dump_open_ng(fname, save_format, encap, cf->snap,
- compressed, shb_hdr, idb_inf, &err);
+ compressed, shb_hdr, idb_inf, nrb_hdr, &err);
}
g_free(idb_inf);
idb_inf = NULL;
@@ -4891,8 +4898,9 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
int err;
wtap_dumper *pdh;
save_callback_args_t callback_args;
- wtapng_section_t *shb_hdr;
- wtapng_iface_descriptions_t *idb_inf;
+ wtapng_section_t *shb_hdr = NULL;
+ wtapng_iface_descriptions_t *idb_inf = NULL;
+ wtapng_name_res_t *nrb_hdr = NULL;
int encap;
cf_callback_invoke(cf_cb_file_export_specified_packets_started, (gpointer)fname);
@@ -4904,8 +4912,10 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
written, don't special-case the operation - read each packet
and then write it out if it's one of the specified ones. */
+ /* XXX: what free's this shb_hdr? */
shb_hdr = wtap_file_get_shb_info(cf->wth);
idb_inf = wtap_file_get_idb_info(cf->wth);
+ nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
/* Determine what file encapsulation type we should use. */
encap = wtap_dump_file_encap_type(cf->linktypes);
@@ -4920,10 +4930,10 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
from which we're reading the packets that we're writing!) */
fname_new = g_strdup_printf("%s~", fname);
pdh = wtap_dump_open_ng(fname_new, save_format, encap, cf->snap,
- compressed, shb_hdr, idb_inf, &err);
+ compressed, shb_hdr, idb_inf, nrb_hdr, &err);
} else {
pdh = wtap_dump_open_ng(fname, save_format, encap, cf->snap,
- compressed, shb_hdr, idb_inf, &err);
+ compressed, shb_hdr, idb_inf, nrb_hdr, &err);
}
g_free(idb_inf);
idb_inf = NULL;