diff --git a/src/expr.rs b/src/expr.rs index c8156a9..3c27d14 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize}; use std::collections::HashSet; use crate::stmt::Statement; +use crate::stmt::JumpTarget; #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] #[serde(untagged)] @@ -18,6 +19,7 @@ pub enum Expression { Range(Range), Named(NamedExpression), + Verdict(Verdict), } #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] @@ -46,7 +48,6 @@ pub enum NamedExpression { JHash(JHash), SymHash(SymHash), Fib(Fib), - Verdict(Verdict), Elem(Elem), Socket(Socket), Osf(Osf), @@ -347,8 +348,8 @@ pub enum Verdict { Drop, Continue, Return, - Jump(String), - Goto(String), + Jump(JumpTarget), + Goto(JumpTarget), } #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] diff --git a/src/schema.rs b/src/schema.rs index 0bfe949..2875425 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -197,7 +197,28 @@ pub struct Set { #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub struct Map { - // TODO + pub family: NfFamily, + pub table: String, + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub handle: Option, + #[serde(rename = "type")] + pub set_type: SetTypeValue, + pub map: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub policy: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub flags: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub elem: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub timeout: Option, + #[serde(rename = "gc-interval", skip_serializing_if = "Option::is_none")] + pub gc_interval: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub size: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, } #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] diff --git a/tests/helper_tests.rs b/tests/helper_tests.rs index 2cb8af8..193c653 100644 --- a/tests/helper_tests.rs +++ b/tests/helper_tests.rs @@ -58,6 +58,23 @@ fn example_ruleset() -> schema::Nftables { gc_interval: None, size: None, })); + let map_name = "test_map".to_string(); + let map_type = "verdict".to_string(); + batch.add(schema::NfListObject::Map(schema::Map { + family: types::NfFamily::IP, + table: table_name.clone(), + name: map_name.clone(), + handle: None, + map: map_type.clone(), + set_type: schema::SetTypeValue::Single(schema::SetType::Ipv4Addr), + policy: None, + flags: None, + elem: None, + timeout: None, + gc_interval: None, + size: None, + comment: None, + })); // add element to set batch.add(schema::NfListObject::Element(schema::Element { family: types::NfFamily::IP,