@@ -208,8 +208,7 @@ impl ExtendedClientInfo {
208
208
fn decode ( src : & mut ReadCursor < ' _ > , character_set : CharacterSet ) -> DecodeResult < Self > {
209
209
ensure_size ! ( in: src, size: CLIENT_ADDRESS_FAMILY_SIZE + CLIENT_ADDRESS_LENGTH_SIZE ) ;
210
210
211
- let address_family = AddressFamily :: from_u16 ( src. read_u16 ( ) )
212
- . ok_or_else ( || invalid_field_err ! ( "clientAddressFamily" , "invalid address family" ) ) ?;
211
+ let address_family = AddressFamily :: from_u16 ( src. read_u16 ( ) ) ;
213
212
214
213
// This size includes the length of the mandatory null terminator.
215
214
let address_size = src. read_u16 ( ) as usize ;
@@ -235,7 +234,7 @@ impl ExtendedClientInfo {
235
234
fn encode ( & self , dst : & mut WriteCursor < ' _ > , character_set : CharacterSet ) -> EncodeResult < ( ) > {
236
235
ensure_size ! ( in: dst, size: self . size( character_set) ) ;
237
236
238
- dst. write_u16 ( self . address_family . to_u16 ( ) . unwrap ( ) ) ;
237
+ dst. write_u16 ( self . address_family . as_u16 ( ) ) ;
239
238
// // + size of null terminator, which will write in the write_string function
240
239
dst. write_u16 ( string_len ( self . address . as_str ( ) , character_set) + character_set. to_u16 ( ) . unwrap ( ) ) ;
241
240
utils:: write_string_to_cursor ( dst, self . address . as_str ( ) , character_set, true ) ?;
@@ -609,12 +608,23 @@ impl Default for PerformanceFlags {
609
608
}
610
609
}
611
610
612
- #[ repr( u16 ) ]
613
- #[ derive( Debug , Copy , Clone , PartialEq , Eq , FromPrimitive , ToPrimitive ) ]
614
- pub enum AddressFamily {
615
- Invalid = 0x0000 , // value given by MS Remote Desktop for Android 10.0.18.1251
616
- INet = 0x0002 ,
617
- INet6 = 0x0017 ,
611
+ #[ repr( transparent) ]
612
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
613
+ pub struct AddressFamily ( u16 ) ;
614
+
615
+ impl AddressFamily {
616
+ pub const INET : Self = Self ( 0x0002 ) ;
617
+ pub const INET_6 : Self = Self ( 0x0017 ) ;
618
+ }
619
+
620
+ impl AddressFamily {
621
+ pub fn from_u16 ( val : u16 ) -> Self {
622
+ Self ( val)
623
+ }
624
+
625
+ pub fn as_u16 ( self ) -> u16 {
626
+ self . 0
627
+ }
618
628
}
619
629
620
630
bitflags ! {
0 commit comments