aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/error.rs2
-rw-r--r--src/expr/mod.rs2
-rw-r--r--src/nlmsg.rs2
-rw-r--r--src/parser.rs6
-rw-r--r--src/parser_impls.rs2
5 files changed, 7 insertions, 7 deletions
diff --git a/src/error.rs b/src/error.rs
index b7ae17b..b2aff3a 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -110,7 +110,7 @@ pub enum DecodeError {
MissingExpressionName,
#[error("Unsupported attribute type")]
- UnsupportedAttributeType(u16),
+ UnsupportedAttributeType(u32),
#[error("Unexpected message type")]
UnexpectedType(u16),
diff --git a/src/expr/mod.rs b/src/expr/mod.rs
index f8fd67d..f72dcb6 100644
--- a/src/expr/mod.rs
+++ b/src/expr/mod.rs
@@ -130,7 +130,7 @@ macro_rules! create_expr_variant {
impl $crate::nlmsg::AttributeDecoder for RawExpression {
fn decode_attribute(
&mut self,
- attr_type: u16,
+ attr_type: u32,
buf: &[u8],
) -> Result<(), $crate::error::DecodeError> {
debug!("Decoding attribute {} in an expression", attr_type);
diff --git a/src/nlmsg.rs b/src/nlmsg.rs
index b8fa857..5f0e554 100644
--- a/src/nlmsg.rs
+++ b/src/nlmsg.rs
@@ -113,7 +113,7 @@ impl<'a> NfNetlinkWriter<'a> {
}
}
-pub type NetlinkType = u16;
+pub type NetlinkType = u32;
pub trait AttributeDecoder {
fn decode_attribute(&mut self, attr_type: NetlinkType, buf: &[u8]) -> Result<(), DecodeError>;
diff --git a/src/parser.rs b/src/parser.rs
index 82dd27e..fd71fdd 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -112,9 +112,9 @@ pub fn write_attribute<'a>(ty: NetlinkType, obj: &impl NfNetlinkAttribute, mut b
// nla_len contains the header size + the unpadded attribute length
nla_len: (header_len + obj.get_size() as usize) as u16,
nla_type: if obj.is_nested() {
- ty | NLA_F_NESTED as u16
+ (ty | NLA_F_NESTED) as u16
} else {
- ty
+ ty as u16
},
};
@@ -138,7 +138,7 @@ pub(crate) fn read_attributes<T: AttributeDecoder + Default>(buf: &[u8]) -> Resu
while remaining_size > pad_netlink_object::<nlattr>() {
let nlattr = unsafe { *transmute::<*const u8, *const nlattr>(buf[pos..].as_ptr()) };
// ignore the byteorder and nested attributes
- let nla_type = nlattr.nla_type & NLA_TYPE_MASK as u16;
+ let nla_type: u32 = (nlattr.nla_type & NLA_TYPE_MASK as u16).into();
pos += pad_netlink_object::<nlattr>();
let attr_remaining_size = nlattr.nla_len as usize - pad_netlink_object::<nlattr>();
diff --git a/src/parser_impls.rs b/src/parser_impls.rs
index c49c876..28ef8de 100644
--- a/src/parser_impls.rs
+++ b/src/parser_impls.rs
@@ -193,7 +193,7 @@ where
while buf.len() - pos > pad_netlink_object::<nlattr>() {
let nlattr = unsafe { *transmute::<*const u8, *const nlattr>(buf[pos..].as_ptr()) };
// ignore the byteorder and nested attributes
- let nla_type = nlattr.nla_type & NLA_TYPE_MASK as u16;
+ let nla_type: u32 = (nlattr.nla_type & NLA_TYPE_MASK as u16).into();
if nla_type != NFTA_LIST_ELEM {
return Err(DecodeError::UnsupportedAttributeType(nla_type));