diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-01-28 10:38:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-28 10:38:56 -0500 |
| commit | b539a22f5a58016c9aee82a835a37c31382b50ba (patch) | |
| tree | d876bdf26695edb6a29d6950f000448c1e59cca9 /lib/yang.c | |
| parent | 170599f6e0d2086a5450fd38b7dca09941f0309a (diff) | |
| parent | 02a0df1f22c5cef8e4d3392d56e7db82da0d49cf (diff) | |
Merge pull request #3664 from opensourcerouting/yang-embed-extensions
yang: embed extensions
Diffstat (limited to 'lib/yang.c')
| -rw-r--r-- | lib/yang.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/yang.c b/lib/yang.c index 71b41c35d8..f62a8163f9 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -26,6 +26,8 @@ #include "yang_translator.h" #include "northbound.h" +#include <libyang/user_types.h> + DEFINE_MTYPE(LIB, YANG_MODULE, "YANG module") DEFINE_MTYPE(LIB, YANG_DATA, "YANG data structure") @@ -639,8 +641,18 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path) zlog(priority, "libyang: %s", msg); } +#if CONFDATE > 20190401 +CPP_NOTICE("lib/yang: time to remove non-LIBYANG_EXT_BUILTIN support") +#endif + +#ifdef LIBYANG_EXT_BUILTIN +extern struct lytype_plugin_list frr_user_types[]; +#endif + void yang_init(void) { +#ifndef LIBYANG_EXT_BUILTIN +CPP_NOTICE("lib/yang: deprecated libyang <0.16.74 extension loading in use!") static char ly_plugin_dir[PATH_MAX]; const char *const *ly_loaded_plugins; const char *ly_plugin; @@ -650,11 +662,20 @@ void yang_init(void) snprintf(ly_plugin_dir, sizeof(ly_plugin_dir), "%s=%s", "LIBYANG_USER_TYPES_PLUGINS_DIR", LIBYANG_PLUGINS_PATH); putenv(ly_plugin_dir); +#endif /* Initialize libyang global parameters that affect all containers. */ ly_set_log_clb(ly_log_cb, 1); ly_log_options(LY_LOLOG | LY_LOSTORE); +#ifdef LIBYANG_EXT_BUILTIN + if (ly_register_types(frr_user_types, "frr_user_types")) { + flog_err(EC_LIB_LIBYANG_PLUGIN_LOAD, + "ly_register_types() failed"); + exit(1); + } +#endif + /* Initialize libyang container for native models. */ ly_native_ctx = ly_ctx_new(YANG_MODELS_PATH, LY_CTX_DISABLE_SEARCHDIR_CWD); @@ -665,6 +686,7 @@ void yang_init(void) ly_ctx_set_module_imp_clb(ly_native_ctx, yang_module_imp_clb, NULL); ly_ctx_set_priv_dup_clb(ly_native_ctx, ly_dup_cb); +#ifndef LIBYANG_EXT_BUILTIN /* Detect if the required libyang plugin(s) were loaded successfully. */ ly_loaded_plugins = ly_get_loaded_plugins(); for (size_t i = 0; (ly_plugin = ly_loaded_plugins[i]); i++) { @@ -678,6 +700,7 @@ void yang_init(void) "%s: failed to load frr_user_types.so", __func__); exit(1); } +#endif yang_translator_init(); } |
