aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2020-09-20 22:22:26 +0200
committerLinus Färnstrand <linus@mullvad.net>2020-09-20 23:06:05 +0200
commitfc93bb9d8bad648dffd4e1c9b95b45af2dac2959 (patch)
treecac4b5300fd0518ded0d2ae7b10b244b4ee01c12
parentaad52ab0973705037147e349b85839a5738b120c (diff)
Add Register enum
-rw-r--r--nftnl/src/expr/mod.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/nftnl/src/expr/mod.rs b/nftnl/src/expr/mod.rs
index e4c4adb..19a9d3f 100644
--- a/nftnl/src/expr/mod.rs
+++ b/nftnl/src/expr/mod.rs
@@ -4,7 +4,7 @@
//! [`Rule`]: struct.Rule.html
use super::rule::Rule;
-use nftnl_sys as sys;
+use nftnl_sys::{self as sys, libc};
/// Trait for every safe wrapper of an nftables expression.
pub trait Expression {
@@ -13,6 +13,23 @@ pub trait Expression {
fn to_expr(&self, rule: &Rule) -> *mut sys::nftnl_expr;
}
+/// A netfilter data register. The expressions store and read data to and from these
+/// when evaluating rule statements.
+#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
+#[repr(i32)]
+pub enum Register {
+ Reg1 = libc::NFT_REG_1,
+ Reg2 = libc::NFT_REG_2,
+ Reg3 = libc::NFT_REG_3,
+ Reg4 = libc::NFT_REG_4,
+}
+
+impl Register {
+ pub fn to_raw(self) -> u32 {
+ self as u32
+ }
+}
+
mod bitwise;
pub use self::bitwise::*;