Skip to content

Commit

Permalink
dhcp client: add basic NAK support
Browse files Browse the repository at this point in the history
  • Loading branch information
etene committed Jan 16, 2025
1 parent e0566b0 commit 2a45a26
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pyroute2/dhcp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,19 @@ async def ack_received(self, pkt: dhcp4msg):
# FIXME: call hooks in a non blocking way (maybe call_soon ?)
for i in self.hooks:
await i.bound(self.lease)
return True

@fsm.state_guard(
fsm.State.REQUESTING,
fsm.State.REBOOTING,
fsm.State.RENEWING,
fsm.State.REBINDING,
)
async def nak_received(self, pkt: dhcp4msg):
await self.transition(to=fsm.State.INIT)
# Reset lease & timers and start again
self._lease = None
self.timers.cancel()
await self.bootstrap()

@fsm.state_guard(fsm.State.SELECTING)
async def offer_received(self, pkt: dhcp4msg):
Expand All @@ -236,7 +248,6 @@ async def offer_received(self, pkt: dhcp4msg):
parameter_list=self.requested_parameters,
),
)
return True

async def __aenter__(self):
self._lease = self.lease_type.load(self.interface)
Expand Down

0 comments on commit 2a45a26

Please sign in to comment.