summaryrefslogtreecommitdiff
path: root/wiretap/wtap.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r--wiretap/wtap.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 02ca1780a4..e5a6af7021 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -167,21 +167,32 @@ wtap_file_tsprec(wtap *wth)
return wth->file_tsprec;
}
+const gchar *
+wtap_file_get_shb_comment(wtap *wth)
+{
+ return wth ? wth->shb_hdr.opt_comment : NULL;
+}
+
+const wtapng_section_t *
+wtap_file_get_shb(wtap *wth)
+{
+ return wth ? &(wth->shb_hdr) : NULL;
+}
+
wtapng_section_t *
-wtap_file_get_shb_info(wtap *wth)
+wtap_file_get_shb_for_new_file(wtap *wth)
{
- wtapng_section_t *shb_hdr;
+ wtapng_section_t *shb_hdr;
- if(wth == NULL)
- return NULL;
- shb_hdr = g_new(wtapng_section_t,1);
- shb_hdr->section_length = wth->shb_hdr.section_length;
- /* options */
- shb_hdr->opt_comment = wth->shb_hdr.opt_comment; /* NULL if not available */
- shb_hdr->shb_hardware = wth->shb_hdr.shb_hardware; /* NULL if not available, UTF-8 string containing the description of the hardware used to create this section. */
- shb_hdr->shb_os = wth->shb_hdr.shb_os; /* NULL if not available, UTF-8 string containing the name of the operating system used to create this section. */
- shb_hdr->shb_user_appl = wth->shb_hdr.shb_user_appl; /* NULL if not available, UTF-8 string containing the name of the application used to create this section. */
+ if (wth == NULL)
+ return NULL;
+
+ shb_hdr = g_new0(wtapng_section_t,1);
+ shb_hdr->section_length = -1;
+ /* options */
+ shb_hdr->opt_comment = g_strdup(wth->shb_hdr.opt_comment);
+ /* the rest of the options remain NULL */
return shb_hdr;
}
@@ -220,6 +231,19 @@ wtap_write_nrb_comment(wtap *wth, gchar *comment)
}
void
+wtap_free_shb(wtapng_section_t *shb_hdr)
+{
+ if (shb_hdr == NULL)
+ return;
+
+ g_free(shb_hdr->opt_comment);
+ g_free(shb_hdr->shb_hardware);
+ g_free(shb_hdr->shb_os);
+ g_free(shb_hdr->shb_user_appl);
+ g_free(shb_hdr);
+}
+
+void
wtap_write_shb_comment(wtap *wth, gchar *comment)
{
g_free(wth->shb_hdr.opt_comment);