diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-08-07 11:09:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-07 11:09:25 -0400 |
| commit | 690e4f9dff41b78e630efee96eabb11864804452 (patch) | |
| tree | 7f0d55d518848b4e9cb61cd765221b865c8c2548 /lib/yang.c | |
| parent | 940bb755fc1e406665b17d4d8a4fac21149d7744 (diff) | |
| parent | 65de8bc8d0d949f0ea12a84dba9b7963ac1a74f6 (diff) | |
Merge pull request #6517 from vishaldhingra/submodule
lib: Add support to load submodules in embedded modules framework
Diffstat (limited to 'lib/yang.c')
| -rw-r--r-- | lib/yang.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/yang.c b/lib/yang.c index db99c0339e..6ab9492d52 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -53,22 +53,30 @@ static const char *yang_module_imp_clb(const char *mod_name, { struct yang_module_embed *e; - if (submod_name || submod_rev) - return NULL; - for (e = embeds; e; e = e->next) { - if (strcmp(e->mod_name, mod_name)) - continue; - if (mod_rev && strcmp(e->mod_rev, mod_rev)) - continue; + if (e->sub_mod_name && submod_name) { + if (strcmp(e->sub_mod_name, submod_name)) + continue; + + if (submod_rev && strcmp(e->sub_mod_rev, submod_rev)) + continue; + } else { + if (strcmp(e->mod_name, mod_name)) + continue; + + if (mod_rev && strcmp(e->mod_rev, mod_rev)) + continue; + } *format = e->format; return e->data; } - flog_warn(EC_LIB_YANG_MODULE_LOAD, - "YANG model \"%s@%s\" not embedded, trying external file", - mod_name, mod_rev ? mod_rev : "*"); + flog_warn( + EC_LIB_YANG_MODULE_LOAD, + "YANG model \"%s@%s\" \"%s@%s\"not embedded, trying external file", + mod_name, mod_rev ? mod_rev : "*", + submod_name ? submod_name : "*", submod_rev ? submod_rev : "*"); return NULL; } |
