mirror of
https://github.com/espressif/openthread.git
synced 2026-08-24 19:29:52 +00:00
[posix] add unified platform API for setting NAT64 CIDR during runtime (#8947)
We should notice that the default CIDR (`192.168.255.0/24`) is not safe to use, however, in most cases, the CIDR used can only be determined during runtime since the single binary might be distributed to BRs in different network conditions. And we cannot conclude an always safe CIDR in all conditions. This commit will emit an event when NAT64 CIDR is changed. So the platform driver can update the route for NAT64.
This commit is contained in:
@@ -413,6 +413,19 @@ class OtbrDocker:
|
||||
def nat64_set_enabled(self, enable):
|
||||
return self.call_dbus_method('io.openthread.BorderRouter', 'SetNat64Enabled', enable)
|
||||
|
||||
@property
|
||||
def nat64_cidr(self):
|
||||
self.send_command('nat64 cidr')
|
||||
cidr = self._expect_command_output()[0].strip()
|
||||
return ipaddress.IPv4Network(cidr, strict=False)
|
||||
|
||||
@nat64_cidr.setter
|
||||
def nat64_cidr(self, cidr: ipaddress.IPv4Network):
|
||||
if not isinstance(cidr, ipaddress.IPv4Network):
|
||||
raise ValueError("cidr is expected to be an instance of ipaddress.IPv4Network")
|
||||
self.send_command(f'nat64 cidr {cidr}')
|
||||
self._expect_done()
|
||||
|
||||
@property
|
||||
def nat64_state(self):
|
||||
state = self.get_dbus_property('Nat64State')
|
||||
|
||||
Reference in New Issue
Block a user