X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_ip.py;h=7f3a6b01e95cd66fec583542b6e72a5514dd906d;hb=8c8acc027871f97370ee549306876690030c3bbb;hp=6d22c16ff609dc51f57d4edb76d12f75abd2af2f;hpb=93cc3ee3b3a9c9224a1446625882205f3282a949;p=vpp.git diff --git a/test/vpp_ip.py b/test/vpp_ip.py index 6d22c16ff60..7f3a6b01e95 100644 --- a/test/vpp_ip.py +++ b/test/vpp_ip.py @@ -27,17 +27,9 @@ class VppIpAddressUnion(): def encode(self): if self.version is 6: - return { - 'ip6': { - 'address': self.ip_addr.packed - }, - } + return {'ip6': self.ip_addr.packed} else: - return { - 'ip4': { - 'address': self.ip_addr.packed - }, - } + return {'ip4': self.ip_addr.packed} @property def version(self): @@ -64,9 +56,9 @@ class VppIpAddressUnion(): elif hasattr(other, "ip4") and hasattr(other, "ip6"): # vl_api_address_union_t if 4 is self.version: - return self.ip_addr.packed == other.ip4.address + return self.ip_addr.packed == other.ip4 else: - return self.ip_addr.packed == other.ip6.address + return self.ip_addr.packed == other.ip6 else: raise Exception("Comparing VppIpAddresUnions:%s" " with unknown type: %s" % @@ -200,6 +192,20 @@ class VppIpPrefix(): return False +class VppIp6Prefix(): + def __init__(self, prefix, prefixlen): + self.ip_prefix = ip_address(unicode(prefix)) + self.prefixlen = prefixlen + + def encode(self): + return {'prefix': self.ip_prefix.packed, + 'len': self.prefixlen} + + +class VppIp4Prefix(VppIp6Prefix): + pass + + class VppIpMPrefix(): def __init__(self, saddr, gaddr, len): self.saddr = saddr @@ -213,31 +219,15 @@ class VppIpMPrefix(): 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': {'ip6': self.ip_gaddr.packed}, + 'src_address': {'ip6': 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': {'ip4': self.ip_gaddr.packed}, + 'src_address': {'ip4': self.ip_saddr.packed}, 'grp_address_length': self.len, } return prefix