aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.rs15
-rw-r--r--src/main.rs2
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(