From: Emanuele Di Pascale Date: Wed, 17 Oct 2018 13:10:47 +0000 (+0200) Subject: lib: fix fetching enum values for derived types X-Git-Tag: frr-7.1-dev~228^2~5 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=42067575720e31d36f39f42bb51f321a187c54c1;p=matthieu%2Ffrr.git lib: fix fetching enum values for derived types Signed-off-by: Emanuele Di Pascale --- 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];