summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-06-01 10:11:46 -0400
committerMichael Mann <mmann78@netscape.net>2016-06-01 22:58:06 +0000
commit614d09af132be967b89103efb85721fa043929c9 (patch)
tree2be3f9f0b52f80b40fd3bb98ced1c3251ac95af9
parentdcf7ac4aa6e2c4fe64d8d81ab628a98ecb4e66bb (diff)
downloadwireshark-614d09af132be967b89103efb85721fa043929c9.tar.gz
Add data structures necessary to support multiple Name Resolution blocks.
This doesn't try to use any data from multiple Name Resolution blocks, it just converts single Name Resolution block usage into a GArray, so the potential is there to then use/support multiple Name Resolution blocks within a file format (like pcapng) Change-Id: Ib0b584af0bd263f183bd6d31ba18275ab0577d0c Reviewed-on: https://code.wireshark.org/review/15684 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--editcap.c24
-rw-r--r--file.c16
-rw-r--r--reordercap.c14
-rw-r--r--tshark.c14
-rw-r--r--wiretap/file_access.c20
-rw-r--r--wiretap/pcapng.c4
-rw-r--r--wiretap/wtap-int.h4
-rw-r--r--wiretap/wtap.c34
-rw-r--r--wiretap/wtap.h20
9 files changed, 81 insertions, 69 deletions
diff --git a/editcap.c b/editcap.c
index efb04bbb3d..4da0b11a01 100644
--- a/editcap.c
+++ b/editcap.c
@@ -907,7 +907,7 @@ static wtap_dumper *
editcap_dump_open(const char *filename, guint32 snaplen,
GArray* shb_hdrs,
wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *write_err)
+ GArray* nrb_hdrs, int *write_err)
{
wtap_dumper *pdh;
@@ -915,11 +915,11 @@ editcap_dump_open(const char *filename, guint32 snaplen,
/* Write to the standard output. */
pdh = wtap_dump_open_stdout_ng(out_file_type_subtype, out_frame_type,
snaplen, FALSE /* compressed */,
- shb_hdrs, idb_inf, nrb_hdr, write_err);
+ shb_hdrs, idb_inf, nrb_hdrs, write_err);
} else {
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
snaplen, FALSE /* compressed */,
- shb_hdrs, idb_inf, nrb_hdr, write_err);
+ shb_hdrs, idb_inf, nrb_hdrs, write_err);
}
return pdh;
}
@@ -966,7 +966,7 @@ main(int argc, char *argv[])
struct wtap_pkthdr temp_phdr;
wtapng_iface_descriptions_t *idb_inf = NULL;
GArray *shb_hdrs = NULL;
- wtap_optionblock_t nrb_hdr = NULL;
+ GArray *nrb_hdrs = NULL;
char *shb_user_appl;
#ifdef HAVE_PLUGINS
@@ -1330,7 +1330,7 @@ main(int argc, char *argv[])
shb_hdrs = wtap_file_get_shb_for_new_file(wth);
idb_inf = wtap_file_get_idb_info(wth);
- nrb_hdr = wtap_file_get_nrb_for_new_file(wth);
+ nrb_hdrs = wtap_file_get_nrb_for_new_file(wth);
/*
* Now, process the rest, if any ... we only write if there is an extra
@@ -1385,7 +1385,7 @@ main(int argc, char *argv[])
pdh = editcap_dump_open(filename,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
- shb_hdrs, idb_inf, nrb_hdr, &write_err);
+ shb_hdrs, idb_inf, nrb_hdrs, &write_err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
@@ -1426,7 +1426,7 @@ main(int argc, char *argv[])
pdh = editcap_dump_open(filename,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
- shb_hdrs, idb_inf, nrb_hdr, &write_err);
+ shb_hdrs, idb_inf, nrb_hdrs, &write_err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
@@ -1455,7 +1455,7 @@ main(int argc, char *argv[])
pdh = editcap_dump_open(filename,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
- shb_hdrs, idb_inf, nrb_hdr, &write_err);
+ shb_hdrs, idb_inf, nrb_hdrs, &write_err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(write_err));
@@ -1826,7 +1826,7 @@ main(int argc, char *argv[])
pdh = editcap_dump_open(filename,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)): wtap_snapshot_length(wth),
- shb_hdrs, idb_inf, nrb_hdr, &write_err);
+ shb_hdrs, idb_inf, nrb_hdrs, &write_err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(write_err));
@@ -1844,8 +1844,8 @@ main(int argc, char *argv[])
}
wtap_optionblock_array_free(shb_hdrs);
shb_hdrs = NULL;
- wtap_optionblock_free(nrb_hdr);
- nrb_hdr = NULL;
+ wtap_optionblock_array_free(nrb_hdrs);
+ nrb_hdrs = NULL;
g_free(filename);
if (frames_user_comments) {
@@ -1869,7 +1869,7 @@ main(int argc, char *argv[])
error_on_exit:
wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_free(nrb_hdr);
+ wtap_optionblock_array_free(nrb_hdrs);
g_free(idb_inf);
exit(2);
}
diff --git a/file.c b/file.c
index 907b43f872..393fc5ed02 100644
--- a/file.c
+++ b/file.c
@@ -4491,13 +4491,13 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
- wtap_optionblock_t nrb_hdr = NULL;
+ GArray *nrb_hdrs = NULL;
int encap;
/* XXX: what free's this shb_hdr? */
shb_hdrs = wtap_file_get_shb_for_new_file(cf->wth);
idb_inf = wtap_file_get_idb_info(cf->wth);
- nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
+ nrb_hdrs = 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);
@@ -4512,10 +4512,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_hdrs, idb_inf, nrb_hdr, &err);
+ compressed, shb_hdrs, idb_inf, nrb_hdrs, &err);
} else {
pdh = wtap_dump_open_ng(fname, save_format, encap, cf->snap,
- compressed, shb_hdrs, idb_inf, nrb_hdr, &err);
+ compressed, shb_hdrs, idb_inf, nrb_hdrs, &err);
}
g_free(idb_inf);
idb_inf = NULL;
@@ -4714,7 +4714,7 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
save_callback_args_t callback_args;
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
- wtap_optionblock_t nrb_hdr = NULL;
+ GArray *nrb_hdrs = NULL;
int encap;
cf_callback_invoke(cf_cb_file_export_specified_packets_started, (gpointer)fname);
@@ -4729,7 +4729,7 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
/* XXX: what free's this shb_hdr? */
shb_hdrs = wtap_file_get_shb_for_new_file(cf->wth);
idb_inf = wtap_file_get_idb_info(cf->wth);
- nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
+ nrb_hdrs = 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);
@@ -4744,10 +4744,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_hdrs, idb_inf, nrb_hdr, &err);
+ compressed, shb_hdrs, idb_inf, nrb_hdrs, &err);
} else {
pdh = wtap_dump_open_ng(fname, save_format, encap, cf->snap,
- compressed, shb_hdrs, idb_inf, nrb_hdr, &err);
+ compressed, shb_hdrs, idb_inf, nrb_hdrs, &err);
}
g_free(idb_inf);
idb_inf = NULL;
diff --git a/reordercap.c b/reordercap.c
index 38c1db57ea..ae1e013320 100644
--- a/reordercap.c
+++ b/reordercap.c
@@ -180,7 +180,7 @@ main(int argc, char *argv[])
guint i;
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
- wtap_optionblock_t nrb_hdr = NULL;
+ GArray *nrb_hdrs = NULL;
GPtrArray *frames;
FrameRecord_t *prevFrame = NULL;
@@ -291,16 +291,16 @@ main(int argc, char *argv[])
shb_hdrs = wtap_file_get_shb_for_new_file(wth);
idb_inf = wtap_file_get_idb_info(wth);
- nrb_hdr = wtap_file_get_nrb_for_new_file(wth);
+ nrb_hdrs = wtap_file_get_nrb_for_new_file(wth);
/* Open outfile (same filetype/encap as input file) */
if (strcmp(outfile, "-") == 0) {
pdh = wtap_dump_open_stdout_ng(wtap_file_type_subtype(wth), wtap_file_encap(wth),
- 65535, FALSE, shb_hdrs, idb_inf, nrb_hdr, &err);
+ 65535, FALSE, shb_hdrs, idb_inf, nrb_hdrs, &err);
outfile = "standard output";
} else {
pdh = wtap_dump_open_ng(outfile, wtap_file_type_subtype(wth), wtap_file_encap(wth),
- 65535, FALSE, shb_hdrs, idb_inf, nrb_hdr, &err);
+ 65535, FALSE, shb_hdrs, idb_inf, nrb_hdrs, &err);
}
g_free(idb_inf);
idb_inf = NULL;
@@ -309,7 +309,7 @@ main(int argc, char *argv[])
fprintf(stderr, "reordercap: Failed to open output file: (%s) - error %s\n",
outfile, wtap_strerror(err));
wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_free(nrb_hdr);
+ wtap_optionblock_array_free(nrb_hdrs);
exit(1);
}
@@ -383,11 +383,11 @@ main(int argc, char *argv[])
fprintf(stderr, "reordercap: Error closing %s: %s\n", outfile,
wtap_strerror(err));
wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_free(nrb_hdr);
+ wtap_optionblock_array_free(nrb_hdrs);
exit(1);
}
wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_free(nrb_hdr);
+ wtap_optionblock_array_free(nrb_hdrs);
/* Finally, close infile */
wtap_fdclose(wth);
diff --git a/tshark.c b/tshark.c
index 435db0336d..96f1555678 100644
--- a/tshark.c
+++ b/tshark.c
@@ -3235,7 +3235,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
guint tap_flags;
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
- wtap_optionblock_t nrb_hdr = NULL;
+ GArray *nrb_hdrs = NULL;
struct wtap_pkthdr phdr;
Buffer buf;
epan_dissect_t *edt = NULL;
@@ -3266,7 +3266,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
tshark_debug("tshark: snapshot_length = %d", snapshot_length);
shb_hdrs = wtap_file_get_shb_for_new_file(cf->wth);
- nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
+ nrb_hdrs = wtap_file_get_nrb_for_new_file(cf->wth);
/* If we don't have an application name add Tshark */
wtap_optionblock_get_option_string(g_array_index(shb_hdrs, wtap_optionblock_t, 0), OPT_SHB_USERAPPL, &shb_user_appl);
@@ -3292,10 +3292,10 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
if (strcmp(save_file, "-") == 0) {
/* Write to the standard output. */
pdh = wtap_dump_open_stdout_ng(out_file_type, linktype,
- snapshot_length, FALSE /* compressed */, shb_hdrs, idb_inf, nrb_hdr, &err);
+ snapshot_length, FALSE /* compressed */, shb_hdrs, idb_inf, nrb_hdrs, &err);
} else {
pdh = wtap_dump_open_ng(save_file, out_file_type, linktype,
- snapshot_length, FALSE /* compressed */, shb_hdrs, idb_inf, nrb_hdr, &err);
+ snapshot_length, FALSE /* compressed */, shb_hdrs, idb_inf, nrb_hdrs, &err);
}
}
@@ -3514,7 +3514,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
}
wtap_dump_close(pdh, &err);
wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_free(nrb_hdr);
+ wtap_optionblock_array_free(nrb_hdrs);
exit(2);
}
}
@@ -3629,7 +3629,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
}
wtap_dump_close(pdh, &err);
wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_free(nrb_hdr);
+ wtap_optionblock_array_free(nrb_hdrs);
exit(2);
}
}
@@ -3746,7 +3746,7 @@ out:
g_free(save_file_string);
wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_free(nrb_hdr);
+ wtap_optionblock_array_free(nrb_hdrs);
return err;
}
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 2628687968..ff2200bd2d 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -2163,7 +2163,7 @@ static int wtap_dump_file_close(wtap_dumper *wdh);
static wtap_dumper *
wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean compressed,
GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ GArray* nrb_hdrs, int *err)
{
wtap_dumper *wdh;
wtap_optionblock_t descr, file_int_data;
@@ -2182,7 +2182,7 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
/* Set Section Header Block data */
wdh->shb_hdrs = shb_hdrs;
/* Set Name Resolution Block data */
- wdh->nrb_hdr = nrb_hdr;
+ wdh->nrb_hdrs = nrb_hdrs;
/* Set Interface Description Block data */
if ((idb_inf != NULL) && (idb_inf->interface_data->len > 0)) {
guint itf_count;
@@ -2229,14 +2229,14 @@ wtap_dump_open(const char *filename, int file_type_subtype, int encap,
wtap_dumper *
wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
int snaplen, gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ GArray* nrb_hdrs, int *err)
{
wtap_dumper *wdh;
WFILE_T fh;
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
- shb_hdrs, idb_inf, nrb_hdr, err);
+ shb_hdrs, idb_inf, nrb_hdrs, err);
if (wdh == NULL)
return NULL;
@@ -2276,7 +2276,7 @@ wtap_dump_open_tempfile_ng(char **filenamep, const char *pfx,
int snaplen, gboolean compressed,
GArray* shb_hdrs,
wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ GArray* nrb_hdrs, int *err)
{
int fd;
char *tmpname;
@@ -2288,7 +2288,7 @@ wtap_dump_open_tempfile_ng(char **filenamep, const char *pfx,
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
- shb_hdrs, idb_inf, nrb_hdr, err);
+ shb_hdrs, idb_inf, nrb_hdrs, err);
if (wdh == NULL)
return NULL;
@@ -2334,14 +2334,14 @@ wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snaplen,
wtap_dumper *
wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ GArray* nrb_hdrs, int *err)
{
wtap_dumper *wdh;
WFILE_T fh;
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
- shb_hdrs, idb_inf, nrb_hdr, err);
+ shb_hdrs, idb_inf, nrb_hdrs, err);
if (wdh == NULL)
return NULL;
@@ -2375,14 +2375,14 @@ wtap_dumper *
wtap_dump_open_stdout_ng(int file_type_subtype, int encap, int snaplen,
gboolean compressed, GArray* shb_hdrs,
wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err)
+ GArray* nrb_hdrs, int *err)
{
wtap_dumper *wdh;
WFILE_T fh;
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
- shb_hdrs, idb_inf, nrb_hdr, err);
+ shb_hdrs, idb_inf, nrb_hdrs, err);
if (wdh == NULL)
return NULL;
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 464cae763e..4ff3afeaa2 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -3260,12 +3260,12 @@ pcapng_write_name_resolution_block(wtap_dumper *wdh, int *err)
}
/* add options, if any */
- if (wdh->nrb_hdr) {
+ if (wdh->nrb_hdrs && wdh->nrb_hdrs->len > 0) {
gboolean have_options = FALSE;
guint32 options_total_length = 0;
struct option option_hdr;
guint32 comment_len = 0, comment_pad_len = 0;
- wtap_optionblock_t nrb_hdr = wdh->nrb_hdr;
+ wtap_optionblock_t nrb_hdr = g_array_index(wdh->nrb_hdrs, wtap_optionblock_t, 0);
guint32 prev_rec_off = rec_off;
char* opt_comment;
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index 55512dc908..bf3feae6f3 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -53,7 +53,7 @@ struct wtap {
struct wtap_pkthdr phdr;
GArray *shb_hdrs;
GArray *interface_data; /**< An array holding the interface data from pcapng IDB:s or equivalent(?)*/
- wtap_optionblock_t nrb_hdr; /**< holds the Name Res Block's comment/custom_opts, or NULL */
+ GArray *nrb_hdrs; /**< holds the Name Res Block's comment/custom_opts, or NULL */
void *priv; /* this one holds per-file state and is free'd automatically by wtap_close() */
void *wslua_data; /* this one holds wslua state info and is not free'd */
@@ -115,7 +115,7 @@ struct wtap_dumper {
*/
addrinfo_lists_t *addrinfo_lists; /**< Struct containing lists of resolved addresses */
GArray *shb_hdrs;
- wtap_optionblock_t nrb_hdr; /**< name resolution comment/custom_opt, or NULL */
+ GArray *nrb_hdrs; /**< name resolution comment/custom_opt, or NULL */
GArray *interface_data; /**< An array holding the interface data from pcapng IDB:s or equivalent(?) NULL if not present.*/
};
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index c77c19fa49..77511f7039 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -209,26 +209,29 @@ wtap_get_nrb_comment(wtap *wth)
char* opt_comment;
g_assert(wth);
- if ((wth == NULL) || (wth->nrb_hdr == NULL))
+ if ((wth == NULL) || (wth->nrb_hdrs == NULL) || (wth->nrb_hdrs->len == 0))
return NULL;
- wtap_optionblock_get_option_string(wth->nrb_hdr, OPT_COMMENT, &opt_comment);
+ wtap_optionblock_get_option_string(g_array_index(wth->nrb_hdrs, wtap_optionblock_t, 0), OPT_COMMENT, &opt_comment);
return opt_comment;
}
void
wtap_write_nrb_comment(wtap *wth, gchar *comment)
{
+ wtap_optionblock_t nrb;
g_assert(wth);
if (wth == NULL)
return;
- if (wth->nrb_hdr == NULL) {
- wth->nrb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_NRB);
+ if (wth->nrb_hdrs == NULL) {
+ wth->nrb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
+ nrb = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_NRB);
+ g_array_append_val(wth->nrb_hdrs, nrb);
}
- wtap_optionblock_set_option_string(wth->nrb_hdr, OPT_COMMENT, comment, (gsize)(comment ? strlen(comment) : 0));
+ wtap_optionblock_set_option_string(g_array_index(wth->nrb_hdrs, wtap_optionblock_t, 0), OPT_COMMENT, comment, (gsize)(comment ? strlen(comment) : 0));
}
void
@@ -363,18 +366,26 @@ wtap_get_debug_if_descr(const wtap_optionblock_t if_descr,
return g_string_free(info, FALSE);
}
-wtap_optionblock_t
+GArray*
wtap_file_get_nrb_for_new_file(wtap *wth)
{
- wtap_optionblock_t nrb_hdr;
+ guint nrb_count;
+ wtap_optionblock_t nrb_hdr_src, nrb_hdr_dest;
+ GArray* nrb_hdrs;
- if (wth == NULL || wth->nrb_hdr == NULL)
+ if ((wth == NULL || wth->nrb_hdrs == NULL) || (wth->nrb_hdrs->len == 0))
return NULL;
- nrb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_NRB);
+ nrb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
+
+ for (nrb_count = 0; nrb_count < wth->nrb_hdrs->len; nrb_count++) {
+ nrb_hdr_src = g_array_index(wth->nrb_hdrs, wtap_optionblock_t, nrb_count);
+ nrb_hdr_dest = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_NRB);
+ wtap_optionblock_copy_options(nrb_hdr_dest, nrb_hdr_src);
+ g_array_append_val(nrb_hdrs, nrb_hdr_dest);
+ }
- wtap_optionblock_copy_options(nrb_hdr, wth->nrb_hdr);
- return nrb_hdr;
+ return nrb_hdrs;
}
/* Table of the encapsulation types we know about. */
@@ -1197,6 +1208,7 @@ wtap_close(wtap *wth)
}
wtap_optionblock_array_free(wth->shb_hdrs);
+ wtap_optionblock_array_free(wth->nrb_hdrs);
wtap_optionblock_array_free(wth->interface_data);
g_free(wth);
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 332c57db50..2a4d3ddb0a 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1685,10 +1685,10 @@ gchar *wtap_get_debug_if_descr(const wtap_optionblock_t if_descr,
* @note Use wtap_free_nrb() to free the returned pointer.
*
* @param wth The wiretap session.
- * @return The new name resolution info, which must be wtap_optionblock_free'd.
+ * @return The new name resolution info, which must be freed.
*/
WS_DLL_PUBLIC
-wtap_optionblock_t wtap_file_get_nrb_for_new_file(wtap *wth);
+GArray* wtap_file_get_nrb_for_new_file(wtap *wth);
/**
* @brief Gets the name resolution comment, if any.
@@ -1778,14 +1778,14 @@ wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype, int enc
* @param compressed True if file should be compressed.
* @param shb_hdrs The section header block(s) information, or NULL.
* @param idb_inf The interface description information, or NULL.
- * @param nrb_hdr The name resolution comment/custom_opts information, or NULL.
+ * @param nrb_hdrs The name resolution blocks(s) comment/custom_opts information, or NULL.
* @param[out] err Will be set to an error code on failure.
* @return The newly created dumper object, or NULL on failure.
*/
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
int snaplen, gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err);
+ GArray* nrb_hdrs, int *err);
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_tempfile(char **filenamep, const char *pfx,
@@ -1808,7 +1808,7 @@ wtap_dumper* wtap_dump_open_tempfile(char **filenamep, const char *pfx,
* @param compressed True if file should be compressed.
* @param shb_hdrs The section header block(s) information, or NULL.
* @param idb_inf The interface description information, or NULL.
- * @param nrb_hdr The name resolution comment/custom_opts information, or NULL.
+ * @param nrb_hdrs The name resolution blocks(s) comment/custom_opts information, or NULL.
* @param[out] err Will be set to an error code on failure.
* @return The newly created dumper object, or NULL on failure.
*/
@@ -1816,7 +1816,7 @@ WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_tempfile_ng(char **filenamep, const char *pfx,
int file_type_subtype, int encap, int snaplen, gboolean compressed,
GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err);
+ GArray* nrb_hdrs, int *err);
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snaplen,
@@ -1836,14 +1836,14 @@ wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snap
* @param compressed True if file should be compressed.
* @param shb_hdrs The section header block(s) information, or NULL.
* @param idb_inf The interface description information, or NULL.
- * @param nrb_hdr The name resolution comment/custom_opts information, or NULL.
+ * @param nrb_hdrs The name resolution blocks(s) comment/custom_opts information, or NULL.
* @param[out] err Will be set to an error code on failure.
* @return The newly created dumper object, or NULL on failure.
*/
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err);
+ GArray* nrb_hdrs, int *err);
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_stdout(int file_type_subtype, int encap, int snaplen,
@@ -1862,14 +1862,14 @@ wtap_dumper* wtap_dump_open_stdout(int file_type_subtype, int encap, int snaplen
* @param compressed True if file should be compressed.
* @param shb_hdrs The section header block(s) information, or NULL.
* @param idb_inf The interface description information, or NULL.
- * @param nrb_hdr The name resolution comment/custom_opts information, or NULL.
+ * @param nrb_hdrs The name resolution blocks(s) comment/custom_opts information, or NULL.
* @param[out] err Will be set to an error code on failure.
* @return The newly created dumper object, or NULL on failure.
*/
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_stdout_ng(int file_type_subtype, int encap, int snaplen,
gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
- wtap_optionblock_t nrb_hdr, int *err);
+ GArray* nrb_hdrs, int *err);
WS_DLL_PUBLIC
gboolean wtap_dump(wtap_dumper *, const struct wtap_pkthdr *, const guint8 *,