- return self.address
-
- @property
- def bytes(self):
- return self.addr.bytes
-
- @property
- def address(self):
- return self.addr.address
-
- @property
- def length(self):
- return self.addr.length
-
- @property
- def version(self):
- return self.addr.version
-
- @property
- def is_ip6(self):
- return (self.version == 6)
-
- @property
- def af(self):
- if self.version == 6:
- return AF_INET6
- else:
- return AF_INET
-
- @property
- def dpo_proto(self):
- if self.version == 6:
- return DpoProto.DPO_PROTO_IP6
- else:
- return DpoProto.DPO_PROTO_IP4
-
-
-class VppIpPrefix():
- def __init__(self, addr, len):
- self.addr = VppIpAddress(addr)
- self.len = len
-
- def __eq__(self, other):
- if self.address == other.address and self.len == other.len:
- return True
- return False
-
- def encode(self):
- return {'address': self.addr.encode(),
- 'address_length': self.len}
-
- @property
- def version(self):
- return self.addr.version
-
- @property
- def address(self):
- return self.addr.address
-
- @property
- def bytes(self):
- return self.addr.bytes
-
- @property
- def length(self):
- return self.len
-
- @property
- def is_ip6(self):
- return self.addr.is_ip6
-
- def __str__(self):
- return "%s/%d" % (self.address, self.length)
-
- def __eq__(self, other):
- if isinstance(other, self.__class__):
- return (self.len == other.len and self.addr == other.addr)
- elif hasattr(other, "address") and hasattr(other, "address_length"):
- # vl_api_prefix_t
- return self.len == other.address_length and \
- self.addr == other.address
- else:
- _log.error(
- "Comparing VppIpPrefix:%s with incomparable type: %s" %
- (self, other))
- return NotImplemented