diff options
| author | Emanuele Di Pascale <emanuele@voltanet.io> | 2018-10-17 15:10:47 +0200 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2018-10-27 16:16:12 -0200 |
| commit | 42067575720e31d36f39f42bb51f321a187c54c1 (patch) | |
| tree | e019051122b0627a786dba7b04aa69cef4e061d9 /lib/yang_wrappers.c | |
| parent | fc5a4adc5de35db56032888f2aa978bcab444ddc (diff) | |
lib: fix fetching enum values for derived types
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
Diffstat (limited to 'lib/yang_wrappers.c')
| -rw-r--r-- | lib/yang_wrappers.c | 8 |
1 files changed, 7 insertions, 1 deletions
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]; |
