{"id":26972542,"url":"https://github.com/cesnet/libyang","last_synced_at":"2025-05-15T00:07:21.697Z","repository":{"id":28630877,"uuid":"32149716","full_name":"CESNET/libyang","owner":"CESNET","description":"YANG data modeling language library","archived":false,"fork":false,"pushed_at":"2025-05-07T12:38:11.000Z","size":46258,"stargazers_count":385,"open_issues_count":26,"forks_count":303,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-05-15T00:07:09.652Z","etag":null,"topics":["c","json","liberouter","modeling-language","modeling-tools","netconf","restconf","xml","yang","yin"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CESNET.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-03-13T10:25:52.000Z","updated_at":"2025-05-12T15:04:22.000Z","dependencies_parsed_at":"2023-10-03T20:15:43.621Z","dependency_job_id":"4c20c8ad-c38c-4d56-80fc-743aac83db04","html_url":"https://github.com/CESNET/libyang","commit_stats":{"total_commits":4630,"total_committers":47,"mean_commits":98.51063829787235,"dds":0.3801295896328294,"last_synced_commit":"4c733412e7173219166be7053940326a92699765"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CESNET%2Flibyang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CESNET%2Flibyang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CESNET%2Flibyang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CESNET%2Flibyang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CESNET","download_url":"https://codeload.github.com/CESNET/libyang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249197,"owners_count":22039029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","json","liberouter","modeling-language","modeling-tools","netconf","restconf","xml","yang","yin"],"created_at":"2025-04-03T09:17:42.927Z","updated_at":"2025-05-15T00:07:16.657Z","avatar_url":"https://github.com/CESNET.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libyang\n\n[![BSD license](https://img.shields.io/badge/License-BSD-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![Build](https://github.com/CESNET/libyang/workflows/libyang%20CI/badge.svg)](https://github.com/CESNET/libyang/actions?query=workflow%3A%22libyang+CI%22)\n[![Docs](https://img.shields.io/badge/docs-link-blue)](https://netopeer.liberouter.org/doc/libyang/)\n[![Coverity Scan Build Status](https://scan.coverity.com/projects/5259/badge.svg)](https://scan.coverity.com/projects/5259)\n[![codecov.io](https://codecov.io/github/CESNET/libyang/coverage.svg?branch=master)](https://codecov.io/github/CESNET/libyang?branch=master)\n[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/libyang.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened\u0026can=1\u0026q=proj:libyang)\n[![Ohloh Project Status](https://www.openhub.net/p/libyang/widgets/project_thin_badge.gif)](https://www.openhub.net/p/libyang)\n\nlibyang is a YANG data modelling language parser and toolkit written (and\nproviding API) in C. The library is used e.g. in [libnetconf2](https://github.com/CESNET/libnetconf2),\n[Netopeer2](https://github.com/CESNET/Netopeer2) or [sysrepo](https://github.com/sysrepo/sysrepo) projects.\n\n## Branches\n\nThe project uses 2 main branches `master` and `devel`. Other branches should not be cloned. In `master` there are files of the\nlast official *release*. Any latest improvements and changes, which were tested at least briefly are found in `devel`. On every\nnew *release*, `devel` is merged into `master`.\n\nThis means that when only stable official releases are to be used, either `master` can be used or specific *releases* downloaded.\nIf all the latest bugfixes should be applied, `devel` branch is the  one to be used. Note that whenever **a new issue is created**\nand it occurs on the `master` branch, the **first response will likely be** to use `devel` before any further provided support.\n\n## Migration from libyang version 1 or older\n\nLook into the documentation and the section `Transition Manual`. That should help with basic migration and the\nability to compile a project. But to actually make use of the new features, it is required to read through\nthe whole documentation and the API.\n\n## Provided Features\n\n* Parsing (and validating) schemas in YANG format.\n* Parsing (and validating) schemas in YIN format.\n* Parsing, validating and printing instance data in XML format.\n* Parsing, validating and printing instance data in JSON format\n  ([RFC 7951](https://tools.ietf.org/html/rfc7951)).\n* Manipulation with the instance data.\n* Support for default values in the instance data ([RFC 6243](https://tools.ietf.org/html/rfc6243)).\n* Support for YANG extensions.\n* Support for YANG Metadata ([RFC 7952](https://tools.ietf.org/html/rfc7952)).\n* Support for YANG Schema Mount ([RFC 8528](https://tools.ietf.org/html/rfc8528)).\n* Support for YANG Structure ([RFC 8791](https://tools.ietf.org/html/rfc8791)).\n* [yanglint](#yanglint) - feature-rich YANG tool.\n\nCurrent implementation covers YANG 1.0 ([RFC 6020](https://tools.ietf.org/html/rfc6020))\nas well as YANG 1.1 ([RFC 7950](https://tools.ietf.org/html/rfc7950)).\n\n## Packages\n\nBinary RPM or DEB packages of the latest release can be built locally using `apkg`, look into `README` in\nthe `distro` directory.\n\n## Requirements\n\n### Unix Build Requirements\n\n* C compiler\n* cmake \u003e= 2.8.12\n* libpcre2 \u003e= 10.21 (including devel package)\n\n#### Optional\n\n* doxygen (for generating documentation)\n* cmocka \u003e= 1.0.1 (for [tests](#Tests))\n* valgrind (for enhanced testing)\n* gcov (for code coverage)\n* lcov (for code coverage)\n* genhtml (for code coverage)\n\n### Unix Runtime Requirements\n\n* libpcre2 \u003e= 10.21\n\n### Windows Build Requirements\n\n* Visual Studio 17 (2022)\n* cmake \u003e= 3.22.0\n* libpcre2 (same considerations as on POSIX)\n* [`pthreads-win32`](https://sourceware.org/pthreads-win32/)\n* [`dirent`](https://github.com/tronkko/dirent)\n* [`dlfcn-win32`](https://github.com/dlfcn-win32/dlfcn-win32)\n* [`getopt-win32`](https://github.com/libimobiledevice-win32/getopt)\n\nThe Windows version [does not support plugins](https://github.com/CESNET/libyang/commit/323c31221645052e13db83f7d0e6e51c3ce9d802), and the `yanglint` works in a [non-interactive mode](https://github.com/CESNET/libyang/commit/2e3f935ed6f4a47e65b31de5aeebcd8877d5a09b) only.\nOn Windows, all YANG date-and-time values are first converted to UTC (if TZ offset was specified), and then returned with \"unspecified timezone\".\n\n## Building\n\n```\n$ mkdir build; cd build\n$ cmake ..\n$ make\n# make install\n```\n\n### Useful CMake Options\n\n#### Changing Compiler\n\nSet `CC` variable:\n\n```\n$ CC=/usr/bin/clang cmake ..\n```\n\n#### Changing Install Path\n\nTo change the prefix where the library, headers and any other files are installed,\nset `CMAKE_INSTALL_PREFIX` variable:\n```\n$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..\n```\n\nDefault prefix is `/usr/local`.\n\n#### Build Modes\n\nThere are two build modes:\n* Release.\n  This generates library for the production use without any debug information.\n* Debug.\n  This generates library with the debug information and disables optimization\n  of the code.\n\nThe `Debug` mode is currently used as the default one. to switch to the\n`Release` mode, enter at the command line:\n```\n$ cmake -D CMAKE_BUILD_TYPE:String=\"Release\" ..\n```\n\n#### Changing Extensions Plugins Directory\n\nAs for YANG extensions, libyang allows loading extension plugins. By default, the\ndirectory to store the plugins is LIBDIR/libyang. To change it, use the following\ncmake option with the value specifying the desired directory:\n\n```\n$ cmake -DPLUGINS_DIR:PATH=`pwd`\"/src/extensions/\" ..\n```\n\nThe directory path can be also changed runtime via environment variable, e.g.:\n\n```\n$ LIBYANG_EXTENSIONS_PLUGINS_DIR=`pwd`/my/relative/path yanglint\n```\n\nNote that plugins are [not available on Windows](https://github.com/CESNET/libyang/commit/323c31221645052e13db83f7d0e6e51c3ce9d802).\n\n#### Optimizations\n\nWhenever the latest revision of a schema is supposed to be loaded (import without specific revision),\nit is performed in the standard way, the first time. By default, every other time when the latest\nrevision of the same schema is needed, the one initially loaded is reused. If you know this can cause\nproblems meaning the latest available revision of a schema can change during operation, you can force\nlibyang to always search for the schema anew by:\n\n```\n$ cmake -DENABLE_LATEST_REVISIONS=OFF ..\n```\n\n### CMake Notes\n\nNote that, with CMake, if you want to change the compiler or its options after\nyou already ran CMake, you need to clear its cache first - the most simple way\nto do it is to remove all content from the 'build' directory.\n\n## Usage\n\nAll libyang functions are available via the main header:\n```\n#include \u003clibyang/libyang.h\u003e\n```\n\nTo compile your program with libyang, it is necessary to link it with libyang using the\nfollowing linker parameters:\n```\n-lyang\n```\n\nNote, that it may be necessary to call `ldconfig(8)` after library installation and if the\nlibrary was installed into a non-standard path, the path to libyang must be specified to the\nlinker. To help with setting all the compiler's options, there is `libyang.pc` file for\n`pkg-config(1)` available in the source tree. The file is installed with the library.\n\nIf you are using `cmake` in you project, it is also possible to use the provided\n`FindLibYANG.cmake` file to detect presence of the libyang library in the system.\n\n## Bindings\n\nThere are no bindings for other languages directly in this project but they are\navailable separately.\n\n* [Python](https://github.com/CESNET/libyang-python/)\n* [C++](https://github.com/CESNET/libyang-cpp/)\n* [Rust](https://github.com/holo-routing/yang2-rs/)\n\n## yanglint\n\nlibyang project includes a feature-rich tool called `yanglint(1)` for validation\nand conversion of the schemas and YANG modeled data. The source codes are\nlocated at [`/tools/lint`](./tools/lint) and can be used to explore how an\napplication is supposed to use the libyang library. `yanglint(1)` binary as\nwell as its man page are installed together with the library itself.\n\nThere is also [README](./tools/lint/examples/README.md) describing some examples of\nusing `yanglint`.\n\n## Tests\n\nlibyang includes several tests built with [cmocka](https://cmocka.org/). The tests\ncan be found in `tests` subdirectory and they are designed for checking library\nfunctionality after code changes. Additional regression tests done with\na corpus of fuzzing inputs that previously caused crashes are done.\nThose are available in `tests/fuzz` and are built automatically with the\ncmocka unit tests.\n\n\nThe tests are by default built in the `Debug` build mode by running\n```\n$ make\n```\n\nIn case of the `Release` mode, the tests are not built by default (it requires\nadditional dependency), but they can be enabled via cmake option:\n```\n$ cmake -DENABLE_TESTS=ON ..\n```\n\nNote that if the necessary [cmocka](https://cmocka.org/) headers are not present\nin the system include paths, tests are not available despite the build mode or\ncmake's options.\n\nTests can be run by the make's `test` target:\n```\n$ make test\n```\n\n### Perf\n\nThere is a performance measurement tool included that prints information about\nthe time required to execute common use-cases of working with YANG instance data.\n\nTo enable this test, use an option and to get representative results, enable Release build type:\n```\n$ cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_PERF_TESTS=ON ..\n```\nand to run the test with seeing its output run:\n```\n$ make\n$ ctest -V -R ly_perf\n```\n\n### Code Coverage\n\nBased on the tests run, it is possible to generate code coverage report. But\nit must be enabled and these commands are needed to generate the report:\n```\n$ cmake -DENABLE_COVERAGE=ON ..\n$ make\n$ make coverage\n```\n\n## Fuzzing\n\nMultiple YANG fuzzing targets and fuzzing instructions are available in the\n`tests/fuzz` directory.\n\nAll of the targets can be fuzzed with LLVM's LibFuzzer and AFL, and new targets\ncan easily be added.\nAsciinema examples which describe the fuzzing setup for both AFL (https://asciinema.org/a/311060)\nand LibFuzzer (https://asciinema.org/a/311035) are available.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesnet%2Flibyang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcesnet%2Flibyang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesnet%2Flibyang/lists"}