aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/openconfig/openconfig_interfaces.c
diff options
context:
space:
mode:
authorYohanPipereau <ypiperea@cisco.com>2019-02-26 11:47:26 +0100
committerYohanPipereau <ypiperea@cisco.com>2019-02-28 11:56:29 +0100
commit793682e6fcb9e39891c59c696e5f8e9c18f9d8e7 (patch)
tree3c85ee82ab556d696dc7af8a6d9f55e9a08cf7f8 /src/plugins/openconfig/openconfig_interfaces.c
parentf9393a8c15fbd63b7a0938269afa8a35ddfc4738 (diff)
This commit changes the way models are registered.
Registering a new model is now done using model_register function which is generic enough to take care of every model family (IETF, Openconfig, ...). Every model (ex: openconfig-interfaces) contain one or several xpaths. Every model (ex: openconfig-interfaces) has its own dedicated C file (ex: openconfig-interfaces.c) with its dedicated xpath_t structure in it. This structure is a mapping of all xpaths of a model to their associated callbacks. It still contains all informations needed by sr_*_subscribe functions. Thus, xpath_t is an external array used in every model, it is seen as a global symbol in shared library. And because these external arrays are passed as arguments to a function, maccros defining the size of these xpath_t arrays have been defined. datastore_e datastructure has been removed to rely on the one provided by sysrepo API. The subscription linked list which was used has been removed because sysrepo already takes care of this. Now, the same subscription_session_ctx_t is used for all subscriptions as it was the case in ietf_subscribe_events. Thus cleanup callback has been simplified to a simple sysrepo_unsubscribe instead of going through the entire Linked List. Change-Id: I43d52f619be27b6216bb3b9d197518b032306fa7 Signed-off-by: Yohan Pipereau <ypiperea@cisco.com>
Diffstat (limited to 'src/plugins/openconfig/openconfig_interfaces.c')
-rw-r--r--src/plugins/openconfig/openconfig_interfaces.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/plugins/openconfig/openconfig_interfaces.c b/src/plugins/openconfig/openconfig_interfaces.c
index e401e07..a1f66bb 100644
--- a/src/plugins/openconfig/openconfig_interfaces.c
+++ b/src/plugins/openconfig/openconfig_interfaces.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <sysrepo/xpath.h>
#include <sysrepo/values.h>
+#include <sysrepo.h>
#define XPATH_SIZE 2000
@@ -209,7 +210,7 @@ int openconfig_interface_mod_cb(
__attribute__((unused)) sr_notif_event_t event,
__attribute__((unused)) void *private_ctx)
{
- SRP_LOG_INF("Module subscribe: %s", module_name);
+ SRP_LOG_DBG("Interface module subscribe: %s", module_name);
return SR_ERR_OK;
}
@@ -876,3 +877,62 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
return SR_ERR_OK;
}
+const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE] = {
+ {
+ .xpath = "openconfig-interfaces",
+ .method = MODULE,
+ .datastore = SR_DS_RUNNING,
+ .cb.mcb = openconfig_interface_mod_cb,
+ .private_ctx = NULL,
+ .priority = 0,
+ //.opts = SR_SUBSCR_EV_ENABLED | SR_SUBSCR_APPLY_ONLY
+ .opts = SR_SUBSCR_EV_ENABLED | SR_SUBSCR_APPLY_ONLY | SR_SUBSCR_CTX_REUSE
+ },
+ {
+ .xpath = "/openconfig-interfaces:interfaces/interface/config",
+ .method = XPATH,
+ .datastore = SR_DS_RUNNING,
+ .cb.scb = openconfig_interfaces_interfaces_interface_config_cb,
+ .private_ctx = NULL,
+ .priority = 0,
+ //.opts = SR_SUBSCR_DEFAULT
+ .opts = SR_SUBSCR_CTX_REUSE
+ },
+ {
+ .xpath = "/openconfig-interfaces:interfaces/interface/state",
+ .method = GETITEM,
+ .datastore = SR_DS_RUNNING,
+ .cb.gcb = openconfig_interfaces_interfaces_interface_state_cb,
+ .private_ctx = NULL,
+ .priority = 0,
+ .opts = SR_SUBSCR_CTX_REUSE
+ },
+ {
+ .xpath = "/openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/state",
+ .method = GETITEM,
+ .datastore = SR_DS_RUNNING,
+ .cb.gcb = openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_state_cb,
+ .private_ctx = NULL,
+ .priority = 0,
+ .opts = SR_SUBSCR_CTX_REUSE
+ },
+ {
+ .xpath = "/openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/openconfig-if-ip:ipv4/openconfig-if-ip:addresses/openconfig-if-ip:address/openconfig-if-ip:config",
+ .method = XPATH,
+ .datastore = SR_DS_RUNNING,
+ .cb.scb = openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_config_cb,
+ .private_ctx = NULL,
+ .priority = 0,
+ //.opts = SR_SUBSCR_DEFAULT
+ .opts = SR_SUBSCR_CTX_REUSE
+ },
+ {
+ .xpath = "/openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/openconfig-if-ip:ipv4/openconfig-if-ip:addresses/openconfig-if-ip:address/openconfig-if-ip:state",
+ .method = GETITEM,
+ .datastore = SR_DS_RUNNING,
+ .cb.gcb = openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_state_cb,
+ .private_ctx = NULL,
+ .priority = 0,
+ .opts = SR_SUBSCR_CTX_REUSE
+ }
+};