summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/faces
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin/src/faces')
-rwxr-xr-xhicn-plugin/src/faces/app/address_mgr.c243
-rwxr-xr-xhicn-plugin/src/faces/app/address_mgr.h76
-rwxr-xr-xhicn-plugin/src/faces/app/face_app_cli.c203
-rwxr-xr-xhicn-plugin/src/faces/app/face_cons.c126
-rwxr-xr-xhicn-plugin/src/faces/app/face_cons.h75
-rwxr-xr-xhicn-plugin/src/faces/app/face_prod.c375
-rwxr-xr-xhicn-plugin/src/faces/app/face_prod.h113
-rwxr-xr-xhicn-plugin/src/faces/app/face_prod_node.c341
-rwxr-xr-xhicn-plugin/src/faces/face.c141
-rwxr-xr-xhicn-plugin/src/faces/face.h240
-rwxr-xr-xhicn-plugin/src/faces/face_cli.c131
-rwxr-xr-xhicn-plugin/src/faces/ip/dpo_ip.c187
-rwxr-xr-xhicn-plugin/src/faces/ip/dpo_ip.h255
-rwxr-xr-xhicn-plugin/src/faces/ip/face_ip.c326
-rwxr-xr-xhicn-plugin/src/faces/ip/face_ip.h241
-rwxr-xr-xhicn-plugin/src/faces/ip/face_ip_cli.c158
-rwxr-xr-xhicn-plugin/src/faces/ip/face_ip_node.c761
-rwxr-xr-xhicn-plugin/src/faces/ip/face_ip_node.h40
-rwxr-xr-xhicn-plugin/src/faces/ip/iface_ip_node.c845
-rwxr-xr-xhicn-plugin/src/faces/ip/iface_ip_node.h35
-rwxr-xr-xhicn-plugin/src/faces/udp/dpo_udp.c158
-rwxr-xr-xhicn-plugin/src/faces/udp/dpo_udp.h312
-rwxr-xr-xhicn-plugin/src/faces/udp/face_udp.c371
-rwxr-xr-xhicn-plugin/src/faces/udp/face_udp.h248
-rwxr-xr-xhicn-plugin/src/faces/udp/face_udp_cli.c164
-rwxr-xr-xhicn-plugin/src/faces/udp/face_udp_node.c864
-rwxr-xr-xhicn-plugin/src/faces/udp/face_udp_node.h35
-rwxr-xr-xhicn-plugin/src/faces/udp/iface_udp_node.c894
-rwxr-xr-xhicn-plugin/src/faces/udp/iface_udp_node.h36
29 files changed, 7994 insertions, 0 deletions
diff --git a/hicn-plugin/src/faces/app/address_mgr.c b/hicn-plugin/src/faces/app/address_mgr.c
new file mode 100755
index 000000000..76a7e0f6d
--- /dev/null
+++ b/hicn-plugin/src/faces/app/address_mgr.c
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright (c) 2017-2019 by cisco systems inc. All rights reserved.
+ *
+ */
+
+#include <dlfcn.h>
+
+#include <vlib/vlib.h>
+#include <vnet/ip/ip6_packet.h>
+#include <vnet/ip/ip4.h> //ip4_add_del_ip_address
+#include <vnet/ip/ip6.h> //ip6_add_del_ip_address
+#include <vnet/fib/fib_types.h> //FIB_PROTOCOL_IP4/6, FIB_NODE_INDEX_INVALID
+#include <vnet/fib/fib_entry.h> //FIB_SOURCE_PLUGIN_HI
+#include <vnet/fib/fib_table.h>
+#include <vppinfra/format.h>
+#include <vnet/interface.h> //appif_flags
+#include <vnet/interface_funcs.h> //vnet_sw_interface_set_flags
+
+#include "address_mgr.h"
+#include "../../hicn.h"
+#include "../../infra.h"
+#include "../../error.h"
+#include "../face.h"
+#include "../ip/face_ip.h"
+#include "../../strategy_dpo_ctx.h"
+#include "../../route.h"
+
+typedef struct address_mgr_main_s
+{
+ ip4_address_t next_ip4_local_addr;
+ ip6_address_t next_ip6_local_addr;
+} address_mgr_main_t;
+
+address_mgr_main_t address_mgr_main;
+
+static void
+increment_v4_address (ip4_address_t * a, u32 val)
+{
+ u32 v;
+
+ v = clib_net_to_host_u32 (a->as_u32) + val;
+ a->as_u32 = clib_host_to_net_u32 (v);
+}
+
+static void
+increment_v6_address (ip6_address_t * a, u64 val)
+{
+ u64 v;
+
+ v = clib_net_to_host_u64 (a->as_u64[1]) + val;
+ a->as_u64[1] = clib_host_to_net_u64 (v);
+}
+
+void
+get_two_ip4_addresses (ip4_address_t * appif_addr, ip4_address_t * nh_addr)
+{
+ /* We want two consecutives address that fall into a /31 mask */
+ if (address_mgr_main.next_ip4_local_addr.as_u8[3] & 0x01)
+ increment_v4_address (&(address_mgr_main.next_ip4_local_addr), 1);
+
+ *appif_addr = address_mgr_main.next_ip4_local_addr;
+ increment_v4_address (&(address_mgr_main.next_ip4_local_addr), 1);
+ *nh_addr = address_mgr_main.next_ip4_local_addr;
+ fib_prefix_t fib_pfx;
+ fib_node_index_t fib_entry_index = FIB_NODE_INDEX_INVALID;
+ u32 fib_index;
+
+ fib_pfx.fp_proto = FIB_PROTOCOL_IP4;
+ fib_pfx.fp_len = ADDR_MGR_IP4_LEN;
+ /* At this point the face exists in the face table */
+ do
+ {
+ /* Check if the route already exist in the fib */
+ fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, appif_addr->as_u8);
+ fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
+ HICN_FIB_TABLE,
+ FIB_SOURCE_PLUGIN_HI);
+ fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx);
+ fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PLUGIN_HI);
+ if (fib_entry_index != FIB_NODE_INDEX_INVALID)
+ {
+ fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, nh_addr->as_u8);
+ fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
+ HICN_FIB_TABLE,
+ FIB_SOURCE_PLUGIN_HI);
+ fib_entry_index =
+ fib_table_lookup_exact_match (fib_index, &fib_pfx);
+ fib_table_unlock (fib_index, fib_pfx.fp_proto,
+ FIB_SOURCE_PLUGIN_HI);
+ }
+ if (fib_entry_index != FIB_NODE_INDEX_INVALID)
+ {
+ increment_v4_address (appif_addr, 2);
+ increment_v4_address (nh_addr, 2);
+ }
+ }
+ while (fib_entry_index != FIB_NODE_INDEX_INVALID);
+
+ address_mgr_main.next_ip4_local_addr = *nh_addr;
+ increment_v4_address (&(address_mgr_main.next_ip4_local_addr), 1);
+}
+
+void
+get_two_ip6_addresses (ip6_address_t * appif_addr, ip6_address_t * nh_addr)
+{
+
+ /* We want two consecutives address that fall into a /127 mask */
+ if (address_mgr_main.next_ip6_local_addr.as_u8[15] & 0x01)
+ increment_v6_address (&(address_mgr_main.next_ip6_local_addr), 1);
+
+ *appif_addr = address_mgr_main.next_ip6_local_addr;
+ increment_v6_address (&(address_mgr_main.next_ip6_local_addr), 1);
+ *nh_addr = address_mgr_main.next_ip6_local_addr;
+
+
+ fib_prefix_t fib_pfx;
+ fib_node_index_t fib_entry_index = FIB_NODE_INDEX_INVALID;
+ u32 fib_index;
+
+ fib_pfx.fp_proto = FIB_PROTOCOL_IP6;
+ fib_pfx.fp_len = ADDR_MGR_IP6_LEN;
+ /* At this point the face exists in the face table */
+ do
+ {
+ /* Check if the route already exist in the fib */
+ fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 1, appif_addr->as_u8);
+ fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
+ HICN_FIB_TABLE,
+ FIB_SOURCE_PLUGIN_HI);
+ fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx);
+ fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PLUGIN_HI);
+ if (fib_entry_index != FIB_NODE_INDEX_INVALID)
+ {
+ fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, nh_addr->as_u8);
+ fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
+ HICN_FIB_TABLE,
+ FIB_SOURCE_PLUGIN_HI);
+ fib_entry_index =
+ fib_table_lookup_exact_match (fib_index, &fib_pfx);
+ fib_table_unlock (fib_index, fib_pfx.fp_proto,
+ FIB_SOURCE_PLUGIN_HI);
+ }
+ if (fib_entry_index != FIB_NODE_INDEX_INVALID)
+ {
+ increment_v6_address (appif_addr, 2);
+ increment_v6_address (nh_addr, 2);
+ }
+ }
+ while (fib_entry_index != FIB_NODE_INDEX_INVALID);
+
+ address_mgr_main.next_ip6_local_addr = *nh_addr;
+ increment_v6_address (&(address_mgr_main.next_ip6_local_addr), 1);
+}
+
+ip4_address_t
+get_ip4_address ()
+{
+ ip4_address_t *prefix = &address_mgr_main.next_ip4_local_addr;
+ fib_prefix_t fib_pfx;
+ fib_node_index_t fib_entry_index = FIB_NODE_INDEX_INVALID;
+ u32 fib_index;
+
+ fib_pfx.fp_proto = FIB_PROTOCOL_IP4;
+ fib_pfx.fp_len = ADDR_MGR_IP4_LEN;
+ /* At this point the face exists in the face table */
+ do
+ {
+ /* Check if the route already exist in the fib */
+ fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, prefix->as_u8);
+ fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
+ HICN_FIB_TABLE,
+ FIB_SOURCE_PLUGIN_HI);
+ fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx);
+ fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PLUGIN_HI);
+ increment_v4_address (prefix, 1);
+ }
+ while (fib_entry_index != FIB_NODE_INDEX_INVALID);
+
+ return fib_pfx.fp_addr.ip4;
+}
+
+ip6_address_t
+get_ip6_address ()
+{
+ ip6_address_t *prefix = &address_mgr_main.next_ip6_local_addr;
+ fib_prefix_t fib_pfx;
+ fib_node_index_t fib_entry_index = FIB_NODE_INDEX_INVALID;
+ u32 fib_index;
+
+ fib_pfx.fp_proto = FIB_PROTOCOL_IP6;
+ fib_pfx.fp_len = ADDR_MGR_IP6_LEN;
+ /* At this point the face exists in the face table */
+ do
+ {
+ /* Check if the route already exist in the fib */
+ fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 1, prefix->as_u8);
+ fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto,
+ HICN_FIB_TABLE,
+ FIB_SOURCE_PLUGIN_HI);
+ fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx);
+ fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PLUGIN_HI);
+ increment_v6_address (prefix, 1);
+ }
+ while (fib_entry_index != FIB_NODE_INDEX_INVALID);
+
+ return fib_pfx.fp_addr.ip6;
+}
+
+void
+address_mgr_init ()
+{
+
+ address_mgr_main.next_ip4_local_addr.as_u8[0] = 169;
+ address_mgr_main.next_ip4_local_addr.as_u8[1] = 254;
+ address_mgr_main.next_ip4_local_addr.as_u8[2] = 1;
+ address_mgr_main.next_ip4_local_addr.as_u8[3] = 1;
+
+ ip6_address_set_zero (&address_mgr_main.next_ip6_local_addr);
+ address_mgr_main.next_ip6_local_addr.as_u16[0] =
+ clib_host_to_net_u16 (0xfc00);
+ address_mgr_main.next_ip6_local_addr.as_u8[15] = 1;
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables: eval: (c-set-style "gnu") End:
+ */
diff --git a/hicn-plugin/src/faces/app/address_mgr.h b/hicn-plugin/src/faces/app/address_mgr.h
new file mode 100755
index 000000000..99450dcdd
--- /dev/null
+++ b/hicn-plugin/src/faces/app/address_mgr.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ADDRESS_MGR_H_
+#define _ADDRESS_MGR_H_
+
+/**
+ * @file
+ *
+ * @brief Address manager.
+ *
+ * Address manager that maintains a pool of ip4 and ip6 addresses to assign to
+ * an interface.
+ */
+
+#define ADDR_MGR_IP4_LEN 32
+#define ADDR_MGR_IP4_CONS_LEN 31
+#define ADDR_MGR_IP6_LEN 128
+#define ADDR_MGR_IP6_CONS_LEN 127
+
+/**
+ * @brief Get two consecutive IP v4 addresses from the same /31 subnet
+ *
+ * @param addr1 first ip address with the least significant bit set to 0
+ * @param addr2 second ip address with the least significant bit set to 1
+ */
+void get_two_ip4_addresses (ip4_address_t * addr1, ip4_address_t * addr2);
+
+/**
+ * @brief Get two consecutive IP v6 addresses from the same /126 subnet
+ *
+ * @param addr1 first ip address with the least significant bit set to 0
+ * @param addr2 second ip address with the least significant bit set to 1
+ */
+void get_two_ip6_addresses (ip6_address_t * addr1, ip6_address_t * addr2);
+
+/**
+ * @brief Get one IP v4 address
+ *
+ * @return ip address
+ */
+ip4_address_t get_ip4_address (void);
+
+/**
+ * @brief Get one IP v6 address
+ *
+ * @return ip address
+ */
+ip6_address_t get_ip6_address (void);
+
+/**
+ * @brief Init the address manager
+ */
+void address_mgr_init (void);
+
+#endif /* _ADDRESS_MGR_ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/app/face_app_cli.c b/hicn-plugin/src/faces/app/face_app_cli.c
new file mode 100755
index 000000000..d55e990de
--- /dev/null
+++ b/hicn-plugin/src/faces/app/face_app_cli.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/vnet.h>
+#include <vnet/dpo/dpo.h>
+#include <vlib/vlib.h>
+#include <vnet/ip/ip6_packet.h>
+
+#include "../ip/face_ip.h"
+#include "../ip/dpo_ip.h"
+#include "../face.h"
+#include "face_prod.h"
+#include "face_cons.h"
+
+#define HICN_FACE_NONE 0
+#define HICN_FACE_DELETE 1
+#define HICN_FACE_ADD 2
+
+static clib_error_t *
+hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
+ unformat_input_t * main_input,
+ vlib_cli_command_t * cmd)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ ip46_address_t prefix;
+ hicn_face_id_t face_id = HICN_FACE_NULL;
+ u32 cs_reserved = HICN_PARAM_FACE_DFT_CS_RESERVED;
+ int ret = HICN_ERROR_NONE;
+ int sw_if;
+ int face_op = HICN_FACE_NONE;
+ int prod = 0;
+ int len;
+
+ /* Get a line of input. */
+ unformat_input_t _line_input, *line_input = &_line_input;
+ if (!unformat_user (main_input, unformat_line_input, line_input))
+ {
+ return (0);
+ }
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "del"))
+ {
+ face_op = HICN_FACE_DELETE;
+ }
+ else if (face_op == HICN_FACE_DELETE
+ && unformat (line_input, "id %d", &face_id))
+ ;
+ else if (unformat (line_input, "add"))
+ {
+ face_op = HICN_FACE_ADD;
+ }
+ else if (face_op == HICN_FACE_ADD)
+ {
+ if (unformat (line_input, "intfc %U",
+ unformat_vnet_sw_interface, vnm, &sw_if))
+ ;
+ else
+ if (unformat
+ (line_input, "prod prefix %U/%d", unformat_ip46_address,
+ &prefix, IP46_TYPE_ANY, &len))
+ {
+ prod = 1;
+ }
+ else if (prod && unformat (line_input, "cs_size %d", &cs_reserved))
+ ;
+ else if (unformat (line_input, "cons"))
+ ;
+ else
+ {
+ return clib_error_return (0, "%s '%U'",
+ get_error_string
+ (HICN_ERROR_CLI_INVAL),
+ format_unformat_error, line_input);
+ }
+ }
+ else
+ {
+ return clib_error_return (0, "%s '%U'",
+ get_error_string (HICN_ERROR_CLI_INVAL),
+ format_unformat_error, line_input);
+ }
+ }
+
+ if (face_id != HICN_FACE_NULL)
+ {
+
+ if (!hicn_dpoi_idx_is_valid (face_id))
+ {
+ return clib_error_return (0, "%s, face_id %d not valid",
+ get_error_string (ret), face_id);
+ }
+ }
+
+ int rv;
+ switch (face_op)
+ {
+ case HICN_FACE_ADD:
+ {
+ ip46_address_t prod_addr;
+ ip4_address_t cons_addr4;
+ ip6_address_t cons_addr6;
+
+ hicn_prefix_t name_prefix = {
+ .name = prefix,
+ .len = len,
+ };
+ if (prod)
+ {
+ rv =
+ hicn_face_prod_add (&name_prefix, sw_if, &cs_reserved,
+ &prod_addr, &face_id);
+ if (rv == HICN_ERROR_NONE)
+ {
+ u8 *sbuf = NULL;
+ sbuf =
+ format (sbuf, "Face id: %d, producer address %U", face_id,
+ format_ip46_address, &prod_addr,
+ 0 /*IP46_ANY_TYPE */ );
+ vlib_cli_output (vm, "%s", sbuf);
+ }
+ else
+ {
+ return clib_error_return (0, get_error_string (rv));
+ }
+ }
+ else
+ {
+ rv =
+ hicn_face_cons_add (&cons_addr4, &cons_addr6, sw_if, &face_id);
+ if (rv == HICN_ERROR_NONE)
+ {
+ u8 *sbuf = NULL;
+ sbuf =
+ format (sbuf, "Face id: %d, consumer addresses v4 %U v6 %U",
+ face_id, format_ip4_address, &cons_addr4,
+ format_ip6_address, &cons_addr6);
+ vlib_cli_output (vm, "%s", sbuf);
+ }
+ else
+ {
+ return clib_error_return (0, get_error_string (rv));
+ }
+ }
+ break;
+ }
+ case HICN_FACE_DELETE:
+ {
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
+
+ if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS)
+ rv = hicn_face_cons_del (face_id);
+ else
+ rv = hicn_face_prod_del (face_id);
+ if (rv == HICN_ERROR_NONE)
+ {
+ vlib_cli_output (vm, "Face %d deleted", face_id);
+ }
+ else
+ {
+ return clib_error_return (0, get_error_string (rv));
+ }
+ break;
+ }
+ default:
+ return clib_error_return (0, "Operation (%d) not implemented", face_op);
+ break;
+ }
+ return (rv == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n",
+ get_error_string
+ (rv));
+}
+
+/* cli declaration for 'cfg face' */
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (hicn_face_app_cli_set_command, static) =
+{
+ .path = "hicn face app",
+ .short_help = "hicn face app {add intfc <sw_if> { prod prefix <hicn_prefix> cs_size <size_in_packets>} {cons} | {del <face_id>}",
+ .function = hicn_face_app_cli_set_command_fn,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/app/face_cons.c b/hicn-plugin/src/faces/app/face_cons.c
new file mode 100755
index 000000000..8278b6ab3
--- /dev/null
+++ b/hicn-plugin/src/faces/app/face_cons.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/ip/ip6_packet.h>
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+
+#include "face_cons.h"
+#include "address_mgr.h"
+#include "../../infra.h"
+
+int
+hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6,
+ u32 swif, hicn_face_id_t * faceid)
+{
+ /* Create the corresponding appif if */
+ /* Retrieve a valid local ip address to assign to the appif */
+ /* Set the ip address and create the face in the face db */
+
+ vlib_main_t *vm = vlib_get_main ();
+ vnet_main_t *vnm = vnet_get_main ();
+
+ hicn_main_t *hm = &hicn_main;
+
+ ip46_address_t if_ip;
+ ip46_address_reset (&if_ip);
+ nh_addr4->as_u32 = 0;
+ nh_addr6->as_u64[0] = 0;
+ nh_addr6->as_u64[1] = 0;
+ u32 if_flags = 0;
+
+ if (!hm->is_enabled)
+ {
+ return HICN_ERROR_FWD_NOT_ENABLED;
+ }
+ if_flags |= VNET_SW_INTERFACE_FLAG_ADMIN_UP;
+ vnet_sw_interface_set_flags (vnm, swif, if_flags);
+
+ get_two_ip4_addresses (&(if_ip.ip4), nh_addr4);
+ ip4_add_del_interface_address (vm,
+ swif,
+ &(if_ip.ip4),
+ ADDR_MGR_IP4_CONS_LEN, 0 /* is_del */ );
+
+ ip46_address_t nh_addr = to_ip46 (0, (u8 *) nh_addr4);
+
+ hicn_iface_ip_add (&if_ip, &nh_addr, swif, faceid);
+
+ hicn_face_t *face = hicn_dpoi_get_from_idx (*faceid);
+ face->shared.flags |= HICN_FACE_FLAGS_APPFACE_CONS;
+
+ get_two_ip6_addresses (&(if_ip.ip6), nh_addr6);
+ ip6_add_del_interface_address (vm,
+ swif,
+ &(if_ip.ip6),
+ ADDR_MGR_IP6_CONS_LEN, 0 /* is_del */ );
+
+ hicn_iface_ip_add (&if_ip, (ip46_address_t *) nh_addr6, swif, faceid);
+
+ face = hicn_dpoi_get_from_idx (*faceid);
+ face->shared.flags |= HICN_FACE_FLAGS_APPFACE_CONS;
+
+ return vnet_feature_enable_disable ("ip6-unicast",
+ "hicn-iface-ip6-input", swif, 1, 0,
+ 0) ==
+ 0 ? HICN_ERROR_NONE : HICN_ERROR_APPFACE_FEATURE;
+}
+
+int
+hicn_face_cons_del (hicn_face_id_t face_id)
+{
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
+
+ if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS)
+ {
+ int ret = hicn_face_ip_del (face_id);
+
+ return ret ==
+ HICN_ERROR_NONE
+ ? (vnet_feature_enable_disable
+ ("ip6-unicast", "hicn-iface-ip6-input", face->shared.sw_if, 0,
+ 0, 0) == 0 ? HICN_ERROR_NONE : HICN_ERROR_APPFACE_FEATURE) : ret;
+ }
+ else
+ {
+ return HICN_ERROR_APPFACE_NOT_FOUND;
+ }
+}
+
+u8 *
+format_hicn_face_cons (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (index_t index) = va_arg (*args, index_t);
+ CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
+
+ s = format (s, " (consumer face)");
+
+ return s;
+}
+
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT(hicn_cons_app, static)=
+{
+ .arc_name = "ip6-unicast",
+ .node_name = "hicn-iface-ip6-input",
+ .runs_before = VNET_FEATURES("ip6-inacl"),
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables: eval: (c-set-style "gnu") End:
+ */
diff --git a/hicn-plugin/src/faces/app/face_cons.h b/hicn-plugin/src/faces/app/face_cons.h
new file mode 100755
index 000000000..067b45a1f
--- /dev/null
+++ b/hicn-plugin/src/faces/app/face_cons.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _FACE_CONSUMER_H_
+#define _FACE_CONSUMER_H_
+
+#include <vnet/vnet.h>
+#include "../face.h"
+
+/**
+ * @file
+ *
+ * @brief Consumer application face.
+ *
+ * A consumer application face is built upon an ip face and identify a local
+ * consumer application (co-located with the forwarder) that acts as a
+ * consumer. The interface used by the consumer application face is
+ * assumed to be reserved only for hICN traffic (e.g., dedicated memif that
+ * connects the applictation to the forwarder). Only one application face can be
+ * assigned to an interface.
+ *
+ * In the vlib graph a consumer application face directly connect the
+ * device-input node to the hicn-vface-ip node.
+ */
+
+/**
+ * @brief Add a new consumer application face
+ *
+ * The method creates the internal ip face and set the ip address to the interface.
+ * @param nh_addr4 ipv4 address to assign to interface used by the application to
+ * send interest to the consumer face
+ * @param nh_addr6 ipv6 address to assign to interface used by the application to
+ * send interest to the consumer face
+ * @param swif interface associated to the face
+ */
+int
+hicn_face_cons_add (ip4_address_t * nh_addr4, ip6_address_t * nh_addr6,
+ u32 swif, hicn_face_id_t * faceid);
+
+/**
+ * @brief Delete an existing consumer application face
+ *
+ * @param face_id Id of the consumer application face
+ */
+int hicn_face_cons_del (hicn_face_id_t face_id);
+
+/**
+ * @brief Format an application consumer face
+ *
+ * @param s Pointer to a previous string. If null it will be initialize
+ * @param args Array storing input values. Expected u32 face_id and u32 indent
+ * @return String with the formatted face
+ */
+u8 *format_hicn_face_cons (u8 * s, va_list * args);
+
+
+#endif /* _FACE_CONSUMER_H_ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables: eval: (c-set-style "gnu") End:
+ */
diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c
new file mode 100755
index 000000000..d06fe2ff3
--- /dev/null
+++ b/hicn-plugin/src/faces/app/face_prod.c
@@ -0,0 +1,375 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/ip/ip6_packet.h>
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+
+#include "face_prod.h"
+#include "address_mgr.h"
+#include "../../infra.h"
+#include "../../route.h"
+#include "../../cache_policies/cs_lru.h"
+
+hicn_face_prod_state_t *face_state_vec;
+
+/* used to check if an interface is already in the vector */
+u32 *face_state_pool;
+
+static int
+hicn_app_state_create (u32 swif, hicn_prefix_t * prefix)
+{
+ /* Make sure that the pool is not empty */
+ pool_validate_index (face_state_pool, 0);
+
+ u32 *swif_app;
+ u8 found = 0;
+ /* *INDENT-OFF* */
+ pool_foreach (swif_app, face_state_pool,{
+ if (*swif_app == swif)
+ {
+ found = 1;
+ }
+ }
+ );
+ /* *INDENT-ON* */
+
+
+ if (found)
+ return HICN_ERROR_APPFACE_ALREADY_ENABLED;
+
+
+ /* Create the appif and store in the vector */
+ vec_validate (face_state_vec, swif);
+ clib_memcpy (&(face_state_vec[swif].prefix), prefix,
+ sizeof (hicn_prefix_t));
+
+ /* Set as busy the element in the vector */
+ pool_get (face_state_pool, swif_app);
+ *swif_app = swif;
+
+ int ret = HICN_ERROR_NONE;
+ if (ip46_address_is_ip4 (&(prefix->name)))
+ {
+ ret =
+ vnet_feature_enable_disable ("ip4-unicast", "hicn-face-prod-input",
+ swif, 1, 0, 0);
+ }
+ else
+ {
+ ret =
+ vnet_feature_enable_disable ("ip6-unicast", "hicn-face-prod-input",
+ swif, 1, 0, 0);
+ }
+
+ return ret == 0 ? HICN_ERROR_NONE : HICN_ERROR_APPFACE_FEATURE;
+}
+
+static int
+hicn_app_state_del (u32 swif)
+{
+ /* Make sure that the pool is not empty */
+ pool_validate_index (face_state_pool, 0);
+
+ u32 *temp;
+ u32 *swif_app = NULL;
+ u8 found = 0;
+ ip46_address_t *prefix_addr;
+ /* *INDENT-OFF* */
+ pool_foreach (temp, face_state_pool,{
+ if (*temp == swif)
+ {
+ found = 1;
+ swif_app = temp;
+ }
+ }
+ );
+ /* *INDENT-ON* */
+
+ prefix_addr = &(face_state_vec[swif].prefix.name);
+ if (!found)
+ return HICN_ERROR_APPFACE_NOT_FOUND;
+
+ int ret = HICN_ERROR_NONE;
+ if (ip46_address_is_ip4 (prefix_addr))
+ {
+ ret =
+ vnet_feature_enable_disable ("ip4-unicast", "hicn-face-prod-input",
+ swif, 0, 0, 0);
+ }
+ else
+ {
+ ret =
+ vnet_feature_enable_disable ("ip6-unicast", "hicn-face-prod-input",
+ swif, 0, 0, 0);
+ }
+
+ pool_put (face_state_pool, swif_app);
+ memset (&face_state_vec[swif], 0, sizeof (hicn_face_prod_state_t));
+
+ return ret == 0 ? HICN_ERROR_NONE : HICN_ERROR_APPFACE_FEATURE;
+}
+
+int
+hicn_face_prod_add (hicn_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
+ ip46_address_t * prod_addr, hicn_face_id_t * faceid)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ vnet_main_t *vnm = vnet_get_main ();
+
+ hicn_main_t *hm = &hicn_main;
+
+ ip46_address_t app_ip;
+ u32 if_flags = 0;
+
+ if (!hm->is_enabled)
+ {
+ return HICN_ERROR_FWD_NOT_ENABLED;
+ }
+ int ret = HICN_ERROR_NONE;
+ hicn_face_t *face = NULL;
+
+ if_flags |= VNET_SW_INTERFACE_FLAG_ADMIN_UP;
+ vnet_sw_interface_set_flags (vnm, sw_if, if_flags);
+
+ if (ip46_address_is_zero (&prefix->name))
+ {
+ return HICN_ERROR_APPFACE_PROD_PREFIX_NULL;
+ }
+ /*
+ * Check if a producer face is already existing for the same prefix
+ * and sw_if
+ */
+ if (ip46_address_is_ip4 (&prefix->name))
+ {
+ face =
+ hicn_face_ip4_get (&(prefix->name.ip4), sw_if,
+ &hicn_face_ip_remote_hashtb);
+ }
+ else
+ {
+ face =
+ hicn_face_ip6_get (&(prefix->name.ip6), sw_if,
+ &hicn_face_ip_remote_hashtb);
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+ }
+
+ if (face != NULL)
+ {
+ if (!(face->shared.flags & HICN_FACE_FLAGS_DELETED))
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ /*
+ * Something went worng, a consumer face exists for the
+ * producer's prefix.
+ */
+ /* It should never happens, this is a safety check. */
+ if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ /* If the face exists but is marked as deleted, undelete it */
+ if (face->shared.flags & HICN_FACE_FLAGS_DELETED)
+ {
+ /*
+ * remove the deleted flag and retrieve the face
+ * local addr
+ */
+ face->shared.flags &= HICN_FACE_FLAGS_DELETED;
+ hicn_face_prod_t *prod_face = (hicn_face_prod_t *) face->data;
+ app_ip = prod_face->ip_face.local_addr;
+ }
+ }
+ else
+ {
+ /* Otherwise create the face */
+ if (ip46_address_is_ip4 (&prefix->name))
+ {
+ /*
+ * Otherwise retrieve an ip address to assign as a
+ * local ip addr.
+ */
+ ip4_address_t app_ip4 = get_ip4_address ();
+ ip4_add_del_interface_address (vm,
+ sw_if,
+ &app_ip4,
+ ADDR_MGR_IP4_CONS_LEN,
+ 0 /* is_del */ );
+ app_ip = to_ip46 ( /* isv6 */ 0, app_ip4.as_u8);
+ }
+ else
+ {
+ ip6_address_t app_ip6 = get_ip6_address ();
+ ip6_add_del_interface_address (vm,
+ sw_if,
+ &app_ip6,
+ ADDR_MGR_IP6_CONS_LEN,
+ 0 /* is_del */ );
+ app_ip = to_ip46 ( /* isv6 */ 1, app_ip6.as_u8);
+ }
+
+ /*
+ * Special case: the nh_addr in the face is the appif ip
+ * address
+ */
+ ret = hicn_face_ip_add (&app_ip, &(prefix->name), sw_if, faceid);
+
+ face = hicn_dpoi_get_from_idx (*faceid);
+
+ face->shared.flags |= HICN_FACE_FLAGS_APPFACE_PROD;
+
+ hicn_face_prod_t *prod_face = (hicn_face_prod_t *) face->data;
+
+ /*
+ * For the moment we keep them here although it would be good
+ * to create a different face for appface
+ */
+ prod_face->policy_vft.hicn_cs_insert = hicn_cs_lru.hicn_cs_insert;
+ prod_face->policy_vft.hicn_cs_update = hicn_cs_lru.hicn_cs_update;
+ prod_face->policy_vft.hicn_cs_dequeue = hicn_cs_lru.hicn_cs_dequeue;
+ prod_face->policy_vft.hicn_cs_delete_get =
+ hicn_cs_lru.hicn_cs_delete_get;
+ prod_face->policy_vft.hicn_cs_trim = hicn_cs_lru.hicn_cs_trim;
+
+ }
+
+ if (ret == HICN_ERROR_NONE
+ && hicn_face_prod_set_lru_max (*faceid, cs_reserved) == HICN_ERROR_NONE)
+ {
+ hicn_app_state_create (sw_if, prefix);
+ ret = hicn_route_add (faceid, 1, &(prefix->name), prefix->len);
+ }
+
+ *prod_addr = app_ip;
+
+ /* Cleanup in case of something went wrong. */
+ if (ret)
+ {
+ hicn_app_state_del (sw_if);
+
+ if (*faceid != HICN_FACE_NULL)
+ hicn_face_ip_del (*faceid);
+ }
+ return ret;
+}
+
+int
+hicn_face_prod_del (hicn_face_id_t face_id)
+{
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
+
+ if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD)
+ {
+ hicn_face_prod_t *prod_face = (hicn_face_prod_t *) face->data;
+ /* Free the CS reserved for the face */
+ hicn_main.pitcs.pcs_app_max += prod_face->policy.max;
+ hicn_main.pitcs.pcs_app_count -= prod_face->policy.max;
+ prod_face->policy.max = 0;
+
+ /* Remove the face from the fib */
+ hicn_route_del_nhop (&(face_state_vec[face->shared.sw_if].prefix.name),
+ (face_state_vec[face->shared.sw_if].prefix.len),
+ face_id);
+
+ int ret = hicn_face_ip_del (face_id);
+ return ret ==
+ HICN_ERROR_NONE ? hicn_app_state_del (face->shared.sw_if) : ret;
+ }
+ else
+ {
+ return HICN_ERROR_APPFACE_NOT_FOUND;
+ }
+}
+
+int
+hicn_face_prod_set_lru_max (hicn_face_id_t face_id, u32 * requested_size)
+{
+ int ret = HICN_ERROR_NONE;
+ vlib_main_t *vm = vlib_get_main ();
+ hicn_face_t *face;
+ hicn_face_prod_t *face_prod;
+
+ if (!hicn_infra_fwdr_initialized)
+ {
+ ret = HICN_ERROR_FWD_NOT_ENABLED;
+ vlib_cli_output (vm, "hicn: %s\n", get_error_string (ret));
+ return ret;
+ }
+ face = hicn_dpoi_get_from_idx (face_id);
+ face_prod = (hicn_face_prod_t *) face->data;
+
+ if (face == NULL)
+ return HICN_ERROR_FACE_NOT_FOUND;
+
+ if (*requested_size > HICN_PARAM_FACE_MAX_CS_RESERVED)
+ *requested_size = HICN_PARAM_FACE_MAX_CS_RESERVED;
+
+ uint32_t available =
+ hicn_main.pitcs.pcs_app_max - hicn_main.pitcs.pcs_app_count;
+
+ if (*requested_size > available)
+ *requested_size = available;
+
+ face_prod->policy.max = *requested_size;
+ face_prod->policy.count = 0;
+ face_prod->policy.head = face_prod->policy.tail = 0;
+
+ hicn_main.pitcs.pcs_app_count += *requested_size;
+
+ return ret;
+}
+
+u8 *
+format_hicn_face_prod (u8 * s, va_list * args)
+{
+ index_t index = va_arg (*args, index_t);
+ CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
+ hicn_face_t *face;
+ hicn_face_prod_t *prod_face;
+
+ face = hicn_dpoi_get_from_idx (index);
+ prod_face = (hicn_face_prod_t *) face->data;
+
+ s =
+ format (s, " (producer face: CS size %d, data cached %d)",
+ prod_face->policy.max, prod_face->policy.count);
+
+ return s;
+}
+
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT(hicn_prod_app_input_ip6, static)=
+{
+ .arc_name = "ip6-unicast",
+ .node_name = "hicn-face-prod-input",
+ .runs_before = VNET_FEATURES("ip6-inacl"),
+};
+/* *INDENT-ON* */
+
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT(hicn_prod_app_input_ip4, static)=
+{
+ .arc_name = "ip4-unicast",
+ .node_name = "hicn-face-prod-input",
+ .runs_before = VNET_FEATURES("ip4-inacl"),
+};
+/* *INDENT-ON* */
+
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables: eval: (c-set-style "gnu") End:
+ */
diff --git a/hicn-plugin/src/faces/app/face_prod.h b/hicn-plugin/src/faces/app/face_prod.h
new file mode 100755
index 000000000..89b74680b
--- /dev/null
+++ b/hicn-plugin/src/faces/app/face_prod.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _FACE_PRODUCER_H_
+#define _FACE_PRODUCER_H_
+
+#include "../../cache_policies/cs_policy.h"
+#include "../ip/face_ip.h"
+
+/**
+ * @file
+ *
+ * @brief Producer application face.
+ *
+ * A producer application face is built upon an ip face and identify a local
+ * producer application (co-located with the forwarder) that acts as a producer. In the
+ * current design an application face is either a face towards a consumer face
+ * or towards a producer. The interface used by the producer application face is
+ * assumed to be reserved only for hICN traffic (e.g., dedicated memif that
+ * connects the applictation to the forwarder). Only one application face can be
+ * assigned to an interface.
+ *
+ * To each producer application face it is assigned a portion of the CS. Every
+ * data arriving to a producer application will be stored in the portion of the
+ * CS assigned to the face. The eviction policy is defined in the
+ * face. Available eviction faces are list in the /cache_policy folder.
+ *
+ * In the vlib graph a producer application face is directly connected to the
+ * device-input node (with the node hicn-face-prod-input) and passes every packet to
+ * the hicn-face-ip node.
+ */
+
+/**
+ * @brief Producer application face state that refer to the hICN producer socket
+ * created by the application.
+ *
+ */
+typedef struct
+{
+ hicn_prefix_t prefix;
+} hicn_face_prod_state_t;
+
+extern hicn_face_prod_state_t *face_state_vec;
+
+typedef struct __attribute__ ((packed)) hicn_face_prod_t_
+{
+ hicn_face_ip_t ip_face;
+
+ hicn_cs_policy_t policy;
+ hicn_cs_policy_vft_t policy_vft;
+
+} hicn_face_prod_t;
+
+/**
+ * @brief Add a new producer application face
+ *
+ * The method creates the internal ip face and the state specific to the
+ * producer application face. This method setups a route in the FIB for the
+ * producer's prefix.
+ * @param prefix hicn prefix name assigned to the producer face
+ * @param len length of the prefix
+ * @param swif interface associated to the face
+ * @param cs_reserved return the amount of cs assigned to the face
+ * @param prod_addr address to assign to interface used by the appliction to
+ * send data to the producer face
+ */
+int
+hicn_face_prod_add (hicn_prefix_t * prefix, u32 swif, u32 * cs_reserved,
+ ip46_address_t * prod_addr, hicn_face_id_t * faceid);
+
+/**
+ * @brief Delete an existing application face
+ *
+ * @param faceid id of the face to remove
+ */
+int hicn_face_prod_del (hicn_face_id_t faceid);
+
+/**
+ * @brief Set lru queue size for an app face
+ *
+ * @param face_id Id of the producer application face
+ */
+int hicn_face_prod_set_lru_max (hicn_face_id_t face_id, u32 * requested_size);
+
+/**
+ * @brief Format an application producer face
+ *
+ * @param s Pointer to a previous string. If null it will be initialize
+ * @param args Array storing input values. Expected u32 face_id and u32 indent
+ * @return String with the formatted face
+ */
+u8 *format_hicn_face_prod (u8 * s, va_list * args);
+
+
+#endif /* _FACE_PROD_H_ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables: eval: (c-set-style "gnu") End:
+ */
diff --git a/hicn-plugin/src/faces/app/face_prod_node.c b/hicn-plugin/src/faces/app/face_prod_node.c
new file mode 100755
index 000000000..2e746a703
--- /dev/null
+++ b/hicn-plugin/src/faces/app/face_prod_node.c
@@ -0,0 +1,341 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ *
+ * @brief Application interface node
+ *
+ * This node runs after the device-input node and perfoms some safety checks in
+ * order to avoid unespected interest and data (i.e., hICN packets whose name do
+ * not contain the prefix associated to the application face)
+ */
+
+#include "face_prod.h"
+#include "../../hicn_api.h"
+#include "../../mgmt.h"
+
+#define foreach_face_prod_input_error \
+ _(NOT_SOCK_PREFIX, "name not in the socket prefix")
+
+typedef enum
+{
+#define _(f,s) FACE_PROD_INPUT_ERROR_##f,
+ foreach_face_prod_input_error
+#undef _
+ FACE_PROD_INPUT_N_ERROR,
+} face_prod_input_error_t;
+
+static __clib_unused char *face_prod_input_error_strings[] = {
+#define _(n,s) s,
+ foreach_face_prod_input_error
+#undef _
+};
+
+/* Node context data */
+typedef struct hicn_face_prod_runtime_s
+{
+ int id;
+} hicn_face_prod_runtime_t;
+
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+} hicn_face_prod_input_trace_t;
+
+typedef enum
+{
+ HICN_FACE_PROD_NEXT_DATA_IP4,
+ HICN_FACE_PROD_NEXT_DATA_IP6,
+ HICN_FACE_PROD_NEXT_ERROR_DROP,
+ HICN_FACE_PROD_N_NEXT,
+} hicn_face_prod_next_t;
+
+vlib_node_registration_t hicn_face_prod_input_node;
+
+static __clib_unused u8 *
+format_face_prod_input_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_prod_input_trace_t *t =
+ va_arg (*args, hicn_face_prod_input_trace_t *);
+ CLIB_UNUSED (u32 indent) = format_get_indent (s);
+
+ s = format (s, "prod-face: sw_if_index %d next-index %d",
+ t->sw_if_index, t->next_index);
+ return s;
+}
+
+static_always_inline int
+match_ip4_name (u32 * name, hicn_prefix_t * prefix)
+{
+ u32 xor = 0;
+
+ xor = *name & prefix->name.ip4.data_u32;
+
+ return xor == prefix->name.ip4.data_u32;
+}
+
+static_always_inline int
+match_ip6_name (u32x4 * name, hicn_prefix_t * prefix)
+{
+ union
+ {
+ u32x4 as_u32x4;
+ u64 as_u64[2];
+ u32 as_u32[4];
+ } xor_sum __attribute__ ((aligned (sizeof (u32x4))));
+
+#ifdef CLIB_HAVE_VEC128
+ if (U32X4_ALIGNED (name))
+ { //SSE can't handle unaligned data
+ xor_sum.as_u32x4 = *((u32x4 *) name) &
+ UNION_CAST (prefix->name.ip6.as_u64[0], u32x4);
+ }
+ else
+#endif /* CLIB_HAVE_VEC128 */
+ {
+ xor_sum.as_u64[0] = ((u64 *) name)[0] & prefix->name.ip6.as_u64[0];
+ xor_sum.as_u64[1] = ((u64 *) name)[1] & prefix->name.ip6.as_u64[1];
+ }
+
+ return (xor_sum.as_u64[0] == prefix->name.ip6.as_u64[0]) &&
+ (xor_sum.as_u64[1] == prefix->name.ip6.as_u64[1]);
+}
+
+static_always_inline u32
+hicn_face_prod_next_from_data_hdr (vlib_node_runtime_t * node,
+ vlib_buffer_t * b, hicn_prefix_t * prefix)
+{
+ u8 *ptr = vlib_buffer_get_current (b);
+ u8 v = *ptr & 0xf0;
+ int match_res = 1;
+
+ if (PREDICT_TRUE (v == 0x40 && ip46_address_is_ip4 (&prefix->name)))
+ {
+ match_res = match_ip4_name ((u32 *) & (ptr[12]), prefix);
+ }
+ else if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->name)))
+ {
+ match_res = match_ip6_name ((u32x4 *) & (ptr[8]), prefix);
+ }
+
+ b->error = 0*(1-match_res) + match_res*(node->errors[FACE_PROD_INPUT_ERROR_NOT_SOCK_PREFIX]);
+
+ return match_res ? HICN_FACE_PROD_NEXT_DATA_IP4 + (v ==
+ 0x60) :
+ HICN_FACE_PROD_NEXT_ERROR_DROP;
+}
+
+static_always_inline void
+hicn_face_prod_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node,
+ u32 swif, vlib_buffer_t * b, u32 next)
+{
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ hicn_face_prod_input_trace_t *t =
+ vlib_add_trace (vm, node, b, sizeof (*t));
+ t->next_index = next;
+ t->sw_if_index = swif;
+ }
+}
+
+static uword
+hicn_face_prod_input_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next;
+ hicn_face_prod_next_t next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ while (n_left_from >= 8 && n_left_to_next >= 4)
+ {
+ vlib_buffer_t *b0, *b1, *b2, *b3;
+ u32 bi0, bi1, bi2, bi3;
+ hicn_face_prod_state_t *prod_face0 = NULL;
+ hicn_face_prod_state_t *prod_face1 = NULL;
+ hicn_face_prod_state_t *prod_face2 = NULL;
+ hicn_face_prod_state_t *prod_face3 = NULL;
+ u32 next0, next1, next2, next3;
+
+ {
+ vlib_buffer_t *b4, *b5, *b6, *b7;
+ b4 = vlib_get_buffer (vm, from[4]);
+ b5 = vlib_get_buffer (vm, from[5]);
+ b6 = vlib_get_buffer (vm, from[6]);
+ b7 = vlib_get_buffer (vm, from[7]);
+ CLIB_PREFETCH (b4, CLIB_CACHE_LINE_BYTES, STORE);
+ CLIB_PREFETCH (b5, CLIB_CACHE_LINE_BYTES, STORE);
+ CLIB_PREFETCH (b6, CLIB_CACHE_LINE_BYTES, STORE);
+ CLIB_PREFETCH (b7, CLIB_CACHE_LINE_BYTES, STORE);
+ }
+
+ bi0 = from[0];
+ bi1 = from[1];
+ bi2 = from[2];
+ bi3 = from[3];
+
+ from += 4;
+ n_left_from -= 4;
+ to_next[0] = bi0;
+ to_next[1] = bi1;
+ to_next[2] = bi2;
+ to_next[3] = bi3;
+
+ to_next += 4;
+ n_left_to_next -= 4;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ b1 = vlib_get_buffer (vm, bi1);
+ b2 = vlib_get_buffer (vm, bi2);
+ b3 = vlib_get_buffer (vm, bi3);
+
+ prod_face0 =
+ &face_state_vec[vnet_buffer (b0)->sw_if_index[VLIB_RX]];
+ prod_face1 =
+ &face_state_vec[vnet_buffer (b1)->sw_if_index[VLIB_RX]];
+ prod_face2 =
+ &face_state_vec[vnet_buffer (b2)->sw_if_index[VLIB_RX]];
+ prod_face3 =
+ &face_state_vec[vnet_buffer (b3)->sw_if_index[VLIB_RX]];
+
+ next0 =
+ hicn_face_prod_next_from_data_hdr (node, b0, &prod_face0->prefix);
+ next1 =
+ hicn_face_prod_next_from_data_hdr (node, b1, &prod_face1->prefix);
+ next2 =
+ hicn_face_prod_next_from_data_hdr (node, b2, &prod_face2->prefix);
+ next3 =
+ hicn_face_prod_next_from_data_hdr (node, b3, &prod_face3->prefix);
+ stats.pkts_data_count += 4;
+
+ /* trace */
+ hicn_face_prod_trace_buffer (vm, node,
+ vnet_buffer (b0)->sw_if_index[VLIB_RX],
+ b0, next0);
+ hicn_face_prod_trace_buffer (vm, node,
+ vnet_buffer (b1)->sw_if_index[VLIB_RX],
+ b1, next1);
+ hicn_face_prod_trace_buffer (vm, node,
+ vnet_buffer (b2)->sw_if_index[VLIB_RX],
+ b2, next2);
+ hicn_face_prod_trace_buffer (vm, node,
+ vnet_buffer (b3)->sw_if_index[VLIB_RX],
+ b3, next3);
+
+ /* enqueue */
+ vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, bi2, bi3,
+ next0, next1, next2, next3);
+
+ stats.pkts_processed += 4;
+
+ }
+
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ vlib_buffer_t *b0;
+ u32 bi0, swif;
+ hicn_face_prod_state_t *prod_face = NULL;
+ u32 next0;
+
+ if (n_left_from > 1)
+ {
+ vlib_buffer_t *b1;
+ b1 = vlib_get_buffer (vm, from[1]);
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE);
+ }
+
+ bi0 = from[0];
+ from += 1;
+ n_left_from -= 1;
+ to_next[0] = bi0;
+ to_next += 1;
+ n_left_to_next -= 1;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ swif = vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ prod_face = &face_state_vec[swif];
+
+ next0 =
+ hicn_face_prod_next_from_data_hdr (node, b0, &prod_face->prefix);
+ stats.pkts_data_count++;
+
+ /* trace */
+ hicn_face_prod_trace_buffer (vm, node,
+ vnet_buffer (b0)->sw_if_index[VLIB_RX],
+ b0, next0);
+
+ /* enqueue */
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
+
+ stats.pkts_processed += 1;
+
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_PROCESSED, stats.pkts_processed);
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_DATAS,
+ stats.pkts_data_count);
+
+ return (frame->n_vectors);
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE(hicn_face_prod_input_node) =
+{
+ .function = hicn_face_prod_input_node_fn,
+ .name = "hicn-face-prod-input",
+ .vector_size = sizeof(u32),
+ .format_trace = format_face_prod_input_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN(face_prod_input_error_strings),
+ .error_strings = face_prod_input_error_strings,
+ .n_next_nodes = HICN_FACE_PROD_N_NEXT,
+ .next_nodes =
+ {
+ [HICN_FACE_PROD_NEXT_DATA_IP4] = "hicn-face-ip4-input",
+ [HICN_FACE_PROD_NEXT_DATA_IP6] = "hicn-face-ip6-input",
+ [HICN_FACE_PROD_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables: eval: (c-set-style "gnu") End:
+ */
diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c
new file mode 100755
index 000000000..f0559bb98
--- /dev/null
+++ b/hicn-plugin/src/faces/face.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "face.h"
+#include "ip/face_ip.h"
+#include "ip/face_ip_node.h"
+#include "ip/iface_ip_node.h"
+#include "ip/dpo_ip.h"
+#include "udp/face_udp.h"
+#include "udp/face_udp_node.h"
+#include "udp/iface_udp_node.h"
+#include "udp/dpo_udp.h"
+
+dpo_id_t *face_dpo_vec;
+hicn_face_vft_t *face_vft_vec;
+char **face_type_names_vec;
+
+hicn_face_t *hicn_dpoi_face_pool;
+
+dpo_type_t first_type = DPO_FIRST;
+
+u8 *
+face_show (u8 * s, int face_id, u32 indent)
+{
+ s = format (s, "Faces:\n", indent);
+ indent += 4;
+ int i;
+ vec_foreach_index (i, face_dpo_vec)
+ {
+ s =
+ format (s, "%U", face_vft_vec[i].format_face,
+ face_dpo_vec[face_id].dpoi_index, indent);
+ }
+
+ return (s);
+
+}
+
+void
+register_face_type (hicn_face_type_t face_type, hicn_face_vft_t * vft,
+ char *name)
+{
+ if (first_type == DPO_FIRST)
+ first_type = face_type;
+
+ int idx = face_type - first_type;
+ ASSERT (idx >= 0);
+ vec_validate (face_vft_vec, idx);
+ vec_validate (face_type_names_vec, idx);
+
+ /* Copy the null char as well */
+ char *name_str = (char *) malloc ((strlen (name) + 1) * sizeof (char));
+ strcpy (name_str, name);
+ face_vft_vec[idx] = *vft;
+ face_type_names_vec[idx] = name_str;
+}
+
+// Make this more flexible for future types face
+void
+hicn_face_module_init (vlib_main_t * vm)
+{
+ pool_validate (hicn_dpoi_face_pool);
+
+ hicn_face_ip_init (vm);
+ hicn_iface_ip_init (vm);
+ hicn_face_udp_init (vm);
+ hicn_iface_udp_init (vm);
+}
+
+u8 *
+format_hicn_face_all (u8 * s, int n, ...)
+{
+ va_list ap;
+ va_start (ap, n);
+ u32 indent = va_arg (ap, u32);
+
+ s = format (s, "Faces: %d\n", indent);
+
+ hicn_face_t *face;
+
+ /* *INDENT-OFF* */
+ pool_foreach ( face, hicn_dpoi_face_pool,
+ {
+ hicn_face_vft_t * vft = hicn_face_get_vft(face->shared.face_type);
+ hicn_face_id_t face_id = hicn_dpoi_get_index(face);
+ s = format(s, "%U\n", vft->format_face, face_id, indent);
+ });
+ /* *INDENT-ON* */
+
+ return s;
+}
+
+hicn_face_vft_t *
+hicn_face_get_vft (hicn_face_type_t face_type)
+{
+ int idx = face_type - first_type;
+ if (idx >= 0)
+ return &face_vft_vec[idx];
+ else
+ return NULL;
+
+}
+
+int
+hicn_face_del (hicn_face_id_t face_id)
+{
+ int ret = HICN_ERROR_NONE;
+
+ if (pool_len (hicn_dpoi_face_pool) > face_id)
+ {
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
+ if (face->shared.locks == 0)
+ pool_put_index (hicn_dpoi_face_pool, face_id);
+ else
+ face->shared.flags |= HICN_FACE_FLAGS_DELETED;
+ }
+ else
+ ret = HICN_ERROR_FACE_NOT_FOUND;
+
+ return ret;
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h
new file mode 100755
index 000000000..2774d9a2e
--- /dev/null
+++ b/hicn-plugin/src/faces/face.h
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_FACE_H__
+#define __HICN_FACE_H__
+
+#include <vnet/vnet.h>
+#include <vlib/vlib.h>
+#include <vnet/dpo/dpo.h>
+#include <vnet/adj/adj_types.h>
+
+typedef u8 hicn_face_flags_t;
+typedef index_t hicn_face_id_t;
+typedef dpo_type_t hicn_face_type_t;
+
+/**
+ * @file
+ *
+ * @brief Face
+ *
+ * This file implements a general face type. A face is carried through nodes as a
+ * dpo. The face state (hicn_face_t) is the object pointed by the
+ * dpoi_index in the dpo_id_t (see
+ * https://docs.fd.io/vpp/18.07/d0/d37/dpo_8h_source.html).
+ * A face state that does not contain the indication of the l2 adjacency is an
+ * incomplete face (iface), otherwise it is considered to be complete. Each face type
+ * provide specific node for processing packets in input or output of complete
+ * and incomplete faces.
+ */
+
+/**
+ * @brief Fields shared among all the different types of faces
+ */
+typedef struct __attribute__ ((packed)) hicn_face_shared_s
+{
+ /* Flags to idenfity if the face is incomplete (iface), complete (face) */
+ /* And a network or application face (1B) */
+ hicn_face_flags_t flags;
+
+ /* Path label (2B) */
+ u16 pl_id;
+
+ /* Number of dpo holding a reference to the dpoi (4B) */
+ u32 locks;
+
+ /* Adjacency for the neighbor (4B) */
+ adj_index_t adj;
+
+ /* local interface for the local ip address */
+ u32 sw_if;
+
+ /* Face id corresponding to the global face pool (4B) */
+ union
+ {
+ hicn_face_type_t face_type;
+ u32 int_face_type; //To forse the face_type_t to be 4B
+ };
+
+} hicn_face_shared_t;
+
+/**
+ * @brief Structure holding the face state. It containes the fields shared among
+ * all the types of faces as well it leaves some space for storing additional
+ * information specific to each type.
+ */
+typedef struct __attribute__ ((packed)) hicn_face_s
+{
+ /* Additional space to fill with face_type specific information */
+ u8 data[2 * CLIB_CACHE_LINE_BYTES - sizeof (hicn_face_shared_t)];
+ hicn_face_shared_t shared;
+
+}
+
+hicn_face_t;
+
+/* Pool of faces */
+extern hicn_face_t *hicn_dpoi_face_pool;
+
+/* Flags */
+/* A face is complete and it stores all the information. A iface lacks of the
+ adj index, therefore sending a packet through a iface require a lookup in
+ the FIB. */
+#define HICN_FACE_FLAGS_DEFAULT 0x00
+#define HICN_FACE_FLAGS_FACE 0x01
+#define HICN_FACE_FLAGS_IFACE 0x02
+#define HICN_FACE_FLAGS_APPFACE_PROD 0x04 /* Currently only IP face can be appface */
+#define HICN_FACE_FLAGS_APPFACE_CONS 0x08 /* Currently only IP face can be appface */
+#define HICN_FACE_FLAGS_DELETED 0x10
+
+#define HICN_FACE_NULL (hicn_face_id_t) ~0
+
+/**
+ * @brief Definition of the virtual functin table for an hICN FACE DPO.
+ *
+ * An hICN dpo is a combination of a dpo context (hicn_dpo_ctx or struct that
+ * extends a hicn_dpo_ctx) and a strategy node. The following virtual function table
+ * template that glues together the fuction to interact with the context and the
+ * creating the dpo
+ */
+typedef struct hicn_face_vft_s
+{
+ u8 *(*format_face) (u8 * s, va_list * args);
+ /**< Format an hICN face dpo*/
+ int (*hicn_face_del) (hicn_face_id_t face_id);
+ void (*hicn_face_get_dpo) (hicn_face_t * face, dpo_id_t * dpo);
+} hicn_face_vft_t;
+
+
+/* Vector maintaining a dpo per face */
+extern dpo_id_t *face_dpo_vec;
+extern hicn_face_vft_t *face_vft_vec;
+
+/* Vector holding the set of face names */
+extern char **face_type_names_vec;
+
+/* First face type registered in the sytem.*/
+extern dpo_type_t first_type;
+
+/**
+ * @brief Return the face id from the face state
+ *
+ * @param Pointer to the face state
+ * @return face id
+ */
+always_inline hicn_face_id_t
+hicn_dpoi_get_index (hicn_face_t * face_dpoi)
+{
+ return face_dpoi - hicn_dpoi_face_pool;
+}
+
+/**
+ * @brief Return the face from the face id. Face id must be valid.
+ *
+ * @param dpoi_index Face identifier
+ * @return Pointer to the face
+ */
+always_inline hicn_face_t *
+hicn_dpoi_get_from_idx (hicn_face_id_t dpoi_index)
+{
+ return (hicn_face_t *) pool_elt_at_index (hicn_dpoi_face_pool, dpoi_index);
+}
+
+/**
+ * @brief Return true if the face id belongs to an existing face
+ */
+always_inline int
+hicn_dpoi_idx_is_valid (hicn_face_id_t face_id)
+{
+ return pool_len (hicn_dpoi_face_pool) > face_id
+ && !pool_is_free_index (hicn_dpoi_face_pool, face_id);
+}
+
+/**
+ * @brief Add a lock to the face dpo
+ *
+ * @param dpo Pointer to the face dpo
+ */
+always_inline void
+hicn_face_lock (dpo_id_t * dpo)
+{
+ hicn_face_t *face;
+ face = hicn_dpoi_get_from_idx (dpo->dpoi_index);
+ face->shared.locks++;
+}
+
+/**
+ * @brief Remove a lock to the face dpo. Deallocate the face id locks == 0
+ *
+ * @param dpo Pointer to the face dpo
+ */
+always_inline void
+hicn_face_unlock (dpo_id_t * dpo)
+{
+ hicn_face_t *face;
+ face = hicn_dpoi_get_from_idx (dpo->dpoi_index);
+ face->shared.locks--;
+}
+
+/**
+ * @brief Init the internal structures of the face module
+ *
+ * Must be called before processing any packet
+ */
+void hicn_face_module_init (vlib_main_t * vm);
+
+/**
+ * @brief Format all the existing faces
+ *
+ * @param s Pointer to a previous string. If null it will be initialize
+ * @param n Number of input parameters
+ * @return String with the faces formatted
+ */
+u8 *format_hicn_face_all (u8 * s, int n, ...);
+
+/**
+ * @brief Delete a face
+ *
+ * @param face_id Id of the face to delete
+ * @return HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise
+ * HICN_ERROR_NONE
+ */
+int hicn_face_del (hicn_face_id_t face_id);
+
+/**
+ * @brief Return the virtual function table corresponding to the face type
+ *
+ * @param face_type Type of the face
+ * @return NULL if the face type does not exist
+ */
+hicn_face_vft_t *hicn_face_get_vft (hicn_face_type_t face_type);
+
+/**
+ * @brief Register a new face type
+ *
+ * @param face_type Type of the face
+ * @param vft Virtual Function table for the new face type
+ */
+void register_face_type (hicn_face_type_t face_type, hicn_face_vft_t * vft,
+ char *name);
+#endif // __HICN_FACE_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/face_cli.c b/hicn-plugin/src/faces/face_cli.c
new file mode 100755
index 000000000..3ddf96beb
--- /dev/null
+++ b/hicn-plugin/src/faces/face_cli.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vlib/vlib.h>
+#include <vppinfra/error.h>
+#include "face.h"
+#include "../error.h"
+
+static clib_error_t *
+hicn_face_cli_show_command_fn (vlib_main_t * vm,
+ unformat_input_t * main_input,
+ vlib_cli_command_t * cmd)
+{
+
+ hicn_face_id_t face_id = HICN_FACE_NULL;
+ char *face_type_name = NULL;
+ int found = ~0;
+ int deleted = 0;
+
+
+ /* Get a line of input. */
+ unformat_input_t _line_input, *line_input = &_line_input;
+ if (unformat_user (main_input, unformat_line_input, line_input))
+ {
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "%u", &face_id))
+ ;
+ else if (unformat (line_input, "type %s", &face_type_name))
+ ;
+ else if (unformat (line_input, "deleted"))
+ deleted = 1;
+ else
+ {
+ return clib_error_return (0, "%s",
+ get_error_string
+ (HICN_ERROR_CLI_INVAL));
+ }
+ }
+
+ if (face_type_name != NULL)
+ {
+ int idx = 0;
+ vec_foreach_index (idx, face_type_names_vec)
+ {
+ if (!strcmp (face_type_names_vec[idx], face_type_name))
+ found = idx;
+ }
+ if (found == ~0)
+ return (clib_error_return (0, "Face type unknown"));
+ }
+
+ }
+
+ if (face_id != HICN_FACE_NULL)
+ {
+ if (!hicn_dpoi_idx_is_valid (face_id))
+ return clib_error_return (0, "%s",
+ get_error_string
+ (HICN_ERROR_FACE_NOT_FOUND));
+
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
+ hicn_face_vft_t *vft = hicn_face_get_vft (face->shared.face_type);
+ vlib_cli_output (vm, "%U\n", vft->format_face, face_id, 0 /*indent */ );
+ }
+ else
+ {
+ if (found != ~0)
+ {
+ hicn_face_t *face;
+ dpo_type_t type = (dpo_type_t) (found + first_type);
+ hicn_face_vft_t *vft = hicn_face_get_vft (type);
+ /* *INDENT-OFF* */
+ pool_foreach(face, hicn_dpoi_face_pool,
+ {
+ if (!((face->shared.flags & HICN_FACE_FLAGS_DELETED) && !deleted))
+ {
+ if ((face->shared.face_type == type) && (face->shared.flags))
+ vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0);
+ }
+ });
+ /* *INDENT-ON* */
+ }
+ else
+ {
+ hicn_face_t *face;
+ /* *INDENT-OFF* */
+ pool_foreach(face, hicn_dpoi_face_pool,
+ {
+ if (!((face->shared.flags & HICN_FACE_FLAGS_DELETED) && !deleted))
+ {
+ hicn_face_vft_t * vft = hicn_face_get_vft(face->shared.face_type);
+ vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0);
+ }
+ });
+ /* *INDENT-ON* */
+ }
+ }
+
+ return 0;
+}
+
+/* cli declaration for 'show faces' */
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (hicn_face_cli_show_command, static) =
+{
+ .path = "hicn face show",
+ .short_help = "hicn face show [<face_id>| type <ip/udp>]",
+ .function = hicn_face_cli_show_command_fn,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/dpo_ip.c b/hicn-plugin/src/faces/ip/dpo_ip.c
new file mode 100755
index 000000000..1b2dbcff9
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/dpo_ip.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dpo_ip.h"
+
+mhash_t hicn_face_ip_local_hashtb;
+mhash_t hicn_face_ip_remote_hashtb;
+dpo_type_t hicn_face_ip_type;
+
+const static char *const hicn_face_ip4dpoi_nodes[] = {
+ "hicn-face-ip4-input",
+ "hicn-face-ip4-output",
+ "hicn-iface-ip4-input",
+ "hicn-iface-ip4-output",
+ NULL,
+};
+
+const static char *const hicn_face_ip6dpoi_nodes[] = {
+ "hicn-face-ip6-input",
+ "hicn-face-ip6-output",
+ "hicn-iface-ip6-input",
+ "hicn-iface-ip6-output",
+ NULL,
+};
+
+const static char *const *const hicn_ip_nodes[DPO_PROTO_NUM] = {
+ [DPO_PROTO_IP4] = hicn_face_ip4dpoi_nodes,
+ [DPO_PROTO_IP6] = hicn_face_ip6dpoi_nodes
+};
+
+const static dpo_vft_t hicn_face_ip_vft = {
+ .dv_lock = hicn_face_lock,
+ .dv_unlock = hicn_face_unlock,
+ .dv_format = format_hicn_face_ip,
+};
+
+/* Must be executed after all the strategy nodes are created */
+void
+hicn_dpo_ip_module_init (void)
+{
+ mhash_init (&hicn_face_ip_local_hashtb,
+ sizeof (hicn_face_id_t) /* value */ ,
+ sizeof (hicn_face_ip_key_t) /* key */ );
+ mhash_init (&hicn_face_ip_remote_hashtb,
+ sizeof (hicn_face_id_t) /* value */ ,
+ sizeof (hicn_face_ip_key_t) /* key */ );
+
+ /*
+ * How much useful is the following registration?
+ * So far it seems that we need it only for setting the dpo_type.
+ */
+ hicn_face_ip_type =
+ dpo_register_new_type (&hicn_face_ip_vft, hicn_ip_nodes);
+}
+
+
+int
+hicn_dpo_ip4_create (dpo_id_t * dpo,
+ const ip4_address_t * local_addr,
+ const ip4_address_t * remote_addr,
+ u32 sw_if,
+ adj_index_t adj,
+ u32 node_index,
+ hicn_face_flags_t flags, hicn_face_id_t * face_id)
+{
+ /* If local matches the dpoi is a face */
+ hicn_face_t *face =
+ hicn_face_ip4_get (local_addr, sw_if, &hicn_face_ip_local_hashtb);
+ u8 is_appface;
+
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ face = hicn_face_ip4_get (remote_addr, sw_if, &hicn_face_ip_remote_hashtb);
+
+ if (face == NULL)
+ {
+ hicn_dpo_ip4_add_and_lock_from_remote (dpo, &is_appface, local_addr,
+ remote_addr, sw_if, node_index);
+ *face_id = (hicn_face_id_t) dpo->dpoi_index;
+ face = hicn_dpoi_get_from_idx (*face_id);
+ }
+ else
+ {
+ *face_id = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, *face_id);
+ dpo->dpoi_next_node = node_index;
+ }
+
+
+ hicn_face_ip_key_t key;
+ hicn_face_ip4_get_key (local_addr, sw_if, &key);
+
+ mhash_set_mem (&hicn_face_ip_local_hashtb, &key, (uword *) face_id, 0);
+
+ hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
+ ip46_address_set_ip4 (&ip_face->local_addr, local_addr);
+ ip46_address_set_ip4 (&ip_face->remote_addr, remote_addr);
+ face->shared.flags = flags;
+ face->shared.adj = adj;
+
+ return HICN_ERROR_NONE;
+}
+
+int
+hicn_dpo_ip6_create (dpo_id_t * dpo,
+ const ip6_address_t * local_addr,
+ const ip6_address_t * remote_addr,
+ u32 sw_if,
+ adj_index_t adj,
+ u32 node_index,
+ hicn_face_flags_t flags, hicn_face_id_t * face_id)
+{
+ /* If local matches the dpoi is a face */
+ hicn_face_t *face =
+ hicn_face_ip6_get (local_addr, sw_if, &hicn_face_ip_local_hashtb);
+
+ u8 is_appface;
+
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ face = hicn_face_ip6_get (remote_addr, sw_if, &hicn_face_ip_remote_hashtb);
+
+ /* If remote matches the dpoi is a iface */
+ if (face == NULL)
+ {
+ hicn_dpo_ip6_add_and_lock_from_remote (dpo, &is_appface, local_addr,
+ remote_addr, sw_if, node_index);
+ *face_id = (hicn_face_id_t) dpo->dpoi_index;
+ face = hicn_dpoi_get_from_idx (*face_id);
+ }
+ else
+ {
+ *face_id = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP6, *face_id);
+ dpo->dpoi_next_node = node_index;
+ }
+
+ hicn_face_ip_key_t key;
+ hicn_face_ip6_get_key (local_addr, sw_if, &key);
+
+ mhash_set_mem (&hicn_face_ip_local_hashtb, &key, (uword *) face_id, 0);
+
+ hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
+ clib_memcpy (&ip_face->local_addr, local_addr, sizeof (ip6_address_t));
+ clib_memcpy (&ip_face->remote_addr, remote_addr, sizeof (ip6_address_t));
+ face->shared.sw_if = sw_if;
+ face->shared.flags = flags;
+ face->shared.adj = adj;
+
+
+ return HICN_ERROR_NONE;
+}
+
+void
+hicn_dpo_ip_create_from_face (hicn_face_t * face, dpo_id_t * dpo,
+ u16 dpoi_next_node)
+{
+ hicn_face_id_t face_dpoi_id = hicn_dpoi_get_index (face);
+ hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
+ dpo_set (dpo, face->shared.face_type,
+ ip46_address_is_ip4 (&ip_face->
+ local_addr) ? DPO_PROTO_IP4 : DPO_PROTO_IP6,
+ face_dpoi_id);
+ dpo->dpoi_next_node = dpoi_next_node;
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/dpo_ip.h b/hicn-plugin/src/faces/ip/dpo_ip.h
new file mode 100755
index 000000000..675443277
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/dpo_ip.h
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_DPO_IP_H__
+#define __HICN_DPO_IP_H__
+
+#include <vnet/vnet.h>
+#include <vnet/ip/ip4_packet.h>
+
+#include "face_ip.h"
+#include "../face.h"
+
+/**
+ * @brief Initialize the internal structures of the dpo ip face module.
+ */
+void hicn_dpo_ip_module_init (void);
+
+
+/**
+ * @brief Retrieve a face from the ip4 local address and returns its dpo. This
+ * method adds a lock on the face state.
+ *
+ * @param dpo: Result of the lookup. If the face doesn't exist dpo = NULL
+ * @param is_appface: Boolean that indicates whether the face is an application
+ * face or not
+ * @param local_addr: Ip v4 local address of the face
+ * @param sw_if: software interface id of the face
+ *
+ * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.
+ */
+always_inline int
+hicn_dpo_ip4_lock_from_local (dpo_id_t * dpo,
+ u8 * is_appface,
+ const ip4_address_t * local_addr, u32 sw_if)
+{
+ hicn_face_t *face =
+ hicn_face_ip4_get (local_addr, sw_if, &hicn_face_ip_local_hashtb);
+
+ if (PREDICT_FALSE (face == NULL))
+ return HICN_ERROR_FACE_NOT_FOUND;
+
+ *is_appface = face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD;
+
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
+ dpo->dpoi_next_node = ~0;
+ dpo_lock (dpo);
+
+ return HICN_ERROR_NONE;
+}
+
+/**
+ * @brief Retrieve a face from the ip6 local address and returns its dpo. This
+ * method adds a lock on the face state.
+ *
+ * @param dpo: Result of the lookup. If the face doesn't exist dpo = NULL
+ * @param is_appface: Boolean that indicates whether the face is an application
+ * face or not
+ * @param local_addr: Ip v6 local address of the face
+ * @param sw_if: software interface id of the face
+ *
+ * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.
+ */
+always_inline int
+hicn_dpo_ip6_lock_from_local (dpo_id_t * dpo,
+ u8 * is_appface,
+ const ip6_address_t * local_addr, u32 sw_if)
+{
+ hicn_face_t *face =
+ hicn_face_ip6_get (local_addr, sw_if, &hicn_face_ip_local_hashtb);
+
+ if (PREDICT_FALSE (face == NULL))
+ return HICN_ERROR_FACE_NOT_FOUND;
+
+ *is_appface = face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD;
+
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP6, dpoi_index);
+ dpo->dpoi_next_node = ~0;
+ dpo_lock (dpo);
+
+ return HICN_ERROR_NONE;
+}
+
+
+/**
+ * @brief Retrieve, or create if it doesn't exist, a face from the ip6 local
+ * address and returns its dpo. This method adds a lock on the face state.
+ *
+ * @param dpo: Result of the lookup
+ * @param is_appface: Boolean that indicates whether the face is an application
+ * face or not
+ * @param local_addr: Ip v4 local address of the face
+ * @param remote_addr: Ip v4 remote address of the face
+ * @param sw_if: software interface id of the face
+ * @param node_index: vlib edge index to use in the packet processing
+ */
+always_inline void
+hicn_dpo_ip4_add_and_lock_from_remote (dpo_id_t * dpo,
+ u8 * is_appface,
+ const ip4_address_t * local_addr,
+ const ip4_address_t * remote_addr,
+ u32 sw_if, u32 node_index)
+{
+ /*All (complete) faces are indexed by remote addess as well */
+ hicn_face_t *face =
+ hicn_face_ip4_get (remote_addr, sw_if, &hicn_face_ip_remote_hashtb);
+
+ if (face == NULL)
+ {
+ hicn_face_id_t dpoi_index;
+ ip46_address_t local_addr46 = to_ip46 (0, (u8 *) local_addr);
+ ip46_address_t remote_addr46 = to_ip46 (0, (u8 *) remote_addr);
+ hicn_iface_ip_add (&local_addr46, &remote_addr46, sw_if, &dpoi_index);
+
+ *is_appface = 0;
+
+ dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
+ dpo->dpoi_next_node = node_index;
+ dpo_lock (dpo);
+
+ return;
+ }
+
+ /* Code replicated on purpose */
+ *is_appface = face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD;
+
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
+ dpo->dpoi_next_node = node_index;
+ dpo_lock (dpo);
+}
+
+/**
+ * @brief Retrieve, or create if it doesn't exist, a face from the ip6 local
+ * address and returns its dpo. This method adds a lock on the face state.
+ *
+ * @param dpo: Result of the lookup
+ * @param is_appface: Boolean that indicates whether the face is an application
+ * face or not
+ * @param local_addr: Ip v6 local address of the face
+ * @param remote_addr: Ip v6 remote address of the face
+ * @param sw_if: software interface id of the face
+ * @param node_index: vlib edge index to use in the packet processing
+ */
+always_inline void
+hicn_dpo_ip6_add_and_lock_from_remote (dpo_id_t * dpo,
+ u8 * is_appface,
+ const ip6_address_t * local_addr,
+ const ip6_address_t * remote_addr,
+ u32 sw_if, u32 node_index)
+{
+ /*All (complete) faces are indexed by remote addess as well */
+ hicn_face_t *face =
+ hicn_face_ip6_get (remote_addr, sw_if, &hicn_face_ip_remote_hashtb);
+
+ if (face == NULL)
+ {
+ hicn_face_id_t dpoi_index;
+ hicn_iface_ip_add ((ip46_address_t *) local_addr,
+ (ip46_address_t *) remote_addr, sw_if, &dpoi_index);
+
+ *is_appface = 0;
+
+ dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP4, dpoi_index);
+ dpo->dpoi_next_node = node_index;
+ dpo_lock (dpo);
+
+ return;
+ }
+ /* Code replicated on purpose */
+ *is_appface = face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD;
+
+ index_t dpoi_index = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_ip_type, DPO_PROTO_IP6, dpoi_index);
+ dpo->dpoi_next_node = node_index;
+ dpo_lock (dpo);
+}
+
+
+/**
+ * @brief Create an ip face and its corresponding dpo. Meant to be used for the
+ * control plane.
+ *
+ * @param dpo: Data plane object that point to the face created.
+ * @param local_addr: Ip v4 local address of the face
+ * @param remote_addr: Ip v4 remote address of the face
+ * @param sw_if: software interface id of the face
+ * @param adj: Ip adjacency corresponding to the remote address in the face
+ * @param node_index: vlib edge index to use in the packet processing
+ * @param flags: Flags of the face
+ * @param face_id: Identifier for the face (dpoi_index)
+ * @return HICN_ERROR_FACE_ALREADY_CREATED if the face exists, otherwise HICN_ERROR_NONE
+ */
+int hicn_dpo_ip4_create (dpo_id_t * dpo,
+ const ip4_address_t * local_addr,
+ const ip4_address_t * remote_addr,
+ u32 sw_if,
+ adj_index_t adj,
+ u32 node_index,
+ hicn_face_flags_t flags, hicn_face_id_t * face_id);
+
+/**
+ * @brief Create an ip face and its corresponding dpo. Meant to be used for the
+ * control plane.
+ *
+ * @param dpo: Data plane object that point to the face created.
+ * @param local_addr: Ip v6 local address of the face
+ * @param remote_addr: Ip v6 remote address of the face
+ * @param sw_if: software interface id of the face
+ * @param adj: Ip adjacency corresponding to the remote address in the face
+ * @param node_index: vlib edge index to use in the packet processing
+ * @param flags: Flags of the face
+ * @param face_id: Identifier for the face (dpoi_index)
+ * @return HICN_ERROR_FACE_ALREADY_CREATED if the face exists, otherwise HICN_ERROR_NONE
+ */
+int hicn_dpo_ip6_create (dpo_id_t * dpo,
+ const ip6_address_t * local_addr,
+ const ip6_address_t * remote_addr,
+ u32 sw_if,
+ adj_index_t adj,
+ u32 node_index,
+ hicn_face_flags_t flags, hicn_face_id_t * face_id);
+
+/**
+ * @brief Create a dpo from an ip face
+ *
+ * @param face Face from which to create the dpo
+ * @param dpoi_next_node Edge index that connects a node to the iface or face nodes
+ * @return the dpo
+ */
+void hicn_dpo_ip_create_from_face (hicn_face_t * face, dpo_id_t * dpo,
+ u16 dpoi_next_node);
+
+#endif // __HICN_DPO_IP_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/face_ip.c b/hicn-plugin/src/faces/ip/face_ip.c
new file mode 100755
index 000000000..c7f6a1ba1
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/face_ip.c
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "face_ip.h"
+#include "face_ip_node.h"
+#include "dpo_ip.h"
+#include "../../strategy_dpo_manager.h"
+#include "../face.h"
+#include "../../cache_policies/cs_lru.h"
+#include "../../infra.h"
+#include "../../hicn.h"
+#include "../app/face_prod.h"
+#include "../app/face_cons.h"
+
+#include "../../mapme.h" // HICN_MAPME_EVENT_*
+#include "../../mapme_eventmgr.h" // hicn_mapme_eventmgr_process_node
+
+extern vlib_node_registration_t hicn_mapme_eventmgr_process_node;
+
+u32 strategy_face_ip4_vlib_edge;
+u32 strategy_face_ip6_vlib_edge;
+
+void
+hicn_face_ip_init (vlib_main_t * vm)
+{
+ int strategy_nodes_n = hicn_strategy_get_all_available ();
+
+ /* Default Strategy has index 0 and it always exists */
+ strategy_face_ip4_vlib_edge = vlib_node_add_next (vm,
+ hicn_dpo_get_strategy_vft
+ (default_dpo.
+ hicn_dpo_get_type ())->
+ get_strategy_node_index
+ (),
+ hicn_face_ip4_output_node.
+ index);
+
+ strategy_face_ip6_vlib_edge = vlib_node_add_next (vm,
+ hicn_dpo_get_strategy_vft
+ (default_dpo.
+ hicn_dpo_get_type ())->
+ get_strategy_node_index
+ (),
+ hicn_face_ip6_output_node.
+ index);
+ /*
+ * Create and edge between al the other strategy nodes
+ * and the ip_encap nodes.
+ */
+ for (int i = 1; i < strategy_nodes_n; i++)
+ {
+ u32 temp_index4 = vlib_node_add_next (vm,
+ hicn_dpo_get_strategy_vft_from_id
+ (i)->get_strategy_node_index (),
+ hicn_face_ip4_output_node.index);
+ u32 temp_index6 = vlib_node_add_next (vm,
+ hicn_dpo_get_strategy_vft_from_id
+ (i)->get_strategy_node_index (),
+ hicn_face_ip6_output_node.index);
+ ASSERT (temp_index4 == strategy_face_ip4_vlib_edge);
+ ASSERT (temp_index6 == strategy_face_ip6_vlib_edge);
+ }
+
+ hicn_dpo_ip_module_init ();
+
+ register_face_type (hicn_face_ip_type, &ip_vft, "ip");
+}
+
+int
+hicn_face_ip_del (hicn_face_id_t face_id)
+{
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
+ hicn_face_ip_t *face_ip = (hicn_face_ip_t *) face->data;
+ hicn_face_ip_key_t key;
+ hicn_face_ip_key_t old_key;
+
+ if (ip46_address_is_ip4 (&face_ip->local_addr))
+ {
+ hicn_face_ip4_get_key (&(face_ip->local_addr.ip4), face->shared.sw_if,
+ &key);
+ mhash_unset (&hicn_face_ip_local_hashtb, &key, (uword *) & old_key);
+ hicn_face_ip4_get_key (&(face_ip->remote_addr.ip4), face->shared.sw_if,
+ &key);
+ mhash_unset (&hicn_face_ip_remote_hashtb, &key, (uword *) & old_key);
+ }
+ else
+ {
+ hicn_face_ip6_get_key (&(face_ip->local_addr.ip6), face->shared.sw_if,
+ &key);
+ mhash_unset (&hicn_face_ip_local_hashtb, &key, (uword *) & old_key);
+ hicn_face_ip6_get_key (&(face_ip->remote_addr.ip6), face->shared.sw_if,
+ &key);
+ mhash_unset (&hicn_face_ip_remote_hashtb, &key, (uword *) & old_key);
+ }
+ return hicn_face_del (face_id);
+}
+
+
+/*
+ * Utility that adds a new face cache entry. For the moment we assume that the
+ * ip_adjacency has already been set up.
+ */
+int
+hicn_face_ip_add (const ip46_address_t * local_addr,
+ const ip46_address_t * remote_addr,
+ int sw_if, hicn_face_id_t * pfaceid)
+{
+ fib_protocol_t fib_type;
+ vnet_link_t link_type;
+ adj_index_t adj;
+ dpo_proto_t dpo_proto;
+
+ /* Check if we found at least one ip address */
+ if (ip46_address_is_zero (local_addr) || ip46_address_is_zero (remote_addr))
+ return HICN_ERROR_FACE_NO_GLOBAL_IP;
+
+ if (ip46_address_is_ip4 (local_addr) && ip46_address_is_ip4 (remote_addr))
+ {
+ link_type = VNET_LINK_IP4;
+ fib_type = FIB_PROTOCOL_IP4;
+ }
+ else
+ {
+ link_type = VNET_LINK_IP6;
+ fib_type = FIB_PROTOCOL_IP6;
+ }
+
+
+ adj = adj_nbr_add_or_lock (fib_type, link_type, remote_addr, sw_if);
+
+ hicn_face_flags_t flags = (hicn_face_flags_t) 0;
+ flags |= HICN_FACE_FLAGS_FACE;
+
+ hicn_face_t *face;
+ if (ip46_address_is_ip4 (local_addr))
+ {
+ face =
+ hicn_face_ip4_get (&(local_addr->ip4), sw_if,
+ &hicn_face_ip_local_hashtb);
+
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ face =
+ hicn_face_ip4_get (&(remote_addr->ip4), sw_if,
+ &hicn_face_ip_remote_hashtb);
+
+ /* If remote matches the face is a iface */
+ if (face == NULL)
+ {
+ hicn_iface_ip_add (local_addr, remote_addr, sw_if, pfaceid);
+ face = hicn_dpoi_get_from_idx (*pfaceid);
+ }
+ else
+ {
+ *pfaceid = hicn_dpoi_get_index (face);
+ }
+
+ hicn_face_ip_key_t key;
+ hicn_face_ip4_get_key (&(local_addr->ip4), sw_if, &key);
+
+ mhash_set_mem (&hicn_face_ip_local_hashtb, &key, (uword *) pfaceid, 0);
+
+ hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
+ clib_memcpy (&ip_face->local_addr, local_addr, sizeof (ip4_address_t));
+ clib_memcpy (&ip_face->remote_addr, remote_addr,
+ sizeof (ip4_address_t));
+ face->shared.sw_if = sw_if;
+ face->shared.flags = flags;
+ face->shared.adj = adj;
+
+ dpo_proto = DPO_PROTO_IP4;
+ }
+ else
+ {
+ face =
+ hicn_face_ip6_get (&(local_addr->ip6), sw_if,
+ &hicn_face_ip_local_hashtb);
+
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ face =
+ hicn_face_ip6_get (&(remote_addr->ip6), sw_if,
+ &hicn_face_ip_remote_hashtb);
+
+ /* If remote matches the face is a iface */
+ if (face == NULL)
+ {
+ hicn_iface_ip_add (local_addr, remote_addr, sw_if, pfaceid);
+ face = hicn_dpoi_get_from_idx (*pfaceid);
+ }
+ else
+ {
+ *pfaceid = hicn_dpoi_get_index (face);
+ }
+
+ hicn_face_ip_key_t key;
+ hicn_face_ip6_get_key (&(local_addr->ip6), sw_if, &key);
+
+ mhash_set_mem (&hicn_face_ip_local_hashtb, &key, (uword *) pfaceid, 0);
+
+ hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
+ clib_memcpy (&ip_face->local_addr, local_addr, sizeof (ip6_address_t));
+ clib_memcpy (&ip_face->remote_addr, remote_addr,
+ sizeof (ip6_address_t));
+ face->shared.sw_if = sw_if;
+ face->shared.flags = flags;
+ face->shared.adj = adj;
+
+ dpo_proto = DPO_PROTO_IP6;
+ }
+
+ retx_t *retx = vlib_process_signal_event_data (vlib_get_main (),
+ hicn_mapme_eventmgr_process_node.
+ index,
+ HICN_MAPME_EVENT_FACE_ADD, 1,
+ sizeof (retx_t));
+ *retx = (retx_t)
+ {
+ .prefix = 0,.dpo = (dpo_id_t)
+ {
+ .dpoi_type = hicn_face_ip_type,.dpoi_proto = dpo_proto,.dpoi_next_node =
+ 0,.dpoi_index = *pfaceid,}
+ };
+
+ return HICN_ERROR_NONE;
+}
+
+u8 *
+format_hicn_face_ip (u8 * s, va_list * args)
+{
+ index_t index = va_arg (*args, index_t);
+ CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
+ hicn_face_t *face;
+ hicn_face_ip_t *ip_face;
+ ip_adjacency_t *adj;
+ vnet_main_t *vnm = vnet_get_main ();
+
+ face = hicn_dpoi_get_from_idx (index);
+ ip_face = (hicn_face_ip_t *) face->data;
+
+ if (face->shared.flags & HICN_FACE_FLAGS_FACE)
+ {
+ ASSERT (face->shared.adj != (adj_index_t) ~ 0);
+ adj = adj_get (face->shared.adj);
+
+ hicn_face_id_t face_id = hicn_dpoi_get_index (face);
+ s = format (s, "%U Face %d: ", format_white_space, indent, face_id);
+ s = format (s, "type IP local %U ",
+ format_ip46_address, &ip_face->local_addr, IP46_TYPE_ANY);
+ s =
+ format (s, "remote %U ", format_ip46_address, &ip_face->remote_addr,
+ IP46_TYPE_ANY);
+ s = format (s, "%U", format_vnet_link, adj->ia_link);
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ vnet_get_sw_interface (vnm, face->shared.sw_if));
+
+ if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD))
+ s = format (s, " %U", format_hicn_face_prod, face_id, 0);
+ else if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS))
+ s = format (s, " %U", format_hicn_face_cons, face_id, 0);
+
+ if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
+ s = format (s, " (deleted)");
+ }
+ else
+ {
+ hicn_face_id_t face_id = hicn_dpoi_get_index (face);
+ s = format (s, "%U iFace %d: ", format_white_space, indent, face_id);
+ s = format (s, "type IP local %U remote %U",
+ format_ip46_address, &ip_face->local_addr, IP46_TYPE_ANY,
+ format_ip46_address, &ip_face->remote_addr, IP46_TYPE_ANY);
+ s =
+ format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ vnet_get_sw_interface (vnm, face->shared.sw_if));
+
+ if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD))
+ s = format (s, " %U", format_hicn_face_prod, face_id, 0);
+ else if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_CONS))
+ s = format (s, " %U", format_hicn_face_cons, face_id, 0);
+
+ if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
+ s = format (s, " (deleted)");
+ }
+
+ return s;
+}
+
+void
+hicn_face_ip_get_dpo (hicn_face_t * face, dpo_id_t * dpo)
+{
+
+ hicn_face_ip_t *face_ip = (hicn_face_ip_t *) face->data;
+ return hicn_dpo_ip_create_from_face (face, dpo,
+ ip46_address_is_ip4 (&face_ip->
+ remote_addr) ?
+ strategy_face_ip4_vlib_edge :
+ strategy_face_ip6_vlib_edge);
+}
+
+hicn_face_vft_t ip_vft = {
+ .format_face = format_hicn_face_ip,
+ .hicn_face_del = hicn_face_ip_del,
+ .hicn_face_get_dpo = hicn_face_ip_get_dpo,
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/face_ip.h b/hicn-plugin/src/faces/ip/face_ip.h
new file mode 100755
index 000000000..8c31f6dd3
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/face_ip.h
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_FACE_IP_H__
+#define __HICN_FACE_IP_H__
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+#include "../face.h"
+#include "../../cache_policies/cs_policy.h"
+
+/**
+ * @file
+ *
+ * @brief IP face
+ *
+ * A face is carried through nodes as a dpo. The face state is the object
+ * pointed by the dpoi_index in the dpo_id_t (see
+ * https://docs.fd.io/vpp/18.07/d0/d37/dpo_8h_source.html)
+ */
+typedef struct hicn_ip_face_t_
+{
+ /**
+ * The headers to paint, in packet painting order
+ */
+ /* Local address of the interface sw_if */
+ ip46_address_t local_addr;
+
+ /* Remote address of neighbor */
+ ip46_address_t remote_addr;
+
+} hicn_face_ip_t;
+
+
+/**
+ * Hash tables that indexes a face by local address. For fast lookup when an
+ * data arrives.
+ */
+extern mhash_t hicn_face_ip_local_hashtb;
+
+/**
+ * Hash tables that indexes a face by remote address. For fast lookup when an
+ * interest arrives.
+ */
+extern mhash_t hicn_face_ip_remote_hashtb;
+
+/**
+ * Key definition for the mhash table. An ip face is uniquely identified by ip
+ * address and the interface id. The ip address can correspond to the remote ip
+ * address of the next hicn hop, or to the local address of the receiving
+ * interface. The former is used to retrieve the incoming face when an interest
+ * is received, the latter when the arring packet is a data.
+ */
+typedef struct hicn_face_ip_key_s
+{
+ ip46_address_t addr;
+ u32 sw_if;
+} hicn_face_ip_key_t;
+
+
+extern hicn_face_type_t hicn_face_ip_type;
+extern hicn_face_vft_t ip_vft;
+
+/**
+ * @brief Create the key object for the mhash. Fill in the key object with the
+ * expected values.
+ *
+ * @param addr Local or remote ip v6 address of the face
+ * @param sw_if interface associated to the face
+ * @param key Pointer to an allocated hicn_face_ip_key_t object
+ */
+always_inline void
+hicn_face_ip6_get_key (const ip6_address_t * addr,
+ u32 sw_if, hicn_face_ip_key_t * key)
+{
+ key->addr.ip6 = *addr;
+ key->sw_if = sw_if;
+}
+
+
+/**
+ * @brief Create the key object for the mhash. Fill in the key object with the
+ * expected values.
+ *
+ * @param addr Local or remote ip v4 address of the face
+ * @param sw_if interface associated to the face
+ * @param key Pointer to an allocated hicn_face_ip_key_t object
+ */
+always_inline void
+hicn_face_ip4_get_key (const ip4_address_t * addr,
+ u32 sw_if, hicn_face_ip_key_t * key)
+{
+ ip46_address_set_ip4 (&(key->addr), addr);
+ key->sw_if = sw_if;
+}
+
+/**
+ * @brief Get the dpoi from the ip v4 address. Does not add any lock.
+ *
+ * @param addr Ip v4 address used to create the key for the hash table.
+ * @param sw_if Software interface id used to create the key for the hash table.
+ * @param hashtb Hash table (remote or local) where to perform the lookup.
+ *
+ * @result Pointer to the face.
+ */
+always_inline hicn_face_t *
+hicn_face_ip4_get (const ip4_address_t * addr, u32 sw_if, mhash_t * hashtb)
+{
+ hicn_face_ip_key_t key;
+
+ hicn_face_ip4_get_key (addr, sw_if, &key);
+
+ hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb,
+ &key);
+
+ return dpoi_index == NULL ? NULL : hicn_dpoi_get_from_idx (*dpoi_index);
+}
+
+/**
+ * @brief Get the dpoi from the ip v6 address. Does not add any lock.
+ *
+ * @param addr Ip v6 address used to create the key for the hash table.
+ * @param sw_if Software interface id used to create the key for the hash table.
+ * @param hashtb Hash table (remote or local) where to perform the lookup.
+ *
+ * @result Pointer to the face.
+ */
+always_inline hicn_face_t *
+hicn_face_ip6_get (const ip6_address_t * addr, u32 sw_if, mhash_t * hashtb)
+{
+ hicn_face_ip_key_t key;
+
+ hicn_face_ip6_get_key (addr, sw_if, &key);
+
+ hicn_face_id_t *dpoi_index = (hicn_face_id_t *) mhash_get (hashtb,
+ &key);
+
+ return dpoi_index == NULL ? NULL : hicn_dpoi_get_from_idx (*dpoi_index);
+}
+
+/**
+ * @brief Create a new face ip. API for other modules (e.g., routing)
+ *
+ * @param local_addr Local ip v4 or v6 address of the face
+ * @param remote_addr Remote ip v4 or v6 address of the face
+ * @param sw_if interface associated to the face
+ * @param is_app_face Boolean to set the face as an application face
+ * @param pfaceid Pointer to return the face id
+ * @return HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally
+ * reachable ip address, otherwise HICN_ERROR_NONE
+ */
+int hicn_face_ip_add (const ip46_address_t * local_addr,
+ const ip46_address_t * remote_addr,
+ int swif, hicn_face_id_t * pfaceid);
+
+/**
+ * @brief Create a new incomplete face ip. (Meant to be used by the data plane)
+ *
+ * @param local_addr Local ip v4 or v6 address of the face
+ * @param remote_addr Remote ip v4 or v6 address of the face
+ * @param sw_if interface associated to the face
+ * @param pfaceid Pointer to return the face id
+ * @return HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally
+ * reachable ip address, otherwise HICN_ERROR_NONE
+ */
+always_inline void
+hicn_iface_ip_add (const ip46_address_t * local_addr,
+ const ip46_address_t * remote_addr,
+ int sw_if, hicn_face_id_t * pfaceid)
+{
+ hicn_face_t *face;
+ pool_get (hicn_dpoi_face_pool, face);
+
+ hicn_face_ip_t *ip_face = (hicn_face_ip_t *) (face->data);
+
+ clib_memcpy (&(ip_face->local_addr.ip6), local_addr,
+ sizeof (ip6_address_t));
+ clib_memcpy (&(ip_face->remote_addr.ip6), remote_addr,
+ sizeof (ip6_address_t));
+ face->shared.sw_if = sw_if;
+
+ face->shared.adj = ADJ_INDEX_INVALID;
+ face->shared.pl_id = (u16) 0;
+ face->shared.face_type = hicn_face_ip_type;
+ face->shared.flags = HICN_FACE_FLAGS_IFACE;
+ face->shared.locks = 0;
+
+ hicn_face_ip_key_t key;
+ hicn_face_ip6_get_key (&(remote_addr->ip6), sw_if, &key);
+ *pfaceid = hicn_dpoi_get_index (face);
+
+ mhash_set_mem (&hicn_face_ip_remote_hashtb, &key, (uword *) pfaceid, 0);
+}
+
+/**
+ * @brief Delete an ip face
+ *
+ * @param face_id Id of the face to delete
+ * @return HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise
+ * HICN_ERROR_NONE
+ */
+int hicn_face_ip_del (hicn_face_id_t face_id);
+
+/**
+ * @brief Format a IP face
+ *
+ * @param s Pointer to a previous string. If null it will be initialize
+ * @param args Array storing input values. Expected u32 face_id and u32 indent
+ * @return String with the formatted face
+ */
+u8 *format_hicn_face_ip (u8 * s, va_list * args);
+
+/**
+ * @brief Create a dpo from an ip face
+ *
+ * @param face Face from which to create the dpo
+ * @return the dpo
+ */
+void hicn_face_ip_get_dpo (hicn_face_t * face, dpo_id_t * dpo);
+
+#endif // __HICN_FACE_IP_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/face_ip_cli.c b/hicn-plugin/src/faces/ip/face_ip_cli.c
new file mode 100755
index 000000000..1558c82cb
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/face_ip_cli.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/vnet.h>
+#include <vnet/dpo/dpo.h>
+#include <vlib/vlib.h>
+
+#include "face_ip.h"
+#include "dpo_ip.h"
+#include "../face.h"
+
+#define HICN_FACE_NONE 0
+#define HICN_FACE_DELETE 1
+#define HICN_FACE_ADD 2
+
+static clib_error_t *
+hicn_face_ip_cli_set_command_fn (vlib_main_t * vm,
+ unformat_input_t * main_input,
+ vlib_cli_command_t * cmd)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ ip46_address_t local_addr;
+ ip46_address_t remote_addr;
+ hicn_face_id_t face_id = HICN_FACE_NULL;
+ int app_face = 0;
+ u32 cs_reserved = HICN_PARAM_FACE_DFT_CS_RESERVED;
+ int ret = HICN_ERROR_NONE;
+ int sw_if;
+ int face_op = HICN_FACE_NONE;
+
+ ip46_address_reset (&local_addr);
+ /* Get a line of input. */
+ unformat_input_t _line_input, *line_input = &_line_input;
+ if (!unformat_user (main_input, unformat_line_input, line_input))
+ {
+ return (0);
+ }
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "del"))
+ {
+ if (unformat (line_input, "id %d", &face_id))
+ face_op = HICN_FACE_DELETE;
+ else
+ {
+ return clib_error_return (0, "missing face id");
+ }
+ }
+ else if (unformat (line_input, "add"))
+ {
+ face_op = HICN_FACE_ADD;
+ if (unformat (line_input, "local %U remote %U intfc %U",
+ unformat_ip46_address, &local_addr, IP46_TYPE_ANY,
+ unformat_ip46_address, &remote_addr, IP46_TYPE_ANY,
+ unformat_vnet_sw_interface, vnm, &sw_if));
+ else
+ {
+ return clib_error_return (0, "%s '%U'",
+ get_error_string
+ (HICN_ERROR_CLI_INVAL),
+ format_unformat_error, line_input);
+ }
+ }
+ else if (unformat (line_input, "app_face %d", &app_face))
+ {
+ if (unformat (line_input, "cs_size %d", &cs_reserved));
+ }
+ else
+ {
+ return clib_error_return (0, "%s '%U'",
+ get_error_string (HICN_ERROR_CLI_INVAL),
+ format_unformat_error, line_input);
+ }
+ }
+
+ if (face_id != HICN_FACE_NULL)
+ {
+
+ if (!hicn_dpoi_idx_is_valid (face_id))
+ {
+ return clib_error_return (0, "%s, face_id %d not valid",
+ get_error_string (ret), face_id);
+ }
+ }
+
+ int rv;
+ switch (face_op)
+ {
+ case HICN_FACE_ADD:
+
+ /* Check for presence of next hop address */
+ if ((remote_addr.as_u64[0] == (u64) 0)
+ && (remote_addr.as_u64[1] == (u64) 0))
+ {
+ return clib_error_return (0, "next hop address not specified");
+ }
+
+ rv = hicn_face_ip_add (&local_addr, &remote_addr, sw_if, &face_id);
+
+ if (rv == HICN_ERROR_NONE)
+ {
+ vlib_cli_output (vm, "Face id: %d", face_id);
+ }
+ else
+ {
+ return clib_error_return (0, get_error_string (rv));
+ }
+ break;
+ case HICN_FACE_DELETE:
+ rv = hicn_face_ip_del (face_id);
+ if (rv == HICN_ERROR_NONE)
+ {
+ vlib_cli_output (vm, "Face %d deleted", face_id);
+ }
+ else
+ {
+ return clib_error_return (0, get_error_string (rv));
+ }
+ break;
+ default:
+ return clib_error_return (0, "Operation (%d) not implemented", face_op);
+ break;
+ }
+ return (rv == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n",
+ get_error_string
+ (rv));
+}
+
+/* cli declaration for 'cfg face' */
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (hicn_face_ip_cli_set_command, static) =
+{
+ .path = "hicn face ip",
+ .short_help = "hicn face ip {add local <local_address> remote <remote_address> intfc <sw_if>} {app_face <0/1>} {cs_size <size_in_packets>} | {del id <face_id>}",
+ .function = hicn_face_ip_cli_set_command_fn,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/face_ip_node.c b/hicn-plugin/src/faces/ip/face_ip_node.c
new file mode 100755
index 000000000..6081e4737
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/face_ip_node.c
@@ -0,0 +1,761 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/adj/adj.h>
+
+#include "face_ip.h"
+#include "face_ip_node.h"
+#include "dpo_ip.h"
+#include "../../strategy_dpo_manager.h"
+#include "../face.h"
+#include "../../cache_policies/cs_lru.h"
+#include "../../infra.h"
+#include "../../hicn.h"
+
+/**
+ * @File
+ *
+ * Definition of the nodes for ip incomplete faces.
+ */
+
+vlib_node_registration_t hicn_face_ip4_input_node;
+vlib_node_registration_t hicn_face_ip4_output_node;
+vlib_node_registration_t hicn_face_ip6_input_node;
+vlib_node_registration_t hicn_face_ip6_output_node;
+
+#define ip_v4 4
+#define ip_v6 6
+
+static char *hicn_face_ip4_input_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn_face_ip6_input_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_face_ip4_input_trace_t;
+
+typedef enum
+{
+ HICN_FACE_IP4_INPUT_NEXT_DATA,
+ HICN_FACE_IP4_INPUT_NEXT_MAPME,
+ HICN_FACE_IP4_INPUT_NEXT_ERROR_DROP,
+ HICN_FACE_IP4_INPUT_N_NEXT,
+} hicn_face_ip4_input_next_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_face_ip6_input_trace_t;
+
+typedef enum
+{
+ HICN_FACE_IP6_INPUT_NEXT_DATA,
+ HICN_FACE_IP6_INPUT_NEXT_MAPME,
+ HICN_FACE_IP6_INPUT_NEXT_ERROR_DROP,
+ HICN_FACE_IP6_INPUT_N_NEXT,
+} hicn_face_ip6_input_next_t;
+
+#define NEXT_MAPME_IP4 HICN_FACE_IP4_INPUT_NEXT_MAPME
+#define NEXT_MAPME_IP6 HICN_FACE_IP6_INPUT_NEXT_MAPME
+#define NEXT_DATA_IP4 HICN_FACE_IP4_INPUT_NEXT_DATA
+#define NEXT_DATA_IP6 HICN_FACE_IP6_INPUT_NEXT_DATA
+
+#define NEXT_ERROR_DROP_IP4 HICN_FACE_IP4_INPUT_NEXT_ERROR_DROP
+#define NEXT_ERROR_DROP_IP6 HICN_FACE_IP6_INPUT_NEXT_ERROR_DROP
+
+#define IP_HEADER_4 ip4_header_t
+#define IP_HEADER_6 ip6_header_t
+
+#define LOCK_FROM_LOCAL_IP4 hicn_dpo_ip4_lock_from_local
+#define LOCK_FROM_LOCAL_IP6 hicn_dpo_ip6_lock_from_local
+
+#define TRACE_INPUT_PKT_IP4 hicn_face_ip4_input_trace_t
+#define TRACE_INPUT_PKT_IP6 hicn_face_ip6_input_trace_t
+
+/*
+ * NOTE: Both hicn_face_ip4_input_node_fn and hicn_face_ip6_input_node_fn
+ * present a similar codebase. Macro are hard to debug, although the
+ * followind code is pretty straighforward and most of the complexity is in
+ * functions that can be easily debug.
+ */
+#define face_input_x1(ipv) \
+ do{ \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = NEXT_ERROR_DROP_IP##ipv; \
+ IP_HEADER_##ipv * ip_hdr = NULL; \
+ hicn_buffer_t * hicnb0; \
+ int ret; \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, 2*CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ hicnb0 = hicn_get_buffer(b0); \
+ ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
+ \
+ u8 is_icmp = ip_hdr->protocol == IPPROTO_ICMPV##ipv; \
+ \
+ next0 = is_icmp*NEXT_MAPME_IP##ipv + \
+ (1-is_icmp)*NEXT_DATA_IP##ipv; \
+ \
+ ret = LOCK_FROM_LOCAL_IP##ipv \
+ (&(hicnb0->face_dpo_id), \
+ &hicnb0->is_appface, \
+ &(ip_hdr->dst_address), \
+ vnet_buffer (b0)->sw_if_index[VLIB_RX]); \
+ \
+ if ( PREDICT_FALSE(ret != HICN_ERROR_NONE) ) \
+ next0 = NEXT_ERROR_DROP_IP##ipv; \
+ else \
+ stats.pkts_data_count += 1; \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, next0); \
+ }while(0)
+
+
+#define face_input_x2(ipv) \
+ do{ \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = NEXT_ERROR_DROP_IP##ipv; \
+ u32 next1 = NEXT_ERROR_DROP_IP##ipv; \
+ IP_HEADER_##ipv * ip_hdr0 = NULL; \
+ IP_HEADER_##ipv * ip_hdr1 = NULL; \
+ hicn_buffer_t * hicnb0; \
+ hicn_buffer_t * hicnb1; \
+ int ret0, ret1; \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, 2*CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, 2*CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ hicnb0 = hicn_get_buffer(b0); \
+ hicnb1 = hicn_get_buffer(b1); \
+ ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
+ ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b1); \
+ \
+ u8 is_icmp0 = ip_hdr0->protocol == IPPROTO_ICMPV##ipv; \
+ u8 is_icmp1 = ip_hdr1->protocol == IPPROTO_ICMPV##ipv; \
+ \
+ next0 = is_icmp0*NEXT_MAPME_IP##ipv + \
+ (1-is_icmp0)*NEXT_DATA_IP##ipv; \
+ \
+ next1 = is_icmp1*NEXT_MAPME_IP##ipv + \
+ (1-is_icmp1)*NEXT_DATA_IP##ipv; \
+ \
+ \
+ ret0 = LOCK_FROM_LOCAL_IP##ipv \
+ (&(hicnb0->face_dpo_id), \
+ &hicnb0->is_appface, \
+ &(ip_hdr0->dst_address), \
+ vnet_buffer (b0)->sw_if_index[VLIB_RX]); \
+ \
+ ret1 = LOCK_FROM_LOCAL_IP##ipv \
+ (&(hicnb1->face_dpo_id), \
+ &hicnb1->is_appface, \
+ &(ip_hdr1->dst_address), \
+ vnet_buffer (b1)->sw_if_index[VLIB_RX]); \
+ \
+ if ( PREDICT_FALSE(ret0 != HICN_ERROR_NONE) ) \
+ next0 = NEXT_ERROR_DROP_IP##ipv; \
+ else \
+ stats.pkts_data_count += 1; \
+ \
+ if ( PREDICT_FALSE(ret1 != HICN_ERROR_NONE) ) \
+ next1 = NEXT_ERROR_DROP_IP##ipv; \
+ else \
+ stats.pkts_data_count += 1; \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, bi1, next0, next1); \
+ }while(0)
+
+
+static uword
+hicn_face_ip4_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ face_input_x2 (4);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ face_input_x1 (4);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_face_ip4_input_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_ip4_input_trace_t *t =
+ va_arg (*args, hicn_face_ip4_input_trace_t *);
+
+ s = format (s, "FACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE(hicn_face_ip4_input_node) =
+{
+ .function = hicn_face_ip4_input_node_fn,
+ .name = "hicn-face-ip4-input",
+ .vector_size = sizeof(u32),
+ .format_trace = hicn_face_ip4_input_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN(hicn_face_ip4_input_error_strings),
+ .error_strings = hicn_face_ip4_input_error_strings,
+ .n_next_nodes = HICN_FACE_IP4_INPUT_N_NEXT,
+ /* edit / add dispositions here */
+ .next_nodes =
+ {
+ [HICN_FACE_IP4_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
+ [HICN_FACE_IP4_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
+ [HICN_FACE_IP4_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+/**
+ * @brief IPv6 face input node function
+ * @see hicn_face_ip4_input_node_fn
+ */
+static uword
+hicn_face_ip6_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ face_input_x2 (6);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ face_input_x1 (6);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_face_ip6_input_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_ip6_input_trace_t *t =
+ va_arg (*args, hicn_face_ip6_input_trace_t *);
+
+ s = format (s, "FACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE(hicn_face_ip6_input_node) =
+{
+ .function = hicn_face_ip6_input_node_fn,
+ .name = "hicn-face-ip6-input",
+ .vector_size = sizeof(u32),
+ .format_trace = hicn_face_ip6_input_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN(hicn_face_ip6_input_error_strings),
+ .error_strings = hicn_face_ip6_input_error_strings,
+ .n_next_nodes = HICN_FACE_IP6_INPUT_N_NEXT,
+ /* edit / add dispositions here */
+ .next_nodes =
+ {
+ [HICN_FACE_IP6_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
+ [HICN_FACE_IP6_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
+ [HICN_FACE_IP6_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+/**** FACE OUTPUT *****/
+
+static inline void
+hicn_face_rewrite_interest (vlib_main_t * vm, vlib_buffer_t * b0,
+ const hicn_face_t * face, u32 * next)
+{
+ ip_adjacency_t *adj = adj_get (face->shared.adj);
+
+ /* We assume the ip adjacency has already the MAC/link layer address */
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = face->shared.adj;
+ hicn_header_t *hicn = vlib_buffer_get_current (b0);
+
+ hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
+
+ ip46_address_t temp_addr;
+ ip46_address_reset (&temp_addr);
+ hicn_type_t type = hicn_get_buffer (b0)->type;
+ hicn_ops_vft[type.l1]->rewrite_interest (type, &hicn->protocol,
+ &ip_face->local_addr, &temp_addr);
+
+ /* We rewrite the dst address to send an arp/neighbour discovert request */
+ if (PREDICT_FALSE
+ (adj->lookup_next_index == IP_LOOKUP_NEXT_ARP
+ || adj->lookup_next_index == IP_LOOKUP_NEXT_GLEAN))
+ hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol,
+ &ip_face->remote_addr, &temp_addr,
+ 0);
+
+ *next = adj->lookup_next_index;
+}
+
+static char *hicn_face_ip4_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn_face_ip6_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_face_ip4_output_trace_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_face_ip6_output_trace_t;
+
+#define TRACE_OUTPUT_PKT_IP4 hicn_face_ip4_output_trace_t
+#define TRACE_OUTPUT_PKT_IP6 hicn_face_ip6_output_trace_t
+
+#define face_output_x1(ipv) \
+ do { \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = IP_LOOKUP_NEXT_DROP; \
+ hicn_face_t * face; \
+ \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , STORE); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ \
+ face = \
+ hicn_dpoi_get_from_idx (vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ \
+ if (PREDICT_TRUE(face != NULL)) \
+ { \
+ hicn_face_rewrite_interest \
+ (vm, b0, face, &next0); \
+ stats.pkts_interest_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, next0); \
+ }while(0)
+
+#define face_output_x2(ipv) \
+ do { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = IP_LOOKUP_NEXT_DROP; \
+ u32 next1 = IP_LOOKUP_NEXT_DROP; \
+ hicn_face_t *face0, *face1; \
+ \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , STORE); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , STORE); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ \
+ face0 = \
+ hicn_dpoi_get_from_idx (vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ face1 = \
+ hicn_dpoi_get_from_idx (vnet_buffer (b1)->ip.adj_index[VLIB_TX]); \
+ \
+ if (PREDICT_TRUE(face0 != NULL)) \
+ { \
+ hicn_face_rewrite_interest \
+ (vm, b0, face0, &next0); \
+ stats.pkts_interest_count += 1; \
+ } \
+ \
+ if (PREDICT_TRUE(face1 != NULL)) \
+ { \
+ hicn_face_rewrite_interest \
+ (vm, b1, face1, &next1); \
+ stats.pkts_interest_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, bi1, next0, next1); \
+ }while(0)
+
+
+static uword
+hicn_face_ip4_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ face_output_x2 (4);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ face_output_x1 (4);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_face_ip4_output_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_ip4_output_trace_t *t =
+ va_arg (*args, hicn_face_ip4_output_trace_t *);
+
+ s = format (s, "FACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE(hicn_face_ip4_output_node) =
+{
+ .function = hicn_face_ip4_output_node_fn,
+ .name = "hicn-face-ip4-output",
+ .vector_size = sizeof(u32),
+ .format_trace = hicn_face_ip4_output_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN(hicn_face_ip4_output_error_strings),
+ .error_strings = hicn_face_ip4_output_error_strings,
+ .n_next_nodes = IP4_LOOKUP_N_NEXT,
+ /* Reusing the list of nodes from lookup to be compatible with arp */
+ .next_nodes = IP4_LOOKUP_NEXT_NODES,
+};
+/* *INDENT-ON* */
+
+
+static uword
+hicn_face_ip6_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ face_output_x2 (6);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ face_output_x1 (6);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_face_ip6_output_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_ip6_output_trace_t *t =
+ va_arg (*args, hicn_face_ip6_output_trace_t *);
+
+ s = format (s, "FACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE(hicn_face_ip6_output_node) =
+{
+ .function = hicn_face_ip6_output_node_fn,
+ .name = "hicn-face-ip6-output",
+ .vector_size = sizeof(u32),
+ .format_trace = hicn_face_ip6_output_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN(hicn_face_ip6_output_error_strings),
+ .error_strings = hicn_face_ip6_output_error_strings,
+ .n_next_nodes = IP6_LOOKUP_N_NEXT,
+ /* Reusing the list of nodes from lookup to be compatible with neighbour discovery */
+ .next_nodes = IP6_LOOKUP_NEXT_NODES,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/face_ip_node.h b/hicn-plugin/src/faces/ip/face_ip_node.h
new file mode 100755
index 000000000..000395a04
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/face_ip_node.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_FACE_IP_NODE_H__
+#define __HICN_FACE_IP_NODE_H__
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+
+extern vlib_node_registration_t hicn_face_ip4_input_node;
+extern vlib_node_registration_t hicn_face_ip4_output_node;
+extern vlib_node_registration_t hicn_face_ip6_input_node;
+extern vlib_node_registration_t hicn_face_ip6_output_node;
+
+/**
+ * @brief Initialize the ip face module
+ */
+void hicn_face_ip_init (vlib_main_t * vm);
+
+#endif // __HICN_FACE_IP_NODE_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/iface_ip_node.c b/hicn-plugin/src/faces/ip/iface_ip_node.c
new file mode 100755
index 000000000..8df0467f0
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/iface_ip_node.c
@@ -0,0 +1,845 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hicn/hicn.h>
+#include "face_ip.h"
+#include "dpo_ip.h"
+#include "../../strategy_dpo_manager.h"
+#include "../face.h"
+#include "../../infra.h"
+#include "../../cache_policies/cs_lru.h"
+
+/**
+ * @File
+ *
+ * Definition of the nodes for ip incomplete faces.
+ */
+
+vlib_node_registration_t hicn_iface_ip4_input_node;
+vlib_node_registration_t hicn_iface_ip4_output_node;
+vlib_node_registration_t hicn_iface_ip6_input_node;
+vlib_node_registration_t hicn_iface_ip6_output_node;
+
+u32 data_fwd_iface_ip4_vlib_edge;
+u32 data_fwd_iface_ip6_vlib_edge;
+
+void
+hicn_iface_ip_init (vlib_main_t * vm)
+{
+ u32 temp_index4 = vlib_node_add_next (vm,
+ hicn_interest_hitcs_node.index,
+ hicn_iface_ip4_output_node.index);
+ u32 temp_index6 = vlib_node_add_next (vm,
+ hicn_interest_hitcs_node.index,
+ hicn_iface_ip6_output_node.index);
+
+ data_fwd_iface_ip4_vlib_edge = vlib_node_add_next (vm,
+ hicn_data_fwd_node.index,
+ hicn_iface_ip4_output_node.
+ index);
+
+ data_fwd_iface_ip6_vlib_edge = vlib_node_add_next (vm,
+ hicn_data_fwd_node.index,
+ hicn_iface_ip6_output_node.
+ index);
+
+ ASSERT (temp_index4 == data_fwd_iface_ip4_vlib_edge);
+ ASSERT (temp_index6 == data_fwd_iface_ip6_vlib_edge);
+}
+
+static char *hicn_iface_ip4_input_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn_iface_ip6_input_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_iface_ip4_input_trace_t;
+
+typedef enum
+{
+ HICN_IFACE_IP4_INPUT_NEXT_INTEREST,
+ HICN_IFACE_IP4_INPUT_NEXT_MAPME,
+ HICN_IFACE_IP4_INPUT_NEXT_ERROR_DROP,
+ HICN_IFACE_IP4_INPUT_N_NEXT,
+} hicn_iface_ip4_input_next_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_iface_ip6_input_trace_t;
+
+typedef enum
+{
+ HICN_IFACE_IP6_INPUT_NEXT_INTEREST,
+ HICN_IFACE_IP6_INPUT_NEXT_MAPME,
+ HICN_IFACE_IP6_INPUT_NEXT_ERROR_DROP,
+ HICN_IFACE_IP6_INPUT_N_NEXT,
+} hicn_iface_ip6_input_next_t;
+
+#define NEXT_MAPME_IP4 HICN_IFACE_IP4_INPUT_NEXT_MAPME
+#define NEXT_MAPME_IP6 HICN_IFACE_IP6_INPUT_NEXT_MAPME
+
+#define NEXT_INTEREST_IP4 HICN_IFACE_IP6_INPUT_NEXT_INTEREST
+#define NEXT_INTEREST_IP6 HICN_IFACE_IP6_INPUT_NEXT_INTEREST
+
+#define ADDRESS_IP4 ip_interface_address_t *ia = 0;ip4_address_t *local_address = ip4_interface_first_address(&ip4_main, swif, &ia)
+#define ADDRESS_IP6 ip6_address_t *local_address = ip6_interface_first_address(&ip6_main, swif)
+
+#define ADDRESSX2_IP4 ip_interface_address_t *ia0, *ia1; ia0 = ia1 = 0; \
+ ip4_address_t *local_address0 = ip4_interface_first_address(&ip4_main, swif0, &ia0); \
+ ip4_address_t *local_address1 = ip4_interface_first_address(&ip4_main, swif1, &ia1);
+
+#define ADDRESSX2_IP6 ip6_address_t *local_address0 = ip6_interface_first_address(&ip6_main, swif0); \
+ ip6_address_t *local_address1 = ip6_interface_first_address(&ip6_main, swif1);
+
+#define DPO_ADD_LOCK_IP4 hicn_dpo_ip4_add_and_lock_from_remote
+#define DPO_ADD_LOCK_IP6 hicn_dpo_ip6_add_and_lock_from_remote
+
+#define VLIB_EDGE_IP4 data_fwd_iface_ip4_vlib_edge
+#define VLIB_EDGE_IP6 data_fwd_iface_ip6_vlib_edge
+
+#define IP_HEADER_4 ip4_header_t
+#define IP_HEADER_6 ip6_header_t
+
+#define TRACE_INPUT_PKT_IP4 hicn_iface_ip4_input_trace_t
+#define TRACE_INPUT_PKT_IP6 hicn_iface_ip6_input_trace_t
+
+#define iface_input_x1(ipv) \
+ do { \
+ vlib_buffer_t *b0; \
+ u32 bi0, next0; \
+ IP_HEADER_##ipv * ip_hdr = NULL; \
+ hicn_buffer_t * hicnb0; \
+ u32 swif; \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, 2*CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ hicnb0 = hicn_get_buffer(b0); \
+ ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
+ \
+ stats.pkts_interest_count += 1; \
+ \
+ u8 is_icmp = ip_hdr->protocol == IPPROTO_ICMPV##ipv; \
+ \
+ next0 = is_icmp*NEXT_MAPME_IP##ipv + \
+ (1-is_icmp)*NEXT_INTEREST_IP##ipv; \
+ \
+ swif = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ \
+ ADDRESS_IP##ipv; \
+ \
+ DPO_ADD_LOCK_IP##ipv \
+ (&(hicnb0->face_dpo_id), \
+ &hicnb0->is_appface, \
+ local_address, \
+ &(ip_hdr->src_address), \
+ vnet_buffer(b0)->sw_if_index[VLIB_RX], \
+ VLIB_EDGE_IP##ipv); \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, next0); \
+ }while(0)
+
+
+#define iface_input_x2(ipv) \
+ do { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1, next0, next1; \
+ IP_HEADER_##ipv * ip_hdr0 = NULL; \
+ IP_HEADER_##ipv * ip_hdr1 = NULL; \
+ hicn_buffer_t *hicnb0, *hicnb1; \
+ u32 swif0, swif1; \
+ \
+ /* Prefetch for next iteration. */ \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, 2*CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, 2*CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ hicnb0 = hicn_get_buffer(b0); \
+ hicnb1 = hicn_get_buffer(b1); \
+ ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
+ ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b1); \
+ \
+ stats.pkts_interest_count += 2; \
+ \
+ u8 is_icmp0 = ip_hdr0->protocol == IPPROTO_ICMPV##ipv; \
+ u8 is_icmp1 = ip_hdr1->protocol == IPPROTO_ICMPV##ipv; \
+ \
+ next0 = is_icmp0*NEXT_MAPME_IP##ipv + \
+ (1-is_icmp0)*NEXT_INTEREST_IP##ipv; \
+ \
+ next1 = is_icmp1*NEXT_MAPME_IP##ipv + \
+ (1-is_icmp1)*NEXT_INTEREST_IP##ipv; \
+ \
+ swif0 = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ swif1 = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ \
+ ADDRESSX2_IP##ipv; \
+ \
+ DPO_ADD_LOCK_IP##ipv \
+ (&(hicnb0->face_dpo_id), \
+ &hicnb0->is_appface, \
+ local_address0, \
+ &(ip_hdr0->src_address), \
+ vnet_buffer(b0)->sw_if_index[VLIB_RX], \
+ VLIB_EDGE_IP##ipv); \
+ \
+ DPO_ADD_LOCK_IP##ipv \
+ (&(hicnb1->face_dpo_id), \
+ &hicnb1->is_appface, \
+ local_address1, \
+ &(ip_hdr1->src_address), \
+ vnet_buffer(b1)->sw_if_index[VLIB_RX], \
+ VLIB_EDGE_IP##ipv); \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ } \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, bi1, next0, next1); \
+ }while(0)
+
+static uword
+hicn_iface_ip4_input_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ iface_input_x2 (4);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ iface_input_x1 (4);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_iface_ip4_input_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_iface_ip4_input_trace_t *t =
+ va_arg (*args, hicn_iface_ip4_input_trace_t *);
+
+ s = format (s, "IFACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_iface_ip4_input_node) =
+{
+ .function = hicn_iface_ip4_input_node_fn,
+ .name = "hicn-iface-ip4-input",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_iface_ip4_input_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_iface_ip4_input_error_strings),
+ .error_strings = hicn_iface_ip4_input_error_strings,
+ .n_next_nodes = HICN_IFACE_IP4_INPUT_N_NEXT,
+ /* edit / add dispositions*/
+ .next_nodes =
+ {
+ [HICN_IFACE_IP4_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
+ [HICN_IFACE_IP4_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
+ [HICN_IFACE_IP4_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+static uword
+hicn_iface_ip6_input_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ iface_input_x2 (6);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ iface_input_x1 (6);
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_iface_ip6_input_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_iface_ip6_input_trace_t *t =
+ va_arg (*args, hicn_iface_ip6_input_trace_t *);
+
+ s = format (s, "IFACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_iface_ip6_input_node) =
+{
+ .function = hicn_iface_ip6_input_node_fn,
+ .name = "hicn-iface-ip6-input",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_iface_ip6_input_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_iface_ip6_input_error_strings),
+ .error_strings = hicn_iface_ip6_input_error_strings,
+ .n_next_nodes = HICN_IFACE_IP6_INPUT_N_NEXT,
+ /* edit / add dispositions*/
+ .next_nodes =
+ {
+ [HICN_IFACE_IP6_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
+ [HICN_IFACE_IP6_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
+ [HICN_IFACE_IP6_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+
+/**** IFACE OUTPUT *****/
+
+static inline void
+hicn_rewrite_iface_data4 (vlib_main_t * vm, vlib_buffer_t * b0,
+ const hicn_face_t * iface)
+{
+ ip4_header_t *ip0;
+
+ /* Get the pointer to the old ip and tcp header */
+ ip0 = vlib_buffer_get_current (b0);
+
+ /* Set up the ip6 header */
+ /* IP4 lenght contains the size of the ip4 header too */
+ u16 sval = (vlib_buffer_length_in_chain (vm, b0));
+ ip0->length = clib_host_to_net_u16 (sval);
+ ip0->ttl = 254; // FIXME TTL
+
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = ~0;
+ hicn_header_t *hicn = vlib_buffer_get_current (b0);
+
+ ip46_address_t temp_addr;
+ ip46_address_reset (&temp_addr);
+ hicn_face_ip_t *iface_ip = (hicn_face_ip_t *) iface->data;
+ hicn_type_t type = hicn_get_buffer (b0)->type;
+ hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol,
+ &(iface_ip->remote_addr), &(temp_addr),
+ iface->shared.pl_id);
+}
+
+static inline void
+hicn_rewrite_iface_data6 (vlib_main_t * vm, vlib_buffer_t * b0,
+ const hicn_face_t * iface)
+{
+ ip6_header_t *ip0;
+
+ /* Get the pointer to the old ip and tcp header */
+ /* Copy the previous ip and tcp header to the new portion of memory */
+ ip0 = vlib_buffer_get_current (b0);
+
+ /* Set up the ip6 header */
+ /* IP6 lenght does not include the size of the ip6 header */
+ u16 sval = (vlib_buffer_length_in_chain (vm, b0) - (sizeof (ip6_header_t)));
+ ip0->payload_length = clib_host_to_net_u16 (sval);
+ ip0->hop_limit = HICN_IP6_HOP_LIMIT;
+
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = ~0;
+ hicn_header_t *hicn = vlib_buffer_get_current (b0);
+
+ ip46_address_t temp_addr;
+ ip46_address_reset (&temp_addr);
+ hicn_face_ip_t *iface_ip = (hicn_face_ip_t *) iface->data;
+ hicn_type_t type = hicn_get_buffer (b0)->type;
+ hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol,
+ &(iface_ip->remote_addr), &(temp_addr),
+ iface->shared.pl_id);
+}
+
+static char *hicn_iface_ip4_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn_iface_ip6_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_iface_ip4_output_trace_t;
+
+typedef enum
+{
+ HICN_IFACE_IP4_OUTPUT_NEXT_LOOKUP,
+ HICN_IFACE_IP4_OUTPUT_NEXT_ERROR_DROP,
+ HICN_IFACE_IP4_OUTPUT_N_NEXT,
+} hicn_iface_ip4_output_next_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_iface_ip6_output_trace_t;
+
+typedef enum
+{
+ HICN_IFACE_IP6_OUTPUT_NEXT_LOOKUP,
+ HICN_IFACE_IP6_OUTPUT_NEXT_ERROR_DROP,
+ HICN_IFACE_IP6_OUTPUT_N_NEXT,
+} hicn_iface_ip6_output_next_t;
+
+#define ERROR_OUTPUT_IP4 HICN_IFACE_IP4_OUTPUT_NEXT_ERROR_DROP
+#define ERROR_OUTPUT_IP6 HICN_IFACE_IP6_OUTPUT_NEXT_ERROR_DROP
+
+#define NEXT_DATA_LOOKUP_IP4 HICN_IFACE_IP4_OUTPUT_NEXT_LOOKUP
+#define NEXT_DATA_LOOKUP_IP6 HICN_IFACE_IP6_OUTPUT_NEXT_LOOKUP
+
+#define HICN_REWRITE_DATA_IP4 hicn_rewrite_iface_data4
+#define HICN_REWRITE_DATA_IP6 hicn_rewrite_iface_data6
+
+#define TRACE_OUTPUT_PKT_IP4 hicn_iface_ip4_output_trace_t
+#define TRACE_OUTPUT_PKT_IP6 hicn_iface_ip6_output_trace_t
+
+#define iface_output_x1(ipv) \
+ do { \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = ERROR_OUTPUT_IP##ipv; \
+ hicn_face_t * face; \
+ \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , STORE); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ \
+ face = \
+ hicn_dpoi_get_from_idx (vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ \
+ if (PREDICT_TRUE(face != NULL)) \
+ { \
+ HICN_REWRITE_DATA_IP##ipv \
+ (vm, b0, face); \
+ next0 = NEXT_DATA_LOOKUP_IP##ipv; \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, next0); \
+ }while(0); \
+
+
+#define iface_output_x2(ipv) \
+ do { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = ERROR_OUTPUT_IP##ipv; \
+ u32 next1 = ERROR_OUTPUT_IP##ipv; \
+ hicn_face_t *face0, *face1; \
+ \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , STORE); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , STORE); \
+ } \
+ \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ \
+ face0 = \
+ hicn_dpoi_get_from_idx (vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ face1 = \
+ hicn_dpoi_get_from_idx (vnet_buffer (b1)->ip.adj_index[VLIB_TX]); \
+ \
+ if (PREDICT_TRUE(face0 != NULL)) \
+ { \
+ HICN_REWRITE_DATA_IP##ipv \
+ (vm, b0, face0); \
+ next0 = NEXT_DATA_LOOKUP_IP##ipv; \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_TRUE(face1 != NULL)) \
+ { \
+ HICN_REWRITE_DATA_IP##ipv \
+ (vm, b1, face1); \
+ next1 = NEXT_DATA_LOOKUP_IP##ipv; \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, bi1, next0, next1); \
+ }while(0); \
+
+
+
+static uword
+hicn_iface_ip4_output_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ iface_output_x2 (4);
+ }
+
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ iface_output_x1 (4);
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_iface_ip4_output_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_iface_ip4_output_trace_t *t =
+ va_arg (*args, hicn_iface_ip4_output_trace_t *);
+
+ s = format (s, "IFACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_iface_ip4_output_node) =
+{
+ .function = hicn_iface_ip4_output_node_fn,
+ .name = "hicn-iface-ip4-output",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_iface_ip4_output_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_iface_ip4_output_error_strings),
+ .error_strings = hicn_iface_ip4_output_error_strings,
+ .n_next_nodes = HICN_IFACE_IP4_OUTPUT_N_NEXT,
+ /* edit / add dispositions here */
+ .next_nodes =
+ {
+ [HICN_IFACE_IP4_OUTPUT_NEXT_LOOKUP] = "ip4-lookup",
+ [HICN_IFACE_IP4_OUTPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+
+static uword
+hicn_iface_ip6_output_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ iface_output_x2 (6);
+ }
+
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ iface_output_x1 (6);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_iface_ip6_output_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_iface_ip6_output_trace_t *t =
+ va_arg (*args, hicn_iface_ip6_output_trace_t *);
+
+ s = format (s, "IFACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_iface_ip6_output_node) =
+{
+ .function = hicn_iface_ip6_output_node_fn,
+ .name = "hicn-iface-ip6-output",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_iface_ip6_output_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_iface_ip6_output_error_strings),
+ .error_strings = hicn_iface_ip6_output_error_strings,
+ .n_next_nodes = HICN_IFACE_IP6_OUTPUT_N_NEXT,
+ /* edit / add dispositions here */
+ .next_nodes =
+ {
+ [HICN_IFACE_IP6_OUTPUT_NEXT_LOOKUP] = "ip6-lookup",
+ [HICN_IFACE_IP6_OUTPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/ip/iface_ip_node.h b/hicn-plugin/src/faces/ip/iface_ip_node.h
new file mode 100755
index 000000000..36923f069
--- /dev/null
+++ b/hicn-plugin/src/faces/ip/iface_ip_node.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_IFACE_IP_NODE_H__
+#define __HICN_IFACE_IP_NODE_H__
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+
+/**
+ * @brief Initialize the ip iface module
+ */
+void hicn_iface_ip_init (vlib_main_t * vm);
+
+#endif // __HICN_IFACE_IP_NODE_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/dpo_udp.c b/hicn-plugin/src/faces/udp/dpo_udp.c
new file mode 100755
index 000000000..e58fc9788
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/dpo_udp.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dpo_udp.h"
+
+#include <vnet/ip/format.h>
+#include <vnet/adj/adj.h>
+#include <vnet/vnet.h>
+#include <vlib/vlib.h>
+
+const static char *const hicn_face_ip4udp_nodes[] = {
+ "hicn-face-encap-udp4",
+ "hicn-face-decap-udp4",
+ "hicn-iface-decap-udp4",
+ "hicn-iface-encap-udp4",
+ NULL,
+};
+
+const static char *const hicn_face_ip6udp_nodes[] = {
+ "hicn-face-encap-udp6",
+ "hicn-face-decap-udp6",
+ "hicn-iface-decap-udp6",
+ "hicn-iface-encap-udp6",
+ NULL,
+};
+
+const static char *const *const hicn_ipudp_nodes[DPO_PROTO_NUM] = {
+ [DPO_PROTO_IP4] = hicn_face_ip4udp_nodes,
+ [DPO_PROTO_IP6] = hicn_face_ip6udp_nodes
+};
+
+
+const static dpo_vft_t hicn_dpoi_udp_vft = {
+ .dv_lock = hicn_face_lock,
+ .dv_unlock = hicn_face_unlock,
+ .dv_format = format_hicn_face_udp,
+};
+
+/* Must be executed after all the strategy nodes are created */
+void
+hicn_dpo_udp_module_init (void)
+{
+ mhash_init (&hicn_face_udp_hashtb, sizeof (hicn_face_id_t) /* value */ ,
+ sizeof (hicn_face_udp_key_t) /* key */ );
+
+ /*
+ * How much useful is the following registration?
+ * So far it seems that we need it only for setting the dpo_type.
+ */
+ hicn_face_udp_type =
+ dpo_register_new_type (&hicn_dpoi_udp_vft, hicn_ipudp_nodes);
+}
+
+
+/* Here udp ports are in host order, move them to network order to do the lookup */
+int
+hicn_dpo_udp4_create (dpo_id_t * dpo,
+ const ip4_address_t * src_ip,
+ const ip4_address_t * dst_ip,
+ u16 src_port, u16 dst_port,
+ u32 sw_if,
+ adj_index_t ip_adj,
+ u32 node_index,
+ hicn_face_flags_t flags, hicn_face_id_t * face_id)
+{
+ u16 net_src_port = clib_host_to_net_u16 (src_port);
+ u16 net_dst_port = clib_host_to_net_u16 (dst_port);
+ hicn_face_t *face = hicn_face_udp4_get (src_ip, dst_ip, src_port, dst_port);
+
+ u8 is_appface;
+ /* ip_csum_t sum0; */
+
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ hicn_dpo_udp4_add_and_lock (dpo, src_ip, dst_ip, net_src_port, net_dst_port,
+ node_index, &is_appface);
+
+ face = hicn_dpoi_get_from_idx (dpo->dpoi_index);
+
+ hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data;
+
+ udp_face->hdrs.ip4.ip.checksum =
+ ip4_header_checksum (&(udp_face->hdrs.ip4.ip));
+
+ face->shared.flags = flags;
+ face->shared.adj = ip_adj;
+ face->shared.sw_if = sw_if;
+ *face_id = hicn_dpoi_get_index (face);
+
+ return HICN_ERROR_NONE;
+}
+
+
+int
+hicn_dpo_udp6_create (dpo_id_t * dpo,
+ const ip6_address_t * src_ip,
+ const ip6_address_t * dst_ip,
+ u16 src_port, u16 dst_port,
+ u32 sw_if,
+ adj_index_t ip_adj,
+ u32 node_index,
+ hicn_face_flags_t flags, hicn_face_id_t * face_id)
+{
+ u16 net_src_port = clib_host_to_net_u16 (src_port);
+ u16 net_dst_port = clib_host_to_net_u16 (dst_port);
+ hicn_face_t *face =
+ hicn_face_udp6_get (src_ip, dst_ip, net_src_port, net_dst_port);
+ u8 is_appface;
+
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ hicn_dpo_udp6_add_and_lock (dpo, src_ip, dst_ip, net_src_port, net_dst_port,
+ node_index, &is_appface);
+
+ face = hicn_dpoi_get_from_idx (dpo->dpoi_index);
+
+ face->shared.flags = flags;
+ face->shared.adj = ip_adj;
+ face->shared.sw_if = sw_if;
+ *face_id = hicn_dpoi_get_index (face);
+
+ return HICN_ERROR_NONE;
+}
+
+void
+hicn_dpo_udp_create_from_face (hicn_face_t * face, dpo_id_t * dpo,
+ u16 dpoi_next_node)
+{
+ hicn_face_id_t face_dpoi_id = hicn_dpoi_get_index (face);
+ hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
+ u8 version =
+ (face_udp->hdrs.ip4.ip.ip_version_and_header_length & 0xf0) >> 4;
+ dpo_set (dpo, face->shared.face_type,
+ version == 4 ? DPO_PROTO_IP4 : DPO_PROTO_IP6, face_dpoi_id);
+ dpo->dpoi_next_node = dpoi_next_node;
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/dpo_udp.h b/hicn-plugin/src/faces/udp/dpo_udp.h
new file mode 100755
index 000000000..fdde4192b
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/dpo_udp.h
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_DPO_UDP_H__
+#define __HICN_DPO_UDP_H__
+
+#include <vnet/adj/adj_types.h>
+#include <vnet/ip/ip4_packet.h>
+#include <vnet/ip/ip6_packet.h>
+
+#include "face_udp.h"
+#include "../face.h"
+#include "../../error.h"
+
+
+/**
+ * @brief Initialize the internal structures of the dpo udp face module.
+ */
+void hicn_dpo_udp_module_init (void);
+
+/**
+ * @brief Create a udp face and its corresponding dpo. Meant to be used for the
+ * control plane.
+ *
+ * @param dpo: Data plane object that point to the face created.
+ * @param local_addr: Local address of the UDP tunnel
+ * @param remote_addr: Remote address of the UDP tunnel
+ * @param local_port: Local port of the UDP tunnel
+ * @param remote_port: Remote port of the UDP tunnel
+ * @param adj: Ip adjacency corresponding to the remote address in the face
+ * @param node_index: vlib edge index to use in the packet processing
+ * @param flags: Flags of the face
+ * @param face_id: Identifier for the face (dpoi_index)
+ * @return HICN_ERROR_FACE_ALREADY_CREATED if the face exists, otherwise HICN_ERROR_NONE
+ */
+int
+hicn_dpo_udp4_create (dpo_id_t * dpo,
+ const ip4_address_t * local_addr,
+ const ip4_address_t * remote_addr,
+ u16 local_port, u16 remote_port,
+ u32 sw_if,
+ adj_index_t adj,
+ u32 node_index,
+ hicn_face_flags_t flags, hicn_face_id_t * face_id);
+
+/**
+ * @brief Retrieve a face using the face identifier, i.e., the quadruplet (local_addr, remote_addr,
+ * local_port, remote_port). This method adds a lock on the face state.
+ *
+ * @param dpo: Result of the lookup. If the face doesn't exist dpo = NULL
+ * @param local_addr: Local address of the UDP tunnel
+ * @param remote_addr: Remote address of the UDP tunnel
+ * @param local_port: Local port of the UDP tunnel
+ * @param remote_port: Remote port of the UDP tunnel
+ * @param is_appface: Boolean that indicates whether the face is an application
+ * face or not. (Currently only IP faces can be appface)
+ *
+ * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.
+ */
+always_inline int
+hicn_dpo_udp4_lock (dpo_id_t * dpo,
+ const ip4_address_t * local_addr,
+ const ip4_address_t * remote_addr,
+ u16 local_port, u16 remote_port, u8 * is_appface)
+{
+ hicn_face_t *face =
+ hicn_face_udp4_get (local_addr, remote_addr, local_port, remote_port);
+
+ if (PREDICT_FALSE (face == NULL))
+ return HICN_ERROR_FACE_NOT_FOUND;
+
+ index_t dpoi_index = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index);
+ dpo->dpoi_next_node = ~0;
+ dpo_lock (dpo);
+
+ *is_appface = 0;
+
+ return HICN_ERROR_NONE;
+}
+
+/**
+ * @brief Retrieve, or create if it doesn't exist, a face from the face
+ * identifier (local_addr, remote_addr, local_port, remote_port) and returns its
+ * dpo. This method adds a lock on the face state.
+ *
+ * @param dpo: Result of the lookup
+ * @param local_addr: Local address of the UDP tunnel
+ * @param remote_addr: Remote address of the UDP tunnel
+ * @param local_port: Local port of the UDP tunnel
+ * @param remote_port: Remote port of the UDP tunnel
+ * @param is_appface: Boolean that indicates whether the face is an application
+ * face or not. (Currently only IP faces can be appface)
+ * @param node_index: vlib edge index to use in the packet processing
+ */
+always_inline void
+hicn_dpo_udp4_add_and_lock (dpo_id_t * dpo,
+ const ip4_address_t * local_addr,
+ const ip4_address_t * remote_addr,
+ u16 local_port, u16 remote_port,
+ u32 node_index, u8 * is_appface)
+{
+ hicn_face_t *face =
+ hicn_face_udp4_get (local_addr, remote_addr, local_port, remote_port);
+
+ if (face == NULL)
+ {
+ pool_get (hicn_dpoi_face_pool, face);
+
+ hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data;
+
+ clib_memcpy (&(udp_face->hdrs.ip4.ip), &ip4_header_skl,
+ sizeof (ip4_header_t));
+ clib_memcpy (&(udp_face->hdrs.ip4.ip.src_address), local_addr,
+ sizeof (ip4_address_t));
+ clib_memcpy (&(udp_face->hdrs.ip4.ip.dst_address), remote_addr,
+ sizeof (ip4_address_t));
+
+ udp_face->hdrs.ip4.udp.src_port = local_port;
+ udp_face->hdrs.ip4.udp.dst_port = remote_port;
+
+ face->shared.adj = ADJ_INDEX_INVALID;
+ face->shared.pl_id = (u16) 0;
+ face->shared.face_type = hicn_face_udp_type;
+ face->shared.flags = HICN_FACE_FLAGS_IFACE;
+ face->shared.locks = 0;
+
+ hicn_face_udp_key_t key;
+ hicn_face_udp4_get_key (local_addr, remote_addr, local_port,
+ remote_port, &key);
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+
+ mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 0);
+ face = face;
+
+ *is_appface = 0;
+ dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index);
+ dpo->dpoi_next_node = node_index;
+ dpo_lock (dpo);
+
+ return;
+ }
+
+ *is_appface = 0;
+
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index);
+ dpo->dpoi_next_node = node_index;
+ dpo_lock (dpo);
+}
+
+/**
+ * @brief Create a udp face and its corresponding dpo. Meant to be used for the
+ * control plane.
+ *
+ * @param dpo: Data plane object that point to the face created.
+ * @param local_addr: Local address of the UDP tunnel
+ * @param remote_addr: Remote address of the UDP tunnel
+ * @param local_port: Local port of the UDP tunnel
+ * @param remote_port: Remote port of the UDP tunnel
+ * @param adj: Ip adjacency corresponding to the remote address in the face
+ * @param node_index: vlib edge index to use in the packet processing
+ * @param flags: Flags of the face
+ * @param face_id: Identifier for the face (dpoi_index)
+ * @return HICN_ERROR_FACE_ALREADY_CREATED if the face exists, otherwise HICN_ERROR_NONE
+ */
+int
+hicn_dpo_udp6_create (dpo_id_t * dpo,
+ const ip6_address_t * local_addr,
+ const ip6_address_t * remote_addr,
+ u16 local_port, u16 remote_port,
+ u32 sw_if,
+ adj_index_t adj,
+ u32 node_index,
+ hicn_face_flags_t flags, hicn_face_id_t * face_id);
+
+
+/**
+ * @brief Retrieve a face using the face identifier, i.e., the quadruplet (local_addr, remote_addr,
+ * local_port, remote_port). This method adds a lock on the face state.
+ *
+ * @param dpo: Result of the lookup. If the face doesn't exist dpo = NULL
+ * @param local_addr: Local address of the UDP tunnel
+ * @param remote_addr: Remote address of the UDP tunnel
+ * @param local_port: Local port of the UDP tunnel
+ * @param remote_port: Remote port of the UDP tunnel
+ * @param is_appface: Boolean that indicates whether the face is an application
+ * face or not. (Currently only IP faces can be appface)
+ *
+ * @result HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise HICN_ERROR_NONE.
+ */
+always_inline int
+hicn_dpo_udp6_lock (dpo_id_t * dpo,
+ const ip6_address_t * local_addr,
+ const ip6_address_t * remote_addr,
+ u16 local_port, u16 remote_port, u8 * is_appface)
+{
+ hicn_face_t *face =
+ hicn_face_udp6_get (local_addr, remote_addr, local_port, remote_port);
+
+
+ if (PREDICT_FALSE (face == NULL))
+ return HICN_ERROR_FACE_NOT_FOUND;
+
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index);
+ dpo->dpoi_next_node = ~0;
+ dpo_lock (dpo);
+ *is_appface = 0;
+
+ return HICN_ERROR_NONE;
+}
+
+/**
+ * @brief Retrieve, or create if it doesn't exist, a face from the face
+ * identifier (local_addr, remote_addr, local_port, remote_port) and returns its
+ * dpo. This method adds a lock on the face state.
+ *
+ * @param dpo: Result of the lookup
+ * @param local_addr: Local address of the UDP tunnel
+ * @param remote_addr: Remote address of the UDP tunnel
+ * @param local_port: Local port of the UDP tunnel
+ * @param remote_port: Remote port of the UDP tunnel
+ * @param is_appface: Boolean that indicates whether the face is an application
+ * face or not. (Currently only IP faces can be appface)
+ * @param node_index: vlib edge index to use in the packet processing
+ */
+always_inline void
+hicn_dpo_udp6_add_and_lock (dpo_id_t * dpo,
+ const ip6_address_t * local_addr,
+ const ip6_address_t * remote_addr,
+ u16 local_port, u16 remote_port,
+ u32 node_index, u8 * is_appface)
+{
+ hicn_face_t *face =
+ hicn_face_udp6_get (local_addr, remote_addr, local_port, remote_port);
+
+ if (face == NULL)
+ {
+ pool_get (hicn_dpoi_face_pool, face);
+
+ hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data;
+
+ clib_memcpy (&(udp_face->hdrs.ip6.ip), &ip6_header_skl,
+ sizeof (ip6_header_t));
+ clib_memcpy (&(udp_face->hdrs.ip6.ip.src_address), local_addr,
+ sizeof (ip6_address_t));
+ clib_memcpy (&(udp_face->hdrs.ip6.ip.dst_address), remote_addr,
+ sizeof (ip6_address_t));
+
+ udp_face->hdrs.ip6.udp.src_port = local_port;
+ udp_face->hdrs.ip6.udp.dst_port = remote_port;
+
+ face->shared.adj = ADJ_INDEX_INVALID;
+ face->shared.pl_id = (u16) 0;
+ face->shared.face_type = hicn_face_udp_type;
+ face->shared.flags = HICN_FACE_FLAGS_IFACE;
+ face->shared.locks = 0;
+
+ hicn_face_udp_key_t key;
+ hicn_face_udp6_get_key (local_addr, remote_addr, local_port,
+ remote_port, &key);
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+
+ mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 0);
+
+ *is_appface = 0;
+ dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP6, dpoi_index);
+ dpo->dpoi_next_node = node_index;
+ dpo_lock (dpo);
+
+ return;
+ }
+
+ *is_appface = 0;
+
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+ dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP6, dpoi_index);
+ dpo->dpoi_next_node = node_index;
+ dpo_lock (dpo);
+}
+
+/**
+ * @brief Create a dpo from a udp face
+ *
+ * @param face Face from which to create the dpo
+ * @return the dpo
+ */
+void hicn_dpo_udp_create_from_face (hicn_face_t * face, dpo_id_t * dpo,
+ u16 dpoi_next_node);
+
+#endif // __HICN_DPO_UDP_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/face_udp.c b/hicn-plugin/src/faces/udp/face_udp.c
new file mode 100755
index 000000000..92335273a
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/face_udp.c
@@ -0,0 +1,371 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+
+#include "face_udp.h"
+#include "face_udp_node.h"
+#include "dpo_udp.h"
+#include "../face.h"
+#include "../../strategy.h"
+#include "../../strategy_dpo_manager.h"
+#include "../../hicn.h"
+
+#include "../../mapme.h" // HICN_MAPME_EVENT_*
+#include "../../mapme_eventmgr.h" // hicn_mapme_eventmgr_process_node
+extern vlib_node_registration_t hicn_mapme_eventmgr_process_node;
+
+mhash_t hicn_face_udp_hashtb;
+
+dpo_type_t hicn_face_udp_type;
+
+ip4_header_t ip4_header_skl = {
+ .ip_version_and_header_length = 0x45,
+ .tos = 0x00,
+ .length = (u16) 0,
+ .fragment_id = (u16) 0,
+ .flags_and_fragment_offset = (u16) 0,
+ .ttl = 254,
+ .protocol = IP_PROTOCOL_UDP,
+ .checksum = 0,
+ .src_address = {{0}},
+ .dst_address = {{0}},
+};
+
+ip6_header_t ip6_header_skl = {
+#if CLIB_ARCH_IS_BIG_ENDIAN
+ .ip_version_traffic_class_and_flow_label = 0x60000000,
+#else
+ .ip_version_traffic_class_and_flow_label = 0x00000060,
+#endif
+ .payload_length = (u16) 0,
+ .protocol = IP_PROTOCOL_UDP,
+ .hop_limit = 254,
+ .src_address = {{0}},
+ .dst_address = {{0}}
+};
+
+u32 strategy_face_udp4_vlib_edge;
+u32 strategy_face_udp6_vlib_edge;
+
+/* Separated from the hicn_face_udp_init because it cannot be called by the
+ init macro due to dependencies with other modules not yet initialied */
+void
+hicn_face_udp_init_internal ()
+{
+ ip4_header_t *ip4_hdr = &ip4_header_skl;
+ ip4_header_skl.checksum = ip4_header_checksum (ip4_hdr);
+}
+
+void
+hicn_face_udp_init (vlib_main_t * vm)
+{
+ int strategy_nodes_n = hicn_strategy_get_all_available ();
+
+ /* Default Strategy has index 0 and it always exists */
+ strategy_face_udp4_vlib_edge = vlib_node_add_next (vm,
+ hicn_dpo_get_strategy_vft
+ (default_dpo.
+ hicn_dpo_get_type ())->
+ get_strategy_node_index
+ (),
+ hicn_face_udp4_output_node.
+ index);
+ strategy_face_udp6_vlib_edge =
+ vlib_node_add_next (vm,
+ hicn_dpo_get_strategy_vft (default_dpo.
+ hicn_dpo_get_type ())->
+ get_strategy_node_index (),
+ hicn_face_udp6_output_node.index);
+
+ /*
+ * Create and edge between al the other strategy nodes
+ * and the udp_output nodes.
+ */
+ for (int i = 1; i < strategy_nodes_n; i++)
+ {
+ u32 temp_index4 = vlib_node_add_next (vm,
+ hicn_dpo_get_strategy_vft_from_id
+ (i)->get_strategy_node_index (),
+ hicn_face_udp4_output_node.index);
+ u32 temp_index6 = vlib_node_add_next (vm,
+ hicn_dpo_get_strategy_vft_from_id
+ (i)->get_strategy_node_index (),
+ hicn_face_udp6_output_node.index);
+ ASSERT (temp_index4 == strategy_face_udp4_vlib_edge);
+ ASSERT (temp_index6 == strategy_face_udp6_vlib_edge);
+ }
+
+ hicn_dpo_udp_module_init ();
+
+ register_face_type (hicn_face_udp_type, &udp_vft, "udp");;
+}
+
+int
+hicn_face_udp_add (const ip46_address_t * local_addr,
+ const ip46_address_t * remote_addr, u16 local_port,
+ u16 remote_port, u32 swif, hicn_face_id_t * pfaceid)
+{
+ fib_protocol_t fib_type;
+ vnet_link_t link_type;
+ adj_index_t ip_adj;
+ int ret = HICN_ERROR_NONE;
+ dpo_proto_t dpo_proto;
+
+ hicn_face_flags_t flags = (hicn_face_flags_t) 0;
+ flags |= HICN_FACE_FLAGS_FACE;
+
+
+ if (ip46_address_is_ip4 (local_addr) && ip46_address_is_ip4 (remote_addr))
+ {
+ link_type = VNET_LINK_IP4;
+ fib_type = FIB_PROTOCOL_IP4;
+ ip_adj = adj_nbr_add_or_lock (fib_type, link_type, remote_addr, swif);
+
+ hicn_face_t *face =
+ hicn_face_udp4_get (&local_addr->ip4, &remote_addr->ip4, local_port,
+ remote_port);
+
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ pool_get (hicn_dpoi_face_pool, face);
+
+ hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data;
+
+ clib_memcpy (&(udp_face->hdrs.ip4.ip), &ip4_header_skl,
+ sizeof (ip4_header_t));
+ clib_memcpy (&(udp_face->hdrs.ip4.ip.src_address), &(local_addr->ip4),
+ sizeof (ip4_address_t));
+ clib_memcpy (&(udp_face->hdrs.ip4.ip.dst_address), &(remote_addr->ip4),
+ sizeof (ip4_address_t));
+
+ udp_face->hdrs.ip4.udp.src_port = local_port;
+ udp_face->hdrs.ip4.udp.dst_port = remote_port;
+
+ ip_csum_t csum = udp_face->hdrs.ip4.ip.checksum;
+ csum = ip_csum_sub_even (csum, ip4_header_skl.src_address.as_u32);
+ csum = ip_csum_sub_even (csum, ip4_header_skl.dst_address.as_u32);
+ csum =
+ ip_csum_add_even (csum, udp_face->hdrs.ip4.ip.src_address.as_u32);
+ csum =
+ ip_csum_add_even (csum, udp_face->hdrs.ip4.ip.dst_address.as_u32);
+ udp_face->hdrs.ip4.ip.checksum = ip_csum_fold (csum);
+
+ face->shared.adj = ip_adj;
+ face->shared.sw_if = swif;
+ face->shared.pl_id = (u16) 0;
+ face->shared.face_type = hicn_face_udp_type;
+ face->shared.flags = flags;
+ face->shared.locks = 0;
+
+ hicn_face_udp_key_t key;
+ hicn_face_udp4_get_key (&local_addr->ip4, &remote_addr->ip4, local_port,
+ remote_port, &key);
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+
+ mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 0);
+
+ *pfaceid = hicn_dpoi_get_index (face);
+ dpo_proto = DPO_PROTO_IP4;
+ }
+ else if (!ip46_address_is_ip4 (local_addr)
+ && !ip46_address_is_ip4 (remote_addr))
+ {
+ link_type = VNET_LINK_IP6;
+ fib_type = FIB_PROTOCOL_IP6;
+ ip_adj = adj_nbr_add_or_lock (fib_type, link_type, remote_addr, swif);
+
+ hicn_face_t *face =
+ hicn_face_udp6_get (&local_addr->ip6, &remote_addr->ip6, local_port,
+ remote_port);
+
+ if (face != NULL)
+ return HICN_ERROR_FACE_ALREADY_CREATED;
+
+ pool_get (hicn_dpoi_face_pool, face);
+
+ hicn_face_udp_t *udp_face = (hicn_face_udp_t *) face->data;
+
+ clib_memcpy (&(udp_face->hdrs.ip6.ip), &ip6_header_skl,
+ sizeof (ip6_header_t));
+ clib_memcpy (&(udp_face->hdrs.ip6.ip.src_address), local_addr,
+ sizeof (ip6_address_t));
+ clib_memcpy (&(udp_face->hdrs.ip6.ip.dst_address), remote_addr,
+ sizeof (ip6_address_t));
+
+ udp_face->hdrs.ip6.udp.src_port = local_port;
+ udp_face->hdrs.ip6.udp.dst_port = remote_port;
+
+ face->shared.adj = ip_adj;
+ face->shared.sw_if = swif;
+ face->shared.pl_id = (u16) 0;
+ face->shared.face_type = hicn_face_udp_type;
+ face->shared.flags = flags;
+ face->shared.locks = 0;
+
+ hicn_face_udp_key_t key;
+ hicn_face_udp6_get_key (&local_addr->ip6, &remote_addr->ip6, local_port,
+ remote_port, &key);
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+
+ mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 0);
+
+ *pfaceid = hicn_dpoi_get_index (face);
+ dpo_proto = DPO_PROTO_IP6;
+ }
+ else
+ {
+ return HICN_ERROR_IPS_ADDR_TYPE_NONUNIFORM;
+ }
+
+ retx_t *retx = vlib_process_signal_event_data (vlib_get_main (),
+ hicn_mapme_eventmgr_process_node.
+ index,
+ HICN_MAPME_EVENT_FACE_ADD, 1,
+ sizeof (retx_t));
+ *retx = (retx_t)
+ {
+ .prefix = 0,.dpo = (dpo_id_t)
+ {
+ .dpoi_type = hicn_face_udp_type,.dpoi_proto =
+ dpo_proto,.dpoi_next_node = 0,.dpoi_index = *pfaceid,}
+ };
+
+ return ret;
+}
+
+int
+hicn_face_udp_del (u32 faceid)
+{
+ return hicn_face_del (faceid);
+}
+
+u8 *
+format_hicn_face_udp (u8 * s, va_list * args)
+{
+ hicn_face_id_t face_id = va_arg (*args, index_t);
+ CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
+ hicn_face_t *face;
+ hicn_face_udp_t *udp_face;
+ ip_adjacency_t *adj;
+ u8 ipv = 0x40;
+ vnet_main_t *vnm = vnet_get_main ();
+
+
+ face = hicn_dpoi_get_from_idx (face_id);
+ udp_face = (hicn_face_udp_t *) (face->data);
+
+ if (face->shared.flags & HICN_FACE_FLAGS_FACE)
+ {
+ ASSERT (face->shared.adj != (adj_index_t) ~ 0);
+ adj = adj_get (face->shared.adj);
+
+ s = format (s, "%U Face %d: ", format_white_space, indent, face_id);
+ if (udp_face->hdrs.ip4.ip.ip_version_and_header_length == ipv)
+ {
+ s = format (s, "type UDP local %U|%u ",
+ format_ip4_address, &udp_face->hdrs.ip4.ip.src_address,
+ clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.src_port));
+ s =
+ format (s, "remote %U|%u ", format_ip4_address,
+ &udp_face->hdrs.ip4.ip.dst_address,
+ clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.dst_port));
+ s = format (s, "%U", format_vnet_link, adj->ia_link);
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ vnet_get_sw_interface (vnm, face->shared.sw_if));
+ if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
+ s = format (s, " (deleted)");
+ }
+ else
+ {
+ s = format (s, "type UDP local %U|%u ",
+ format_ip6_address, &udp_face->hdrs.ip6.ip.src_address,
+ clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.src_port));
+ s =
+ format (s, "remote %U|%u", format_ip6_address,
+ &udp_face->hdrs.ip6.ip.dst_address,
+ clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.dst_port));
+ s = format (s, "%U", format_vnet_link, adj->ia_link);
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ vnet_get_sw_interface (vnm, face->shared.sw_if));
+ if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
+ s = format (s, " (deleted)");
+ }
+ }
+ else
+ {
+ s = format (s, "IFace %d: ", format_white_space, indent, face_id);
+ if (udp_face->hdrs.ip4.ip.ip_version_and_header_length == ipv)
+ {
+ s = format (s, "type UDP local %U|%u",
+ format_ip4_address, &udp_face->hdrs.ip4.ip.src_address,
+ clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.src_port));
+ s =
+ format (s, " local %U|%u", format_ip4_address,
+ &udp_face->hdrs.ip4.ip.dst_address,
+ clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.dst_port));
+ s =
+ format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ vnet_get_sw_interface (vnm, face->shared.sw_if));
+ if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
+ s = format (s, " (deleted)");
+ }
+ else
+ {
+ s = format (s, "type UDP local %U|%u",
+ format_ip6_address, &udp_face->hdrs.ip6.ip.src_address,
+ clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.src_port));
+ s =
+ format (s, " remote %U|%u", format_ip6_address,
+ &udp_face->hdrs.ip6.ip.dst_address,
+ clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.dst_port));
+ s =
+ format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ vnet_get_sw_interface (vnm, face->shared.sw_if));
+ if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
+ s = format (s, " (deleted)");
+ }
+ }
+
+ return s;
+}
+
+void
+hicn_face_udp_get_dpo (hicn_face_t * face, dpo_id_t * dpo)
+{
+ hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
+ u8 version =
+ (face_udp->hdrs.ip4.ip.ip_version_and_header_length & 0xf0) >> 4;
+ return hicn_dpo_udp_create_from_face (face, dpo,
+ version ==
+ (u8) 4 ? strategy_face_udp4_vlib_edge
+ : strategy_face_udp6_vlib_edge);
+}
+
+hicn_face_vft_t udp_vft = {
+ .format_face = format_hicn_face_udp,
+ .hicn_face_del = hicn_face_udp_del,
+ .hicn_face_get_dpo = hicn_face_udp_get_dpo,
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/face_udp.h b/hicn-plugin/src/faces/udp/face_udp.h
new file mode 100755
index 000000000..8694bad5c
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/face_udp.h
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_FACE_UDP_H__
+#define __HICN_FACE_UDP_H__
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+#include <vnet/ip/ip6_packet.h>
+#include <vnet/udp/udp_packet.h>
+
+#include "../face.h"
+
+/**
+ * @file
+ * @brief UDP face
+ *
+ * This file containes the definition of UDP faces.
+ * UDP faces encap and decap an hicn packet into a UDP tunnel.
+ * Src and dst address in interest and data packets are not considered and
+ * should be set to 0 (not checked in the forwarder).
+ */
+
+/* Pre-instantiated ip header to fast fill an newly encapsulated packet */
+extern ip4_header_t ip4_header_skl;
+extern ip6_header_t ip6_header_skl;
+
+#define INVALID_UDP_DPO_INDEX ~0
+
+/**
+ * @brief UDP face representation. The following is stored in the data field of
+ * an hicn_face_t object (see hicn_face.h). A UDP face is identifies by the
+ * quadruplet (src addr, dst addr, src port, dst port).
+ */
+typedef struct hicn_face_udp_t_
+{
+ /**
+ * The headers to paint, in packet painting order
+ */
+ union
+ {
+ struct
+ {
+ ip4_header_t ip;
+ udp_header_t udp;
+ } __attribute__ ((packed)) ip4;
+ struct
+ {
+ ip6_header_t ip;
+ udp_header_t udp;
+ } __attribute__ ((packed)) ip6;
+ } __attribute__ ((packed)) hdrs;
+} hicn_face_udp_t;
+
+/* Hast table mapping the udp key with the face id (dpoi_index pointing to and
+ element in the face pool defined in hicn_face.h)*/
+extern mhash_t hicn_face_udp_hashtb;
+
+/**
+ * @brief Hash table key.
+ */
+typedef struct hicn_face_udp_key_s
+{
+ ip46_address_t local_addr;
+ ip46_address_t remote_addr;
+ u16 local_port;
+ u16 remote_port;
+} hicn_face_udp_key_t;
+
+/* DPO type for the udp face */
+extern dpo_type_t hicn_face_udp_type;
+
+/* VFT table for the udp face. Mainly used to format the face in the right way */
+extern hicn_face_vft_t udp_vft;
+
+/**
+ * @brief Create the key object for the mhash. Fill in the key object with the
+ * expected values.
+ *
+ * @param local_addr Local address of the UDP tunnel
+ * @param remote_addr Remote address of the UDP tunnel
+ * @param local_port Local port of the UDP tunnel
+ * @param remote_port Remote port of the UDP tunnel
+ * @param key Pointer to an allocated hicn_face_udp_key_t object
+ */
+always_inline void
+hicn_face_udp4_get_key (const ip4_address_t * local_addr,
+ const ip4_address_t * remote_addr,
+ u16 local_port, u16 remote_port,
+ hicn_face_udp_key_t * key)
+{
+
+ ip46_address_set_ip4 (&(key->local_addr), local_addr);
+ ip46_address_set_ip4 (&(key->remote_addr), remote_addr);
+ key->local_port = local_port;
+ key->remote_port = remote_port;
+}
+
+/**
+ * @brief Create the key object for the mhash. Fill in the key object with the
+ * expected values.
+ *
+ * @param local_addr Local address of the UDP tunnel
+ * @param remote_addr Remote address of the UDP tunnel
+ * @param local_port Local port of the UDP tunnel
+ * @param remote_port Remote port of the UDP tunnel
+ * @param key Pointer to an allocated hicn_face_udp_key_t object
+ */
+always_inline void
+hicn_face_udp6_get_key (const ip6_address_t * local_addr,
+ const ip6_address_t * remote_addr,
+ u16 local_port, u16 remote_port,
+ hicn_face_udp_key_t * key)
+{
+ key->local_addr.ip6 = *local_addr;
+ key->remote_addr.ip6 = *remote_addr;
+ key->local_port = local_port;
+ key->remote_port = remote_port;
+}
+
+/**
+ * @brief Get the dpoi from the quadruplet that identifies the face. Does not add any lock.
+ *
+ * @param local_addr Local address of the UDP tunnel
+ * @param remote_addr Remote address of the UDP tunnel
+ * @param local_port Local port of the UDP tunnel
+ * @param remote_port Remote port of the UDP tunnel
+ *
+ * @result Pointer to the face.
+ */
+always_inline hicn_face_t *
+hicn_face_udp4_get (const ip4_address_t * local_addr,
+ const ip4_address_t * remote_addr,
+ u16 local_port, u16 remote_port)
+{
+ hicn_face_udp_key_t key;
+
+ hicn_face_udp4_get_key (local_addr, remote_addr, local_port, remote_port,
+ &key);
+
+ hicn_face_id_t *dpoi_index =
+ (hicn_face_id_t *) mhash_get (&hicn_face_udp_hashtb,
+ &key);
+
+ return dpoi_index == NULL ? NULL : hicn_dpoi_get_from_idx (*dpoi_index);
+}
+
+/**
+ * @brief Get the dpoi from the quadruplet that identifies the face. Does not add any lock.
+ *
+ * @param local_addr Local address of the UDP tunnel (network order)
+ * @param remote_addr Remote address of the UDP tunnel (network order)
+ * @param local_port Local port of the UDP tunnel (network order)
+ * @param remote_port Remote port of the UDP tunnel (network order)
+ *
+ * @result Pointer to the face.
+ */
+always_inline hicn_face_t *
+hicn_face_udp6_get (const ip6_address_t * local_addr,
+ const ip6_address_t * remote_addr,
+ u16 local_port, u16 remote_port)
+{
+ hicn_face_udp_key_t key;
+
+ hicn_face_udp6_get_key (local_addr, remote_addr, local_port, remote_port,
+ &key);
+
+ hicn_face_id_t *dpoi_index =
+ (hicn_face_id_t *) mhash_get (&hicn_face_udp_hashtb,
+ &key);
+
+ return dpoi_index == NULL ? NULL : hicn_dpoi_get_from_idx (*dpoi_index);
+}
+
+
+/**
+ * @brief Initialize the udp face module
+ */
+void hicn_face_udp_init (vlib_main_t * vm);
+
+/**
+ * @brief Create a new face ip. API for other modules (e.g., routing)
+ *
+ * @param local_addr Local ip v4 or v6 address of the face (network order)
+ * @param remote_addr Remote ip v4 or v6 address of the face (network order)
+ * @param local_port Local udp port of the face (network order)
+ * @param remote_port Remote udp port of the face (network order)
+ * @param sw_if interface associated to the face
+ * @param pfaceid Pointer to return the face id
+ * @return HICN_ERROR_FACE_NO_GLOBAL_IP if the face does not have a globally
+ * reachable ip address, otherwise HICN_ERROR_NONE
+ */
+int hicn_face_udp_add (const ip46_address_t * local_addr,
+ const ip46_address_t * remote_addr, u16 local_port,
+ u16 remote_port, u32 swif, hicn_face_id_t * pfaceid);
+
+/**
+ * @brief Delete an ip face
+ *
+ * @param face_id Id of the face to delete
+ * @return HICN_ERROR_FACE_NOT_FOUND if the face does not exist, otherwise
+ * HICN_ERROR_NONE
+ */
+int hicn_face_udp_del (hicn_face_id_t faceid);
+
+/**
+ * @brief Format a UDP face
+ *
+ * @param s Pointer to a previous string. If null it will be initialize
+ * @param args Array storing input values. Expected u32 indent and u32 face_id
+ * @return String with the formatted face
+ */
+u8 *format_hicn_face_udp (u8 * s, va_list * args);
+
+/**
+ * @brief Create a dpo from a udp face
+ *
+ * @param face Face from which to create the dpo
+ * @return the dpo
+ */
+void hicn_face_udp_get_dpo (hicn_face_t * face, dpo_id_t * dpo);
+
+/**
+ * @brief Init some internal structures
+ */
+void hicn_face_udp_init_internal (void);
+
+#endif // __HICN_FACE_UDP_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/face_udp_cli.c b/hicn-plugin/src/faces/udp/face_udp_cli.c
new file mode 100755
index 000000000..7bb172ce8
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/face_udp_cli.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "face_udp.h"
+#include "dpo_udp.h"
+
+#include <vnet/vnet.h>
+#include <vnet/dpo/dpo.h>
+#include <vlib/vlib.h>
+#include <vnet/ip/format.h>
+
+#define HICN_FACE_NONE 0
+#define HICN_FACE_DELETE 1
+#define HICN_FACE_ADD 2
+
+
+static clib_error_t *
+hicn_face_udp_cli_set_command_fn (vlib_main_t * vm,
+ unformat_input_t * main_input,
+ vlib_cli_command_t * cmd)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ ip46_address_t src_addr;
+ u32 src_port = 0;
+ ip46_address_t dst_addr;
+ u32 dst_port = 0;
+ hicn_face_id_t face_id = HICN_FACE_NULL;
+ int ret = HICN_ERROR_NONE;
+ int sw_if;
+ int face_op = HICN_FACE_NONE;
+
+ ip46_address_reset (&src_addr);
+ ip46_address_reset (&dst_addr);
+ /* Get a line of input. */
+ unformat_input_t _line_input, *line_input = &_line_input;
+ if (!unformat_user (main_input, unformat_line_input, line_input))
+ {
+ return (0);
+ }
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "del"))
+ {
+ if (unformat (line_input, "id %d", &face_id))
+ face_op = HICN_FACE_DELETE;
+ else
+ {
+ return clib_error_return (0, "missing face id");
+ }
+ }
+ else if (unformat (line_input, "add"))
+ {
+ face_op = HICN_FACE_ADD;
+ if (unformat
+ (line_input, "src_addr %U port %u dst_addr %U port %u intfc %U",
+ unformat_ip46_address, &src_addr, IP46_TYPE_ANY, &src_port,
+ unformat_ip46_address, &dst_addr, IP46_TYPE_ANY, &dst_port,
+ unformat_vnet_sw_interface, vnm, &sw_if));
+ else
+ {
+ return clib_error_return (0, "%s '%U'",
+ get_error_string
+ (HICN_ERROR_CLI_INVAL),
+ format_unformat_error, line_input);
+ }
+ }
+ else
+ {
+ return clib_error_return (0, "%s '%U'",
+ get_error_string (HICN_ERROR_CLI_INVAL),
+ format_unformat_error, line_input);
+ }
+ }
+
+ if (face_id != HICN_FACE_NULL)
+ {
+ if (!hicn_dpoi_idx_is_valid (face_id))
+ {
+ return clib_error_return (0, "%s, face_id %d not valid",
+ get_error_string (ret), face_id);
+ }
+ }
+
+ int rv;
+ switch (face_op)
+ {
+ case HICN_FACE_ADD:
+
+ /* Check for presence of next hop address */
+ if (((dst_addr.as_u64[0] == (u64) 0) && (dst_addr.as_u64[1] == (u64) 0))
+ || dst_port == 0)
+ {
+ return clib_error_return (0, "dst address and port not specified");
+ }
+
+ if (((src_addr.as_u64[0] == (u64) 0) && (src_addr.as_u64[1] == (u64) 0))
+ || src_port == 0)
+ {
+ return clib_error_return (0, "src address not specified");
+ }
+
+ rv =
+ hicn_face_udp_add (&src_addr, &dst_addr,
+ clib_host_to_net_u16 (src_port),
+ clib_host_to_net_u16 (dst_port), sw_if, &face_id);
+ if (rv == HICN_ERROR_NONE)
+ {
+ vlib_cli_output (vm, "Face id: %d", face_id);
+ }
+ else
+ {
+ return clib_error_return (0, get_error_string (rv));
+ }
+ break;
+ case HICN_FACE_DELETE:
+ rv = hicn_face_udp_del (face_id);
+ if (rv == HICN_ERROR_NONE)
+ {
+ vlib_cli_output (vm, "Face %d deleted", face_id);
+ }
+ else
+ {
+ return clib_error_return (0, get_error_string (rv));
+ }
+ break;
+ default:
+ return clib_error_return (0, "Operation (%d) not implemented", face_op);
+ break;
+ }
+ return (rv == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n",
+ get_error_string
+ (rv));
+}
+
+/* cli declaration for 'cfg face' */
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (hicn_face_udp_cli_set_command, static) =
+{
+ .path = "hicn face udp",
+ .short_help = "hicn face udp {add src_addr <src_address> port <src_port > dst_addr <dst_address> port <dst_port>} intfc <interface> | {del id <face_id>}",
+ .function = hicn_face_udp_cli_set_command_fn,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/face_udp_node.c b/hicn-plugin/src/faces/udp/face_udp_node.c
new file mode 100755
index 000000000..74d0b1864
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/face_udp_node.c
@@ -0,0 +1,864 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+#include <vnet/ip/ip_packet.h>
+
+#include "face_udp.h"
+#include "face_udp_node.h"
+#include "dpo_udp.h"
+#include "../face.h"
+#include "../../strategy.h"
+#include "../../strategy_dpo_manager.h"
+#include "../../hicn.h"
+
+/**
+ * @File
+ *
+ * Definition of the nodes for udp faces.
+ */
+
+vlib_node_registration_t hicn_face_udp4_input_node;
+vlib_node_registration_t hicn_face_udp6_input_node;
+vlib_node_registration_t hicn_face_udp4_output_node;
+vlib_node_registration_t hicn_face_udp6_output_node;
+
+static char *hicn_face_udp4_input_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn_face_udp6_input_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_face_udp4_input_trace_t;
+
+typedef enum
+{
+ HICN_FACE_UDP4_INPUT_NEXT_DATA,
+ HICN_FACE_UDP4_INPUT_NEXT_MAPME,
+ HICN_FACE_UDP4_INPUT_NEXT_ERROR_DROP,
+ HICN_FACE_UDP4_INPUT_N_NEXT,
+} hicn_face_udp4_input_next_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_face_udp6_input_trace_t;
+
+typedef enum
+{
+ HICN_FACE_UDP6_INPUT_NEXT_DATA,
+ HICN_FACE_UDP6_INPUT_NEXT_MAPME,
+ HICN_FACE_UDP6_INPUT_NEXT_ERROR_DROP,
+ HICN_FACE_UDP6_INPUT_N_NEXT,
+} hicn_face_udp6_input_next_t;
+
+#define ERROR_INPUT_UDP4 HICN_FACE_UDP4_INPUT_NEXT_ERROR_DROP
+#define ERROR_INPUT_UDP6 HICN_FACE_UDP6_INPUT_NEXT_ERROR_DROP
+
+#define NEXT_MAPME_UDP4 HICN_FACE_UDP4_INPUT_NEXT_MAPME
+#define NEXT_MAPME_UDP6 HICN_FACE_UDP6_INPUT_NEXT_MAPME
+#define NEXT_DATA_UDP4 HICN_FACE_UDP4_INPUT_NEXT_DATA
+#define NEXT_DATA_UDP6 HICN_FACE_UDP6_INPUT_NEXT_DATA
+
+#define IP_HEADER_4 ip4_header_t
+#define IP_HEADER_6 ip6_header_t
+
+#define HICN_DPO_UDP_LOCK_IP4 hicn_dpo_udp4_lock
+#define HICN_DPO_UDP_LOCK_IP6 hicn_dpo_udp6_lock
+
+#define TRACE_INPUT_PKT_UDP4 hicn_face_udp4_input_trace_t
+#define TRACE_INPUT_PKT_UDP6 hicn_face_udp6_input_trace_t
+
+#define face_input_x1(ipv) \
+ do { \
+ int ret; \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = ERROR_INPUT_UDP##ipv; \
+ IP_HEADER_##ipv * ip_hdr = NULL; \
+ u8 * inner_ip_hdr = NULL; \
+ udp_header_t * udp_hdr = NULL; \
+ hicn_buffer_t * hicnb0; \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
+ udp_hdr = (udp_header_t *) (ip_hdr + 1); \
+ hicnb0 = hicn_get_buffer(b0); \
+ \
+ inner_ip_hdr = (u8 *)(udp_hdr + 1); \
+ u8 is_v6 = ((inner_ip_hdr[0] & 2) >> 1); \
+ u8 is_icmp = is_v6*(inner_ip_hdr[7] == IPPROTO_ICMPV6) + \
+ (1 - is_v6)*(inner_ip_hdr[10] == IPPROTO_ICMPV4); \
+ \
+ ret = HICN_DPO_UDP_LOCK_IP##ipv \
+ (&(hicnb0->face_dpo_id), \
+ &(ip_hdr->dst_address), \
+ &(ip_hdr->src_address), \
+ (udp_hdr->dst_port), \
+ (udp_hdr->src_port), \
+ &hicnb0->is_appface); \
+ \
+ if ( PREDICT_FALSE(ret != HICN_ERROR_NONE) ) \
+ { \
+ next0 = ERROR_INPUT_UDP##ipv; \
+ } \
+ else \
+ { \
+ next0 = is_icmp*NEXT_MAPME_UDP##ipv + \
+ (1-is_icmp)*NEXT_DATA_UDP##ipv; \
+ stats.pkts_data_count += 1; \
+ \
+ vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \
+ sizeof(udp_header_t)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_CONTENT; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, next0); \
+ }while(0) \
+
+#define face_input_x2(ipv) \
+ do { \
+ int ret0, ret1; \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = ERROR_INPUT_UDP##ipv; \
+ u32 next1 = ERROR_INPUT_UDP##ipv; \
+ IP_HEADER_##ipv * ip_hdr0 = NULL; \
+ IP_HEADER_##ipv * ip_hdr1 = NULL; \
+ u8 * inner_ip_hdr0 = NULL; \
+ u8 * inner_ip_hdr1 = NULL; \
+ udp_header_t * udp_hdr0 = NULL; \
+ udp_header_t * udp_hdr1 = NULL; \
+ hicn_buffer_t *hicnb0, *hicnb1; \
+ \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
+ ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b1); \
+ udp_hdr0 = (udp_header_t *) (ip_hdr0 + 1); \
+ udp_hdr1 = (udp_header_t *) (ip_hdr1 + 1); \
+ hicnb0 = hicn_get_buffer(b0); \
+ hicnb1 = hicn_get_buffer(b1); \
+ \
+ inner_ip_hdr0 = (u8 *)(udp_hdr0 + 1); \
+ u8 is_v6_0 = ((inner_ip_hdr0[0] & 2) >> 1); \
+ u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[7] == IPPROTO_ICMPV6) + \
+ (1 - is_v6_0)*(inner_ip_hdr0[10] == IPPROTO_ICMPV4); \
+ \
+ inner_ip_hdr1 = (u8 *)(udp_hdr1 + 1); \
+ u8 is_v6_1 = ((inner_ip_hdr1[0] & 2) >> 1); \
+ u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[7] == IPPROTO_ICMPV6) + \
+ (1 - is_v6_1)*(inner_ip_hdr1[10] == IPPROTO_ICMPV4); \
+ \
+ ret0 = HICN_DPO_UDP_LOCK_IP##ipv \
+ (&(hicnb0->face_dpo_id), \
+ &(ip_hdr0->dst_address), \
+ &(ip_hdr0->src_address), \
+ (udp_hdr0->dst_port), \
+ (udp_hdr0->src_port), \
+ &hicnb0->is_appface); \
+ \
+ ret1 = HICN_DPO_UDP_LOCK_IP##ipv \
+ (&(hicnb1->face_dpo_id), \
+ &(ip_hdr1->dst_address), \
+ &(ip_hdr1->src_address), \
+ (udp_hdr1->dst_port), \
+ (udp_hdr1->src_port), \
+ &hicnb1->is_appface); \
+ \
+ if ( PREDICT_FALSE(ret0 != HICN_ERROR_NONE) ) \
+ { \
+ next0 = ERROR_INPUT_UDP##ipv; \
+ } \
+ else \
+ { \
+ stats.pkts_data_count += 1; \
+ next0 = is_icmp0*NEXT_MAPME_UDP##ipv + \
+ (1-is_icmp0)*NEXT_DATA_UDP##ipv; \
+ \
+ vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \
+ sizeof(udp_header_t)); \
+ } \
+ \
+ if ( PREDICT_FALSE(ret1 != HICN_ERROR_NONE) ) \
+ { \
+ next1 = ERROR_INPUT_UDP##ipv; \
+ } \
+ else \
+ { \
+ stats.pkts_data_count += 1; \
+ next1 = is_icmp1*NEXT_MAPME_UDP##ipv + \
+ (1-is_icmp1)*NEXT_DATA_UDP##ipv; \
+ \
+ vlib_buffer_advance(b1, sizeof(IP_HEADER_##ipv) + \
+ sizeof(udp_header_t)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_CONTENT; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_CONTENT; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, bi1, next0, next1); \
+ }while(0) \
+
+static uword
+hicn_face_udp4_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ face_input_x2 (4);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ face_input_x1 (4);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_face_udp4_input_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_udp4_input_trace_t *t =
+ va_arg (*args, hicn_face_udp4_input_trace_t *);
+
+ s = format (s, "FACE_UDP4_INPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_face_udp4_input_node) =
+{
+ .function = hicn_face_udp4_input_node_fn,
+ .name = "hicn-face-udp4-input",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_face_udp4_input_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_face_udp4_input_error_strings),
+ .error_strings = hicn_face_udp4_input_error_strings,
+ .n_next_nodes = HICN_FACE_UDP4_INPUT_N_NEXT,
+ /* edit / add dispositions here */
+ .next_nodes =
+ {
+ [HICN_FACE_UDP4_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
+ [HICN_FACE_UDP4_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
+ [HICN_FACE_UDP4_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+
+static uword
+hicn_face_udp6_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ face_input_x2 (6);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ face_input_x1 (6);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_PROCESSED, stats.pkts_processed);
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_face_udp6_input_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_udp6_input_trace_t *t =
+ va_arg (*args, hicn_face_udp6_input_trace_t *);
+
+ s = format (s, "FACE_UDP6_INPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_face_udp6_input_node) =
+{
+ .function = hicn_face_udp6_input_node_fn,
+ .name = "hicn-face-udp6-input",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_face_udp6_input_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_face_udp6_input_error_strings),
+ .error_strings = hicn_face_udp6_input_error_strings,
+ .n_next_nodes = HICN_FACE_UDP6_INPUT_N_NEXT,
+ /* edit / add dispositions here */
+ .next_nodes =
+ {
+ [HICN_FACE_UDP6_INPUT_NEXT_DATA] = "hicn-data-pcslookup",
+ [HICN_FACE_UDP6_INPUT_NEXT_MAPME] = "hicn-mapme-ack",
+ [HICN_FACE_UDP6_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+/******* Face Output *******/
+
+always_inline void
+hicn_face_udp4_encap (vlib_main_t * vm,
+ vlib_buffer_t * outer_b0,
+ hicn_face_t * face, u32 * next)
+{
+ u16 old_l0 = 0, new_l0;
+ ip_csum_t sum0;
+ ip4_header_t *ip0;
+ udp_header_t *udp0;
+ hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
+ ip_adjacency_t *adj = adj_get (face->shared.adj);
+
+ /* ip */
+ ip0 = vlib_buffer_get_current (outer_b0);
+ clib_memcpy (ip0, &(face_udp->hdrs.ip4.ip), sizeof (ip4_header_t) +
+ sizeof (udp_header_t));
+
+ /* Fix UDP length */
+ udp0 = (udp_header_t *) (ip0 + 1);
+
+ new_l0 =
+ clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, outer_b0) -
+ sizeof (*ip0));
+ udp0->length = new_l0;
+
+ old_l0 = ip0->length;
+ ip0->length =
+ clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, outer_b0));
+
+ sum0 = ip0->checksum;
+
+ //old_l0 always 0, see the rewrite setup
+ new_l0 = ip0->length;
+
+ sum0 = ip_csum_update (sum0, old_l0, new_l0, ip4_header_t,
+ length /* changed member */ );
+ ip0->checksum = sum0;
+
+ vnet_buffer (outer_b0)->ip.adj_index[VLIB_TX] = face->shared.adj;
+
+ *next = adj->lookup_next_index;
+}
+
+always_inline void
+hicn_face_udp6_encap (vlib_main_t * vm,
+ vlib_buffer_t * outer_b0,
+ hicn_face_t * face, u32 * next)
+{
+ int bogus0;
+ u16 new_l0;
+ ip6_header_t *ip0;
+ udp_header_t *udp0;
+ hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
+ ip_adjacency_t *adj = adj_get (face->shared.adj);
+
+ /* ip */
+ ip0 = vlib_buffer_get_current (outer_b0);
+ clib_memcpy (ip0, &(face_udp->hdrs.ip6.ip), sizeof (ip6_header_t) +
+ sizeof (udp_header_t));
+ new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, outer_b0)
+ - sizeof (*ip0));
+ ip0->payload_length = new_l0;
+
+ /* Fix UDP length */
+ udp0 = (udp_header_t *) (ip0 + 1);
+ udp0->length = new_l0;
+
+ udp0->checksum =
+ ip6_tcp_udp_icmp_compute_checksum (vm, outer_b0, ip0, &bogus0);
+
+ ASSERT (bogus0 == 0);
+
+ if (udp0->checksum == 0)
+ udp0->checksum = 0xffff;
+
+ vnet_buffer (outer_b0)->ip.adj_index[VLIB_TX] = face->shared.adj;
+
+ *next = adj->lookup_next_index;
+}
+
+static char *hicn_face_udp4_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn_face_udp6_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_face_udp4_output_trace_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_face_udp6_output_trace_t;
+
+#define HICN_FACE_UDP_ENCAP_IP4 hicn_face_udp4_encap
+#define HICN_FACE_UDP_ENCAP_IP6 hicn_face_udp6_encap
+
+#define TRACE_OUTPUT_PKT_UDP4 hicn_face_udp4_output_trace_t
+#define TRACE_OUTPUT_PKT_UDP6 hicn_face_udp6_output_trace_t
+
+#define IP_HEADER_4 ip4_header_t
+#define IP_HEADER_6 ip6_header_t
+
+#define face_output_x1(ipv) \
+ do { \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = IP_LOOKUP_NEXT_DROP; \
+ hicn_face_t * face; \
+ \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ face = \
+ hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ \
+ if (PREDICT_TRUE(face != NULL)) \
+ { \
+ /* Adjust vlib buffer. Create space for the udp tunnel. */ \
+ vlib_buffer_advance(b0, -(sizeof (IP_HEADER_##ipv) + \
+ sizeof (udp_header_t))); \
+ \
+ \
+ HICN_FACE_UDP_ENCAP_IP##ipv \
+ (vm, b0, face, &next0); \
+ stats.pkts_interest_count += 1; \
+ } \
+ \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, next0); \
+ } while(0) \
+
+
+#define face_output_x2(ipv) \
+ do { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = IP_LOOKUP_NEXT_DROP; \
+ u32 next1 = IP_LOOKUP_NEXT_DROP; \
+ hicn_face_t *face0, *face1; \
+ \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ \
+ face0 = \
+ hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ face1 = \
+ hicn_dpoi_get_from_idx(vnet_buffer (b1)->ip.adj_index[VLIB_TX]); \
+ \
+ if (PREDICT_TRUE(face0 != NULL)) \
+ { \
+ /* Adjust vlib buffer. Create space for the udp tunnel. */ \
+ vlib_buffer_advance(b0, -(sizeof (IP_HEADER_##ipv) + \
+ sizeof (udp_header_t))); \
+ \
+ \
+ HICN_FACE_UDP_ENCAP_IP##ipv \
+ (vm, b0, face0, &next0); \
+ stats.pkts_interest_count += 1; \
+ } \
+ \
+ if (PREDICT_TRUE(face1 != NULL)) \
+ { \
+ /* Adjust vlib buffer. Create space for the udp tunnel. */ \
+ vlib_buffer_advance(b1, -(sizeof (IP_HEADER_##ipv) + \
+ sizeof (udp_header_t))); \
+ \
+ \
+ HICN_FACE_UDP_ENCAP_IP##ipv \
+ (vm, b1, face1, &next1); \
+ stats.pkts_interest_count += 1; \
+ } \
+ \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, bi1, next0, next1); \
+ } while(0) \
+
+
+static uword
+hicn_face_udp4_output_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ face_output_x2 (4);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ face_output_x1 (4);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_face_udp4_output_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_udp4_output_trace_t *t =
+ va_arg (*args, hicn_face_udp4_output_trace_t *);
+
+ s = format (s, "FACE_UDP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/* *INDENT-OFF* */
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_face_udp4_output_node) =
+{
+ .function = hicn_face_udp4_output_node_fn,
+ .name = "hicn-face-udp4-output",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_face_udp4_output_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_face_udp4_output_error_strings),
+ .error_strings = hicn_face_udp4_output_error_strings,
+ .n_next_nodes = IP4_LOOKUP_N_NEXT,
+ /* Reusing the list of nodes from lookup to be compatible with arp */
+ .next_nodes = IP4_LOOKUP_NEXT_NODES,
+};
+/* *INDENT-ON* */
+
+/* *INDENT-ON* */
+
+static uword
+hicn_face_udp6_output_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ face_output_x2 (6);
+ }
+
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ face_output_x1 (6);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_face_udp6_output_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_face_udp6_output_trace_t *t =
+ va_arg (*args, hicn_face_udp6_output_trace_t *);
+
+ s = format (s, "FACE_UDP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/* *INDENT-OFF* */
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_face_udp6_output_node) =
+{
+ .function = hicn_face_udp6_output_node_fn,
+ .name = "hicn-face-udp6-output",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_face_udp6_output_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_face_udp6_output_error_strings),
+ .error_strings = hicn_face_udp6_output_error_strings,
+ .n_next_nodes = IP6_LOOKUP_N_NEXT,
+ /* Reusing the list of nodes from lookup to be compatible with neighbour discovery */
+ .next_nodes = IP6_LOOKUP_NEXT_NODES,
+};
+/* *INDENT-ON* */
+
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/face_udp_node.h b/hicn-plugin/src/faces/udp/face_udp_node.h
new file mode 100755
index 000000000..c759312c8
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/face_udp_node.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_FACE_UDP_NODE_H__
+#define __HICN_FACE_UDP_NODE_H__
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+
+extern vlib_node_registration_t hicn_face_udp4_input_node;
+extern vlib_node_registration_t hicn_face_udp6_input_node;
+extern vlib_node_registration_t hicn_face_udp4_output_node;
+extern vlib_node_registration_t hicn_face_udp6_output_node;
+
+#endif // __HICN_FACE_UDP_NODE_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/iface_udp_node.c b/hicn-plugin/src/faces/udp/iface_udp_node.c
new file mode 100755
index 000000000..ddea31b4c
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/iface_udp_node.c
@@ -0,0 +1,894 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iface_udp_node.h"
+#include "dpo_udp.h"
+#include "../face.h"
+
+#include "../../infra.h"
+#include "../../hicn.h"
+
+/**
+ * @File
+ *
+ * Definition of the nodes for udp incomplete faces.
+ */
+
+vlib_node_registration_t hicn_iface_udp4_input_node;
+vlib_node_registration_t hicn_iface_udp6_input_node;
+vlib_node_registration_t hicn_iface_udp4_output_node;
+vlib_node_registration_t hicn_iface_udp6_output_node;
+
+u32 data_fwd_face_udp4_vlib_edge;
+u32 data_fwd_face_udp6_vlib_edge;
+
+void
+hicn_iface_udp_init (vlib_main_t * vm)
+{
+ data_fwd_face_udp4_vlib_edge = vlib_node_add_next (vm,
+ hicn_data_fwd_node.index,
+ hicn_iface_udp4_output_node.
+ index);
+
+ data_fwd_face_udp6_vlib_edge = vlib_node_add_next (vm,
+ hicn_data_fwd_node.index,
+ hicn_iface_udp6_output_node.
+ index);
+
+ u32 temp_index4 = vlib_node_add_next (vm,
+ hicn_interest_hitcs_node.index,
+ hicn_iface_udp4_output_node.index);
+ u32 temp_index6 = vlib_node_add_next (vm,
+ hicn_interest_hitcs_node.index,
+ hicn_iface_udp6_output_node.index);
+
+ ASSERT (temp_index4 == data_fwd_face_udp4_vlib_edge);
+ ASSERT (temp_index6 == data_fwd_face_udp6_vlib_edge);
+}
+
+static char *hicn_iface_udp4_input_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn_iface_udp6_input_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+u32
+get_face_udp4_output_node (void)
+{
+ return data_fwd_face_udp4_vlib_edge;
+}
+
+u32
+get_face_udp6_output_node (void)
+{
+ return data_fwd_face_udp6_vlib_edge;
+}
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_iface_udp4_input_trace_t;
+
+typedef enum
+{
+ HICN_IFACE_UDP4_INPUT_NEXT_INTEREST,
+ HICN_IFACE_UDP4_INPUT_NEXT_MAPME,
+ HICN_IFACE_UDP4_INPUT_NEXT_ERROR_DROP,
+ HICN_IFACE_UDP4_INPUT_N_NEXT,
+} hicn_iface_udp4_input_next_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_iface_udp6_input_trace_t;
+
+typedef enum
+{
+ HICN_IFACE_UDP6_INPUT_NEXT_INTEREST,
+ HICN_IFACE_UDP6_INPUT_NEXT_MAPME,
+ HICN_IFACE_UDP6_INPUT_NEXT_ERROR_DROP,
+ HICN_IFACE_UDP6_INPUT_N_NEXT,
+} hicn_iface_udp6_input_next_t;
+
+#define ERROR_INPUT_UDP4 HICN_IFACE_UDP4_INPUT_NEXT_ERROR_DROP
+#define ERROR_INPUT_UDP6 HICN_IFACE_UDP6_INPUT_NEXT_ERROR_DROP
+
+#define IP_HEADER_4 ip4_header_t
+#define IP_HEADER_6 ip6_header_t
+
+#define NEXT_MAPME_UDP4 HICN_IFACE_UDP4_INPUT_NEXT_MAPME
+#define NEXT_MAPME_UDP6 HICN_IFACE_UDP6_INPUT_NEXT_MAPME
+
+#define NEXT_INTEREST_UDP4 HICN_IFACE_UDP4_INPUT_NEXT_INTEREST
+#define NEXT_INTEREST_UDP6 HICN_IFACE_UDP6_INPUT_NEXT_INTEREST
+
+#define HICN_IFACE_UDP_ADD_LOCK_IP4 hicn_dpo_udp4_add_and_lock
+#define HICN_IFACE_UDP_ADD_LOCK_IP6 hicn_dpo_udp6_add_and_lock
+
+#define GET_FACE_UDP4 get_face_udp4_output_node
+#define GET_FACE_UDP6 get_face_udp6_output_node
+
+#define TRACE_INPUT_PKT_UDP4 hicn_iface_udp4_input_trace_t
+#define TRACE_INPUT_PKT_UDP6 hicn_iface_udp6_input_trace_t
+
+#define iface_input_x1(ipv) \
+ do { \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = ERROR_INPUT_UDP##ipv; \
+ IP_HEADER_##ipv * ip_hdr = NULL; \
+ u8 * inner_ip_hdr = NULL; \
+ udp_header_t * udp_hdr = NULL; \
+ hicn_buffer_t * hicnb0; \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
+ udp_hdr = (udp_header_t *) (ip_hdr + 1); \
+ hicnb0 = hicn_get_buffer(b0); \
+ \
+ stats.pkts_interest_count += 1; \
+ \
+ inner_ip_hdr = (u8 *)(udp_hdr + 1); \
+ u8 is_v6 = ((inner_ip_hdr[0] & 2) >> 1); \
+ u8 is_icmp = is_v6*(inner_ip_hdr[7] == IPPROTO_ICMPV6) + \
+ (1 - is_v6)*(inner_ip_hdr[10] == IPPROTO_ICMPV4); \
+ \
+ next0 = is_icmp*NEXT_MAPME_UDP##ipv + \
+ (1-is_icmp)*NEXT_INTEREST_UDP##ipv; \
+ \
+ HICN_IFACE_UDP_ADD_LOCK_IP##ipv \
+ (&(hicnb0->face_dpo_id), \
+ &(ip_hdr->dst_address), \
+ &(ip_hdr->src_address), \
+ udp_hdr->dst_port, \
+ udp_hdr->src_port, \
+ GET_FACE_UDP##ipv \
+ (), \
+ &hicnb0->is_appface); \
+ \
+ vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \
+ sizeof(udp_header_t)); \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, next0); \
+ }while(0)
+
+
+#define iface_input_x2(ipv) \
+ do { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0, next1 = ERROR_INPUT_UDP##ipv; \
+ IP_HEADER_##ipv * ip_hdr0 = NULL, *ip_hdr1 = NULL; \
+ u8 * inner_ip_hdr0 = NULL, *inner_ip_hdr1 = NULL; \
+ udp_header_t * udp_hdr0 = NULL, *udp_hdr1 = NULL; \
+ hicn_buffer_t * hicnb0, *hicnb1; \
+ \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
+ ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b1); \
+ udp_hdr0 = (udp_header_t *) (ip_hdr0 + 1); \
+ udp_hdr1 = (udp_header_t *) (ip_hdr1 + 1); \
+ hicnb0 = hicn_get_buffer(b0); \
+ hicnb1 = hicn_get_buffer(b1); \
+ \
+ stats.pkts_interest_count += 2; \
+ \
+ inner_ip_hdr0 = (u8 *)(udp_hdr0 + 1); \
+ inner_ip_hdr1 = (u8 *)(udp_hdr1 + 1); \
+ u8 is_v6_0 = ((inner_ip_hdr0[0] & 2) >> 1); \
+ u8 is_v6_1 = ((inner_ip_hdr1[0] & 2) >> 1); \
+ u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[7] == IPPROTO_ICMPV6) + \
+ (1 - is_v6_0)*(inner_ip_hdr0[10] == IPPROTO_ICMPV4); \
+ u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[7] == IPPROTO_ICMPV6) + \
+ (1 - is_v6_1)*(inner_ip_hdr1[10] == IPPROTO_ICMPV4); \
+ \
+ next0 = is_icmp0*NEXT_MAPME_UDP##ipv + \
+ (1-is_icmp0)*NEXT_INTEREST_UDP##ipv; \
+ next1 = is_icmp1*NEXT_MAPME_UDP##ipv + \
+ (1-is_icmp1)*NEXT_INTEREST_UDP##ipv; \
+ \
+ HICN_IFACE_UDP_ADD_LOCK_IP##ipv \
+ (&(hicnb0->face_dpo_id), \
+ &(ip_hdr0->dst_address), \
+ &(ip_hdr0->src_address), \
+ udp_hdr0->dst_port, \
+ udp_hdr0->src_port, \
+ GET_FACE_UDP##ipv \
+ (), \
+ &hicnb0->is_appface); \
+ \
+ \
+ HICN_IFACE_UDP_ADD_LOCK_IP##ipv \
+ (&(hicnb1->face_dpo_id), \
+ &(ip_hdr1->dst_address), \
+ &(ip_hdr1->src_address), \
+ udp_hdr1->dst_port, \
+ udp_hdr1->src_port, \
+ GET_FACE_UDP##ipv \
+ (), \
+ &hicnb1->is_appface); \
+ \
+ vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \
+ sizeof(udp_header_t)); \
+ \
+ vlib_buffer_advance(b1, sizeof(IP_HEADER_##ipv) + \
+ sizeof(udp_header_t)); \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, bi1, next0, next1); \
+ }while(0)
+
+
+static uword
+hicn_iface_udp4_input_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ iface_input_x2 (4);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ iface_input_x1 (4);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_iface_udp4_input_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_iface_udp4_input_trace_t *t =
+ va_arg (*args, hicn_iface_udp4_input_trace_t *);
+
+ s = format (s, "IFACE_UDP4_INPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_iface_udp4_input_node) =
+
+{
+ .function = hicn_iface_udp4_input_node_fn,
+ .name = "hicn-iface-udp4-input",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_iface_udp4_input_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_iface_udp4_input_error_strings),
+ .error_strings = hicn_iface_udp4_input_error_strings,
+ .n_next_nodes = HICN_IFACE_UDP4_INPUT_N_NEXT,
+ .next_nodes =
+ {
+ [HICN_IFACE_UDP4_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
+ [HICN_IFACE_UDP4_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
+ [HICN_IFACE_UDP4_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+
+static uword
+hicn_iface_udp6_input_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ /* Dual loop, X2 */
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ iface_input_x2 (6);
+ }
+
+ /* Dual loop, X1 */
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ iface_input_x1 (6);
+ }
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_INTERESTS,
+ stats.pkts_interest_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_iface_udp6_input_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_iface_udp6_input_trace_t *t =
+ va_arg (*args, hicn_iface_udp6_input_trace_t *);
+
+ s = format (s, "IFACE_UDP6_INPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_iface_udp6_input_node) =
+{
+ .function = hicn_iface_udp6_input_node_fn,
+ .name = "hicn-iface-udp6-input",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_iface_udp6_input_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_iface_udp6_input_error_strings),
+ .error_strings = hicn_iface_udp6_input_error_strings,
+ .n_next_nodes = HICN_IFACE_UDP6_INPUT_N_NEXT,
+ .next_nodes =
+ {
+ [HICN_IFACE_UDP6_INPUT_NEXT_INTEREST] = "hicn-interest-pcslookup",
+ [HICN_IFACE_UDP6_INPUT_NEXT_MAPME] = "hicn-mapme-ctrl",
+ [HICN_IFACE_UDP6_INPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+/******* Iface Output *******/
+
+always_inline void
+hicn_iface_udp4_encap (vlib_main_t * vm,
+ vlib_buffer_t * b0, hicn_face_t * face)
+{
+ u16 new_l0 = 0;
+ ip4_header_t *ip0;
+ udp_header_t *udp0;
+ hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
+
+ /* Adjust vlib buffers */
+ /* Set the right length on the header buffer */
+ /* Move the next buffer current data pointer back to the ip+tcp header (hicn header) */
+ int offset = sizeof (ip4_header_t) + sizeof (udp_header_t);
+ b0->current_data -= offset;
+ b0->current_length += offset;
+
+ /* ip */
+ ip0 = vlib_buffer_get_current (b0);
+ clib_memcpy (ip0, &(face_udp->hdrs.ip4.ip), sizeof (ip4_header_t) +
+ sizeof (udp_header_t));
+
+ /* Fix UDP length */
+ udp0 = (udp_header_t *) (ip0 + 1);
+
+ new_l0 =
+ clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
+ sizeof (*ip0));
+ udp0->length = new_l0;
+
+ ip0->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
+ ip0->checksum = ip4_header_checksum (ip0);
+}
+
+always_inline void
+hicn_iface_udp6_encap (vlib_main_t * vm,
+ vlib_buffer_t * b0, hicn_face_t * face)
+{
+ int bogus0;
+ u16 new_l0;
+ ip6_header_t *ip0;
+ udp_header_t *udp0;
+ hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
+
+ /* Adjust vlib buffer */
+ int offset = sizeof (ip6_header_t) + sizeof (udp_header_t);
+ b0->current_data -= offset;
+ b0->current_length += offset;
+
+ /* ip */
+ ip0 = vlib_buffer_get_current (b0);
+ clib_memcpy (ip0, &(face_udp->hdrs.ip6.ip), sizeof (ip6_header_t) +
+ sizeof (udp_header_t));
+
+ new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)
+ - sizeof (*ip0));
+
+ ip0->payload_length = new_l0;
+
+ /* Fix UDP length */
+ udp0 = (udp_header_t *) (ip0 + 1);
+ udp0->length = new_l0;
+
+ udp0->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip0, &bogus0);
+
+ ASSERT (bogus0 == 0);
+
+ if (udp0->checksum == 0)
+ udp0->checksum = 0xffff;
+}
+
+static char *hicn_iface_udp4_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+static char *hicn_iface_udp6_output_error_strings[] = {
+#define _(sym, string) string,
+ foreach_hicnfwd_error
+#undef _
+};
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_iface_udp4_output_trace_t;
+
+typedef enum
+{
+ HICN_IFACE_UDP4_OUTPUT_NEXT_LOOKUP,
+ HICN_IFACE_UDP4_OUTPUT_NEXT_ERROR_DROP,
+ HICN_IFACE_UDP4_OUTPUT_N_NEXT,
+} hicn_iface_udp4_output_next_t;
+
+/* Trace context struct */
+typedef struct
+{
+ u32 next_index;
+ u32 sw_if_index;
+ u8 pkt_type;
+} hicn_iface_udp6_output_trace_t;
+
+typedef enum
+{
+ HICN_IFACE_UDP6_OUTPUT_NEXT_LOOKUP,
+ HICN_IFACE_UDP6_OUTPUT_NEXT_ERROR_DROP,
+ HICN_IFACE_UDP6_OUTPUT_N_NEXT,
+} hicn_iface_udp6_output_next_t;
+
+#define ERROR_OUTPUT_UDP4 HICN_IFACE_UDP4_OUTPUT_NEXT_ERROR_DROP
+#define ERROR_OUTPUT_UDP6 HICN_IFACE_UDP6_OUTPUT_NEXT_ERROR_DROP
+
+#define IP_HEADER_4 ip4_header_t
+#define IP_HEADER_6 ip6_header_t
+
+#define NEXT_LOOKUP_UDP4 HICN_IFACE_UDP4_OUTPUT_NEXT_LOOKUP
+#define NEXT_LOOKUP_UDP6 HICN_IFACE_UDP6_OUTPUT_NEXT_LOOKUP
+
+#define HICN_IFACE_UDP_ADD_LOCK_IP4 hicn_dpo_udp4_add_and_lock
+#define HICN_IFACE_UDP_ADD_LOCK_IP6 hicn_dpo_udp6_add_and_lock
+
+#define HICN_FACE_UDP_ENCAP_IP4 hicn_iface_udp4_encap
+#define HICN_FACE_UDP_ENCAP_IP6 hicn_iface_udp6_encap
+
+#define TRACE_OUTPUT_PKT_UDP4 hicn_iface_udp4_output_trace_t
+#define TRACE_OUTPUT_PKT_UDP6 hicn_iface_udp6_output_trace_t
+
+#define iface_output_x1(ipv) \
+ do { \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = ERROR_OUTPUT_UDP##ipv; \
+ hicn_face_t * face; \
+ \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ \
+ face = \
+ hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ \
+ if (PREDICT_TRUE(face != NULL)) \
+ { \
+ HICN_FACE_UDP_ENCAP_IP##ipv \
+ (vm, b0, face); \
+ next0 = NEXT_LOOKUP_UDP##ipv; \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, next0); \
+ } while(0)
+
+#define iface_output_x2(ipv) \
+ do { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = ERROR_OUTPUT_UDP##ipv, next1 = ERROR_OUTPUT_UDP##ipv; \
+ hicn_face_t *face0, *face1; \
+ \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
+ } \
+ \
+ /* Dequeue packets buffers */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ \
+ face0 = \
+ hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ face1 = \
+ hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \
+ \
+ if (PREDICT_TRUE(face0 != NULL)) \
+ { \
+ HICN_FACE_UDP_ENCAP_IP##ipv \
+ (vm, b0, face0); \
+ next0 = NEXT_LOOKUP_UDP##ipv; \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_TRUE(face1 != NULL)) \
+ { \
+ HICN_FACE_UDP_ENCAP_IP##ipv \
+ (vm, b1, face1); \
+ next0 = NEXT_LOOKUP_UDP##ipv; \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_UDP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ } \
+ \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
+ to_next, n_left_to_next, \
+ bi0, bi1, next0, next1); \
+ } while(0)
+
+
+static uword
+hicn_iface_udp4_output_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ iface_output_x2 (4);
+ }
+
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ iface_output_x1 (4);
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+
+ return (frame->n_vectors);
+}
+
+/* packet trace format function */
+static u8 *
+hicn_iface_udp4_output_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_iface_udp4_output_trace_t *t =
+ va_arg (*args, hicn_iface_udp4_output_trace_t *);
+
+ s = format (s, "IFACE_UDP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_iface_udp4_output_node) =
+{
+ .function = hicn_iface_udp4_output_node_fn,
+ .name = "hicn-iface-udp4-output",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_iface_udp4_output_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_iface_udp4_output_error_strings),
+ .error_strings = hicn_iface_udp4_output_error_strings,
+ .n_next_nodes = HICN_IFACE_UDP4_OUTPUT_N_NEXT,
+ /* edit / add dispositions here */
+ .next_nodes =
+ {
+ [HICN_IFACE_UDP4_OUTPUT_NEXT_LOOKUP] = "ip4-lookup",
+ [HICN_IFACE_UDP4_OUTPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+
+static uword
+hicn_iface_udp6_output_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next, next_index;
+ vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ while (n_left_from >= 4 && n_left_to_next >= 2)
+ {
+ iface_output_x2 (6);
+ }
+
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ iface_output_x1 (6);
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+
+ return (frame->n_vectors);
+
+}
+
+/* packet trace format function */
+static u8 *
+hicn_iface_udp6_output_format_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ hicn_iface_udp6_output_trace_t *t =
+ va_arg (*args, hicn_iface_udp6_output_trace_t *);
+
+ s = format (s, "IFACE_UDP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, t->sw_if_index, t->next_index);
+ return (s);
+}
+
+/*
+ * Node registration for the interest forwarder node
+ */
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (hicn_iface_udp6_output_node) =
+{
+ .function = hicn_iface_udp6_output_node_fn,
+ .name = "hicn-iface-udp6-output",
+ .vector_size = sizeof (u32),
+ .format_trace = hicn_iface_udp6_output_format_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_iface_udp6_output_error_strings),
+ .error_strings = hicn_iface_udp6_output_error_strings,
+ .n_next_nodes = HICN_IFACE_UDP6_OUTPUT_N_NEXT,
+ /* edit / add dispositions here */
+ .next_nodes =
+ {
+ [HICN_IFACE_UDP6_OUTPUT_NEXT_LOOKUP] = "ip6-lookup",
+ [HICN_IFACE_UDP6_OUTPUT_NEXT_ERROR_DROP] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/hicn-plugin/src/faces/udp/iface_udp_node.h b/hicn-plugin/src/faces/udp/iface_udp_node.h
new file mode 100755
index 000000000..957d19217
--- /dev/null
+++ b/hicn-plugin/src/faces/udp/iface_udp_node.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HICN_IFACE_UDP_H__
+#define __HICN_IFACE_UDP_H__
+
+#include <vlib/vlib.h>
+
+extern vlib_node_registration_t hicn_iface_udp4_input_node;
+extern vlib_node_registration_t hicn_iface_udp6_input_node;
+extern vlib_node_registration_t hicn_iface_udp4_output_node;
+extern vlib_node_registration_t hicn_iface_udp6_output_node;
+
+void hicn_iface_udp_init (vlib_main_t * vm);
+
+#endif // __HICN_FACE_UDP_H__
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */