diff options
author | Anders Broman <anders.broman@ericsson.com> | 2012-03-15 13:46:42 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2012-03-15 13:46:42 +0000 |
commit | dc674a60434c30dfcfb28692bb187e6710157b94 (patch) | |
tree | 8dae696d82040e23c375cba3c03dbafc6e5b6ecc | |
parent | b1a9d50e035a98dd03ed0485f5b090e43403d49d (diff) |
- Store ISB data.
- free IDB and ISB data when closing.
svn path=/trunk/; revision=41558
-rw-r--r-- | wiretap/pcapng.c | 42 | ||||
-rw-r--r-- | wiretap/wtap.c | 37 |
2 files changed, 75 insertions, 4 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 067eb6d5e8..4ea33239cf 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -2128,6 +2128,8 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) pcapng_t *pcapng = (pcapng_t *)wth->priv; int bytes_read; wtapng_block_t wblock; + wtapng_if_descr_t *wtapng_if_descr; + wtapng_if_stats_t if_stats; pcapng_debug1("pcapng_read: wth->data_offset is initially %" G_GINT64_MODIFIER "u", wth->data_offset); *data_offset = wth->data_offset; @@ -2164,11 +2166,43 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) if (wblock.type == BLOCK_TYPE_PB || wblock.type == BLOCK_TYPE_EPB) { break; } + if (wblock.type == BLOCK_TYPE_ISB ){ + pcapng_debug0("pcapng_read: block type BLOCK_TYPE_ISB"); + *data_offset += bytes_read; + pcapng_debug1("pcapng_read: *data_offset is updated to %" G_GINT64_MODIFIER "u", *data_offset); + if(wth->number_of_interfaces < wblock.data.if_stats.interface_id){ + pcapng_debug1("pcapng_read: BLOCK_TYPE_ISB wblock.if_stats.interface_id %u > number_of_interfaces", wblock.data.if_stats.interface_id); + }else{ + /* Get the interface description */ + wtapng_if_descr = &g_array_index(wth->interface_data, wtapng_if_descr_t, wblock.data.if_stats.interface_id); + if(wtapng_if_descr->num_stat_entries == 0){ + /* First ISB found, no previous entry */ + pcapng_debug0("pcapng_read: block type BLOCK_TYPE_ISB. First ISB found, no previous entry"); + wtapng_if_descr->interface_statistics = g_array_new(FALSE, FALSE, sizeof(wtapng_if_stats_t)); + } - /* XXX - improve handling of "unknown" blocks */ - pcapng_debug1("pcapng_read: block type 0x%x not PB/EPB", wblock.type); - *data_offset += bytes_read; - pcapng_debug1("pcapng_read: *data_offset is updated to %" G_GINT64_MODIFIER "u", *data_offset); + if_stats.interface_id = wblock.data.if_stats.interface_id; + if_stats.ts_high = wblock.data.if_stats.ts_high; + if_stats.ts_low = wblock.data.if_stats.ts_low; + /* options */ + if_stats.opt_comment = wblock.data.if_stats.opt_comment; /* NULL if not available */ + if_stats.isb_starttime = wblock.data.if_stats.isb_starttime; + if_stats.isb_endtime = wblock.data.if_stats.isb_endtime; + if_stats.isb_ifrecv = wblock.data.if_stats.isb_ifrecv; + if_stats.isb_ifdrop = wblock.data.if_stats.isb_ifdrop; + if_stats.isb_filteraccept = wblock.data.if_stats.isb_filteraccept; + if_stats.isb_osdrop = wblock.data.if_stats.isb_osdrop; + if_stats.isb_usrdeliv = wblock.data.if_stats.isb_usrdeliv; + + g_array_append_val(wtapng_if_descr->interface_statistics, if_stats); + wtapng_if_descr->num_stat_entries++; + } + }else{ + /* XXX - improve handling of "unknown" blocks */ + pcapng_debug1("pcapng_read: block type 0x%x not PB/EPB", wblock.type); + *data_offset += bytes_read; + pcapng_debug1("pcapng_read: *data_offset is updated to %" G_GINT64_MODIFIER "u", *data_offset); + } } if (wblock.data.packet.interface_id < pcapng->number_of_interfaces) { diff --git a/wiretap/wtap.c b/wiretap/wtap.c index f1f8212ccd..9485ba7c7d 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -718,6 +718,10 @@ g_fast_seek_item_free(gpointer data, gpointer user_data _U_) void wtap_close(wtap *wth) { + gint i; + wtapng_if_descr_t *wtapng_if_descr; + wtapng_if_stats_t *if_stats; + wtap_sequential_close(wth); if (wth->subtype_close != NULL) @@ -733,6 +737,39 @@ wtap_close(wtap *wth) g_ptr_array_foreach(wth->fast_seek, g_fast_seek_item_free, NULL); g_ptr_array_free(wth->fast_seek, TRUE); } + for(i = 0; i < (gint)wth->number_of_interfaces; i++) { + wtapng_if_descr = &g_array_index(wth->interface_data, wtapng_if_descr_t, i); + if(wtapng_if_descr->opt_comment != NULL){ + g_free(wtapng_if_descr->opt_comment); + } + if(wtapng_if_descr->if_name != NULL){ + g_free(wtapng_if_descr->if_name); + } + if(wtapng_if_descr->if_description != NULL){ + g_free(wtapng_if_descr->if_description); + } + if(wtapng_if_descr->if_filter_str != NULL){ + g_free(wtapng_if_descr->if_filter_str); + } + if(wtapng_if_descr->if_filter_bpf_bytes != NULL){ + g_free(wtapng_if_descr->if_filter_bpf_bytes); + } + if(wtapng_if_descr->if_os != NULL){ + g_free(wtapng_if_descr->if_os); + } + for(i = 0; i < (gint)wtapng_if_descr->num_stat_entries; i++) { + if_stats = &g_array_index(wtapng_if_descr->interface_statistics, wtapng_if_stats_t, i); + if(if_stats->opt_comment != NULL){ + g_free(if_stats->opt_comment); + } + } + if(wtapng_if_descr->num_stat_entries != 0){ + g_array_free(wtapng_if_descr->interface_statistics, TRUE); + } + } + if(wth->number_of_interfaces != 0){ + g_array_free(wth->interface_data, TRUE); + } g_free(wth); } |