use std::fmt;
#[derive(Debug, Copy, Clone, PartialEq)]
#[repr(C)]
pub(crate) enum ParamType {
HeartbeatInfo = 1,
Ipv4Addr = 5,
Ipv6Addr = 6,
StateCookie = 7,
UnrecognizedParam = 8,
CookiePreservative = 9,
HostNameAddr = 11,
SupportedAddrTypes = 12,
OutSsnResetReq = 13,
IncSsnResetReq = 14,
SsnTsnResetReq = 15,
ReconfigResp = 16,
AddOutStreamsReq = 17,
AddIncStreamsReq = 18,
Random = 32770,
ChunkList = 32771,
ReqHmacAlgo = 32772,
Padding = 32773,
SupportedExt = 32776,
ForwardTsnSupp = 49152,
AddIpAddr = 49153,
DelIpaddr = 49154,
ErrClauseInd = 49155,
SetPriAddr = 49156,
SuccessInd = 49157,
AdaptLayerInd = 49158,
Unknown,
}
impl Default for ParamType {
fn default() -> Self {
ParamType::Unknown
}
}
impl fmt::Display for ParamType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match *self {
ParamType::HeartbeatInfo => "Heartbeat Info",
ParamType::Ipv4Addr => "IPv4 IP",
ParamType::Ipv6Addr => "IPv6 IP",
ParamType::StateCookie => "State Cookie",
ParamType::UnrecognizedParam => "Unrecognized Parameters",
ParamType::CookiePreservative => "Cookie Preservative",
ParamType::HostNameAddr => "Host Name IP",
ParamType::SupportedAddrTypes => "Supported IP Types",
ParamType::OutSsnResetReq => "Outgoing SSN Reset Request Parameter",
ParamType::IncSsnResetReq => "Incoming SSN Reset Request Parameter",
ParamType::SsnTsnResetReq => "SSN/TSN Reset Request Parameter",
ParamType::ReconfigResp => "Re-configuration Response Parameter",
ParamType::AddOutStreamsReq => "Add Outgoing Streams Request Parameter",
ParamType::AddIncStreamsReq => "Add Incoming Streams Request Parameter",
ParamType::Random => "Random",
ParamType::ChunkList => "Chunk List",
ParamType::ReqHmacAlgo => "Requested HMAC Algorithm Parameter",
ParamType::Padding => "Padding",
ParamType::SupportedExt => "Supported Extensions",
ParamType::ForwardTsnSupp => "Forward TSN supported",
ParamType::AddIpAddr => "Add IP IP",
ParamType::DelIpaddr => "Delete IP IP",
ParamType::ErrClauseInd => "Error Cause Indication",
ParamType::SetPriAddr => "Set Primary IP",
ParamType::SuccessInd => "Success Indication",
ParamType::AdaptLayerInd => "Adaptation Layer Indication",
_ => "Unknown ParamType",
};
write!(f, "{}", s)
}
}
impl From<u16> for ParamType {
fn from(v: u16) -> ParamType {
match v {
1 => ParamType::HeartbeatInfo,
5 => ParamType::Ipv4Addr,
6 => ParamType::Ipv6Addr,
7 => ParamType::StateCookie,
8 => ParamType::UnrecognizedParam,
9 => ParamType::CookiePreservative,
11 => ParamType::HostNameAddr,
12 => ParamType::SupportedAddrTypes,
13 => ParamType::OutSsnResetReq,
14 => ParamType::IncSsnResetReq,
15 => ParamType::SsnTsnResetReq,
16 => ParamType::ReconfigResp,
17 => ParamType::AddOutStreamsReq,
18 => ParamType::AddIncStreamsReq,
32770 => ParamType::Random,
32771 => ParamType::ChunkList,
32772 => ParamType::ReqHmacAlgo,
32773 => ParamType::Padding,
32776 => ParamType::SupportedExt,
49152 => ParamType::ForwardTsnSupp,
49153 => ParamType::AddIpAddr,
49154 => ParamType::DelIpaddr,
49155 => ParamType::ErrClauseInd,
49156 => ParamType::SetPriAddr,
49157 => ParamType::SuccessInd,
_ => ParamType::Unknown,
}
}
}