]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/northbound_sysrepo.c
Merge pull request #10583 from donaldsharp/pim_upstream_timers
[mirror_frr.git] / lib / northbound_sysrepo.c
index 63fd40f8d3a63763561f71136908d570f2368a22..0158d8ea0a001a7af695459c15532d155987f55d 100644 (file)
@@ -41,17 +41,17 @@ static sr_session_ctx_t *session;
 static sr_conn_ctx_t *connection;
 static struct nb_transaction *transaction;
 
-static int frr_sr_read_cb(struct thread *thread);
+static void frr_sr_read_cb(struct thread *thread);
 static int frr_sr_finish(void);
 
 /* Convert FRR YANG data value to sysrepo YANG data value. */
 static int yang_data_frr2sr(struct yang_data *frr_data, sr_val_t *sr_data)
 {
        struct nb_node *nb_node;
-       const struct lys_node *snode;
-       struct lys_node_container *scontainer;
-       struct lys_node_leaf *sleaf;
-       struct lys_node_leaflist *sleaflist;
+       const struct lysc_node *snode;
+       struct lysc_node_container *scontainer;
+       struct lysc_node_leaf *sleaf;
+       struct lysc_node_leaflist *sleaflist;
        LY_DATA_TYPE type;
 
        sr_val_set_xpath(sr_data, frr_data->xpath);
@@ -67,8 +67,8 @@ static int yang_data_frr2sr(struct yang_data *frr_data, sr_val_t *sr_data)
        snode = nb_node->snode;
        switch (snode->nodetype) {
        case LYS_CONTAINER:
-               scontainer = (struct lys_node_container *)snode;
-               if (!scontainer->presence)
+               scontainer = (struct lysc_node_container *)snode;
+               if (!CHECK_FLAG(scontainer->flags, LYS_PRESENCE))
                        return -1;
                sr_data->type = SR_CONTAINER_PRESENCE_T;
                return 0;
@@ -76,11 +76,11 @@ static int yang_data_frr2sr(struct yang_data *frr_data, sr_val_t *sr_data)
                sr_data->type = SR_LIST_T;
                return 0;
        case LYS_LEAF:
-               sleaf = (struct lys_node_leaf *)snode;
+               sleaf = (struct lysc_node_leaf *)snode;
                type = sleaf->type.base;
                break;
        case LYS_LEAFLIST:
-               sleaflist = (struct lys_node_leaflist *)snode;
+               sleaflist = (struct lysc_node_leaflist *)snode;
                type = sleaflist->type.base;
                break;
        default:
@@ -359,7 +359,7 @@ static int frr_sr_config_change_cb(sr_session_ctx_t *session,
        }
 }
 
-static int frr_sr_state_data_iter_cb(const struct lys_node *snode,
+static int frr_sr_state_data_iter_cb(const struct lysc_node *snode,
                                     struct yang_translator *translator,
                                     struct yang_data *data, void *arg)
 {
@@ -526,23 +526,20 @@ static int frr_sr_notification_send(const char *xpath, struct list *arguments)
        return NB_OK;
 }
 
-static int frr_sr_read_cb(struct thread *thread)
+static void frr_sr_read_cb(struct thread *thread)
 {
-       sr_subscription_ctx_t *sr_subscription = THREAD_ARG(thread);
+       struct yang_module *module = THREAD_ARG(thread);
        int fd = THREAD_FD(thread);
        int ret;
 
-       ret = sr_process_events(sr_subscription, session, NULL);
+       ret = sr_process_events(module->sr_subscription, session, NULL);
        if (ret != SR_ERR_OK) {
                flog_err(EC_LIB_LIBSYSREPO, "%s: sr_fd_event_process(): %s",
                         __func__, sr_strerror(ret));
-               return -1;
+               return;
        }
 
-       thread = NULL;
-       thread_add_read(master, frr_sr_read_cb, sr_subscription, fd, &thread);
-
-       return 0;
+       thread_add_read(master, frr_sr_read_cb, module, fd, &module->sr_thread);
 }
 
 static void frr_sr_subscribe_config(struct yang_module *module)
@@ -562,7 +559,7 @@ static void frr_sr_subscribe_config(struct yang_module *module)
                         sr_strerror(ret));
 }
 
-static int frr_sr_subscribe_state(const struct lys_node *snode, void *arg)
+static int frr_sr_subscribe_state(const struct lysc_node *snode, void *arg)
 {
        struct yang_module *module = arg;
        struct nb_node *nb_node;
@@ -591,7 +588,7 @@ static int frr_sr_subscribe_state(const struct lys_node *snode, void *arg)
        return YANG_ITER_CONTINUE;
 }
 
-static int frr_sr_subscribe_rpc(const struct lys_node *snode, void *arg)
+static int frr_sr_subscribe_rpc(const struct lysc_node *snode, void *arg)
 {
        struct yang_module *module = arg;
        struct nb_node *nb_node;
@@ -703,7 +700,7 @@ static int frr_sr_init(void)
                                 sr_strerror(ret));
                        goto cleanup;
                }
-               thread_add_read(master, frr_sr_read_cb, module->sr_subscription,
+               thread_add_read(master, frr_sr_read_cb, module,
                                event_pipe, &module->sr_thread);
        }