Skip to content

Commit

Permalink
Elem fields should be Option
Browse files Browse the repository at this point in the history
E.g. for the set:
set test_set {
    typeof ip saddr
    flags interval
    elements = { 10.0.0.0/24 }
}

The json object will look like this:
 "set": {
    "family": "ip",
    "name": "snat_hv",
    "table": "nat",
    "type": "ipv4_addr",
    "handle": 4,
    "flags": [
      "interval"
    ],
    "elem": [
      {
        "elem": {
          "val": {
            "prefix": {
              "addr": "10.0.0.0",
              "len": 24
            }
          },
        }
      }
 }
 There is no timeout, expires and comments fields, they should be
 optional.
  • Loading branch information
marcinosypka committed Jan 17, 2024
1 parent 80561b9 commit 6159989
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,21 @@ pub enum Verdict {
Goto(String),
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
/// Explicitly set element object.
pub struct ElemCounter {
pub packets: u32,
pub bytes: u32,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename = "elem")]
/// Explicitly set element object.
pub struct Elem {
pub val: Box<Expression>,
pub timeout: u32,
pub expires: u32,
pub comment: String,
pub timeout: Option<u32>,
pub expires: Option<u32>,
pub comment: Option<String>,
pub counter: Option<Counter>,
}

Expand Down

0 comments on commit 6159989

Please sign in to comment.