@@ -3,62 +3,62 @@ use std::fmt;
3
3
/// paramType represents a SCTP INIT/INITACK parameter
4
4
#[ derive( Debug , Copy , Clone , PartialEq ) ]
5
5
#[ repr( C ) ]
6
- #[ derive( Default ) ]
7
6
pub ( crate ) enum ParamType {
8
- HeartbeatInfo = 1 ,
7
+ HeartbeatInfo ,
9
8
/// Heartbeat Info [RFCRFC4960]
10
- Ipv4Addr = 5 ,
9
+ Ipv4Addr ,
11
10
/// IPv4 IP [RFCRFC4960]
12
- Ipv6Addr = 6 ,
11
+ Ipv6Addr ,
13
12
/// IPv6 IP [RFCRFC4960]
14
- StateCookie = 7 ,
13
+ StateCookie ,
15
14
/// State Cookie [RFCRFC4960]
16
- UnrecognizedParam = 8 ,
15
+ UnrecognizedParam ,
17
16
/// Unrecognized Parameters [RFCRFC4960]
18
- CookiePreservative = 9 ,
17
+ CookiePreservative ,
19
18
/// Cookie Preservative [RFCRFC4960]
20
- HostNameAddr = 11 ,
19
+ HostNameAddr ,
21
20
/// Host Name IP [RFCRFC4960]
22
- SupportedAddrTypes = 12 ,
21
+ SupportedAddrTypes ,
23
22
/// Supported IP Types [RFCRFC4960]
24
- OutSsnResetReq = 13 ,
23
+ OutSsnResetReq ,
25
24
/// Outgoing SSN Reset Request Parameter [RFCRFC6525]
26
- IncSsnResetReq = 14 ,
25
+ IncSsnResetReq ,
27
26
/// Incoming SSN Reset Request Parameter [RFCRFC6525]
28
- SsnTsnResetReq = 15 ,
27
+ SsnTsnResetReq ,
29
28
/// SSN/TSN Reset Request Parameter [RFCRFC6525]
30
- ReconfigResp = 16 ,
29
+ ReconfigResp ,
31
30
/// Re-configuration Response Parameter [RFCRFC6525]
32
- AddOutStreamsReq = 17 ,
31
+ AddOutStreamsReq ,
33
32
/// Add Outgoing Streams Request Parameter [RFCRFC6525]
34
- AddIncStreamsReq = 18 ,
33
+ AddIncStreamsReq ,
35
34
/// Add Incoming Streams Request Parameter [RFCRFC6525]
36
- Random = 32770 ,
35
+ Random ,
37
36
/// Random (0x8002) [RFCRFC4805]
38
- ChunkList = 32771 ,
37
+ ChunkList ,
39
38
/// Chunk List (0x8003) [RFCRFC4895]
40
- ReqHmacAlgo = 32772 ,
39
+ ReqHmacAlgo ,
41
40
/// Requested HMAC Algorithm Parameter (0x8004) [RFCRFC4895]
42
- Padding = 32773 ,
41
+ Padding ,
43
42
/// Padding (0x8005)
44
- SupportedExt = 32776 ,
43
+ SupportedExt ,
45
44
/// Supported Extensions (0x8008) [RFCRFC5061]
46
- ForwardTsnSupp = 49152 ,
45
+ ForwardTsnSupp ,
47
46
/// Forward TSN supported (0xC000) [RFCRFC3758]
48
- AddIpAddr = 49153 ,
47
+ AddIpAddr ,
49
48
/// Add IP IP (0xC001) [RFCRFC5061]
50
- DelIpaddr = 49154 ,
49
+ DelIpaddr ,
51
50
/// Delete IP IP (0xC002) [RFCRFC5061]
52
- ErrClauseInd = 49155 ,
51
+ ErrClauseInd ,
53
52
/// Error Cause Indication (0xC003) [RFCRFC5061]
54
- SetPriAddr = 49156 ,
53
+ SetPriAddr ,
55
54
/// Set Primary IP (0xC004) [RFCRFC5061]
56
- SuccessInd = 49157 ,
55
+ SuccessInd ,
57
56
/// Success Indication (0xC005) [RFCRFC5061]
58
- AdaptLayerInd = 49158 ,
57
+ AdaptLayerInd ,
59
58
/// Adaptation Layer Indication (0xC006) [RFCRFC5061]
60
- #[ default]
61
- Unknown ,
59
+ Unknown {
60
+ param_type : u16 ,
61
+ } ,
62
62
}
63
63
64
64
impl fmt:: Display for ParamType {
@@ -124,7 +124,41 @@ impl From<u16> for ParamType {
124
124
49155 => ParamType :: ErrClauseInd ,
125
125
49156 => ParamType :: SetPriAddr ,
126
126
49157 => ParamType :: SuccessInd ,
127
- _ => ParamType :: Unknown ,
127
+ _ => ParamType :: Unknown { param_type : v } ,
128
+ }
129
+ }
130
+ }
131
+
132
+ impl From < ParamType > for u16 {
133
+ fn from ( v : ParamType ) -> u16 {
134
+ match v {
135
+ ParamType :: HeartbeatInfo => 1 ,
136
+ ParamType :: Ipv4Addr => 5 ,
137
+ ParamType :: Ipv6Addr => 6 ,
138
+ ParamType :: StateCookie => 7 ,
139
+ ParamType :: UnrecognizedParam => 8 ,
140
+ ParamType :: CookiePreservative => 9 ,
141
+ ParamType :: HostNameAddr => 11 ,
142
+ ParamType :: SupportedAddrTypes => 12 ,
143
+ ParamType :: OutSsnResetReq => 13 ,
144
+ ParamType :: IncSsnResetReq => 14 ,
145
+ ParamType :: SsnTsnResetReq => 15 ,
146
+ ParamType :: ReconfigResp => 16 ,
147
+ ParamType :: AddOutStreamsReq => 17 ,
148
+ ParamType :: AddIncStreamsReq => 18 ,
149
+ ParamType :: Random => 32770 ,
150
+ ParamType :: ChunkList => 32771 ,
151
+ ParamType :: ReqHmacAlgo => 32772 ,
152
+ ParamType :: Padding => 32773 ,
153
+ ParamType :: SupportedExt => 32776 ,
154
+ ParamType :: ForwardTsnSupp => 49152 ,
155
+ ParamType :: AddIpAddr => 49153 ,
156
+ ParamType :: DelIpaddr => 49154 ,
157
+ ParamType :: ErrClauseInd => 49155 ,
158
+ ParamType :: SetPriAddr => 49156 ,
159
+ ParamType :: SuccessInd => 49157 ,
160
+ ParamType :: AdaptLayerInd => 49158 ,
161
+ ParamType :: Unknown { param_type, .. } => param_type,
128
162
}
129
163
}
130
164
}
0 commit comments