diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2024-01-27 23:21:21 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2024-01-27 23:21:21 +0100 |
commit | 54c893bed1e202b48d047280a0c72b63374bf4f4 (patch) | |
tree | aad3483497ff4030e1aad40915c7a7905c84c719 | |
parent | 807230da704731e9b21db32a1f9322b5461c7abf (diff) |
ipv6 subnet id extraction: work well with prefix delegations as tiny as /61
Stops requiring a /48 to work with IPv4. Unlike the tunnel broker the native IPv6 connection I'm using only delegates a /56 which seems to be the most common prefix length.
-rw-r--r-- | src/main.rs | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 2dfadfd..839f717 100644 --- a/src/main.rs +++ b/src/main.rs @@ -355,14 +355,7 @@ fn is_dhcp_known(hostname: &Name, leases: Arc<RwLock<Vec<Lease>>>) -> Result<boo fn subnet_id(addr: &IpAddr) -> u8 { match addr { IpAddr::V4(v4) => v4.octets()[2], - IpAddr::V6(v6) => { - u16::from_be_bytes( - v6.octets()[6..8] - .try_into() - .expect("ipv6 address is less than 8 bytes long, should be 16"), - ) as u8 - * 10 - } + IpAddr::V6(v6) => (v6.octets()[7] & 0x07) * 10, // Max. 8 subnets => assume PD /61. } } |