Alignment to libyang prototype changes and security fixes
[ric-plt/o1.git] / agent / pkg / nbi / helper.c
index b06e732..1ad907b 100755 (executable)
@@ -37,6 +37,7 @@ char * yang_data_sr2json(sr_session_ctx_t *session, const char *module_name, sr_
     sr_val_t *val = NULL;
     char *json_str = NULL;
     struct lyd_node *root = NULL;
+    struct lyd_node *node = NULL;
 
     rc = sr_get_changes_iter(session, "//." , &it);
     if (rc != SR_ERR_OK) {
@@ -48,9 +49,9 @@ char * yang_data_sr2json(sr_session_ctx_t *session, const char *module_name, sr_
         val = oper == SR_OP_CREATED ? new_value : old_value;
         char *leaf = sr_val_to_str(val);
         if (root) {
-            lyd_new_path(root, NULL, val->xpath, (void *) leaf, 0, 1);
+            lyd_new_path(root, NULL, val->xpath, (void *) leaf, LYD_NEW_PATH_UPDATE, &node);
         } else {
-            root = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), val->xpath, (void *) leaf, 0, 1);
+            lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), val->xpath, (void *) leaf, LYD_NEW_PATH_UPDATE, &root);
         }
 
         sr_free_val(old_value);
@@ -61,7 +62,7 @@ char * yang_data_sr2json(sr_session_ctx_t *session, const char *module_name, sr_
     }
 
     if (root) {
-        lyd_print_mem(&json_str, root, LYD_JSON, LYP_WITHSIBLINGS | LYP_FORMAT);
+        lyd_print_mem(&json_str, root, LYD_JSON, LYD_PRINT_WITHSIBLINGS);
         printf("\n%s\n", json_str);
     }
 
@@ -85,7 +86,7 @@ char * get_data_json(sr_session_ctx_t *session, const char *module_name) {
     }
 
     if (data) {
-        lyd_print_mem(&json_str, data, LYD_JSON, LYP_WITHSIBLINGS | LYP_FORMAT);
+        lyd_print_mem(&json_str, data, LYD_JSON, LYD_PRINT_WITHSIBLINGS);
     }
     return json_str;
 }
@@ -100,10 +101,11 @@ int gnb_status_cb(sr_session_ctx_t *session, const char *module_name, const char
 
 void create_new_path(sr_session_ctx_t *session, char **parent, char *key, char *value) {
     struct lyd_node **p = (struct lyd_node **)parent;
+    struct lyd_node *node;
 
     if (*parent == NULL) {
-        *p = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), key, value, 0, 0);
+        lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), key, value, LYD_NEW_PATH_UPDATE, &node);
     } else {
-        lyd_new_path(*p, sr_get_context(sr_session_get_connection(session)), key, value, 0, 0);
+        lyd_new_path(*p, sr_get_context(sr_session_get_connection(session)), key, value, LYD_NEW_PATH_UPDATE, &node);
     }
-}
\ No newline at end of file
+}