aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/pcapng.c6
-rw-r--r--wiretap/wtap-int.h6
-rw-r--r--wiretap/wtap.c25
3 files changed, 30 insertions, 7 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 035f5b6a9e..55fd663360 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -2646,11 +2646,7 @@ pcapng_process_idb(wtap *wth, pcapng_t *pcapng, wtapng_block_t *wblock)
static void
pcapng_process_dsb(wtap *wth, wtapng_block_t *wblock)
{
- const wtapng_dsb_mandatory_t *dsb = (wtapng_dsb_mandatory_t*)wtap_block_get_mandatory_data(wblock->block);
-
- if (wth->add_new_secrets) {
- wth->add_new_secrets(dsb->secrets_type, dsb->secrets_data, dsb->secrets_len);
- }
+ wtapng_process_dsb(wth, wblock->block);
/* Store DSB such that it can be saved by the dumper. */
g_array_append_val(wth->dsbs, wblock->block);
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index 9271ac39fa..486b03685f 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -326,6 +326,12 @@ wtap_full_file_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset);
*/
gboolean
wtap_full_file_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
+
+/**
+ * Invokes the callback with the given decryption secrets block.
+ */
+void
+wtapng_process_dsb(wtap *wth, wtap_block_t dsb);
#endif /* __WTAP_INT_H__ */
/*
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index b7498d337c..fe43e3b457 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1266,8 +1266,29 @@ void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6) {
}
void wtap_set_cb_new_secrets(wtap *wth, wtap_new_secrets_callback_t add_new_secrets) {
- if (wth)
- wth->add_new_secrets = add_new_secrets;
+ /* Is a valid wth given that supports DSBs? */
+ if (!wth || !wth->dsbs)
+ return;
+
+ wth->add_new_secrets = add_new_secrets;
+ /*
+ * Send all DSBs that were read so far to the new callback. file.c
+ * relies on this to support redissection (during redissection, the
+ * previous secrets are lost and has to be resupplied).
+ */
+ for (guint i = 0; i < wth->dsbs->len; i++) {
+ wtap_block_t dsb = g_array_index(wth->dsbs, wtap_block_t, i);
+ wtapng_process_dsb(wth, dsb);
+ }
+}
+
+void
+wtapng_process_dsb(wtap *wth, wtap_block_t dsb)
+{
+ const wtapng_dsb_mandatory_t *dsb_mand = (wtapng_dsb_mandatory_t*)wtap_block_get_mandatory_data(dsb);
+
+ if (wth->add_new_secrets)
+ wth->add_new_secrets(dsb_mand->secrets_type, dsb_mand->secrets_data, dsb_mand->secrets_len);
}
gboolean