diff options
author | John Thacker <johnthacker@gmail.com> | 2023-12-05 07:03:06 -0500 |
---|---|---|
committer | John Thacker <johnthacker@gmail.com> | 2023-12-07 01:00:42 +0000 |
commit | 8ebde1309d0cc0335e32cff8c7112dc98c05d5ed (patch) | |
tree | 560a0e29431d77dcdcabf7de2861b5ee21445bfb /file_packet_provider.c | |
parent | 577cc97f322d5df60a1215061aa8dc4aa2a0f75b (diff) |
Improve interface displaying and writing with multiple sections
Update the functions that get an interface name or description
to also take the section number in the record (0 if not present.)
Store a mapping of SHB number and interface number to global
interface number, and provide a function to access it. Use the
function to display the correct interface name and description
when there are multiple SHBs.
Use this information to rewrite interface numbers when writing a
pcapng file through wtap dumper, since we don't write additional
SHBs to a file when dumping. We could, but we'd have to store
exactly when to write the extra SHB when reading the file in
sequentially (unlike the other internal blocks, IDB, NRB, and
DSBs, that we intentionally move to the start.)
Since we're changing the number of sections, perhaps we should edit
the SHB options more?
Merging handles interface numbers in its own manner, but also needs
to know about the per-SHB interface ID to global ID mapping when
doing so.
Capinfos and capture file properties still require a bit more work
for proper output.
Fix #16531, fix #18049
Diffstat (limited to 'file_packet_provider.c')
-rw-r--r-- | file_packet_provider.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/file_packet_provider.c b/file_packet_provider.c index 1b92eebca0..9764526405 100644 --- a/file_packet_provider.c +++ b/file_packet_provider.c @@ -25,7 +25,7 @@ frame_cmp(gconstpointer a, gconstpointer b, gpointer user_data _U_) } const char * -cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32 interface_id) +cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32 interface_id, unsigned section_number) { wtapng_iface_descriptions_t *idb_info; wtap_block_t wtapng_if_descr = NULL; @@ -33,8 +33,10 @@ cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32 idb_info = wtap_file_get_idb_info(prov->wth); - if (interface_id < idb_info->interface_data->len) - wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_block_t, interface_id); + unsigned gbl_iface_id = wtap_file_get_shb_global_interface_id(prov->wth, section_number, interface_id); + + if (gbl_iface_id < idb_info->interface_data->len) + wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_block_t, gbl_iface_id); g_free(idb_info); @@ -50,7 +52,7 @@ cap_file_provider_get_interface_name(struct packet_provider_data *prov, guint32 } const char * -cap_file_provider_get_interface_description(struct packet_provider_data *prov, guint32 interface_id) +cap_file_provider_get_interface_description(struct packet_provider_data *prov, guint32 interface_id, unsigned section_number) { wtapng_iface_descriptions_t *idb_info; wtap_block_t wtapng_if_descr = NULL; @@ -58,6 +60,8 @@ cap_file_provider_get_interface_description(struct packet_provider_data *prov, g idb_info = wtap_file_get_idb_info(prov->wth); + interface_id = wtap_file_get_shb_global_interface_id(prov->wth, section_number, interface_id); + if (interface_id < idb_info->interface_data->len) wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_block_t, interface_id); |