return NULL;
}
- return parent->child;
+ return lys_getnext(NULL, parent, NULL, 0);
}
-KR_EXPORT const struct lys_node* schema_child_next(const struct lys_node* prev_child) {
+KR_EXPORT const struct lys_node* schema_child_next(const struct lys_node* parent, const struct lys_node* prev_child) {
assert(prev_child != NULL);
- return prev_child->next;
+ assert(parent != NULL);
+
+ return lys_getnext(prev_child, parent, NULL, 0);
}
KR_EXPORT const char* schema_get_name(const struct lys_node* node) {
/** Given a libyang schema node, returns it's first child (or NULL if there aren't any) */
KR_EXPORT const struct lys_node* schema_child_first(const struct lys_node* parent);
/** Given a libyang schema node, return next sibling or NULL if there isn't any */
-KR_EXPORT const struct lys_node* schema_child_next(const struct lys_node* prev_child);
+KR_EXPORT const struct lys_node* schema_child_next(const struct lys_node* parent, const struct lys_node* prev_child);
/** Given a libyang schema node, return it's name */
KR_EXPORT const char* schema_get_name(const struct lys_node* node);
/** Get schema root */
/** Given a libyang schema node, returns it's first child */
const struct lys_node* schema_child_first(const struct lys_node* parent);
/** Given a libyang schema node, return next sibling or NULL if there isn't any */
- const struct lys_node* schema_child_next(const struct lys_node* prev_child);
- /** Given a libyang schema node, return it's name */
+ const struct lys_node* schema_child_next(const struct lys_node* parent, const struct lys_node* prev_child); /** Given a libyang schema node, return it's name */
const char* schema_get_name(const struct lys_node* node);
/** Get schema root */
const struct lys_node* schema_root();
while child ~= nil do
local nm = ffi.string(clib().schema_get_name(child))
lookup[nm] = child
- child = clib().schema_child_next(child)
+ child = clib().schema_child_next(schema_node, child)
end
return lookup
-- return configured container bind node
return ContainerBindNode(
"listen-interfaces",
- { ["ip-address"] = "string", ["name"] = "string", ["port"] = "uint16", ["kind"] = "string" },
+ { ["ip-address"] = "string", ["id"] = "string", ["port"] = "uint16", ["kind"] = "string" },
+ -- { ["ip-address"] = "string", ["name"] = "string", ["port"] = "uint16" },
get_arg_func,
function(v)
net.listen(v["ip-address"], v["port"], { kind = v["kind"] })
+ -- net.listen(v["ip-address"], v["port"])
end
)
end
return ContainerBindNode(
"tls",
{ ["cert"] = "string", ["cert-key"] = "string" },
- nil,
+ function()
+ local t = net.tls()
+ return {
+ ["cert"] = t[1],
+ ["cert-key"] = t[2],
+ }
+ end,
function(vals) net.tls(vals["cert"], vals["cert-key"]) end
)
end
local function get_listen_interfaces()
-- the data structure from `net.list()` has to be transformed to be understood
-- by ContainerBindNode
+ local id = -1;
+
local function transform(arg)
+ id = id + 1
return {
["ip-address"] = arg['transport']['ip'],
- ["name"] = arg["kind"] .. "://" .. arg['transport']['ip'] .. tostring(arg['transport']['port']),
+ ["id"] = tostring(id),
["port"] = arg['transport']['port'],
["kind"] = arg['kind'],
}