@@ -3,62 +3,62 @@ use std::fmt;
33/// paramType represents a SCTP INIT/INITACK parameter
44#[ derive( Debug , Copy , Clone , PartialEq ) ]
55#[ repr( C ) ]
6- #[ derive( Default ) ]
76pub ( crate ) enum ParamType {
8- HeartbeatInfo = 1 ,
7+ HeartbeatInfo ,
98 /// Heartbeat Info [RFCRFC4960]
10- Ipv4Addr = 5 ,
9+ Ipv4Addr ,
1110 /// IPv4 IP [RFCRFC4960]
12- Ipv6Addr = 6 ,
11+ Ipv6Addr ,
1312 /// IPv6 IP [RFCRFC4960]
14- StateCookie = 7 ,
13+ StateCookie ,
1514 /// State Cookie [RFCRFC4960]
16- UnrecognizedParam = 8 ,
15+ UnrecognizedParam ,
1716 /// Unrecognized Parameters [RFCRFC4960]
18- CookiePreservative = 9 ,
17+ CookiePreservative ,
1918 /// Cookie Preservative [RFCRFC4960]
20- HostNameAddr = 11 ,
19+ HostNameAddr ,
2120 /// Host Name IP [RFCRFC4960]
22- SupportedAddrTypes = 12 ,
21+ SupportedAddrTypes ,
2322 /// Supported IP Types [RFCRFC4960]
24- OutSsnResetReq = 13 ,
23+ OutSsnResetReq ,
2524 /// Outgoing SSN Reset Request Parameter [RFCRFC6525]
26- IncSsnResetReq = 14 ,
25+ IncSsnResetReq ,
2726 /// Incoming SSN Reset Request Parameter [RFCRFC6525]
28- SsnTsnResetReq = 15 ,
27+ SsnTsnResetReq ,
2928 /// SSN/TSN Reset Request Parameter [RFCRFC6525]
30- ReconfigResp = 16 ,
29+ ReconfigResp ,
3130 /// Re-configuration Response Parameter [RFCRFC6525]
32- AddOutStreamsReq = 17 ,
31+ AddOutStreamsReq ,
3332 /// Add Outgoing Streams Request Parameter [RFCRFC6525]
34- AddIncStreamsReq = 18 ,
33+ AddIncStreamsReq ,
3534 /// Add Incoming Streams Request Parameter [RFCRFC6525]
36- Random = 32770 ,
35+ Random ,
3736 /// Random (0x8002) [RFCRFC4805]
38- ChunkList = 32771 ,
37+ ChunkList ,
3938 /// Chunk List (0x8003) [RFCRFC4895]
40- ReqHmacAlgo = 32772 ,
39+ ReqHmacAlgo ,
4140 /// Requested HMAC Algorithm Parameter (0x8004) [RFCRFC4895]
42- Padding = 32773 ,
41+ Padding ,
4342 /// Padding (0x8005)
44- SupportedExt = 32776 ,
43+ SupportedExt ,
4544 /// Supported Extensions (0x8008) [RFCRFC5061]
46- ForwardTsnSupp = 49152 ,
45+ ForwardTsnSupp ,
4746 /// Forward TSN supported (0xC000) [RFCRFC3758]
48- AddIpAddr = 49153 ,
47+ AddIpAddr ,
4948 /// Add IP IP (0xC001) [RFCRFC5061]
50- DelIpaddr = 49154 ,
49+ DelIpaddr ,
5150 /// Delete IP IP (0xC002) [RFCRFC5061]
52- ErrClauseInd = 49155 ,
51+ ErrClauseInd ,
5352 /// Error Cause Indication (0xC003) [RFCRFC5061]
54- SetPriAddr = 49156 ,
53+ SetPriAddr ,
5554 /// Set Primary IP (0xC004) [RFCRFC5061]
56- SuccessInd = 49157 ,
55+ SuccessInd ,
5756 /// Success Indication (0xC005) [RFCRFC5061]
58- AdaptLayerInd = 49158 ,
57+ AdaptLayerInd ,
5958 /// Adaptation Layer Indication (0xC006) [RFCRFC5061]
60- #[ default]
61- Unknown ,
59+ Unknown {
60+ param_type : u16 ,
61+ } ,
6262}
6363
6464impl fmt:: Display for ParamType {
@@ -124,7 +124,41 @@ impl From<u16> for ParamType {
124124 49155 => ParamType :: ErrClauseInd ,
125125 49156 => ParamType :: SetPriAddr ,
126126 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,
128162 }
129163 }
130164}
0 commit comments