Skip to content

Commit 3bacfb4

Browse files
committed
lib UPDATE remove binary internal modules
1 parent 0e01d70 commit 3bacfb4

14 files changed

Lines changed: 53 additions & 3735 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ set(LIBNETCONF2_SOVERSION_FULL ${LIBNETCONF2_MAJOR_SOVERSION}.${LIBNETCONF2_MINO
7171
set(LIBNETCONF2_SOVERSION ${LIBNETCONF2_MAJOR_SOVERSION})
7272

7373
# Version of libyang library that this project depends on
74-
set(LIBYANG_DEP_VERSION 5.1.1)
75-
set(LIBYANG_DEP_SOVERSION 5.1.1)
74+
set(LIBYANG_DEP_VERSION 5.6.0)
75+
set(LIBYANG_DEP_SOVERSION 5.3.4)
7676
set(LIBYANG_DEP_SOVERSION_MAJOR 5)
7777

7878
# global C flags

modules/ietf_netconf@2013-09-29_yang.h

Lines changed: 0 additions & 2251 deletions
This file was deleted.

modules/ietf_netconf_monitoring@2010-10-04_yang.h

Lines changed: 0 additions & 1454 deletions
This file was deleted.

src/server_config.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,16 @@ nc_server_config_load_modules(struct ly_ctx **ctx)
486486
int i, new_ctx = 0;
487487

488488
if (!*ctx) {
489-
if (ly_ctx_new(NC_SERVER_SEARCH_DIR, 0, ctx)) {
490-
ERR(NULL, "Couldn't create new libyang context.\n");
489+
if (ly_ctx_new(ly_yang_module_dir(), 0, ctx)) {
490+
ERR(NULL, "Failed to create new libyang context.");
491491
goto error;
492492
}
493493
new_ctx = 1;
494+
495+
if (ly_ctx_set_searchdir(*ctx, nc_yang_module_dir())) {
496+
ERR(NULL, "Failed to set new searchdir for a context.");
497+
goto error;
498+
}
494499
}
495500

496501
/* all features */
@@ -555,7 +560,7 @@ nc_server_config_load_modules(struct ly_ctx **ctx)
555560

556561
for (i = 0; module_names[i]; i++) {
557562
if (!ly_ctx_load_module(*ctx, module_names[i], NULL, module_features[i])) {
558-
ERR(NULL, "Loading module \"%s\" failed.\n", module_names[i]);
563+
ERR(NULL, "Loading module \"%s\" failed.", module_names[i]);
559564
goto error;
560565
}
561566
}

src/session.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,3 +1948,9 @@ nc_session_tls_crl_from_cert_ext_fetch(void *leaf_cert, void *cert_store, void *
19481948
}
19491949

19501950
#endif
1951+
1952+
API const char *
1953+
nc_yang_module_dir(void)
1954+
{
1955+
return NC_SERVER_SEARCH_DIR;
1956+
}

src/session.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ int nc_session_is_callhome(const struct nc_session *session);
249249
*/
250250
void nc_session_free(struct nc_session *session, void (*data_free)(void *));
251251

252+
/**
253+
* @brief Get the directory with internal libnetconf2 YANG modules.
254+
*
255+
* @return YANG module dir.
256+
*/
257+
const char *nc_yang_module_dir(void);
258+
252259
#ifdef __cplusplus
253260
}
254261
#endif

src/session_client.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@
5252
#include "session_client_ch.h"
5353
#include "session_p.h"
5454

55-
#include "../modules/ietf_netconf@2013-09-29_yang.h"
56-
#include "../modules/ietf_netconf_monitoring@2010-10-04_yang.h"
57-
5855
static const char *ncds2str[] = {NULL, "config", "url", "running", "startup", "candidate"};
5956

6057
#ifdef NC_ENABLED_SSH_TLS
@@ -241,7 +238,7 @@ nc_client_session_new_ctx(struct nc_session *session, struct ly_ctx *ctx)
241238
{
242239
/* assign context (dicionary needed for handshake) */
243240
if (!ctx) {
244-
if (ly_ctx_new(NULL, LY_CTX_NO_YANGLIBRARY, &ctx)) {
241+
if (ly_ctx_new(ly_yang_module_dir(), LY_CTX_NO_YANGLIBRARY, &ctx)) {
245242
return EXIT_FAILURE;
246243
}
247244

@@ -1179,7 +1176,6 @@ nc_ctx_fill_ietf_netconf(struct nc_session *session, struct module_info *modules
11791176
{
11801177
uint32_t u;
11811178
const char **features = NULL;
1182-
struct ly_in *in;
11831179
struct lys_module *ietfnc;
11841180

11851181
/* find supported features (capabilities) in ietf-netconf */
@@ -1202,11 +1198,6 @@ nc_ctx_fill_ietf_netconf(struct nc_session *session, struct module_info *modules
12021198
} else {
12031199
/* load the module */
12041200
nc_ctx_load_module(session, "ietf-netconf", NULL, features, modules, user_clb, user_data, has_get_schema, &ietfnc);
1205-
if (!ietfnc) {
1206-
ly_in_new_memory(ietf_netconf_2013_09_29_yang, &in);
1207-
lys_parse(session->ctx, in, LYS_IN_YANG, features, &ietfnc);
1208-
ly_in_free(in, 0);
1209-
}
12101201
}
12111202
if (!ietfnc) {
12121203
ERR(session, "Loading base NETCONF module failed.");
@@ -1265,7 +1256,8 @@ nc_ctx_check_and_fill(struct nc_session *session)
12651256
}
12661257

12671258
/* get-schema is supported, load local ietf-netconf-monitoring so we can create <get-schema> RPCs */
1268-
if (get_schema_support && lys_parse_mem(session->ctx, ietf_netconf_monitoring_2010_10_04_yang, LYS_IN_YANG, NULL)) {
1259+
if (get_schema_support &&
1260+
nc_ctx_load_module(session, "ietf-netconf-monitoring", NULL, NULL, server_modules, old_clb, old_data, 0, &mod)) {
12691261
WRN(session, "Loading NETCONF monitoring module failed, cannot use <get-schema>.");
12701262
get_schema_support = 0;
12711263
}

src/session_server.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,30 @@ nc_server_init_ctx(struct ly_ctx **ctx)
165165

166166
if (!*ctx) {
167167
/* context not given, create a new one */
168-
if (ly_ctx_new(NC_SERVER_SEARCH_DIR, 0, ctx)) {
169-
ERR(NULL, "Couldn't create new libyang context.\n");
168+
if (ly_ctx_new(ly_yang_module_dir(), 0, ctx)) {
169+
ERR(NULL, "Failed to create a new libyang context.");
170170
ret = 1;
171171
goto cleanup;
172172
}
173173
new_ctx = 1;
174+
175+
if (ly_ctx_set_searchdir(*ctx, nc_yang_module_dir())) {
176+
ERR(NULL, "Failed to set searchdir for a context.");
177+
ret = 1;
178+
goto cleanup;
179+
}
174180
}
175181

176182
if (new_ctx) {
177183
/* new context created, implement both modules */
178184
if (!ly_ctx_load_module(*ctx, "ietf-netconf", NULL, ietf_netconf_features)) {
179-
ERR(NULL, "Loading module \"ietf-netconf\" failed.\n");
185+
ERR(NULL, "Loading module \"ietf-netconf\" failed.");
180186
ret = 1;
181187
goto cleanup;
182188
}
183189

184190
if (!ly_ctx_load_module(*ctx, "ietf-netconf-monitoring", NULL, ietf_netconf_monitoring_features)) {
185-
ERR(NULL, "Loading module \"ietf-netconf-monitoring\" failed.\n");
191+
ERR(NULL, "Loading module \"ietf-netconf-monitoring\" failed.");
186192
ret = 1;
187193
goto cleanup;
188194
}
@@ -197,7 +203,7 @@ nc_server_init_ctx(struct ly_ctx **ctx)
197203
if (lys_feature_value(module, ietf_netconf_features[i])) {
198204
/* feature not found, enable all of them */
199205
if (!ly_ctx_load_module(*ctx, "ietf-netconf", NULL, ietf_netconf_features)) {
200-
ERR(NULL, "Loading module \"ietf-netconf\" failed.\n");
206+
ERR(NULL, "Loading module \"ietf-netconf\" failed.");
201207
ret = 1;
202208
goto cleanup;
203209
}
@@ -208,7 +214,7 @@ nc_server_init_ctx(struct ly_ctx **ctx)
208214
} else {
209215
/* ietf-netconf module not found, add it */
210216
if (!ly_ctx_load_module(*ctx, "ietf-netconf", NULL, ietf_netconf_features)) {
211-
ERR(NULL, "Loading module \"ietf-netconf\" failed.\n");
217+
ERR(NULL, "Loading module \"ietf-netconf\" failed.");
212218
ret = 1;
213219
goto cleanup;
214220
}
@@ -218,7 +224,7 @@ nc_server_init_ctx(struct ly_ctx **ctx)
218224
if (!module) {
219225
/* ietf-netconf-monitoring module not found, add it */
220226
if (!ly_ctx_load_module(*ctx, "ietf-netconf-monitoring", NULL, ietf_netconf_monitoring_features)) {
221-
ERR(NULL, "Loading module \"ietf-netconf-monitoring\" failed.\n");
227+
ERR(NULL, "Loading module \"ietf-netconf-monitoring\" failed.");
222228
ret = 1;
223229
goto cleanup;
224230
}

tests/ln2_test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,12 @@ ln2_glob_test_setup(struct ln2_test_ctx **test_ctx)
153153
}
154154

155155
/* create libyang context */
156-
ret = ly_ctx_new(MODULES_DIR, 0, &(*test_ctx)->ctx);
156+
ret = ly_ctx_new(ly_yang_module_dir(), 0, &(*test_ctx)->ctx);
157157
if (ret) {
158158
SETUP_FAIL_LOG;
159159
goto cleanup;
160160
}
161+
ly_ctx_set_searchdir((*test_ctx)->ctx, MODULES_DIR);
161162

162163
/* load default yang modules */
163164
ret = nc_server_init_ctx(&(*test_ctx)->ctx);

tests/test_cert_exp_notif.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,9 @@ init_test_ctx(struct ly_ctx **ctx)
541541
struct lys_module *mod;
542542
const char *ietf_ct_features[] = {"cleartext-passwords", "cleartext-private-keys", "certificate-expiration-notification", NULL};
543543

544-
ret = ly_ctx_new(MODULES_DIR, 0, ctx);
544+
ret = ly_ctx_new(ly_yang_module_dir(), 0, ctx);
545545
assert_int_equal(ret, 0);
546+
ly_ctx_set_searchdir(*ctx, MODULES_DIR);
546547

547548
ret = nc_server_init_ctx(ctx);
548549
assert_int_equal(ret, 0);

0 commit comments

Comments
 (0)