Created
January 15, 2021 19:18
-
-
Save rwestphal/51593172a1a7e4dd702022628796492e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <err.h> | |
#include <libyang/libyang.h> | |
//#define YANG_SEARCH_PATH "/usr/local/share/yang/" | |
#define YANG_SEARCH_PATH "/mnt/renato/git/rust/yang2-rs/assets/yang/" | |
int main(int argc, char **argv) | |
{ | |
struct ly_ctx *ly_ctx; | |
const struct lys_module *module; | |
const struct lysc_node *snode; | |
const char *path = | |
"/ietf-routing:routing/control-plane-protocols/control-plane-protocol/ietf-isis:isis/preference/internal"; | |
/* initialization */ | |
if (ly_ctx_new(YANG_SEARCH_PATH, 0, &ly_ctx) != LY_SUCCESS) | |
errx(1, "ly_ctx_new(): %s", ly_errmsg(ly_ctx)); | |
module = ly_ctx_load_module(ly_ctx, "ietf-isis", NULL, NULL); | |
if (module == NULL) | |
errx(1, "ly_ctx_load_module: %s", ly_errmsg(ly_ctx)); | |
snode = lys_find_path(ly_ctx, NULL, path, 0); | |
if (!snode) | |
errx(1, "lys_find_path: %s\n", ly_errmsg(ly_ctx)); | |
while (snode) { | |
char buf[BUFSIZ]; | |
memset(buf, 0, sizeof(buf)); | |
lysc_path(snode, LYSC_PATH_LOG, buf, sizeof(buf)); | |
printf("%s: %u\n", buf, snode->flags & LYS_CONFIG_W); | |
snode = lysc_node_parent_full(snode); | |
} | |
/* cleanup */ | |
ly_ctx_destroy(ly_ctx, NULL); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment