@@ -858,6 +858,27 @@ impl Ssl {
858858 self . max_early_data = max;
859859 }
860860
861+ fn get_early_data_status ( & mut self ) -> EarlyDataStatus {
862+ // XXX: unfortunately `ClientConnection::early_data()` and
863+ // `ServerConnection::early_data()` both require a mut self;
864+ // which means this getter is mut too.
865+ match self . conn_mut ( ) {
866+ Some ( Connection :: Server ( server) ) => match server. early_data ( ) {
867+ Some ( _) => EarlyDataStatus :: Accepted ,
868+ None => EarlyDataStatus :: NotSent ,
869+ } ,
870+ Some ( Connection :: Client ( client) ) => {
871+ let accepted = client. is_early_data_accepted ( ) ;
872+ match ( client. early_data ( ) , accepted) {
873+ ( _, true ) => EarlyDataStatus :: Accepted ,
874+ ( None , false ) => EarlyDataStatus :: Rejected ,
875+ ( Some ( _) , _) => EarlyDataStatus :: NotSent ,
876+ }
877+ }
878+ None => EarlyDataStatus :: NotSent ,
879+ }
880+ }
881+
861882 fn clear_options ( & mut self , clear : u64 ) -> u64 {
862883 self . raw_options &= !clear;
863884 self . raw_options
@@ -1722,6 +1743,24 @@ impl EnabledVersions {
17221743 }
17231744}
17241745
1746+ #[ derive( Debug ) ]
1747+ enum EarlyDataStatus {
1748+ NotSent ,
1749+ Rejected ,
1750+ Accepted ,
1751+ }
1752+
1753+ impl From < EarlyDataStatus > for c_int {
1754+ fn from ( e : EarlyDataStatus ) -> Self {
1755+ // refer to OpenSSL SSL_EARLY_DATA_NOT_SENT et al.
1756+ match e {
1757+ EarlyDataStatus :: NotSent => 0 ,
1758+ EarlyDataStatus :: Rejected => 1 ,
1759+ EarlyDataStatus :: Accepted => 2 ,
1760+ }
1761+ }
1762+ }
1763+
17251764pub ( crate ) const SSL_OP_NO_TICKET : u64 = 1 << 14 ; // See ssl.h
17261765
17271766#[ cfg( test) ]
0 commit comments