@@ -35,94 +35,63 @@ internal enum SNIProviders
3535 /// <summary>
3636 /// SMUX packet header
3737 /// </summary>
38- internal struct SNISMUXHeader
38+ internal sealed class SNISMUXHeader
3939 {
4040 public const int HEADER_LENGTH = 16 ;
4141
42- public byte SMID { get ; private set ; }
43- public byte Flags { get ; private set ; }
44- public ushort SessionId { get ; private set ; }
45- public uint Length { get ; private set ; }
46- public uint SequenceNumber { get ; private set ; }
47- public uint Highwater { get ; private set ; }
48-
49- public void Set ( byte smid , byte flags , ushort sessionID , uint length , uint sequenceNumber , uint highwater )
50- {
51- SMID = smid ;
52- Flags = flags ;
53- SessionId = sessionID ;
54- Length = length ;
55- SequenceNumber = sequenceNumber ;
56- Highwater = highwater ;
57- }
42+ public byte SMID ;
43+ public byte flags ;
44+ public ushort sessionId ;
45+ public uint length ;
46+ public uint sequenceNumber ;
47+ public uint highwater ;
5848
5949 public void Read ( byte [ ] bytes )
6050 {
6151 SMID = bytes [ 0 ] ;
62- Flags = bytes [ 1 ] ;
63- SessionId = BitConverter . ToUInt16 ( bytes , 2 ) ;
64- Length = BitConverter . ToUInt32 ( bytes , 4 ) - SNISMUXHeader . HEADER_LENGTH ;
65- SequenceNumber = BitConverter . ToUInt32 ( bytes , 8 ) ;
66- Highwater = BitConverter . ToUInt32 ( bytes , 12 ) ;
52+ flags = bytes [ 1 ] ;
53+ sessionId = BitConverter . ToUInt16 ( bytes , 2 ) ;
54+ length = BitConverter . ToUInt32 ( bytes , 4 ) - SNISMUXHeader . HEADER_LENGTH ;
55+ sequenceNumber = BitConverter . ToUInt32 ( bytes , 8 ) ;
56+ highwater = BitConverter . ToUInt32 ( bytes , 12 ) ;
6757 }
6858
6959 public void Write ( Span < byte > bytes )
7060 {
71- uint value = Highwater ;
61+ uint value = highwater ;
7262 // access the highest element first to cause the largest range check in the jit, then fill in the rest of the value and carry on as normal
7363 bytes [ 15 ] = ( byte ) ( ( value >> 24 ) & 0xff ) ;
7464 bytes [ 12 ] = ( byte ) ( value & 0xff ) ; // BitConverter.GetBytes(_currentHeader.highwater).CopyTo(headerBytes, 12);
7565 bytes [ 13 ] = ( byte ) ( ( value >> 8 ) & 0xff ) ;
7666 bytes [ 14 ] = ( byte ) ( ( value >> 16 ) & 0xff ) ;
7767
7868 bytes [ 0 ] = SMID ; // BitConverter.GetBytes(_currentHeader.SMID).CopyTo(headerBytes, 0);
79- bytes [ 1 ] = Flags ; // BitConverter.GetBytes(_currentHeader.flags).CopyTo(headerBytes, 1);
69+ bytes [ 1 ] = flags ; // BitConverter.GetBytes(_currentHeader.flags).CopyTo(headerBytes, 1);
8070
81- value = SessionId ;
71+ value = sessionId ;
8272 bytes [ 2 ] = ( byte ) ( value & 0xff ) ; // BitConverter.GetBytes(_currentHeader.sessionId).CopyTo(headerBytes, 2);
8373 bytes [ 3 ] = ( byte ) ( ( value >> 8 ) & 0xff ) ;
8474
85- value = Length ;
75+ value = length ;
8676 bytes [ 4 ] = ( byte ) ( value & 0xff ) ; // BitConverter.GetBytes(_currentHeader.length).CopyTo(headerBytes, 4);
8777 bytes [ 5 ] = ( byte ) ( ( value >> 8 ) & 0xff ) ;
8878 bytes [ 6 ] = ( byte ) ( ( value >> 16 ) & 0xff ) ;
8979 bytes [ 7 ] = ( byte ) ( ( value >> 24 ) & 0xff ) ;
9080
91- value = SequenceNumber ;
81+ value = sequenceNumber ;
9282 bytes [ 8 ] = ( byte ) ( value & 0xff ) ; // BitConverter.GetBytes(_currentHeader.sequenceNumber).CopyTo(headerBytes, 8);
9383 bytes [ 9 ] = ( byte ) ( ( value >> 8 ) & 0xff ) ;
9484 bytes [ 10 ] = ( byte ) ( ( value >> 16 ) & 0xff ) ;
9585 bytes [ 11 ] = ( byte ) ( ( value >> 24 ) & 0xff ) ;
9686
9787 }
98-
99- public SNISMUXHeader Clone ( )
100- {
101- SNISMUXHeader copy = new SNISMUXHeader ( ) ;
102- copy . SMID = SMID ;
103- copy . Flags = Flags ;
104- copy . SessionId = SessionId ;
105- copy . Length = Length ;
106- copy . SequenceNumber = SequenceNumber ;
107- copy . Highwater = Highwater ;
108- return copy ;
109- }
110-
111- public void Clear ( )
112- {
113- SMID = 0 ;
114- Flags = 0 ;
115- SessionId = 0 ;
116- Length = 0 ;
117- SequenceNumber = 0 ;
118- Highwater = 0 ;
119- }
12088 }
12189
12290 /// <summary>
12391 /// SMUX packet flags
12492 /// </summary>
125- internal enum SNISMUXFlags : uint
93+ [ Flags ]
94+ internal enum SNISMUXFlags
12695 {
12796 SMUX_SYN = 1 , // Begin SMUX connection
12897 SMUX_ACK = 2 , // Acknowledge SMUX packets
0 commit comments