summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2020-05-19 07:17:19 +0000
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-08-31 09:23:32 +0000
commit29f3c7d2ecac2f9d80bb33e91bd5d1f9d434768a (patch)
tree66d7c69f2c24959ef4f6ef67b7c56dba11d8be29 /src/vnet
parent133c91c1c06e7c773ba675181901ba0dcf955ae6 (diff)
cnat: Destination based NAT
Type: feature Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: I64a99a4fbc674212944247793fd5c1fb701408cb
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/ip/ip_types.c35
-rw-r--r--src/vnet/lisp-cp/control.c35
2 files changed, 35 insertions, 35 deletions
diff --git a/src/vnet/ip/ip_types.c b/src/vnet/ip/ip_types.c
index 5041c129245..3d489e4e00d 100644
--- a/src/vnet/ip/ip_types.c
+++ b/src/vnet/ip/ip_types.c
@@ -261,6 +261,30 @@ ip_address_from_46 (const ip46_address_t * nh,
ip_addr_version (ip) = ip_address_family_from_fib_proto (fproto);
}
+/**
+ * convert from a IP address to a FIB prefix
+ */
+void
+ip_address_to_fib_prefix (const ip_address_t * addr, fib_prefix_t * prefix)
+{
+ if (addr->version == AF_IP4)
+ {
+ prefix->fp_len = 32;
+ prefix->fp_proto = FIB_PROTOCOL_IP4;
+ clib_memset (&prefix->fp_addr.pad, 0, sizeof (prefix->fp_addr.pad));
+ memcpy (&prefix->fp_addr.ip4, &addr->ip.ip4,
+ sizeof (prefix->fp_addr.ip4));
+ }
+ else
+ {
+ prefix->fp_len = 128;
+ prefix->fp_proto = FIB_PROTOCOL_IP6;
+ memcpy (&prefix->fp_addr.ip6, &addr->ip.ip6,
+ sizeof (prefix->fp_addr.ip6));
+ }
+ prefix->___fp___pad = 0;
+}
+
static void
ip_prefix_normalize_ip4 (ip4_address_t * ip4, u8 preflen)
{
@@ -364,6 +388,17 @@ ip_prefix_cmp (ip_prefix_t * p1, ip_prefix_t * p2)
return cmp;
}
+/**
+ * convert from a LISP to a FIB prefix
+ */
+void
+ip_prefix_to_fib_prefix (const ip_prefix_t * ip_prefix,
+ fib_prefix_t * fib_prefix)
+{
+ ip_address_to_fib_prefix (&ip_prefix->addr, fib_prefix);
+ fib_prefix->fp_len = ip_prefix->len;
+}
+
static bool
ip4_prefix_validate (const ip_prefix_t * ip)
{
diff --git a/src/vnet/lisp-cp/control.c b/src/vnet/lisp-cp/control.c
index c1593662b6d..7e9d059f9ed 100644
--- a/src/vnet/lisp-cp/control.c
+++ b/src/vnet/lisp-cp/control.c
@@ -124,41 +124,6 @@ ip_interface_get_first_ip_address (lisp_cp_main_t * lcm, u32 sw_if_index,
}
/**
- * convert from a LISP address to a FIB prefix
- */
-void
-ip_address_to_fib_prefix (const ip_address_t * addr, fib_prefix_t * prefix)
-{
- if (addr->version == AF_IP4)
- {
- prefix->fp_len = 32;
- prefix->fp_proto = FIB_PROTOCOL_IP4;
- clib_memset (&prefix->fp_addr.pad, 0, sizeof (prefix->fp_addr.pad));
- memcpy (&prefix->fp_addr.ip4, &addr->ip.ip4,
- sizeof (prefix->fp_addr.ip4));
- }
- else
- {
- prefix->fp_len = 128;
- prefix->fp_proto = FIB_PROTOCOL_IP6;
- memcpy (&prefix->fp_addr.ip6, &addr->ip.ip6,
- sizeof (prefix->fp_addr.ip6));
- }
- prefix->___fp___pad = 0;
-}
-
-/**
- * convert from a LISP to a FIB prefix
- */
-void
-ip_prefix_to_fib_prefix (const ip_prefix_t * ip_prefix,
- fib_prefix_t * fib_prefix)
-{
- ip_address_to_fib_prefix (&ip_prefix->addr, fib_prefix);
- fib_prefix->fp_len = ip_prefix->len;
-}
-
-/**
* Find the sw_if_index of the interface that would be used to egress towards
* dst.
*/