ip: IP address and prefix types (moved from LISP)
Type: refactor
Change-Id: I2c6b59013bfd21136a2955442c779685f951932b
Signed-off-by: Neale Ranns <nranns@cisco.com>
diff --git a/src/vnet/lisp-gpe/lisp_gpe.c b/src/vnet/lisp-gpe/lisp_gpe.c
index 9a10836..c75ad6b 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.c
+++ b/src/vnet/lisp-gpe/lisp_gpe.c
@@ -406,9 +406,9 @@
lisp_gpe_main_t *lgm = &lisp_gpe_main;
fib_route_path_t *rpath;
- if (vec_len (lgm->native_fwd_rpath[IP4]))
+ if (vec_len (lgm->native_fwd_rpath[AF_IP4]))
{
- vec_foreach (rpath, lgm->native_fwd_rpath[IP4])
+ vec_foreach (rpath, lgm->native_fwd_rpath[AF_IP4])
{
vlib_cli_output (vm, "nh: %U fib_index %u sw_if_index %u",
format_ip46_address, &rpath->frp_addr,
@@ -416,9 +416,9 @@
rpath->frp_sw_if_index);
}
}
- if (vec_len (lgm->native_fwd_rpath[IP6]))
+ if (vec_len (lgm->native_fwd_rpath[AF_IP6]))
{
- vec_foreach (rpath, lgm->native_fwd_rpath[IP6])
+ vec_foreach (rpath, lgm->native_fwd_rpath[AF_IP6])
{
vlib_cli_output (vm, "nh: %U fib_index %u sw_if_index %u",
format_ip46_address, &rpath->frp_addr, IP46_TYPE_IP6,
@@ -461,7 +461,7 @@
fib_route_path_t *rpath;
u8 ip_version;
- ip_version = a->rpath.frp_proto == DPO_PROTO_IP4 ? IP4 : IP6;
+ ip_version = a->rpath.frp_proto == DPO_PROTO_IP4 ? AF_IP4 : AF_IP6;
if (a->is_add)
{
diff --git a/src/vnet/lisp-gpe/lisp_gpe_adjacency.c b/src/vnet/lisp-gpe/lisp_gpe_adjacency.c
index 1b53e4d..4b5ca17 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_adjacency.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_adjacency.c
@@ -99,9 +99,9 @@
{
switch (ip_addr_version (&ladj->remote_rloc))
{
- case IP4:
+ case AF_IP4:
return (FIB_FORW_CHAIN_TYPE_UNICAST_IP4);
- case IP6:
+ case AF_IP6:
return (FIB_FORW_CHAIN_TYPE_UNICAST_IP6);
default:
ASSERT (0);
@@ -116,11 +116,11 @@
if (ip46_address_is_ip4 (a))
{
clib_memset (b, 0, sizeof (*b));
- ip_address_set (b, &a->ip4, IP4);
+ ip_address_set (b, &a->ip4, AF_IP4);
}
else
{
- ip_address_set (b, &a->ip6, IP6);
+ ip_address_set (b, &a->ip6, AF_IP6);
}
}
diff --git a/src/vnet/lisp-gpe/lisp_gpe_api.c b/src/vnet/lisp-gpe/lisp_gpe_api.c
index 515f484..16c1128 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_api.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_api.c
@@ -75,7 +75,7 @@
/* local locator */
r = &((vl_api_gpe_locator_t *) locs)[i];
clib_memset (&pair, 0, sizeof (pair));
- ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
+ ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? AF_IP4 : AF_IP6);
pair.weight = r->weight;
vec_add1 (pairs, pair);
@@ -86,7 +86,7 @@
/* remote locators */
r = &((vl_api_gpe_locator_t *) locs)[i];
p = &pairs[i - rloc_num];
- ip_address_set (&p->rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
+ ip_address_set (&p->rmt_loc, &r->addr, r->is_ip4 ? AF_IP4 : AF_IP6);
}
return pairs;
}
@@ -99,13 +99,13 @@
{
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;
@@ -135,7 +135,7 @@
const ip_address_t * addr, u8 weight)
{
loc->weight = weight;
- if (IP4 == ip_addr_version (addr))
+ if (AF_IP4 == ip_addr_version (addr))
{
loc->is_ip4 = 1;
memcpy (loc->addr, addr, 4);
@@ -208,7 +208,7 @@
switch (fid_addr_type (&e->leid))
{
case FID_ADDR_IP_PREF:
- if (IP4 == ip_prefix_version (&fid_addr_ippref (&e->leid)))
+ if (AF_IP4 == ip_prefix_version (&fid_addr_ippref (&e->leid)))
{
memcpy (&dst[i].leid, &fid_addr_ippref (&e->leid), 4);
memcpy (&dst[i].reid, &fid_addr_ippref (&e->reid), 4);
diff --git a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
index 2d6cd01..4524695 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
@@ -87,7 +87,7 @@
*/
lookup_dpo_add_or_lock_w_fib_index (src_fib_index,
(ip_prefix_version (dst_prefix) ==
- IP6 ? DPO_PROTO_IP6 :
+ AF_IP6 ? DPO_PROTO_IP6 :
DPO_PROTO_IP4),
LOOKUP_UNICAST,
LOOKUP_INPUT_SRC_ADDR,
@@ -329,7 +329,7 @@
ip_prefix_t ippref;
fib_prefix_t fib_prefix;
u8 ip_version = ip_prefix_version (&lfe->key->rmt.ippref);
- dproto = (ip_version == IP4 ? DPO_PROTO_IP4 : DPO_PROTO_IP6);
+ dproto = (ip_version == AF_IP4 ? DPO_PROTO_IP4 : DPO_PROTO_IP6);
if (lfe->is_src_dst)
{
@@ -539,7 +539,7 @@
lfe - lgm->lisp_fwd_entry_pool);
a->fwd_entry_index = lfe - lgm->lisp_fwd_entry_pool;
- fproto = (IP4 == ip_prefix_version (&fid_addr_ippref (&lfe->key->rmt)) ?
+ fproto = (AF_IP4 == ip_prefix_version (&fid_addr_ippref (&lfe->key->rmt)) ?
FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6);
lfe->type = (a->is_negative ?
@@ -581,7 +581,7 @@
delete_fib_entries (lfe);
- fproto = (IP4 == ip_prefix_version (&fid_addr_ippref (&lfe->key->rmt)) ?
+ fproto = (AF_IP4 == ip_prefix_version (&fid_addr_ippref (&lfe->key->rmt)) ?
FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6);
fib_table_unlock (lfe->eid_fib_index, fproto, FIB_SOURCE_LISP);
diff --git a/src/vnet/lisp-gpe/lisp_gpe_sub_interface.h b/src/vnet/lisp-gpe/lisp_gpe_sub_interface.h
index 1abb314..457db93 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_sub_interface.h
+++ b/src/vnet/lisp-gpe/lisp_gpe_sub_interface.h
@@ -112,7 +112,7 @@
key.local_rloc.ip.v6.as_u64[0] = addr->as_u64[0];
key.local_rloc.ip.v6.as_u64[1] = addr->as_u64[1];
- key.local_rloc.version = IP6;
+ key.local_rloc.version = AF_IP6;
key.vni = vni;
p = hash_get_mem (&lisp_gpe_sub_interfaces_sw_if_index, &key);
@@ -135,7 +135,7 @@
const uword *p;
key.local_rloc.ip.v4.as_u32 = addr->as_u32;
- key.local_rloc.version = IP4;
+ key.local_rloc.version = AF_IP4;
key.vni = vni;
p = hash_get_mem (&lisp_gpe_sub_interfaces_sw_if_index, &key);
diff --git a/src/vnet/lisp-gpe/lisp_gpe_tunnel.c b/src/vnet/lisp-gpe/lisp_gpe_tunnel.c
index d0e9bc2..0373542 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_tunnel.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_tunnel.c
@@ -52,7 +52,7 @@
int len;
gpe_encap_mode_t encap_mode = vnet_gpe_get_encap_mode ();
- if (IP4 == ip_addr_version (&lgt->key->lcl))
+ if (AF_IP4 == ip_addr_version (&lgt->key->lcl))
{
ip4_udp_lisp_gpe_header_t *h0;
ip4_header_t *ip0;