aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2020-04-23 14:23:36 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2020-05-04 15:19:41 +0200
commit43d0ecbb1a1f7e1f72bf85441547b1678aed4350 (patch)
tree3da1d867acb6c8b735fbd76eeec51189b5d3996f
parentc1b56d5861829a23289f42cecd716e681b520cf0 (diff)
[HICN-603] Cleanup code for managing route
- Remove old code to add and remove hicn route. Routes are now added only through the ip route commands/apis - Adjusted the cli to set the strategy for a particular prefix - Adjusted libtransport consumer and producer app creation - Adjusted sysrepo plugin. Added hicn enable and disable and removed old api related to hicn routes and hicn faces - Adjusted libhicnctrl. Only routes api and listener are now available for hicn-plugin Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com> Change-Id: Ib4f7f45ba0b99253d60a9da2b295d6e783e5cd51
-rw-r--r--ctrl/libhicnctrl/includes/hicn/ctrl/api.h3
-rw-r--r--ctrl/libhicnctrl/src/hicn_plugin_api.c621
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c6
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c13
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox48
-rw-r--r--ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c1610
-rw-r--r--ctrl/sysrepo-plugins/yang/hicn/hicn.yang509
-rw-r--r--docs/source/control.md59
-rw-r--r--docs/source/vpp-plugin.md88
-rw-r--r--hicn-plugin/src/cli.c92
-rw-r--r--hicn-plugin/src/hicn.api72
-rw-r--r--hicn-plugin/src/hicn_api.c71
-rw-r--r--hicn-plugin/src/hicn_api_test.c161
-rw-r--r--hicn-plugin/src/route.c232
-rw-r--r--hicn-plugin/src/route.h19
-rw-r--r--libtransport/src/core/hicn_forwarder_interface.cc2
-rw-r--r--libtransport/src/core/hicn_forwarder_interface.h2
-rw-r--r--libtransport/src/core/hicn_vapi.c45
-rw-r--r--libtransport/src/core/hicn_vapi.h6
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.cc2
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.h1
21 files changed, 1334 insertions, 2328 deletions
diff --git a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
index c1eccbd17..bdb0c0a5f 100644
--- a/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
+++ b/ctrl/libhicnctrl/includes/hicn/ctrl/api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 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:
@@ -603,6 +603,7 @@ typedef struct {
ip_address_t remote_addr; /* krw */
u8 len; /* krw */
u16 cost; /* .rw */
+ hc_face_t face;
} hc_route_t;
int hc_route_parse(void *in, hc_route_t *route);
diff --git a/ctrl/libhicnctrl/src/hicn_plugin_api.c b/ctrl/libhicnctrl/src/hicn_plugin_api.c
index 63509312a..0b0a9ad54 100644
--- a/ctrl/libhicnctrl/src/hicn_plugin_api.c
+++ b/ctrl/libhicnctrl/src/hicn_plugin_api.c
@@ -34,6 +34,7 @@
#include <strings.h>
#include <vapi/hicn.api.vapi.h>
#include <vapi/ip.api.vapi.h>
+#include <vapi/udp.api.vapi.h>
#include <vapi/interface.api.vapi.h>
#include <hicn/util/log.h>
#include <hicn/util/map.h>
@@ -48,6 +49,7 @@
DEFINE_VAPI_MSG_IDS_HICN_API_JSON
DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON
DEFINE_VAPI_MSG_IDS_IP_API_JSON
+DEFINE_VAPI_MSG_IDS_UDP_API_JSON
typedef struct {
vapi_ctx_t g_vapi_ctx_instance;
@@ -98,12 +100,6 @@ struct hc_sock_s {
_(hicn_api_faces_details) \
_(hicn_api_face_stats_details) \
_(hicn_api_face_get_reply) \
- _(hicn_api_route_nhops_add) \
- _(hicn_api_route_nhops_add_reply) \
- _(hicn_api_route_del) \
- _(hicn_api_route_del_reply) \
- _(hicn_api_route_nhop_del) \
- _(hicn_api_route_nhop_del_reply) \
_(hicn_api_route_get) \
_(hicn_api_route_get_reply) \
_(hicn_api_routes_details) \
@@ -619,12 +615,29 @@ int hc_connection_set_admin_state_async(hc_sock_t *s,
* Routes
*----------------------------------------------------------------------------*/
+vapi_error_e create_udp_tunnel_cb( vapi_ctx_t ctx,
+ void *callback_ctx,
+ vapi_error_e rv,
+ bool is_last,
+ vapi_payload_hicn_api_udp_tunnel_add_del_reply *reply) {
+ if (reply == NULL || rv != VAPI_OK)
+ return rv;
+
+ if (reply->retval != VAPI_OK)
+ return reply->retval;
+
+ u32 * uei = (u32*) callback_ctx;
+ *uei = reply->uei;
+
+ return reply->retval;
+}
+
/* ROUTE CREATE */
vapi_error_e parse_route_create( vapi_ctx_t ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
- vapi_payload_hicn_api_route_nhops_add_reply *reply) {
+ vapi_payload_ip_route_add_del_reply *reply) {
if (reply == NULL || rv != VAPI_OK)
return rv;
@@ -634,31 +647,133 @@ vapi_error_e parse_route_create( vapi_ctx_t ctx,
return reply->retval;
}
+vapi_error_e hicn_enable_cb( vapi_ctx_t ctx,
+ void *callback_ctx,
+ vapi_error_e rv,
+ bool is_last,
+ vapi_payload_hicn_api_enable_disable_reply *reply) {
+ if (reply == NULL || rv != VAPI_OK)
+ return rv;
+
+ return reply->retval;
+}
+
int _hc_route_create(hc_sock_t *s, hc_route_t *route, bool async) {
if (!IS_VALID_FAMILY(route->family)) return -1;
+ int ret;
vapi_lock();
- vapi_msg_hicn_api_route_nhops_add *hicnp_msg;
- hicnp_msg = vapi_alloc_hicn_api_route_nhops_add(s->g_vapi_ctx_instance);
- if (!hicnp_msg) return VAPI_ENOMEM;
+ vapi_msg_ip_route_add_del *hicnp_msg = vapi_alloc_ip_route_add_del(s->g_vapi_ctx_instance, 1);
+ hicnp_msg->payload.is_add = 1;
if (route->family == AF_INET) {
- memcpy(&hicnp_msg->payload.prefix.address.un.ip4[0], &route->remote_addr.v4, 4);
+ memcpy(&hicnp_msg->payload.route.prefix.address.un.ip4[0], &route->remote_addr.v4, 4);
+ hicnp_msg->payload.route.prefix.address.af = ADDRESS_IP4;
}
else {
- memcpy(&hicnp_msg->payload.prefix.address.un.ip6[0], &route->remote_addr.v6, 16);
+ memcpy(&hicnp_msg->payload.route.prefix.address.un.ip6[0], &route->remote_addr.v6, 16);
+ hicnp_msg->payload.route.prefix.address.af = ADDRESS_IP6;
}
- hicnp_msg->payload.prefix.address.af =
- route->family == AF_INET ? ADDRESS_IP4 : ADDRESS_IP6;
- hicnp_msg->payload.prefix.len = route->len;
- hicnp_msg->payload.face_ids[0] = route->face_id;
- hicnp_msg->payload.n_faces = 1;
- vapi_error_e ret = vapi_hicn_api_route_nhops_add(s->g_vapi_ctx_instance, hicnp_msg, parse_route_create, NULL);
+ hicnp_msg->payload.route.prefix.len = route->len;
+
+ hicnp_msg->payload.route.paths[0].sw_if_index = ~0;
+ hicnp_msg->payload.route.paths[0].table_id = 0;
+
+ hc_face_t *face = &(route->face);
+ switch (face->face.type) {
+ case FACE_TYPE_HICN:
+ {
+ if (ip46_address_is_ip4((ip46_address_t *)(&(face->face.remote_addr)))) {
+ memcpy(&(hicnp_msg->payload.route.paths[0].nh.address.ip4), &face->face.remote_addr.v4, sizeof(ip4_address_t));
+ hicnp_msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP4;
+ }
+ else{
+ memcpy(&(hicnp_msg->payload.route.paths[0].nh.address.ip6), &face->face.remote_addr.v6, sizeof(ip6_address_t));
+ hicnp_msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP6;
+ }
+
+ hicnp_msg->payload.route.paths[0].type = FIB_API_PATH_FLAG_NONE;
+ hicnp_msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
+
+ break;
+ }
+ case FACE_TYPE_UDP:
+ {
+ vapi_msg_hicn_api_udp_tunnel_add_del *msg = NULL;
+ u32 uei = ~0;
+
+ if (ip46_address_is_ip4((ip46_address_t *)(&(face->face.remote_addr))) &&
+ ip46_address_is_ip4((ip46_address_t *)(&(face->face.local_addr)))) {
+
+ msg = vapi_alloc_hicn_api_udp_tunnel_add_del(s->g_vapi_ctx_instance);
+ memcpy(msg->payload.src_addr.un.ip4, &face->face.local_addr.v4, sizeof(ip4_address_t));
+ msg->payload.src_addr.af = ADDRESS_IP4;
+
+ memcpy(msg->payload.dst_addr.un.ip4, &face->face.remote_addr.v4, sizeof(ip4_address_t));
+ msg->payload.dst_addr.af = ADDRESS_IP4;
+
+ } else if (!ip46_address_is_ip4((ip46_address_t *)(&(route->face.face.remote_addr))) &&
+ !ip46_address_is_ip4((ip46_address_t *)(&(route->face.face.local_addr)))) {
+
+ msg = vapi_alloc_hicn_api_udp_tunnel_add_del(s->g_vapi_ctx_instance);
+ memcpy(msg->payload.src_addr.un.ip6, &face->face.local_addr.v6, sizeof(ip6_address_t));
+ msg->payload.src_addr.af = ADDRESS_IP4;
+
+ memcpy(msg->payload.dst_addr.un.ip6, &face->face.remote_addr.v6, sizeof(ip6_address_t));
+ msg->payload.dst_addr.af = ADDRESS_IP6;
+
+ } else {
+ //NOT IMPLEMENTED
+ ret = -1;
+ goto done;
+ }
+
+ msg->payload.src_port = face->face.local_port;
+ msg->payload.dst_port = face->face.remote_port;
+ msg->payload.is_add = 1;
+
+ int ret = vapi_hicn_api_udp_tunnel_add_del(s->g_vapi_ctx_instance, msg, create_udp_tunnel_cb, &uei);
+
+ if(ret) {
+ vapi_msg_free(s->g_vapi_ctx_instance, hicnp_msg);
+ goto done;
+ }
+
+ hicnp_msg->payload.route.paths[0].type = FIB_API_PATH_TYPE_UDP_ENCAP;
+ hicnp_msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
+ hicnp_msg->payload.route.paths[0].nh.obj_id = uei;
+ break;
+ }
+ default:
+ ret = -1;
+ goto done;
+ }
+
+ ret = vapi_ip_route_add_del(s->g_vapi_ctx_instance, hicnp_msg, parse_route_create, NULL);
+
+ if (ret)
+ goto done;
+
+ vapi_msg_hicn_api_enable_disable *msg = vapi_alloc_hicn_api_enable_disable(s->g_vapi_ctx_instance);
+
+ if (route->family == AF_INET) {
+ memcpy(&msg->payload.prefix.address.un.ip4[0], &route->remote_addr.v4, 4);
+ msg->payload.prefix.address.af = ADDRESS_IP4;
+ }
+ else {
+ memcpy(&msg->payload.prefix.address.un.ip6[0], &route->remote_addr.v6, 16);
+ msg->payload.prefix.address.af = ADDRESS_IP6;
+ }
+
+ msg->payload.prefix.len = route->len;
+ msg->payload.enable_disable = 1;
+
+ ret = vapi_hicn_api_enable_disable(s->g_vapi_ctx_instance, msg, hicn_enable_cb, NULL);
+done:
vapi_unlock();
return ret;
-
}
int hc_route_create(hc_sock_t *s, hc_route_t *route) {
@@ -674,13 +789,10 @@ vapi_error_e parse_route_delete( vapi_ctx_t ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
- vapi_payload_hicn_api_route_nhop_del_reply *reply) {
+ vapi_payload_ip_route_add_del_reply *reply) {
if (reply == NULL || rv != VAPI_OK)
return rv;
- if (reply->retval != VAPI_OK)
- return reply->retval;
-
return reply->retval;
}
@@ -688,20 +800,56 @@ int _hc_route_delete(hc_sock_t *s, hc_route_t *route, bool async) {
if (!IS_VALID_FAMILY(route->family)) return -1;
vapi_lock();
- vapi_msg_hicn_api_route_nhop_del *hicnp_msg;
- hicnp_msg = vapi_alloc_hicn_api_route_nhop_del(s->g_vapi_ctx_instance);
+ vapi_msg_ip_route_add_del *hicnp_msg = vapi_alloc_ip_route_add_del(s->g_vapi_ctx_instance, 1);
+
+ hicnp_msg->payload.is_add = 0;
+ if (route->family == AF_INET) {
+ memcpy(&hicnp_msg->payload.route.prefix.address.un.ip4[0], &route->remote_addr.v4, 4);
+ hicnp_msg->payload.route.prefix.address.af = ADDRESS_IP4;
+ }
+ else {
+ memcpy(&hicnp_msg->payload.route.prefix.address.un.ip6[0], &route->remote_addr.v6, 16);
+ hicnp_msg->payload.route.prefix.address.af = ADDRESS_IP6;
+ }
- if (!hicnp_msg) return VAPI_ENOMEM;
+ hicnp_msg->payload.route.prefix.len = route->len;
- memcpy(&hicnp_msg->payload.prefix.address.un.ip6[0], &route->remote_addr, 16);
- hicnp_msg->payload.prefix.address.af =
- route->family == AF_INET ? ADDRESS_IP4 : ADDRESS_IP6;
- hicnp_msg->payload.prefix.len = route->len;
- hicnp_msg->payload.faceid = route->face_id;
+ hicnp_msg->payload.route.paths[0].sw_if_index = ~0;
+ hicnp_msg->payload.route.paths[0].table_id = 0;
+
+ hc_face_t *face = &(route->face);
+ switch (face->face.type) {
+ case FACE_TYPE_HICN:
+ {
+ if (ip46_address_is_ip4((ip46_address_t *)(&(face->face.remote_addr)))) {
+ memcpy(&(hicnp_msg->payload.route.paths[0].nh.address.ip4), &face->face.remote_addr.v4, sizeof(ip4_address_t));
+ hicnp_msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP4;
+ }
+ else{
+ memcpy(&(hicnp_msg->payload.route.paths[0].nh.address.ip6), &face->face.remote_addr.v6, sizeof(ip6_address_t));
+ hicnp_msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP6;
+ }
+
+ hicnp_msg->payload.route.paths[0].type = FIB_API_PATH_FLAG_NONE;
+ hicnp_msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
+
+ break;
+ }
+ case FACE_TYPE_UDP:
+ {
+ hicnp_msg->payload.route.paths[0].type = FIB_API_PATH_TYPE_UDP_ENCAP;
+ hicnp_msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
+ hicnp_msg->payload.route.paths[0].nh.obj_id = face->face.netdevice.index;
+ break;
+ }
+ default:
+ return -1;
+ }
+
+ vapi_error_e ret = vapi_ip_route_add_del(s->g_vapi_ctx_instance, hicnp_msg, parse_route_delete, NULL);
- int retval = vapi_hicn_api_route_nhop_del(s->g_vapi_ctx_instance, hicnp_msg, parse_route_delete, NULL);
vapi_unlock();
- return retval;
+ return ret;
}
int hc_route_delete(hc_sock_t *s, hc_route_t *route) {
@@ -712,18 +860,121 @@ int hc_route_delete_async(hc_sock_t *s, hc_route_t *route) {
return _hc_route_delete(s, route, true);
}
+vapi_error_e parse_udp_encap_list( vapi_ctx_t ctx,
+ void *callback_ctx,
+ vapi_error_e rv,
+ bool is_last,
+ vapi_payload_udp_encap_details *reply) {
+ if (reply == NULL || rv != VAPI_OK)
+ return rv;
+
+ hc_face_t * face = (hc_face_t *)callback_ctx;
+
+ if (face->face.netdevice.index == reply->udp_encap.id)
+ {
+ switch(reply->udp_encap.src_ip.af) {
+ case ADDRESS_IP4:
+ {
+ memcpy(&face->face.local_addr.v4, &(reply->udp_encap.src_ip.un.ip4), sizeof(ip4_address_t));
+ memcpy(&face->face.remote_addr.v4, &(reply->udp_encap.dst_ip.un.ip4), sizeof(ip4_address_t));
+ break;
+ }
+ case ADDRESS_IP6:
+ {
+ memcpy(&face->face.local_addr.v6, &(reply->udp_encap.src_ip.un.ip6), sizeof(ip6_address_t));
+ memcpy(&face->face.remote_addr.v6, &(reply->udp_encap.dst_ip.un.ip6), sizeof(ip6_address_t));
+ break;
+ }
+ default:
+ break;
+ }
+
+ face->face.local_port = reply->udp_encap.src_port;
+ face->face.remote_port = reply->udp_encap.dst_port;
+ }
+ return rv;
+}
+
+int fill_face_with_info(hc_face_t * face, vapi_type_fib_path *path, hc_sock_t *s) {
+ switch(path->type){
+ case FIB_API_PATH_FLAG_NONE:
+ {
+ face->face.type = FACE_TYPE_HICN;
+ switch(path->proto){
+ case FIB_API_PATH_NH_PROTO_IP4:
+ memcpy(&face->face.remote_addr.v4, &(path->nh.address.ip4), sizeof(ip4_address_t));
+ break;
+ case FIB_API_PATH_NH_PROTO_IP6:
+ memcpy(&face->face.remote_addr.v6, &(path->nh.address.ip6), sizeof(ip6_address_t));
+ break;
+ default:
+ break;
+ }
+ face->face.netdevice.index = path->sw_if_index;
+ }
+ break;
+ case FIB_API_PATH_TYPE_UDP_ENCAP:
+ {
+ face->face.type = FACE_TYPE_UDP;
+ face->face.netdevice.index = clib_net_to_host_u32(path->nh.obj_id);
+ //vapi_msg_udp_encap_dump *msg;
+ //msg = vapi_alloc_udp_encap_dump(s->g_vapi_ctx_instance);
+ //vapi_udp_encap_dump(s->g_vapi_ctx_instance, msg, parse_udp_encap_list, face);
+ }
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
/* ROUTE LIST */
+typedef struct hicn_route_socket_s {
+ hc_data_t *data;
+ hc_sock_t *s;
+} hicn_route_socket_t;
+
vapi_error_e parse_route_list( vapi_ctx_t ctx,
void *callback_ctx,
vapi_error_e rv,
bool is_last,
- vapi_payload_hicn_api_routes_details *reply) {
+ vapi_payload_ip_route_details *reply) {
if (reply == NULL || rv != VAPI_OK)
return rv;
- if (reply->retval != VAPI_OK)
- return reply->retval;
+ hicn_route_socket_t *rs = (hicn_route_socket_t *)callback_ctx;
+ hc_data_t *data = rs->data;
+
+ u8 found = false;
+ for (int j = 0; j < reply->route.n_paths; j++){
+ for (int i = 0; i < data->size && !found; i++) {
+ hc_route_t * route = &((hc_route_t*)(data->buffer))[i];
+
+ if(ip46_address_is_ip4((ip46_address_t *)&(route->remote_addr)) &&
+ memcmp(route->remote_addr.v4.as_u8, reply->route.prefix.address.un.ip4, sizeof(ip4_address_t)) == 0 &&
+ route->len == reply->route.prefix.len && route->face_id == ~0) {
+ fill_face_with_info(&(route->face), &reply->route.paths[j], rs->s);
+ found = true;
+ } else if (memcmp(route->remote_addr.v6.as_u8, reply->route.prefix.address.un.ip6, sizeof(ip6_address_t)) == 0 &&
+ route->len == reply->route.prefix.len && route->face_id == ~0) {
+ fill_face_with_info(&(route->face), &reply->route.paths[j], rs->s);
+ found = true;
+ }
+ }
+ }
+
+ return rv;
+}
+
+vapi_error_e parse_hicn_route_list( vapi_ctx_t ctx,
+ void *callback_ctx,
+ vapi_error_e rv,
+ bool is_last,
+ vapi_payload_hicn_api_routes_details *reply) {
+
+ if (reply == NULL || rv != VAPI_OK)
+ return rv;
hc_data_t *data = (hc_data_t *)callback_ctx;
@@ -739,7 +990,7 @@ vapi_error_e parse_route_list( vapi_ctx_t ctx,
for (int i = 0; i < reply->nfaces; i++) {
hc_route_t * route = &((hc_route_t*)(data->buffer))[data->current];
- route->face_id = reply->faceids[i];
+ route->face_id = ~0;
route->cost = 1;
route->len = reply->prefix.len;
if (reply->prefix.address.af == ADDRESS_IP6)
@@ -754,13 +1005,14 @@ vapi_error_e parse_route_list( vapi_ctx_t ctx,
data->current++;
}
- return reply->retval;
+ return rv;
}
int _hc_route_list(hc_sock_t *s, hc_data_t **pdata, bool async) {
vapi_lock();
- vapi_msg_hicn_api_routes_dump *hicnp_msg;
- hicnp_msg = vapi_alloc_hicn_api_routes_dump(s->g_vapi_ctx_instance);
+
+ vapi_msg_hicn_api_routes_dump *msg;
+ msg = vapi_alloc_hicn_api_routes_dump(s->g_vapi_ctx_instance);
hc_data_t *data = hc_data_create(0, sizeof(hc_route_t),NULL);
int ret = VAPI_OK;
@@ -778,7 +1030,28 @@ int _hc_route_list(hc_sock_t *s, hc_data_t **pdata, bool async) {
goto err_free;
}
- ret = vapi_hicn_api_routes_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_route_list, data);
+ ret = vapi_hicn_api_routes_dump(s->g_vapi_ctx_instance, msg, parse_hicn_route_list, data);
+
+ if (ret != VAPI_OK)
+ goto err_free;
+
+ vapi_msg_ip_route_dump *hicnp_msg;
+ hicnp_msg = vapi_alloc_ip_route_dump(s->g_vapi_ctx_instance);
+ hicnp_msg->payload.table.table_id = 0;
+ hicnp_msg->payload.table.is_ip6 = 1;
+
+ hicn_route_socket_t ctx = {
+ .data = data,
+ .s = s,
+ };
+
+ ret = vapi_ip_route_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_route_list, &ctx);
+
+ hicnp_msg = vapi_alloc_ip_route_dump(s->g_vapi_ctx_instance);
+ hicnp_msg->payload.table.table_id = 0;
+ hicnp_msg->payload.table.is_ip6 = 0;
+
+ ret = vapi_ip_route_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_route_list, &ctx);
if (ret != VAPI_OK)
goto err_free;
@@ -877,282 +1150,22 @@ int hc_connection_to_local_listener(const hc_connection_t *connection,
return 0;
}
-/* FACE CREATE */
-// vapi_error_e parse_face_create( vapi_ctx_t ctx,
-// void *callback_ctx,
-// vapi_error_e rv,
-// bool is_last,
-// vapi_payload_hicn_api_face_add_reply *reply) {
-
-// if (reply == NULL || rv != VAPI_OK)
-// return rv;
-
-// if (reply->retval != VAPI_OK)
-// return reply->retval;
-
-// hc_data_t *data = (hc_data_t *)callback_ctx;
-
-// hc_face_t *output = (hc_face_t *)data->buffer;
-
-// output->id = reply->faceid;
-// return reply->retval;
-// }
-
int hc_face_create(hc_sock_t *s, hc_face_t *face) {
-
- // vapi_lock();
- // vapi_msg_hicn_api_face_add *hicnp_msg;
- // hicnp_msg = vapi_alloc_hicn_api_face_add(s->g_vapi_ctx_instance);
-
- // int retval = VAPI_OK;
-// if (!hicnp_msg) {
-// retval = VAPI_ENOMEM;
-// goto END;
-// }
-
-// switch(face->face.type) {
-// case FACE_TYPE_HICN:
-// {
-// u8 check = ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr)) == ip46_address_is_ip4((ip46_address_t *)&(face->face.remote_addr));
-// if (!check) {
-// retval = -1;
-// goto END;
-// }
-
-// hicnp_msg->payload.type = IP_FACE;
-// if (ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr)))
-// {
-// memcpy(hicnp_msg->payload.face.ip.local_addr.un.ip4, face->face.local_addr.v4.as_u8, 4);
-// memcpy(hicnp_msg->payload.face.ip.remote_addr.un.ip4, face->face.remote_addr.v4.as_u8, 4);
-// hicnp_msg->payload.face.ip.local_addr.af = ADDRESS_IP4;
-// hicnp_msg->payload.face.ip.remote_addr.af = ADDRESS_IP4;
-// }
-// else
-// {
-// memcpy(hicnp_msg->payload.face.ip.local_addr.un.ip6, face->face.local_addr.v6.as_u8, 16);
-// memcpy(hicnp_msg->payload.face.ip.remote_addr.un.ip6, face->face.remote_addr.v6.as_u8, 16);
-// hicnp_msg->payload.face.ip.local_addr.af = ADDRESS_IP6;
-// hicnp_msg->payload.face.ip.remote_addr.af = ADDRESS_IP6;
-// }
-// hicnp_msg->payload.face.ip.swif = face->face.netdevice.index;
-// memcpy(hicnp_msg->payload.face.ip.if_name, face->face.netdevice.name, IFNAMSIZ);
-// break;
-// }
-// case FACE_TYPE_UDP:
-// {
-// u8 check = ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr)) == ip46_address_is_ip4((ip46_address_t *)&(face->face.remote_addr));
-// if (!check) {
-// retval = -1;
-// goto END;
-// }
-
-// hicnp_msg->payload.type = UDP_FACE;
-// if (ip46_address_is_ip4((ip46_address_t *)&(face->face.local_addr)))
-// {
-// memcpy(hicnp_msg->payload.face.udp.local_addr.un.ip4, face->face.local_addr.v4.as_u8, 4);
-// memcpy(hicnp_msg->payload.face.udp.remote_addr.un.ip4, face->face.remote_addr.v4.as_u8, 4);
-// hicnp_msg->payload.face.udp.local_addr.af = ADDRESS_IP4;
-// hicnp_msg->payload.face.udp.remote_addr.af = ADDRESS_IP4;
-// }
-// else
-// {
-// memcpy(hicnp_msg->payload.face.udp.local_addr.un.ip6, face->face.local_addr.v6.as_u8, 16);
-// memcpy(hicnp_msg->payload.face.udp.remote_addr.un.ip6, face->face.remote_addr.v6.as_u8, 16);
-// hicnp_msg->payload.face.udp.local_addr.af = ADDRESS_IP6;
-// hicnp_msg->payload.face.udp.remote_addr.af = ADDRESS_IP6;
-// }
-// hicnp_msg->payload.face.udp.lport = face->face.local_port;
-// hicnp_msg->payload.face.udp.rport = face->face.remote_port;
-// hicnp_msg->payload.face.udp.swif = face->face.netdevice.index;
-// memcpy(hicnp_msg->payload.face.udp.if_name, face->face.netdevice.name, IFNAMSIZ);
-// break;
-// }
-// default:
-// {
-// retval = -1;
-// goto END;
-// }
-// }
-
-// hc_data_t *data = hc_data_create(0, sizeof(hc_face_t),NULL);
-
-// if (!data) {
-// retval = -1;
-// goto END;
-// }
-
-// data->buffer = malloc(sizeof(hc_face_t));
-// data->out_element_size = sizeof(hc_face_t);
-
-// if (!data->buffer) {
-// free (data);
-// retval = -1;
-// goto END;
-// }
-
-// retval = vapi_hicn_api_face_add(s->g_vapi_ctx_instance, hicnp_msg, parse_face_create, data);
-
-// if (retval != VAPI_OK)
-// goto END;
-
-// face->id = ((hc_face_t *)data->buffer)->id;
-
-// END:
-// vapi_unlock();
- ERROR("hc_punting_snprintf not (yet) implemented.");
+ ERROR("Face creation implemented.");
return -1;
}
-// vapi_error_e parse_face_delete( vapi_ctx_t ctx,
-// void *callback_ctx,
-// vapi_error_e rv,
-// bool is_last,
-// vapi_payload_hicn_api_face_del_reply *reply) {
-
-// if (reply == NULL || rv != VAPI_OK)
-// return rv;
-
-// return reply->retval;
-// }
-
int hc_face_delete(hc_sock_t *s, hc_face_t *face) {
- // vapi_msg_hicn_api_face_del *hicnp_msg;
- // vapi_lock();
- // hicnp_msg = vapi_alloc_hicn_api_face_del(s->g_vapi_ctx_instance);
-
- // if (!hicnp_msg) return VAPI_ENOMEM;
-
- // hicnp_msg->payload.faceid = face->id;
-
- // int retval = vapi_hicn_api_face_del(s->g_vapi_ctx_instance, hicnp_msg, parse_face_delete, NULL);
- // vapi_unlock();
- // return retval;
- ERROR("hc_punting_snprintf not (yet) implemented.");
+ ERROR("Face deletion not implemented.");
return -1;
}
/* FACE LIST */
-// vapi_error_e parse_face_list( vapi_ctx_t ctx,
-// void *callback_ctx,
-// vapi_error_e rv,
-// bool is_last,
-// vapi_payload_hicn_api_faces_details *reply) {
-
-// if (reply == NULL || rv != VAPI_OK)
-// return rv;
-
-// if (reply->retval != VAPI_OK)
-// return reply->retval;
-
-// hc_data_t *data = (hc_data_t *)callback_ctx;
-
-// if (data->size == data->current) {
-// int new_size = data->size *2;
-// data->buffer = realloc(data->buffer, sizeof(hc_face_t) * (new_size));
-// if (!data->buffer)
-// return VAPI_ENOMEM;
-
-// data->size =new_size;
-// }
-
-// int retval = VAPI_OK;
-
-// hc_face_t * face = &((hc_face_t *)(data->buffer))[data->current];
-// switch(reply->type)
-// {
-// case IP_FACE:
-// {
-// if (reply->face.ip.local_addr.af == ADDRESS_IP4)
-// {
-// memcpy(face->face.local_addr.v4.as_u8, reply->face.ip.local_addr.un.ip4, IPV4_ADDR_LEN);
-// memcpy(face->face.remote_addr.v4.as_u8, reply->face.ip.remote_addr.un.ip4, IPV4_ADDR_LEN);
-// }
-// else
-// {
-// memcpy(face->face.local_addr.v6.as_u8, reply->face.ip.local_addr.un.ip6, IPV6_ADDR_LEN);
-// memcpy(face->face.remote_addr.v6.as_u8, reply->face.ip.remote_addr.un.ip6, IPV6_ADDR_LEN);
-// }
-// face->face.type = FACE_TYPE_HICN;
-// face->id = reply->faceid;
-// face->face.netdevice.index = reply->face.ip.swif;
-// memcpy(face->face.netdevice.name, reply->face.ip.if_name, IFNAMSIZ);
-// break;
-// }
-// case UDP_FACE:
-// {
-// if (reply->face.ip.local_addr.af == ADDRESS_IP4)
-// {
-// memcpy(face->face.local_addr.v4.as_u8, reply->face.udp.local_addr.un.ip4, IPV4_ADDR_LEN);
-// memcpy(face->face.remote_addr.v4.as_u8, reply->face.udp.remote_addr.un.ip4, IPV4_ADDR_LEN);
-// }
-// else
-// {
-// memcpy(face->face.local_addr.v6.as_u8, reply->face.udp.local_addr.un.ip6, IPV6_ADDR_LEN);
-// memcpy(face->face.remote_addr.v6.as_u8, reply->face.udp.remote_addr.un.ip6, IPV6_ADDR_LEN);
-// }
-// face->face.local_port = reply->face.udp.lport;
-// face->face.remote_port = reply->face.udp.rport;
-// face->face.type = FACE_TYPE_UDP;
-// face->id = reply->faceid;
-// face->face.netdevice.index = reply->face.udp.swif;
-// memcpy(face->face.netdevice.name, reply->face.udp.if_name, IFNAMSIZ);
-// break;
-// }
-// default:
-// retval = -1;
-// }
-// if (!retval)
-// data->current++;
-
-// return reply->retval;
-// }
-
int hc_face_list(hc_sock_t *s, hc_data_t **pdata) {
-// vapi_lock();
-// vapi_msg_hicn_api_faces_dump *hicnp_msg;
-// hicnp_msg = vapi_alloc_hicn_api_faces_dump(s->g_vapi_ctx_instance);
-
-// int retval = 0;
-// if (!hicnp_msg) {
-// retval = VAPI_ENOMEM;
-// goto END;
-// }
-
-// hc_data_t *data = hc_data_create(0, sizeof(hc_face_t),NULL);
-
-// if (!data) {
-// retval = -1;
-// goto END;
-// }
-
-// data->buffer = malloc(sizeof(hc_face_t));
-// data->size = 1;
-
-// if (!data->buffer) {
-// free (data);
-// retval = -1;
-// goto err;
-// }
-
-
-// retval = vapi_hicn_api_faces_dump(s->g_vapi_ctx_instance, hicnp_msg, parse_face_list, data);
-// *pdata = data;
-
-// if (retval != VAPI_OK)
-// goto err;
-
-// data->size = data->current;
-// vapi_unlock();
-// return retval;
-// err:
-// free(data);
-// END:
-// vapi_unlock();
-// return retval;
-ERROR("hc_punting_snprintf not (yet) implemented.");
+ERROR("Face list not implemented.");
return -1;
}
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c
index dc3ac16d4..bbcc2e9bf 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Copyright (c) 2019-2020 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:
@@ -38,8 +38,10 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) {
// HICN subscribe
hicn_subscribe_events(session, &subscription);
+ //sr_subscription_ctx_t *subscription2 = NULL;
+
// IETF subscribe
- ietf_subscribe_events(session, &subscription);
+ //ietf_subscribe_events(session, &subscription2);
/* set subscription as our private context */
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c
index b46b38b89..3e0c90cf9 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Copyright (c) 2016-2020 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:
@@ -442,7 +442,7 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *mo
sr_change_oper_t op = SR_OP_CREATED;
sr_val_t *old_val = NULL;
sr_val_t *new_val = NULL;
- sr_xpath_ctx_t xpath_ctx = { 0, };
+ sr_xpath_ctx_t xpath_ctx = { 0 };
bool is_ipv6 = false, has_addr = false, has_prefix = false;
uint8_t addr[16] = { 0, };
uint8_t prefix = 0;
@@ -570,7 +570,8 @@ int ietf_subscribe_events(sr_session_ctx_t *session,
goto error;
}
- rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address", ietf_interface_ipv46_address_change_cb,
+ //rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address", ietf_interface_ipv46_address_change_cb,
+ rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces", ietf_interface_ipv46_address_change_cb,
NULL,
99, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_ENABLED, subscription);
@@ -579,9 +580,9 @@ int ietf_subscribe_events(sr_session_ctx_t *session,
goto error;
}
- rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address", ietf_interface_ipv46_address_change_cb,
- NULL,
- 98, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_ENABLED, subscription);
+ //rc = sr_module_change_subscribe(session, "ietf-interfaces","/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address", ietf_interface_ipv46_address_change_cb,
+ // NULL,
+ // 98, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_ENABLED, subscription);
if (rc != SR_ERR_OK) {
SRP_LOG_DBGMSG("Problem in subscription /ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address\n");
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox b/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox
index dc4289379..978578039 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/mainpage.dox
@@ -29,47 +29,13 @@ fi
*Here you can find different examples to run RPC in the yang-model.
```
-<face-ip-add xmlns="urn:sysrepo:hicn">
- <lip4>192.168.1.10</lip4>
- <lip6>-1</lip6>
- <rip4>192.168.1.1</rip4>
- <rip6>-1</rip6>
- <swif>0</swif>
-</face-ip-add>
-
-<route-nhops-add xmlns="urn:sysrepo:hicn">
- <ip4>192.168.1.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
- <face_ids0>0</face_ids0>
- <face_ids1>0</face_ids1>
- <face_ids2>0</face_ids2>
- <face_ids3>0</face_ids3>
- <face_ids4>0</face_ids4>
- <face_ids5>0</face_ids5>
- <face_ids6>0</face_ids6>
- <n_faces>1</n_faces>
-</route-nhops-add>
-
-<route-nhops-del xmlns="urn:sysrepo:hicn">
- <ip4>192.168.1.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
- <faceid>0</faceid>
-</route-nhops-del>
-
-
-<face-ip-del xmlns="urn:sysrepo:hicn">
- <faceid>0</faceid>
-</face-ip-del>
-
-
-<punting-del-ip xmlns="urn:sysrepo:hicn">
- <ip4>192.168.0.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
- <swif>0</swif>
-</punting-del-ip>
+<hicn-enable xmlns="urn:sysrepo:hicn">
+ <prefix>b001::/64</prefix>
+</hicn-enable>
+
+<hicn-disable xmlns="urn:sysrepo:hicn">
+ <prefix>b001::/64</prefix>
+</hicn-disable>
```
*/
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
index 0e0a9104b..63685e10a 100644
--- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
+++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
@@ -1,1013 +1,875 @@
/*
-* Copyright (c) 2019-2020 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) 2019-2020 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 hicn_model.c
* @brief This file contains implementations of the main calls
*/
-
#define _GNU_SOURCE
-#include <stdio.h>
-#include <malloc.h>
-#include <sysrepo/xpath.h>
#include <inttypes.h>
-#include <unistd.h>
+#include <malloc.h>
#include <pthread.h>
-
-
-
#include <sched.h>
+#include <stdio.h>
+#include <string.h>
+#include <sysrepo/xpath.h>
+#include <unistd.h>
/* Hicn headers */
#include <hicn/util/ip_address.h>
+
#include "../hicn_plugin.h"
#include "../hicn_vpp_comm.h"
#include "hicn_model.h"
#include "tlock.h"
-
DEFINE_VAPI_MSG_IDS_HICN_API_JSON
-
// Shared local variables between state and RPCs
/**
* @brief this shared variable keeps the hicn state
*/
-volatile hicn_state_t * hicn_state = NULL;
+volatile hicn_state_t *hicn_state = NULL;
/**
* @brief this shared variable keeps hicn strategies
*/
-volatile hicn_strategies_t * hicn_strategies =NULL;
+volatile hicn_strategies_t *hicn_strategies = NULL;
/**
* @brief this shared variable keeps statistics of hicn faces
*/
-volatile hicn_faces_t * hicn_faces = NULL;
+volatile hicn_faces_t *hicn_faces = NULL;
/**
* @brief this shared variable keeps routes information in hicn
*/
-volatile hicn_routes_t * hicn_routes = NULL;
+volatile hicn_routes_t *hicn_routes = NULL;
/**
- * @brief this shared variable is the link list to maintain all the faces (up to MAX_FACES)
+ * @brief this shared variable is the link list to maintain all the faces (up to
+ * MAX_FACES)
*/
-struct hicn_faces_s * fcurrent = NULL;
+struct hicn_faces_s *fcurrent = NULL;
/**
* @brief this shared variable is the link list to maintain all the routes
*/
-struct hicn_routes_s * rcurrent = NULL;
+struct hicn_routes_s *rcurrent = NULL;
+static int init_buffer(void) {
+ hicn_state = memalign(MEM_ALIGN, sizeof(hicn_state_t));
+ memset((hicn_state_t *)hicn_state, 0, sizeof(hicn_state_t));
-static int init_buffer(void){
+ hicn_strategies = memalign(MEM_ALIGN, sizeof(hicn_strategies_t));
+ memset((hicn_strategies_t *)hicn_strategies, 0, sizeof(hicn_strategies_t));
- hicn_state = memalign(MEM_ALIGN, sizeof(hicn_state_t) );
- memset((hicn_state_t *)hicn_state, 0 , sizeof(hicn_state_t) );
+ hicn_faces = memalign(MEM_ALIGN, sizeof(hicn_faces_t));
+ hicn_faces->next = memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
+ fcurrent = hicn_faces->next;
- hicn_strategies = memalign(MEM_ALIGN, sizeof(hicn_strategies_t) );
- memset((hicn_strategies_t *) hicn_strategies, 0 , sizeof(hicn_strategies_t) );
+ hicn_routes = memalign(MEM_ALIGN, sizeof(hicn_routes_t));
+ hicn_routes->next = memalign(MEM_ALIGN, sizeof(struct hicn_routes_s));
+ rcurrent = hicn_routes->next;
- hicn_faces = memalign(MEM_ALIGN, sizeof(hicn_faces_t) );
- hicn_faces->next=memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
- fcurrent=hicn_faces->next;
+ int retval = -1;
+ ARG_CHECK5(retval, hicn_state, hicn_strategies, fcurrent, hicn_faces,
+ hicn_routes);
+ hicn_routes->nroute = 0;
+ hicn_faces->nface = 0;
+ retval = 0;
-
- hicn_routes = memalign(MEM_ALIGN, sizeof(hicn_routes_t) );
- hicn_routes->next=memalign(MEM_ALIGN, sizeof(struct hicn_routes_s));
- rcurrent=hicn_routes->next;
-
-
- int retval=-1;
- ARG_CHECK5(retval, hicn_state, hicn_strategies, fcurrent, hicn_faces, hicn_routes);
- hicn_routes->nroute=0;
- hicn_faces->nface=0;
- retval=0;
-
- return retval;
+ return retval;
}
-static int init_face_pool(struct hicn_faces_s * head){
-
- for(int i=0; i<MAX_FACE_POOL; i++){
- head->next=memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
- head=head->next;
- }
- SRP_LOG_DBGMSG("Face memory pool allocated\n");
- head->next=NULL;
- return 0;
-
+static int init_face_pool(struct hicn_faces_s *head) {
+ for (int i = 0; i < MAX_FACE_POOL; i++) {
+ head->next = memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
+ head = head->next;
+ }
+ SRP_LOG_DBGMSG("Face memory pool allocated\n");
+ head->next = NULL;
+ return 0;
}
-static int init_route_pool(struct hicn_routes_s * head){
-
- for(int i=0; i<MAX_ROUTE_POOL; i++){
- head->next=memalign(MEM_ALIGN, sizeof(struct hicn_routes_s));
- head=head->next;
- }
- SRP_LOG_DBGMSG("Route memory pool allocated\n");
- head->next=NULL;
- return 0;
-
+static int init_route_pool(struct hicn_routes_s *head) {
+ for (int i = 0; i < MAX_ROUTE_POOL; i++) {
+ head->next = memalign(MEM_ALIGN, sizeof(struct hicn_routes_s));
+ head = head->next;
+ }
+ SRP_LOG_DBGMSG("Route memory pool allocated\n");
+ head->next = NULL;
+ return 0;
}
/* VAPI CALLBACKS */
-static vapi_error_e call_hicn_api_strategies_get(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_strategies_get_reply *reply){
-if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
-
-static vapi_error_e call_hicn_api_route_nhops_add(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_route_nhops_add_reply *reply){
-if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
-}
-
-static vapi_error_e call_hicn_api_route_del(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_route_del_reply *reply){
-
-if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
+static vapi_error_e call_hicn_api_strategies_get(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_strategies_get_reply *reply) {
+ if (!reply->retval) {
+ SRP_LOG_DBGMSG("Successfully done");
+ return VAPI_OK;
+ } else
+ return VAPI_EUSER;
}
-static vapi_error_e call_hicn_api_face_params_get(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_face_params_get_reply *reply){
-if(!reply->retval){
- if (callback_ctx!=NULL){
- struct hicn_faces_s * tmp;
- tmp = (struct hicn_faces_s *) callback_ctx;
+static vapi_error_e call_hicn_api_face_params_get(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_face_params_get_reply *reply) {
+ if (!reply->retval) {
+ if (callback_ctx != NULL) {
+ struct hicn_faces_s *tmp;
+ tmp = (struct hicn_faces_s *)callback_ctx;
tmp->face.intfc = reply->swif;
- }
- return VAPI_OK;
- }else
- return VAPI_EUSER;
+ }
+ return VAPI_OK;
+ } else
+ return VAPI_EUSER;
}
-static vapi_error_e call_hicn_api_route_nhop_del(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_route_nhop_del_reply *reply){
-if(!reply->retval){
- SRP_LOG_DBGMSG("Successfully done");
- return VAPI_OK;
- }else
- return VAPI_EUSER;
+static vapi_error_e call_vapi_hicn_api_node_stats_get(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_node_stats_get_reply *reply) {
+ if (!reply->retval) {
+ hicn_state->pkts_processed = reply->pkts_processed;
+ hicn_state->pkts_interest_count = reply->pkts_interest_count;
+ hicn_state->pkts_data_count = reply->pkts_data_count;
+ hicn_state->pkts_from_cache_count = reply->pkts_from_cache_count;
+ hicn_state->pkts_no_pit_count = reply->pkts_no_pit_count;
+ hicn_state->pit_expired_count = reply->pit_expired_count;
+ hicn_state->cs_expired_count = reply->cs_expired_count;
+ hicn_state->cs_lru_count = reply->cs_lru_count;
+ hicn_state->pkts_drop_no_buf = reply->pkts_drop_no_buf;
+ hicn_state->interests_aggregated = reply->interests_aggregated;
+ hicn_state->interests_retx = reply->interests_retx;
+ hicn_state->pit_entries_count = reply->pit_entries_count;
+ hicn_state->cs_entries_count = reply->cs_entries_count;
+ hicn_state->cs_entries_ntw_count = reply->cs_entries_ntw_count;
+ return VAPI_OK;
+ } else
+ return VAPI_EUSER;
}
-static vapi_error_e call_vapi_hicn_api_node_stats_get(struct vapi_ctx_s *ctx,
- void *callback_ctx,
- vapi_error_e rv,
- bool is_last,
- vapi_payload_hicn_api_node_stats_get_reply *reply){
-
-
-if(!reply->retval){
- hicn_state->pkts_processed = reply->pkts_processed;
- hicn_state->pkts_interest_count = reply->pkts_interest_count;
- hicn_state->pkts_data_count = reply->pkts_data_count;
- hicn_state->pkts_from_cache_count = reply->pkts_from_cache_count;
- hicn_state->pkts_no_pit_count = reply->pkts_no_pit_count;
- hicn_state->pit_expired_count = reply->pit_expired_count;
- hicn_state->cs_expired_count = reply->cs_expired_count;
- hicn_state->cs_lru_count = reply->cs_lru_count;
- hicn_state->pkts_drop_no_buf = reply->pkts_drop_no_buf;
- hicn_state->interests_aggregated = reply->interests_aggregated;
- hicn_state->interests_retx = reply->interests_retx;
- hicn_state->pit_entries_count = reply->pit_entries_count;
- hicn_state->cs_entries_count = reply->cs_entries_count;
- hicn_state->cs_entries_ntw_count = reply->cs_entries_ntw_count;
- return VAPI_OK;
- }else
- return VAPI_EUSER;
+static inline void state_update(sr_val_t *vals, struct lyd_node **parent,
+ sr_session_ctx_t *session) {
+ char buf[20];
+
+ sr_val_set_xpath(&vals[0], "/hicn:hicn-state/states/pkts_processed");
+ vals[0].type = SR_UINT64_T;
+ vals[0].data.uint64_val = hicn_state->pkts_processed;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_processed);
+ *parent =
+ lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)),
+ vals[0].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[1], "/hicn:hicn-state/states/pkts_interest_count");
+ vals[1].type = SR_UINT64_T;
+ vals[1].data.uint64_val = hicn_state->pkts_interest_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_interest_count);
+ lyd_new_path(*parent, NULL, vals[1].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[2], "/hicn:hicn-state/states/pkts_data_count");
+ vals[2].type = SR_UINT64_T;
+ vals[2].data.uint64_val = hicn_state->pkts_data_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_data_count);
+ lyd_new_path(*parent, NULL, vals[2].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[3], "/hicn:hicn-state/states/pkts_from_cache_count");
+ vals[3].type = SR_UINT64_T;
+ vals[3].data.uint64_val = hicn_state->pkts_from_cache_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_from_cache_count);
+ lyd_new_path(*parent, NULL, vals[3].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[4], "/hicn:hicn-state/states/pkts_no_pit_count");
+ vals[4].type = SR_UINT64_T;
+ vals[4].data.uint64_val = hicn_state->pkts_no_pit_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_no_pit_count);
+ lyd_new_path(*parent, NULL, vals[4].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[5], "/hicn:hicn-state/states/pit_expired_count");
+ vals[5].type = SR_UINT64_T;
+ vals[5].data.uint64_val = hicn_state->pit_expired_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pit_expired_count);
+ lyd_new_path(*parent, NULL, vals[5].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[6], "/hicn:hicn-state/states/cs_expired_count");
+ vals[6].type = SR_UINT64_T;
+ vals[6].data.uint64_val = hicn_state->cs_expired_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->cs_expired_count);
+ lyd_new_path(*parent, NULL, vals[6].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[7], "/hicn:hicn-state/states/cs_lru_count");
+ vals[7].type = SR_UINT64_T;
+ vals[7].data.uint64_val = hicn_state->cs_lru_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->cs_lru_count);
+ lyd_new_path(*parent, NULL, vals[7].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[8], "/hicn:hicn-state/states/pkts_drop_no_buf");
+ vals[8].type = SR_UINT64_T;
+ vals[8].data.uint64_val = hicn_state->pkts_drop_no_buf;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pkts_drop_no_buf);
+ lyd_new_path(*parent, NULL, vals[8].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[9], "/hicn:hicn-state/states/interests_aggregated");
+ vals[9].type = SR_UINT64_T;
+ vals[9].data.uint64_val = hicn_state->interests_aggregated;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->interests_aggregated);
+ lyd_new_path(*parent, NULL, vals[9].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[10], "/hicn:hicn-state/states/interests_retx");
+ vals[10].type = SR_UINT64_T;
+ vals[10].data.uint64_val = hicn_state->interests_retx;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->interests_retx);
+ lyd_new_path(*parent, NULL, vals[10].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[11],
+ "/hicn:hicn-state/states/interests_hash_collision");
+ vals[11].type = SR_UINT64_T;
+ vals[11].data.uint64_val = hicn_state->interests_hash_collision;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->interests_hash_collision);
+ lyd_new_path(*parent, NULL, vals[11].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[12], "/hicn:hicn-state/states/pit_entries_count");
+ vals[12].type = SR_UINT64_T;
+ vals[12].data.uint64_val = hicn_state->pit_entries_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->pit_entries_count);
+ lyd_new_path(*parent, NULL, vals[12].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[13], "/hicn:hicn-state/states/cs_entries_count");
+ vals[13].type = SR_UINT64_T;
+ vals[13].data.uint64_val = hicn_state->cs_entries_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->cs_entries_count);
+ lyd_new_path(*parent, NULL, vals[13].xpath, buf, 0, 0);
+
+ sr_val_set_xpath(&vals[14], "/hicn:hicn-state/states/cs_entries_ntw_count");
+ vals[14].type = SR_UINT64_T;
+ vals[14].data.uint64_val = hicn_state->cs_entries_ntw_count;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, hicn_state->cs_entries_ntw_count);
+ lyd_new_path(*parent, NULL, vals[14].xpath, buf, 0, 0);
}
-static inline void state_update(sr_val_t * vals, struct lyd_node **parent, sr_session_ctx_t *session){
- char buf[20];
-
- sr_val_set_xpath(&vals[0], "/hicn:hicn-state/states/pkts_processed");
- vals[0].type = SR_UINT64_T;
- vals[0].data.uint64_val = hicn_state->pkts_processed;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_processed);
- * parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), vals[0].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[1], "/hicn:hicn-state/states/pkts_interest_count");
- vals[1].type = SR_UINT64_T;
- vals[1].data.uint64_val = hicn_state->pkts_interest_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_interest_count );
- lyd_new_path(*parent, NULL, vals[1].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[2], "/hicn:hicn-state/states/pkts_data_count");
- vals[2].type = SR_UINT64_T;
- vals[2].data.uint64_val = hicn_state->pkts_data_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_data_count );
- lyd_new_path(*parent, NULL, vals[2].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[3], "/hicn:hicn-state/states/pkts_from_cache_count");
- vals[3].type = SR_UINT64_T;
- vals[3].data.uint64_val = hicn_state->pkts_from_cache_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_from_cache_count );
- lyd_new_path(*parent, NULL, vals[3].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[4], "/hicn:hicn-state/states/pkts_no_pit_count");
- vals[4].type = SR_UINT64_T;
- vals[4].data.uint64_val = hicn_state->pkts_no_pit_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_no_pit_count );
- lyd_new_path(*parent, NULL, vals[4].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[5], "/hicn:hicn-state/states/pit_expired_count");
- vals[5].type = SR_UINT64_T;
- vals[5].data.uint64_val = hicn_state->pit_expired_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pit_expired_count );
- lyd_new_path(*parent, NULL, vals[5].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[6], "/hicn:hicn-state/states/cs_expired_count");
- vals[6].type = SR_UINT64_T;
- vals[6].data.uint64_val = hicn_state->cs_expired_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->cs_expired_count );
- lyd_new_path(*parent, NULL, vals[6].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[7], "/hicn:hicn-state/states/cs_lru_count");
- vals[7].type = SR_UINT64_T;
- vals[7].data.uint64_val = hicn_state->cs_lru_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->cs_lru_count );
- lyd_new_path(*parent, NULL, vals[7].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[8], "/hicn:hicn-state/states/pkts_drop_no_buf");
- vals[8].type = SR_UINT64_T;
- vals[8].data.uint64_val = hicn_state->pkts_drop_no_buf;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pkts_drop_no_buf );
- lyd_new_path(*parent, NULL, vals[8].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[9], "/hicn:hicn-state/states/interests_aggregated");
- vals[9].type = SR_UINT64_T;
- vals[9].data.uint64_val = hicn_state->interests_aggregated;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->interests_aggregated );
- lyd_new_path(*parent, NULL, vals[9].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[10], "/hicn:hicn-state/states/interests_retx");
- vals[10].type = SR_UINT64_T;
- vals[10].data.uint64_val = hicn_state->interests_retx;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->interests_retx );
- lyd_new_path(*parent, NULL, vals[10].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[11],
- "/hicn:hicn-state/states/interests_hash_collision");
- vals[11].type = SR_UINT64_T;
- vals[11].data.uint64_val = hicn_state->interests_hash_collision;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->interests_hash_collision );
- lyd_new_path(*parent, NULL, vals[11].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[12], "/hicn:hicn-state/states/pit_entries_count");
- vals[12].type = SR_UINT64_T;
- vals[12].data.uint64_val = hicn_state->pit_entries_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->pit_entries_count );
- lyd_new_path(*parent, NULL, vals[12].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[13], "/hicn:hicn-state/states/cs_entries_count");
- vals[13].type = SR_UINT64_T;
- vals[13].data.uint64_val = hicn_state->cs_entries_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->cs_entries_count );
- lyd_new_path(*parent, NULL, vals[13].xpath, buf, 0, 0);
-
- sr_val_set_xpath(&vals[14], "/hicn:hicn-state/states/cs_entries_ntw_count");
- vals[14].type = SR_UINT64_T;
- vals[14].data.uint64_val = hicn_state->cs_entries_ntw_count;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, hicn_state->cs_entries_ntw_count );
- lyd_new_path(*parent, NULL, vals[14].xpath, buf, 0, 0);
-
-}
-
-static inline int routes_update(sr_val_t * vals, uint32_t nleaves, struct lyd_node **parent, sr_session_ctx_t *session){
-
- struct hicn_routes_s * temp = hicn_routes->next;
- char buf[20];
- int route =0;
- for(int count=0; count<nleaves; count++){
-
- sr_val_build_xpath(&vals[route], "%s[routeid='%d']/prefix", "/hicn:hicn-state/routes/route",
- temp->route.route_id);
- vals[route].type = SR_STRING_T;
-
- memset(buf, 0x00, 20);
- if (temp->route.prefix.address.af==ADDRESS_IP4){
- struct sockaddr_in sa;
- memcpy(&sa.sin_addr.s_addr, temp->route.prefix.address.un.ip4, IPV4_ADDR_LEN);
- inet_ntop(AF_INET, &(sa.sin_addr), buf, INET_ADDRSTRLEN);
- vals[route].data.string_val = buf;
- }else{
- struct sockaddr_in6 sa;
- memcpy(&sa.sin6_addr,temp->route.prefix.address.un.ip6, IPV6_ADDR_LEN);
- inet_ntop(AF_INET6, &(sa.sin6_addr), buf, INET6_ADDRSTRLEN);
- vals[route].data.string_val = buf;
- }
-
-
- lyd_new_path(*parent, NULL, vals[route].xpath, buf, 0, 0);
-
-
- route++;
-
- sr_val_build_xpath(&vals[route], "%s[routeid='%d']/strategy_id", "/hicn:hicn-state/routes/route",
- temp->route.route_id);
- vals[route].type = SR_UINT32_T;
- vals[route].data.uint32_val = temp->route.strategy_id;
- memset(buf, 0x00, 20);
- sprintf( buf, "%d", temp->route.strategy_id);
- lyd_new_path(*parent, NULL, vals[route].xpath, buf, 0, 0);
-
- route++;
-
- temp=temp->next;
+static inline int routes_update(sr_val_t *vals, uint32_t nleaves,
+ struct lyd_node **parent,
+ sr_session_ctx_t *session) {
+ struct hicn_routes_s *temp = hicn_routes->next;
+ char buf[20];
+ int route = 0;
+ for (int count = 0; count < nleaves; count++) {
+ sr_val_build_xpath(&vals[route], "%s[routeid='%d']/prefix",
+ "/hicn:hicn-state/routes/route", temp->route.route_id);
+ vals[route].type = SR_STRING_T;
+
+ memset(buf, 0x00, 20);
+ if (temp->route.prefix.address.af == ADDRESS_IP4) {
+ struct sockaddr_in sa;
+ memcpy(&sa.sin_addr.s_addr, temp->route.prefix.address.un.ip4,
+ IPV4_ADDR_LEN);
+ inet_ntop(AF_INET, &(sa.sin_addr), buf, INET_ADDRSTRLEN);
+ vals[route].data.string_val = buf;
+ } else {
+ struct sockaddr_in6 sa;
+ memcpy(&sa.sin6_addr, temp->route.prefix.address.un.ip6, IPV6_ADDR_LEN);
+ inet_ntop(AF_INET6, &(sa.sin6_addr), buf, INET6_ADDRSTRLEN);
+ vals[route].data.string_val = buf;
+ }
+
+ lyd_new_path(*parent, NULL, vals[route].xpath, buf, 0, 0);
+
+ route++;
+
+ sr_val_build_xpath(&vals[route], "%s[routeid='%d']/strategy_id",
+ "/hicn:hicn-state/routes/route", temp->route.route_id);
+ vals[route].type = SR_UINT32_T;
+ vals[route].data.uint32_val = temp->route.strategy_id;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%d", temp->route.strategy_id);
+ lyd_new_path(*parent, NULL, vals[route].xpath, buf, 0, 0);
+
+ route++;
+
+ temp = temp->next;
+ }
+ SRP_LOG_DBGMSG("Routes state updated \n");
+ return SR_ERR_OK;
}
- SRP_LOG_DBGMSG("Routes state updated \n");
- return SR_ERR_OK;
+static inline int faces_update(sr_val_t *vals, uint32_t nleaves,
+ struct lyd_node **parent,
+ sr_session_ctx_t *session) {
+ struct hicn_faces_s *temp = hicn_faces->next;
+ char buf[20];
+ int face = 0;
+
+ for (int count = 0; count < nleaves; count++) {
+ vapi_msg_hicn_api_face_params_get *msg;
+ msg = vapi_alloc_hicn_api_face_params_get(g_vapi_ctx_instance);
+
+ msg->payload.faceid = temp->face.faceid;
+
+ if (vapi_hicn_api_face_params_get(g_vapi_ctx_instance, msg,
+ call_hicn_api_face_params_get,
+ (void *)temp) != VAPI_OK) {
+ SRP_LOG_DBGMSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
+ }
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/intfc",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT32_T;
+ vals[face].data.uint32_val = temp->face.intfc;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%u", temp->face.intfc);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/irx_packets",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.irx_packets;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.irx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/irx_bytes",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.irx_bytes;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.irx_bytes);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/itx_packets",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.itx_packets;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.itx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/itx_bytes",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.itx_bytes;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.itx_bytes);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/drx_packets",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.drx_packets;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.drx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/drx_bytes",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.drx_bytes;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.drx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/dtx_packets",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.dtx_packets;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.dtx_packets);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ sr_val_build_xpath(&vals[face], "%s[faceid='%d']/dtx_bytes",
+ "/hicn:hicn-state/faces/face", temp->face.faceid);
+ vals[face].type = SR_UINT64_T;
+ vals[face].data.uint64_val = temp->face.dtx_bytes;
+ memset(buf, 0x00, 20);
+ sprintf(buf, "%" PRIu64, temp->face.dtx_bytes);
+ lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
+
+ face++;
+
+ temp = temp->next;
+ }
+ SRP_LOG_DBGMSG("Faces state updated \n");
+ return SR_ERR_OK;
}
-static inline int faces_update(sr_val_t * vals, uint32_t nleaves, struct lyd_node **parent, sr_session_ctx_t *session){
-
- struct hicn_faces_s * temp = hicn_faces->next;
- char buf[20];
- int face =0;
-
-
- for(int count=0; count<nleaves; count++){
-
- vapi_msg_hicn_api_face_params_get *msg;
- msg = vapi_alloc_hicn_api_face_params_get(g_vapi_ctx_instance);
-
-
- msg->payload.faceid = temp->face.faceid;
-
- if(vapi_hicn_api_face_params_get(g_vapi_ctx_instance,msg,call_hicn_api_face_params_get, (void *)temp)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
- }
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/intfc", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT32_T;
- vals[face].data.uint32_val = temp->face.intfc;
- memset(buf, 0x00, 20);
- sprintf( buf,"%u", temp->face.intfc);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/irx_packets", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.irx_packets;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.irx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
- face++;
-
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/irx_bytes", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.irx_bytes;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.irx_bytes);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
- face++;
-
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/itx_packets", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.itx_packets;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.itx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
- face++;
-
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/itx_bytes", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.itx_bytes;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.itx_bytes);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/drx_packets", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.drx_packets;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.drx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
-
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/drx_bytes", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.drx_bytes;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.drx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/dtx_packets", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.dtx_packets;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.dtx_packets);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
- face++;
-
-
- sr_val_build_xpath(&vals[face], "%s[faceid='%d']/dtx_bytes", "/hicn:hicn-state/faces/face",
- temp->face.faceid);
- vals[face].type = SR_UINT64_T;
- vals[face].data.uint64_val = temp->face.dtx_bytes;
- memset(buf, 0x00, 20);
- sprintf( buf, "%" PRIu64, temp->face.dtx_bytes);
- lyd_new_path(*parent, NULL, vals[face].xpath, buf, 0, 0);
-
-
- face++;
+static int hicn_state_states_cb(sr_session_ctx_t *session,
+ const char *module_name, const char *path,
+ const char *request_xpath, uint32_t request_id,
+ struct lyd_node **parent, void *private_data) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name state;
+ state = lstate;
+ SRP_LOG_DBGMSG("Requesting state data");
+
+ rc = sr_new_values(NSTATE_LEAVES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
- temp=temp->next;
+ tlock(state);
+ state_update(vals, parent, session);
+ tunlock(state);
- }
- SRP_LOG_DBGMSG("Faces state updated \n");
- return SR_ERR_OK;
+ return SR_ERR_OK;
}
-static int hicn_state_states_cb(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath,
- uint32_t request_id, struct lyd_node **parent, void *private_data) {
- sr_val_t *vals;
- int rc;
- enum locks_name state;
- state=lstate;
- SRP_LOG_DBGMSG("Requesting state data");
-
-
- rc = sr_new_values(NSTATE_LEAVES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
-
-
- tlock(state);
- state_update(vals,parent,session);
- tunlock(state);
+static int hicn_state_route_cb(sr_session_ctx_t *session,
+ const char *module_name, const char *path,
+ const char *request_xpath, uint32_t request_id,
+ struct lyd_node **parent, void *private_data) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name route;
+ route = lroute;
+ uint32_t NROUTE_NODES = hicn_routes->nroute * ROUTES_CHILDREN;
+
+ rc = sr_new_values(NROUTE_NODES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
+ tlock(route);
+ routes_update(vals, NROUTE_NODES / ROUTES_CHILDREN, parent, session);
+ tunlock(route);
- return SR_ERR_OK;
+ return SR_ERR_OK;
}
-static int hicn_state_route_cb(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath,
- uint32_t request_id, struct lyd_node **parent, void *private_data) {
- sr_val_t *vals;
- int rc;
- enum locks_name route;
- route=lroute;
- uint32_t NROUTE_NODES = hicn_routes->nroute * ROUTES_CHILDREN;
-
-
-
- rc = sr_new_values(NROUTE_NODES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
-
- tlock(route);
- routes_update(vals,NROUTE_NODES/ROUTES_CHILDREN, parent, session);
- tunlock(route);
-
-
- return SR_ERR_OK;
-
- }
-
-
- static int hicn_state_faces_cb(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath,
- uint32_t request_id, struct lyd_node **parent, void *private_data) {
-
-
- sr_val_t *vals;
- int rc;
- enum locks_name faces;
- faces=lfaces;
- uint32_t NFACES_NODES = hicn_faces->nface * FACES_CHILDREN;
-
- rc = sr_new_values(NFACES_NODES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
-
- tlock(faces);
- faces_update(vals, NFACES_NODES/FACES_CHILDREN, parent, session);
- tunlock(faces);
-
- return SR_ERR_OK;
-
- }
-
-static int hicn_strategies_get_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
- sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
-
-SRP_LOG_DBGMSG("hicn strategies received successfully");
-vapi_msg_hicn_api_strategies_get *msg;
-
-msg = vapi_alloc_hicn_api_strategies_get(g_vapi_ctx_instance);
+static int hicn_state_faces_cb(sr_session_ctx_t *session,
+ const char *module_name, const char *path,
+ const char *request_xpath, uint32_t request_id,
+ struct lyd_node **parent, void *private_data) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name faces;
+ faces = lfaces;
+ uint32_t NFACES_NODES = hicn_faces->nface * FACES_CHILDREN;
+
+ rc = sr_new_values(NFACES_NODES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
-if (vapi_hicn_api_strategies_get(g_vapi_ctx_instance, msg, call_hicn_api_strategies_get, NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
-}
-return SR_ERR_OK;
+ tlock(faces);
+ faces_update(vals, NFACES_NODES / FACES_CHILDREN, parent, session);
+ tunlock(faces);
+ return SR_ERR_OK;
}
-static int hicn_route_nhops_add_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
- sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
-
- SRP_LOG_DBGMSG("hicn route nhops add received successfully");
- vapi_msg_hicn_api_route_nhops_add *msg;
-
- msg = vapi_alloc_hicn_api_route_nhops_add(g_vapi_ctx_instance);
-
- if(strcmp(input[0].data.string_val,"-1")){
-
- struct sockaddr_in sa;
- inet_pton(AF_INET, input[0].data.string_val, &(sa.sin_addr));
- unsigned char * tmp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32);
- msg->payload.prefix.address.af = ADDRESS_IP4;
-
- }else if(strcmp(input[1].data.string_val,"-1")){
-
- void *dst = malloc(sizeof(struct in6_addr));
- inet_pton(AF_INET6, input[1].data.string_val, dst);
- unsigned char * tmp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128);
- msg->payload.prefix.address.af = ADDRESS_IP6;
-
- }else{
- SRP_LOG_DBGMSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
-
- msg->payload.prefix.len = input[2].data.uint8_val;
- msg->payload.face_ids[0] = input[3].data.uint32_val;
- msg->payload.face_ids[1] = input[4].data.uint32_val;
- msg->payload.face_ids[2] = input[5].data.uint32_val;
- msg->payload.face_ids[3] = input[6].data.uint32_val;
- msg->payload.face_ids[4] = input[7].data.uint32_val;
- msg->payload.face_ids[5] = input[8].data.uint32_val;
- msg->payload.face_ids[6] = input[9].data.uint32_val;
- msg->payload.n_faces = input[10].data.uint8_val;
-
-
-if(vapi_hicn_api_route_nhops_add(g_vapi_ctx_instance,msg,call_hicn_api_route_nhops_add,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
-}
-return SR_ERR_OK;
+static int hicn_strategies_get_cb(sr_session_ctx_t *session, const char *path,
+ const sr_val_t *input, const size_t input_cnt,
+ sr_event_t event, uint32_t request_id,
+ sr_val_t **output, size_t *output_cnt,
+ void *private_data) {
+ SRP_LOG_DBGMSG("hicn strategies received successfully");
+ vapi_msg_hicn_api_strategies_get *msg;
+
+ msg = vapi_alloc_hicn_api_strategies_get(g_vapi_ctx_instance);
+
+ if (vapi_hicn_api_strategies_get(g_vapi_ctx_instance, msg,
+ call_hicn_api_strategies_get,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ return SR_ERR_OK;
}
-static int hicn_route_del_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
- sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
-
- SRP_LOG_DBGMSG("hicn route del received successfully");
- vapi_msg_hicn_api_route_del *msg;
-
- msg = vapi_alloc_hicn_api_route_del(g_vapi_ctx_instance);
-
- if(strcmp(input[0].data.string_val,"-1")){
-
- struct sockaddr_in sa;
- inet_pton(AF_INET, input[0].data.string_val, &(sa.sin_addr));
- unsigned char * tmp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32);
- msg->payload.prefix.address.af = ADDRESS_IP4;
-
-
- }else if(strcmp(input[1].data.string_val,"-1")){
-
- void *dst = malloc(sizeof(struct in6_addr));
- inet_pton(AF_INET6, input[1].data.string_val, dst);
- unsigned char * tmp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128);
- msg->payload.prefix.address.af = ADDRESS_IP6;
-
- }else{
- SRP_LOG_DBGMSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+static int hicn_face_params_get_cb(sr_session_ctx_t *session, const char *path,
+ const sr_val_t *input,
+ const size_t input_cnt, sr_event_t event,
+ uint32_t request_id, sr_val_t **output,
+ size_t *output_cnt, void *private_data) {
+ SRP_LOG_DBGMSG("hicn face ip params get received successfully");
+ vapi_msg_hicn_api_face_params_get *msg;
+ msg = vapi_alloc_hicn_api_face_params_get(g_vapi_ctx_instance);
- msg->payload.prefix.len = input[2].data.uint8_val;
+ msg->payload.faceid = input[0].data.uint32_val;
+ if (vapi_hicn_api_face_params_get(g_vapi_ctx_instance, msg,
+ call_hicn_api_face_params_get,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
+ }
-if(vapi_hicn_api_route_del(g_vapi_ctx_instance,msg,call_hicn_api_route_del,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
-}
-return SR_ERR_OK;
+ return SR_ERR_OK;
}
-static int hicn_face_params_get_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
- sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
-
- SRP_LOG_DBGMSG("hicn face ip params get received successfully");
- vapi_msg_hicn_api_face_params_get *msg;
-
- msg = vapi_alloc_hicn_api_face_params_get(g_vapi_ctx_instance);
-
- msg->payload.faceid = input[0].data.uint32_val;
-
-if (vapi_hicn_api_face_params_get(g_vapi_ctx_instance,msg,call_hicn_api_face_params_get,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
-}
-return SR_ERR_OK;
+static vapi_error_e call_hicn_api_enable_disable(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_enable_disable_reply *reply) {
+ if (!reply->retval) {
+ SRP_LOG_DBGMSG("Successfully done");
+ return VAPI_OK;
+ } else
+ return VAPI_EUSER;
}
-static int hicn_route_nhops_del_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
- sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
+static int hicn_enable_cb(sr_session_ctx_t *session, const char *path,
+ const sr_val_t *input, const size_t input_cnt,
+ sr_event_t event, uint32_t request_id,
+ sr_val_t **output, size_t *output_cnt,
+ void *private_data) {
+ SRP_LOG_DBGMSG("hicn enable received successfully");
+ vapi_msg_hicn_api_enable_disable *msg;
- SRP_LOG_DBGMSG("hicn route nhop del received successfully");
- // allocate memory msg
- vapi_msg_hicn_api_route_nhop_del *msg;
+ msg = vapi_alloc_hicn_api_enable_disable(g_vapi_ctx_instance);
- msg = vapi_alloc_hicn_api_route_nhop_del(g_vapi_ctx_instance);
+ const char *delim = "/";
+ if (input->type != SR_STRING_T) {
+ SRP_LOG_DBGMSG("Expected prefix of type string");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ char *token;
+
+ /* get the first token */
+ token = strtok(input->data.string_val, delim);
+
+ /* if null the address is ipv4 else ipv6*/
+ if (strrchr(token, ':') == NULL) {
+ struct sockaddr_in sa;
+ inet_pton(AF_INET, token, &(sa.sin_addr));
+ unsigned char *tmp = (unsigned char *)&sa.sin_addr.s_addr;
+ memcpy(&msg->payload.prefix.address.un.ip4[0], tmp, B32);
+ msg->payload.prefix.address.af = ADDRESS_IP4;
+ } else {
+ void *dst = malloc(sizeof(struct in6_addr));
+ inet_pton(AF_INET6, token, dst);
+ unsigned char *tmp = (unsigned char *)((struct in6_addr *)dst)->s6_addr;
+ memcpy(&msg->payload.prefix.address.un.ip6[0], tmp, B128);
+ msg->payload.prefix.address.af = ADDRESS_IP6;
+ }
+ /* The second token is the prefix len*/
+ token = strtok(NULL, delim);
- if(strcmp(input[0].data.string_val,"-1")){
+ msg->payload.prefix.len = atoi(token);
+ msg->payload.enable_disable = 1;
- struct sockaddr_in sa;
- // store this IP address in sa:
- inet_pton(AF_INET, input[0].data.string_val, &(sa.sin_addr));
- unsigned char * tmp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix.address.un.ip4[0],tmp,B32);
- msg->payload.prefix.address.af = ADDRESS_IP4;
+ if (vapi_hicn_api_enable_disable(g_vapi_ctx_instance, msg,
+ call_hicn_api_enable_disable,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ return SR_ERR_OK;
+}
- }else if(strcmp(input[1].data.string_val,"-1")){
+static int hicn_disable_cb(sr_session_ctx_t *session, const char *path,
+ const sr_val_t *input, const size_t input_cnt,
+ sr_event_t event, uint32_t request_id,
+ sr_val_t **output, size_t *output_cnt,
+ void *private_data) {
+ SRP_LOG_DBGMSG("hicn disable received successfully");
+ vapi_msg_hicn_api_enable_disable *msg;
- void *dst = malloc(sizeof(struct in6_addr));
- inet_pton(AF_INET6, input[1].data.string_val, dst);
- unsigned char * tmp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix.address.un.ip6[0],tmp,B128);
- msg->payload.prefix.address.af = ADDRESS_IP6;
+ msg = vapi_alloc_hicn_api_enable_disable(g_vapi_ctx_instance);
- }else{
- SRP_LOG_DBGMSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ const char *delim = "/";
+ if (input->type != SR_STRING_T) {
+ SRP_LOG_DBGMSG("Expected prefix of type string");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ char *token;
+
+ /* get the first token */
+ token = strtok(input->data.string_val, delim);
+
+ /* if null the address is ipv4 else ipv6*/
+ if (strrchr(token, ':') == NULL) {
+ struct sockaddr_in sa;
+ inet_pton(AF_INET, token, &(sa.sin_addr));
+ unsigned char *tmp = (unsigned char *)&sa.sin_addr.s_addr;
+ memcpy(&msg->payload.prefix.address.un.ip4[0], tmp, B32);
+ msg->payload.prefix.address.af = ADDRESS_IP4;
+ } else {
+ void *dst = malloc(sizeof(struct in6_addr));
+ inet_pton(AF_INET6, token, dst);
+ unsigned char *tmp = (unsigned char *)((struct in6_addr *)dst)->s6_addr;
+ memcpy(&msg->payload.prefix.address.un.ip6[0], tmp, B128);
+ msg->payload.prefix.address.af = ADDRESS_IP6;
+ }
+ /* The second token is the prefix len*/
+ token = strtok(NULL, delim);
- msg->payload.prefix.len = input[2].data.uint8_val;
- msg->payload.faceid = input[3].data.uint32_val;
+ msg->payload.prefix.len = atoi(token);
+ msg->payload.enable_disable = 0;
+ if (vapi_hicn_api_enable_disable(g_vapi_ctx_instance, msg,
+ call_hicn_api_enable_disable,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
+ }
-if (vapi_hicn_api_route_nhop_del(g_vapi_ctx_instance, msg, call_hicn_api_route_nhop_del,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG("Operation failed");
- return SR_ERR_OPERATION_FAILED;
-}
-return SR_ERR_OK;
+ return SR_ERR_OK;
}
-static vapi_error_e
-hicn_api_routes_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
- vapi_error_e rv, bool is_last,
- vapi_payload_hicn_api_routes_details *reply)
-{
-
- static int counter = 0;
-
- tlock(lroute);
- if (reply!=NULL){
- rcurrent->route.route_id = counter;
- rcurrent->route.prefix = reply->prefix;
- rcurrent->route.nfaces = reply->nfaces;
- rcurrent->route.strategy_id = reply->strategy_id;
- for(int cnt=0;cnt<rcurrent->route.nfaces;cnt++)
- rcurrent->route.faceids[cnt] = rcurrent->route.faceids[cnt];
-
- counter++;
- rcurrent = rcurrent->next;
-
- SRP_LOG_DBG("nfaces %d", reply->nfaces);
- SRP_LOG_DBG("strategy_id %d", reply->strategy_id);
-
- }else
- {
- SRP_LOG_DBGMSG("---------Routes------- \n");
- hicn_routes->nroute=counter;
- counter=0;
- rcurrent=hicn_routes->next;
- }
- tunlock(lroute);
- return SR_ERR_OK;
-
+static vapi_error_e hicn_api_routes_dump_cb(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_routes_details *reply) {
+ static int counter = 0;
+
+ tlock(lroute);
+ if (reply != NULL) {
+ rcurrent->route.route_id = counter;
+ rcurrent->route.prefix = reply->prefix;
+ rcurrent->route.nfaces = reply->nfaces;
+ rcurrent->route.strategy_id = reply->strategy_id;
+ for (int cnt = 0; cnt < rcurrent->route.nfaces; cnt++)
+ rcurrent->route.faceids[cnt] = rcurrent->route.faceids[cnt];
+
+ counter++;
+ rcurrent = rcurrent->next;
+
+ SRP_LOG_DBG("nfaces %d", reply->nfaces);
+ SRP_LOG_DBG("strategy_id %d", reply->strategy_id);
+
+ } else {
+ SRP_LOG_DBGMSG("---------Routes------- \n");
+ hicn_routes->nroute = counter;
+ counter = 0;
+ rcurrent = hicn_routes->next;
+ }
+ tunlock(lroute);
+ return SR_ERR_OK;
}
-
-static vapi_error_e
-hicn_api_face_stats_dump_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
- vapi_error_e rv, bool is_last,
- vapi_payload_hicn_api_face_stats_details *reply)
-{
-
- static int counter = 0;
-
- tlock(lfaces);
- if (reply!=NULL){
-
- fcurrent->face.faceid = reply->faceid;
- fcurrent->face.intfc = 1;
- fcurrent->face.irx_packets = reply->irx_packets;
- fcurrent->face.irx_bytes = reply->irx_bytes;
- fcurrent->face.itx_packets = reply->itx_packets;
- fcurrent->face.itx_bytes = reply->itx_bytes;
- fcurrent->face.drx_packets = reply->drx_packets;
- fcurrent->face.drx_bytes = reply->drx_bytes;
- fcurrent->face.dtx_packets = reply->dtx_packets;
- fcurrent->face.dtx_bytes = reply->dtx_bytes;
- counter++;
- fcurrent = fcurrent->next;
- SRP_LOG_DBG("faceid %d", reply->faceid);
- SRP_LOG_DBG("drxB %d", reply->drx_bytes);
- SRP_LOG_DBG("dtxB %d", reply->dtx_bytes);
-
- }else
- {
- SRP_LOG_DBGMSG("---------Faces------- \n");
- hicn_faces->nface=counter;
- counter=0;
- fcurrent=hicn_faces->next;
- }
- tunlock(lfaces);
- return SR_ERR_OK;
+static vapi_error_e hicn_api_face_stats_dump_cb(
+ struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
+ vapi_payload_hicn_api_face_stats_details *reply) {
+ static int counter = 0;
+
+ tlock(lfaces);
+ if (reply != NULL) {
+ fcurrent->face.faceid = reply->faceid;
+ fcurrent->face.intfc = 1;
+ fcurrent->face.irx_packets = reply->irx_packets;
+ fcurrent->face.irx_bytes = reply->irx_bytes;
+ fcurrent->face.itx_packets = reply->itx_packets;
+ fcurrent->face.itx_bytes = reply->itx_bytes;
+ fcurrent->face.drx_packets = reply->drx_packets;
+ fcurrent->face.drx_bytes = reply->drx_bytes;
+ fcurrent->face.dtx_packets = reply->dtx_packets;
+ fcurrent->face.dtx_bytes = reply->dtx_bytes;
+ counter++;
+ fcurrent = fcurrent->next;
+ SRP_LOG_DBG("faceid %d", reply->faceid);
+ SRP_LOG_DBG("drxB %d", reply->drx_bytes);
+ SRP_LOG_DBG("dtxB %d", reply->dtx_bytes);
+
+ } else {
+ SRP_LOG_DBGMSG("---------Faces------- \n");
+ hicn_faces->nface = counter;
+ counter = 0;
+ fcurrent = hicn_faces->next;
+ }
+ tunlock(lfaces);
+ return SR_ERR_OK;
}
-
static void *state_thread(void *arg) {
+ // mapping can be retrieved by cpuinfo
+ int map = 0;
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ CPU_SET(map, &cpuset);
+
+ // pin the thread to a core
+ if (pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset)) {
+ SRP_LOG_DBGMSG("Thread pining failed\n");
+ exit(1);
+ }
- // mapping can be retrieved by cpuinfo
- int map = 0;
- cpu_set_t cpuset;
- CPU_ZERO(&cpuset);
- CPU_SET(map, &cpuset);
-
- // pin the thread to a core
- if (pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset))
- {
- SRP_LOG_DBGMSG("Thread pining failed\n");
- exit(1);
- }
-
- vapi_msg_hicn_api_node_stats_get *msg=NULL;
- enum locks_name state;
- state=lstate;
-
- while(true){
-
- // dump faces
- vapi_msg_hicn_api_face_stats_dump *fmsg;
- fmsg = vapi_alloc_hicn_api_face_stats_dump(g_vapi_ctx_instance);
- vapi_hicn_api_face_stats_dump(g_vapi_ctx_instance, fmsg, hicn_api_face_stats_dump_cb, fcurrent);
-
- // dump routes
- vapi_msg_hicn_api_routes_dump *rmsg;
- rmsg = vapi_alloc_hicn_api_routes_dump(g_vapi_ctx_instance);
- vapi_hicn_api_routes_dump(g_vapi_ctx_instance, rmsg, hicn_api_routes_dump_cb, rcurrent);
+ vapi_msg_hicn_api_node_stats_get *msg = NULL;
+ enum locks_name state;
+ state = lstate;
+ while (true) {
+ tlock(state);
+ // dump faces
+ vapi_msg_hicn_api_face_stats_dump *fmsg;
+ fmsg = vapi_alloc_hicn_api_face_stats_dump(g_vapi_ctx_instance);
+ vapi_hicn_api_face_stats_dump(g_vapi_ctx_instance, fmsg,
+ hicn_api_face_stats_dump_cb, fcurrent);
+ // dump routes
+ vapi_msg_hicn_api_routes_dump *rmsg;
+ rmsg = vapi_alloc_hicn_api_routes_dump(g_vapi_ctx_instance);
+ vapi_hicn_api_routes_dump(g_vapi_ctx_instance, rmsg,
+ hicn_api_routes_dump_cb, rcurrent);
- msg = vapi_alloc_hicn_api_node_stats_get(g_vapi_ctx_instance);
+ msg = vapi_alloc_hicn_api_node_stats_get(g_vapi_ctx_instance);
+ if (vapi_hicn_api_node_stats_get(g_vapi_ctx_instance, msg,
+ call_vapi_hicn_api_node_stats_get,
+ NULL) != VAPI_OK) {
+ SRP_LOG_DBGMSG(" State operation failed");
+ }
- tlock(state);
+ tunlock(state);
+ sleep(1);
- if(vapi_hicn_api_node_stats_get(g_vapi_ctx_instance,msg,call_vapi_hicn_api_node_stats_get,NULL)!=VAPI_OK){
- SRP_LOG_DBGMSG(" State operation failed");
+ SRP_LOG_DBGMSG("state cached");
}
+ return NULL;
+}
+int hicn_subscribe_events(sr_session_ctx_t *session,
+ sr_subscription_ctx_t **subscription) {
+ int rc = SR_ERR_OK;
+ SRP_LOG_DBGMSG("Subscriging hicn.");
+
+ // Initializing the locks
+ for (int i = 0; i < NLOCKS; i++) ticket_init(i, LOCK_INIT);
+
+ // Initializing the buffer
+ rc = init_buffer();
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in initializing the buffers\n");
+ goto error;
+ }
- tunlock(state);
- sleep(1);
-
- SRP_LOG_DBGMSG("state cached");
+ SRP_LOG_DBGMSG("buffer initialized successfully.");
- }
- return NULL;
-}
+ rc = init_face_pool(fcurrent);
+ if (rc) {
+ SRP_LOG_DBGMSG("Problem in initializing the pools\n");
+ goto error;
+ }
+ rc = init_route_pool(rcurrent);
+ if (rc) {
+ SRP_LOG_DBGMSG("Problem in initializing the pools\n");
+ goto error;
+ }
-int hicn_subscribe_events(sr_session_ctx_t *session,
- sr_subscription_ctx_t **subscription) {
- int rc = SR_ERR_OK;
- SRP_LOG_DBGMSG("Subscriging hicn.");
+ SRP_LOG_DBGMSG("pools created successfully.");
- //Initializing the locks
- for (int i=0; i<NLOCKS; i++)
- ticket_init(i,LOCK_INIT);
+ // Create state thread observation
+ pthread_t state_tid;
+ rc = pthread_create((pthread_t *)&state_tid, NULL, state_thread, NULL);
+ if (rc != 0) {
+ SRP_LOG_DBGMSG("Error making hicn state thread");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ SRP_LOG_DBGMSG("State thread created successfully.");
- //Initializing the buffer
- rc=init_buffer();
- if(rc!= SR_ERR_OK){
- SRP_LOG_DBGMSG("Problem in initializing the buffers\n");
- goto error;
- }
+ // strategies subscriptions
- SRP_LOG_DBGMSG("buffer initialized successfully.");
+ rc = sr_rpc_subscribe(session, "/hicn:strategies-get", hicn_strategies_get_cb,
+ session, 98, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription strategies-get\n");
+ goto error;
+ }
+ // face ip subscriptions
- rc=init_face_pool(fcurrent);
- if(rc){
- SRP_LOG_DBGMSG("Problem in initializing the pools\n");
- goto error;
- }
+ rc = sr_rpc_subscribe(session, "/hicn:face-params-get",
+ hicn_face_params_get_cb, session, 93,
+ SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription face-params-get\n");
+ goto error;
+ }
+ // hICN enable-disable subscriptions
- rc=init_route_pool(rcurrent);
- if(rc){
- SRP_LOG_DBGMSG("Problem in initializing the pools\n");
- goto error;
- }
+ rc = sr_rpc_subscribe(session, "/hicn:hicn-enable", hicn_enable_cb, session,
+ 94, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription hicn-enable\n");
+ goto error;
+ }
+ rc = sr_rpc_subscribe(session, "/hicn:hicn-disable", hicn_disable_cb, session,
+ 95, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription hicn-enable\n");
+ goto error;
+ }
- SRP_LOG_DBGMSG("pools created successfully.");
+ // subscribe as hicn state data provider
+ rc = sr_oper_get_items_subscribe(session, "hicn", "/hicn:hicn-state/states",
+ hicn_state_states_cb, NULL,
+ SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/states\n");
+ goto error;
+ }
- // Create state thread observation
- pthread_t state_tid;
- rc = pthread_create((pthread_t *)&state_tid, NULL, state_thread, NULL);
- if (rc != 0) {
- SRP_LOG_DBGMSG("Error making hicn state thread");
- return SR_ERR_OPERATION_FAILED;
- }
- SRP_LOG_DBGMSG("State thread created successfully.");
+ rc = sr_oper_get_items_subscribe(session, "hicn", "/hicn:hicn-state/routes",
+ hicn_state_route_cb, NULL,
+ SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/routes\n");
+ goto error;
+ }
+ rc = sr_oper_get_items_subscribe(session, "hicn", "/hicn:hicn-state/faces",
+ hicn_state_faces_cb, NULL,
+ SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/faces\n");
+ goto error;
+ }
-/*
- // subscripe for edit-config
- rc = sr_module_change_subscribe(
- session, "hicn","/hicn:hicn-conf", hicn_node_params_set_cb, g_vapi_ctx_instance,
- 0, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_ENABLED, subscription);
- if (SR_ERR_OK != rc) {
- //SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-conf\n");
- perror("Problem in subscription /hicn:hicn-conf\n");
- goto error;
- }
-*/
-
- // strategies subscriptions
-
- rc = sr_rpc_subscribe(session, "/hicn:strategies-get",
- hicn_strategies_get_cb, session, 98,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc!= SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription strategies-get\n");
- goto error;
- }
-
- // route nhops subscriptions
-
- rc = sr_rpc_subscribe(session, "/hicn:route-nhops-add",
- hicn_route_nhops_add_cb, session, 95,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc!= SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription route-nhops-add\n");
- goto error;
- }
-
- rc = sr_rpc_subscribe(session, "/hicn:route-nhops-del",
- hicn_route_nhops_del_cb, session, 94,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc!= SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription route-nhops-del\n");
- goto error;
- }
-
- rc = sr_rpc_subscribe(session, "/hicn:route-del", hicn_route_del_cb,
- session, 96,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription route-del\n");
- goto error;
- }
-
- // face ip subscriptions
-
- rc = sr_rpc_subscribe(session, "/hicn:face-params-get",
- hicn_face_params_get_cb, session, 93,SR_SUBSCR_CTX_REUSE, subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription face-ip-params-get\n");
- goto error;
- }
-
- // subscribe as hicn state data provider
-
- rc = sr_oper_get_items_subscribe(session, "hicn","/hicn:hicn-state/states",
- hicn_state_states_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/states\n");
- goto error;
- }
-
-
- rc = sr_oper_get_items_subscribe(session, "hicn","/hicn:hicn-state/routes",
- hicn_state_route_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/routes\n");
- goto error;
- }
-
-
- rc = sr_oper_get_items_subscribe(session, "hicn","/hicn:hicn-state/faces",
- hicn_state_faces_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBGMSG("Problem in subscription /hicn:hicn-state/faces\n");
- goto error;
- }
-
-
- SRP_LOG_DBGMSG("hicn plugin initialized successfully.\n");
- return SR_ERR_OK;
+ SRP_LOG_DBGMSG("hicn plugin initialized successfully.\n");
+ return SR_ERR_OK;
error:
- SRP_LOG_ERRMSG("Error by initialization of the hicn plugin.");
- sr_plugin_cleanup_cb(session, &g_vapi_ctx_instance);
- return rc;
+ SRP_LOG_ERRMSG("Error by initialization of the hicn plugin.");
+ sr_plugin_cleanup_cb(session, &g_vapi_ctx_instance);
+ return rc;
}
diff --git a/ctrl/sysrepo-plugins/yang/hicn/hicn.yang b/ctrl/sysrepo-plugins/yang/hicn/hicn.yang
index de09fcdb9..0514a7a2a 100644
--- a/ctrl/sysrepo-plugins/yang/hicn/hicn.yang
+++ b/ctrl/sysrepo-plugins/yang/hicn/hicn.yang
@@ -1,426 +1,247 @@
module hicn {
-namespace "urn:sysrepo:hicn";
-prefix hcn;
+ namespace "urn:sysrepo:hicn";
+ prefix hcn;
-
-revision 2019-10-30{
- description "revised revision focus on telemetry.";
-}
-
-/* new data types and grouping definition to forward the remote request toward hicn controler--to-->hicn */
-
-typedef float {
- type decimal64 {
- fraction-digits 2;
- }
-}
-
-grouping face_ip_add {
-
-leaf lip4 {
- description "IP version 4 local address.";
- type string;
- }
-
-leaf lip6 {
- description "IP version 6 local address.";
- type string;
- }
-
-leaf rip4 {
- description "IP version 4 local address.";
- type string;
- }
-
-leaf rip6 {
- description "IP version 6 local address.";
- type string;
- }
-
-leaf swif {
- description "Interface Index.";
- type uint32;
- }
-}
-
-grouping route_nhops_add {
-
-leaf ip4 {
- description "ip4 to be added to the FIB.";
- type string;
- }
-
-leaf ip6 {
- description "ip6 to be added to the FIB.";
- type string;
- }
-
-leaf len {
- description "Length of the prefix.";
- type uint8;
- }
-
-leaf face_ids0 {
- description "A Face ID to the next hop forwarder for the specified prefix.";
- type uint32;
- }
-
-leaf face_ids1 {
- description "A Face ID to the next hop forwarder for the specified prefix.";
- type uint32;
- }
-
-leaf face_ids2 {
- description "A Face ID to the next hop forwarder for the specified prefix.";
- type uint32;
- }
-
-leaf face_ids3 {
- description "A Face ID to the next hop forwarder for the specified prefix.";
- type uint32;
- }
-
-leaf face_ids4 {
- description "A Face ID to the next hop forwarder for the specified prefix.";
- type uint32;
- }
-
-leaf face_ids5 {
- description "A Face ID to the next hop forwarder for the specified prefix.";
- type uint32;
- }
-
-leaf face_ids6 {
- description "A Face ID to the next hop forwarder for the specified prefix.";
- type uint32;
- }
-
-leaf n_faces {
- description "Number of face to add.";
- type uint8;
- }
-}
-
-
-grouping route_nhops_del {
-
-leaf ip4 {
- description "ip4 to be added to the FIB.";
- type string;
- }
-
-leaf ip6 {
- description "ip6 to be added to the FIB.";
- type string;
- }
-
-leaf len {
- description "Length of the prefix.";
- type uint8;
- }
-
-leaf faceid {
- description "A Face ID to the next hop forwarder for the specified prefix.";
- type uint32;
- }
-
-}
-
-grouping route_del {
-
-leaf ip4 {
- description "ip4 to be added to the FIB.";
- type string;
- }
-
-leaf ip6 {
- description "ip6 to be added to the FIB.";
- type string;
- }
-
-leaf len {
- description "Length of the prefix.";
- type uint8;
- }
-}
-
-grouping punting_add_ip {
-
-leaf ip4 {
- description "ip4 to be added to the FIB.";
- type string;
- }
-
-leaf ip6 {
- description "ip6 to be added to the FIB.";
- type string;
- }
-
-leaf len {
- description "Length of the prefix.";
- type uint8;
+ import ietf-inet-types {
+ prefix inet;
}
-leaf swif {
- description "Interface id.";
- type uint32;
+ revision 2020-04-29{
+ description "revised revision focus on telemetry.";
}
-}
-
-grouping states-reply {
-
- leaf pkts_processed {
- description "ICN packets processed.";
- type uint64;
- }
-
- leaf pkts_interest_count {
- description "PIT maximum size, otherwise -1 to assign default value.";
- type uint64;
- }
-
- leaf pkts_data_count {
- description "CS maximum size, otherwise -1 to assign default value.";
- type uint64;
- }
-
- leaf pkts_from_cache_count {
- description "Portion of CS reserved to application, otherwise -1 to assign default value.";
- type uint64;
- }
-
- leaf pkts_no_pit_count {
- description "Default PIT entry lifetime, otherwise -1 to assign default value.";
- type uint64;
- }
- leaf pit_expired_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value.";
- type uint64;
- }
-
- leaf cs_expired_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
-
- leaf cs_lru_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
+ /* new data types and grouping definition to forward the remote request toward hicn controler--to-->hicn */
- leaf pkts_drop_no_buf {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
-
- leaf interests_aggregated {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
-
- leaf interests_retx {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
+ typedef float {
+ type decimal64 {
+ fraction-digits 2;
}
+ }
- leaf interests_hash_collision {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
+ grouping states-reply {
- leaf pit_entries_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
+ leaf pkts_processed {
+ description "ICN packets processed.";
+ type uint64;
+ }
- leaf cs_entries_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
+ leaf pkts_interest_count {
+ description "PIT maximum size, otherwise -1 to assign default value.";
+ type uint64;
+ }
- leaf cs_entries_ntw_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
+ leaf pkts_data_count {
+ description "CS maximum size, otherwise -1 to assign default value.";
+ type uint64;
+ }
-}
+ leaf pkts_from_cache_count {
+ description "Portion of CS reserved to application, otherwise -1 to assign default value.";
+ type uint64;
+ }
-grouping face-stats-reply {
- list face{
- key faceid;
- leaf faceid {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint32;
+ leaf pkts_no_pit_count {
+ description "Default PIT entry lifetime, otherwise -1 to assign default value.";
+ type uint64;
}
- leaf intfc {
- description "This is the idx number of the faceid.";
- type uint32;
+ leaf pit_expired_count {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value.";
+ type uint64;
}
- leaf irx_packets {
+ leaf cs_expired_count {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf irx_bytes {
+ leaf cs_lru_count {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf itx_packets {
+ leaf pkts_drop_no_buf {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf itx_bytes {
+ leaf interests_aggregated {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
-
- leaf drx_packets {
+ leaf interests_retx {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf drx_bytes {
+ leaf interests_hash_collision {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
- leaf dtx_packets {
+ leaf pit_entries_count {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
+ leaf cs_entries_count {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
- leaf dtx_bytes {
+ leaf cs_entries_ntw_count {
description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
type uint64;
}
+
}
-}
-grouping route-reply {
+ grouping face-stats-reply {
+ list face{
+ key faceid;
+ leaf faceid {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint32;
+ }
- list route{
- key routeid;
- leaf routeid {
- description "the unique key for each item.";
- type uint32;
- }
- leaf prefix {
- description "IP address.";
- type string;
-
- }
- leaf strategy_id {
- description "compile-time plugin features.";
- type uint32;
- }
- }
-}
+ leaf intfc {
+ description "This is the idx number of the faceid.";
+ type uint32;
+ }
-grouping strategies-reply {
- leaf n_strategies {
- description "Enable / disable ICN forwarder in VPP.";
- type uint8;
- }
- leaf strategy_id {
- description "Enable / disable ICN forwarder in VPP.";
- type uint32;
- }
+ leaf irx_packets {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-}
+ leaf irx_bytes {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
+ leaf itx_packets {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-/* Hicn operational data */
+ leaf itx_bytes {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-container hicn-state {
- config false;
- description "operational data container for the hicn.";
- container faces{
- uses face-stats-reply;
- }
- container states{
- uses states-reply;
- }
- container routes{
- uses route-reply;
- }
-}
+ leaf drx_packets {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
+ leaf drx_bytes {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-/* RPC Definitions */
+ leaf dtx_packets {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
-rpc strategies-get {
- description "Operation to get hicn strategies.";
-}
-rpc route-del {
- description "Operation to del hicn route.";
- input {
- uses route_del;
+ leaf dtx_bytes {
+ description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
+ type uint64;
+ }
+ }
}
-}
-rpc route-nhops-add {
- description "Operation to add hicn route nhops.";
- input {
- uses route_nhops_add;
+ grouping route-reply {
+
+ list route{
+ key routeid;
+ leaf routeid {
+ description "the unique key for each item.";
+ type uint32;
+ }
+ leaf prefix {
+ description "IP address.";
+ type string;
+
+ }
+ leaf strategy_id {
+ description "compile-time plugin features.";
+ type uint32;
+ }
}
-}
+ }
+
+ grouping strategies-reply {
+ leaf n_strategies {
+ description "Enable / disable ICN forwarder in VPP.";
+ type uint8;
+ }
+ leaf strategy_id {
+ description "Enable / disable ICN forwarder in VPP.";
+ type uint32;
+ }
-rpc route-nhops-del {
- description "Operation to add hicn face ip punt.";
- input {
- uses route_nhops_del;
}
-}
-rpc face-ip-params-get {
- description "Operation to del hicn route.";
- input {
- leaf faceid {
- description "Face to be retrieved .";
- type uint32;
+ typedef hicn-prefix {
+ description "hICN prefix.";
+ type inet:ip-prefix;
+ }
+
+
+ /* Hicn operational data */
+
+ container hicn-state {
+
+ config false;
+ description "operational data container for the hicn.";
+ container faces{
+ uses face-stats-reply;
+ }
+ container states{
+ uses states-reply;
+ }
+ container routes{
+ uses route-reply;
}
}
-}
-rpc face-ip-add {
- description "Operation to add hicn face ip.";
- input {
- uses face_ip_add;
+
+ /* RPC Definitions */
+
+ rpc strategies-get {
+ description "Operation to get hicn strategies.";
}
-}
-rpc face-ip-del {
- description "Operation to del hicn face ip.";
- input {
- leaf faceid {
- description "Face to be deleted .";
- type uint32;
+ rpc face-params-get {
+ description "Operation to del hicn route.";
+ input {
+ leaf faceid {
+ description "Face to be retrieved .";
+ type uint32;
+ }
}
}
-}
-rpc punting-add-ip {
- description "Operation to add hicn punt.";
- input {
- uses punting_add_ip;
+ rpc hicn-enable {
+ description "Enable hicn on a gie prefix.";
+ input {
+ leaf prefix {
+ type hicn-prefix;
+ }
+ }
}
-}
-rpc punting-del-ip {
- description "Operation to del hicn punt.";
- input {
- uses punting_add_ip; /* It uses the same payload as the add*/
+ rpc hicn-disable {
+ description "Disable hicn on a gie prefix.";
+ input {
+ leaf prefix {
+ type hicn-prefix;
+ }
+ }
}
-}
-
}
diff --git a/docs/source/control.md b/docs/source/control.md
index 07010a8d1..9564a23af 100644
--- a/docs/source/control.md
+++ b/docs/source/control.md
@@ -149,60 +149,17 @@ controler_rpcs_instances.xml in the yang-model. Here you can find the content:
<len>30</len>
</route-get>
-<route-del xmlns="urn:sysrepo:hicn">
- <prefix0>10</prefix0>
- <prefix1>20</prefix1>
- <len>30</len>
-</route-del>
-
-<route-nhops-add xmlns="urn:sysrepo:hicn">
- <prefix0>10</prefix0>
- <prefix1>20</prefix1>
- <len>30</len>
- <face_ids0>40</face_ids0>
- <face_ids1>50</face_ids1>
- <face_ids2>60</face_ids2>
- <face_ids3>70</face_ids3>
- <face_ids4>80</face_ids4>
- <face_ids5>90</face_ids5>
- <face_ids6>100</face_ids6>
- <n_faces>110</n_faces>
-</route-nhops-add>
-
-<route-nhops-del xmlns="urn:sysrepo:hicn">
- <prefix0>10</prefix0>
- <prefix1>20</prefix1>
- <len>30</len>
- <faceid>40</faceid>
-</route-nhops-del>
-
-<face-ip-params-get xmlns="urn:sysrepo:hicn">
+<face-params-get xmlns="urn:sysrepo:hicn">
<faceid>10</faceid>
-</face-ip-params-get>
-
-<face-ip-add xmlns="urn:sysrepo:hicn">
- <nh_addr0>10</nh_addr0>
- <nh_addr1>20</nh_addr1>
- <swif>30</swif>
-</face-ip-add>
+</face-params-get>
-<face-ip-del xmlns="urn:sysrepo:hicn">
- <faceid>0</faceid>
-</face-ip-del>
+<hicn-enable xmlns="urn:sysrepo:hicn">
+ <prefix>b001::/64</prefix>
+</hicn-enable>
-<punting-add xmlns="urn:sysrepo:hicn">
- <prefix0>10</prefix0>
- <prefix1>20</prefix1>
- <len>30</len>
- <swif>40</swif>
-</punting-add>
-
-<punting-del xmlns="urn:sysrepo:hicn">
- <prefix0>10</prefix0>
- <prefix1>20</prefix1>
- <len>30</len>
- <swif>40</swif>
-</punting-del>
+<hicn-disable xmlns="urn:sysrepo:hicn">
+ <prefix>b001::/64</prefix>
+</hicn-disable>
```
#### Run the plugin
diff --git a/docs/source/vpp-plugin.md b/docs/source/vpp-plugin.md
index f93479da8..7f49cd8b9 100644
--- a/docs/source/vpp-plugin.md
+++ b/docs/source/vpp-plugin.md
@@ -188,40 +188,6 @@ sudo vppctl
vpp# hicn ?
```
-`hicn control param`: configures the internal parameter of the hICN plugin.
-This command must be run before hicn control start.
-
-```bash
-hicn control param { pit { size <entries> | { dfltlife | minlife | maxlife } <seconds> } | cs {size <entries> | app <portion to reserved to app>} }
- <entries> :set the maximum number of entry in the PIT or CS. Default for PIT is 131072, for CS is 4096. CS size cannot be grater than PIT size. Moreover CS size must be smaller than (# of vlib buffer - 8196).
- <seconds> :set the default, maximum or minimum lifetime of pit entries. Default value 2s (default), 0.2s (minumum), 20s (maximum)
- <portion to reserved to app> :set the portion of CS to reserve to application running locally on the forwarder. Default is 30% of the cs size.
-```
-
-`hicn control start`: starts the hICN plugin in VPP.
-
-`hicn control stop` : stops the hICN plugin in VPP. Currently not supported.
-
-`hicn face app` : manipulates producer and consumer application faces in the forwarder.
-
-```bash
-hicn face app {add intfc <sw_if> {prod prefix <hicn_prefix> cs_size <size_in_packets>} {cons}} | {del <face_id>}
- <sw_if> :software interface existing in vpp on top of which to create an application face
- <hicn_prefix> :prefix to bound to the producer application face. Only content matching the prefix will be allowed through such face.
- <size_in_packets> :content store size associated to the producer face.
- <face_id> :id of the face to remove
-```
-
-`hicn face ip`: manipulates ip application faces in the forwarder.
-
-```bash
-hicn face ip {add [local <src_address>] remote <dst_address> intfc <sw_if>} | {del id <face_id>}
- <src_address> :the IPv4 or IPv6 local IP address to bind to (not mandatory, if not specified the local address is one of the address assigned to sw_if)
- <dst_address> :the IPv4 or IPv6 address of the remote system
- <sw_if> :software interface on thop of which we create the face
- <face_id> :id of the face to remove
-```
-
`hicn face show`: list the available faces in the forwarder.
```bash
@@ -230,28 +196,6 @@ hicn face show [<face_id>| type <ip/udp>]
<ip/udp> :shows all the ip or udp faces available
```
-`hicn face udp`: manipulates udp application faces in the forwarder.
-
-```bash
-hicn face udp {add src_addr <src_address> port <src_port > dst_addr <dst_address> port <dst_port>} intfc <sw_if> | {del id <face_id>}
- <src_address> :the IPv4 or IPv6 local IP address to bind to
- <src_port> :the local UDP port
- <dst_address> :the IPv4 or IPv6 address of the remote system
- <dst_port> :the remote UDP port
- <sw_if> :software interface on thop of which we create the face
- <face_id> :id of the face to remove
-
-```
-
-`hicn fib`: manipulates hicn fib entries.
-
-```bash
-hicn fib {{add | delete } prefix <prefix> face <face_id> } | set strategy <strategy_id> prefix <prefix>
- <prefix> :prefix to add to the FIB
- <face_id> :face id to add as nexto hop in the FIB entry
- <strategy_id> :set a strategy for the corresponding prefix
-```
-
`hicn pgen client`: set an vpp forwarder as an hicn packet generator client.
```bash
@@ -291,6 +235,21 @@ hicn strategy mw set prefix <prefix> face <face_id> weight <weight>
<weight> :weight
```
+`hicn enable`: enable hICN forwarding pipeline for an ip prefix.
+
+```bash
+hicn enable <prefix>
+ <prefix> :prefix for which the hICN forwarding pipeline is enabled
+```
+
+`hicn disable`: disable hICN forwarding pipeline for an ip prefix.
+
+```bash
+hicn enable <prefix>
+ <prefix> :prefix for which the hICN forwarding pipeline is disable
+```
+
+
#### hICN plugin configuration file
A configuration can be use to setup the hicn plugin when vpp starts.
@@ -328,10 +287,8 @@ forwarders are connected through a dpdk link.
sudo vppctl
vpp# set interface ip address TenGigabitEtherneta/0/0 2001::2/64
vpp# set interface state TenGigabitEtherneta/0/0 up
-vpp# hicn control start
-vpp# hicn face ip add local 2001::2 remote 2001::3 intfc TenGigabitEtherneta/0/0
-vpp# hicn fib add prefix b002::1/64 face 0
-vpp# hicn punting add prefix b002::1/64 intfc TenGigabitEtherneta/0/0 type ip
+vpp# ip route add b002::1/64 via remote 2001::3 TenGigabitEtherneta/0/0
+vpp# hicn enable b002::1/64
```
#### Forwarder B (server)
@@ -340,8 +297,6 @@ vpp# hicn punting add prefix b002::1/64 intfc TenGigabitEtherneta/0/0 type ip
sudo vppctl
vpp# set interface ip address TenGigabitEtherneta/0/1 2001::3/64
vpp# set interface state TenGigabitEtherneta/0/1 up
-vpp# hicn control start
-vpp# hicn punting add prefix b002::1/64 intfc TenGigabitEtherneta/0/1 type ip
```
Once the two forwarder are started, run the `ping_server` application on the
@@ -380,6 +335,7 @@ sudo vppctl
vpp# set interface ip address TenGigabitEtherneta/0/0 2001::2/64
vpp# set interface state TenGigabitEtherneta/0/0 up
vpp# ip route add b001::/64 via 2001::3 TenGigabitEtherneta/0/0
+vpp# ip route add 2001::3 via TenGigabitEtherneta/0/0
vpp# hicn pgen client src 2001::2 name b001::1/64 intfc TenGigabitEtherneta/0/0
vpp# exec /<path_to>pg.conf
vpp# packet-generator enable-stream hicn-pg
@@ -419,8 +375,8 @@ vpp# hicn pgen server name b001::1/64 intfc TenGigabitEtherneta/0/1
sudo vppctl
vpp# set interface ip address TenGigabitEtherneta/0/0 2001::2/64
vpp# set interface state TenGigabitEtherneta/0/0 up
-vpp# hicn face ip add remote 2001::3 intfc TenGigabitEtherneta/0/0
-vpp# hicn fib add prefix b001::/64 face 0
+vpp# ip route add b001::/64 via 2001::3 TenGigabitEtherneta/0/0
+vpp# hicn enable b001::/64
vpp# create loopback interface
vpp# set interface state loop0 up
vpp# set interface ip address loop0 5002::1/64
@@ -442,7 +398,7 @@ vpp# create loopback interface
vpp# set interface state loop0 up
vpp# set interface ip address loop0 2002::1/64
vpp# ip neighbor loop1 2002::2 de:ad:00:00:00:00
-vpp# hicn face ip add remote 2002::2 intfc loop0
-vpp# hicn fib add prefix b001::/64 face 0
+vpp# ip route add b001::/64 via 2002::2 loop0
+vpp# hicn enable b001::/64
vpp# hicn pgen server name b001::1/64 intfc loop0
```
diff --git a/hicn-plugin/src/cli.c b/hicn-plugin/src/cli.c
index b3d03294d..5d613c535 100644
--- a/hicn-plugin/src/cli.c
+++ b/hicn-plugin/src/cli.c
@@ -364,17 +364,16 @@ done:
* cli handler for 'fib'
*/
static clib_error_t *
-hicn_cli_fib_set_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_cli_strategy_set_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
+ vlib_cli_command_t * cmd)
{
clib_error_t *cl_err = 0;
int rv = HICN_ERROR_NONE;
int addpfx = -1;
ip46_address_t address;
- hicn_face_id_t faceid = HICN_FACE_NULL;
u32 strategy_id;
- u8 plen = 0;
+ u32 plen = 0;
fib_prefix_t prefix;
/* Get a line of input. */
@@ -385,15 +384,7 @@ hicn_cli_fib_set_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
}
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (addpfx == -1 && unformat (line_input, "add"))
- {
- addpfx = 1;
- }
- else if (addpfx == -1 && unformat (line_input, "delete"))
- {
- addpfx = 0;
- }
- else if (unformat (line_input, "set strategy %d", &strategy_id))
+ if (unformat (line_input, "set %d", &strategy_id))
{
addpfx = 2;
}
@@ -402,9 +393,6 @@ hicn_cli_fib_set_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
&address, IP46_TYPE_ANY, &plen))
{;
}
- else if (addpfx <= 1 && unformat (line_input, "face %u", &faceid))
- {;
- }
else
{
cl_err = clib_error_return (0, "%s '%U'",
@@ -417,63 +405,18 @@ hicn_cli_fib_set_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
fib_prefix_from_ip46_addr (&address, &prefix);
prefix.fp_len = plen;
/* Check parse */
- if (addpfx <= 1
- && ((ip46_address_is_zero (&prefix.fp_addr))
- || faceid == HICN_FACE_NULL))
- {
- cl_err =
- clib_error_return (0, "Please specify prefix and a valid faceid...");
- goto done;
- }
- /* Check parse */
- if ((ip46_address_is_zero (&prefix.fp_addr))
- || (addpfx == 2 && hicn_dpo_strategy_id_is_valid (strategy_id)))
+ if (hicn_dpo_strategy_id_is_valid (strategy_id) == HICN_ERROR_DPO_MGR_ID_NOT_VALID)
{
cl_err = clib_error_return (0,
- "Please specify prefix and strategy_id...");
+ "Please specify a valid strategy...");
goto done;
}
- if (addpfx == 0)
- {
- if (ip46_address_is_zero (&prefix.fp_addr))
- {
- cl_err = clib_error_return (0, "Please specify prefix");
- goto done;
- }
- if (faceid == HICN_FACE_NULL)
- {
- rv = hicn_route_del (&prefix);
- }
- else
- {
- rv = hicn_route_del_nhop (&prefix, faceid);
- }
- cl_err =
- (rv == HICN_ERROR_NONE) ? NULL : clib_error_return (0,
- get_error_string
- (rv));
- }
- else if (addpfx == 1)
- {
- rv = hicn_route_add (&faceid, 1, &prefix);
- if (rv == HICN_ERROR_ROUTE_ALREADY_EXISTS)
- {
- rv = hicn_route_add_nhops (&faceid, 1, &prefix);
- }
- cl_err =
- (rv == HICN_ERROR_NONE) ? NULL : clib_error_return (0,
- get_error_string
- (rv));
- }
- else if (addpfx == 2)
- {
- rv = hicn_route_set_strategy (&prefix, strategy_id);
- cl_err =
- (rv == HICN_ERROR_NONE) ? NULL : clib_error_return (0,
- get_error_string
- (rv));
- }
+ rv = hicn_route_set_strategy (&prefix, strategy_id);
+ cl_err =
+ (rv == HICN_ERROR_NONE) ? NULL : clib_error_return (0,
+ get_error_string
+ (rv));
done:
return (cl_err);
@@ -886,13 +829,12 @@ VLIB_CLI_COMMAND(hicn_cli_node_ctl_command, static)=
};
/* cli declaration for 'fib' */
-VLIB_CLI_COMMAND(hicn_cli_fib_set_command, static)=
-{
- .path = "hicn fib",
- .short_help = "hicn fib {{add | delete } prefix <prefix> face <facei_d> }"
- " | set strategy <strategy_id> prefix <prefix>",
- .function = hicn_cli_fib_set_command_fn,
-};
+VLIB_CLI_COMMAND(hicn_cli_strategy_set_command, static)=
+ {
+ .path = "hicn strategy",
+ .short_help = "hicn strategy set <strategy_id> prefix <prefix>",
+ .function = hicn_cli_strategy_set_command_fn,
+ };
/* cli declaration for 'show' */
VLIB_CLI_COMMAND(hicn_cli_show_command, static)=
diff --git a/hicn-plugin/src/hicn.api b/hicn-plugin/src/hicn.api
index 753491c5f..9643f2098 100644
--- a/hicn-plugin/src/hicn.api
+++ b/hicn-plugin/src/hicn.api
@@ -294,78 +294,6 @@ define hicn_api_face_get_reply
vl_api_hicn_face_t face;
};
-define hicn_api_route_nhops_add
-{
- /* Client identifier, set from api_main.my_client_index */
- u32 client_index;
-
- /* Arbitrary context, so client can match reply to request */
- u32 context;
-
- /* Prefix to be added to the FIB */
- vl_api_prefix_t prefix;
-
- /* A Face ID to the next hop forwarder for the specified prefix */
- u32 face_ids[10];
-
- /* Number of face to add */
- u8 n_faces;
-};
-
-define hicn_api_route_nhops_add_reply
-{
- /* From the request */
- u32 context;
-
- /* Return value, zero means all OK */
- i32 retval;
-};
-
-define hicn_api_route_del
-{
- /* Client identifier, set from api_main.my_client_index */
- u32 client_index;
-
- /* Arbitrary context, so client can match reply to request */
- u32 context;
-
- /* Prefix to be added to the FIB */
- vl_api_prefix_t prefix;
-};
-
-define hicn_api_route_del_reply
-{
- /* From the request */
- u32 context;
-
- /* Return value, zero means all OK */
- i32 retval;
-};
-
-define hicn_api_route_nhop_del
-{
- /* Client identifier, set from api_main.my_client_index */
- u32 client_index;
-
- /* Arbitrary context, so client can match reply to request */
- u32 context;
-
- /* Prefix to be added to the FIB */
- vl_api_prefix_t prefix;
-
- /* Specific next-hop to be removed */
- u32 faceid;
-};
-
-define hicn_api_route_nhop_del_reply
-{
- /* From the request */
- u32 context;
-
- /* Return value, zero means all OK */
- i32 retval;
-};
-
define hicn_api_route_get
{
/* Client identifier, set from api_main.my_client_index */
diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c
index 1aa6178a7..f5d2cee74 100644
--- a/hicn-plugin/src/hicn_api.c
+++ b/hicn-plugin/src/hicn_api.c
@@ -304,77 +304,6 @@ static void
/****** ROUTE *******/
-static void
-vl_api_hicn_api_route_nhops_add_t_handler (vl_api_hicn_api_route_nhops_add_t
- * mp)
-{
- vl_api_hicn_api_route_nhops_add_reply_t *rmp;
- int rv = HICN_ERROR_NONE;
- hicn_face_id_t face_ids[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
-
- hicn_main_t *sm = &hicn_main;
-
- fib_prefix_t prefix;
- ip_prefix_decode (&mp->prefix, &prefix);
-
- u8 n_faces = mp->n_faces;
-
- for (int i = 0; i < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; i++)
- {
- face_ids[i] = clib_net_to_host_u32 (mp->face_ids[i]);
- }
-
- if ((face_ids == NULL) || (n_faces > HICN_PARAM_FIB_ENTRY_NHOPS_MAX))
- {
- rv = VNET_API_ERROR_INVALID_ARGUMENT;
- }
- if (rv == HICN_ERROR_NONE)
- {
- rv = hicn_route_add (face_ids, n_faces, &prefix);
-
- if (rv == HICN_ERROR_ROUTE_ALREADY_EXISTS)
- {
- rv = hicn_route_add_nhops (face_ids, n_faces, &prefix);
- }
- }
- REPLY_MACRO (VL_API_HICN_API_ROUTE_NHOPS_ADD_REPLY /* , rmp, mp, rv */ );
-}
-
-
-static void vl_api_hicn_api_route_del_t_handler
- (vl_api_hicn_api_route_del_t * mp)
-{
- vl_api_hicn_api_route_del_reply_t *rmp;
- int rv = HICN_ERROR_NONE;
-
- hicn_main_t *sm = &hicn_main;
-
- fib_prefix_t prefix;
- ip_prefix_decode (&mp->prefix, &prefix);
-
- rv = hicn_route_del (&prefix);
-
- REPLY_MACRO (VL_API_HICN_API_ROUTE_DEL_REPLY /* , rmp, mp, rv */ );
-}
-
-static void vl_api_hicn_api_route_nhop_del_t_handler
- (vl_api_hicn_api_route_nhop_del_t * mp)
-{
- vl_api_hicn_api_route_nhop_del_reply_t *rmp;
- int rv = HICN_ERROR_NONE;
-
- hicn_main_t *sm = &hicn_main;
-
- fib_prefix_t prefix;
- ip_prefix_decode (&mp->prefix, &prefix);
- hicn_face_id_t faceid = clib_net_to_host_u32 (mp->faceid);
-
-
- rv = hicn_route_del_nhop (&prefix, faceid);
-
- REPLY_MACRO (VL_API_HICN_API_ROUTE_NHOP_DEL_REPLY /* , rmp, mp, rv */ );
-}
-
static void vl_api_hicn_api_route_get_t_handler
(vl_api_hicn_api_route_get_t * mp)
{
diff --git a/hicn-plugin/src/hicn_api_test.c b/hicn-plugin/src/hicn_api_test.c
index a09e62c58..e4704e8ea 100644
--- a/hicn-plugin/src/hicn_api_test.c
+++ b/hicn-plugin/src/hicn_api_test.c
@@ -222,9 +222,6 @@ hicn_test_main_t hicn_test_main;
#define foreach_standard_reply_retval_handler \
_(hicn_api_node_params_set_reply) \
-_(hicn_api_route_nhops_add_reply) \
-_(hicn_api_route_del_reply) \
-_(hicn_api_route_nhop_del_reply) \
_(hicn_api_enable_disable_reply)
#define _(n) \
@@ -255,12 +252,9 @@ _(HICN_API_NODE_STATS_GET_REPLY, hicn_api_node_stats_get_reply) \
_(HICN_API_FACE_GET_REPLY, hicn_api_face_get_reply) \
_(HICN_API_FACES_DETAILS, hicn_api_faces_details) \
_(HICN_API_FACE_STATS_DETAILS, hicn_api_face_stats_details) \
-_(HICN_API_ROUTE_NHOPS_ADD_REPLY, hicn_api_route_nhops_add_reply) \
_(HICN_API_FACE_PARAMS_GET_REPLY, hicn_api_face_params_get_reply) \
_(HICN_API_ROUTE_GET_REPLY, hicn_api_route_get_reply) \
_(HICN_API_ROUTES_DETAILS, hicn_api_routes_details) \
-_(HICN_API_ROUTE_DEL_REPLY, hicn_api_route_del_reply) \
-_(HICN_API_ROUTE_NHOP_DEL_REPLY, hicn_api_route_nhop_del_reply) \
_(HICN_API_STRATEGIES_GET_REPLY, hicn_api_strategies_get_reply) \
_(HICN_API_STRATEGY_GET_REPLY, hicn_api_strategy_get_reply) \
_(HICN_API_ENABLE_DISABLE_REPLY, hicn_api_enable_disable_reply) \
@@ -552,6 +546,9 @@ api_hicn_api_faces_dump (vat_main_t * vam)
M (HICN_API_FACES_DUMP, mp);
S (mp);
+ if (!hm->ping_id)
+ hm->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));
+
/* Use a control ping for synchronization */
mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));
mp_ping->_vl_msg_id = htons (hm->ping_id);
@@ -655,6 +652,9 @@ api_hicn_api_face_stats_dump (vat_main_t * vam)
M (HICN_API_FACE_STATS_DUMP, mp);
S (mp);
+ if (!hm->ping_id)
+ hm->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));
+
/* Use a control ping for synchronization */
mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));
mp_ping->_vl_msg_id = htons (hm->ping_id);
@@ -757,6 +757,9 @@ api_hicn_api_routes_dump (vat_main_t * vam)
M (HICN_API_ROUTES_DUMP, mp);
S (mp);
+ if (!hm->ping_id)
+ hm->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));
+
/* Use a control ping for synchronization */
mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));
mp_ping->_vl_msg_id = htons (hm->ping_id);
@@ -847,152 +850,6 @@ static void
}
static int
-api_hicn_api_route_nhops_add (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_hicn_api_route_nhops_add_t *mp;
-
- fib_prefix_t prefix;
- u32 faceid = 0;
- int ret;
-
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "add prefix %U/%d", unformat_ip46_address,
- &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len))
- {;
- }
- else if (unformat (input, "face %d", &faceid))
- {;
- }
- else
- {
- break;
- }
- }
-
- /* Check parse */
- if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0))
- || (prefix.fp_len == 0) || (faceid == 0))
- {
- clib_warning ("Please specify prefix and faceid...");
- return 1;
- }
- /* Construct the API message */
- M (HICN_API_ROUTE_NHOPS_ADD, mp);
- ip_prefix_encode (&prefix, &mp->prefix);
-
- if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
- prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
-
- mp->face_ids[0] = clib_host_to_net_u32 (faceid);
- mp->n_faces = 1;
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return ret;
-}
-
-static int
-api_hicn_api_route_del (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_hicn_api_route_del_t *mp;
-
- fib_prefix_t prefix;
- int ret;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "prefix %U/%d", unformat_ip46_address,
- &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len))
- {;
- }
- else
- {
- break;
- }
- }
-
- /* Check parse */
- if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0))
- || (prefix.fp_len == 0))
- {
- clib_warning ("Please specify prefix...");
- return 1;
- }
- /* Construct the API message */
- M (HICN_API_ROUTE_DEL, mp);
- ip_prefix_encode (&prefix, &mp->prefix);
-
- if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
- prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return ret;
-
-}
-
-static int
-api_hicn_api_route_nhop_del (vat_main_t * vam)
-{
- unformat_input_t *input = vam->input;
- vl_api_hicn_api_route_nhop_del_t *mp;
-
- fib_prefix_t prefix;
- int faceid = 0, ret;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "del prefix %U/%d", unformat_ip46_address,
- &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len))
- {;
- }
- else if (unformat (input, "face %d", &faceid))
- {;
- }
- else
- {
- break;
- }
- }
-
- /* Check parse */
- if (((prefix.fp_addr.as_u64[0] == 0) && (prefix.fp_addr.as_u64[1] == 0))
- || (prefix.fp_len == 0) || (faceid == HICN_FACE_NULL))
- {
- clib_warning ("Please specify prefix and faceid...");
- return 1;
- }
- /* Construct the API message */
- M (HICN_API_ROUTE_NHOP_DEL, mp);
- ip_prefix_encode (&prefix, &mp->prefix);
-
- if (!ip46_address_is_ip4 (&(prefix.fp_addr)))
- prefix.fp_proto = fib_proto_from_ip46 (IP46_TYPE_IP6);
-
- mp->faceid = clib_host_to_net_u32 (faceid);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
-
- return ret;
-}
-
-static int
api_hicn_api_strategies_get (vat_main_t * vam)
{
vl_api_hicn_api_strategies_get_t *mp;
diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c
index 0096edb2b..b569d431e 100644
--- a/hicn-plugin/src/route.c
+++ b/hicn-plugin/src/route.c
@@ -103,238 +103,6 @@ hicn_route_get_dpo (const fib_prefix_t * prefix,
}
int
-hicn_route_add_nhops (hicn_face_id_t * face_id, u32 len,
- const fib_prefix_t * prefix)
-{
- const dpo_id_t *hicn_dpo_id;
- int ret = HICN_ERROR_NONE;
- hicn_face_id_t faces_id_tmp[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
- int n_face_id = 0;
- const hicn_dpo_vft_t *dpo_vft;
- u32 fib_index;
- vlib_main_t *vm = vlib_get_main ();
-
- if (face_id == NULL)
- {
- return HICN_ERROR_ROUTE_INVAL;
- }
- /*
- * Check is the faces are available, otherwise skip the face
- * id_adjacency existance is not checked. It should be checked before
- * sending a packet out
- */
- for (int i = 0; i < clib_min (HICN_PARAM_FIB_ENTRY_NHOPS_MAX, len); i++)
- {
- hicn_face_t *face = hicn_dpoi_get_from_idx_safe (face_id[i]);
-
- if (face == NULL)
- {
- vlib_cli_output (vm, "Face %d not found, skip...\n", face_id[i]);
- return ret;
- }
- else
- {
- faces_id_tmp[n_face_id++] = face_id[i];
- }
- }
-
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- if (ret == HICN_ERROR_NONE)
- {
- for (int i = 0; i < n_face_id && (ret == HICN_ERROR_NONE); i++)
- {
- u32 vft_id = hicn_dpo_get_vft_id (hicn_dpo_id);
- dpo_vft = hicn_dpo_get_vft (vft_id);
-
- hicn_face_t *face =
- hicn_dpoi_get_from_idx (faces_id_tmp[i]);
- //Disable feature on the interface
- if (prefix->fp_proto == FIB_PROTOCOL_IP4)
- vnet_feature_enable_disable ("ip4-local", "hicn-data-input-ip4",
- face->sw_if, 1, 0, 0);
- else if (prefix->fp_proto == FIB_PROTOCOL_IP6)
- vnet_feature_enable_disable ("ip6-local", "hicn-data-input-ip6",
- face->sw_if, 1, 0, 0);
-
- ret = dpo_vft->hicn_dpo_add_update_nh (faces_id_tmp[i],
- hicn_dpo_id->dpoi_index);
- }
- }
- return ret;
-}
-
-/* Add a new route for a name prefix */
-int
-hicn_route_add (hicn_face_id_t * face_id, u32 len,
- const fib_prefix_t * prefix)
-{
- dpo_id_t dpo = DPO_INVALID;
- const dpo_id_t *hicn_dpo_id;
- int ret = HICN_ERROR_NONE;
- hicn_face_id_t face_id_tmp[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
- int n_face_id = 0;
- index_t dpo_idx;
- u32 fib_index;
- vlib_main_t *vm = vlib_get_main ();
-
- if (face_id == NULL || !hicn_dpoi_idx_is_valid (*face_id))
- {
- return HICN_ERROR_ROUTE_INVAL;
- }
- /*
- * Check is the faces are available, otherwise skip the face
- * id_adjacency existance is not checked. It should be checked before
- * sending a packet out
- */
- for (int i = 0; i < clib_min (HICN_PARAM_FIB_ENTRY_NHOPS_MAX, len); i++)
- {
- hicn_face_t *face = hicn_dpoi_get_from_idx (face_id[i]);
-
- if (face == NULL)
- {
- vlib_cli_output (vm, "Face %d not found, skip...\n", face_id[i]);
- return ret;
- }
- else
- {
- face_id_tmp[n_face_id++] = face_id[i];
- }
- }
-
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- if (ret == HICN_ERROR_ROUTE_NOT_FOUND)
- {
- hicn_face_id_t nhops[HICN_PARAM_FIB_ENTRY_NHOPS_MAX];
- for (int i = 0; i < n_face_id; i++)
- {
- nhops[i] = face_id_tmp[i];
- hicn_face_t *face =
- hicn_dpoi_get_from_idx (face_id_tmp[i]);
- //Disable feature on the interface
- if (prefix->fp_proto == FIB_PROTOCOL_IP4)
- vnet_feature_enable_disable ("ip4-local", "hicn-data-input-ip4",
- face->sw_if, 1, 0, 0);
- else if (prefix->fp_proto == FIB_PROTOCOL_IP6)
- vnet_feature_enable_disable ("ip6-local", "hicn-data-input-ip6",
- face->sw_if, 1, 0, 0);
- }
-
- default_dpo.hicn_dpo_create (prefix->fp_proto, nhops, n_face_id,
- &dpo_idx);
-
- /* the value we got when we registered */
- /*
- * This should be taken from the name?!? the index of the
- * object
- */
- dpo_set (&dpo,
- default_dpo.hicn_dpo_get_type (),
- (ip46_address_is_ip4 (&prefix->fp_addr) ? DPO_PROTO_IP4 :
- DPO_PROTO_IP6), dpo_idx);
-
- /* Here is where we create the "via" like route */
- /*
- * For the moment we use the global one the prefix you want
- * to match Neale suggested -- FIB_SOURCE_HICN the client
- * that is adding them -- no easy explanation at this timeā€¦
- */
- fib_node_index_t new_fib_node_index =
- fib_table_entry_special_dpo_add (fib_index,
- prefix,
- hicn_fib_src,
- (FIB_ENTRY_FLAG_EXCLUSIVE |
- FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT),
- &dpo);
-
- /* We added a route, therefore add one lock to the table */
- fib_table_lock (fib_index, prefix->fp_proto, hicn_fib_src);
-
- dpo_unlock (&dpo);
- ret =
- (new_fib_node_index !=
- FIB_NODE_INDEX_INVALID) ? HICN_ERROR_NONE :
- HICN_ERROR_ROUTE_NO_INSERT;
-
- /*
- * TODO: we might want to store the fib index in the face.
- * This will help to update the fib entries when a face is
- * deleted. Fib_index_t is returned from
- * fib_table_entry_special_dpo_add.
- */
- }
- else if (ret == HICN_ERROR_NONE)
- {
- ret = hicn_route_add_nhops (face_id, len, prefix);
- }
- return ret;
-}
-
-int
-hicn_route_del (fib_prefix_t * prefix)
-{
- const dpo_id_t *hicn_dpo_id;
- int ret = HICN_ERROR_NONE;
- u32 fib_index;
-
- /* Remove the fib entry only if the dpo is of type hicn */
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- if (ret == HICN_ERROR_NONE)
- {
- fib_table_entry_special_remove (HICN_FIB_TABLE, prefix, hicn_fib_src);
-
- /*
- * Remove the lock from the table. We keep one lock per route
- */
- fib_table_unlock (fib_index, prefix->fp_proto, hicn_fib_src);
- }
- //Remember to remove the lock from the table when removing the entry
- return ret;
-}
-
-int
-hicn_route_del_nhop (fib_prefix_t * prefix, hicn_face_id_t face_id)
-{
- const dpo_id_t *hicn_dpo_id;
- int ret;
- u32 vft_id;
- const hicn_dpo_vft_t *dpo_vft;
- u32 fib_index;
-
-
- ret = hicn_route_get_dpo (prefix, &hicn_dpo_id, &fib_index);
-
- /* Check if the dpo is an hicn_dpo_t */
- if (ret == HICN_ERROR_NONE)
- {
- vft_id = hicn_dpo_get_vft_id (hicn_dpo_id);
- dpo_vft = hicn_dpo_get_vft (vft_id);
-
- hicn_face_t *face = hicn_dpoi_get_from_idx (face_id);
- //Disable feature on the interface
- if (prefix->fp_proto == FIB_PROTOCOL_IP4)
- vnet_feature_enable_disable ("ip4-local", "hicn-data-input-ip4",
- face->sw_if, 0, 0, 0);
- else if (prefix->fp_proto == FIB_PROTOCOL_IP6)
- vnet_feature_enable_disable ("ip6-local", "hicn-data-input-ip6",
- face->sw_if, 0, 0, 0);
-
- ret = dpo_vft->hicn_dpo_del_nh (face_id, hicn_dpo_id->dpoi_index);
-
- hicn_dpo_ctx_t *dpo_ctx =
- hicn_strategy_dpo_ctx_get (hicn_dpo_id->dpoi_index);
-
-
- if (ret == HICN_ERROR_NONE && !dpo_ctx->entry_count)
- ret = hicn_route_del (prefix);
- }
- //Remember to remove the lock from the table when removing the entry
- return ret;
-}
-
-int
hicn_route_set_strategy (fib_prefix_t * prefix, u8 strategy_id)
{
const dpo_id_t *hicn_dpo_id;
diff --git a/hicn-plugin/src/route.h b/hicn-plugin/src/route.h
index 4ff514740..4918f275b 100644
--- a/hicn-plugin/src/route.h
+++ b/hicn-plugin/src/route.h
@@ -32,25 +32,6 @@ int
hicn_route_get_dpo (const fib_prefix_t * prefix,
const dpo_id_t ** hicn_dpo, u32 * fib_index);
-/*
- * Add a new route for a name prefix
- */
-int
-hicn_route_add (hicn_face_id_t * face_id, u32 len,
- const fib_prefix_t * prefix);
-
-/*
- * Add new next hops for a prefix route
- */
-int
-hicn_route_add_nhops (hicn_face_id_t * face_id, u32 len,
- const fib_prefix_t * prefix);
-
-/* Remove a route for a name prefix */
-int hicn_route_del (fib_prefix_t * prefix);
-
-/* Remove a next hop route for a name prefix */
-int hicn_route_del_nhop (fib_prefix_t * prefix, u32 face_id);
/* Remove a next hop route for a name prefix */
int
diff --git a/libtransport/src/core/hicn_forwarder_interface.cc b/libtransport/src/core/hicn_forwarder_interface.cc
index 810daba3a..5a0faa360 100644
--- a/libtransport/src/core/hicn_forwarder_interface.cc
+++ b/libtransport/src/core/hicn_forwarder_interface.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 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:
diff --git a/libtransport/src/core/hicn_forwarder_interface.h b/libtransport/src/core/hicn_forwarder_interface.h
index 6969f4a6b..c4138c6c2 100644
--- a/libtransport/src/core/hicn_forwarder_interface.h
+++ b/libtransport/src/core/hicn_forwarder_interface.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 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:
diff --git a/libtransport/src/core/hicn_vapi.c b/libtransport/src/core/hicn_vapi.c
index d19e36346..be556f3aa 100644
--- a/libtransport/src/core/hicn_vapi.c
+++ b/libtransport/src/core/hicn_vapi.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 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:
@@ -18,7 +18,6 @@
#ifdef __vpp__
#include <hicn/transport/utils/log.h>
-
#include <core/hicn_vapi.h>
#define HICN_VPP_PLUGIN
@@ -31,10 +30,10 @@
#include <vlibmemory/api.h>
#include <vppinfra/error.h>
-#include <vnet/fib/fib_types.h>
#include <vnet/ip/format.h>
#include <vnet/ip/ip4_packet.h>
#include <vnet/ip/ip6_packet.h>
+#include <vapi/ip.api.vapi.h>
#include <vapi/hicn.api.vapi.h>
#include <vpp_plugins/hicn/error.h>
@@ -54,6 +53,7 @@ u8 *format_vl_api_address_union(u8 *s, va_list *args) { return NULL; }
/*********************************************************************************/
DEFINE_VAPI_MSG_IDS_HICN_API_JSON
+DEFINE_VAPI_MSG_IDS_IP_API_JSON
static vapi_error_e register_prod_app_cb(
vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
@@ -184,7 +184,7 @@ int hicn_vapi_face_cons_del(vapi_ctx_t ctx,
static vapi_error_e reigster_route_cb(
vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv, bool is_last,
- vapi_payload_hicn_api_route_nhops_add_reply *reply) {
+ vapi_payload_ip_route_add_del_reply *reply) {
if (reply == NULL) return rv;
return reply->retval;
@@ -193,17 +193,36 @@ static vapi_error_e reigster_route_cb(
int hicn_vapi_register_route(vapi_ctx_t ctx,
hicn_producer_set_route_params *input_params) {
vapi_lock();
- vapi_msg_hicn_api_route_nhops_add *msg =
- vapi_alloc_hicn_api_route_nhops_add(ctx);
+ vapi_msg_ip_route_add_del *msg = vapi_alloc_ip_route_add_del(ctx, 1);
+
+ msg->payload.is_add = 1;
+ if (ip46_address_is_ip4((ip46_address_t *)(input_params->prod_addr))) {
+ memcpy(&msg->payload.route.prefix.address.un.ip4, &input_params->prefix->address.v4,
+ sizeof(ip4_address_t));
+ msg->payload.route.prefix.address.af = ADDRESS_IP4;
+ msg->payload.route.prefix.len = input_params->prefix->len;
+ } else {
+ memcpy(&msg->payload.route.prefix.address.un.ip6, &input_params->prefix->address.v6,
+ sizeof(ip6_address_t));
+ msg->payload.route.prefix.address.af = ADDRESS_IP6;
+ msg->payload.route.prefix.len = input_params->prefix->len;
+ }
+
+ msg->payload.route.paths[0].sw_if_index = ~0;
+ msg->payload.route.paths[0].table_id = 0;
+ if (ip46_address_is_ip4((ip46_address_t *)(input_params->prod_addr))) {
+ memcpy(&(msg->payload.route.paths[0].nh.address.ip4), input_params->prod_addr->v4.as_u8, sizeof(ip4_address_t));
+ msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP4;
+ }
+ else{
+ memcpy(&(msg->payload.route.paths[0].nh.address.ip6), input_params->prod_addr->v6.as_u8, sizeof(ip6_address_t));
+ msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP6;
+ }
- fib_prefix_t prefix;
- memcpy(&prefix.fp_addr, &input_params->prefix->address,
- sizeof(ip46_address_t));
- prefix.fp_len = input_params->prefix->len;
- msg->payload.face_ids[0] = input_params->face_id;
- msg->payload.n_faces = 1;
+ msg->payload.route.paths[0].type = FIB_API_PATH_FLAG_NONE;
+ msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE;
- int ret = vapi_hicn_api_route_nhops_add(ctx, msg, reigster_route_cb, NULL);
+ int ret = vapi_ip_route_add_del(ctx, msg, reigster_route_cb, NULL);
vapi_unlock();
return ret;
diff --git a/libtransport/src/core/hicn_vapi.h b/libtransport/src/core/hicn_vapi.h
index f2718e6f5..f5d61e7ef 100644
--- a/libtransport/src/core/hicn_vapi.h
+++ b/libtransport/src/core/hicn_vapi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 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:
@@ -20,6 +20,8 @@
#ifdef __vpp__
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -57,7 +59,7 @@ typedef struct {
typedef struct {
ip_prefix_t* prefix;
- uint32_t face_id;
+ ip_address_t* prod_addr;
} hicn_producer_set_route_params;
int hicn_vapi_register_prod_app(
diff --git a/libtransport/src/core/vpp_forwarder_interface.cc b/libtransport/src/core/vpp_forwarder_interface.cc
index 7b4298592..28a2560b3 100644
--- a/libtransport/src/core/vpp_forwarder_interface.cc
+++ b/libtransport/src/core/vpp_forwarder_interface.cc
@@ -167,7 +167,7 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) {
params.prefix->address = addr.address;
params.prefix->family = addr.family;
params.prefix->len = addr.len;
- params.face_id = face_id1_;
+ params.prod_addr = &producer_locator;
int ret = hicn_vapi_register_route(VPPForwarderInterface::sock_, &params);
diff --git a/libtransport/src/core/vpp_forwarder_interface.h b/libtransport/src/core/vpp_forwarder_interface.h
index eb759f8bc..bc83f476e 100644
--- a/libtransport/src/core/vpp_forwarder_interface.h
+++ b/libtransport/src/core/vpp_forwarder_interface.h
@@ -21,6 +21,7 @@
#include <hicn/transport/core/prefix.h>
+
#ifdef always_inline
#undef always_inline
#endif