From 42067575720e31d36f39f42bb51f321a187c54c1 Mon Sep 17 00:00:00 2001 From: Emanuele Di Pascale Date: Wed, 17 Oct 2018 15:10:47 +0200 Subject: [PATCH] lib: fix fetching enum values for derived types Signed-off-by: Emanuele Di Pascale --- lib/yang_wrappers.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c index 60a7456aa3..da9d37669b 100644 --- a/lib/yang_wrappers.c +++ b/lib/yang_wrappers.c @@ -201,6 +201,7 @@ struct yang_data *yang_data_new_enum(const char *xpath, int value) { const struct lys_node *snode; const struct lys_node_leaf *sleaf; + const struct lys_type *type; const struct lys_type_info_enums *enums; snode = ly_ctx_get_node(ly_native_ctx, NULL, xpath, 0); @@ -212,7 +213,12 @@ struct yang_data *yang_data_new_enum(const char *xpath, int value) } sleaf = (const struct lys_node_leaf *)snode; - enums = &sleaf->type.info.enums; + type = &sleaf->type; + enums = &type->info.enums; + while (enums->count == 0 && type->der) { + type = &type->der->type; + enums = &type->info.enums; + } for (unsigned int i = 0; i < enums->count; i++) { const struct lys_type_enum *enm = &enums->enm[i]; -- 2.39.5