aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap.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 /wiretap/wtap.c
parent1420f3df6376f45157b7f363c6c07da3a9ac6f29 (diff)
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 'wiretap/wtap.c')
-rw-r--r--wiretap/wtap.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 897f0944cb..02ca1780a4 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -186,6 +186,39 @@ wtap_file_get_shb_info(wtap *wth)
return shb_hdr;
}
+const gchar*
+wtap_get_nrb_comment(wtap *wth)
+{
+ g_assert(wth);
+
+ if (wth == NULL)
+ return NULL;
+
+ return wth->nrb_hdr ? wth->nrb_hdr->opt_comment : NULL;
+}
+
+void
+wtap_write_nrb_comment(wtap *wth, gchar *comment)
+{
+ g_assert(wth);
+
+ if (wth == NULL)
+ return;
+
+ if (wth->nrb_hdr == NULL) {
+ wth->nrb_hdr = g_new0(wtapng_name_res_t,1);
+ } else {
+ g_free(wth->nrb_hdr->opt_comment);
+ }
+
+ /*
+ * I'd prefer this function duplicate the passed-in comment,
+ * but wtap_write_shb_comment() assumes the caller duplicated
+ * it so we'll stick with that.
+ */
+ wth->nrb_hdr->opt_comment = comment;
+}
+
void
wtap_write_shb_comment(wtap *wth, gchar *comment)
{
@@ -206,6 +239,32 @@ wtap_file_get_idb_info(wtap *wth)
return idb_info;
}
+wtapng_name_res_t *
+wtap_file_get_nrb_for_new_file(wtap *wth)
+{
+ wtapng_name_res_t *nrb_hdr;
+
+ if (wth == NULL || wth->nrb_hdr == NULL)
+ return NULL;
+
+ nrb_hdr = g_new0(wtapng_name_res_t,1);
+
+ nrb_hdr->opt_comment = g_strdup(wth->nrb_hdr->opt_comment);
+
+ return nrb_hdr;
+}
+
+void
+wtap_free_nrb(wtapng_name_res_t *nrb_hdr)
+{
+ if (nrb_hdr == NULL)
+ return;
+
+ g_free(nrb_hdr->opt_comment);
+ g_free(nrb_hdr);
+}
+
+
/* Table of the encapsulation types we know about. */
struct encap_type_info {
const char *name;