aboutsummaryrefslogtreecommitdiffstats
path: root/utils/sysrepo-plugins/hicn-plugin/plugin
diff options
context:
space:
mode:
authorMasoud Hemmatpour <mhemmatp@cisco.com>2019-04-04 13:34:04 +0200
committerMauro Sardara <msardara@cisco.com>2019-05-03 08:54:29 +0000
commite9a02cb3a565daab16e295c551dff80501f94974 (patch)
tree891701aac1b440c4e74c31f485dad667bfab3924 /utils/sysrepo-plugins/hicn-plugin/plugin
parent305e7617be61d21ebd0dee043588c469bc28ad3b (diff)
[HICN-153] vapi definition warning
Change-Id: I50f381540e171fe2808d4e56cc24ba6d66e8a2ab Signed-off-by: Masoud Hemmatpour <mhemmatp@cisco.com>
Diffstat (limited to 'utils/sysrepo-plugins/hicn-plugin/plugin')
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c6
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h19
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h2
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c2120
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h157
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c6
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h6
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/yang/controler_rpcs_instances.xml76
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/yang/model/hicn.yang536
-rw-r--r--utils/sysrepo-plugins/hicn-plugin/plugin/yang/startup.xml11
10 files changed, 1262 insertions, 1677 deletions
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c b/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c
index 2add127f2..f044c5b1b 100644
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c
+++ b/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c
@@ -13,6 +13,7 @@
* limitations under the License.
*/
#include "hicn_vpp_comm.h"
+#include <vapi/vapi.h>
@@ -21,7 +22,10 @@
#define MAX_OUTSTANDING_REQUESTS 4
#define RESPONSE_QUEUE_SIZE 2
vapi_ctx_t g_vapi_ctx_instance=NULL;
-DEFINE_VAPI_MSG_IDS_HICN_API_JSON;
+
+// Use VAPI macros to define symbols
+
+
int hicn_connect_vpp() {
HICN_INVOKE_BEGIN;
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h b/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h
index aff8e2ea1..fd71dbaf2 100644
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h
+++ b/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h
@@ -41,9 +41,7 @@
#define HICN_LOG_ERR_MSG // SRP_LOG_ERR_MSG
#endif
-//DEFINE_VAPI_MSG_IDS_VPE_API_JSON
-DEFINE_VAPI_MSG_IDS_HICN_API_JSON;
// ctx vpp connect
extern vapi_ctx_t g_vapi_ctx_instance;
@@ -72,13 +70,13 @@ extern vapi_ctx_t g_vapi_ctx_instance;
ARG_CHECK(retval, arg1); \
ARG_CHECK(retval, arg2)
-#define ARG_CHECK5(retval, arg1, arg2, arg3, arg4, arg5) \
+#define ARG_CHECK6(retval, arg1, arg2, arg3, arg4, arg5, arg6) \
ARG_CHECK(retval, arg1); \
ARG_CHECK(retval, arg2); \
ARG_CHECK(retval, arg3); \
ARG_CHECK(retval, arg4); \
- ARG_CHECK(retval, arg5)
-
+ ARG_CHECK(retval, arg5); \
+ ARG_CHECK(retval, arg6)
/**
@@ -113,6 +111,17 @@ extern vapi_ctx_t g_vapi_ctx_instance;
} while (0);
+// define the error list
+typedef enum {
+ HICN_OK = 0, /* Success */
+ HICN_EINVAL, /* Invalid value encountered */
+ HICN_EAGAIN, /* Operation would block */
+ HICN_ENOTSUP, /* Operation not supported */
+ HICN_ENOMEM, /* Out of memory */
+ HICN_NOT_FOUND, /* Required element can not be found */
+} hicn_error_e;
+
+
int hicn_connect_vpp();
int hicn_disconnect_vpp();
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h b/utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h
index dec789853..0f6c7f8b4 100644
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h
+++ b/utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h
@@ -16,8 +16,6 @@
#ifndef __IETF_INTERFACE_H__
#define __IETF_INTERFACE_H__
-//#include "../sc_model.h"
-
int ietf_subscribe_events(sr_session_ctx_t *session,
sr_subscription_ctx_t **subscription);
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c b/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
index 340d403fb..b49839c53 100644
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
+++ b/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c
@@ -1,21 +1,30 @@
/*
- * Copyright (c) 2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright (c) 2019 Cisco and/or its affiliates.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <malloc.h>
#include <sysrepo/xpath.h>
#include <inttypes.h>
+#include <unistd.h>
+#include <pthread.h>
+
+
+
+#include <sched.h>
/* Hicn headers */
#include <vapi/hicn.api.vapi.h>
@@ -26,7 +35,8 @@
#include "tlock.h"
-//vapi_ctx_t g_vapi_ctx_instance=NULL;
+DEFINE_VAPI_MSG_IDS_HICN_API_JSON
+
// Shared local variables between state and RPCs
@@ -35,1289 +45,1411 @@ volatile hicn_strategy_t * hicn_strategy = NULL;
volatile hicn_strategies_t * hicn_strategies =NULL;
volatile hicn_route_t * hicn_route = NULL;
volatile hicn_face_ip_params_t * hicn_face_ip_params = NULL;
+volatile hicn_faces_t * hicn_faces = NULL;
+//volatile hicn_face_stat_t * hicn_face_stat=NULL;
+struct hicn_faces_s * current = NULL;
+//volatile hicn_state_face_t * hicn_state_face=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) );
- hicn_strategy = memalign(MEM_ALIGN, sizeof(hicn_strategy_t) );
- memset((hicn_strategy_t *) hicn_strategy, 0 , sizeof(hicn_strategy_t) );
- hicn_strategies = memalign(MEM_ALIGN, sizeof(hicn_strategies_t) );
- memset((hicn_strategies_t *) hicn_strategies, 0 , sizeof(hicn_strategies_t) );
- hicn_route = memalign(MEM_ALIGN, sizeof(hicn_route_t) );
- memset((hicn_route_t *) hicn_route, 0 , sizeof(hicn_route_t) );
- hicn_face_ip_params = memalign(MEM_ALIGN, sizeof(hicn_face_ip_params_t) );
- memset((hicn_face_ip_params_t *) hicn_face_ip_params, 0 , sizeof(hicn_face_ip_params_t) );
- int retval=-1;
- ARG_CHECK5(retval, hicn_state, hicn_strategy, hicn_strategies, hicn_route, hicn_face_ip_params);
- retval=0;
- return retval;
+ hicn_state = memalign(MEM_ALIGN, sizeof(hicn_state_t) );
+ memset((hicn_state_t *)hicn_state, 0 , sizeof(hicn_state_t) );
+
+ hicn_strategy = memalign(MEM_ALIGN, sizeof(hicn_strategy_t) );
+ memset((hicn_strategy_t *) hicn_strategy, 0 , sizeof(hicn_strategy_t) );
+
+ hicn_strategies = memalign(MEM_ALIGN, sizeof(hicn_strategies_t) );
+ memset((hicn_strategies_t *) hicn_strategies, 0 , sizeof(hicn_strategies_t) );
+
+ hicn_route = memalign(MEM_ALIGN, sizeof(hicn_route_t) );
+ memset((hicn_route_t *) hicn_route, 0 , sizeof(hicn_route_t) );
+
+ hicn_faces = memalign(MEM_ALIGN, sizeof(hicn_faces_t) );
+ hicn_faces->next=memalign(MEM_ALIGN, sizeof(struct hicn_faces_s));
+ current=hicn_faces->next;
+
+// hicn_state_face = memalign(MEM_ALIGN, sizeof(hicn_state_face_t) );
+// memset((hicn_state_face_t *) hicn_state_face, 0, sizeof(hicn_state_face_t));
+
+ int retval=-1;
+ ARG_CHECK6(retval, hicn_state, hicn_strategy, hicn_strategies, hicn_route, current, hicn_faces);
+ hicn_faces->nface=0;
+ retval=0;
+
+ return retval;
}
- static inline void state_update(sr_val_t * vals ){
- 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;
- 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;
+static int init_face_pool(struct hicn_faces_s * head){
+
+ ARG_CHECK(HICN_EINVAL, 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_DBG_MSG("Allocated\n");
+ }
+ head->next=NULL;
+ return HICN_OK;
- 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;
+}
- 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;
+static inline void state_cache(vapi_msg_hicn_api_node_stats_get_reply * resp){
+ hicn_state->pkts_processed = resp->payload.pkts_processed;
+ hicn_state->pkts_interest_count = resp->payload.pkts_interest_count;
+ hicn_state->pkts_data_count = resp->payload.pkts_data_count;
+ hicn_state->pkts_from_cache_count = resp->payload.pkts_from_cache_count;
+ hicn_state->pkts_no_pit_count = resp->payload.pkts_no_pit_count;
+ hicn_state->pit_expired_count = resp->payload.pit_expired_count;
+ hicn_state->cs_expired_count = resp->payload.cs_expired_count;
+ hicn_state->cs_lru_count = resp->payload.cs_lru_count;
+ hicn_state->pkts_drop_no_buf = resp->payload.pkts_drop_no_buf;
+ hicn_state->interests_aggregated = resp->payload.interests_aggregated;
+ hicn_state->interests_retx = resp->payload.interests_retx;
+ hicn_state->pit_entries_count = resp->payload.pit_entries_count;
+ hicn_state->cs_entries_count = resp->payload.cs_entries_count;
+ hicn_state->cs_entries_ntw_count = resp->payload.cs_entries_ntw_count;
+ SRP_LOG_DBG_MSG("state cached");
+}
- 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;
- 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;
+static inline void state_update(sr_val_t * vals ){
+ 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;
- 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;
+ 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;
- 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;
+ 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;
- 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;
+ 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;
- 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;
+ 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;
- 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;
+ 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;
- 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;
+ 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;
- 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;
+ 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;
- 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;
+ 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;
- 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;
-}
+ 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;
+ 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;
-static inline void strategy_update(sr_val_t * vals ){
- sr_val_set_xpath(&vals[0], "/hicn:hicn-state/strategy/description");
- vals[0].type = SR_UINT8_T;
- vals[0].data.uint8_val = hicn_strategy->description[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;
-static inline void strategies_update(sr_val_t * vals ){
- sr_val_set_xpath(&vals[0], "/hicn:hicn-state/strategies/n_strategies");
- vals[0].type = SR_UINT8_T;
- vals[0].data.uint8_val = hicn_strategies->n_strategies;
+ 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;
- sr_val_set_xpath(&vals[1], "/hicn:hicn-state/strategies/strategy_id");
- vals[1].type = SR_UINT32_T;
- vals[1].data.uint32_val = hicn_strategies->strategy_id[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;
+ 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;
}
-static inline void route_update(sr_val_t * vals ){
- sr_val_set_xpath(&vals[0], "/hicn:hicn-state/route/faceids");
- vals[0].type = SR_UINT16_T;
- vals[0].data.uint16_val = hicn_route->faceids[0];
+static inline void strategies_update(sr_val_t * vals ){
+ sr_val_set_xpath(&vals[0], "/hicn:hicn-state/strategies/n_strategies");
+ vals[0].type = SR_UINT8_T;
+ vals[0].data.uint8_val = hicn_strategies->n_strategies;
- sr_val_set_xpath(&vals[1], "/hicn:hicn-state/route/strategy_id");
- vals[1].type = SR_UINT32_T;
- vals[1].data.uint32_val = hicn_route->strategy_id;
+ sr_val_set_xpath(&vals[1], "/hicn:hicn-state/strategies/strategy_id");
+ vals[1].type = SR_UINT32_T;
+ vals[1].data.uint32_val = hicn_strategies->strategy_id[0];
}
-static inline void face_ip_params_update(sr_val_t * vals ){
- sr_val_set_xpath(&vals[0], "/hicn:hicn-state/face-ip-params/nh_addr");
- vals[0].type = SR_UINT64_T;
- vals[0].data.uint64_val = hicn_face_ip_params->nh_addr[0];
-
- sr_val_set_xpath(&vals[1], "/hicn:hicn-state/face-ip-params/swif");
- vals[1].type = SR_UINT32_T;
- vals[1].data.uint32_val = hicn_face_ip_params->swif;
+static inline void route_update(sr_val_t * vals ){
+ sr_val_set_xpath(&vals[0], "/hicn:hicn-state/routes/faceids");
+ vals[0].type = SR_UINT16_T;
+ vals[0].data.uint32_val = hicn_route->faceids[0];
- sr_val_set_xpath(&vals[2], "/hicn:hicn-state/face-ip-params/flags");
- vals[2].type = SR_UINT32_T;
- vals[2].data.uint32_val = hicn_face_ip_params->flags;
+ sr_val_set_xpath(&vals[1], "/hicn:hicn-state/routes/strategy_id");
+ vals[1].type = SR_UINT32_T;
+ vals[1].data.uint32_val = hicn_route->strategy_id;
}
+static inline int faces_update(sr_val_t * vals, uint32_t nleaves){
-static int hicn_state_states_cb(const char *xpath, sr_val_t **values,
- size_t *values_cnt, uint64_t request_id,
- const char *original_xpath, void *private_ctx) {
- sr_val_t *vals;
- int rc;
- enum locks_name state;
- state=lstate;
- SRP_LOG_DBG("Requesting state data for '%s'", xpath);
-
- if (!sr_xpath_node_name_eq(xpath, "states")) {
- *values = NULL;
- *values_cnt = 0;
- return SR_ERR_OK;
- }
+ struct hicn_faces_s * temp = hicn_faces->next;
+ int face =0;
- rc = sr_new_values(NSTATE_LEAVES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
+ for(int count=0; count<nleaves; count++){
- SRP_LOG_DBG("Requesting state data for '%s'", xpath);
- Ticket_Lock(state);
- state_update(vals);
- Ticket_Unlock(state);
- *values = vals;
- *values_cnt = NSTATE_LEAVES;
-/*
- pthread_t state_tid;
- rc = pthread_create((pthread_t *)&state_tid, NULL, state_thread, NULL);
- if (rc != 0) {
- SRP_LOG_DBG_MSG("Error making hicn state thread");
- return SR_ERR_OPERATION_FAILED;
- }
-*/
- return SR_ERR_OK;
-}
+ // This part must be removed once the faceid is provided by the dump msg
+ vapi_msg_hicn_api_face_ip_params_get *msg;
+ vapi_msg_hicn_api_face_ip_params_get_reply *resp;
+ msg = vapi_alloc_hicn_api_face_ip_params_get(g_vapi_ctx_instance);
+ msg->payload.faceid = temp->face.faceid;
+ vapi_msg_hicn_api_face_ip_params_get_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_face_ip_params_get_reply_ntoh(resp);
+ if(!resp->payload.retval){
+ SRP_LOG_DBG("faceid(%d)-->intfc(%d)", temp->face.faceid, resp->payload.swif);
+ temp->face.intfc= resp->payload.swif;
+ }
-static int hicn_state_strategy_cb(const char *xpath, sr_val_t **values,
- size_t *values_cnt, uint64_t request_id,
- const char *original_xpath, void *private_ctx) {
- sr_val_t *vals;
- int rc;
- enum locks_name strategy;
- strategy=lstrategy;
-
- if (!sr_xpath_node_name_eq(xpath, "strategy")) {
- *values = NULL;
- *values_cnt = 0;
- return SR_ERR_OK;
- }
+ 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;
- rc = sr_new_values(NSTRATEGY_LEAVES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
- SRP_LOG_DBG("Requesting state data for '%s'", xpath);
- Ticket_Lock(strategy);
- strategy_update(vals);
- Ticket_Unlock(strategy);
+ face++;
- *values = vals;
- *values_cnt = NSTRATEGY_LEAVES;
- return SR_ERR_OK;
- }
+ 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;
-static int hicn_state_strategies_cb(const char *xpath, sr_val_t **values,
- size_t *values_cnt, uint64_t request_id,
- const char *original_xpath, void *private_ctx) {
- sr_val_t *vals;
- int rc;
- enum locks_name strategies;
- strategies=lstrategies;
+ 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;
+ face++;
- if (! sr_xpath_node_name_eq(xpath, "strategies")) {
- SRP_LOG_DBG_MSG("Requesting state is not for strategies");
- *values = NULL;
- *values_cnt = 0;
- return SR_ERR_OK;
- }
+ 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;
+ face++;
- rc = sr_new_values(NSTRATEGIES_LEAVES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
+ 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;
- SRP_LOG_DBG("Requesting state data for '%s'", xpath);
- Ticket_Lock(strategies);
- strategies_update(vals);
- Ticket_Unlock(strategies);
+ face++;
- *values = vals;
- *values_cnt = NSTRATEGIES_LEAVES;
- return SR_ERR_OK;
+ 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;
- }
+ 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;
-static int hicn_state_route_cb(const char *xpath, sr_val_t **values,
- size_t *values_cnt, uint64_t request_id,
- const char *original_xpath, void *private_ctx) {
- sr_val_t *vals;
- int rc;
- enum locks_name route;
- route=lroute;
-
-
- if (! sr_xpath_node_name_eq(xpath, "route")) {
- SRP_LOG_DBG_MSG("Requesting state is not for route");
- *values = NULL;
- *values_cnt = 0;
- return SR_ERR_OK;
- }
+ face++;
- rc = sr_new_values(NROUTE_LEAVES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
+ 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;
- SRP_LOG_DBG("Requesting state data for '%s'", xpath);
- Ticket_Lock(route);
- route_update(vals);
- Ticket_Unlock(route);
+ face++;
- *values = vals;
- *values_cnt = NROUTE_LEAVES;
- return SR_ERR_OK;
+ 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;
- }
+ face++;
+ SRP_LOG_DBG(" **********************face is: %d-%d-%d ****************\n",temp->face.dtx_bytes,temp->face.drx_bytes,temp->face.faceid);
- static int hicn_state_face_ip_params_cb(const char *xpath, sr_val_t **values,
- size_t *values_cnt, uint64_t request_id,
- const char *original_xpath, void *private_ctx) {
- sr_val_t *vals;
- int rc;
- enum locks_name face_ip_params;
- face_ip_params=lface_ip_params;
+ printf("%" PRId64 "\n", temp->face.drx_bytes);
+ temp=temp->next;
+ }
+ SRP_LOG_DBG_MSG("Faces state updated \n");
+ return SR_ERR_OK;
+}
- if (! sr_xpath_node_name_eq(xpath, "face-ip-params")) {
- SRP_LOG_DBG_MSG("Requesting state is not for face-ip-params");
- *values = NULL;
- *values_cnt = 0;
- return SR_ERR_OK;
- }
+static int hicn_state_states_cb(const char *xpath, sr_val_t **values,
+ size_t *values_cnt, uint64_t request_id,
+ const char *original_xpath, void *private_ctx) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name state;
+ state=lstate;
+ SRP_LOG_DBG("Requesting state data for '%s'", xpath);
+
+ if (!sr_xpath_node_name_eq(xpath, "states")) {
+ *values = NULL;
+ *values_cnt = 0;
+ return SR_ERR_OK;
+ }
+
+ rc = sr_new_values(NSTATE_LEAVES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
+
+ SRP_LOG_DBG("Requesting state data for '%s'", xpath);
+ tlock(state);
+ state_update(vals);
+ tunlock(state);
+
+ *values = vals;
+ *values_cnt = NSTATE_LEAVES;
+
+ return SR_ERR_OK;
+}
- rc = sr_new_values(NFACE_IP_PARAMS_LEAVES, &vals);
- if (SR_ERR_OK != rc) {
- return rc;
- }
+static int hicn_state_strategies_cb(const char *xpath, sr_val_t **values,
+ size_t *values_cnt, uint64_t request_id,
+ const char *original_xpath, void *private_ctx) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name strategies;
+ strategies=lstrategies;
- SRP_LOG_DBG("Requesting state data for '%s'", xpath);
- Ticket_Lock(face_ip_params);
- face_ip_params_update(vals);
- Ticket_Unlock(face_ip_params);
- *values = vals;
- *values_cnt = NFACE_IP_PARAMS_LEAVES;
- return SR_ERR_OK;
- }
+ if (! sr_xpath_node_name_eq(xpath, "strategies")) {
+ SRP_LOG_DBG_MSG("Requesting state is not for strategies");
+ *values = NULL;
+ *values_cnt = 0;
+ return SR_ERR_OK;
+ }
-static int params_send(vapi_msg_hicn_api_node_params_set *msg,
- vapi_msg_hicn_api_node_params_set_reply *resp) {
- vapi_msg_hicn_api_node_params_set_hton(msg);
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
- HICN_VPP_VAPI_RECV;
- SRP_LOG_DBG_MSG("state data are updated successfully");
- return SR_ERR_OK;
-}
+ rc = sr_new_values(NSTRATEGIES_LEAVES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
-/**
- * @brief Callback to be called by any config change of "/hicn:/" leaf.
- */
-static int hicn_node_params_set_cb(sr_session_ctx_t *session, const char *xpath,
- sr_notif_event_t event, void *private_ctx) {
- sr_change_iter_t *iter = NULL;
- 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,
- };
- int rc = SR_ERR_OK, op_rc = SR_ERR_OK;
- // no-op for apply, we only care about SR_EV_ENABLED, SR_EV_VERIFY,
- // SR_EV_ABORT
- if (SR_EV_APPLY == event) {
- return SR_ERR_OK;
- }
+ SRP_LOG_DBG("Requesting state data for '%s'", xpath);
+ tlock(strategies);
+ strategies_update(vals);
+ tunlock(strategies);
- // get changes iterator
- rc = sr_get_changes_iter(session, xpath, &iter);
- if (SR_ERR_OK != rc) {
- SRP_LOG_ERR("Unable to retrieve change iterator: %s", sr_strerror(rc));
- return rc;
- }
+ *values = vals;
+ *values_cnt = NSTRATEGIES_LEAVES;
+ return SR_ERR_OK;
- vapi_msg_hicn_api_node_params_set *msg;
- vapi_msg_hicn_api_node_params_set_reply *resp = NULL;
- msg = vapi_alloc_hicn_api_node_params_set(g_vapi_ctx_instance);
- // iterate over all changes
- while ((SR_ERR_OK == op_rc || event == SR_EV_ABORT) &&
- (SR_ERR_OK ==
- (rc = sr_get_change_next(session, iter, &op, &old_val, &new_val)))) {
- if (!strcmp(new_val->xpath, "/hicn:hicn-conf/params/enable_disable")) {
- SRP_LOG_DBG("A change detected in '%s', op=%d",
- new_val ? new_val->xpath : old_val->xpath,
- new_val->data.bool_val);
- msg->payload.enable_disable = new_val->data.bool_val;
- } else if (!strcmp(new_val->xpath, "/hicn:hicn-conf/params/pit_max_size")) {
- SRP_LOG_DBG("A change detected in '%s', op=%d",
- new_val ? new_val->xpath : old_val->xpath,
- new_val->data.int32_val);
- msg->payload.pit_max_size = new_val->data.int32_val;
- } else if (!strcmp(new_val->xpath, "/hicn:hicn-conf/params/cs_max_size")) {
- SRP_LOG_DBG("A change detected in '%s', op=%d",
- new_val ? new_val->xpath : old_val->xpath,
- new_val->data.int32_val);
- msg->payload.cs_max_size = new_val->data.int32_val;
- } else if (!strcmp(new_val->xpath,
- "/hicn:hicn-conf/params/cs_reserved_app")) {
- SRP_LOG_DBG("A change detected in '%s', op=%d",
- new_val ? new_val->xpath : old_val->xpath,
- new_val->data.int32_val);
- msg->payload.cs_reserved_app = new_val->data.int32_val;
- } else if (!strcmp(new_val->xpath,
- "/hicn:hicn-conf/params/pit_dflt_lifetime_sec")) {
- SRP_LOG_DBG("A change detected in '%s', op=%d",
- new_val ? new_val->xpath : old_val->xpath,
- new_val->data.decimal64_val);
- msg->payload.pit_dflt_lifetime_sec = new_val->data.decimal64_val;
- } else if (!strcmp(new_val->xpath,
- "/hicn:hicn-conf/params/pit_min_lifetime_sec")) {
- SRP_LOG_DBG("A change detected in '%s', op=%d",
- new_val ? new_val->xpath : old_val->xpath,
- new_val->data.decimal64_val);
- msg->payload.pit_min_lifetime_sec = new_val->data.decimal64_val;
- } else if (!strcmp(new_val->xpath,
- "/hicn:hicn-conf/params/pit_max_lifetime_sec")) {
- SRP_LOG_DBG("A change detected in '%s', op=%d",
- new_val ? new_val->xpath : old_val->xpath,
- new_val->data.decimal64_val);
- msg->payload.pit_max_lifetime_sec = new_val->data.decimal64_val;
- }
-
- switch (op) {
- case SR_OP_CREATED:
- case SR_OP_MODIFIED:
- op_rc = SR_ERR_OK; // OK
- break;
- case SR_OP_DELETED:
- op_rc = SR_ERR_OPERATION_FAILED; // ERROR
- break;
- default:
- break;
- }
- sr_xpath_recover(&xpath_ctx);
- if (SR_ERR_INVAL_ARG == op_rc) {
- sr_set_error(session, "You are not allowed to change the schema.",
- new_val ? new_val->xpath : old_val->xpath);
- }
- sr_free_val(old_val);
- sr_free_val(new_val);
- }
+ }
- params_send(msg, resp);
- sr_free_change_iter(iter);
- SRP_LOG_DBG_MSG("Configuration applied successfully");
- return SR_ERR_OK;
+static int hicn_state_route_cb(const char *xpath, sr_val_t **values,
+ size_t *values_cnt, uint64_t request_id,
+ const char *original_xpath, void *private_ctx) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name route;
+ route=lroute;
+
+
+ if (! sr_xpath_node_name_eq(xpath, "routes")) {
+ SRP_LOG_DBG_MSG("Requesting state is not for routes");
+ *values = NULL;
+ *values_cnt = 0;
+ return SR_ERR_OK;
+ }
+
+ rc = sr_new_values(NROUTE_LEAVES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
+
+ SRP_LOG_DBG("Requesting state data for '%s'", xpath);
+ tlock(route);
+ route_update(vals);
+ tunlock(route);
+
+ *values = vals;
+ *values_cnt = NROUTE_LEAVES;
+ return SR_ERR_OK;
+
+ }
+
+
+ static int hicn_state_faces_cb(const char *xpath, sr_val_t **values,
+ size_t *values_cnt, uint64_t request_id,
+ const char *original_xpath, void *private_ctx) {
+ sr_val_t *vals;
+ int rc;
+ enum locks_name faces;
+ faces=lfaces;
+ uint32_t NFACES_NODES = hicn_faces->nface * FACES_CHILDREN;
+
+ if (! sr_xpath_node_name_eq(xpath, "faces")) {
+ SRP_LOG_DBG_MSG("Requesting state is not for faces");
+ *values = NULL;
+ *values_cnt = 0;
+ return SR_ERR_OK;
+ }
+
+ // We should only consider the number of leaves not the head of list(faceid)
+ rc = sr_new_values(NFACES_NODES, &vals);
+ if (SR_ERR_OK != rc) {
+ return rc;
+ }
+
+ SRP_LOG_DBG("Requesting state data for '%s'", xpath);
+
+ tlock(faces);
+ SRP_LOG_DBG("**********NFACES-LEAVES '%d' *********", NFACES_NODES);
+ faces_update(vals, NFACES_NODES/FACES_CHILDREN);
+ tunlock(faces);
+ //hicn_faces->nface=0;
+ *values = vals;
+ *values_cnt = NFACES_NODES;
+ return SR_ERR_OK;
+
+ }
+
+/**
+* @brief Callback to be called by any config change of "/hicn:/" leaf.
+*/
+static int hicn_node_params_set_cb(sr_session_ctx_t *session, const char *xpath,
+ sr_notif_event_t event, void *private_ctx) {
+ sr_change_iter_t *iter = NULL;
+ 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,
+ };
+ int rc = SR_ERR_OK, op_rc = SR_ERR_OK;
+ // no-op for apply, we only care about SR_EV_ENABLED, SR_EV_VERIFY,
+ // SR_EV_ABORT
+ if (SR_EV_APPLY == event) {
+ return SR_ERR_OK;
+ }
+
+ // get changes iterator
+ rc = sr_get_changes_iter(session, xpath, &iter);
+ if (SR_ERR_OK != rc) {
+ SRP_LOG_ERR("Unable to retrieve change iterator: %s", sr_strerror(rc));
+ return rc;
+ }
+
+ vapi_msg_hicn_api_node_params_set *msg;
+ vapi_msg_hicn_api_node_params_set_reply *resp = NULL;
+ msg = vapi_alloc_hicn_api_node_params_set(g_vapi_ctx_instance);
+ SRP_LOG_DBG("H:recv msgid [%d]\n", msg->header._vl_msg_id); \
+
+ // iterate over all changes
+ while ((SR_ERR_OK == op_rc || event == SR_EV_ABORT) &&
+ (SR_ERR_OK ==
+ (rc = sr_get_change_next(session, iter, &op, &old_val, &new_val)))) {
+ if (!strcmp(new_val->xpath, "/hicn:hicn-conf/params/enable_disable")) {
+ SRP_LOG_DBG("A change detected in '%s', op=%d",
+ new_val ? new_val->xpath : old_val->xpath,
+ new_val->data.bool_val);
+ msg->payload.enable_disable = new_val->data.bool_val;
+ } else if (!strcmp(new_val->xpath, "/hicn:hicn-conf/params/pit_max_size")) {
+ SRP_LOG_DBG("A change detected in '%s', op=%d",
+ new_val ? new_val->xpath : old_val->xpath,
+ new_val->data.int32_val);
+ msg->payload.pit_max_size = new_val->data.int32_val;
+ } else if (!strcmp(new_val->xpath, "/hicn:hicn-conf/params/cs_max_size")) {
+ SRP_LOG_DBG("A change detected in '%s', op=%d",
+ new_val ? new_val->xpath : old_val->xpath,
+ new_val->data.int32_val);
+ msg->payload.cs_max_size = new_val->data.int32_val;
+ } else if (!strcmp(new_val->xpath,
+ "/hicn:hicn-conf/params/cs_reserved_app")) {
+ SRP_LOG_DBG("A change detected in '%s', op=%d",
+ new_val ? new_val->xpath : old_val->xpath,
+ new_val->data.int32_val);
+ msg->payload.cs_reserved_app = new_val->data.int32_val;
+ } else if (!strcmp(new_val->xpath,
+ "/hicn:hicn-conf/params/pit_dflt_lifetime_sec")) {
+ SRP_LOG_DBG("A change detected in '%s', op=%d",
+ new_val ? new_val->xpath : old_val->xpath,
+ new_val->data.decimal64_val);
+ msg->payload.pit_dflt_lifetime_sec = new_val->data.decimal64_val;
+ } else if (!strcmp(new_val->xpath,
+ "/hicn:hicn-conf/params/pit_min_lifetime_sec")) {
+ SRP_LOG_DBG("A change detected in '%s', op=%d",
+ new_val ? new_val->xpath : old_val->xpath,
+ new_val->data.decimal64_val);
+ msg->payload.pit_min_lifetime_sec = new_val->data.decimal64_val;
+ } else if (!strcmp(new_val->xpath,
+ "/hicn:hicn-conf/params/pit_max_lifetime_sec")) {
+ SRP_LOG_DBG("A change detected in '%s', op=%d",
+ new_val ? new_val->xpath : old_val->xpath,
+ new_val->data.decimal64_val);
+ msg->payload.pit_max_lifetime_sec = new_val->data.decimal64_val;
+ }
+
+ switch (op) {
+ case SR_OP_CREATED:
+ case SR_OP_MODIFIED:
+ op_rc = SR_ERR_OK; // OK
+ break;
+ case SR_OP_DELETED:
+ op_rc = SR_ERR_OPERATION_FAILED; // ERROR
+ break;
+ default:
+ break;
+ }
+ sr_xpath_recover(&xpath_ctx);
+ if (SR_ERR_INVAL_ARG == op_rc) {
+ sr_set_error(session, "You are not allowed to change the schema.",
+ new_val ? new_val->xpath : old_val->xpath);
+ }
+ sr_free_val(old_val);
+ sr_free_val(new_val);
+ }
+
+ vapi_msg_hicn_api_node_params_set_hton(msg);
+
+ params_send(msg, resp);
+
+ vapi_msg_hicn_api_node_params_set_reply_ntoh(resp);
+
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ sr_free_change_iter(iter);
+ return SR_ERR_OK;
+ }
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to get hicn param in vpp.
- */
+* @brief API to get hicn param in vpp.
+*/
static int hicn_node_params_get_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn node parameter received successfully");
- vapi_msg_hicn_api_node_params_get *msg;
- vapi_msg_hicn_api_node_params_get_reply *resp;
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- msg = vapi_alloc_hicn_api_node_params_get(g_vapi_ctx_instance);
- vapi_msg_hicn_api_node_params_get_hton(msg);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
+ SRP_LOG_DBG_MSG("hicn node parameter received successfully");
+ vapi_msg_hicn_api_node_params_get *msg;
+ vapi_msg_hicn_api_node_params_get_reply *resp;
+ msg = vapi_alloc_hicn_api_node_params_get(g_vapi_ctx_instance);
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
- HICN_VPP_VAPI_RECV;
- vapi_msg_hicn_api_node_params_get_reply_ntoh(resp);
+ vapi_msg_hicn_api_node_params_get_hton(msg);
+ params_send(msg, resp);
+ vapi_msg_hicn_api_node_params_get_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- SRP_LOG_DBG("Pit Max entries: %d",resp->payload.pit_max_size);
- return SR_ERR_OK;
- }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to get hicn stat in vpp.
- */
+* @brief API to get hicn stat in vpp.
+*/
static int hicn_node_stat_get_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- SRP_LOG_DBG_MSG("hicn status received successfully");
- vapi_msg_hicn_api_node_stats_get *msg;
- vapi_msg_hicn_api_node_stats_get_reply *resp;
- enum locks_name state;
- state=lstate;
+ SRP_LOG_DBG_MSG("hicn status received successfully");
+ vapi_msg_hicn_api_node_stats_get *msg;
+ vapi_msg_hicn_api_node_stats_get_reply *resp;
+ enum locks_name state;
+ state=lstate;
+ msg = vapi_alloc_hicn_api_node_stats_get(g_vapi_ctx_instance);
- //vapi_msg_id_hicn_api_node_stats_get=103;
- msg = vapi_alloc_hicn_api_node_stats_get(g_vapi_ctx_instance);
- vapi_msg_hicn_api_node_stats_get_hton(msg);
+ vapi_msg_hicn_api_node_stats_get_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_node_stats_get_reply_ntoh(resp);
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ if(resp->payload.retval){
+ SRP_LOG_DBG_MSG("Error updating state");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ tlock(state);
- HICN_VPP_VAPI_RECV;
- vapi_msg_hicn_api_node_stats_get_reply_ntoh(resp);
+ state_cache(resp);
- if(resp->payload.retval){
- SRP_LOG_DBG_MSG("Error updating state");
- return SR_ERR_OPERATION_FAILED;
- }
- Ticket_Lock(state);
- // hicn_state = (hicn_state_t *) resp->payload;
- hicn_state->pkts_processed = resp->payload.pkts_processed;
- hicn_state->pkts_interest_count = resp->payload.pkts_interest_count;
- hicn_state->pkts_data_count = resp->payload.pkts_data_count;
- hicn_state->pkts_from_cache_count = resp->payload.pkts_from_cache_count;
- hicn_state->pkts_no_pit_count = resp->payload.pkts_no_pit_count;
- hicn_state->pit_expired_count = resp->payload.pit_expired_count;
- hicn_state->cs_expired_count = resp->payload.cs_expired_count;
- hicn_state->cs_lru_count = resp->payload.cs_lru_count;
- hicn_state->pkts_drop_no_buf = resp->payload.pkts_drop_no_buf;
- hicn_state->interests_aggregated = resp->payload.interests_aggregated;
- hicn_state->interests_retx = resp->payload.interests_retx;
- // hicn_state->interests_hash_collision = resp->payload.interests_hash_collision;
- hicn_state->pit_entries_count = resp->payload.pit_entries_count;
- hicn_state->cs_entries_count = resp->payload.cs_entries_count;
- hicn_state->cs_entries_ntw_count = resp->payload.cs_entries_ntw_count;
- Ticket_Unlock(state);
-
- return SR_ERR_OK;
+ tunlock(state);
+ return SR_ERR_OK;
}
/**
- * @brief API to get hicn strategy in vpp.
- */
+* @brief API to get hicn strategy in vpp.
+*/
static int hicn_strategy_get_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn strategy receive successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_strategy_get *msg;
- vapi_msg_hicn_api_strategy_get_reply *resp;
-
- msg = vapi_alloc_hicn_api_strategy_get(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
-
- msg->payload.strategy_id = input[0].data.uint32_val;
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- vapi_msg_hicn_api_strategy_get_hton(msg);
+ SRP_LOG_DBG_MSG("hicn strategy receive successfully");
+ vapi_msg_hicn_api_strategy_get *msg;
+ vapi_msg_hicn_api_strategy_get_reply *resp;
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg = vapi_alloc_hicn_api_strategy_get(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- HICN_VPP_VAPI_RECV;
+ msg->payload.strategy_id = input[0].data.uint32_val;
- vapi_msg_hicn_api_strategy_get_reply_ntoh(resp);
+ vapi_msg_hicn_api_strategy_get_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_strategy_get_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to get hicn strategies in vpp.
- */
+* @brief API to get hicn strategies in vpp.
+*/
static int hicn_strategies_get_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn strategies received successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_strategies_get *msg;
- vapi_msg_hicn_api_strategies_get_reply *resp;
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- msg = vapi_alloc_hicn_api_strategies_get(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- vapi_msg_hicn_api_strategies_get_hton(msg);
+ SRP_LOG_DBG_MSG("hicn strategies received successfully");
+ vapi_msg_hicn_api_strategies_get *msg;
+ vapi_msg_hicn_api_strategies_get_reply *resp;
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg = vapi_alloc_hicn_api_strategies_get(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- HICN_VPP_VAPI_RECV;
- vapi_msg_hicn_api_strategies_get_reply_ntoh(resp);
+ vapi_msg_hicn_api_strategies_get_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_strategies_get_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to get hicn route in vpp.
- */
+* @brief API to get hicn route in vpp.
+*/
static int hicn_route_get_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- SRP_LOG_DBG_MSG("hicn route receive successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_route_get *msg;
- vapi_msg_hicn_api_route_get_reply *resp;
-
- msg = vapi_alloc_hicn_api_route_get(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
+ SRP_LOG_DBG_MSG("hicn route receive successfully");
+ vapi_msg_hicn_api_route_get *msg;
+ vapi_msg_hicn_api_route_get_reply *resp;
+ msg = vapi_alloc_hicn_api_route_get(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- if(strcmp(input[0].data.string_val,"-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 * temp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix[0],temp,4);
+ 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[0],tmp,B32);
- }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 * temp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix[0],temp,8);
- memcpy(&msg->payload.prefix[1],temp+8,8);
+ }else if(strcmp(input[1].data.string_val,"-1")){
- }else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ 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[0],tmp,B64);
+ memcpy(&msg->payload.prefix[1],tmp+B64,B64);
+ }else{
+ SRP_LOG_DBG_MSG("Invalid local IP address");
+ return SR_ERR_OPERATION_FAILED;
+ }
- msg->payload.len = input[2].data.uint8_val;
- vapi_msg_hicn_api_route_get_hton(msg);
+ msg->payload.len = input[2].data.uint8_val;
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ vapi_msg_hicn_api_route_get_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_route_get_reply_ntoh(resp);
- HICN_VPP_VAPI_RECV;
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- vapi_msg_hicn_api_route_get_reply_ntoh(resp);
-
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
-
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to add hicn route nhops in vpp.
- */
+* @brief API to add hicn route nhops in vpp.
+*/
static int hicn_route_nhops_add_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn route nhops add received successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_route_nhops_add *msg;
- vapi_msg_hicn_api_route_nhops_add_reply *resp;
-
- msg = vapi_alloc_hicn_api_route_nhops_add(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- vapi_msg_hicn_api_route_nhops_add_hton(msg);
-
-
-
- if(strcmp(input[0].data.string_val,"-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 * temp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix[0],temp,4);
-
-
- }else if(strcmp(input[1].data.string_val,"-1")){
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- void *dst = malloc(sizeof(struct in6_addr));
- inet_pton(AF_INET6, input[1].data.string_val, dst);
- unsigned char * temp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix[0],temp,8);
- memcpy(&msg->payload.prefix[1],temp+8,8);
+ SRP_LOG_DBG_MSG("hicn route nhops add received successfully");
+ vapi_msg_hicn_api_route_nhops_add *msg;
+ vapi_msg_hicn_api_route_nhops_add_reply *resp;
- }else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg = vapi_alloc_hicn_api_route_nhops_add(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
+ 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[0],tmp,4);
+ }else if(strcmp(input[1].data.string_val,"-1")){
- msg->payload.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;
+ 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[0],tmp,B64);
+ memcpy(&msg->payload.prefix[1],tmp+B64,B64);
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)){
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ }else{
+ SRP_LOG_DBG_MSG("Invalid local IP address");
+ return SR_ERR_OPERATION_FAILED;
+ }
- HICN_VPP_VAPI_RECV;
+ msg->payload.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;
- vapi_msg_hicn_api_route_nhops_add_reply_ntoh(resp);
+ vapi_msg_hicn_api_route_nhops_add_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_route_nhops_add_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to del hicn route in vpp.
- */
+* @brief API to del hicn route in vpp.
+*/
static int hicn_route_del_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- SRP_LOG_DBG_MSG("hicn route del received successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_route_del *msg;
- vapi_msg_hicn_api_route_del_reply *resp;
+ SRP_LOG_DBG_MSG("hicn route del received successfully");
+ vapi_msg_hicn_api_route_del *msg;
+ vapi_msg_hicn_api_route_del_reply *resp;
- msg = vapi_alloc_hicn_api_route_del(g_vapi_ctx_instance);
+ msg = vapi_alloc_hicn_api_route_del(g_vapi_ctx_instance);
- if(strcmp(input[0].data.string_val,"-1")){
+ if(strcmp(input[0].data.string_val,"-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 * temp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix[0],temp,4);
+ 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[0],tmp,B32);
- }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 * temp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix[0],temp,8);
- memcpy(&msg->payload.prefix[1],temp+8,8);
-
- }else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
-
+ }else if(strcmp(input[1].data.string_val,"-1")){
- msg->payload.len = input[2].data.uint8_val;
+ 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[0],tmp,B64);
+ memcpy(&msg->payload.prefix[1],tmp+B64,B64);
- vapi_msg_hicn_api_route_del_hton(msg);
+ }else{
+ SRP_LOG_DBG_MSG("Invalid local IP address");
+ return SR_ERR_OPERATION_FAILED;
+ }
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
- HICN_VPP_VAPI_RECV;
+ msg->payload.len = input[2].data.uint8_val;
- vapi_msg_hicn_api_route_del_reply_ntoh(resp);
+ vapi_msg_hicn_api_route_del_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_route_del_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to get face ip params in hicn in vpp.
- */
+* @brief API to get face ip params in hicn in vpp.
+*/
static int hicn_face_ip_params_get_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn face ip params get received successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_face_ip_params_get *msg;
- vapi_msg_hicn_api_face_ip_params_get_reply *resp;
-
- msg = vapi_alloc_hicn_api_face_ip_params_get(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
-
- msg->payload.faceid = input[0].data.uint16_val;
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- vapi_msg_hicn_api_face_ip_params_get_hton(msg);
+ SRP_LOG_DBG_MSG("hicn face ip params get received successfully");
+ vapi_msg_hicn_api_face_ip_params_get *msg;
+ vapi_msg_hicn_api_face_ip_params_get_reply *resp;
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg = vapi_alloc_hicn_api_face_ip_params_get(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- HICN_VPP_VAPI_RECV;
+ msg->payload.faceid = input[0].data.uint32_val;
- vapi_msg_hicn_api_face_ip_params_get_reply_ntoh(resp);
+ vapi_msg_hicn_api_face_ip_params_get_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_face_ip_params_get_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG("faceid(%d)-->intfc(%d)",input[0].data.uint32_val, resp->payload.swif);
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to get face ip params in hicn in vpp.
- */
+* @brief API to get face ip params in hicn in vpp.
+*/
static int hicn_punting_add_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn punting add received successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_punting_add *msg;
- vapi_msg_hicn_api_punting_add_reply *resp;
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- msg = vapi_alloc_hicn_api_punting_add(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
-
-
- if(strcmp(input[0].data.string_val,"-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 * temp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix[0],temp,4);
+ SRP_LOG_DBG_MSG("hicn punting add received successfully");
+ // allocate memory msg and resp
+ vapi_msg_hicn_api_punting_add *msg;
+ vapi_msg_hicn_api_punting_add_reply *resp;
+ msg = vapi_alloc_hicn_api_punting_add(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- }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 * temp =(unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix[0],temp,8);
- memcpy(&msg->payload.prefix[1],temp+8,8);
+ if(strcmp(input[0].data.string_val,"-1")){
- }else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ 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[0],tmp,B32);
- msg->payload.len = input[2].data.uint8_val;
- msg->payload.swif = input[3].data.uint32_val;
+ }else if(strcmp(input[1].data.string_val,"-1")){
- vapi_msg_hicn_api_punting_add_hton(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[0],tmp,B64);
+ memcpy(&msg->payload.prefix[1],tmp+B64,B64);
+ }else{
+ SRP_LOG_DBG_MSG("Invalid local IP address");
+ return SR_ERR_OPERATION_FAILED;
+ }
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg->payload.len = input[2].data.uint8_val;
+ msg->payload.swif = input[3].data.uint32_val;
- HICN_VPP_VAPI_RECV;
- vapi_msg_hicn_api_punting_add_reply_ntoh(resp);
+ vapi_msg_hicn_api_punting_add_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_punting_add_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to del hicn route nhops in vpp.
- */
+* @brief API to del hicn route nhops in vpp.
+*/
static int hicn_route_nhops_del_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn route nhop del received successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_route_nhop_del *msg;
- vapi_msg_hicn_api_route_nhop_del_reply *resp;
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- msg = vapi_alloc_hicn_api_route_nhop_del(g_vapi_ctx_instance);
- vapi_msg_hicn_api_route_nhop_del_hton(msg);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
+ SRP_LOG_DBG_MSG("hicn route nhop del received successfully");
+ // allocate memory msg and resp
+ vapi_msg_hicn_api_route_nhop_del *msg;
+ vapi_msg_hicn_api_route_nhop_del_reply *resp;
+ msg = vapi_alloc_hicn_api_route_nhop_del(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- if(strcmp(input[0].data.string_val,"-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 * temp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix[0],temp,4);
+ if(strcmp(input[0].data.string_val,"-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[0],tmp,B32);
- }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 * temp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix[0],temp,8);
- memcpy(&msg->payload.prefix[1],temp+8,8);
+ }else if(strcmp(input[1].data.string_val,"-1")){
- }else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ 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[0],tmp,B64);
+ memcpy(&msg->payload.prefix[1],tmp+B64,B64);
+ }else{
+ SRP_LOG_DBG_MSG("Invalid local IP address");
+ return SR_ERR_OPERATION_FAILED;
+ }
- msg->payload.len = input[2].data.uint8_val;
- msg->payload.faceid = input[3].data.uint16_val;
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg->payload.len = input[2].data.uint8_val;
+ msg->payload.faceid = input[3].data.uint32_val;
- HICN_VPP_VAPI_RECV;
+ vapi_msg_hicn_api_route_nhop_del_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_route_nhop_del_reply_ntoh(resp);
- vapi_msg_hicn_api_route_nhop_del_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to del hicn punting in vpp.
- */
+* @brief API to del hicn punting in vpp.
+*/
static int hicn_punting_del_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- SRP_LOG_DBG_MSG("hicn punting del received successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_punting_del *msg;
- vapi_msg_hicn_api_punting_del_reply *resp;
+ SRP_LOG_DBG_MSG("hicn punting del received successfully");
+ // allocate memory msg and resp
+ vapi_msg_hicn_api_punting_del *msg;
+ vapi_msg_hicn_api_punting_del_reply *resp;
- msg = vapi_alloc_hicn_api_punting_del(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
-
-
- if(strcmp(input[0].data.string_val,"-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 * temp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.prefix[0],temp,4);
-
-
- }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 * temp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.prefix[0],temp,8);
- memcpy(&msg->payload.prefix[1],temp+8,8);
-
- }else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg = vapi_alloc_hicn_api_punting_del(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
+ 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[0],tmp,B32);
+ }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[0],tmp,B64);
+ memcpy(&msg->payload.prefix[1],tmp+B64,B64);
- msg->payload.len = input[2].data.uint8_val;
- msg->payload.swif = input[3].data.uint32_val;
+ }else{
+ SRP_LOG_DBG_MSG("Invalid local IP address");
+ return SR_ERR_OPERATION_FAILED;
+ }
- vapi_msg_hicn_api_punting_del_hton(msg);
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg->payload.len = input[2].data.uint8_val;
+ msg->payload.swif = input[3].data.uint32_val;
- HICN_VPP_VAPI_RECV;
+ vapi_msg_hicn_api_punting_del_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_punting_del_reply_ntoh(resp);
- vapi_msg_hicn_api_punting_del_reply_ntoh(resp);
-
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to del hicn face ip in vpp.
- */
+* @brief API to del hicn face ip in vpp.
+*/
static int hicn_face_ip_del_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn face ip del received successfully");
- // allocate memory msg and resp
- vapi_msg_hicn_api_face_ip_del *msg;
- vapi_msg_hicn_api_face_ip_del_reply *resp;
-
- msg = vapi_alloc_hicn_api_face_ip_del(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- msg->payload.faceid = input[0].data.uint16_val;
-
- vapi_msg_hicn_api_face_ip_del_hton(msg);
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ SRP_LOG_DBG_MSG("hicn face ip del received successfully");
+ // allocate memory msg and resp
+ vapi_msg_hicn_api_face_ip_del *msg;
+ vapi_msg_hicn_api_face_ip_del_reply *resp;
- HICN_VPP_VAPI_RECV;
+ msg = vapi_alloc_hicn_api_face_ip_del(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
+ msg->payload.faceid = input[0].data.uint32_val;
- vapi_msg_hicn_api_face_ip_del_reply_ntoh(resp);
+ vapi_msg_hicn_api_face_ip_del_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_face_ip_del_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG_MSG("Successfully Done");
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
/**
- * @brief API to del hicn face ip in vpp.
- */
+* @brief API to del hicn face ip in vpp.
+*/
static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input,
- const size_t input_cnt, sr_val_t **output,
- size_t *output_cnt, void *private_ctx) {
-
- SRP_LOG_DBG_MSG("hicn face ip add received successfully");
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
- // allocate memory msg and resp
- vapi_msg_hicn_api_face_ip_add *msg;
- vapi_msg_hicn_api_face_ip_add_reply *resp;
-
- msg = vapi_alloc_hicn_api_face_ip_add(g_vapi_ctx_instance);
- SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
- if(strcmp(input[0].data.string_val,"-1")){
+ SRP_LOG_DBG_MSG("hicn face ip add received successfully");
- struct sockaddr_in sa;
- // store this IP address in sa:
- inet_pton(AF_INET, input[0].data.string_val, &(sa.sin_addr));
- unsigned char * temp = (unsigned char *) &sa.sin_addr.s_addr;
- memcpy(&msg->payload.local_addr[0],temp,4);
- }else if(strcmp(input[1].data.string_val,"-1")){
+ vapi_msg_hicn_api_face_ip_add *msg;
+ vapi_msg_hicn_api_face_ip_add_reply *resp;
- void *dst = malloc(sizeof(struct in6_addr));
- inet_pton(AF_INET6, input[1].data.string_val, dst);
- unsigned char * temp = (unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.local_addr[0],temp,8);
- memcpy(&msg->payload.local_addr[1],temp+8,8);
+ msg = vapi_alloc_hicn_api_face_ip_add(g_vapi_ctx_instance);
+ SRP_LOG_DBG("msg id:%d",msg->header._vl_msg_id);
+ 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.local_addr[0],tmp,B32);
- }else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ }else if(strcmp(input[1].data.string_val,"-1")){
- if(strcmp(input[2].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.local_addr[0],tmp,B64);
+ memcpy(&msg->payload.local_addr[1],tmp+B64,B64);
- struct sockaddr_in sa;
- // store this IP address in sa:
- inet_pton(AF_INET, input[2].data.string_val, &(sa.sin_addr));
- unsigned char * temp = (unsigned char *)&sa.sin_addr.s_addr;
- memcpy(&msg->payload.remote_addr[0],temp,4);
+ }else{
+ SRP_LOG_DBG_MSG("Invalid local IP address");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ if(strcmp(input[2].data.string_val,"-1")){
- }else if(strcmp(input[3].data.string_val,"-1")){
+ struct sockaddr_in sa;
+ inet_pton(AF_INET, input[2].data.string_val, &(sa.sin_addr));
+ unsigned char * tmp = (unsigned char *)&sa.sin_addr.s_addr;
+ memcpy(&msg->payload.remote_addr[0],tmp,B32);
- void *dst = malloc(sizeof(struct in6_addr));
- inet_pton(AF_INET6, input[3].data.string_val, dst);
- unsigned char * temp =(unsigned char *) ((struct in6_addr *)dst)->s6_addr;
- memcpy(&msg->payload.remote_addr[0],temp,8);
- memcpy(&msg->payload.remote_addr[1],temp+8,8);
- }else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
- return SR_ERR_OPERATION_FAILED;
- }
+ }else if(strcmp(input[3].data.string_val,"-1")){
- msg->payload.swif = input[4].data.uint32_val; // This is the idx number of interface
+ void *dst = malloc(sizeof(struct in6_addr));
+ inet_pton(AF_INET6, input[3].data.string_val, dst);
+ unsigned char * tmp =(unsigned char *) ((struct in6_addr *)dst)->s6_addr;
+ memcpy(&msg->payload.remote_addr[0],tmp,B64);
+ memcpy(&msg->payload.remote_addr[1],tmp+B64,B64);
- vapi_msg_hicn_api_face_ip_add_hton(msg);
+ }else{
+ SRP_LOG_DBG_MSG("Invalid local IP address");
+ return SR_ERR_OPERATION_FAILED;
+ }
- if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
- SRP_LOG_DBG_MSG("Sending msg to VPP failed");
- return SR_ERR_OPERATION_FAILED;
- }
+ msg->payload.swif = input[4].data.uint32_val; // This is the idx number of interface
- HICN_VPP_VAPI_RECV;
- vapi_msg_hicn_api_face_ip_add_reply_ntoh(resp);
+ vapi_msg_hicn_api_face_ip_add_hton(msg);
+ params_send(msg,resp);
+ vapi_msg_hicn_api_face_ip_add_reply_ntoh(resp);
- if(!resp->payload.retval){
- SRP_LOG_DBG("Successfully Done return faceid: %d",resp->payload.faceid);
- return SR_ERR_OK;
- }
+ if(!resp->payload.retval){
+ SRP_LOG_DBG_MSG("Successfully done");
+ return SR_ERR_OK;
+ }
- SRP_LOG_DBG_MSG("Operation Failed");
- return SR_ERR_OPERATION_FAILED;
+ SRP_LOG_DBG_MSG("Operation failed");
+ return SR_ERR_OPERATION_FAILED;
}
-/**
- * @brief Helper function for subscribing all hicn APIs.
- */
-int hicn_subscribe_events(sr_session_ctx_t *session,
- sr_subscription_ctx_t **subscription) {
- int rc = SR_ERR_OK;
- SRP_LOG_DBG_MSG("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_DBG_MSG("Problem in initializing the buffers\n"); goto error;
- }
-
+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)
+{
- // node state subscriptions
-
- rc = sr_rpc_subscribe(session, "/hicn:node-params-get", hicn_node_params_get_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription stat-get\n");
- goto error;
- }
-
+ static int counter = 0;
+/*
+ UNUSED(ctx); UNUSED(rv); UNUSED(is_last);
+ //struct elt **stackp;
+ ARG_CHECK2(VAPI_EINVAL, callback_ctx, reply);
+ stackp = (struct elt**) callback_ctx;
+ SRP_LOG_DBG("reply: %d:%d:%d", reply->faceid,reply->dtx_packets,reply->irx_packets);
+
+ vapi_payload_hicn_api_face_stats_details *passed;
+ ARG_CHECK2(VAPI_EINVAL, callback_ctx, reply);
+ passed = (vapi_payload_hicn_api_face_stats_details *) callback_ctx;
+ *passed = *reply;
+ SRP_LOG_DBG("reply %d", reply->faceid);*/
+
+ tlock(lfaces);
+ if (reply!=NULL){
+
+ current->face.faceid = reply->faceid;
+ current->face.intfc = 1;
+ current->face.irx_packets = reply->irx_packets;
+ current->face.irx_bytes = reply->irx_bytes;
+ current->face.itx_packets = reply->itx_packets;
+ current->face.itx_bytes = reply->itx_bytes;
+ current->face.drx_packets = reply->drx_packets;
+ current->face.drx_bytes = reply->drx_bytes;
+ current->face.dtx_packets = reply->dtx_packets;
+ current->face.dtx_bytes = reply->dtx_bytes;
+ //hicn_faces->nface++; // Increment the number of faces
+ counter++;
+ current = current->next;
+ //current->next = memalign(MEM_ALIGN, sizeof(hicn_faces_t));
+ SRP_LOG_DBG_MSG("---------Face------- \n");
+ SRP_LOG_DBG("reply %d", reply->faceid);
+ SRP_LOG_DBG("reply %d", reply->drx_bytes);
+ SRP_LOG_DBG("reply %d", reply->dtx_bytes);
+
+ }else
+ {
+ hicn_faces->nface=counter;
+ counter=0;
+ current=hicn_faces->next;
+ }
+ tunlock(lfaces);
+ return SR_ERR_OK;
+}
- // node state subscriptions
+/**
+* @brief API to del hicn face state details in vpp.
+*/
- rc = sr_rpc_subscribe(session, "/hicn:node-stat-get", hicn_node_stat_get_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription stat-get\n");
- goto error;
- }
+static int hicn_face_stats_details_cb(const char *xpath, const sr_val_t *input,
+ const size_t input_cnt, sr_val_t **output,
+ size_t *output_cnt, void *private_ctx) {
+ //struct elt* stack=NULL ;
+ SRP_LOG_DBG_MSG("hicn face state details received successfully");
+ vapi_payload_hicn_api_face_stats_details resp={0};
+ vapi_msg_hicn_api_face_stats_dump *msg;
+ msg = vapi_alloc_hicn_api_face_stats_dump(g_vapi_ctx_instance);
+ vapi_hicn_api_face_stats_dump(g_vapi_ctx_instance, msg, hicn_api_face_stats_dump_cb, &resp);
+ return SR_ERR_OK;
+}
- // strategies subscriptions
- rc = sr_rpc_subscribe(session, "/hicn:strategy-get", hicn_strategy_get_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription strategy-get\n");
- goto error;
- }
+/**
+* @brief Thread to update the state
+*/
+static void *state_thread(void *arg) {
- rc = sr_rpc_subscribe(session, "/hicn:strategies-get",
- hicn_strategies_get_cb, session, SR_SUBSCR_CTX_REUSE, subscription); if (rc
- != SR_ERR_OK) { SRP_LOG_DBG_MSG("Problem in subscription strategies-get\n"); goto error;
- }
+ // mapping can be retrieved by cpuinfo
+ int map = 0;
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ CPU_SET(map, &cpuset);
- // route subscriptions
+ // pin the thread to a core
+ if (pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset))
+ {
+ SRP_LOG_DBG_MSG("Thread pining failed\n");
+ exit(1);
+ }
- rc = sr_rpc_subscribe(session, "/hicn:route-get", hicn_route_get_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription route-get\n");
- goto error;
- }
+ vapi_msg_hicn_api_node_stats_get *msg=NULL;
+ vapi_msg_hicn_api_node_stats_get_reply *resp=NULL;
+ enum locks_name state;
+ state=lstate;
- rc = sr_rpc_subscribe(session, "/hicn:route-del", hicn_route_del_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription route-del\n");
- goto error;
- }
+ while(true){
+ msg = vapi_alloc_hicn_api_node_stats_get(g_vapi_ctx_instance);
+ vapi_msg_hicn_api_node_stats_get_hton(msg);
- // route nhops subscriptions
+ if (VAPI_OK != vapi_send(g_vapi_ctx_instance, msg)) {
+ SRP_LOG_DBG_MSG("Sending msg to VPP failed");
+ // Here I should think about a recovery method
+ return NULL;
+ }
- rc = sr_rpc_subscribe(session, "/hicn:route-nhops-add",
- hicn_route_nhops_add_cb, session, SR_SUBSCR_CTX_REUSE, subscription); if (rc
- != SR_ERR_OK) { SRP_LOG_DBG_MSG("Problem in subscription route-get\n"); goto error;
- }
+ HICN_VPP_VAPI_RECV;
- rc = sr_rpc_subscribe(session, "/hicn:route-nhops-del",
- hicn_route_nhops_del_cb, session, SR_SUBSCR_CTX_REUSE, subscription); if (rc
- != SR_ERR_OK) { SRP_LOG_DBG_MSG("Problem in subscription route-nhops-del\n"); goto
- error;
- }
+ vapi_msg_hicn_api_node_stats_get_reply_ntoh(resp);
+ if(resp->payload.retval){
+ SRP_LOG_DBG_MSG("Error updating state");
+ // Here I should think about a recovery method
+ return NULL;
+ }
- // face ip subscriptions
+ //vapi_payload_hicn_api_face_stats_details resp_dump={0};
+ vapi_msg_hicn_api_face_stats_dump *msg;
+ msg = vapi_alloc_hicn_api_face_stats_dump(g_vapi_ctx_instance);
+ vapi_hicn_api_face_stats_dump(g_vapi_ctx_instance, msg, hicn_api_face_stats_dump_cb, current);
- rc = sr_rpc_subscribe(session, "/hicn:face-ip-params-get",
- hicn_face_ip_params_get_cb, session, SR_SUBSCR_CTX_REUSE, subscription); if
- (rc != SR_ERR_OK) { SRP_LOG_DBG_MSG("Problem in subscription face-ip-params-get\n");
- goto error;
- }
+ tlock(state);
+ state_cache(resp);
+ SRP_LOG_DBG_MSG("state updated");
+ tunlock(state);
+ sleep(1);
+ }
+ return NULL;
+}
- rc = sr_rpc_subscribe(session, "/hicn:face-ip-add", hicn_face_ip_add_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription face-ip-add\n");
- goto error;
- }
+/**
+* @brief helper function for subscribing all hicn APIs.
+*/
+int hicn_subscribe_events(sr_session_ctx_t *session,
+ sr_subscription_ctx_t **subscription) {
+ int rc = SR_ERR_OK;
+ SRP_LOG_DBG_MSG("Subscriging hicn.");
- rc = sr_rpc_subscribe(session, "/hicn:face-ip-del", hicn_face_ip_del_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription face-ip-del\n");
- goto error;
- }
+ pthread_t state_tid;
+ rc = pthread_create((pthread_t *)&state_tid, NULL, state_thread, NULL);
+ if (rc != 0) {
+ SRP_LOG_DBG_MSG("Error making hicn state thread");
+ return SR_ERR_OPERATION_FAILED;
+ }
+ SRP_LOG_DBG_MSG("State thread created successfully.");
- // punting subscriptions
+ //Initializing the locks
+ for (int i=0; i<NLOCKS; i++)
+ ticket_init(i,LOCK_INIT);
- rc = sr_rpc_subscribe(session, "/hicn:punting-add", hicn_punting_add_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription); if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription punting-add\n");
- goto error;
- }
+ //Initializing the buffer
+ rc=init_buffer();
+ if(rc!= SR_ERR_OK){
+ SRP_LOG_DBG_MSG("Problem in initializing the buffers\n");
+ goto error;
+ }
- rc = sr_rpc_subscribe(session, "/hicn:punting-del", hicn_punting_del_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription punting-del\n");
- goto error;
- }
+ SRP_LOG_DBG_MSG("buffer initialized successfully.");
- rc = sr_subtree_change_subscribe(
- session, "/hicn:hicn-conf", hicn_node_params_set_cb, g_vapi_ctx_instance,
- 100, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_EV_ENABLED, subscription);
- if (SR_ERR_OK != rc) {
- SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-conf\n");
- goto error;
- }
- // subscribe as hicn state data provider
- rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/states",
- hicn_state_states_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/states\n");
- goto error;
- }
+ rc=init_face_pool(current);
+ if(rc!= SR_ERR_OK){
+ SRP_LOG_DBG_MSG("Problem in initializing the face pool\n");
+ goto error;
+ }
- rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/strategy",
- hicn_state_strategy_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/strategy\n");
- goto error;
- }
+ SRP_LOG_DBG_MSG("face pool created successfully.");
+ // node state subscriptions
- rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/strategies",
- hicn_state_strategies_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/strategies\n");
- goto error;
- }
+ rc = sr_rpc_subscribe(session, "/hicn:node-params-get", hicn_node_params_get_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription node-params-get\n");
+ goto error;
+ }
- rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/route",
- hicn_state_route_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/route\n");
- goto error;
- }
+ // node state subscriptions
+ rc = sr_rpc_subscribe(session, "/hicn:node-stat-get", hicn_node_stat_get_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription stat-get\n");
+ goto error;
+ }
- rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/face-ip-params",
- hicn_state_face_ip_params_cb, NULL, SR_SUBSCR_CTX_REUSE,
- subscription);
- if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/face-ip-params\n");
- goto error;
- }
+ // strategies subscriptions
+ rc = sr_rpc_subscribe(session, "/hicn:strategy-get", hicn_strategy_get_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription strategy-get\n");
+ goto error;
+ }
- SRP_LOG_INF_MSG("hicn plugin initialized successfully.");
- return SR_ERR_OK;
+ rc = sr_rpc_subscribe(session, "/hicn:strategies-get",
+ hicn_strategies_get_cb, session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc!= SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription strategies-get\n");
+ goto error;
+ }
+
+ // route subscriptions
+
+ rc = sr_rpc_subscribe(session, "/hicn:route-get", hicn_route_get_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription route-get\n");
+ goto error;
+ }
+
+ rc = sr_rpc_subscribe(session, "/hicn:route-del", hicn_route_del_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription route-del\n");
+ goto error;
+ }
+
+
+ // route nhops subscriptions
+
+ rc = sr_rpc_subscribe(session, "/hicn:route-nhops-add",
+ hicn_route_nhops_add_cb, session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc!= SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription route-nhops-add\n");
+ goto error;
+ }
+
+ rc = sr_rpc_subscribe(session, "/hicn:route-nhops-del",
+ hicn_route_nhops_del_cb, session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc!= SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription route-nhops-del\n");
+ goto error;
+ }
+
+
+ // face ip subscriptions
+
+ rc = sr_rpc_subscribe(session, "/hicn:face-ip-params-get",
+ hicn_face_ip_params_get_cb, session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription face-ip-params-get\n");
+ goto error;
+ }
+
+
+ rc = sr_rpc_subscribe(session, "/hicn:face-ip-add", hicn_face_ip_add_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription face-ip-add\n");
+ goto error;
+ }
+
+ rc = sr_rpc_subscribe(session, "/hicn:face-ip-del", hicn_face_ip_del_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription face-ip-del\n");
+ goto error;
+ }
+
+ // punting subscriptions
+
+ rc = sr_rpc_subscribe(session, "/hicn:punting-add", hicn_punting_add_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription punting-add\n");
+ goto error;
+ }
+
+ rc = sr_rpc_subscribe(session, "/hicn:punting-del", hicn_punting_del_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription punting-del\n");
+ goto error;
+ }
+
+
+ rc = sr_rpc_subscribe(session, "/hicn:face-stats-details", hicn_face_stats_details_cb,
+ session, SR_SUBSCR_CTX_REUSE, subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription face-stats-details\n");
+ goto error;
+ }
+
+ // subscripe for edit-config
+ rc = sr_subtree_change_subscribe(
+ session, "/hicn:hicn-conf", hicn_node_params_set_cb, g_vapi_ctx_instance,
+ 0, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_EV_ENABLED, subscription);
+ if (SR_ERR_OK != rc) {
+ SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-conf\n");
+ goto error;
+ }
+
+ // subscribe as hicn state data provider
+ rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/states",
+ hicn_state_states_cb, NULL, SR_SUBSCR_CTX_REUSE,
+ subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/states\n");
+ goto error;
+ }
+
+ rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/strategies",
+ hicn_state_strategies_cb, NULL, SR_SUBSCR_CTX_REUSE,
+ subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/strategies\n");
+ goto error;
+ }
+
+
+ rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/routes",
+ hicn_state_route_cb, NULL, SR_SUBSCR_CTX_REUSE,
+ subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/routes\n");
+ goto error;
+ }
+
+
+ rc = sr_dp_get_items_subscribe(session, "/hicn:hicn-state/faces",
+ hicn_state_faces_cb, NULL, SR_SUBSCR_CTX_REUSE,
+ subscription);
+ if (rc != SR_ERR_OK) {
+ SRP_LOG_DBG_MSG("Problem in subscription /hicn:hicn-state/faces\n");
+ goto error;
+ }
+
+
+ SRP_LOG_INF_MSG("hicn plugin initialized successfully.");
+ return SR_ERR_OK;
error:
- SRP_LOG_ERR_MSG("Error by initialization of the hicn plugin.");
- sr_plugin_cleanup_cb(session, &g_vapi_ctx_instance);
- return rc;
+ SRP_LOG_ERR_MSG("Error by initialization of the hicn plugin.");
+ sr_plugin_cleanup_cb(session, &g_vapi_ctx_instance);
+ return rc;
} \ No newline at end of file
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h b/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h
index 1f5acabc5..6cb5d2710 100644
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h
+++ b/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h
@@ -1,25 +1,26 @@
/*
- * Copyright (c) 2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright (c) 2019 Cisco and/or its affiliates.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
#ifndef __IETF_HICN_H__
#define __IETF_HICN_H__
#include "../hicn_vpp_comm.h"
-
#define MEM_ALIGN 4096
+#define B32 4
+#define B64 8
// Number of locks is equal to number of nodes in hicn-state
// It is a coarse grain approach later can be changed to fine grained
@@ -28,63 +29,127 @@
#define LOCK_INIT 0
-enum locks_name {lstate, lstrategy, lstrategies, lroute, lface_ip_params};
+enum locks_name {lstate, lstrategy, lstrategies, lroute, lfaces};
#define NSTATE_LEAVES 15
#define NSTRATEGY_LEAVES 1
#define NSTRATEGIES_LEAVES 2
#define NROUTE_LEAVES 2
-#define NFACE_IP_PARAMS_LEAVES 3
+#define MAX_FACE_POOL 100
+#define FACES_CHILDREN 9 /*this is the number of children of each leave*/
+
+#define params_send( msg , resp ) \
+{ \
+ if (VAPI_OK != vapi_send(g_vapi_ctx_instance, (msg))) { \
+ SRP_LOG_DBG_MSG("Sending msg to VPP failed"); \
+ return SR_ERR_OPERATION_FAILED; \
+ } \
+ HICN_VPP_VAPI_RECV; \
+};
typedef struct __attribute__ ((__packed__)) {
- uint64_t pkts_processed;
- uint64_t pkts_interest_count;
- uint64_t pkts_data_count;
- uint64_t pkts_from_cache_count;
- uint64_t pkts_no_pit_count;
- uint64_t pit_expired_count;
- uint64_t cs_expired_count;
- uint64_t cs_lru_count;
- uint64_t pkts_drop_no_buf;
- uint64_t interests_aggregated;
- uint64_t interests_retx;
- uint64_t interests_hash_collision;
- uint64_t pit_entries_count;
- uint64_t cs_entries_count;
- uint64_t cs_entries_ntw_count;
- int32_t retval;
+
+ int32_t retval;
+ uint64_t pkts_processed;
+ uint64_t pkts_interest_count;
+ uint64_t pkts_data_count;
+ uint64_t pkts_from_cache_count;
+ uint64_t pkts_no_pit_count;
+ uint64_t pit_expired_count;
+ uint64_t cs_expired_count;
+ uint64_t cs_lru_count;
+ uint64_t pkts_drop_no_buf;
+ uint64_t interests_aggregated;
+ uint64_t interests_retx;
+ uint64_t interests_hash_collision;
+ uint64_t pit_entries_count;
+ uint64_t cs_entries_count;
+ uint64_t cs_entries_ntw_count;
} hicn_state_t;
typedef struct __attribute__ ((__packed__)) {
- uint8_t description[200];
- int32_t retval;
+ uint8_t description[200];
+ int32_t retval;
} hicn_strategy_t;
typedef struct __attribute__ ((__packed__)) {
- uint8_t n_strategies;
- uint32_t strategy_id[256];
- int32_t retval;
+ uint8_t n_strategies;
+ uint32_t strategy_id[256];
+ int32_t retval;
} hicn_strategies_t;
typedef struct __attribute__ ((__packed__)) {
- uint16_t faceids[1000];
- uint32_t strategy_id;
- int32_t retval;
+ uint32_t faceids[1000];
+ uint32_t strategy_id;
+ int32_t retval;
} hicn_route_t;
typedef struct __attribute__ ((__packed__)) {
- uint64_t nh_addr[2];
- uint32_t swif;
- uint32_t flags;
- int32_t retval;
+ uint64_t nh_addr[2];
+ uint32_t swif;
+ uint32_t flags;
+ int32_t retval;
} hicn_face_ip_params_t;
+typedef struct __attribute__ ((__packed__)) {
+ uint32_t faceid;
+ uint32_t intfc;
+ uint64_t irx_packets;
+ uint64_t irx_bytes;
+ uint64_t itx_packets;
+ uint64_t itx_bytes;
+ uint64_t drx_packets;
+ uint64_t drx_bytes;
+ uint64_t dtx_packets;
+ uint64_t dtx_bytes;
+} hicn_face_inf_t;
+
+
+struct hicn_faces_s{
+ hicn_face_inf_t face;
+ struct hicn_faces_s * next;
+};
+
+typedef struct __attribute__ ((__packed__)) {
+ uint32_t nface;
+ struct hicn_faces_s * next;
+} hicn_faces_t;
+
+// typedef struct __attribute__ ((__packed__)) {
+// int32_t retval;
+// uint32_t faceid;
+// uint64_t irx_packets;
+// uint64_t irx_bytes;
+// uint64_t itx_packets;
+// uint64_t itx_bytes;
+// uint64_t drx_packets;
+// uint64_t drx_bytes;
+// uint64_t dtx_packets;
+// uint64_t dtx_bytes;
+// } hicn_face_stat_t;
+
+// typedef struct __attribute__ ((__packed__)) {
+
+// int32_t retval;
+// uint32_t faceid;
+// uint64_t irx_packets;
+// uint64_t irx_bytes;
+// uint64_t itx_packets;
+// uint64_t itx_bytes;
+// uint64_t drx_packets;
+// uint64_t drx_bytes;
+// uint64_t dtx_packets;
+// uint64_t dtx_bytes;
+
+// } hicn_state_face_t;
+
+
int hicn_subscribe_events(sr_session_ctx_t *session,
- sr_subscription_ctx_t **subscription);
+ sr_subscription_ctx_t **subscription);
-#endif /* __IETF_HICN_H__ */ \ No newline at end of file
+#endif /* __IETF_HICN_H__ */
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c b/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c
index d870adf75..d27ae6492 100644
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c
+++ b/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c
@@ -1,7 +1,7 @@
#include"tlock.h"
-void Ticket_init ( int Lock_Number , long int init ){
+void ticket_init ( int Lock_Number , long int init ){
//__atomic_store( &En[Lock_Number] , &init , __ATOMIC_SEQ_CST );
//__atomic_store( &De[Lock_Number] , &init , __ATOMIC_SEQ_CST );
@@ -9,13 +9,13 @@ En[Lock_Number]=init;
De[Lock_Number]=init;
}
-void Ticket_Lock(int Lock_Number ){
+void tlock(int Lock_Number ){
int my_ticket = __sync_fetch_and_add(&En[Lock_Number] , 1 );
while ( my_ticket != De[ Lock_Number ] ) {};
}
-void Ticket_Unlock(int Lock_Number ){
+void tunlock(int Lock_Number ){
De[Lock_Number]++;
}
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h b/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h
index 36698115a..8cdfc8b5b 100644
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h
+++ b/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h
@@ -24,8 +24,8 @@
volatile long int En[MAX_LOCK_SIZE] , De[MAX_LOCK_SIZE] ; // For Ticket Algorithm
-void Ticket_init ( int Lock_Number , long int init );
-void Ticket_Lock(int Lock_Number );
-void Ticket_Unlock(int Lock_Number );
+void ticket_init ( int Lock_Number , long int init );
+void tlock(int Lock_Number );
+void tunlock(int Lock_Number );
#endif /* __IETF_HICN_H__ */ \ No newline at end of file
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/yang/controler_rpcs_instances.xml b/utils/sysrepo-plugins/hicn-plugin/plugin/yang/controler_rpcs_instances.xml
deleted file mode 100644
index f497f0193..000000000
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/yang/controler_rpcs_instances.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<node-params-get xmlns="urn:sysrepo:hicn"/>
-
-<node-stat-get xmlns="urn:sysrepo:hicn"/>
-
-<strategy-get xmlns="urn:sysrepo:hicn">
- <strategy_id>0</strategy_id>
-</strategy-get>
-
-<strategies-get xmlns="urn:sysrepo:hicn"/>
-
-
-<route-get xmlns="urn:sysrepo:hicn">
- <ip4>192.168.1.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
-</route-get>
-
-<route-del xmlns="urn:sysrepo:hicn">
- <ip4>192.168.1.1</ip4>
- <ip6>-1</ip6>
- <len>30</len>
-</route-del>
-
-<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-params-get xmlns="urn:sysrepo:hicn">
- <faceid>10</faceid>
-</face-ip-params-get>
-
-<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>
-
-
-<face-ip-del xmlns="urn:sysrepo:hicn">
- <faceid>0</faceid>
-</face-ip-del>
-
-<punting-add xmlns="urn:sysrepo:hicn">
- <ip4>192.168.0.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
- <swif>0</swif>
-</punting-add>
-
-
-<punting-del xmlns="urn:sysrepo:hicn">
- <ip4>192.168.0.1</ip4>
- <ip6>-1</ip6>
- <len>24</len>
- <swif>0</swif>
-</punting-del> \ No newline at end of file
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/yang/model/hicn.yang b/utils/sysrepo-plugins/hicn-plugin/plugin/yang/model/hicn.yang
deleted file mode 100644
index eddf31c98..000000000
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/yang/model/hicn.yang
+++ /dev/null
@@ -1,536 +0,0 @@
-module hicn {
-namespace "urn:sysrepo:hicn";
-prefix hcn;
-
-revision 2019-02-06 {
- description "Initial revision.";
-}
-
-/* new data types and grouping definition to forward the remote request toward hicn controler--to-->hicn */
-
-typedef float {
- type decimal64 {
- fraction-digits 2;
- }
-}
-
-
-grouping params {
-
-leaf enable_disable {
- description "Enable / disable ICN forwarder in VPP.";
- type boolean;
- default false;
- }
-
-leaf pit_max_size {
- description "PIT maximum size, otherwise -1 to assign default value.";
- type int32;
- default -1;
- }
-
-leaf cs_max_size {
- description "CS maximum size, otherwise -1 to assign default value.";
- type int32;
- default -1;
- }
-
-leaf cs_reserved_app {
- description "Portion of CS reserved to application, otherwise -1 to assign default value.";
- type int32;
- default -1;
- }
-
-leaf pit_dflt_lifetime_sec {
- description "Default PIT entry lifetime, otherwise -1 to assign default value.";
- type float;
- default -1;
- }
-
-leaf pit_max_lifetime_sec {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value.";
- type float;
- default -1;
- }
-
-leaf pit_min_lifetime_sec {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type float;
- default -1;
- }
-}
-
-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 uint16;
- }
-
-}
-
-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 route_get {
-
-
-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 {
-
-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 swif {
- description "Interface id.";
- type uint32;
- }
-}
-
-grouping register_prod_app {
-
-leaf-list prefix {
- description "prefix to be matched to the FIB.";
- type uint64;
- }
-
-leaf len {
- description "Length of the prefix.";
- type uint8;
- }
-
-leaf swif {
- description "Interface id.";
- type uint32;
- }
-
-leaf cs_reserved {
- description "CS memory reserved -- in number of packets.";
- type uint32;
- }
-
-}
-
-/* new data types and grouping definition to backward the remote response hicn--to-->controler */
-
-
-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;
- }
-
- 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;
- }
-
- leaf interests_hash_collision {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
-
- 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 cs_entries_ntw_count {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint64;
- }
-
-}
-
-
-
-grouping strategy-reply {
-
- leaf description {
- description "Enable / disable ICN forwarder in VPP.";
- type uint8;
- }
-}
-
-grouping route-reply {
-
- leaf faceids {
- description "Enable / disable ICN forwarder in VPP.";
- type uint16;
-
- }
-
- 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;
- }
-
-}
-
-grouping face-ip-params-reply {
-
- leaf nh_addr {
- description "Enable / disable ICN forwarder in VPP.";
- type uint64;
- }
-
- leaf swif {
- description "compile-time plugin features.";
- type uint32;
- }
-
- leaf flags {
- description "compile-time plugin features.";
- type uint32;
- }
-
-}
-
-
-/* Hicn configuration */
-
-container hicn-conf {
- config true;
- description "config data container for the hicn-vpp.";
-
- container params{
- uses params;
- }
-}
-
-
-/* Hicn operational data */
-
-container hicn-state {
- config false;
- description "operational data container for the hicn.";
-
- container states{
- uses states-reply;
- }
- container strategy{
- uses strategy-reply;
- }
- container route{
- uses route-reply;
- }
- container strategies{
- uses strategies-reply;
- }
- container face-ip-params{
- uses face-ip-params-reply;
- }
-
-}
-
-/* RPC Definitions */
-
-
-rpc node-params-set {
- description "Operation to set hicn params in vpp.";
- input {
- uses params;
- }
-}
-
-rpc node-params-get {
- description "Operation to get hicn parameter in vpp.";
-}
-
-
-rpc node-stat-get {
- description "Operation to get hicn status in vpp.";
-}
-
-
-rpc strategy-get {
- description "Operation to get hicn strategy.";
- input {
- leaf strategy_id {
- description "Upper bound on PIT entry lifetime, otherwise -1 to assign default value .";
- type uint32;
- }
- }
-}
-
-rpc strategies-get {
- description "Operation to get hicn strategies.";
-}
-
-rpc route-get {
- description "Operation to get hicn route.";
- input {
- uses route_get;
- }
-}
-
-rpc route-del {
- description "Operation to del hicn route.";
- input {
- uses route_del;
- }
-}
-
-rpc route-nhops-add {
- description "Operation to add hicn route nhops.";
- input {
- uses route_nhops_add;
- }
-}
-
-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 uint16;
- }
- }
-}
-
-rpc face-ip-add {
- description "Operation to add hicn face ip.";
- input {
- uses face_ip_add;
- }
-}
-
-rpc face-ip-del {
- description "Operation to del hicn face ip.";
- input {
- leaf faceid {
- description "Face to be deleted .";
- type uint16;
- }
- }
-}
-
-rpc punting-add {
- description "Operation to add hicn punt.";
- input {
- uses punting_add;
- }
-}
-
-rpc punting-del {
- description "Operation to del hicn punt.";
- input {
- uses punting_add; /* It uses the same payload as the add*/
- }
-}
-
-}
diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/yang/startup.xml b/utils/sysrepo-plugins/hicn-plugin/plugin/yang/startup.xml
deleted file mode 100644
index f88e13ea2..000000000
--- a/utils/sysrepo-plugins/hicn-plugin/plugin/yang/startup.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<hicn-conf xmlns="urn:sysrepo:hicn">
-<params>
- <enable_disable>false</enable_disable>
- <pit_max_size>-1</pit_max_size>
- <cs_max_size>-1</cs_max_size>
- <cs_reserved_app>-1</cs_reserved_app>
- <pit_dflt_lifetime_sec>-1</pit_dflt_lifetime_sec>
- <pit_max_lifetime_sec>-1</pit_max_lifetime_sec>
- <pit_min_lifetime_sec>-1</pit_min_lifetime_sec>
-</params>
-</hicn-conf> \ No newline at end of file