aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/openconfig/openconfig_plugin.c16
-rw-r--r--src/plugins/openconfig/openconfig_plugin.h8
-rw-r--r--src/plugins/sc_plugins.c8
3 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/openconfig/openconfig_plugin.c b/src/plugins/openconfig/openconfig_plugin.c
index 5d5582a..a47d687 100644
--- a/src/plugins/openconfig/openconfig_plugin.c
+++ b/src/plugins/openconfig/openconfig_plugin.c
@@ -263,3 +263,19 @@ void openconfig_unsubscribe(plugin_main_t* plugin_main)
} while (plugin_subcscription != NULL);
}
}
+
+plugin_main_t plugin_main;
+
+int openconfig_plugin_init(sr_session_ctx_t* session)
+{
+ memset((void*) &plugin_main, 0, sizeof(plugin_main));
+
+ plugin_main.ds_running = session;
+
+ openconfig_register_subscribe(&plugin_main);
+}
+
+void openconfig_plugin_cleanup()
+{
+ openconfig_register_subscribe(&plugin_main);
+}
diff --git a/src/plugins/openconfig/openconfig_plugin.h b/src/plugins/openconfig/openconfig_plugin.h
index 5f0c352..714ae7d 100644
--- a/src/plugins/openconfig/openconfig_plugin.h
+++ b/src/plugins/openconfig/openconfig_plugin.h
@@ -66,5 +66,13 @@ struct _sys_repo_call {
int openconfig_register_subscribe(plugin_main_t *plugin_main);
void openconfig_unsubscribe(plugin_main_t *plugin_main);
+//FIXME:
+// This solution is not good and should be rewrite.
+// But first we must discuss the architecture of sweetcomb and how we should
+// register the new YANGS modules.
+// This function here is only for test.
+int openconfig_plugin_init(sr_session_ctx_t *session);
+void openconfig_plugin_cleanup();
+
#endif /* __SWEETCOMB_OPENCONFIG_PLUGIN__ */
diff --git a/src/plugins/sc_plugins.c b/src/plugins/sc_plugins.c
index 29d75bb..1a09654 100644
--- a/src/plugins/sc_plugins.c
+++ b/src/plugins/sc_plugins.c
@@ -41,6 +41,8 @@ DEFINE_VAPI_MSG_IDS_HC_API_JSON;
//#include "sc_l2.h"
//#include "sc_vxlan.h"
+#include "openconfig/openconfig_plugin.h"
+
int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx)
{
SC_INVOKE_BEGIN;
@@ -61,6 +63,9 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx)
//INTERFACE
sc_interface_subscribe_events(session, &subscription);
+ //Openconfig modules
+ openconfig_plugin_init(session);
+
/* set subscription as our private context */
*private_ctx = subscription;
SC_INVOKE_END;
@@ -70,6 +75,9 @@ 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_INVOKE_BEGIN;
+
+ openconfig_plugin_clean();
+
/* subscription was set as our private context */
sr_unsubscribe(session, private_ctx);
SC_LOG_DBG_MSG("unload plugin ok.");