From a0f325f0b6ca0129ed339ac4ac94d7159e926977 Mon Sep 17 00:00:00 2001 From: mhemmatp Date: Thu, 12 Dec 2019 16:05:13 +0100 Subject: [HICN-440] Add comments to hicn sysrepo plugin code Signed-off-by: mhemmatp Change-Id: I0ed0c5b0b9cd7714b46867e4d4fe0324945cf418 --- .../hicn-plugin/plugin/model/hicn_model.c | 144 ++++++--------------- 1 file changed, 43 insertions(+), 101 deletions(-) (limited to 'ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c') diff --git a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c index 8db0a6238..d73e6145a 100644 --- a/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c +++ b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c @@ -13,6 +13,13 @@ * limitations under the License. */ + + +/** @file hicn_model.c + * @brief This file contains implementations of the main calls + */ + + #define _GNU_SOURCE #include @@ -39,14 +46,29 @@ DEFINE_VAPI_MSG_IDS_HICN_API_JSON // Shared local variables between state and RPCs +/** + * @brief this shared variable keeps the hicn state + */ volatile hicn_state_t * hicn_state = NULL; -volatile hicn_strategy_t * hicn_strategy = NULL; +/** + * @brief this shared variable keeps hicn strategies + */ 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; +/** + * @brief this shared variable keeps statistics of hicn faces + */ volatile hicn_faces_t * hicn_faces = NULL; +/** + * @brief this shared variable keeps routes information in hicn + */ volatile hicn_routes_t * hicn_routes = NULL; +/** + * @brief this shared variable is the link list to maintain all the faces (up to MAX_FACES) + */ struct hicn_faces_s * fcurrent = NULL; +/** + * @brief this shared variable is the link list to maintain all the routes + */ struct hicn_routes_s * rcurrent = NULL; @@ -55,15 +77,9 @@ 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_faces = memalign(MEM_ALIGN, sizeof(hicn_faces_t) ); hicn_faces->next=memalign(MEM_ALIGN, sizeof(struct hicn_faces_s)); fcurrent=hicn_faces->next; @@ -75,7 +91,7 @@ static int init_buffer(void){ int retval=-1; - ARG_CHECK7(retval, hicn_state, hicn_strategy, hicn_strategies, hicn_route, fcurrent, hicn_faces, hicn_routes); + ARG_CHECK5(retval, hicn_state, hicn_strategies, fcurrent, hicn_faces, hicn_routes); hicn_routes->nroute=0; hicn_faces->nface=0; retval=0; @@ -83,7 +99,6 @@ static int init_buffer(void){ return retval; } - static int init_face_pool(struct hicn_faces_s * head){ for(int i=0; iretval){ - SRP_LOG_DBGMSG("Successfully done"); - return VAPI_OK; - }else - return VAPI_EUSER; -} - - -vapi_error_e call_hicn_api_strategies_get(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_strategies_get(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -136,20 +137,7 @@ if(!reply->retval){ return VAPI_EUSER; } -vapi_error_e call_hicn_api_route_get_hton(struct vapi_ctx_s *ctx, - void *callback_ctx, - vapi_error_e rv, - bool is_last, - vapi_payload_hicn_api_strategies_get_reply *reply){ -if(!reply->retval){ - SRP_LOG_DBGMSG("Successfully done"); - return VAPI_OK; - }else - return VAPI_EUSER; -} - - -vapi_error_e call_hicn_api_route_nhops_add(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_route_nhops_add(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -161,7 +149,7 @@ if(!reply->retval){ return VAPI_EUSER; } -vapi_error_e call_hicn_api_route_del(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_route_del(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -174,7 +162,7 @@ if(!reply->retval){ return VAPI_EUSER; } -vapi_error_e call_hicn_api_face_ip_params_get(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_face_ip_params_get(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -190,8 +178,7 @@ if(!reply->retval){ return VAPI_EUSER; } - -vapi_error_e call_hicn_api_punting_add(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_punting_add(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -204,7 +191,7 @@ if(!reply->retval){ } -vapi_error_e call_hicn_api_route_nhop_del(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_route_nhop_del(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -216,8 +203,7 @@ if(!reply->retval){ return VAPI_EUSER; } - -vapi_error_e call_hicn_api_punting_del(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_punting_del(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -230,7 +216,7 @@ if(!reply->retval){ } -vapi_error_e call_hicn_api_face_ip_del(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_face_ip_del(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -243,7 +229,7 @@ if(!reply->retval){ } -vapi_error_e call_hicn_api_face_ip_add(struct vapi_ctx_s *ctx, +static vapi_error_e call_hicn_api_face_ip_add(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -256,7 +242,7 @@ if(!reply->retval){ } -vapi_error_e call_vapi_hicn_api_node_stats_get(struct vapi_ctx_s *ctx, +static vapi_error_e call_vapi_hicn_api_node_stats_get(struct vapi_ctx_s *ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -283,21 +269,9 @@ if(!reply->retval){ return VAPI_EUSER; } -vapi_error_e call_hicn_api_node_params_set(struct vapi_ctx_s *ctx, - void *callback_ctx, - vapi_error_e rv, - bool is_last, - vapi_payload_hicn_api_node_params_set_reply *reply){ - if(!reply->retval){ - SRP_LOG_DBGMSG("Successfully done"); - return VAPI_OK; - }else - return VAPI_EUSER; -} - static inline void state_update(sr_val_t * vals, struct lyd_node **parent, sr_session_ctx_t *session){ char buf[20]; - //struct ly_ctx *ly_ctx = sr_get_context(sr_session_get_connection(session)); + 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; @@ -463,8 +437,6 @@ static inline int faces_update(sr_val_t * vals, uint32_t nleaves, struct lyd_no for(int count=0; count