aboutsummaryrefslogtreecommitdiff
path: root/rustables/src/expr/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rustables/src/expr/mod.rs')
-rw-r--r--rustables/src/expr/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/rustables/src/expr/mod.rs b/rustables/src/expr/mod.rs
index 39ab2e0..f2a4d5e 100644
--- a/rustables/src/expr/mod.rs
+++ b/rustables/src/expr/mod.rs
@@ -89,6 +89,7 @@ pub trait Expression {
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[repr(i32)]
pub enum Register {
+ Verdict = libc::NFT_REG_VERDICT,
Reg1 = libc::NFT_REG_1,
Reg2 = libc::NFT_REG_2,
Reg3 = libc::NFT_REG_3,
@@ -99,6 +100,17 @@ impl Register {
pub fn to_raw(self) -> u32 {
self as u32
}
+
+ pub fn from_raw(val: u32) -> Option<Self> {
+ match val as i32 {
+ libc::NFT_REG_VERDICT => Some(Self::Verdict),
+ libc::NFT_REG_1 => Some(Self::Reg1),
+ libc::NFT_REG_2 => Some(Self::Reg2),
+ libc::NFT_REG_3 => Some(Self::Reg3),
+ libc::NFT_REG_4 => Some(Self::Reg4),
+ _ => None,
+ }
+ }
}
mod bitwise;