use crate::constants::*;
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub struct NetlinkFlags(u16);
impl From<u16> for NetlinkFlags {
fn from(flags: u16) -> Self {
NetlinkFlags(flags)
}
}
impl<'a> From<&'a NetlinkFlags> for u16 {
fn from(flags: &'a NetlinkFlags) -> u16 {
flags.0
}
}
impl From<NetlinkFlags> for u16 {
fn from(flags: NetlinkFlags) -> u16 {
flags.0
}
}
impl Default for NetlinkFlags {
fn default() -> Self {
NetlinkFlags::new()
}
}
impl NetlinkFlags {
pub fn new() -> Self {
NetlinkFlags(0)
}
pub fn set_request(&mut self) -> &mut Self {
self.0 |= NLM_F_REQUEST;
self
}
pub fn has_request(self) -> bool {
self.0 & NLM_F_REQUEST == NLM_F_REQUEST
}
pub fn set_multipart(&mut self) -> &mut Self {
self.0 |= NLM_F_MULTIPART;
self
}
pub fn has_multipart(self) -> bool {
self.0 & NLM_F_MULTIPART == NLM_F_MULTIPART
}
pub fn set_ack(&mut self) -> &mut Self {
self.0 |= NLM_F_ACK;
self
}
pub fn has_ack(self) -> bool {
self.0 & NLM_F_ACK == NLM_F_ACK
}
pub fn set_echo(&mut self) -> &mut Self {
self.0 |= NLM_F_ECHO;
self
}
pub fn has_echo(self) -> bool {
self.0 & NLM_F_ECHO == NLM_F_ECHO
}
pub fn set_dump_intr(&mut self) -> &mut Self {
self.0 |= NLM_F_DUMP_INTR;
self
}
pub fn has_dump_intr(self) -> bool {
self.0 & NLM_F_DUMP_INTR == NLM_F_DUMP_INTR
}
pub fn set_dump_filterd(&mut self) -> &mut Self {
self.0 |= NLM_F_DUMP_FILTERED;
self
}
pub fn has_dump_filterd(self) -> bool {
self.0 & NLM_F_DUMP_FILTERED == NLM_F_DUMP_FILTERED
}
pub fn set_root(&mut self) -> &mut Self {
self.0 |= NLM_F_ROOT;
self
}
pub fn has_root(self) -> bool {
self.0 & NLM_F_ROOT == NLM_F_ROOT
}
pub fn set_match(&mut self) -> &mut Self {
self.0 |= NLM_F_MATCH;
self
}
pub fn has_match(self) -> bool {
self.0 & NLM_F_MATCH == NLM_F_MATCH
}
pub fn set_atomic(&mut self) -> &mut Self {
self.0 |= NLM_F_ATOMIC;
self
}
pub fn has_atomic(self) -> bool {
self.0 & NLM_F_ATOMIC == NLM_F_ATOMIC
}
pub fn set_dump(&mut self) -> &mut Self {
self.0 |= NLM_F_DUMP;
self
}
pub fn has_dump(self) -> bool {
self.0 & NLM_F_DUMP == NLM_F_DUMP
}
pub fn set_replace(&mut self) -> &mut Self {
self.0 |= NLM_F_REPLACE;
self
}
pub fn has_replace(self) -> bool {
self.0 & NLM_F_REPLACE == NLM_F_REPLACE
}
pub fn set_excl(&mut self) -> &mut Self {
self.0 |= NLM_F_EXCL;
self
}
pub fn has_excl(self) -> bool {
self.0 & NLM_F_EXCL == NLM_F_EXCL
}
pub fn set_create(&mut self) -> &mut Self {
self.0 |= NLM_F_CREATE;
self
}
pub fn has_create(self) -> bool {
self.0 & NLM_F_CREATE == NLM_F_CREATE
}
pub fn set_append(&mut self) -> &mut Self {
self.0 |= NLM_F_APPEND;
self
}
pub fn has_append(self) -> bool {
self.0 & NLM_F_APPEND == NLM_F_APPEND
}
pub fn set_nonrec(&mut self) -> &mut Self {
self.0 |= NLM_F_NONREC;
self
}
pub fn has_nonrec(self) -> bool {
self.0 & NLM_F_NONREC == NLM_F_NONREC
}
pub fn set_ack_tvls(&mut self) -> &mut Self {
self.0 |= NLM_F_ACK_TLVS;
self
}
pub fn has_ack_tvls(self) -> bool {
self.0 & NLM_F_ACK_TLVS == NLM_F_ACK_TLVS
}
pub fn set_capped(&mut self) -> &mut Self {
self.0 |= NLM_F_CAPPED;
self
}
pub fn has_capped(self) -> bool {
self.0 & NLM_F_CAPPED == NLM_F_CAPPED
}
}