use rustables_macros::nfnetlink_struct; use super::{Expression, ExpressionError}; use crate::sys::{NFTA_LOG_GROUP, NFTA_LOG_PREFIX}; #[derive(Clone, PartialEq, Eq, Default, Debug)] #[nfnetlink_struct] /// A Log expression will log all packets that match the rule. pub struct Log { #[field(NFTA_LOG_GROUP)] group: u16, #[field(NFTA_LOG_PREFIX)] prefix: String, } impl Log { pub fn new( group: Option, prefix: Option>, ) -> Result { let mut res = Log::default(); if let Some(group) = group { res.set_group(group); } if let Some(prefix) = prefix { let prefix = prefix.into(); if prefix.bytes().count() > 127 { return Err(ExpressionError::TooLongLogPrefix); } res.set_prefix(prefix); } Ok(res) } } impl Expression for Log { fn get_name() -> &'static str { "log" } }