@@ -21,7 +21,7 @@ use crate::{
21
21
cid_generator:: ConnectionIdGenerator ,
22
22
cid_queue:: CidQueue ,
23
23
coding:: { BufExt , BufMutExt , UnexpectedEnd } ,
24
- config:: { EndpointConfig , ServerConfig , TransportConfig } ,
24
+ config:: { EndpointConfig , Racenonce , ServerConfig , TransportConfig } ,
25
25
connection:: PathId ,
26
26
shared:: ConnectionId ,
27
27
} ;
@@ -118,6 +118,9 @@ macro_rules! make_struct {
118
118
119
119
// Multipath extension
120
120
pub ( crate ) initial_max_path_id: Option <PathId >,
121
+
122
+ // Racenonce
123
+ pub ( crate ) racenonce: Option <Racenonce >,
121
124
}
122
125
123
126
// We deliberately don't implement the `Default` trait, since that would be public, and
@@ -143,6 +146,7 @@ macro_rules! make_struct {
143
146
write_order: None ,
144
147
address_discovery_role: address_discovery:: Role :: Disabled ,
145
148
initial_max_path_id: None ,
149
+ racenonce: None
146
150
}
147
151
}
148
152
}
@@ -157,6 +161,7 @@ impl TransportParameters {
157
161
endpoint_config : & EndpointConfig ,
158
162
cid_gen : & dyn ConnectionIdGenerator ,
159
163
initial_src_cid : ConnectionId ,
164
+ racenonce : Option < Racenonce > ,
160
165
server_config : Option < & ServerConfig > ,
161
166
rng : & mut impl RngCore ,
162
167
) -> Self {
@@ -193,6 +198,7 @@ impl TransportParameters {
193
198
address_discovery_role : config. address_discovery_role ,
194
199
// TODO(@divma): TransportConfig or..?
195
200
initial_max_path_id : config. initial_max_path_id . map ( PathId :: from) ,
201
+ racenonce,
196
202
..Self :: default ( )
197
203
}
198
204
}
@@ -409,6 +415,13 @@ impl TransportParameters {
409
415
w. write ( val) ;
410
416
}
411
417
}
418
+ TransportParameterId :: Racenonce => {
419
+ if let Some ( val) = self . racenonce {
420
+ w. write_var ( id as u64 ) ;
421
+ w. write_var ( val. len ( ) as u64 ) ;
422
+ w. put_slice ( & val) ;
423
+ }
424
+ }
412
425
id => {
413
426
macro_rules! write_params {
414
427
{ $( $( #[ $doc: meta] ) * $name: ident ( $id: ident) = $default: expr, ) * } => {
@@ -535,6 +548,14 @@ impl TransportParameters {
535
548
params. initial_max_path_id = Some ( value) ;
536
549
tracing:: debug!( initial_max_path_id=%value, "multipath enabled" ) ;
537
550
}
551
+ TransportParameterId :: Racenonce => {
552
+ if len != 32 || params. racenonce . is_some ( ) {
553
+ return Err ( Error :: Malformed ) ;
554
+ }
555
+ let mut val = [ 0 ; 32 ] ;
556
+ r. copy_to_slice ( & mut val) ;
557
+ params. racenonce = Some ( val) ;
558
+ }
538
559
_ => {
539
560
macro_rules! parse {
540
561
{ $( $( #[ $doc: meta] ) * $name: ident ( $id: ident) = $default: expr, ) * } => {
@@ -703,11 +724,13 @@ pub(crate) enum TransportParameterId {
703
724
704
725
// https://datatracker.ietf.org/doc/html/draft-ietf-quic-multipath
705
726
InitialMaxPathId = 0x0f739bbc1b666d0c ,
727
+
728
+ Racenonce = 0x0f138193fac ,
706
729
}
707
730
708
731
impl TransportParameterId {
709
732
/// Array with all supported transport parameter IDs
710
- const SUPPORTED : [ Self ; 23 ] = [
733
+ const SUPPORTED : [ Self ; 24 ] = [
711
734
Self :: MaxIdleTimeout ,
712
735
Self :: MaxUdpPayloadSize ,
713
736
Self :: InitialMaxData ,
@@ -731,6 +754,7 @@ impl TransportParameterId {
731
754
Self :: MinAckDelayDraft07 ,
732
755
Self :: ObservedAddr ,
733
756
Self :: InitialMaxPathId ,
757
+ Self :: Racenonce ,
734
758
] ;
735
759
}
736
760
@@ -772,6 +796,7 @@ impl TryFrom<u64> for TransportParameterId {
772
796
id if Self :: MinAckDelayDraft07 == id => Self :: MinAckDelayDraft07 ,
773
797
id if Self :: ObservedAddr == id => Self :: ObservedAddr ,
774
798
id if Self :: InitialMaxPathId == id => Self :: InitialMaxPathId ,
799
+ id if Self :: Racenonce == id => Self :: Racenonce ,
775
800
_ => return Err ( ( ) ) ,
776
801
} ;
777
802
Ok ( param)
@@ -812,6 +837,7 @@ mod test {
812
837
min_ack_delay : Some ( 2_000u32 . into ( ) ) ,
813
838
address_discovery_role : address_discovery:: Role :: SendOnly ,
814
839
initial_max_path_id : Some ( PathId :: MAX ) ,
840
+ racenonce : Some ( [ 42u8 ; 32 ] ) ,
815
841
..TransportParameters :: default ( )
816
842
} ;
817
843
params. write ( & mut buf) ;
0 commit comments