diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-22 13:55:37 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-22 13:55:37 +0100 |
commit | e810686e00d121a3ca71f141e9e297c9760f0fd7 (patch) | |
tree | f94b4dbc4870b14db4cc2d0b280972ce8adb6138 | |
parent | 77ae19ceac3f845e4074999e7c1e0c2cd46f85c7 (diff) |
rebind: accept new server id
-rw-r--r-- | src/client.rs | 15 | ||||
-rw-r--r-- | src/main.rs | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/client.rs b/src/client.rs index c5806dd..fdf8b32 100644 --- a/src/client.rs +++ b/src/client.rs @@ -214,6 +214,21 @@ impl Dhcp6c { self.state == Dhcp6cState::Soliciting } + /// Reports whether the `Dhcp6c` is in the `Rebinding` state. + pub fn is_rebinding(&self) -> bool { + self.state == Dhcp6cState::Rebinding + } + + /// Reports whether the `Dhcp6c` is in the `Rerouting` state. + pub fn is_rerouting(&self) -> bool { + self.state == Dhcp6cState::Rerouting + } + + /// Reports whether the `Dhcp6c` is in a state that accepts new server IDs. + pub fn accept_new_server_id(&self) -> bool { + self.is_soliciting() || self.is_rebinding() || self.is_rerouting() + } + /// Returns a watch channel receiver that can be used to monitor whether /// the `Dhcp6c` has a valid and routed prefix. /// This is equivalent to the `Renewing`, `Rebinding` and `Opened` states. diff --git a/src/main.rs b/src/main.rs index 01f622e..8b949ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -255,7 +255,7 @@ fn handle(dhcp6: &mut Dhcp6, dhcp6c: &mut Dhcp6c, buf: &[u8]) -> Result<()> { )); } - if dhcp6c.is_soliciting() { + if dhcp6c.accept_new_server_id() { dhcp6.server_id = server_id.to_vec(); } else if server_id != &dhcp6.server_id { return Err(Error::WrongServerId( |