summaryrefslogtreecommitdiffstats
path: root/src/plugins/sc_plugins.c
diff options
context:
space:
mode:
authorYohanPipereau <ypiperea@cisco.com>2019-06-05 11:21:14 +0200
committerHongjun Ni <hongjun.ni@intel.com>2019-06-13 02:43:00 +0000
commitec995e056d985f9ef54f92adbcbe626967912592 (patch)
tree38f50dddfebdf8af34daa0273ecae75f8bc644f7 /src/plugins/sc_plugins.c
parent86af475f838adff5c44bb8eccdfba2d665975451 (diff)
Support for ietf-interfaces statistics
-Add connection to VPP STAT API -Support a few statistic counters from ietf-interfaces Change-Id: I77372ea562e73311effd5b08fd36b0d90ababdac Signed-off-by: YohanPipereau <ypiperea@cisco.com>
Diffstat (limited to 'src/plugins/sc_plugins.c')
-rw-r--r--src/plugins/sc_plugins.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/sc_plugins.c b/src/plugins/sc_plugins.c
index e0de0f6..7fc5975 100644
--- a/src/plugins/sc_plugins.c
+++ b/src/plugins/sc_plugins.c
@@ -17,6 +17,8 @@
#include <dirent.h>
+#include <vpp-api/client/stat_client.h>
+
sc_plugin_main_t sc_plugin_main;
static int vpp_pid_start;
@@ -73,9 +75,17 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx)
sc_plugin_main.session = session;
+ /* Connect to VAPI */
rc = sc_connect_vpp();
if (0 != rc) {
- SRP_LOG_ERR("vpp connect error , with return %d.", rc);
+ SRP_LOG_ERR("vpp vapi connect error , with return %d.", rc);
+ return SR_ERR_INTERNAL;
+ }
+
+ /* Connect to STAT API */
+ rc = stat_segment_connect(STAT_SEGMENT_SOCKET_FILE);
+ if (rc != 0) {
+ SRP_LOG_ERR("vpp stat connect error , with return %d.", rc);
return SR_ERR_INTERNAL;
}
@@ -94,13 +104,17 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx)
void sr_plugin_cleanup_cb(sr_session_ctx_t *session, void *private_ctx)
{
- sc_call_all_exit_function(&sc_plugin_main);
+ sc_call_all_exit_function(&sc_plugin_main);
/* subscription was set as our private context */
if (private_ctx != NULL)
sr_unsubscribe(session, private_ctx);
SRP_LOG_DBG_MSG("unload plugin ok.");
+ /* Disconnect from STAT API */
+ stat_segment_disconnect();
+
+ /* Disconnect from VAPI */
sc_disconnect_vpp();
SRP_LOG_DBG_MSG("plugin disconnect vpp ok.");
}