summaryrefslogtreecommitdiffstats
path: root/ctrl/sysrepo-plugins/hicn-light
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl/sysrepo-plugins/hicn-light')
-rw-r--r--ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.c13
-rw-r--r--ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h22
-rw-r--r--ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c54
3 files changed, 27 insertions, 62 deletions
diff --git a/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.c b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.c
index ae436a8ad..6cfc0b52b 100644
--- a/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.c
+++ b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.c
@@ -27,7 +27,6 @@ sr_subscription_ctx_t *subscription = NULL;
volatile int exit_application = 0;
int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) {
- HICN_INVOKE_BEGIN
sr_subscription_ctx_t *subscription = NULL;
int rc = SR_ERR_OK;
rc = hicn_connect_light();
@@ -36,24 +35,20 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) {
return SR_ERR_INTERNAL;
}
- // HICN subscribe
hicn_subscribe_events(session, &subscription);
/* set subscription as our private context */
*private_ctx = subscription;
- HICN_INVOKE_END;
return SR_ERR_OK;
}
void sr_plugin_cleanup_cb(sr_session_ctx_t *session, void *private_ctx) {
- HICN_INVOKE_BEGIN;
/* subscription was set as our private context */
- sr_unsubscribe(session, private_ctx);
+ sr_unsubscribe(private_ctx);
HICN_LOG_DBG_MSG("hicn light unload plugin ok.");
hicn_disconnect_light();
HICN_LOG_DBG_MSG("hicn light disconnect ok.");
- HICN_INVOKE_END;
}
static void sigint_handler(int signum) { exit_application = 1; }
@@ -75,14 +70,14 @@ int main(int argc, char **argv) {
}
/* connect to sysrepo */
- rc = sr_connect("cpe_application", SR_CONN_DEFAULT, &connection);
+ rc = sr_connect(SR_CONN_DEFAULT, &connection);
if (SR_ERR_OK != rc) {
fprintf(stderr, "Error by sr_connect: %s\n", sr_strerror(rc));
goto cleanup;
}
/* start session */
- rc = sr_session_start(connection, SR_DS_STARTUP, SR_SESS_DEFAULT, &session);
+ rc = sr_session_start(connection, SR_DS_STARTUP, &session);
if (SR_ERR_OK != rc) {
fprintf(stderr, "Error by sr_session_start: %s\n", sr_strerror(rc));
goto cleanup;
@@ -107,7 +102,7 @@ int main(int argc, char **argv) {
cleanup:
if (NULL != subscription) {
- sr_unsubscribe(session, subscription);
+ sr_unsubscribe(subscription);
}
if (NULL != session) {
sr_session_stop(session);
diff --git a/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h
index 100023564..ca67cf0b7 100644
--- a/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h
+++ b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h
@@ -16,7 +16,6 @@
#ifndef __HICN_LIGHT_COMMM_H__
#define __HICN_LIGHT_COMMM_H__
#include <sysrepo.h>
-#include <sysrepo/plugins.h>
#include <sysrepo/values.h>
@@ -30,27 +29,6 @@
#endif
#endif
-#ifndef _NOLOG
-#define HICN_LOG_DBG SRP_LOG_DBG
-#define HICN_LOG_ERR SRP_LOG_ERR
-#define HICN_LOG_DBG_MSG SRP_LOG_DBG_MSG
-#define HICN_LOG_ERR_MSG SRP_LOG_ERR_MSG
-#else
-#define HICN_LOG_DBG // printf
-#define HICN_LOG_DBG // SRP_LOG_DBG
-#define HICN_LOG_ERR // SRP_LOG_ERR
-#define HICN_LOG_DBG_MSG // SRP_LOG_DBG_MSG
-#define HICN_LOG_ERR_MSG // SRP_LOG_ERR_MSG
-#endif
-
-//Here it is the definition
-
-#define HICN_INVOKE_BEGIN HICN_LOG_DBG("inovke %s bein.", HICN_THIS_FUNC);
-#define HICN_INVOKE_END \
- HICN_LOG_DBG("inovke %s end,with return OK.", HICN_THIS_FUNC);
-#define HICN_INVOKE_ENDX(...) \
- HICN_LOG_DBG("inovke %s end,with %s.", HICN_THIS_FUNC, ##__VA_ARGS__)
-
#define ARG_CHECK(retval, arg) \
do { \
if (NULL == (arg)) { \
diff --git a/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c b/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c
index 6f8ece08c..47e07d196 100644
--- a/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c
+++ b/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c
@@ -28,11 +28,10 @@
/**
* @brief API to add hicn face ip in hicn-light.
*/
-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) {
+static int hicn_face_ip_add_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
+ sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
- SRP_LOG_DBG_MSG("hicn face ip add received successfully");
+ SRP_LOG_DBGMSG("hicn face ip add received successfully");
hc_face_t face;
if(strcmp(input[0].data.string_val,"-1")){
@@ -51,7 +50,7 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input,
face.face.local_addr.v6.as_in6addr = *dst;
}else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
+ SRP_LOG_DBGMSG("Invalid local IP address");
return SR_ERR_OPERATION_FAILED;
}
@@ -72,12 +71,11 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input,
face.face.remote_addr.v6.as_in6addr = *dst;
}else{
- SRP_LOG_DBG_MSG("Invalid local IP address");
+ SRP_LOG_DBGMSG("Invalid local IP address");
return SR_ERR_OPERATION_FAILED;
}
- // strncpy(face.face.hicn.netdevice.name,"ens39"); // Can we work only with Idx number ?
face.face.netdevice.index = input[4].data.uint32_val; // This is the idx number of interface
@@ -88,34 +86,29 @@ static int hicn_face_ip_add_cb(const char *xpath, const sr_val_t *input,
int rc;
rc = hc_face_create(hsocket, &face);
if (rc > 0) {
- SRP_LOG_DBG_MSG("Face added successfully");
+ SRP_LOG_DBGMSG("Face added successfully");
return SR_ERR_OK;
}
- SRP_LOG_DBG_MSG("Operation Failed");
+ SRP_LOG_DBGMSG("Operation Failed");
return SR_ERR_OPERATION_FAILED;
}
/**
* @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) {
+static int hicn_face_ip_del_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
+ sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
- SRP_LOG_DBG_MSG("hicn face ip del received successfully");
+ SRP_LOG_DBGMSG("hicn face ip del received successfully");
face_t * face=NULL;
- // msg->payload.faceid = input[0].data.uint16_val;
- //lookup(face);
+
face_free(face);
- // if(!resp->payload.retval){
- // SRP_LOG_DBG_MSG("Successfully Done");
- // return SR_ERR_OK;
- // }
- SRP_LOG_DBG_MSG("Operation Failed");
+
+ SRP_LOG_DBGMSG("Operation Failed");
return SR_ERR_OPERATION_FAILED;
}
@@ -124,9 +117,8 @@ static int hicn_face_ip_del_cb(const char *xpath, const sr_val_t *input,
/**
* @brief API to del hicn face ip in vpp.
*/
-static int hicn_route_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) {
+static int hicn_route_add_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
+ sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) {
/*
@@ -169,34 +161,34 @@ int hicn_subscribe_events(sr_session_ctx_t *session,
int rc;
rc = sr_rpc_subscribe(session, "/hicn:face-ip-add", hicn_face_ip_add_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription);
+ session, 100,SR_SUBSCR_CTX_REUSE, subscription);
if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription stat-get\n");
+ SRP_LOG_DBGMSG("Problem in subscription stat-get\n");
goto error;
}
rc = sr_rpc_subscribe(session, "/hicn:face-ip-del", hicn_face_ip_del_cb,
- session, SR_SUBSCR_CTX_REUSE, subscription);
+ session, 100,SR_SUBSCR_CTX_REUSE, subscription);
if (rc != SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription face-ip-del\n");
+ SRP_LOG_DBGMSG("Problem in subscription face-ip-del\n");
goto error;
}
rc = sr_rpc_subscribe(session, "/hicn:route-nhops-add",
- hicn_route_add_cb, session, SR_SUBSCR_CTX_REUSE, subscription);
+ hicn_route_add_cb, session, 100,SR_SUBSCR_CTX_REUSE, subscription);
if (rc!= SR_ERR_OK) {
- SRP_LOG_DBG_MSG("Problem in subscription route-nhops-add\n");
+ SRP_LOG_DBGMSG("Problem in subscription route-nhops-add\n");
goto error;
}
- SRP_LOG_INF_MSG("hicn light initialized successfully.");
+ SRP_LOG_DBGMSG("hicn light initialized successfully.");
return SR_ERR_OK;
error:
- SRP_LOG_ERR_MSG("Error by initialization of the hicn plugin.");
+ SRP_LOG_ERRMSG("Error by initialization of the hicn plugin.");
sr_plugin_cleanup_cb(session, hsocket);
return rc;