data handling UPDATE reflect changes in libyang's handling of default values
reflects changes in libyang 0.10.86
diff --git a/src/io.c b/src/io.c
index e6cc293..fd21951 100644
--- a/src/io.c
+++ b/src/io.c
@@ -923,6 +923,7 @@
struct wclb_arg arg;
const char **capabilities;
uint32_t *sid = NULL, i;
+ int wd;
assert(session);
@@ -974,8 +975,24 @@
nc_write_clb((void *)&arg, "<ok/>", 5, 0);
break;
case NC_RPL_DATA:
- assert(((struct nc_reply_data *)reply)->data->schema->nodetype == LYS_RPC);
- lyd_print_clb(nc_write_xmlclb, (void *)&arg, ((struct nc_reply_data *)reply)->data->child, LYD_XML, LYP_WITHSIBLINGS);
+ assert(((struct nc_server_reply_data *)reply)->data->schema->nodetype == LYS_RPC);
+ switch(((struct nc_server_reply_data *)reply)->wd) {
+ case NC_WD_UNKNOWN:
+ case NC_WD_EXPLICIT:
+ wd = LYP_WD_EXPLICIT;
+ break;
+ case NC_WD_TRIM:
+ wd = LYP_WD_TRIM;
+ break;
+ case NC_WD_ALL:
+ wd = LYP_WD_ALL;
+ break;
+ case NC_WD_ALL_TAG:
+ wd = LYP_WD_ALL_TAG;
+ break;
+ }
+ lyd_print_clb(nc_write_xmlclb, (void *)&arg, ((struct nc_reply_data *)reply)->data->child, LYD_XML,
+ LYP_WITHSIBLINGS | wd);
break;
case NC_RPL_ERROR:
error_rpl = (struct nc_server_reply_error *)reply;
diff --git a/src/messages_p.h b/src/messages_p.h
index 66e0546..ca171f7 100644
--- a/src/messages_p.h
+++ b/src/messages_p.h
@@ -53,6 +53,7 @@
NC_RPL type;
struct lyd_node *data;
char free;
+ NC_WD_MODE wd;
};
struct nc_server_reply_error {
diff --git a/src/messages_server.c b/src/messages_server.c
index f8160f6..20e805d 100644
--- a/src/messages_server.c
+++ b/src/messages_server.c
@@ -40,7 +40,7 @@
}
API struct nc_server_reply *
-nc_server_reply_data(struct lyd_node *data, NC_PARAMTYPE paramtype)
+nc_server_reply_data(struct lyd_node *data, NC_WD_MODE wd, NC_PARAMTYPE paramtype)
{
struct nc_server_reply_data *ret;
@@ -56,6 +56,7 @@
}
ret->type = NC_RPL_DATA;
+ ret->wd = wd;
if (paramtype == NC_PARAMTYPE_DUP_AND_FREE) {
ret->data = lyd_dup(data, 1);
} else {
diff --git a/src/messages_server.h b/src/messages_server.h
index f6426cf..733fe5c 100644
--- a/src/messages_server.h
+++ b/src/messages_server.h
@@ -78,10 +78,11 @@
*
* @param[in] data Reply data tree. This tree must be valid according to
* the RPC output of the RPC this is a reply to.
+ * @param[in] wd with-default mode if applicable
* @param[in] paramtype Determines how the \p data parameter is treated.
* @return rpc-reply object, NULL on error.
*/
-struct nc_server_reply *nc_server_reply_data(struct lyd_node *data, NC_PARAMTYPE paramtype);
+struct nc_server_reply *nc_server_reply_data(struct lyd_node *data, NC_WD_MODE wd, NC_PARAMTYPE paramtype);
/**
* @brief Create an ERROR rpc-reply object.
diff --git a/src/netconf.h b/src/netconf.h
index 37212f8..d99d01f 100644
--- a/src/netconf.h
+++ b/src/netconf.h
@@ -84,10 +84,10 @@
*/
typedef enum NC_WITHDEFAULTS_MODE {
NC_WD_UNKNOWN = 0, /**< invalid mode */
- NC_WD_ALL = 0x01, /**< report-all mode */
- NC_WD_ALL_TAG = 0x02, /**< report-all-tagged mode */
- NC_WD_TRIM = 0x04, /**< trim mode */
- NC_WD_EXPLICIT = 0x08 /**< explicit mode */
+ NC_WD_ALL, /**< report-all mode */
+ NC_WD_ALL_TAG, /**< report-all-tagged mode */
+ NC_WD_TRIM, /**< trim mode */
+ NC_WD_EXPLICIT /**< explicit mode */
} NC_WD_MODE;
/**
diff --git a/src/session_server.c b/src/session_server.c
index 5a93800..be33625 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -346,7 +346,7 @@
return NULL;
}
- return nc_server_reply_data(data, NC_PARAMTYPE_FREE);
+ return nc_server_reply_data(data, NC_WD_EXPLICIT, NC_PARAMTYPE_FREE);
}
static struct nc_server_reply *