diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-11-30 16:30:19 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-12-01 00:31:03 +0000 |
commit | 846bb5394812c39359dfdbbf7e8755a7e3cf5326 (patch) | |
tree | 70dcf5a08a04abe66c1ef766ce15c634e87a6cf2 /file.c | |
parent | 35b1bc5ec61260bc1890a2c991cdb7218946ae1f (diff) | |
download | wireshark-846bb5394812c39359dfdbbf7e8755a7e3cf5326.tar.gz |
Add a Buffer to wtap_pkthdr to hold file-type-specific packet metadata.
For example, this can be used for pcap-ng options not mapped to
file-type-independent metadata values.
Change-Id: I398b324c62c1cc1cc61eb5e9631de00481b4aadc
Reviewed-on: https://code.wireshark.org/review/5549
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -310,6 +310,9 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp and fill in the information for this file. */ cf_close(cf); + /* Initialize the packet header. */ + wtap_phdr_init(&cf->phdr); + /* XXX - we really want to initialize this after we've read all the packets, so we know how much we'll ultimately need. */ ws_buffer_init(&cf->buf, 1500); @@ -436,6 +439,9 @@ cf_close(capture_file *cf) /* no open_routine type */ cf->open_type = WTAP_TYPE_AUTO; + /* Clean up the packet header. */ + wtap_phdr_cleanup(&cf->phdr); + /* Free up the packet buffer. */ ws_buffer_free(&cf->buf); @@ -2192,7 +2198,7 @@ process_specified_records(capture_file *cf, packet_range_t *range, range_process_e process_this; struct wtap_pkthdr phdr; - memset(&phdr, 0, sizeof(struct wtap_pkthdr)); + wtap_phdr_init(&phdr); ws_buffer_init(&buf, 1500); /* Update the progress bar when it gets to this value. */ @@ -2290,6 +2296,7 @@ process_specified_records(capture_file *cf, packet_range_t *range, if (progbar != NULL) destroy_progress_dlg(progbar); + wtap_phdr_cleanup(&phdr); ws_buffer_free(&buf); return ret; @@ -3942,6 +3949,8 @@ cf_get_user_packet_comment(capture_file *cf, const frame_data *fd) char * cf_get_comment(capture_file *cf, const frame_data *fd) { + char *comment; + /* fetch user comment */ if (fd->flags.has_user_comment) return g_strdup(cf_get_user_packet_comment(cf, fd)); @@ -3951,14 +3960,16 @@ cf_get_comment(capture_file *cf, const frame_data *fd) struct wtap_pkthdr phdr; /* Packet header */ Buffer buf; /* Packet data */ - memset(&phdr, 0, sizeof(struct wtap_pkthdr)); - + wtap_phdr_init(&phdr); ws_buffer_init(&buf, 1500); + if (!cf_read_record_r(cf, fd, &phdr, &buf)) { /* XXX, what we can do here? */ } + comment = phdr.opt_comment; + wtap_phdr_cleanup(&phdr); ws_buffer_free(&buf); - return phdr.opt_comment; + return comment; } return NULL; } |