- 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:
- raise Exception("Comparing VppIpPrefix:%s with unknown type: %s" %
- (self, other))
- return False
-
-
-class VppIpMPrefix():
- def __init__(self, saddr, gaddr, len):
- self.saddr = saddr
- self.gaddr = gaddr
- self.len = len
- self.ip_saddr = ip_address(unicode(self.saddr))
- self.ip_gaddr = ip_address(unicode(self.gaddr))
-
- def encode(self):
-
- if 6 is self.ip_saddr.version:
- prefix = {
- 'af': VppEnum.vl_api_address_family_t.ADDRESS_IP6,
- 'grp_address': {
- 'ip6': {
- 'address': self.ip_gaddr.packed
- },
- },
- 'src_address': {
- 'ip6': {
- 'address': self.ip_saddr.packed
- },
- },
- 'grp_address_length': self.len,
- }
- else:
- prefix = {
- 'af': VppEnum.vl_api_address_family_t.ADDRESS_IP4,
- 'grp_address': {
- 'ip4': {
- 'address': self.ip_gaddr.packed
- },
- },
- 'src_address': {
- 'ip4': {
- 'address': self.ip_saddr.packed
- },
- },
- 'grp_address_length': self.len,
- }
- return prefix
+ return (self.glen == other.glen and
+ self.saddr == other.gaddr and
+ self.saddr == other.saddr)
+ elif (hasattr(other, "grp_address_length") and
+ hasattr(other, "grp_address") and
+ hasattr(other, "src_address")):
+ # vl_api_mprefix_t
+ if 4 == self.version:
+ return (self.glen == other.grp_address_length and
+ self.gaddr == str(other.grp_address.ip4) and
+ self.saddr == str(other.src_address.ip4))
+ else:
+ return (self.glen == other.grp_address_length and
+ self.gaddr == str(other.grp_address.ip6) and
+ self.saddr == str(other.src_address.ip6))
+ return NotImplemented