@@ -20,6 +20,7 @@ use rand::Rng as _;
2020use s2n_codec:: EncoderBuffer ;
2121use s2n_quic_core:: { dc, varint:: VarInt } ;
2222use std:: {
23+ any:: Any ,
2324 net:: SocketAddr ,
2425 sync:: {
2526 atomic:: { AtomicU32 , AtomicU8 , Ordering } ,
@@ -31,8 +32,10 @@ use std::{
3132#[ cfg( test) ]
3233mod tests;
3334
35+ pub type ApplicationData = Arc < dyn Any + Send + Sync > ;
36+
3437#[ derive( Debug ) ]
35- pub ( super ) struct Entry {
38+ pub struct Entry {
3639 creation_time : Instant ,
3740 rehandshake_delta_secs : AtomicU32 ,
3841 peer : SocketAddr ,
@@ -44,6 +47,7 @@ pub(super) struct Entry {
4447 // we store this as a u8 to allow the cleaner to separately "take" accessed for id and addr
4548 // maps while not having two writes and wasting an extra byte of space.
4649 accessed : AtomicU8 ,
50+ application_data : ApplicationData ,
4751}
4852
4953impl SizeOf for Entry {
@@ -58,6 +62,7 @@ impl SizeOf for Entry {
5862 receiver,
5963 parameters,
6064 accessed,
65+ application_data,
6166 } = self ;
6267 creation_time. size ( )
6368 + rehandshake_delta_secs. size ( )
@@ -68,6 +73,13 @@ impl SizeOf for Entry {
6873 + receiver. size ( )
6974 + parameters. size ( )
7075 + accessed. size ( )
76+ + application_data. size ( )
77+ }
78+ }
79+
80+ impl SizeOf for ApplicationData {
81+ fn size ( & self ) -> usize {
82+ std:: mem:: size_of_val ( self )
7183 }
7284}
7385
@@ -82,6 +94,7 @@ impl Entry {
8294 receiver : receiver:: State ,
8395 parameters : dc:: ApplicationParams ,
8496 rehandshake_time : Duration ,
97+ application_data : ApplicationData ,
8598 ) -> Self {
8699 // clamp max datagram size to a well-known value
87100 parameters
@@ -99,6 +112,7 @@ impl Entry {
99112 receiver,
100113 parameters,
101114 accessed : AtomicU8 :: new ( 0 ) ,
115+ application_data,
102116 } ;
103117 entry. rehandshake_time_reschedule ( rehandshake_time) ;
104118 entry
@@ -123,6 +137,7 @@ impl Entry {
123137 receiver,
124138 dc:: testing:: TEST_APPLICATION_PARAMS ,
125139 dc:: testing:: TEST_REHANDSHAKE_PERIOD ,
140+ Arc :: new ( ( ) ) ,
126141 ) )
127142 }
128143
@@ -287,6 +302,10 @@ impl Entry {
287302 pub fn control_sealer ( & self ) -> crate :: crypto:: awslc:: seal:: control:: Secret {
288303 self . secret . control_sealer ( )
289304 }
305+
306+ pub fn application_data ( & self ) -> & ApplicationData {
307+ & self . application_data
308+ }
290309}
291310
292311impl receiver:: Error {
0 commit comments