diff options
author | Hadriel Kaplan <hadrielk@yahoo.com> | 2015-07-20 11:09:06 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-08-18 05:52:45 +0000 |
commit | e25562baddd7a675510daea9bb6a6e4ab36b2d68 (patch) | |
tree | 2338173d5f211716b8004c915ee92713d197c1b1 /wiretap/wtap.c | |
parent | 4048ca0a27b7ed693b91103ed6912a4a1abfa3db (diff) | |
download | wireshark-e25562baddd7a675510daea9bb6a6e4ab36b2d68.tar.gz |
Pcapng: clean up Section Header Block handling
Change-Id: I8516d0c561ed0b63e49a3594027c9c15bb789258
Reviewed-on: https://code.wireshark.org/review/9726
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
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.c | 46 |
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); |