@@ -35,94 +35,63 @@ internal enum SNIProviders
35
35
/// <summary>
36
36
/// SMUX packet header
37
37
/// </summary>
38
- internal struct SNISMUXHeader
38
+ internal sealed class SNISMUXHeader
39
39
{
40
40
public const int HEADER_LENGTH = 16 ;
41
41
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 ;
58
48
59
49
public void Read ( byte [ ] bytes )
60
50
{
61
51
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 ) ;
67
57
}
68
58
69
59
public void Write ( Span < byte > bytes )
70
60
{
71
- uint value = Highwater ;
61
+ uint value = highwater ;
72
62
// 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
73
63
bytes [ 15 ] = ( byte ) ( ( value >> 24 ) & 0xff ) ;
74
64
bytes [ 12 ] = ( byte ) ( value & 0xff ) ; // BitConverter.GetBytes(_currentHeader.highwater).CopyTo(headerBytes, 12);
75
65
bytes [ 13 ] = ( byte ) ( ( value >> 8 ) & 0xff ) ;
76
66
bytes [ 14 ] = ( byte ) ( ( value >> 16 ) & 0xff ) ;
77
67
78
68
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);
80
70
81
- value = SessionId ;
71
+ value = sessionId ;
82
72
bytes [ 2 ] = ( byte ) ( value & 0xff ) ; // BitConverter.GetBytes(_currentHeader.sessionId).CopyTo(headerBytes, 2);
83
73
bytes [ 3 ] = ( byte ) ( ( value >> 8 ) & 0xff ) ;
84
74
85
- value = Length ;
75
+ value = length ;
86
76
bytes [ 4 ] = ( byte ) ( value & 0xff ) ; // BitConverter.GetBytes(_currentHeader.length).CopyTo(headerBytes, 4);
87
77
bytes [ 5 ] = ( byte ) ( ( value >> 8 ) & 0xff ) ;
88
78
bytes [ 6 ] = ( byte ) ( ( value >> 16 ) & 0xff ) ;
89
79
bytes [ 7 ] = ( byte ) ( ( value >> 24 ) & 0xff ) ;
90
80
91
- value = SequenceNumber ;
81
+ value = sequenceNumber ;
92
82
bytes [ 8 ] = ( byte ) ( value & 0xff ) ; // BitConverter.GetBytes(_currentHeader.sequenceNumber).CopyTo(headerBytes, 8);
93
83
bytes [ 9 ] = ( byte ) ( ( value >> 8 ) & 0xff ) ;
94
84
bytes [ 10 ] = ( byte ) ( ( value >> 16 ) & 0xff ) ;
95
85
bytes [ 11 ] = ( byte ) ( ( value >> 24 ) & 0xff ) ;
96
86
97
87
}
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
- }
120
88
}
121
89
122
90
/// <summary>
123
91
/// SMUX packet flags
124
92
/// </summary>
125
- internal enum SNISMUXFlags : uint
93
+ [ Flags ]
94
+ internal enum SNISMUXFlags
126
95
{
127
96
SMUX_SYN = 1 , // Begin SMUX connection
128
97
SMUX_ACK = 2 , // Acknowledge SMUX packets
0 commit comments