]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: fix fetching enum values for derived types
authorEmanuele Di Pascale <emanuele@voltanet.io>
Wed, 17 Oct 2018 13:10:47 +0000 (15:10 +0200)
committerRenato Westphal <renato@opensourcerouting.org>
Sat, 27 Oct 2018 18:16:12 +0000 (16:16 -0200)
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
lib/yang_wrappers.c

index 60a7456aa3808a378aefec22840236aaa02f3f9a..da9d37669bf91c40eeefeb0c35aa773d3b92b459 100644 (file)
@@ -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];