- @staticmethod
- def union_addr(ip_addr):
- """Creates union IP address.
-
- :param ip_addr: IPv4 or IPv6 address.
- :type ip_addr: IPv4Address or IPv6Address
- :returns: Union IP address.
- :rtype: dict
- """
- return dict(ip6=ip_addr.packed) if ip_addr.version == 6 \
- else dict(ip4=ip_addr.packed)
-
- @staticmethod
- def create_ip_address_object(ip_addr):
- """Create IP address object.
-
- :param ip_addr: IPv4 or IPv6 address
- :type ip_addr: IPv4Address or IPv6Address
- :returns: IP address object.
- :rtype: dict
- """
- return dict(
- af=getattr(
- AddressFamily, u"ADDRESS_IP6" if ip_addr.version == 6
- else u"ADDRESS_IP4"
- ).value,
- un=IPUtil.union_addr(ip_addr)
- )
-