diff options
-rw-r--r-- | src/plugins/lb/lb.api | 10 | ||||
-rw-r--r-- | src/plugins/lb/lb_types.api | 2 | ||||
-rwxr-xr-x | src/tools/vppapigen/vppapigen.py | 7 | ||||
-rw-r--r-- | src/tools/vppapigen/vppapigen_c.py | 19 | ||||
-rw-r--r-- | src/tools/vppapigen/vppapigen_json.py | 3 | ||||
-rw-r--r-- | src/vnet/ip/ip.api | 4 | ||||
-rw-r--r-- | src/vnet/ip/ip_types.api | 17 | ||||
-rw-r--r-- | src/vnet/mpls/mpls.api | 3 | ||||
-rwxr-xr-x | src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py | 94 | ||||
-rw-r--r-- | src/vpp-api/python/vpp_papi/vpp_format.py | 72 | ||||
-rw-r--r-- | src/vpp-api/python/vpp_papi/vpp_serializer.py | 20 | ||||
-rwxr-xr-x | src/vpp-api/vapi/vapi_c_gen.py | 4 | ||||
-rw-r--r-- | src/vpp-api/vapi/vapi_json_parser.py | 30 | ||||
-rw-r--r-- | test/vpp_ip_route.py | 2 |
14 files changed, 241 insertions, 46 deletions
diff --git a/src/plugins/lb/lb.api b/src/plugins/lb/lb.api index 867832df966..b9f5c22126a 100644 --- a/src/plugins/lb/lb.api +++ b/src/plugins/lb/lb.api @@ -39,7 +39,7 @@ autoreply manual_print define lb_conf autoreply manual_print define lb_add_del_vip { u32 client_index; u32 context; - vl_api_prefix_t pfx; + vl_api_address_with_prefix_t pfx; u8 protocol [default=255]; u16 port; vl_api_lb_encap_type_t encap; @@ -64,7 +64,7 @@ autoreply manual_print define lb_add_del_vip { autoreply manual_print define lb_add_del_as { u32 client_index; u32 context; - vl_api_prefix_t pfx; + vl_api_address_with_prefix_t pfx; u8 protocol [default=255]; u16 port; vl_api_address_t as_address; @@ -82,7 +82,7 @@ autoreply manual_print define lb_add_del_as { autoreply manual_print define lb_flush_vip { u32 client_index; u32 context; - vl_api_prefix_t pfx; + vl_api_address_with_prefix_t pfx; u8 protocol; u16 port; }; @@ -94,7 +94,7 @@ autoreply manual_print define lb_flush_vip { define lb_vip_dump{ u32 client_index; u32 context; - vl_api_prefix_t pfx; + vl_api_address_with_prefix_t pfx; vl_api_prefix_matcher_t pfx_matcher; u8 protocol [default=255]; u16 port; @@ -126,7 +126,7 @@ define lb_as_dump{ u32 client_index; u32 context; /* vip */ - vl_api_prefix_t pfx; + vl_api_address_with_prefix_t pfx; u8 protocol; u16 port; }; diff --git a/src/plugins/lb/lb_types.api b/src/plugins/lb/lb_types.api index 818e51462c5..8f3cb3ae1cf 100644 --- a/src/plugins/lb/lb_types.api +++ b/src/plugins/lb/lb_types.api @@ -67,7 +67,7 @@ enum lb_nat_protocol */ typeonly define lb_vip { - vl_api_prefix_t pfx; + vl_api_address_with_prefix_t pfx; vl_api_ip_proto_t protocol; u16 port; }; diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py index 22c80e900b9..c5304db834c 100755 --- a/src/tools/vppapigen/vppapigen.py +++ b/src/tools/vppapigen/vppapigen.py @@ -177,6 +177,9 @@ class Using(): def __init__(self, name, alias): self.name = name self.vla = False + self.block = [] + self.manual_print = True + self.manual_endian = True if isinstance(alias, Array): a = {'type': alias.fieldtype, @@ -689,7 +692,6 @@ class VPPAPI(object): s['Service'] = [] s['types'] = [] s['Import'] = [] - s['Alias'] = {} crc = 0 for o in objs: tname = o.__class__.__name__ @@ -709,10 +711,9 @@ class VPPAPI(object): s['Service'].append(o2) elif (isinstance(o, Enum) or isinstance(o, Typedef) or + isinstance(o, Using) or isinstance(o, Union)): s['types'].append(o) - elif isinstance(o, Using): - s['Alias'][o.name] = o.alias else: if tname not in s: raise ValueError('Unknown class type: {} {}' diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py index c1bc11d4a12..a97d01b6805 100644 --- a/src/tools/vppapigen/vppapigen_c.py +++ b/src/tools/vppapigen/vppapigen_c.py @@ -103,7 +103,7 @@ def api2c(fieldtype): return fieldtype -def typedefs(objs, aliases, filename): +def typedefs(objs, filename): name = filename.replace('.', '_') output = '''\ @@ -116,18 +116,15 @@ def typedefs(objs, aliases, filename): ''' output = output.format(module=name) - for k, v in aliases.items(): - output += duplicate_wrapper_head(k) - if 'length' in v: - output += 'typedef %s vl_api_%s_t[%s];\n' % (v['type'], k, v['length']) - else: - output += 'typedef %s vl_api_%s_t;\n' % (v['type'], k) - output += duplicate_wrapper_tail() - for o in objs: tname = o.__class__.__name__ output += duplicate_wrapper_head(o.name) - if tname == 'Enum': + if tname == 'Using': + if 'length' in o.alias: + output += 'typedef %s vl_api_%s_t[%s];\n' % (o.alias['type'], o.name, o.alias['length']) + else: + output += 'typedef %s vl_api_%s_t;\n' % (o.alias['type'], o.name) + elif tname == 'Enum': if o.enumtype == 'u32': output += "typedef enum {\n" else: @@ -311,7 +308,7 @@ def run(input_filename, s): output += msg_ids(s) output += msg_names(s) output += msg_name_crc_list(s, filename) - output += typedefs(s['types'] + s['Define'], s['Alias'], filename + file_extension) + output += typedefs(s['types'] + s['Define'], filename + file_extension) output += printfun(s['types'] + s['Define']) output += endianfun(s['types'] + s['Define']) output += version_tuple(s, basename) diff --git a/src/tools/vppapigen/vppapigen_json.py b/src/tools/vppapigen/vppapigen_json.py index 124c0d3a0bd..95f9e5e63ce 100644 --- a/src/tools/vppapigen/vppapigen_json.py +++ b/src/tools/vppapigen/vppapigen_json.py @@ -55,7 +55,6 @@ def walk_defs(s, is_message = False): r.append(d) return r - # # Plugin entry point # @@ -68,6 +67,6 @@ def run(filename, s): j['enums'] = walk_enums([o for o in s['types'] if o.__class__.__name__ == 'Enum']) j['services'] = walk_services(s['Service']) j['options'] = s['Option'] - j['aliases'] = s['Alias'] + j['aliases'] = {o.name:o.alias for o in s['types'] if o.__class__.__name__ == 'Using'} j['vl_api_version'] = hex(s['file_crc']) return json.dumps(j, indent=4, separators=(',', ': ')) diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api index 2dae4385602..e6b9b348cfc 100644 --- a/src/vnet/ip/ip.api +++ b/src/vnet/ip/ip.api @@ -29,7 +29,7 @@ import "vnet/mfib/mfib_types.api"; /** \brief An IP table @param is_ipv6 - V4 or V6 table @param table_id - table ID associated with the route - This table ID will apply to both the unicats + This table ID will apply to both the unicats and mlticast FIBs @param name - A client provided name/tag for the table. If this is not set by the client, then VPP will generate something @@ -496,7 +496,7 @@ define ip_address_details { u32 context; u32 sw_if_index; - vl_api_prefix_t prefix; + vl_api_address_with_prefix_t prefix; }; define ip_address_dump diff --git a/src/vnet/ip/ip_types.api b/src/vnet/ip/ip_types.api index af8f6231285..bc1b5adbcdb 100644 --- a/src/vnet/ip/ip_types.api +++ b/src/vnet/ip/ip_types.api @@ -107,6 +107,23 @@ typedef ip4_prefix { u8 len; }; +/** \brief + * + * The vl_api_[ip4|ip6]_address_with_prefix_t types are used as a type to denote + * both an IP address and a prefix. I.e. in CIDR notation + * '192.168.10.1/24' the address is 192.168.10.1 and the network + * prefix is 192.168.10.0/24. + * + * If only an address is needed use: vl_api_address_t types and if + * only a network prefix is needed (i.e. no hosts bits), then use the + * vl_api_prefix_t types. + * + **/ + +typedef vl_api_prefix_t address_with_prefix; +typedef vl_api_ip4_prefix_t ip4_address_with_prefix; +typedef vl_api_ip6_prefix_t ip6_address_with_prefix; + /** \brief A context for matching prefixes against. (Think ip prefix list.) The meaning (exact match / want subnets) of an unset matcher is left to the implementer. @param le - le mut be <= to prefix.len. Default: 255 (not set). diff --git a/src/vnet/mpls/mpls.api b/src/vnet/mpls/mpls.api index 5d85812807a..0de47660774 100644 --- a/src/vnet/mpls/mpls.api +++ b/src/vnet/mpls/mpls.api @@ -26,8 +26,7 @@ import "vnet/ip/ip_types.api"; @param mb_ip_table_id - The IP table-id of the IP prefix to bind to. @param mb_is_bind - Bind or unbind @param mb_is_ip4 - The prefix to bind to is IPv4 - @param mb_address_length - Length of IP prefix - @param mb_address[16] - IP prefix/ + @param mb_prefix - IP prefix */ autoreply define mpls_ip_bind_unbind { diff --git a/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py b/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py index 6ca8e6c4ff3..9ac3e78224c 100755 --- a/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py +++ b/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py @@ -104,6 +104,10 @@ class TestAddType(unittest.TestCase): [['vl_api_address_family_t', 'af'], ['vl_api_address_union_t', 'un']]) + prefix = VPPType('vl_api_prefix_t', + [['vl_api_address_t', 'address'], + ['u8', 'len']]) + va_address_list = VPPType('list_addresses', [['u8', 'count'], ['vl_api_address_t', 'addresses', @@ -151,6 +155,96 @@ class TestAddType(unittest.TestCase): nt, size = message_with_va_address_list.unpack(b) self.assertEqual(nt.is_cool, 100) + def test_address_with_prefix(self): + af = VPPEnumType('vl_api_address_family_t', [["ADDRESS_IP4", 0], + ["ADDRESS_IP6", 1], + {"enumtype": "u32"}]) + ip4 = VPPTypeAlias('vl_api_ip4_address_t', {'type': 'u8', + 'length': 4}) + ip6 = VPPTypeAlias('vl_api_ip6_address_t', {'type': 'u8', + 'length': 16}) + VPPUnionType('vl_api_address_union_t', + [["vl_api_ip4_address_t", "ip4"], + ["vl_api_ip6_address_t", "ip6"]]) + + address = VPPType('vl_api_address_t', + [['vl_api_address_family_t', 'af'], + ['vl_api_address_union_t', 'un']]) + + + prefix = VPPType('vl_api_prefix_t', + [['vl_api_address_t', 'address'], + ['u8', 'len']]) + prefix4 = VPPType('vl_api_ip4_prefix_t', + [['vl_api_ip4_address_t', 'address'], + ['u8', 'len']]) + prefix6 = VPPType('vl_api_ip6_prefix_t', + [['vl_api_ip6_address_t', 'address'], + ['u8', 'len']]) + + address_with_prefix = VPPTypeAlias('vl_api_address_with_prefix_t', {'type': 'vl_api_prefix_t' }) + address4_with_prefix = VPPTypeAlias('vl_api_ip4_address_with_prefix_t', + {'type': 'vl_api_ip4_prefix_t' }) + address6_with_prefix = VPPTypeAlias('vl_api_ip6_address_with_prefix_t', + {'type': 'vl_api_ip6_prefix_t' }) + + awp_type = VPPType('foobar_t', + [['vl_api_address_with_prefix_t', 'address']]) + + # address with prefix + b = address_with_prefix.pack(IPv4Interface('2.2.2.2/24')) + self.assertEqual(len(b), 21) + nt, size = address_with_prefix.unpack(b) + self.assertTrue(isinstance(nt, IPv4Interface)) + self.assertEqual(str(nt), '2.2.2.2/24') + + b = address_with_prefix.pack(IPv6Interface('2::2/64')) + self.assertEqual(len(b), 21) + nt, size = address_with_prefix.unpack(b) + self.assertTrue(isinstance(nt, IPv6Interface)) + self.assertEqual(str(nt), '2::2/64') + + b = address_with_prefix.pack(IPv4Network('2.2.2.2/24', strict=False)) + self.assertEqual(len(b), 21) + nt, size = address_with_prefix.unpack(b) + self.assertTrue(isinstance(nt, IPv4Interface)) + self.assertEqual(str(nt), '2.2.2.0/24') + + b = address4_with_prefix.pack('2.2.2.2/24') + self.assertEqual(len(b), 5) + nt, size = address4_with_prefix.unpack(b) + self.assertTrue(isinstance(nt, IPv4Interface)) + self.assertEqual(str(nt), '2.2.2.2/24') + b = address4_with_prefix.pack(IPv4Interface('2.2.2.2/24')) + self.assertEqual(len(b), 5) + + b = address6_with_prefix.pack('2::2/64') + self.assertEqual(len(b), 17) + nt, size = address6_with_prefix.unpack(b) + self.assertTrue(isinstance(nt, IPv6Interface)) + self.assertEqual(str(nt), '2::2/64') + b = address6_with_prefix.pack(IPv6Interface('2::2/64')) + self.assertEqual(len(b), 17) + + b = prefix.pack('192.168.10.0/24') + self.assertEqual(len(b), 21) + nt, size = prefix.unpack(b) + self.assertTrue(isinstance(nt, IPv4Network)) + self.assertEqual(str(nt), '192.168.10.0/24') + + b = awp_type.pack({'address': '1.2.3.4/24'}) + self.assertEqual(len(b), 21) + nt, size = awp_type.unpack(b) + self.assertTrue(isinstance(nt.address, IPv4Interface)) + self.assertEqual(str(nt.address), '1.2.3.4/24') + + b = awp_type.pack({'address': IPv4Interface('1.2.3.4/24')}) + self.assertEqual(len(b), 21) + nt, size = awp_type.unpack(b) + self.assertTrue(isinstance(nt.address, IPv4Interface)) + self.assertEqual(str(nt.address), '1.2.3.4/24') + + def test_recursive_address(self): af = VPPEnumType('vl_api_address_family_t', [["ADDRESS_IP4", 0], ["ADDRESS_IP6", 1], diff --git a/src/vpp-api/python/vpp_papi/vpp_format.py b/src/vpp-api/python/vpp_papi/vpp_format.py index 7d2dcba491a..3e836c9da6b 100644 --- a/src/vpp-api/python/vpp_papi/vpp_format.py +++ b/src/vpp-api/python/vpp_papi/vpp_format.py @@ -52,6 +52,15 @@ def format_vl_api_prefix_t(args): return {'address': format_vl_api_address_t(p), 'len': int(length)} +def format_vl_api_address_with_prefix_t(args): + if isinstance(args, (ipaddress.IPv4Interface, ipaddress.IPv6Interface)): + return {'address': format_vl_api_address_t( + text_type(args.network_address)), + 'len': int(args.prefixlen)} + p, length = args.split('/') + return {'address': format_vl_api_address_t(p), + 'len': int(length)} + def format_vl_api_ip6_prefix_t(args): if isinstance(args, ipaddress.IPv6Network): @@ -61,6 +70,13 @@ def format_vl_api_ip6_prefix_t(args): return {'address': inet_pton(AF_INET6, p), 'len': int(length)} +def format_vl_api_ip6_address_with_prefix_t(args): + if isinstance(args, ipaddress.IPv6Interface): + return {'address': args.network_address.packed, + 'len': int(args.prefixlen)} + p, length = args.split('/') + return {'address': inet_pton(AF_INET6, p), + 'len': int(length)} def format_vl_api_ip4_prefix_t(args): if isinstance(args, ipaddress.IPv4Network): @@ -70,6 +86,14 @@ def format_vl_api_ip4_prefix_t(args): return {'address': inet_pton(AF_INET, p), 'len': int(length)} +def format_vl_api_ip4_address_with_prefix_t(args): + if isinstance(args, ipaddress.IPv4Interface): + return {'address': args.network_address.packed, + 'len': int(args.prefixlen)} + p, length = args.split('/') + return {'address': inet_pton(AF_INET, p), + 'len': int(length)} + conversion_table = { 'vl_api_ip6_address_t': @@ -112,6 +136,30 @@ conversion_table = { 'len': o.prefixlen}, 'str': lambda s: format_vl_api_prefix_t(s) }, + 'vl_api_address_with_prefix_t': + { + 'IPv4Interface': lambda o: {'address': + {'af': ADDRESS_IP4, 'un': + {'ip4': o.packed}}, + 'len': o.network.prefixlen}, + 'IPv6Interface': lambda o: {'address': + {'af': ADDRESS_IP6, 'un': + {'ip6': o.packed}}, + 'len': o.network.prefixlen}, + 'str': lambda s: format_vl_api_address_with_prefix_t(s) + }, + 'vl_api_ip4_address_with_prefix_t': + { + 'IPv4Interface': lambda o: {'address': o.packed, + 'len': o.network.prefixlen}, + 'str': lambda s: format_vl_api_ip4_address_with_prefix_t(s) + }, + 'vl_api_ip6_address_with_prefix_t': + { + 'IPv6Interface': lambda o: {'address': o.packed, + 'len': o.network.prefixlen}, + 'str': lambda s: format_vl_api_ip6_address_with_prefix_t(s) + }, 'vl_api_mac_address_t': { 'MACAddress': lambda o: o.packed, @@ -130,14 +178,33 @@ def unformat_api_address_t(o): return ipaddress.IPv6Address(o.un.ip6) if o.af == 0: return ipaddress.IPv4Address(o.un.ip4) - + raise ValueError('Unknown address family {}'.format(o)) def unformat_api_prefix_t(o): + if o.address.af == 1: + return ipaddress.IPv6Network((o.address.un.ip6, o.len), False) + if o.address.af == 0: + return ipaddress.IPv4Network((o.address.un.ip4, o.len), False) + raise ValueError('Unknown address family {}'.format(o)) + if isinstance(o.address, ipaddress.IPv4Address): return ipaddress.IPv4Network((o.address, o.len), False) if isinstance(o.address, ipaddress.IPv6Address): return ipaddress.IPv6Network((o.address, o.len), False) + raise ValueError('Unknown instance {}', format(o)) + +def unformat_api_address_with_prefix_t(o): + if o.address.af == 1: + return ipaddress.IPv6Interface((o.address.un.ip6, o.len)) + if o.address.af == 0: + return ipaddress.IPv4Interface((o.address.un.ip4, o.len)) + raise ValueError('Unknown address family {}'.format(o)) + +def unformat_api_ip4_address_with_prefix_t(o): + return ipaddress.IPv4Interface((o.address, o.len)) +def unformat_api_ip6_address_with_prefix_t(o): + return ipaddress.IPv6Interface((o.address, o.len)) conversion_unpacker_table = { 'vl_api_ip6_address_t': lambda o: ipaddress.IPv6Address(o), @@ -146,6 +213,9 @@ conversion_unpacker_table = { 'vl_api_ip4_prefix_t': lambda o: ipaddress.IPv4Network((o.address, o.len)), 'vl_api_address_t': lambda o: unformat_api_address_t(o), 'vl_api_prefix_t': lambda o: unformat_api_prefix_t(o), + 'vl_api_address_with_prefix_t': lambda o: unformat_api_address_with_prefix_t(o), + 'vl_api_ip4_address_with_prefix_t': lambda o: unformat_api_ip4_address_with_prefix_t(o), + 'vl_api_ip6_address_with_prefix_t': lambda o: unformat_api_ip6_address_with_prefix_t(o), 'vl_api_mac_address_t': lambda o: macaddress.MACAddress(o), 'vl_api_timestamp_t': lambda o: datetime.datetime.fromtimestamp(o), 'vl_api_timedelta_t': lambda o: datetime.timedelta(seconds=o), diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py index ec6a06bb3d5..00ed8632916 100644 --- a/src/vpp-api/python/vpp_papi/vpp_serializer.py +++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py @@ -414,7 +414,7 @@ class VPPTypeAlias(object): self.name = name t = vpp_get_type(msgdef['type']) if not t: - raise ValueError() + raise ValueError('No such type: {}'.format(msgdef['type'])) if 'length' in msgdef: if msgdef['length'] == 0: raise ValueError() @@ -429,6 +429,7 @@ class VPPTypeAlias(object): self.size = t.size types[name] = self + self.toplevelconversion = False def __call__(self, args): self.options = args @@ -445,8 +446,13 @@ class VPPTypeAlias(object): return self.packer.pack(data, kwargs) def unpack(self, data, offset=0, result=None, ntc=False): + if ntc == False and self.name in vpp_format.conversion_unpacker_table: + # Disable type conversion for dependent types + ntc = True + self.toplevelconversion = True t, size = self.packer.unpack(data, offset, result, ntc=ntc) - if not ntc: + if self.toplevelconversion: + self.toplevelconversion = False return conversion_unpacker(t, self.name), size return t, size @@ -513,6 +519,7 @@ class VPPType(object): self.size = size self.tuple = collections.namedtuple(name, self.fields, rename=True) types[name] = self + self.toplevelconversion = False def __call__(self, args): self.options = args @@ -551,6 +558,11 @@ class VPPType(object): # Return a list of arguments result = [] total = 0 + if ntc == False and self.name in vpp_format.conversion_unpacker_table: + # Disable type conversion for dependent types + ntc = True + self.toplevelconversion = True + for p in self.packers: x, size = p.unpack(data, offset, result, ntc) if type(x) is tuple and len(x) == 1: @@ -559,7 +571,9 @@ class VPPType(object): offset += size total += size t = self.tuple._make(result) - if not ntc: + + if self.toplevelconversion: + self.toplevelconversion = False t = conversion_unpacker(t, self.name) return t, total diff --git a/src/vpp-api/vapi/vapi_c_gen.py b/src/vpp-api/vapi/vapi_c_gen.py index b9b9aa750a8..9a285eb98ad 100755 --- a/src/vpp-api/vapi/vapi_c_gen.py +++ b/src/vpp-api/vapi/vapi_c_gen.py @@ -713,12 +713,12 @@ def gen_json_unified_header(parser, logger, j, io, name): emitted = [] for e in parser.enums_by_json[j]: emit_definition(parser, j, emitted, e) - for a in parser.aliases_by_json[j]: - emit_definition(parser, j, emitted, a) for u in parser.unions_by_json[j]: emit_definition(parser, j, emitted, u) for t in parser.types_by_json[j]: emit_definition(parser, j, emitted, t) + for a in parser.aliases_by_json[j]: + emit_definition(parser, j, emitted, a) for m in parser.messages_by_json[j].values(): emit_definition(parser, j, emitted, m) diff --git a/src/vpp-api/vapi/vapi_json_parser.py b/src/vpp-api/vapi/vapi_json_parser.py index d7669365ce8..98143e26756 100644 --- a/src/vpp-api/vapi/vapi_json_parser.py +++ b/src/vpp-api/vapi/vapi_json_parser.py @@ -377,19 +377,6 @@ class JsonParser(object): self.unions[union.name] = union self.logger.debug("Parsed union: %s" % union) self.unions_by_json[path].append(union) - for name, body in j['aliases'].iteritems(): - if name in self.aliases: - progress = progress + 1 - continue - if 'length' in body: - array_len = body['length'] - else: - array_len = None - t = self.types[body['type']] - alias = self.alias_class(name, t, array_len) - self.aliases[name] = alias - self.logger.debug("Parsed alias: %s" % alias) - self.aliases_by_json[path].append(alias) for t in j['types']: if t[0] in self.types: progress = progress + 1 @@ -408,6 +395,23 @@ class JsonParser(object): self.types[type_.name] = type_ self.types_by_json[path].append(type_) self.logger.debug("Parsed type: %s" % type_) + for name, body in j['aliases'].iteritems(): + if name in self.aliases: + progress = progress + 1 + continue + if 'length' in body: + array_len = body['length'] + else: + array_len = None + try: + t = self.lookup_type_like_id(body['type']) + except ParseError as e: + exceptions.append(e) + continue + alias = self.alias_class(name, t, array_len) + self.aliases[name] = alias + self.logger.debug("Parsed alias: %s" % alias) + self.aliases_by_json[path].append(alias) if not exceptions: # finished parsing break diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py index a70180b3de5..569ccea4d4f 100644 --- a/test/vpp_ip_route.py +++ b/test/vpp_ip_route.py @@ -153,7 +153,7 @@ def fib_interface_ip_prefix(test, address, length, sw_if_index): # TODO: refactor this to VppIpPrefix.__eq__ for a in addrs: if a.sw_if_index == sw_if_index and \ - a.prefix == prefix: + a.prefix.network == prefix: return True return False |