Skip to content

Commit 90b0556

Browse files
committed
nla: Copy from utils
Signed-off-by: Enrique Llorente <[email protected]>
1 parent 448cf26 commit 90b0556

File tree

3 files changed

+400
-0
lines changed

3 files changed

+400
-0
lines changed

src/error.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ impl DecodeError {
8787
msg: format!("Invalid number. Expected {expected} bytes, received {received} bytes"),
8888
}
8989
}
90+
91+
pub fn nla_buffer_too_small(buffer_len: usize, nla_len: usize) -> Self {
92+
Self{
93+
msg: format!("buffer has length {buffer_len}, but an NLA header is {nla_len} bytes"),
94+
}
95+
}
96+
97+
pub fn nla_length_mismatch(buffer_len: usize, nla_len: usize) -> Self {
98+
Self{
99+
msg: format!("buffer has length: {buffer_len}, but the NLA is {nla_len} bytes"),
100+
}
101+
}
102+
103+
pub fn nla_invalid_length(buffer_len: usize, nla_len: usize) -> Self {
104+
Self{
105+
msg: format!("NLA has invalid length: {nla_len} (should be at least {buffer_len} bytes)"),
106+
}
107+
}
90108
}
91109

92110
#[derive(Debug, PartialEq, Eq, Clone)]

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,8 @@ pub use self::constants::*;
271271
pub mod parsers;
272272
pub use self::parsers::*;
273273

274+
pub mod nla;
275+
pub use self::nla::*;
276+
274277
#[macro_use]
275278
mod macros;

0 commit comments

Comments
 (0)