Skip to content

Commit 4627a5c

Browse files
committed
ndisc: add router advertisement validity check
1 parent 29f5db2 commit 4627a5c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/wire/ndiscoption.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,16 @@ pub struct PrefixInformation {
402402
pub prefix: Ipv6Address,
403403
}
404404

405+
impl PrefixInformation {
406+
/// Validates the prefix information option against check a, b, c in
407+
/// https://www.rfc-editor.org/rfc/rfc4862#section-5.5.3
408+
pub fn valid_prefix_info(&self) -> bool {
409+
self.flags.contains(PrefixInfoFlags::ADDRCONF)
410+
&& !self.prefix.is_link_local()
411+
&& self.preferred_lifetime <= self.valid_lifetime
412+
}
413+
}
414+
405415
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
406416
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
407417
pub struct RedirectedHeader<'a> {

0 commit comments

Comments
 (0)