diff --git a/Cargo.toml b/Cargo.toml index 66e24ac..e91eda8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "conntrack" -version = "0.1.0" -authors = [ "Matt Bolt "] repository = "https://github.com/rusty-bolt/conntrack-rs" description = "Netfilter Conntrack" categories = ["network-programming"] @@ -24,4 +24,4 @@ env_logger = "0.10.0" [[example]] name = "conntrack-dump" -path = "examples/conntrack_dump.rs" \ No newline at end of file +path = "examples/conntrack_dump.rs" diff --git a/src/attributes.rs b/src/attributes.rs index 5a9bf72..289e012 100644 --- a/src/attributes.rs +++ b/src/attributes.rs @@ -1,3 +1,7 @@ +//! # Attributes +//! This module contains neli compatible attributes used to read and decode +//! conntrack subsystem responses. + use neli::{ attr::AttrHandle, consts::genl::NlAttrType, diff --git a/src/connection.rs b/src/connection.rs index aa8b9ca..90c6041 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -1,3 +1,6 @@ +//! # Connection +//! This module contains the general API for the conntrack library. + use neli::{ consts::{nl::*, socket::*}, genl::Genlmsghdr, diff --git a/src/decoders.rs b/src/decoders.rs index e18f8cc..e2f3a86 100644 --- a/src/decoders.rs +++ b/src/decoders.rs @@ -1,3 +1,7 @@ +//! # Decoders +//! This module contains decoder traits and implementations capable of extracting +//! conntrack table data from neli attributes. + use std::net::IpAddr; use std::net::Ipv4Addr; use std::net::Ipv6Addr; @@ -143,6 +147,9 @@ impl<'a> AttrDecoder<'a, ConntrackAttr, Flow> for Flow { ConntrackAttr::CtaTimeout => { flow.timeout = Some(Duration::from_secs((u32::decode(attr)?) as u64)); } + ConntrackAttr::CtaMark => { + flow.mark = Some(u32::decode(attr)?); + } ConntrackAttr::CtaSeqAdjOrig => { let seq_adj_orig_attr = attr.get_attr_handle::()?; @@ -162,7 +169,7 @@ impl<'a> AttrDecoder<'a, ConntrackAttr, Flow> for Flow { flow.sec_ctx = Some(SecCtx::decode(sec_ctx_attr)?); } ConntrackAttr::CtaSecMark => { - flow.mark = Some(u32::decode(attr)?); + flow.sec_mark = Some(u32::decode(attr)?); } ConntrackAttr::CtaMarkMask => { flow.mark_mask = Some(u32::decode(attr)?); diff --git a/src/error.rs b/src/error.rs index 0bf83f7..e2e3572 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,3 +1,7 @@ +//! # Error +//! This module contains all the potential error types that can come from +//! the `conntrack` library. + use std::fmt::Debug; /// Error consolidates and propagates all underlying error types. diff --git a/src/message.rs b/src/message.rs index e09251b..8e1f43e 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,3 +1,6 @@ +//! # Message +//! This module contains neli compatible subsystem messages. + use neli::neli_enum; #[inline] diff --git a/src/model.rs b/src/model.rs index b04a825..c26af25 100644 --- a/src/model.rs +++ b/src/model.rs @@ -1,3 +1,6 @@ +//! # Model +//! This module contains rust model structs for the decoded conntrack data. + use bitflags::bitflags; use chrono::prelude::*; use neli::neli_enum; @@ -43,6 +46,7 @@ pub struct Flow { pub seq_adj_orig: Option, pub seq_adj_repl: Option, pub sec_ctx: Option, + pub sec_mark: Option, pub exp: Option, } #[neli_enum(serialized_type = "u8")] diff --git a/src/result.rs b/src/result.rs index 97319cd..4f1939e 100644 --- a/src/result.rs +++ b/src/result.rs @@ -1,3 +1,6 @@ +//! # Result +//! This module contains the result alias and a module reimport for the error types. + pub use crate::error::Error; /// Result is an alias for `core::result::Result`