From: Christos Sfakianakis csfakian@redhat.com
Add "link_local" attribute in Ip6Address to be used for filtering off ipv6 link-local addresses when this is desirable (e.g by using the "ips_filter" method of the Device module). The value of this attribute is determined by the "is_link_local" method.
Signed-off-by: Christos Sfakianakis csfakian@redhat.com --- lnst/Common/IpAddress.py | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/lnst/Common/IpAddress.py b/lnst/Common/IpAddress.py index e54553d..53dc047 100644 --- a/lnst/Common/IpAddress.py +++ b/lnst/Common/IpAddress.py @@ -12,6 +12,8 @@ olichtne@redhat.com (Ondrej Lichtner)
import re from socket import inet_pton, inet_ntop, AF_INET, AF_INET6 +from binascii import hexlify +import socket from lnst.Common.LnstError import LnstError
#TODO create various generators for IPNetworks and IPaddresses in the same @@ -77,6 +79,7 @@ class Ip6Address(BaseIpAddress): super(Ip6Address, self).__init__(addr)
self.family = AF_INET6 + self.link_local = self.is_link_local()
@staticmethod def _parse_addr(addr): @@ -97,6 +100,10 @@ class Ip6Address(BaseIpAddress):
return addr, prefixlen
+ def is_link_local(self): + left_half = hexlify(socket.inet_pton(socket.AF_INET6, str(self)))[:16] + return left_half == 'fe80000000000000' + def ipaddress(addr): """Factory method to create a BaseIpAddress object""" if isinstance(addr, BaseIpAddress):
On Fri, Jan 18, 2019 at 06:54:46PM +0100, csfakian@redhat.com wrote:
From: Christos Sfakianakis csfakian@redhat.com
Add "link_local" attribute in Ip6Address to be used for filtering off ipv6 link-local addresses when this is desirable (e.g by using the "ips_filter" method of the Device module). The value of this attribute is determined by the "is_link_local" method.
Signed-off-by: Christos Sfakianakis csfakian@redhat.com
lnst/Common/IpAddress.py | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/lnst/Common/IpAddress.py b/lnst/Common/IpAddress.py index e54553d..53dc047 100644 --- a/lnst/Common/IpAddress.py +++ b/lnst/Common/IpAddress.py @@ -12,6 +12,8 @@ olichtne@redhat.com (Ondrej Lichtner)
import re from socket import inet_pton, inet_ntop, AF_INET, AF_INET6 +from binascii import hexlify +import socket from lnst.Common.LnstError import LnstError
#TODO create various generators for IPNetworks and IPaddresses in the same @@ -77,6 +79,7 @@ class Ip6Address(BaseIpAddress): super(Ip6Address, self).__init__(addr)
self.family = AF_INET6
self.link_local = self.is_link_local()
@staticmethod def _parse_addr(addr):
@@ -97,6 +100,10 @@ class Ip6Address(BaseIpAddress):
return addr, prefixlen
- def is_link_local(self):
left_half = hexlify(socket.inet_pton(socket.AF_INET6, str(self)))[:16]
return left_half == 'fe80000000000000'
def ipaddress(addr): """Factory method to create a BaseIpAddress object""" if isinstance(addr, BaseIpAddress): -- 2.17.1 _______________________________________________ LNST-developers mailing list -- lnst-developers@lists.fedorahosted.org To unsubscribe send an email to lnst-developers-leave@lists.fedorahosted.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedorahos...
This looks ok, I'll apply and push to upstream.
-Ondrej
lnst-developers@lists.fedorahosted.org