capinfos: Fix count of IP address and decryption secrets

When opening a file offline, pcapng will read initial non packet
blocks in order to try to find the first interface, to try to
support conversion to file types only support one link layer type
and need to know it to set in the initial header.
(0d2a2d3777)

This means that initial NRBs and DSBs can already be processed
when the ipv4 and secrets callbacks are added. Wiretap ensures
that the callbacks are called for any NRBs (c65d5a0a80)
and DSBs (e8f9ac3352) that have
already been read when the callbacks are added. So far so good.

However, this means that capinfos needs to zero out the counters
*before* adding the callbacks, not afterwards.
This commit is contained in:
John Thacker 2023-11-01 21:01:52 -04:00
parent a3fd4fd25b
commit afdbc17b96
1 changed files with 5 additions and 5 deletions

View File

@ -1144,17 +1144,17 @@ process_cap_file(const char *filename, gboolean need_separator)
g_free(idb_info);
idb_info = NULL;
/* Zero out the counters for the callbacks. */
num_ipv4_addresses = 0;
num_ipv6_addresses = 0;
num_decryption_secrets = 0;
/* Register callbacks for new name<->address maps from the file and
decryption secrets from the file. */
wtap_set_cb_new_ipv4(cf_info.wth, count_ipv4_address);
wtap_set_cb_new_ipv6(cf_info.wth, count_ipv6_address);
wtap_set_cb_new_secrets(cf_info.wth, count_decryption_secret);
/* Zero out the counters for the callbacks. */
num_ipv4_addresses = 0;
num_ipv6_addresses = 0;
num_decryption_secrets = 0;
/* Tally up data that we need to parse through the file to find */
wtap_rec_init(&rec);
ws_buffer_init(&buf, 1514);