From 6159989e370d2a3bc161d9bf11eb265226a61edd Mon Sep 17 00:00:00 2001 From: Marcin Osypka Date: Wed, 17 Jan 2024 20:05:53 +0100 Subject: [PATCH] Elem fields should be Option 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. --- src/expr.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index c6895ef..ffe5c58 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -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, - pub timeout: u32, - pub expires: u32, - pub comment: String, + pub timeout: Option, + pub expires: Option, + pub comment: Option, pub counter: Option, }