Skip to content

Commit d178508

Browse files
committed
Merge branch 'devel'
2 parents ae386d7 + dadeaf3 commit d178508

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+35141
-15584
lines changed

CMakeLists.txt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ set(LIBYANG_DESCRIPTION "libyang is YANG data modelling language parser and tool
77

88
# set version
99
set(LIBYANG_MAJOR_VERSION 0)
10-
set(LIBYANG_MINOR_VERSION 11)
11-
set(LIBYANG_MICRO_VERSION 112)
10+
set(LIBYANG_MINOR_VERSION 12)
11+
set(LIBYANG_MICRO_VERSION 113)
1212
set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_MICRO_VERSION})
1313
set(LIBYANG_SOVERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION})
1414
configure_file(${PROJECT_SOURCE_DIR}/src/libyang.h.in ${PROJECT_SOURCE_DIR}/src/libyang.h)
1515

16+
if(PLUGINS_DIR)
17+
set(LIBYANG_EXT_PLUGINS_DIR ${PLUGINS_DIR})
18+
else()
19+
set(LIBYANG_EXT_PLUGINS_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libyang)
20+
endif()
21+
configure_file(${PROJECT_SOURCE_DIR}/src/extensions_config.h.in ${PROJECT_SOURCE_DIR}/src/extensions_config.h)
22+
1623
# include custom Modules
1724
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
1825

@@ -33,9 +40,9 @@ else()
3340
configure_file(${PROJECT_SOURCE_DIR}/src/yang.y.in ${PROJECT_SOURCE_DIR}/src/yang.y)
3441
add_custom_target(bison
3542
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
36-
COMMAND bison -Wno-other -l -o parser_yang_bis.c --defines=parser_yang_bis.h yang.y
43+
COMMAND bison -l -o parser_yang_bis.c --defines=parser_yang_bis.h yang.y
3744
COMMAND flex -8 -L -o parser_yang_lex.c --header-file=parser_yang_lex.h yang.l
38-
COMMAND ${SED_TOOL} -i 's/int yychar\;/int yychar\;\\nchar *s = NULL, *tmp_s = NULL\;\\nstruct lys_include inc\;\\nstruct lys_module *trg = NULL\;\\nstruct lys_node *tpdf_parent = NULL, *data_node = NULL\;\\nvoid *actual = NULL\;\\nstruct lys_node_uses *refine_parent = NULL\;\\nint config_inherit = 0, actual_type = 0\;\\nint64_t cnt_val\;\\nint read_string = read_all\;\\nvoid *yang_type = NULL\;/' parser_yang_bis.c
45+
COMMAND ${SED_TOOL} -i 's/int yychar\;/int yychar\;\\nchar *s = NULL, *tmp_s = NULL, *ext_name = NULL\;\\nstruct lys_module *trg = NULL\;\\nstruct lys_node *tpdf_parent = NULL, *data_node = NULL\;\\nstruct lys_ext_instance_complex *ext_instance = NULL\;\\nint is_ext_instance\;\\nvoid *actual = NULL\;\\nenum yytokentype backup_type, actual_type = MODULE_KEYWORD\;\\nint64_t cnt_val = 0\;\\nint is_value = 0\;\\nvoid *yang_type = NULL\;/' parser_yang_bis.c
3946
)
4047
endif()
4148

@@ -49,7 +56,7 @@ if(NOT CMAKE_BUILD_TYPE)
4956
set(CMAKE_BUILD_TYPE debug)
5057
endif()
5158

52-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fvisibility=hidden")
59+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
5360
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
5461
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
5562

@@ -78,6 +85,7 @@ set(libsrc
7885
src/parser_yang.c
7986
src/tree_schema.c
8087
src/tree_data.c
88+
src/extensions.c
8189
src/printer.c
8290
src/xpath.c
8391
src/printer_yang.c
@@ -102,14 +110,17 @@ set(headers
102110
src/libyang.h
103111
src/tree_schema.h
104112
src/tree_data.h
113+
src/extensions.h
105114
src/xml.h
106115
src/dict.h)
107116

108117
# create static libyang library
109118
if(STATIC)
110119
add_library(yang_static STATIC ${libsrc})
111120
set_target_properties(yang_static PROPERTIES OUTPUT_NAME yang)
121+
set_target_properties(yang_static PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
112122
target_link_libraries(yang_static m)
123+
target_link_libraries(yang_static ${CMAKE_DL_LIBS})
113124
target_link_libraries(yang_static ${CMAKE_THREAD_LIBS_INIT})
114125
target_link_libraries(yang_static ${PCRE_LIBRARIES})
115126
install(TARGETS yang_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
@@ -119,10 +130,14 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
119130
add_library(yangobj OBJECT ${libsrc})
120131
add_library(yang SHARED $<TARGET_OBJECTS:yangobj>)
121132
set_target_properties(yang PROPERTIES VERSION ${LIBYANG_VERSION} SOVERSION ${LIBYANG_SOVERSION})
133+
set_target_properties(yang PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
122134

123135
# link math
124136
target_link_libraries(yang m)
125137

138+
#link dl
139+
target_link_libraries(yang ${CMAKE_DL_LIBS})
140+
126141
# find pthreads
127142
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
128143
find_package(Threads REQUIRED)
@@ -169,11 +184,16 @@ add_custom_target(cclean
169184
COMMAND rm -rf Makefile Doxyfile
170185
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
171186

187+
# YANG extensions plugins
188+
add_subdirectory(src/extensions)
189+
190+
# yanglint
172191
add_executable(yanglint ${lintsrc})
173192
target_link_libraries(yanglint yang)
174193
install(TARGETS yanglint DESTINATION ${CMAKE_INSTALL_BINDIR})
175194
install(FILES ${PROJECT_SOURCE_DIR}/tools/lint/yanglint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
176195

196+
# yang2yin
177197
add_executable(yang2yin ${yang2yinsrc})
178198

179199
if(ENABLE_VALGRIND_TESTS)

Doxyfile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ WARN_LOGFILE =
756756
INPUT = ./src/libyang.h \
757757
./src/tree_data.h \
758758
./src/tree_schema.h \
759+
./src/extensions.h \
759760
./src/xml.h \
760761
./src/dict.h
761762

FAQ.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,23 @@ $ make
2121
or add the libyang's location to the linker paths in `/etc/ld.so.conf.d` and
2222
then run `ldconfig` to rebuild the linker cache.
2323

24+
__Q: yanglint(1) does not start and, but prints the following error messages:__
25+
```
26+
./yanglint
27+
libyang[0]: Invalid keyword "type" as a child to "annotation". (path: /)
28+
libyang[0]: Module "yang" parsing failed.
29+
Failed to create context.
30+
```
31+
32+
__A:__ To handle complex YANG extensions, libyang (and therefore yanglint(1))
33+
needs plugins. By default, the plugins are installed into the system path
34+
(next to the libyang library into the separate `libyang` subdirectory). If
35+
libyang was not installed, yanglint cannot find these plugins and it fails.
36+
If you do not want to install libyang, it is possible to specify path to the
37+
plugins via environment variable. The plugins can be found in the libyang
38+
build directory in `src/extensions/` subdirectory. So running yanglint(1)
39+
then can be made this way:
40+
```
41+
$ LIBYANG_EXTENSIONS_PLUGINS_DIR=`pwd`/src/extensions ./yanglint
42+
```
2443

KNOWNISSUES.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
# Known Issues
22

3-
## YANG statements
4-
5-
### Extensions
6-
7-
libyang is not able to parse generic extensions defined in YANG schema. The currently supported
8-
extensions are only
9-
* get-filter-element-attributes from ietf-netconf,
10-
* default-deny-write from ietf-netconf-acm,
11-
* default-deny-all from ietf-netconf-acm.
12-
13-
All other extension definitions/instances are currently ignored and only warning
14-
`Not supported "<name>" extension statement found, ignoring.` is printed.
15-
163
## XPath Expressions
174

185
### Axes
196

207
libyang uses its own XPath implementation to evaluate XPath expressions. The implementation
218
completely lacks support for [axes](https://www.w3.org/TR/1999/REC-xpath-19991116/#axes).
22-
nevertheless, it should always be possible to write equivalent expressions without
9+
Nevertheless, it should always be possible to write equivalent expressions without
2310
the use of axes.
11+
12+
### Deviation Must
13+
14+
If there are any XPath expressions defined as part of a deviation, they include literals,
15+
which are directly compared with identityref nodes (testing whether an identityref has a
16+
specific identity value), and the identity literal used is from the deviation module
17+
(meaning it could be written without a prefix), the prefix is mandatory for libyang
18+
to evaluate the XPath expression correctly.

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ providing API) in C. The library is used e.g. in [libnetconf2](https://github.co
1919
([RFC 7951](https://tools.ietf.org/html/rfc7951)).
2020
* Manipulation with the instance data.
2121
* Support for default values in the instance data ([RFC 6243](https://tools.ietf.org/html/rfc6243)).
22+
* Support for YANG extensions.
23+
* Support for YANG Metadata ([RFC 7952](https://tools.ietf.org/html/rfc6243)).
2224
* [yanglint](#yanglint) - features rich YANG tool.
2325

2426
Current implementation covers YANG 1.0 ([RFC 6020](https://tools.ietf.org/html/rfc6020))
@@ -53,7 +55,8 @@ $ make doc
5355
$ google-chrome ../doc/html/index.html
5456
```
5557

56-
The documentation is also built hourly and available at [netopeer.liberouter.org](https://netopeer.liberouter.org/doc/libyang/master/).
58+
The documentation is also built hourly and available at
59+
[netopeer.liberouter.org](https://netopeer.liberouter.org/doc/libyang/master/).
5760

5861
### Useful CMake Options
5962

@@ -89,6 +92,23 @@ The `Debug` mode is currently used as the default one. to switch to the
8992
```
9093
$ cmake -D CMAKE_BUILD_TYPE:String="Release" ..
9194
```
95+
96+
#### Changing Extensions Plugins Directory
97+
98+
For the YANG extensions, libyang loads the extension plugins. By default, the
99+
directory to store the plugins is LIBDIR/libyang. To change it, use the following
100+
cmake option with the value specifying the desired directory:
101+
102+
```
103+
$ cmake -DPLUGINS_DIR:PATH=`pwd`"/src/extensions/" ..
104+
```
105+
106+
The directory path can be also changed runtime via environment variable, e.g.:
107+
108+
```
109+
$ LIBYANG_EXTENSIONS_PLUGINS_DIR=`pwd`/my/relative/path yanglint
110+
```
111+
92112
### CMake Notes
93113

94114
Note that, with CMake, if you want to change the compiler or its options after
@@ -127,6 +147,22 @@ well as its man page are installed together with the library itself.
127147
There is also [README](./tools/lint/examples/README.md) describing some examples of
128148
using `yanglint`.
129149

150+
libyang supports YANG extensions via a plugin mechanism. Some of the plugins (for
151+
NACM or Metadata) are available out of the box and installed together with libyang.
152+
However, when libyang is not installed and `yanglint(1)` is used from the build
153+
directory, the plugins are not available. There are two options:
154+
155+
1. Install libyang.
156+
```
157+
# make install
158+
```
159+
160+
2. Set environment variable `LIBYANG_EXTENSIONS_PLUGINS_DIR` to contain path to the
161+
built extensions plugin (`./src/extensions` from the build directory).
162+
```
163+
$ LIBYANG_EXTENSIONS_PLUGINS_DIR="`pwd`/src/extensions" ./yanglint
164+
```
165+
130166
## Tests
131167

132168
libyang includes several tests built with [cmocka](https://cmocka.org/). The tests

0 commit comments

Comments
 (0)