aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_access.c
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2023-12-05 07:03:06 -0500
committerJohn Thacker <johnthacker@gmail.com>2023-12-07 01:00:42 +0000
commit8ebde1309d0cc0335e32cff8c7112dc98c05d5ed (patch)
tree560a0e29431d77dcdcabf7de2861b5ee21445bfb /wiretap/file_access.c
parent577cc97f322d5df60a1215061aa8dc4aa2a0f75b (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 'wiretap/file_access.c')
-rw-r--r--wiretap/file_access.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 9670d62def..fb7166ca40 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -912,6 +912,9 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
*/
wth->next_interface_data = 0;
+ wth->shb_iface_to_global = g_array_new(FALSE, FALSE, sizeof(unsigned));
+ g_array_append_val(wth->shb_iface_to_global, wth->interface_data->len);
+
if (wth->random_fh) {
wth->fast_seek = g_ptr_array_new();
@@ -2335,6 +2338,7 @@ wtap_dump_init_dumper(int file_type_subtype, wtap_compression_type compression_t
wdh->file_encap = params->encap;
wdh->compression_type = compression_type;
wdh->wslua_data = NULL;
+ wdh->shb_iface_to_global = params->shb_iface_to_global;
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
/* Set Section Header Block data */