diff options
author | David Perry <boolean263@protonmail.com> | 2021-04-29 07:23:21 -0400 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-07-07 18:40:24 +0000 |
commit | 73087d6fb486a61e8eb0886a02e6c6403534fa36 (patch) | |
tree | 2cee7a922a2225628103bb247818a8bb2db133b3 /wiretap/wtap.c | |
parent | 20f38c06eab3f9a995468141cdfb14ec821a6503 (diff) |
Use wtap_blocks for packet comments
Mostly functioning proof of concept for #14329. This work is intended to
allow Wireshark to support multiple packet comments per packet.
Uses and expands upon the `wtap_block` API in `wiretap/wtap_opttypes.h`.
It attaches a `wtap_block` structure to `wtap_rec` in place of its
current `opt_comment` and `packet_verdict` members to hold OPT_COMMENT
and OPT_PKT_VERDICT option values.
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r-- | wiretap/wtap.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c index e77525c182..b69f1ac47e 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1499,6 +1499,7 @@ wtapng_process_dsb(wtap *wth, wtap_block_t dsb) wth->add_new_secrets(dsb_mand->secrets_type, dsb_mand->secrets_data, dsb_mand->secrets_len); } +/* Perform per-packet initialization */ static void wtap_init_rec(wtap *wth, wtap_rec *rec) { @@ -1514,6 +1515,8 @@ wtap_init_rec(wtap *wth, wtap_rec *rec) */ rec->rec_header.packet_header.pkt_encap = wth->file_encap; rec->tsprec = wth->file_tsprec; + rec->block = NULL; + rec->has_block_changed = FALSE; } gboolean @@ -1654,35 +1657,26 @@ wtap_read_so_far(wtap *wth) return file_tell_raw(wth->fh); } +/* Perform global/initial initialization */ void wtap_rec_init(wtap_rec *rec) { memset(rec, 0, sizeof *rec); ws_buffer_init(&rec->options_buf, 0); + /* In the future, see if we can create rec->block here once + * and have it be reused like the rest of rec. + * Currently it's recreated for each packet. + */ } +/* clean up record metadata */ void wtap_rec_cleanup(wtap_rec *rec) { - wtap_option_t option; - guint i; - - g_free(rec->opt_comment); - rec->opt_comment = NULL; + wtap_block_unref(rec->block); + rec->block = NULL; + rec->has_block_changed = FALSE; ws_buffer_free(&rec->options_buf); - if (rec->packet_verdict != NULL) { - g_ptr_array_free(rec->packet_verdict, TRUE); - rec->packet_verdict = NULL; - } - if (rec->custom_options != NULL) { - for (i = 0; i < rec->custom_options->len; i++) { - option = g_array_index(rec->custom_options, wtap_option_t, i); - g_free(option.value.custom_opt.custom_data); - option.value.custom_opt.custom_data = NULL; - } - g_array_free(rec->custom_options, TRUE); - rec->custom_options = NULL; - } } gboolean |