diff options
author | Himbeer <himbeer@disroot.org> | 2024-08-20 12:53:45 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-08-20 12:53:45 +0200 |
commit | ac90fec5f9afe906c516fc06480d9c882587f272 (patch) | |
tree | eb5cf36a83df90f940be30857e613d1b272ea5ec | |
parent | e9e73abcba5022e6bda82c352e0320d4e28e0ea4 (diff) |
Announce ULA prefixes
-rw-r--r-- | src/main.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index dd528fa..0465151 100644 --- a/src/main.rs +++ b/src/main.rs @@ -147,7 +147,7 @@ fn create_ra_pkt(link: String) -> Result<(Vec<u8>, Vec<Ipv6Addr>)> { } }); - for prefix in ipv6_addrs.filter(is_gua) { + for prefix in ipv6_addrs.filter(|addr| is_gua(addr) || is_ula(addr)) { let mut prefix_data = [ 64, // Prefix Length, always /64 0xc0, // Flags: On-Link + SLAAC @@ -229,3 +229,10 @@ fn is_gua(addr: &Ipv6Addr) -> bool { let first_octet_trunc = addr.octets()[0] & 0xe0; first_octet_trunc == 0x20 } + +/// Checks whether an IPv6 address is part of the `fc00::/7` network. +fn is_ula(addr: &Ipv6Addr) -> bool { + // Stable implementation of [`Ipv6Addr::is_unique_local`]. + // Tracking issue: https://github.com/rust-lang/rust/issues/27709 for + (addr.segments()[0] & 0xfe00) == 0xfc00 +} |