mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-31 04:53:01 +02:00
statd: break out parent interface code (cosmetic)
A non functional change to prepare for upcoming patches. Signed-off-by: Richard Alpe <richard@bit42.se>
This commit is contained in:
committed by
Joachim Wiberg
parent
d6152ce6ea
commit
f643b4f9dc
+32
-14
@@ -226,6 +226,34 @@ static int ly_add_ip_link_br(const struct ly_ctx *ctx, struct lyd_node **parent,
|
||||
return SR_ERR_OK;
|
||||
}
|
||||
|
||||
static int ly_add_ip_link_parent(const struct ly_ctx *ctx, struct lyd_node **parent,
|
||||
char *xpath, json_t *j_iface)
|
||||
{
|
||||
json_t *j_val;
|
||||
int err;
|
||||
|
||||
j_val = json_object_get(j_iface, "link");
|
||||
if (!j_val) {
|
||||
/* Interface has no parent */
|
||||
return SR_ERR_OK;
|
||||
}
|
||||
|
||||
if (!json_is_string(j_val)) {
|
||||
ERROR("Expected a JSON string for 'link'");
|
||||
return SR_ERR_SYS;
|
||||
}
|
||||
|
||||
err = lydx_new_path(ctx, parent, xpath,
|
||||
"ietf-if-extensions:parent-interface", "%s",
|
||||
json_string_value(j_val));
|
||||
if (err) {
|
||||
ERROR("Error, adding 'link' to data tree, libyang error %d", err);
|
||||
return SR_ERR_LY;
|
||||
}
|
||||
|
||||
return SR_ERR_OK;
|
||||
}
|
||||
|
||||
static int ly_add_ip_link_data(const struct ly_ctx *ctx, struct lyd_node **parent,
|
||||
char *xpath, json_t *j_iface)
|
||||
{
|
||||
@@ -291,20 +319,10 @@ static int ly_add_ip_link_data(const struct ly_ctx *ctx, struct lyd_node **paren
|
||||
return err;
|
||||
}
|
||||
|
||||
j_val = json_object_get(j_iface, "link");
|
||||
if (j_val) {
|
||||
if (!json_is_string(j_val)) {
|
||||
ERROR("Expected a JSON string for 'link'");
|
||||
return SR_ERR_SYS;
|
||||
}
|
||||
|
||||
err = lydx_new_path(ctx, parent, xpath,
|
||||
"ietf-if-extensions:parent-interface", "%s",
|
||||
json_string_value(j_val));
|
||||
if (err) {
|
||||
ERROR("Error, adding 'link' to data tree, libyang error %d", err);
|
||||
return SR_ERR_LY;
|
||||
}
|
||||
err = ly_add_ip_link_parent(ctx, parent, xpath, j_iface);
|
||||
if (err) {
|
||||
ERROR("Error, adding parent iface to data tree, libyang error %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return SR_ERR_OK;
|
||||
|
||||
Reference in New Issue
Block a user