summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-06-06 14:07:55 -0400
committerNeale Ranns <nranns@cisco.com>2019-06-26 11:36:57 +0000
commitab05508e1eb96749b68de8ccd2f6f88ff3e64fad (patch)
tree05f290dfff68a24810d0a3bdb2f7227ac4608114 /src
parent941da4a224bbfc153bfe7c2344ae00e294d92798 (diff)
api: refactor format_vl_api_prefix_t return keys
format_vl_api_prefix_t returns a dict with keys 'address' and 'address_length', but other format_vl_api_prefix functions return a dict with 'prefix', and 'len'. Refactor all format_vl_api_prefix_t to return consistent keys 'address' and 'len'. Type: refactor Change-Id: I5f9558fc2da8742a303266e011102f5b2db80aad Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/gbp/gbp_api_print.h2
-rw-r--r--src/plugins/map/map_api.c12
-rw-r--r--src/plugins/nat/nat_api.c6
-rw-r--r--src/vat/api_format.c14
-rw-r--r--src/vnet/ip/ip_types.api6
-rw-r--r--src/vnet/ip/ip_types_api.c4
-rw-r--r--src/vnet/ipip/ipip_api.c4
-rwxr-xr-xsrc/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py2
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_format.py24
-rw-r--r--src/vpp/api/types.c4
10 files changed, 38 insertions, 40 deletions
diff --git a/src/plugins/gbp/gbp_api_print.h b/src/plugins/gbp/gbp_api_print.h
index 21b351984b8..7598306ec5c 100644
--- a/src/plugins/gbp/gbp_api_print.h
+++ b/src/plugins/gbp/gbp_api_print.h
@@ -218,7 +218,7 @@ vl_api_gbp_subnet_add_del_t_print (vl_api_gbp_subnet_add_del_t * a,
s = format (s, "type %d ", ntohl (a->subnet.type));
s =
format (s, "prefix %U/%d", format_vl_api_address,
- &a->subnet.prefix.address, a->subnet.prefix.address_length);
+ &a->subnet.prefix.address, a->subnet.prefix.len);
s = format (s, "\n");
diff --git a/src/plugins/map/map_api.c b/src/plugins/map/map_api.c
index a64d90cd452..1d2614ccb5d 100644
--- a/src/plugins/map/map_api.c
+++ b/src/plugins/map/map_api.c
@@ -56,11 +56,11 @@ vl_api_map_add_domain_t_handler (vl_api_map_add_domain_t * mp)
u8 *vtag = 0;
vtag = vl_api_from_api_to_vec (&mp->tag);
rv =
- map_create_domain ((ip4_address_t *) & mp->ip4_prefix.prefix,
+ map_create_domain ((ip4_address_t *) & mp->ip4_prefix.address,
mp->ip4_prefix.len,
- (ip6_address_t *) & mp->ip6_prefix.prefix,
+ (ip6_address_t *) & mp->ip6_prefix.address,
mp->ip6_prefix.len,
- (ip6_address_t *) & mp->ip6_src.prefix,
+ (ip6_address_t *) & mp->ip6_src.address,
mp->ip6_src.len, mp->ea_bits_len, mp->psid_offset,
mp->psid_length, &index, ntohs (mp->mtu), flags, vtag);
vec_free (vtag);
@@ -128,9 +128,9 @@ vl_api_map_domain_dump_t_handler (vl_api_map_domain_dump_t * mp)
rmp->_vl_msg_id = htons(VL_API_MAP_DOMAIN_DETAILS + mm->msg_id_base);
rmp->context = mp->context;
rmp->domain_index = htonl(map_domain_index);
- clib_memcpy(&rmp->ip6_prefix.prefix, &d->ip6_prefix, sizeof(rmp->ip6_prefix.prefix));
- clib_memcpy(&rmp->ip4_prefix.prefix, &d->ip4_prefix, sizeof(rmp->ip4_prefix.prefix));
- clib_memcpy(&rmp->ip6_src.prefix, &d->ip6_src, sizeof(rmp->ip6_src.prefix));
+ clib_memcpy(&rmp->ip6_prefix.address, &d->ip6_prefix, sizeof(rmp->ip6_prefix.address));
+ clib_memcpy(&rmp->ip4_prefix.address, &d->ip4_prefix, sizeof(rmp->ip4_prefix.address));
+ clib_memcpy(&rmp->ip6_src.address, &d->ip6_src, sizeof(rmp->ip6_src.address));
rmp->ip6_prefix.len = d->ip6_prefix_len;
rmp->ip4_prefix.len = d->ip4_prefix_len;
rmp->ip6_src.len = d->ip6_src_len;
diff --git a/src/plugins/nat/nat_api.c b/src/plugins/nat/nat_api.c
index 1dad4e42728..9cb27448fdf 100644
--- a/src/plugins/nat/nat_api.c
+++ b/src/plugins/nat/nat_api.c
@@ -3007,7 +3007,7 @@ vl_api_nat64_add_del_prefix_t_handler (vl_api_nat64_add_del_prefix_t * mp)
ip6_address_t prefix;
int rv = 0;
- memcpy (&prefix.as_u8, mp->prefix.prefix, 16);
+ memcpy (&prefix.as_u8, mp->prefix.address, 16);
rv =
nat64_add_del_prefix (&prefix, mp->prefix.len,
@@ -3022,7 +3022,7 @@ vl_api_nat64_add_del_prefix_t_print (vl_api_nat64_add_del_prefix_t * mp,
u8 *s;
s = format (0, "SCRIPT: nat64_add_del_prefix %U/%u vrf_id %u %s\n",
- format_ip6_address, mp->prefix.prefix, mp->prefix.len,
+ format_ip6_address, mp->prefix.address, mp->prefix.len,
ntohl (mp->vrf_id), mp->is_add ? "" : "del");
FINISH;
@@ -3038,7 +3038,7 @@ nat64_api_prefix_walk (nat64_prefix_t * p, void *arg)
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_NAT64_PREFIX_DETAILS + sm->msg_id_base);
- clib_memcpy (rmp->prefix.prefix, &(p->prefix), 16);
+ clib_memcpy (rmp->prefix.address, &(p->prefix), 16);
rmp->prefix.len = p->plen;
rmp->vrf_id = ntohl (p->vrf_id);
rmp->context = ctx->context;
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 992060df394..d9c13ad8644 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -788,8 +788,8 @@ static void
vat_json_object_add_prefix (vat_json_node_t * node,
const vl_api_prefix_t * prefix)
{
- vat_json_object_add_uint (node, "address_length", prefix->address_length);
- vat_json_object_add_address (node, "prefix", &prefix->address);
+ vat_json_object_add_uint (node, "len", prefix->len);
+ vat_json_object_add_address (node, "address", &prefix->address);
}
static void vl_api_create_loopback_reply_t_handler
@@ -2663,7 +2663,7 @@ static void vl_api_ip_address_details_t_handler
address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
- address->prefix_length = mp->prefix.address_length;
+ address->prefix_length = mp->prefix.len;
#undef addresses
}
@@ -19201,8 +19201,7 @@ vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
print (vam->ofp,
"table-id %d, prefix %U/%d",
ntohl (mp->route.table_id),
- format_ip46_address,
- mp->route.prefix.address, mp->route.prefix.address_length);
+ format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
for (i = 0; i < count; i++)
{
fp = &mp->route.paths[i];
@@ -19242,8 +19241,7 @@ static void vl_api_ip_route_details_t_handler_json
clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
vat_json_object_add_ip4 (node, "prefix", ip4);
}
- vat_json_object_add_uint (node, "mask_length",
- mp->route.prefix.address_length);
+ vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
vat_json_object_add_uint (node, "path_count", count);
for (i = 0; i < count; i++)
{
@@ -21310,7 +21308,7 @@ api_ip_container_proxy_add_del (vat_main_t * vam)
else
break;
}
- if (sw_if_index == ~0 || pfx.address_length == 0)
+ if (sw_if_index == ~0 || pfx.len == 0)
{
errmsg ("address and sw_if_index must be set");
return -99;
diff --git a/src/vnet/ip/ip_types.api b/src/vnet/ip/ip_types.api
index 4c685670d5e..b962e1a6f31 100644
--- a/src/vnet/ip/ip_types.api
+++ b/src/vnet/ip/ip_types.api
@@ -41,7 +41,7 @@ typedef address {
typedef prefix {
vl_api_address_t address;
- u8 address_length;
+ u8 len;
};
typedef mprefix {
@@ -52,11 +52,11 @@ typedef mprefix {
};
typedef ip6_prefix {
- vl_api_ip6_address_t prefix;
+ vl_api_ip6_address_t address;
u8 len;
};
typedef ip4_prefix {
- vl_api_ip4_address_t prefix;
+ vl_api_ip4_address_t address;
u8 len;
};
diff --git a/src/vnet/ip/ip_types_api.c b/src/vnet/ip/ip_types_api.c
index 6ad2c366dff..0343d2001ad 100644
--- a/src/vnet/ip/ip_types_api.c
+++ b/src/vnet/ip/ip_types_api.c
@@ -196,7 +196,7 @@ ip_prefix_decode (const vl_api_prefix_t * in, fib_prefix_t * out)
out->fp_proto = FIB_PROTOCOL_IP6;
break;
}
- out->fp_len = in->address_length;
+ out->fp_len = in->len;
out->___fp___pad = 0;
ip_address_decode (&in->address, &out->fp_addr);
}
@@ -204,7 +204,7 @@ ip_prefix_decode (const vl_api_prefix_t * in, fib_prefix_t * out)
void
ip_prefix_encode (const fib_prefix_t * in, vl_api_prefix_t * out)
{
- out->address_length = in->fp_len;
+ out->len = in->fp_len;
ip_address_encode (&in->fp_addr,
fib_proto_to_ip46 (in->fp_proto), &out->address);
}
diff --git a/src/vnet/ipip/ipip_api.c b/src/vnet/ipip/ipip_api.c
index 62a99659eee..d88047560a9 100644
--- a/src/vnet/ipip/ipip_api.c
+++ b/src/vnet/ipip/ipip_api.c
@@ -180,9 +180,9 @@ vl_api_ipip_6rd_add_tunnel_t_handler (vl_api_ipip_6rd_add_tunnel_t * mp)
}
else
{
- rv = sixrd_add_tunnel ((ip6_address_t *) & mp->ip6_prefix.prefix,
+ rv = sixrd_add_tunnel ((ip6_address_t *) & mp->ip6_prefix.address,
mp->ip6_prefix.len,
- (ip4_address_t *) & mp->ip4_prefix.prefix,
+ (ip4_address_t *) & mp->ip4_prefix.address,
mp->ip4_prefix.len,
(ip4_address_t *) & mp->ip4_src,
mp->security_check,
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 74a0a62c021..bddaa9e00c2 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
@@ -139,7 +139,7 @@ class TestAddType(unittest.TestCase):
prefix = VPPType('vl_api_prefix_t',
[['vl_api_address_t', 'address'],
- ['u8', 'address_length']])
+ ['u8', 'len']])
message = VPPMessage('svs',
[['vl_api_prefix_t', 'prefix']])
message_addr = VPPMessage('svs_address',
diff --git a/src/vpp-api/python/vpp_papi/vpp_format.py b/src/vpp-api/python/vpp_papi/vpp_format.py
index 415070c4196..d54106b245c 100644
--- a/src/vpp-api/python/vpp_papi/vpp_format.py
+++ b/src/vpp-api/python/vpp_papi/vpp_format.py
@@ -45,29 +45,29 @@ def format_vl_api_address_t(args):
def format_vl_api_prefix_t(args):
if isinstance(args, (ipaddress.IPv4Network, ipaddress.IPv6Network)):
- return {'prefix': format_vl_api_address_t(
+ 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),
- 'address_length': int(length)}
+ 'len': int(length)}
def format_vl_api_ip6_prefix_t(args):
if isinstance(args, ipaddress.IPv6Network):
- return {'prefix': args.network_address.packed,
+ return {'address': args.network_address.packed,
'len': int(args.prefixlen)}
p, length = args.split('/')
- return {'prefix': inet_pton(AF_INET6, p),
+ return {'address': inet_pton(AF_INET6, p),
'len': int(length)}
def format_vl_api_ip4_prefix_t(args):
if isinstance(args, ipaddress.IPv4Network):
- return {'prefix': args.network_address.packed,
+ return {'address': args.network_address.packed,
'len': int(args.prefixlen)}
p, length = args.split('/')
- return {'prefix': inet_pton(AF_INET, p),
+ return {'address': inet_pton(AF_INET, p),
'len': int(length)}
@@ -84,13 +84,13 @@ conversion_table = {
},
'vl_api_ip6_prefix_t':
{
- 'IPv6Network': lambda o: {'prefix': o.network_address.packed,
+ 'IPv6Network': lambda o: {'address': o.network_address.packed,
'len': o.prefixlen},
'str': lambda s: format_vl_api_ip6_prefix_t(s)
},
'vl_api_ip4_prefix_t':
{
- 'IPv4Network': lambda o: {'prefix': o.network_address.packed,
+ 'IPv4Network': lambda o: {'address': o.network_address.packed,
'len': o.prefixlen},
'str': lambda s: format_vl_api_ip4_prefix_t(s)
},
@@ -129,16 +129,16 @@ def unformat_api_address_t(o):
def unformat_api_prefix_t(o):
if isinstance(o.address, ipaddress.IPv4Address):
- return ipaddress.IPv4Network((o.address, o.address_length), False)
+ return ipaddress.IPv4Network((o.address, o.len), False)
if isinstance(o.address, ipaddress.IPv6Address):
- return ipaddress.IPv6Network((o.address, o.address_length), False)
+ return ipaddress.IPv6Network((o.address, o.len), False)
conversion_unpacker_table = {
'vl_api_ip6_address_t': lambda o: ipaddress.IPv6Address(o),
- 'vl_api_ip6_prefix_t': lambda o: ipaddress.IPv6Network((o.prefix, o.len)),
+ 'vl_api_ip6_prefix_t': lambda o: ipaddress.IPv6Network((o.address, o.len)),
'vl_api_ip4_address_t': lambda o: ipaddress.IPv4Address(o),
- 'vl_api_ip4_prefix_t': lambda o: ipaddress.IPv4Network((o.prefix, o.len)),
+ '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_mac_address_t': lambda o: macaddress.MACAddress(o),
diff --git a/src/vpp/api/types.c b/src/vpp/api/types.c
index 3d556b72bfd..f9993b1883b 100644
--- a/src/vpp/api/types.c
+++ b/src/vpp/api/types.c
@@ -89,7 +89,7 @@ format_vl_api_prefix (u8 * s, va_list * args)
const vl_api_prefix_t *pfx = va_arg (*args, vl_api_prefix_t *);
s = format (s, "%U/%d", format_vl_api_address,
- &pfx->address, pfx->address_length);
+ &pfx->address, pfx->len);
return s;
}
@@ -167,7 +167,7 @@ unformat_vl_api_prefix (unformat_input_t * input, va_list * args)
vl_api_prefix_t *pfx = va_arg (*args, vl_api_prefix_t *);
if (unformat (input, "%U/%d", unformat_vl_api_address, &pfx->address,
- &pfx->address_length))
+ &pfx->len))
return (1);
return (0);
}