aboutsummaryrefslogtreecommitdiff
path: root/rustables/src/expr/masquerade.rs
diff options
context:
space:
mode:
authorSimon THOBY <git@nightmared.fr>2021-11-05 06:23:45 +0000
committerSimon THOBY <git@nightmared.fr>2021-11-05 06:23:45 +0000
commit46b22d88c36863851e4b27efa767d28c8aeecfe0 (patch)
treeab1a638de7587e7b73fe64093428218e1c545004 /rustables/src/expr/masquerade.rs
parent3f61ea42bd291c208d07006d8019c25d588f9183 (diff)
parent1bec5a5c30541e47e9c7cff839ac0e7dd3fb6215 (diff)
Merge branch 'manipulate-exprs' into 'master'
Add functions to iterate over the expressions of existing rules See merge request rustwall/rustables!3
Diffstat (limited to 'rustables/src/expr/masquerade.rs')
-rw-r--r--rustables/src/expr/masquerade.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/rustables/src/expr/masquerade.rs b/rustables/src/expr/masquerade.rs
index 66e9e0e..40565d5 100644
--- a/rustables/src/expr/masquerade.rs
+++ b/rustables/src/expr/masquerade.rs
@@ -1,12 +1,24 @@
-use super::{Expression, Rule};
+use super::{DeserializationError, Expression, Rule};
use rustables_sys as sys;
use std::os::raw::c_char;
/// Sets the source IP to that of the output interface.
+#[derive(Debug, PartialEq)]
pub struct Masquerade;
impl Expression for Masquerade {
+ fn get_raw_name() -> *const sys::libc::c_char {
+ b"masq\0" as *const _ as *const c_char
+ }
+
+ fn from_expr(_expr: *const sys::nftnl_expr) -> Result<Self, DeserializationError>
+ where
+ Self: Sized,
+ {
+ Ok(Masquerade)
+ }
+
fn to_expr(&self, _rule: &Rule) -> *mut sys::nftnl_expr {
- try_alloc!(unsafe { sys::nftnl_expr_alloc(b"masq\0" as *const _ as *const c_char) })
+ try_alloc!(unsafe { sys::nftnl_expr_alloc(Self::get_raw_name()) })
}
}