From: Ondrej Lichtner <olichtne(a)redhat.com>
By default all ip addresses are non-tentative, as this check only makes
sense for ipv6 addresses at the moment.
The IPv6 address class checks the flag for by binary and with 0x40 which
is the flag used by the Linux kernel.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/IpAddress.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lnst/Common/IpAddress.py b/lnst/Common/IpAddress.py
index d8aabcc..2640007 100644
--- a/lnst/Common/IpAddress.py
+++ b/lnst/Common/IpAddress.py
@@ -52,6 +52,11 @@ def _parse_addr(addr):
def __repr__(self):
return "{}({}/{})".format(self.__class__.__name__, str(self),
self.prefixlen)
+ @property
+ def is_tentative(self):
+ #can only be True for IPv6 addresses
+ return False
+
class Ip4Address(BaseIpAddress):
def __init__(self, addr, flags=None):
super(Ip4Address, self).__init__(addr, flags)
@@ -115,6 +120,12 @@ def is_link_local(self):
def is_multicast(self):
return self.addr[:1] == b'\xff'
+ @property
+ def is_tentative(self):
+ #constant from linux/if_addr.h
+ IFA_F_TENTATIVE = 0x40
+ return IFA_F_TENTATIVE & self.flags
+
def ipaddress(addr, flags=None):
"""Factory method to create a BaseIpAddress object"""
if isinstance(addr, BaseIpAddress):
--
2.22.0