mirror of
https://git.proxmox.com/git/proxmox-ve-rs
synced 2025-10-04 16:26:18 +00:00
config: nftables: add support for icmp-type any
We support any as wildcard for matching all icmp types. Implement parsing logic for parsing the any value and support converting the any value into an nftables expression. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
parent
948a94af84
commit
0bd09fe6fa
@ -511,6 +511,7 @@ impl FromStr for Icmp {
|
|||||||
pub enum IcmpType {
|
pub enum IcmpType {
|
||||||
Numeric(u8),
|
Numeric(u8),
|
||||||
Named(&'static str),
|
Named(&'static str),
|
||||||
|
Any,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[sortable]
|
#[sortable]
|
||||||
@ -536,6 +537,10 @@ impl std::str::FromStr for IcmpType {
|
|||||||
type Err = Error;
|
type Err = Error;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Error> {
|
fn from_str(s: &str) -> Result<Self, Error> {
|
||||||
|
if s.eq_ignore_ascii_case("any") {
|
||||||
|
return Ok(Self::Any);
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(ty) = s.trim().parse::<u8>() {
|
if let Ok(ty) = s.trim().parse::<u8>() {
|
||||||
return Ok(Self::Numeric(ty));
|
return Ok(Self::Numeric(ty));
|
||||||
}
|
}
|
||||||
@ -553,6 +558,7 @@ impl fmt::Display for IcmpType {
|
|||||||
match self {
|
match self {
|
||||||
IcmpType::Numeric(ty) => write!(f, "{ty}"),
|
IcmpType::Numeric(ty) => write!(f, "{ty}"),
|
||||||
IcmpType::Named(ty) => write!(f, "{ty}"),
|
IcmpType::Named(ty) => write!(f, "{ty}"),
|
||||||
|
IcmpType::Any => write!(f, "any"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -664,6 +670,7 @@ impl FromStr for Icmpv6 {
|
|||||||
pub enum Icmpv6Type {
|
pub enum Icmpv6Type {
|
||||||
Numeric(u8),
|
Numeric(u8),
|
||||||
Named(&'static str),
|
Named(&'static str),
|
||||||
|
Any,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[sortable]
|
#[sortable]
|
||||||
@ -693,6 +700,10 @@ impl std::str::FromStr for Icmpv6Type {
|
|||||||
type Err = Error;
|
type Err = Error;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Error> {
|
fn from_str(s: &str) -> Result<Self, Error> {
|
||||||
|
if s.eq_ignore_ascii_case("any") {
|
||||||
|
return Ok(Self::Any);
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(ty) = s.trim().parse::<u8>() {
|
if let Ok(ty) = s.trim().parse::<u8>() {
|
||||||
return Ok(Self::Numeric(ty));
|
return Ok(Self::Numeric(ty));
|
||||||
}
|
}
|
||||||
@ -710,6 +721,7 @@ impl fmt::Display for Icmpv6Type {
|
|||||||
match self {
|
match self {
|
||||||
Icmpv6Type::Numeric(ty) => write!(f, "{ty}"),
|
Icmpv6Type::Numeric(ty) => write!(f, "{ty}"),
|
||||||
Icmpv6Type::Named(ty) => write!(f, "{ty}"),
|
Icmpv6Type::Named(ty) => write!(f, "{ty}"),
|
||||||
|
Icmpv6Type::Any => write!(f, "any"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user