aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/lisp-cp/one_api.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-11-12 17:16:47 +0000
committerFlorin Coras <florin.coras@gmail.com>2019-11-12 18:56:04 +0000
commitea93e48cf6e918937422638cb574964b88a146b6 (patch)
treec35f8c921a8a9175b0dbf89e3e0775abc433e521 /src/vnet/lisp-cp/one_api.c
parentc046d709e1e493d20fee80f8c23b4106be67a98e (diff)
ip: IP address and prefix types (moved from LISP)
Type: refactor Change-Id: I2c6b59013bfd21136a2955442c779685f951932b Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/lisp-cp/one_api.c')
-rw-r--r--src/vnet/lisp-cp/one_api.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/vnet/lisp-cp/one_api.c b/src/vnet/lisp-cp/one_api.c
index 447b68f377c..17d4afc8267 100644
--- a/src/vnet/lisp-cp/one_api.c
+++ b/src/vnet/lisp-cp/one_api.c
@@ -146,7 +146,8 @@ unformat_one_locs (vl_api_one_remote_locator_t * rmt_locs, u32 rloc_num)
/* remote locators */
r = &rmt_locs[i];
clib_memset (&loc, 0, sizeof (loc));
- gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
+ gid_address_ip_set (&loc.address, &r->addr,
+ r->is_ip4 ? AF_IP4 : AF_IP6);
loc.priority = r->priority;
loc.weight = r->weight;
@@ -289,13 +290,13 @@ unformat_one_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
{
case 0: /* ipv4 */
gid_address_type (dst) = GID_ADDR_IP_PREFIX;
- gid_address_ip_set (dst, src, IP4);
+ gid_address_ip_set (dst, src, AF_IP4);
gid_address_ippref_len (dst) = len;
ip_prefix_normalize (&gid_address_ippref (dst));
break;
case 1: /* ipv6 */
gid_address_type (dst) = GID_ADDR_IP_PREFIX;
- gid_address_ip_set (dst, src, IP6);
+ gid_address_ip_set (dst, src, AF_IP6);
gid_address_ippref_len (dst) = len;
ip_prefix_normalize (&gid_address_ippref (dst));
break;
@@ -396,7 +397,7 @@ vl_api_one_add_del_map_server_t_handler (vl_api_one_add_del_map_server_t * mp)
clib_memset (&addr, 0, sizeof (addr));
- ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
+ ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4);
rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
@@ -413,7 +414,7 @@ vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
clib_memset (a, 0, sizeof (a[0]));
a->is_add = mp->is_add;
- ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
+ ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? AF_IP6 : AF_IP4);
rv = vnet_lisp_add_del_map_resolver (a);
@@ -519,7 +520,7 @@ vl_api_one_use_petr_t_handler (vl_api_one_use_petr_t * mp)
int rv = 0;
ip_address_t addr;
- ip_address_set (&addr, &mp->address, mp->is_ip4 ? IP4 : IP6);
+ ip_address_set (&addr, &mp->address, mp->is_ip4 ? AF_IP4 : AF_IP6);
rv = vnet_lisp_use_petr (&addr, mp->is_add);
REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
@@ -558,12 +559,12 @@ vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
ip_address_t *ip = &gid_address_ip (&addr);
switch (ip_addr_version (ip))
{
- case IP4:
+ case AF_IP4:
clib_memcpy (rmp->address, &ip_addr_v4 (ip),
sizeof (ip_addr_v4 (ip)));
break;
- case IP6:
+ case AF_IP6:
clib_memcpy (rmp->address, &ip_addr_v6 (ip),
sizeof (ip_addr_v6 (ip)));
break;
@@ -571,7 +572,7 @@ vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
default:
ASSERT (0);
}
- rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
+ rmp->is_ip4 = (gid_address_ip_version (&addr) == AF_IP4);
});
/* *INDENT-ON* */
}
@@ -818,7 +819,7 @@ one_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
switch (fid_addr_type (src))
{
case FID_ADDR_IP_PREF:
- if (ip_prefix_version (ippref) == IP4)
+ if (ip_prefix_version (ippref) == AF_IP4)
clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
else
clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
@@ -845,9 +846,9 @@ fid_type_to_api_type (fid_address_t * fid)
{
case FID_ADDR_IP_PREF:
ippref = &fid_addr_ippref (fid);
- if (ip_prefix_version (ippref) == IP4)
+ if (ip_prefix_version (ippref) == AF_IP4)
return 0;
- else if (ip_prefix_version (ippref) == IP6)
+ else if (ip_prefix_version (ippref) == AF_IP6)
return 1;
else
return ~0;
@@ -927,7 +928,7 @@ send_one_eid_table_details (mapping_t * mapit,
break;
case GID_ADDR_IP_PREFIX:
rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
- if (ip_prefix_version (ip_prefix) == IP4)
+ if (ip_prefix_version (ip_prefix) == AF_IP4)
{
rmp->eid_type = 0; /* ipv4 type */
clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
@@ -1013,13 +1014,13 @@ send_one_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
switch (ip_addr_version (ip))
{
- case IP4:
+ case AF_IP4:
rmp->is_ipv6 = 0;
clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
sizeof (ip_addr_v4 (ip)));
break;
- case IP6:
+ case AF_IP6:
rmp->is_ipv6 = 1;
clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
sizeof (ip_addr_v6 (ip)));
@@ -1062,13 +1063,13 @@ send_one_map_resolver_details (ip_address_t * ip,
switch (ip_addr_version (ip))
{
- case IP4:
+ case AF_IP4:
rmp->is_ipv6 = 0;
clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
sizeof (ip_addr_v4 (ip)));
break;
- case IP6:
+ case AF_IP6:
rmp->is_ipv6 = 1;
clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
sizeof (ip_addr_v6 (ip)));
@@ -1175,7 +1176,7 @@ one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
case GID_ADDR_IP_PREFIX:
a.reid_prefix_len = gid_address_ippref_len (&adj->reid);
a.leid_prefix_len = gid_address_ippref_len (&adj->leid);
- if (gid_address_ip_version (&adj->reid) == IP4)
+ if (gid_address_ip_version (&adj->reid) == AF_IP4)
{
a.eid_type = 0; /* ipv4 type */
clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
@@ -1460,7 +1461,7 @@ lisp_fid_addr_to_api (fid_address_t * fid, u8 * dst, u8 * api_eid_type,
{
case FID_ADDR_IP_PREF:
*prefix_length = fid_addr_prefix_length (fid);
- if (fid_addr_ip_version (fid) == IP4)
+ if (fid_addr_ip_version (fid) == AF_IP4)
{
*api_eid_type = 0; /* ipv4 type */
clib_memcpy (dst, &fid_addr_ippref (fid), 4);
@@ -1509,7 +1510,7 @@ vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
&rmp->seid_pref_len);
rmp->vni = clib_host_to_net_u32 (stat->vni);
- rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == IP4 ? 1 : 0;
+ rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == AF_IP4 ? 1 : 0;
ip_address_copy_addr (rmp->rloc, &stat->rmt_rloc);
ip_address_copy_addr (rmp->lloc, &stat->loc_rloc);
@@ -1533,7 +1534,7 @@ static void
gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
/* vpp keeps ip4 addresses in network byte order */
- ip_address_set (&gid_address_arp_ndp_ip (arp), &mp->ip4, IP4);
+ ip_address_set (&gid_address_arp_ndp_ip (arp), &mp->ip4, AF_IP4);
rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mp->mac, mp->is_add);
@@ -1550,7 +1551,7 @@ vl_api_one_add_del_ndp_entry_t_handler (vl_api_one_add_del_ndp_entry_t * mp)
gid_address_type (g) = GID_ADDR_NDP;
gid_address_ndp_bd (g) = clib_net_to_host_u32 (mp->bd);
- ip_address_set (&gid_address_arp_ndp_ip (g), mp->ip6, IP6);
+ ip_address_set (&gid_address_arp_ndp_ip (g), mp->ip6, AF_IP6);
rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mp->mac, mp->is_add);