summaryrefslogtreecommitdiff
path: root/wiretap/wtap.c
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 /wiretap/wtap.c
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>
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r--wiretap/wtap.c34
1 files changed, 23 insertions, 11 deletions
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);