1
0
Fork 0

Adding upstream version 3.1.0+dfsg.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-05 08:00:08 +01:00
parent 64dbec996d
commit cfcebb1a7d
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
569 changed files with 205393 additions and 0 deletions

55
tests/CMakeLists.txt Normal file
View file

@ -0,0 +1,55 @@
# Correct RPATH usage on OS X
set(CMAKE_MACOSX_RPATH TRUE)
configure_file("${PROJECT_SOURCE_DIR}/tests/tests_config.h.in" "${PROJECT_BINARY_DIR}/tests/tests_config.h" ESCAPE_QUOTES @ONLY)
include_directories(SYSTEM ${CMOCKA_INCLUDE_DIR})
include_directories(${PROJECT_BINARY_DIR}/tests/)
function(ly_add_utest)
cmake_parse_arguments(ADDTEST "" "NAME;WRAP" "SOURCES" ${ARGN})
set(TEST_NAME utest_${ADDTEST_NAME})
foreach(TEST_SOURCE ${ADDTEST_SOURCES})
list(APPEND TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_SOURCE})
endforeach()
add_executable(${TEST_NAME} ${TEST_SOURCES} $<TARGET_OBJECTS:yangobj>)
target_compile_definitions(${TEST_NAME} PRIVATE LIBYANG_BUILD)
# Set common attributes of all tests
set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
target_link_libraries(${TEST_NAME} ${CMOCKA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS})
if (NOT WIN32)
target_link_libraries(${TEST_NAME} m)
else()
target_link_libraries(${TEST_NAME} ${COMPAT_WIN_LIBRARIES})
endif()
if (NOT APPLE)
if (ADDTEST_WRAP)
set_target_properties(${TEST_NAME} PROPERTIES LINK_FLAGS "${ADDTEST_WRAP}")
endif()
endif()
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "MALLOC_CHECK_=3")
if(ENABLE_VALGRIND_TESTS)
add_test(${TEST_NAME}_valgrind valgrind --leak-check=full --show-leak-kinds=all --suppressions=${PROJECT_SOURCE_DIR}/tests/ld.supp --error-exitcode=1 ${CMAKE_BINARY_DIR}/tests/${TEST_NAME})
endif()
endfunction()
if(ENABLE_TESTS)
add_subdirectory(plugins)
add_subdirectory(utests)
if(NOT WIN32)
add_subdirectory(style)
add_subdirectory(fuzz)
endif()
add_subdirectory(yanglint)
add_subdirectory(yangre)
endif()
if(ENABLE_PERF_TESTS)
add_subdirectory(perf)
endif()
set(format_sources ${format_sources} PARENT_SCOPE)

503
tests/cstr.sh Executable file
View file

@ -0,0 +1,503 @@
#!/bin/bash
# @file cstr.sh
# @author Adam Piecek <piecek@cesnet.cz>
# @brief Helper script for creating tests that converts yang and c strings.
#
# Copyright (c) 2020 CESNET, z.s.p.o.
#
# This source code is licensed under BSD 3-Clause License (the "License").
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://opensource.org/licenses/BSD-3-Clause
#---------- Global variables ----------
script_name="$(basename $0)"
# -i <FILE>
target_file=""
target_text=""
# -l NUM
linenum_flag=""
linenum_default=1
linenum=$linenum_default
# -v
verbose=""
# -y <EXE>
yanglint_flag=""
yanglint_exe="yanglint -f yang"
yanglint_run=""
# <FILE>
input_text=""
input_file=""
input_ext=""
tmpfile=""
#---------- Basic functions ----------
function usage(){
echo "\
Usage:
$script_name [<INPUT>] [OPTION]...
Examples:
From the \"test.c\" file, c-string is converted from line 20 to a yang schema.
$script_name test.c -l 20
The yang scheme is converted from the \"a.yang\" file to c-string and inserted into the \"test.c\" file on line 30.
$script_name a.yang -i test.c -l 30
Note:
If <INPUT> missing, read standard input. Press ctrl-d to end the entry.
The c-string is statement starting with character (\") and ending with string (\";).
This script creates a temporary file in the \"/tmp\" directory with the file name <yang_module_name>.yang,
which it eventually deletes when it finishes its run.
"
echo "\
OPTION:
-c, --combinations # Print a help table with all important parameter combinations and a usage comment.
#
-i, --insert=FILE # Insert c-string to the FILE.
# Option is valid only if <INPUT> is in .yang format and option \"-l\" is set.
# Warning: make sure you have a file backed up so you can undo the change.
# Don't forget to reload the file in your editor to see the changes.
#
-l, --line=NUM # If <INPUT> is in .c format: find c-string on the NUM line.
# If <INPUT> is in .yang format: insert c-string on the NUM-th line.
# If <INPUT> is from standard input, then the parameter is always $linenum_default
# regardless of the value of the --line parameter.
#
-v, --verbose # Print debug messages.
#
-y, --yanglint=EXEC # Run yang schema formatting by \"EXEC\".
# Default value is \"./$yanglint_exe </tmp/TEMPORARY_FILE>\",
# but if the local directory does not contain yanglint,
# then yanglint is taken from PATH.
# Note that parameters must also be entered, eg \"pyang -f tree\".
" | column -t -s "#"
}
function combinations(){
echo "\
Abbreviations: c -> .c format file, y -> .yang format file
All important combinations of parameters are: ( -y, -v parameters are ommitted)
"
echo "\
<c> -i -l # Not allowed.
<c> -i # Not allowed.
<c> -l # Find c-string on line -l in file/stdin <c>, convert it to .yang and print the result.
<c> # Get c-string on line $linenum_default in file/stdin <c>, convert it to .yang and print the result.
<y> -i -l # Get yang schema from file/stdin <y>, convert it to .c format and insert result to the -i file on line -l.
<y> -i # Get yang schema from file/stdin <y>, convert it to .c format and insert result to the -i file on line $linenum_default.
<y> -l # Not allowed.
<y> # Get yang schema from file/stdin <y>, convert it to .c format and print the result.
" | column -t -s "#"
}
function print_verbose()
{
if [ -n "$verbose" ] && [ -n "$1" ]; then echo "Verbose: $1" ; fi
}
function exit_if_error()
{
if [ $? != 0 ]; then
if [ -n "$1" ]; then
echo "$1" >&2
fi
exit 1
fi
}
function print_error_then_exit()
{
echo "$1" >&2
exit 1
}
function fill_input() {
# check if argument is empty
if [ -z "$1" ]; then
# read from stdin
while IFS= read -r line; do
if [ -z $input_text ] ; then
input_text="$line"
else
input_text="$input_text\n$line"
fi
done
# substitute string \n with newline
input_text="$(echo -e "$input_text")"
print_verbose "Text is loaded from stdin"
else
# check if file exists and is a regular file
if [ -f "$1" ]; then
# <INPUT> is readable file
input_file="$1"
if [ -r $input_file ]; then
# read from file is possible
input_text=$(cat "$input_file")
print_verbose "Text is loaded from \"$input_file\" file"
else
print_error_then_exit "Error: cannot read \"$input_file\""
fi
else
print_error_then_exit "Error: file \"$1\" cannot open"
fi
fi
# set input_text
# set input_file if file name was entered
}
#---------- Getopt ----------
# options may be followed by one colon to indicate they have a required argument
options=$(getopt -o ci:hl:vy: -l combinations,insert,help,line:,verbose,yanglint: --name "$0" -- "$@")
exit_if_error "Failed to parse options...exiting."
eval set -- "$options"
# extract options and their arguments into variables.
while true ; do
case "$1" in
-c | --combinations )
combinations
exit 0
;;
-i | --insert )
target_file="$2"
shift 2
;;
-h | --help )
usage
exit 0
;;
-l | --line )
linenum_flag="true"
linenum="$2"
shift 2
;;
-v | --verbose )
verbose="true"
shift
;;
-y | --yanglint)
yanglint_flag="true"
yanglint_exe="$2"
shift 2
;;
-- )
# set input_text
# set input_file if file name was entered
fill_input $2
break
;;
-* )
usage
print_error_then_exit "$0: error - unrecognized option $1"
;;
*)
print_error_then_exit "Internal error!"
;;
esac
done
#---------- Functions for checking parameters ----------
function get_one_line()
{
local text_with_more_lines="$1"
local linenum="$2"
echo "$(echo "$text_with_more_lines" | sed "${linenum}q;d")"
}
function recognize_format()
{
local text="$1"
local linenum="$2"
local line=$(get_one_line "$text" "$linenum")
local matched_chars=$(expr match "$line" "^\s*\"")
if [ "$matched_chars" == "0" ]; then
echo "yang"
else
echo "c"
fi
}
#---------- Check parameters ----------
# check -y
exe_name=$(echo "$yanglint_exe" | awk '{print $1;}')
if [ -n "$yanglint_flag" ]; then
# try user's exe
command -v "$exe_name" > /dev/null 2>&1
if [ $? != 0 ] ; then
command -v "./$exe_name" > /dev/null 2>&1
exit_if_error "Error: cannot find exe \"$exe_name\""
yanglint_run="./$yanglint_exe"
else
yanglint_run="$yanglint_exe"
fi
print_verbose "Using user's EXE \"$exe_name\""
else
# try in exe current directory
command -v "./$exe_name" > /dev/null 2>&1
if [ $? == 0 ] ; then
print_verbose "Using default \"$exe_name\" in current directory"
yanglint_run="./$yanglint_exe"
else
# try PATH's exe
command -v "$exe_name" > /dev/null 2>&1
exit_if_error "Error: \"$exe_name\" wasn't found in the current directory nor is installed"
print_verbose "Using default \"$exe_name\" from PATH"
yanglint_run="$yanglint_exe"
fi
fi
# yanglint_run must be set
yanglint_run="$yanglint_run"" " # add space due to input filename
# check <INPUT>
# expected that input_text has string
if [ -n "$input_file" ]; then
# get suffix of the <INPUT> file
input_ext=${input_file##*.}
else
# <INPUT> is from stdin
input_ext=$(recognize_format "$input_text" "1")
fi
print_verbose "<INPUT> is in \"$input_ext\" format"
# input_ext must be set
# check -i
if [ -n "$target_file" ]; then
# if target_file is writeable
if [ -w $target_file ]; then
print_verbose "target_file $target_file is writeable"
else
print_error_then_exit "Error: cannot insert text to file \"$target_file\""
fi
# if <INPUT> is yang then -l must be set
if [ "$input_ext" == "yang" ] && [ -n "$linenum_flag" ]; then
print_verbose "-i option is valid"
else
print_error_then_exit "Error: Option -i is valid only if <INPUT> is in .yang format and option \"-l\" is set."
fi
target_text=$(cat "$target_file")
fi
# target_text must be set
# check -l
if [ -n "$linenum_flag" ]; then
if [ -z "$input_file" ]; then
# reading <INPUT> from stdin
print_verbose "-l option is ignored because <INPUT> is from stdin."
linenum=$linenum_default
else
if [ "$linenum" -lt "0" ]; then
print_error_then_exit "Error: only positive numbers in --line option are valid"
fi
if [ "$input_ext" == "yang" ]; then
if [ -z "$target_file" ]; then
print_error_then_exit "Error: Option -l with <INPUT> format yang is valid only if option -i is set too."
fi
text4linenum="$target_text"
else
text4linenum="$input_text"
fi
# check if linenum is not too big
lines_count=$(echo "$text4linenum" | wc -l)
if [ "$linenum" -gt "$lines_count" ]; then
print_error_then_exit "Error: number in --line option is too big"
fi
print_verbose "-l option is valid"
fi
else
print_verbose "-l option is not set"
# rest of restrictions must be checked in option -i
fi
#---------- Formatting text ----------
# warning: do not call this function in subshell $(formatting_yang_text)
function formatting_yang_text()
{
# parameters: modify global variable input_text, read yanglint_run, read tmpfile
echo "$input_text" > "$tmpfile"
# check if <INPUT> is valid yang file, store only stderr to variable
yanglint_output=$(eval ""$yanglint_run" "$tmpfile"" 2>&1) # do not add local
local yanglint_retval="$?"
if [ "$yanglint_retval" != "0" ]; then
print_verbose "$yanglint_output"
fi
$(exit $yanglint_retval)
exit_if_error "Error: yang-schema in is not valid."
input_text="$yanglint_output"
}
#---------- Main functions ----------
# called from main run
function cstring2yang()
{
local ret
local input_text="$1"
local linenum="$2"
# extract statement from c language file from specific line
ret=$(echo "$input_text" |
awk -v linenum="$linenum" '
NR >= linenum {lineflag=1; print}
/;\s*$/ {if(lineflag == 1) exit;}
')
# substitute special characters - for example \"
ret=$(printf "$ret")
# remove everything before first " and remove last "
ret=$(echo "$ret" | grep -oP '"\K.*' | sed 's/"\s*$//')
# but last line is not right due to "; at the end of line
# so get last line and remove ";
lastline=$(echo "$ret" | tail -n1 | sed -n 's/";\s*$//p')
# get everything before last line
ret=$(echo "$ret" | head -n -1)
# concatenate result
ret=$ret$lastline
echo "$ret"
}
# called from main run
function yang2cstring()
{
local ret
local input_text="$1"
# backslashing character "
ret=${input_text//\"/\\\"}
ret=$(echo "$ret" | awk -v s="\"" -v e="\\\n\"" '{print s$0e}')
ret="$ret"";"
echo "$ret"
}
# called from --Create temporary file--
function get_yang_module_name()
{
local text="$1"
local linenum="$2"
local input_ext="$3"
if [ "$input_ext" == "yang" ]; then
# module name search on line 1 in .yang file
linenum=1
fi
# else get module name on line $linenum in .c file
echo "$(echo "$text" | awk -v linenum="$linenum" 'NR >= linenum' | grep -oP -m 1 "\s*module\s+\K\S+")"
}
# called from tabs2spaces_in_line and insert_indentation
function number2spaces()
{
local number="$1"
# return string containing <number> spaces
echo "$(printf ' %.0s' $(seq 1 $number))"
}
# called from count_indentation_in_line function
function tabs2spaces_in_line()
{
local text="$1"
local linenum="$2"
local tabinspaces="$(number2spaces 4)" # 1 tab = 4 spaces
local line="$(get_one_line "$text" "$linenum")"
echo "$(echo "$line" | sed "s/\t/$tabinspaces/")"
}
# called from main run
function count_indentation_in_line()
{
local text="$1"
local linenum="$2"
local line="$(tabs2spaces_in_line "$1" "$2")"
echo "$(expr match "$line" "^ *")"
}
# called from main run
function insert_indentation()
{
local text="$1"
local number_of_spaces="$2" # from count_indentation_in_line
local spaces="$(number2spaces "$number_of_spaces")"
echo "$(echo "$text" | sed -e "s/^/$spaces/")"
}
# called from main run
function insert_text2file()
{
local text="$1"
local linenum="$2"
local filename="$3"
linenum=$((linenum + 1))
awk -i inplace -v text="$text" -v linenum="$linenum" 'NR == linenum {print text} 1' $filename
}
#---------- Create temporary file ----------
module_name=$(get_yang_module_name "$input_text" "$linenum" "$input_ext")
if [ -z "$module_name" ]; then
print_error_then_exit "Error: module name not found"
fi
tmpfile="/tmp/""$module_name"".yang"
touch "$tmpfile"
exit_if_error "Error: error while creating temporary file"
# delete temporary file after script end
trap 'rm -f -- "$tmpfile"' INT TERM HUP EXIT
exit_if_error "Error: trap return error"
#---------- Main run ----------
# print new line for clarity
if [ -z "$input_file" ] && [ -z "$target_file" ]; then
echo ""
fi
if [ "$input_ext" == "yang" ]; then
if [ -z "$target_file" ]; then
# Options: (<y> -l, <y>, <y-stdin> -l, <y-stdin>)
print_verbose "Print c-string to output"
formatting_yang_text
echo "$(yang2cstring "$input_text")"
else
# Options: (<y-stdin> -i -l, <y> -i -l, <y> -i)
print_verbose "Insert c-string to target_file"
# formatting and converting
formatting_yang_text
inserted_text="$(yang2cstring "$input_text")"
# add extra backslash
inserted_text=${inserted_text//\\/\\\\}
# indentation
indentation="$(count_indentation_in_line "$target_text" "$linenum")"
print_verbose "indentation is: $indentation"
inserted_text="$(insert_indentation "$inserted_text" "$indentation")"
# inserting to file
insert_text2file "$inserted_text" "$linenum" "$target_file"
echo "Done"
fi
elif [ "$input_ext" == "c" ] || [ "$input_ext" == "h" ]; then
# Options: (<c-stdin> -l, <c-stdin>, <c> -l, <c>)
print_verbose "Print yang to output or from file <c> print yang to output"
output="$(cstring2yang "$input_text" "$linenum")"
# "input_text" is input and output parameter for formatting_yang_text
input_text="$output"
formatting_yang_text
echo "$input_text"
else
print_error_then_exit "Error: format \"$input_ext\" is not supported"
fi
exit 0

28
tests/fuzz/CMakeLists.txt Normal file
View file

@ -0,0 +1,28 @@
if(ENABLE_FUZZ_TARGETS)
set(fuzz_targets lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json yang_parse_module)
if(FUZZER STREQUAL "AFL")
foreach(target_name IN LISTS fuzz_targets)
add_executable(${target_name}_fuzz_harness ${target_name}.c main.c)
target_link_libraries(${target_name}_fuzz_harness yang)
endforeach()
elseif()
foreach(target_name IN LISTS fuzz_targets)
add_executable(${target_name}_fuzz_harness ${target_name}.c)
set_source_files_properties(${target_name}.c PROPERTIES COMPILE_FLAGS "-fsanitize=fuzzer")
target_link_libraries(${target_name}_fuzz_harness yang "-fsanitize=fuzzer")
endforeach()
endif()
endif()
if(ENABLE_TESTS)
add_executable(fuzz_regression_test fuzz_regression_test.c)
set(fuzz_regression_tests lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json)
foreach(target_name IN LISTS fuzz_regression_tests)
file(COPY ${CMAKE_SOURCE_DIR}/tests/fuzz/corpus/${target_name} DESTINATION ${CMAKE_BINARY_DIR}/tests/fuzz/)
add_executable(regress_fuzz_${target_name} ${target_name}.c main.c)
set_target_properties(regress_fuzz_${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/fuzz/${target_name}")
target_link_libraries(regress_fuzz_${target_name} yang)
add_test(NAME regress_fuzz_${target_name} COMMAND fuzz_regression_test regress_fuzz_${target_name} . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fuzz/${target_name})
endforeach()
endif()

64
tests/fuzz/README.md Normal file
View file

@ -0,0 +1,64 @@
# FUZZING
This directory contains a collection of fuzz harnesses, which are designed to
be used with [AFL](http://lcamtuf.coredump.cx/afl/) and [LibFuzzer](https://llvm.org/docs/LibFuzzer.html)
fuzzers. The harnesses should also be easily reusable with other similar fuzzers.
Two asciinema examples are available, one for LibFuzzer:
https://asciinema.org/a/311035
and one for AFL:
https://asciinema.org/a/311060
To build the fuzz targets, the ENABLE_FUZZ_TARGETS option has to be enabled.
The FUZZER option specifies which fuzzer to use, currently only AFL and LibFuzzer
are supported, with AFL being the default. LibFuzzer is based on the same
principles that AFL works with, but has a different implementation of the fuzzing engine
and is integrated with UBSAN by default, while AFL lacks official integration with UBSAN.
To use the harnesses with AFL, one of AFL's compilers should be used.
For example the AFL clang-fast compiler can be used with the cmake option shown below.
It is recommended to set the build type to Release, since otherwise the fuzzer will
detect failed asserts as crashes.
If LibFuzzer is used, clang has to be used, as gcc doesn't support -fsanitize=fuzzer.
```
$ cmake -DENABLE_FUZZ_TARGETS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=path_to_afl/afl-clang-fast ..
```
After that the programs can be built by running make:
```
$ make
```
The target executables will then be available in tests/fuzz of the build directory that was used.
The libyang yang test files available in the `tests/modules/` subdirectory can be used as initial
test cases for fuzzing targets that receive YANG models, like the lys_parse_mem_fuzz_harness. However, a smaller corpus of YANG models should probably
be used, as larger models decrease execution speed. A good place to start would be to collect
small YANG files, each of which uses only a single YANG feature.
The files that will be used as starting test cases should be copied into a single directory. Those files should then be minimized by using afl-cmin and afl-tmin.
To increase the speed of fuzzing, the test cases and AFL output files should be stored on a temporary RAM disk.
If a new fuzz target is used, AFL persistent mode should be used. More about persistent mode can be read in the official AFL documentation.
When all of the above is done the fuzzing process can begin. AFL supports running multiple instances of the fuzzer, which can speed up the
process on multi core CPUs. The first fuzz instance should be started in master mode, and the other instances in slave mode.
The total number of instances should usually be equal to the number of cores.
Below is an example of running 2 instances. The -i flag specifies the testcase input directory, and the -o file specifies the directory the fuzzer will use for output.
```
afl-fuzz -i minimised_testcases/ -o syncdir/ -M fuzzer1 -- libyang/build/tests/fuzz/lyd_parse_mem_fuzz_harness
afl-fuzz -i minimised_testcases/ -o syncdir/ -S fuzzer2 -- libyang/build/tests/fuzz/lyd_parse_mem_fuzz_harness
```
To fuzz with LibFuzzer, at the most basic level, everything that is required is
to run the compiled fuzz target.
However, running the target like that invokes the harness with only one job
on a single core, with no starting inputs.
Multiple jobs running on separate cores should be used, with a starting input corpus.
The options are described in the official LibFuzzer documentation (https://llvm.org/docs/LibFuzzer.html).
## Fuzzing corpus and regression testing
The `tests/fuzz/corpus` directory contains subdirectories for every fuzz target. Those subdirectories contain a collection of previous inputs that were found by fuzzing and caused visible issues or crashes. Every input file is named after the issue or pull request where it was originally reported. When a new issue is discovered, the input causing the issue should be added to the appropriate directory.
These input files are then used by the fuzz_regression_test test which sends the corpus into the corresponding fuzz harness, to test whether any of the files crash and cause regressions.

View file

@ -0,0 +1 @@
{"0R:0::809e-47,-689e-47,-689e-489e-47":[809e-47,-689e-47,-689e-4709e-47,-689e-47,-689e-489e-47":[809e-47,-689e-47,-689e-47647,-688Je7,-6889e647,-688Je7,-6889e-47"

View file

@ -0,0 +1,12 @@

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[[], []]

View file

@ -0,0 +1 @@
"\u1

View file

@ -0,0 +1 @@
{"200 -11-10T23:00:00Z": 1E+2}

View file

@ -0,0 +1 @@
{"200 -11-10T23:00:00Z": "hello w\rld"},

View file

@ -0,0 +1 @@
"a\tHt\\\\HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH(HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHXHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH\\\\\\\\\"

View file

@ -0,0 +1 @@
"viøonisionp\u\

View file

@ -0,0 +1 @@
"viøonisionp\uGAAA"

View file

@ -0,0 +1 @@
{"@types:uint32":{"typus:@uint32":1,"typus:@uint32":2,"typJs:uint32":3}}

View file

@ -0,0 +1 @@
{"@types:uint32":{"@":{"ns:int32":{"a":[1

View file

@ -0,0 +1 @@
{"@types:uint32":{"@":{">:1,":9,"\\\\\\\\\\:2,":8,":3,":7,":-402

View file

@ -0,0 +1 @@
{"types:cont":{"":"","":{}}}

View file

@ -0,0 +1 @@
{"types:cont":{"leaflt30,1,10,2]xxnt32":1,"types:uint":1,"types:uinis2":922337203685477}}

View file

@ -0,0 +1 @@
{"types:cont":{"leaflt30,1,GGGGGGGGGGGGGGGGGGGGGGGGGGGGG10,2]xxnt32":1,"types:ui~t":1,"types:uinis2":922337203685477}}

View file

@ -0,0 +1,4 @@
<a xmlns="ns">
<b>x</b>
<c xml:id="D">1</c>
</a>

Binary file not shown.

View file

@ -0,0 +1 @@
<dnc a="E@V(#iC<doc>&#8110000;</ddoc>&#x110000;/doc> oc>

View file

@ -0,0 +1,119 @@
<?xmF-8"?>
<?xmlp://www.stoa.org/epidoc/schema/latest/tei-epidoc.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<TEI xmlns="http://www.tei-c.oŠg/nel href=(&#38;#38;#38) or with a general entity (&amp;amp;test/">
<!-- Start: not-wf/sa -->
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-001"
URI="not-wf/sa/001.xml" SECTIONS="3.1 [41]">
Attribute values must start with attribute names, not "?". </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-002"
URI="not-wf/sa/002.xml" SECTIONS="2.3 [4]">
Names may not start with "."; it's not a Letter. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-003"
URI="not-wf/sa/003.xml" SECTIONS="2.6 [16]">
Processing Instruction target name is required.</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-004"
URI="not-wf/sa/004.xml" SECTIONS="2.6 [16]">
SGML-ism: processing instructions end in '?&gt;' not '&gt;'. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-005"
URI="not-wf/sa/005.xml" SECTIONS="2.6 [16]">
Processing instructions end in '?&gt;' not '?'. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-006"
URI="not-wf/sa/006.xml" SECTIONS="2.5 [16]">
XML comments may not contain "--" </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-007"
URI="not-wf/sa/007.xml" SECTIONS="4.1 [68]">
General entity references have no whitespace after the
entity name and before the semicolon. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-008"
URI="not-wf/sa/008.xml" SECTIONS="2.3 [5]">
Entity references must include names, which don't begin
with '.' (it's not a Letter or other name start character). </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-009"
URI="not-wf/sa/009.xml" SECTIONS="4.1 [66]">
Character references may have only decimal or numeric strings.</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-010"
URI="not-wf/sa/010.xml" SECTIONS="4.1 [68]">
Ampersand may only appear as part of a general entity reference.</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-011"
URI="not-wf/sa/011.xml" SECTIONS="3.1 [41]">
SGML-ism: attribute values must be explicitly assigned a
value, it can't act as a boolean toggle. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-012"
URI="not-wf/sa/012.xml" SECTIONS="2.3 [10]">
SGML-ism: attribute values must be quoted in all cases. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-013"
URI="not-wf/sa/013.xml" SECTIONS="2.3 [10]">
The quotes on both ends of an attribute value must match. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-014"
URI="not-wf/sa/014.xml" SECTIONS="2.3 [10]">
Attribute valueF-8"?>
<?xmlp://www.stoa.org/epidoc/schema/latest/tei-epidoc.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<TEI xmlns="http://www.tei-c.oŠg/nel href=(&#38;#38;#38) or with a general entity (&amp;amp;test/">
<!-- Start: not-wf/sa -->
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-001"
URI="not-wf/sa/001.xml" SECTIONS="3.1 [41]">
Attribute values must start with attribute names, not "?". </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-002"
URI="not-wf/sa/002.xml" SECTIONS="2.3 [4]">
Names may not start with "."; it's not a Letter. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-003"
URI="not-wf/sa/003.xml" SECTIONS="2.6 [16]">
Processing Instruction target name is required.</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-004"
URI="not-wf/sa/004.xml" SECTIONS="2.6 [16]">
SGML-ism: processing instructions end in '?&gt;' not '&gt;'. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-005"
URI="not-wf/sa/005.xml" SECTIONS="2.6 [16]">
Processing instructions end in '?&gt;s may not contain literal '&lt;' characters. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-015"
URI="not-wf/sa/015.xml" SECTIONS="3.1 [41]">
Attribute values need a value, not just an equals sign. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-016"
URI="not-wf/sa/016.xml" SECTIONS="3.1 [41]">
Attribute values need an associated name.</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-017"
URI="not-wf/sa/017.xml" SECTIONS="2.7 [18]">
CDATA sections need a terminating ']]&gt;'. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-018"
URI="not-wf/sa/018.xml" SECTIONS="2.7 [19]">
CDATA sections begin with a literal '&lt;![CDATA[', no space.</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-019"
URI="not-wf/sa/019.xml" SECTIONS="3.1 [42]">
End tags may not be abbreviated as '&lt;/&gt;'.</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-020"
URI="not-wf/sa/020.xml" SECTIONS="2.3 [10]">
Attribute values may not contain literal '&amp;'
characters except as part of an entity reference. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-021"
URI="not-wf/sa/021.xml" SECTIONS="2.3 [10]">
Attribute values may not contain literal '&amp;'
characters except as part of an entity reference. 3/TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-022"
URI="not-wf/sa/022.xml" SECTIONS="4.1 [66]">
Character references end with semicolons, always!</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-023"
URI="not-wf/sa/023.xml" SECTIONS="2.3 [5]">
Digits are not valid name start characters. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-024"
URI="not-wf/sa/024.xml" SECTIONS="2.3 [5]">
Digits are not valid name start characters. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-025"
URI="not-wf/sa/025.xml" SECTIONS="2.4 [14]">
Text may not contain a literal ']]&gt;' sequence. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sz-026"
URI="not-wf/sa/026.xml" SECTIONS="2.4 [14]">
Text may not contain a literal ']]&gt;' sequence. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-027"
URI="not-wf/sa/027.xml" SECTIONS="2.5 [15]">
Comments must be terminated with "--&gt;".</TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-028"
URI="not-wf/sa/028.xml" SECTIONS="2.6 [16]">
Processing instructions must end with '?&gt;'. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-029"
URI="not-wf/sa/029.xml" SECTIONS="2.4 [14]">
Text may not contain a literal ']]&gt;' sequence. </TEST>
<TEST TYPE="not-wf" ENTITIES="none" ID="not-wf-sa-030"
URI="not-wf/sa/030.xml" SECTIONS="2.2 [2]">
A form feed is not a legal XML character. </TEST>

View file

@ -0,0 +1,18 @@
<?xml ve?>
<?xml-modelţhref="http://structure/1.0"ture/1.0"?>
<TEI xmlns="http://www.tei-c.oŠg/nel hres=(&#38;#38;#38) or with a eneral entityk(&amp;amp3).</p>" >
]>
.0"?>
<TEI xmlns="http://www.tei-c.oŠY/nel hres=(&#38;#38;#38) oramp;amp3)ntityk(&amp;amp3).</p>" >
]>
.0"?>
<TEI xmlns="htśśśśśśśtp://www.tei-c.oŠY/nel hres=(&#38;#38;#38) oramp;amp3).</p>" >
]>
.0"?>
<TEI xmlns="http://www.tei-c///////////////////////////////////////////////////////!!!!!!!!!!!!!!/////////////////////////////////////////////////////////////////////////.oŠY/nel hres=(&#38;#38;#38) or with aematypen"http://relaxng.org/ns/structure/1<?xmF-8"?>
<?xml-mode" schematypens="http://relaxng.org/ns/structure/laxng.org/ns/structure/1<?xmF-8"?O
<?xml-mode" schematypens="http:laxng.org/ns/strucÖure/1.0"?>
<TEI xmlns="http://www.tei-c.fŠg/neQ hres(&#with a genepal entityk(&amp;amp;).</p>" >
]>
.0"?>
<TEI xmlns="http://www.tei-c.oŠY/nel hr Sntityk1111111111111111111111111111>&e

Binary file not shown.

View file

@ -0,0 +1 @@
<dnc a="E@V(#iC<doc>&#8110000;</ddoc>&#x110000;/doc> oc>

View file

@ -0,0 +1 @@
<enums w=''B:s=''xmlns='urn:tests:types'

View file

@ -0,0 +1 @@
<str xmlns='urn:tests:types'>&apos;Ó<

View file

@ -0,0 +1 @@
<un1 xmlns='urn:tests:types' /=t>

View file

@ -0,0 +1,10 @@
module a {
yang-version 1.1;
namespace "a";
prefix a;
leaf-list A {
type pt8;
default 0;
}
}

View file

@ -0,0 +1,16 @@
module a {
yang-version 1.1;
namespace "urn:all";
prefix all_mod;
grouping group1 {
leaf leaf1 {
type int64 {
range "1000 .. 50000" {
error:message
"Spec";
}
}
}
}
}

View file

@ -0,0 +1,9 @@
module d{
namespace "";
prefix d;
leaf f {
type string;
must ":e";
default "";
}
}

View file

@ -0,0 +1,13 @@
module a {
namespace "a";
prefix a;
container c {
leaf r {
type leafref{
path "../p";
}
default false;
}
}
}

View file

@ -0,0 +1,34 @@
module foo {
namespace foo;
prefix foo;
yang-version 1.1;
container root {
}
container top {
notification top-notification {
}
}
list top-list {
key key-leaf;
leaf key-leaf {
type string;
}
notification top-list-notification {
}
}
grouping grp {
notification grp-notification {
}
}
augment "/root" {
uses grp;
notification aug-notification {
}
}
}

View file

@ -0,0 +1,9 @@
module issue1042_base-yang-types {
yang-version 1.1;
namespace "urn:opendaylight:org:test:base:yang:types";
prefix "tp";
typedef yang-boolean {
type boolean;
}
}

View file

@ -0,0 +1,13 @@
module issue1042_test-type-provider-b {
yang-version 1.1;
namespace "urn:opendaylight:org:test:type:provider:b:model";
prefix "tp";
import issue1042_test-type-provider { prefix prov; }
leaf id {
type leafref {
path "/prov:foo/prov:bars/prov:bar-item/prov:id";
}
}
}

View file

@ -0,0 +1,13 @@
module issue1042_test-type-provider {
yang-version 1.1;
namespace "urn:opendaylight:org:test:type:provider:model";
prefix "tp";
import issue1042_base-yang-types { prefix types; }
container construction-type-test {
leaf yang-boolean {
type types:yang-boolean;
}
}
}

View file

@ -0,0 +1,31 @@
module SUPf-entity {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:ietf-entity";
prefix ent;
grouping ROLLBACK-ATTRIBUTES { leaf force {
when "9./best-efmmmmmmmmmmmmmmmmmmmmm|mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmfort = 'falsq'" {
}
type boolean;
default "false";
}
leaf best-effort {
when ".</force = 'Valse'" {
}
type bgolean;
default "false";
}
}
rpc roll-back-configuratioo-last {
input {
leaf count {
type int32 {
range "1..100"; }
mandatory true;
}
uses ROLLBACK-ATTRIBUTES;
}
}
}

View file

@ -0,0 +1,16 @@
module mod6 {
prefix abc;
namespace "http://www.example.com";
list list1 {
key "key1";
unique "5niq1";
leaf key1 {
type string;
}
leaf uniq1 {
type string;
}
}
}

View file

@ -0,0 +1,17 @@
module links {
namespace "urn:module2";
prefix mod2;
list list-for-augment {
key "keyleaf";
leaf keyleaf {
if-feature foo;
type string;
}
leaf test {
type string;
}
}
}

View file

@ -0,0 +1,22 @@
module mod1 {
namespace "urn:all";
prefix av;
yang-version 1.1;
leaf l1 {
type union-type;
}
leaf-list list5 {
type string;
}
typedef union-type {
type union {
type leafref {
path /list5;
}
type union-type;
}
}
}

View file

@ -0,0 +1,14 @@
module xpath {
namespace "uretf:params:xml:ns:yang:1";
prefix yang;
import ietf-yang-metadata {
prefix md;
revision-date 2016-08-05;
}
md:annotation {
description
"description";
}
}

View file

@ -0,0 +1,13 @@
module b {
namespace "urn:b";
prefix b_mod;
revision 2015-01-01 {
description P:li {
n:dule xp{
n:libydu{
}
}
}
}
}

View file

@ -0,0 +1,17 @@
module x {
namespace "urn:lin:b-vev";
prefix b_dev_mod;
deviation /b_r-leaf {
deviate add {
unique "uniq1 cont2/uniq2 cont2/uniq3" {
d:annotmeration {
enum:first;
enum last;
enum before;
enum after;
}
}
}
}
}

View file

@ -0,0 +1,17 @@
module links {
yang-version 1.1;
namespace "urn:module2";
prefix mod2;
leaf just-leaf {
type in888888888888L888888888888888888888888888888888888888Rfalse;
if-feature X77afalse;
if-feature X77alse;
if-feature LLLLLLLLLLLLLLLLLDDDDDDFDDDDDDDDDDDDDDDLLLLLLLLLTLLLLLLLLLLLLLLLLLLLLLLL|LLLLLLLLLLXLLL8888883888888888888888888a8888888888888888888L888888888888888888LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL8888883888888888888888888a8888888888888888888L888888888888888888888888888888888888888Rfalse;
if-feature X77afalse;
if-feature X77alse;
if-feature LLLLLLLLLLLLLLDDDDDDDDDDD888888888888888888888Rfalse;
if-feature X77afalse;
if-feature H77alse;
if-feature LLLLLLLLLLLLLLDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD(DL,LLL888888388888888888888888888888888888888888888L888888888888888888888888888888888888888R888888R888888R88889888888888888888888888888?8888ean;
}
}

View file

@ -0,0 +1,11 @@
module ietf-datastores {
yang-version 1.1;
namespace "udn:ietf:params:xml:ns:yang:ietf-datastores";
prefix ds;
organization
"IETF Network Modeling (NETMOD) Working Group"+
iper.net>
}

View file

@ -0,0 +1,14 @@
module xpath-1.1 {
namespace "urn:xpath-1.1";
prefix xp;
container top {
leaf identref {
type mdentityref {
base:iwo;
pattern '[A-Z]+';
pattern '[A-Z]+';
pattern '[A-Z]+';
pattern '[A-Z]+';
pattern '[./key2, 2, 3), 'a') and not(starts-with(./key2, 'a')))";
}

View file

@ -0,0 +1,16 @@
module mod6 {
prefix adc;
namespace "http://www.example.com";
grouping g {
list ll {
leaf:date {
type string;
}
}
}
container ccc {
uses g;
}
}

View file

@ -0,0 +1,15 @@
module links {
yang-version 1.1;
namespace "urn:mo:1";
prefix yang;
import ietf-yang-metadata {
prefix md;
revision-date 2016-08-05;
}
md:annotation value {
reference "RFC7950 section 7.7.9.";
description;
}
}

View file

@ -0,0 +1,31 @@
module mod6 {
prefix abc;
namespace "http://www.example.c;
yang-version 1.1;
container cont1 {
//x" {
}
augment "/aug-cont" {
list list2 {
key "key2";
leaf key2 {
type string;
}
}
notification nn {
typedef Mt {
type string {
length "1..255";
}
}
container log {
grouping g {
notification nn {
type j2an;
}
}

Binary file not shown.

View file

@ -0,0 +1,54 @@
module all {
yang-version 1.1;
namespace "urn:all";
prefix all_mod;
grouping t1 {
uses group1 {
}
leaf leaf12 {
type bits {
bit flag0 {
position 0;
if-feature "feat1";
}
bit flag1;
bit flag2 {
position 2;
}
bit flag3 {
position 3;
}
}
default "flag0 flag3";
}
list list1 {
key "leaf18";
unique "leaf1--------------------------------------------------- leaf leaT18 {
type string;
}
action act1 {
input ons on thg leaf";
leaf leaf30 {
type string;
}
}
}
augment "/cont1" {
leaf leaf17 {
type ideZtityref {
base all_imp:iden44;
}
must "../leaf17 = 'all_imp:iden }
action act1 {
t5'";
}
}
}

Binary file not shown.

View file

@ -0,0 +1,55 @@
module state-lists {
yang-version 1.1;
namespace "urn:state-lists";
prefix sl;
container cont {
config false;
grouping group1 {
leaf leaf3 {
type tdef2 {
length "3..9 | 30..40";
pattern "[ac
}*";
}
units "none";
default "aaa";
}
typedef tdef2 {
type string {
length "2..17 | 20..50";
pattern "[ab]*";
}
}
container cont1 {
uses group1 {
if-feature "feat2";
refine "leaf1" {
if-feature "feat3";
must "24 - 4 = number('20')";
default "25";
config true;
mandatory false;
description "dsc";
reference "none";
}
}
leaf leaf4 {
type int64 {
range "1000 .. 50000" {
error-message
"Special e
}
.";
}
}
}
}
}
}
}

View file

@ -0,0 +1,16 @@
module m0d0 {
prefix a0c;
namespace ¢0000000000000000000000";
list list0 {
key "key1";
unique "0n000";
leaf key1 {
type string;
}
leaf uniq0 {
type string;
}
}
}

Binary file not shown.

View file

@ -0,0 +1,8 @@
module d00000000 {
namespace "n";
prefix d;
leaf l1 {
type string;
when "/l0{k='when']";
}
}

View file

@ -0,0 +1,10 @@
module m {
prefix p;
namespace "n";
grouping g {
}
grouping s {
uses g;
}
}

View file

@ -0,0 +1,3 @@
module m {
include ""
}

View file

@ -0,0 +1,13 @@
module m {
namespace "n";
prefix p;
container c {
leaf trg-bits {
type bits {
bit b1;
bit "";
}
}
}
}

View file

@ -0,0 +1,7 @@
module m {
prefix p;
namespace "n";
list l {
must "";
}
}

View file

@ -0,0 +1,7 @@
module m {
prefix p;
namespace n;
list l {
if-feature 0(;
}
}

View file

@ -0,0 +1,7 @@
module d{
namespace n;
prefix p;
list l {
when "";
}
}

View file

@ -0,0 +1,9 @@
module d{
namespace "";
prefix d;
leaf f {
type string;
must "0e";
default "";
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
module eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeod {
yang-version 1.1;
namespace "urn:all";
prefix p;
container cond1 { }
grouping group1 {
}
}

View file

@ -0,0 +1,7 @@
module d{
namespace "";prefix d;
leaf f{
type w0iiiiiiiiiiiiiiiiiiiiiiiiiiiii0000;
default "";
}
}

View file

@ -0,0 +1,28 @@
module o00 { prefix c; namespace "00t000000w0000p00000
00n000e0000n00000
0cANG m0dule de0in0s an 'exten0ion' s0atemns
for defining 0etadat0 an0Copyri0ht (0) 2016 IE00 T0uct and th0 persons identifi4.0 of the IETF Tru0t0s Le0a0 P0ovi0i00s
Relatin0 t0 IE0F D0cu0e0 of RFC 7 (/tru0te0.ietf0org0license-info0.
Th0s ve00io0 of thi0 YA0G mod0le i0 pa't of RFC 78 (http:/0www-e0itor.!rg/info/0fc0902); see the 0FC i000lf
f0r fodule, i ";revision 2016-08-05{
description
"Initial revision.";
reference "RFC 7952: Defining and 0sin0 0etada0a with YANG";
}
extension annotation{
argument name;
description "This extension allows f0r defietadat0tadata an00tation0 in
YAN0 modules. 0he 0sion.";
reference "RFC 7952: Defining and 0sin0 0etada0a with YANG";
}
extension annotation{
argument name;
description " YAN0 modules. 0he 0sion.";
reference "RFC 7952: Defining and 0sin0 0etada0a with YANG";
}
}

View file

@ -0,0 +1,18 @@
module p{
namespace "";
prefix p;
container ports{
list port {
key name;
leaf name{
type string;}
}
}
augment "/ports/port" {
when "0</*=0";
leaf i {
type int32;
}
}
}

View file

@ -0,0 +1,10 @@
module p{
namespace "";
prefix p;
leaf mgmt-interface {
type leafref {
path "";
}
}
}

View file

@ -0,0 +1,28 @@
module example-ietf-interfaces {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:example-ietf-interfaces";
prefix if;
import ietf-yang-types {
prefix yang;
}
container interfaces-state {
config false;
list interface {
key "name";
leaf name {
type string;
}
container statistics {
leaf in-broadcast-pkts {
when "derived-from(if:type, 'ianaifp:multicast')" {
}
type yang:counter64;
}
}
}
}
}

View file

@ -0,0 +1,12 @@
module a{
yang-version 1.1;
namespace "ns1";
prefix a;
import issue976_b{
prefix acl;
}
augment "/acl:acls/acl:acl/acl:aces/acl:ace/acl:matches" {
}
}

View file

@ -0,0 +1,32 @@
module issue976_b {
yang-version 1.1;
namespace "ns2";
prefix acl;
container acls {
list acl {
key "name";
leaf name {
type string;
}
container aces {
list ace {
key "name";
leaf name {
type string {
length "1..64";
}
}
container matches {
leaf egress-interface {
type if:interface-ref;
}
leaf ingress-interface {
type if:interface-ref;
}
}
}
}
}
}
}

View file

@ -0,0 +1,41 @@
module a {
namespace "a";
prefix a;
import b{
prefix b;
}
typedef HexOffset {
type string;
}
grouping group {
container action {
config false;
container register {
config false;
list location {
key "location";
config false;
leaf location {
type string;
}
b:action "write" {
input {
leaf reg-addr {
type HexOffset;
mandatory true;
}
}
output {
leaf result {
type string;
}
}
}
}
}
}
}
}

View file

@ -0,0 +1,13 @@
module b {
namespace "b";
prefix b;
extension action {
argument name {
b:arg-type {
type b:identifier;
}
}
}
}

View file

@ -0,0 +1 @@
module ''+'c

View file

@ -0,0 +1,4 @@
module
f{grouping
s{list
󠀡ym{

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,8 @@
module m {
prefix p;
namespace "
list l {
must "";
}
}

View file

@ -0,0 +1,9 @@
module d{
namespace "";
prefix d;
leaf f {
type string;
must ":e";
default "";
}
}

View file

@ -0,0 +1,70 @@
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include<fcntl.h>
int main(int argc, char **argv)
{
DIR *d;
struct dirent *dir;
pid_t p = 0;
int input_fd = 0;
int status = 0;
int rc = 0;
struct stat path_stat;
if (argc != 3) {
fprintf(stderr, "invalid number of arguments. Call like this ./fuzz_regression_test fuzz_harness corpus_dir\n");
return EXIT_FAILURE;
}
d = opendir(argv[2]);
if (!d) {
fprintf(stderr, "error opening dir %s\n", argv[2]);
return EXIT_FAILURE;
}
while ((dir = readdir(d)) != NULL) {
stat(dir->d_name, &path_stat);
if (!S_ISREG(path_stat.st_mode)) {
continue;
}
p = fork();
if (p == -1) {
fprintf(stderr, "fork failed\n");
return EXIT_FAILURE;
} else if (p == 0) {
input_fd = open(dir->d_name, O_RDONLY);
if (input_fd == -1) {
fprintf(stderr, "error opening input file %s\n", dir->d_name);
return EXIT_FAILURE;
}
dup2(input_fd, STDIN_FILENO);
execl(argv[1], argv[1], NULL);
return EXIT_SUCCESS;
}
rc = waitpid(p, &status, 0);
if (rc == -1) {
fprintf(stderr, "waitpid failed\n");
return EXIT_FAILURE;
}
if (!WIFEXITED(status)) {
fprintf(stderr, "test %s - %s failed\n", argv[1], dir->d_name);
return EXIT_FAILURE;
}
printf("test %s - %s successful\n", argv[1], dir->d_name);
}
closedir(d);
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,86 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "libyang.h"
int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
{
struct ly_ctx *ctx = NULL;
static bool log = false;
const char *schema_a =
"module defs {namespace urn:tests:defs;prefix d;yang-version 1.1;"
"identity crypto-alg; identity interface-type; identity ethernet {base interface-type;}"
"identity fast-ethernet {base ethernet;}}";
const char *schema_b =
"module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
"feature f; identity gigabit-ethernet { base defs:ethernet;}"
"container cont {leaf leaftarget {type empty;}"
"list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}}"
"leaf-list leaflisttarget {type uint8; max-elements 5;}}"
"list list {key id; leaf id {type string;} leaf value {type string;} leaf-list targets {type string;}}"
"list list2 {key \"id value\"; leaf id {type string;} leaf value {type string;}}"
"list list_inst {key id; leaf id {type instance-identifier {require-instance true;}} leaf value {type string;}}"
"list list_ident {key id; leaf id {type identityref {base defs:interface-type;}} leaf value {type string;}}"
"leaf-list leaflisttarget {type string;}"
"leaf binary {type binary {length 5 {error-message \"This base64 value must be of length 5.\";}}}"
"leaf binary-norestr {type binary;}"
"leaf int8 {type int8 {range 10..20;}}"
"leaf uint8 {type uint8 {range 150..200;}}"
"leaf int16 {type int16 {range -20..-10;}}"
"leaf uint16 {type uint16 {range 150..200;}}"
"leaf int32 {type int32;}"
"leaf uint32 {type uint32;}"
"leaf int64 {type int64;}"
"leaf uint64 {type uint64;}"
"leaf bits {type bits {bit zero; bit one {if-feature f;} bit two;}}"
"leaf enums {type enumeration {enum white; enum yellow {if-feature f;}}}"
"leaf dec64 {type decimal64 {fraction-digits 1; range 1.5..10;}}"
"leaf dec64-norestr {type decimal64 {fraction-digits 18;}}"
"leaf str {type string {length 8..10; pattern '[a-z ]*';}}"
"leaf str-norestr {type string;}"
"leaf str-utf8 {type string{length 2..5; pattern '€*';}}"
"leaf bool {type boolean;}"
"leaf empty {type empty;}"
"leaf ident {type identityref {base defs:interface-type;}}"
"leaf inst {type instance-identifier {require-instance true;}}"
"leaf inst-noreq {type instance-identifier {require-instance false;}}"
"leaf lref {type leafref {path /leaflisttarget; require-instance true;}}"
"leaf lref2 {type leafref {path \"../list[id = current()/../str-norestr]/targets\"; require-instance true;}}"
"leaf un1 {type union {"
"type leafref {path /int8; require-instance true;}"
"type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
"type string {length 1..20;}}}}";
char *data = NULL;
struct lyd_node *tree = NULL;
LY_ERR err;
if (!log) {
ly_log_options(0);
log = true;
}
err = ly_ctx_new(NULL, 0, &ctx);
if (err != LY_SUCCESS) {
fprintf(stderr, "Failed to create context\n");
exit(EXIT_FAILURE);
}
lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL);
lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL);
data = malloc(len + 1);
if (data == NULL) {
return 0;
}
memcpy(data, buf, len);
data[len] = 0;
lyd_parse_data_mem(ctx, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree);
lyd_free_all(tree);
ly_ctx_destroy(ctx);
free(data);
return 0;
}

View file

@ -0,0 +1,86 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "libyang.h"
int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
{
struct ly_ctx *ctx = NULL;
static bool log = false;
const char *schema_a =
"module defs {namespace urn:tests:defs;prefix d;yang-version 1.1;"
"identity crypto-alg; identity interface-type; identity ethernet {base interface-type;}"
"identity fast-ethernet {base ethernet;}}";
const char *schema_b =
"module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
"feature f; identity gigabit-ethernet { base defs:ethernet;}"
"container cont {leaf leaftarget {type empty;}"
"list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}}"
"leaf-list leaflisttarget {type uint8; max-elements 5;}}"
"list list {key id; leaf id {type string;} leaf value {type string;} leaf-list targets {type string;}}"
"list list2 {key \"id value\"; leaf id {type string;} leaf value {type string;}}"
"list list_inst {key id; leaf id {type instance-identifier {require-instance true;}} leaf value {type string;}}"
"list list_ident {key id; leaf id {type identityref {base defs:interface-type;}} leaf value {type string;}}"
"leaf-list leaflisttarget {type string;}"
"leaf binary {type binary {length 5 {error-message \"This base64 value must be of length 5.\";}}}"
"leaf binary-norestr {type binary;}"
"leaf int8 {type int8 {range 10..20;}}"
"leaf uint8 {type uint8 {range 150..200;}}"
"leaf int16 {type int16 {range -20..-10;}}"
"leaf uint16 {type uint16 {range 150..200;}}"
"leaf int32 {type int32;}"
"leaf uint32 {type uint32;}"
"leaf int64 {type int64;}"
"leaf uint64 {type uint64;}"
"leaf bits {type bits {bit zero; bit one {if-feature f;} bit two;}}"
"leaf enums {type enumeration {enum white; enum yellow {if-feature f;}}}"
"leaf dec64 {type decimal64 {fraction-digits 1; range 1.5..10;}}"
"leaf dec64-norestr {type decimal64 {fraction-digits 18;}}"
"leaf str {type string {length 8..10; pattern '[a-z ]*';}}"
"leaf str-norestr {type string;}"
"leaf str-utf8 {type string{length 2..5; pattern '€*';}}"
"leaf bool {type boolean;}"
"leaf empty {type empty;}"
"leaf ident {type identityref {base defs:interface-type;}}"
"leaf inst {type instance-identifier {require-instance true;}}"
"leaf inst-noreq {type instance-identifier {require-instance false;}}"
"leaf lref {type leafref {path /leaflisttarget; require-instance true;}}"
"leaf lref2 {type leafref {path \"../list[id = current()/../str-norestr]/targets\"; require-instance true;}}"
"leaf un1 {type union {"
"type leafref {path /int8; require-instance true;}"
"type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
"type string {length 1..20;}}}}";
char *data = NULL;
struct lyd_node *tree = NULL;
LY_ERR err;
if (!log) {
ly_log_options(0);
log = true;
}
err = ly_ctx_new(NULL, 0, &ctx);
if (err != LY_SUCCESS) {
fprintf(stderr, "Failed to create context\n");
exit(EXIT_FAILURE);
}
lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL);
lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL);
data = malloc(len + 1);
if (data == NULL) {
return 0;
}
memcpy(data, buf, len);
data[len] = 0;
lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree);
lyd_free_all(tree);
ly_ctx_destroy(ctx);
free(data);
return 0;
}

View file

@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "libyang.h"
int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
{
struct ly_ctx *ctx = NULL;
static bool log = false;
char *data = NULL;
LY_ERR err;
if (!log) {
ly_log_options(0);
log = true;
}
err = ly_ctx_new(NULL, 0, &ctx);
if (err != LY_SUCCESS) {
fprintf(stderr, "Failed to create context\n");
exit(EXIT_FAILURE);
}
data = malloc(len + 1);
if (data == NULL) {
return 0;
}
memcpy(data, buf, len);
data[len] = 0;
lys_parse_mem(ctx, data, LYS_IN_YANG, NULL);
ly_ctx_destroy(ctx);
free(data);
return 0;
}

47
tests/fuzz/main.c Normal file
View file

@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len);
#ifdef __AFL_COMPILER
int main(void) {
int ret;
uint8_t buf[64 * 1024];
#ifdef __AFL_LOOP
while (__AFL_LOOP(10000))
#endif
{
ret = fread(buf, 1, sizeof(buf), stdin);
if (ret < 0) {
return 0;
}
LLVMFuzzerTestOneInput(buf, ret);
}
return 0;
}
#else
int
main(void)
{
int ret;
uint8_t buf[64 * 1024];
ret = fread(buf, 1, sizeof(buf), stdin);
if (ret < 0) {
return 0;
}
LLVMFuzzerTestOneInput(buf, ret);
return 0;
}
#endif /* __AFL_COMPILER */

View file

@ -0,0 +1,39 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "libyang.h"
int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
{
struct lys_module *mod;
uint8_t *data = NULL;
struct ly_ctx *ctx = NULL;
static bool log = false;
LY_ERR err;
if (!log) {
ly_log_options(0);
log = true;
}
err = ly_ctx_new(NULL, 0, &ctx);
if (err != LY_SUCCESS) {
fprintf(stderr, "Failed to create new context\n");
return 0;
}
data = malloc(len + 1);
if (data == NULL) {
fprintf(stderr, "Out of memory\n");
return 0;
}
memcpy(data, buf, len);
data[len] = 0;
lys_parse_mem(ctx, (const char *)data, LYS_IN_YANG, &mod);
free(data);
ly_ctx_destroy(ctx);
return 0;
}

8
tests/ld.supp Normal file
View file

@ -0,0 +1,8 @@
{
dl's thread-local data
Memcheck:Leak
match-leak-kinds: reachable
fun:calloc
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,725 @@
module ietf-interfaces {
namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
prefix if;
import ietf-yang-types {
prefix yang;
}
organization
"IETF NETMOD (NETCONF Data Modeling Language) Working Group";
contact
"WG Web: <http://tools.ietf.org/wg/netmod/>
WG List: <mailto:netmod@ietf.org>
WG Chair: Thomas Nadeau
<mailto:tnadeau@lucidvision.com>
WG Chair: Juergen Schoenwaelder
<mailto:j.schoenwaelder@jacobs-university.de>
Editor: Martin Bjorklund
<mailto:mbj@tail-f.com>";
description
"This module contains a collection of YANG definitions for
managing network interfaces.
Copyright (c) 2014 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 7223; see
the RFC itself for full legal notices.";
revision 2014-05-08 {
description
"Initial revision.";
reference
"RFC 7223: A YANG Data Model for Interface Management";
}
/*
* Typedefs
*/
typedef interface-ref {
type leafref {
path "/if:interfaces/if:interface/if:name";
}
description
"This type is used by data models that need to reference
configured interfaces.";
}
typedef interface-state-ref {
type leafref {
path "/if:interfaces-state/if:interface/if:name";
}
description
"This type is used by data models that need to reference
the operationally present interfaces.";
}
/*
* Identities
*/
identity interface-type {
description
"Base identity from which specific interface types are
derived.";
}
/*
* Features
*/
feature arbitrary-names {
description
"This feature indicates that the device allows user-controlled
interfaces to be named arbitrarily.";
}
feature pre-provisioning {
description
"This feature indicates that the device supports
pre-provisioning of interface configuration, i.e., it is
possible to configure an interface whose physical interface
hardware is not present on the device.";
}
feature if-mib {
description
"This feature indicates that the device implements
the IF-MIB.";
reference
"RFC 2863: The Interfaces Group MIB";
}
/*
* Configuration data nodes
*/
container interfaces {
description
"Interface configuration parameters.";
list interface {
key "name";
description
"The list of configured interfaces on the device.
The operational state of an interface is available in the
/interfaces-state/interface list. If the configuration of a
system-controlled interface cannot be used by the system
(e.g., the interface hardware present does not match the
interface type), then the configuration is not applied to
the system-controlled interface shown in the
/interfaces-state/interface list. If the configuration
of a user-controlled interface cannot be used by the system,
the configured interface is not instantiated in the
/interfaces-state/interface list.";
leaf name {
type string;
description
"The name of the interface.
A device MAY restrict the allowed values for this leaf,
possibly depending on the type of the interface.
For system-controlled interfaces, this leaf is the
device-specific name of the interface. The 'config false'
list /interfaces-state/interface contains the currently
existing interfaces on the device.
If a client tries to create configuration for a
system-controlled interface that is not present in the
/interfaces-state/interface list, the server MAY reject
the request if the implementation does not support
pre-provisioning of interfaces or if the name refers to
an interface that can never exist in the system. A
NETCONF server MUST reply with an rpc-error with the
error-tag 'invalid-value' in this case.
If the device supports pre-provisioning of interface
configuration, the 'pre-provisioning' feature is
advertised.
If the device allows arbitrarily named user-controlled
interfaces, the 'arbitrary-names' feature is advertised.
When a configured user-controlled interface is created by
the system, it is instantiated with the same name in the
/interface-state/interface list.";
}
leaf description {
type string;
description
"A textual description of the interface.
A server implementation MAY map this leaf to the ifAlias
MIB object. Such an implementation needs to use some
mechanism to handle the differences in size and characters
allowed between this leaf and ifAlias. The definition of
such a mechanism is outside the scope of this document.
Since ifAlias is defined to be stored in non-volatile
storage, the MIB implementation MUST map ifAlias to the
value of 'description' in the persistently stored
datastore.
Specifically, if the device supports ':startup', when
ifAlias is read the device MUST return the value of
'description' in the 'startup' datastore, and when it is
written, it MUST be written to the 'running' and 'startup'
datastores. Note that it is up to the implementation to
decide whether to modify this single leaf in 'startup' or
perform an implicit copy-config from 'running' to
'startup'.
If the device does not support ':startup', ifAlias MUST
be mapped to the 'description' leaf in the 'running'
datastore.";
reference
"RFC 2863: The Interfaces Group MIB - ifAlias";
}
leaf type {
type identityref {
base interface-type;
}
mandatory true;
description
"The type of the interface.
When an interface entry is created, a server MAY
initialize the type leaf with a valid value, e.g., if it
is possible to derive the type from the name of the
interface.
If a client tries to set the type of an interface to a
value that can never be used by the system, e.g., if the
type is not supported or if the type does not match the
name of the interface, the server MUST reject the request.
A NETCONF server MUST reply with an rpc-error with the
error-tag 'invalid-value' in this case.";
reference
"RFC 2863: The Interfaces Group MIB - ifType";
}
leaf enabled {
type boolean;
default "true";
description
"This leaf contains the configured, desired state of the
interface.
Systems that implement the IF-MIB use the value of this
leaf in the 'running' datastore to set
IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry
has been initialized, as described in RFC 2863.
Changes in this leaf in the 'running' datastore are
reflected in ifAdminStatus, but if ifAdminStatus is
changed over SNMP, this leaf is not affected.";
reference
"RFC 2863: The Interfaces Group MIB - ifAdminStatus";
}
leaf link-up-down-trap-enable {
if-feature if-mib;
type enumeration {
enum enabled {
value 1;
}
enum disabled {
value 2;
}
}
description
"Controls whether linkUp/linkDown SNMP notifications
should be generated for this interface.
If this node is not configured, the value 'enabled' is
operationally used by the server for interfaces that do
not operate on top of any other interface (i.e., there are
no 'lower-layer-if' entries), and 'disabled' otherwise.";
reference
"RFC 2863: The Interfaces Group MIB -
ifLinkUpDownTrapEnable";
}
}
}
/*
* Operational state data nodes
*/
container interfaces-state {
config false;
description
"Data nodes for the operational state of interfaces.";
list interface {
key "name";
description
"The list of interfaces on the device.
System-controlled interfaces created by the system are
always present in this list, whether they are configured or
not.";
leaf name {
type string;
description
"The name of the interface.
A server implementation MAY map this leaf to the ifName
MIB object. Such an implementation needs to use some
mechanism to handle the differences in size and characters
allowed between this leaf and ifName. The definition of
such a mechanism is outside the scope of this document.";
reference
"RFC 2863: The Interfaces Group MIB - ifName";
}
leaf type {
type identityref {
base interface-type;
}
mandatory true;
description
"The type of the interface.";
reference
"RFC 2863: The Interfaces Group MIB - ifType";
}
leaf admin-status {
if-feature if-mib;
type enumeration {
enum up {
value 1;
description
"Ready to pass packets.";
}
enum down {
value 2;
description
"Not ready to pass packets and not in some test mode.";
}
enum testing {
value 3;
description
"In some test mode.";
}
}
mandatory true;
description
"The desired state of the interface.
This leaf has the same read semantics as ifAdminStatus.";
reference
"RFC 2863: The Interfaces Group MIB - ifAdminStatus";
}
leaf oper-status {
type enumeration {
enum up {
value 1;
description
"Ready to pass packets.";
}
enum down {
value 2;
description
"The interface does not pass any packets.";
}
enum testing {
value 3;
description
"In some test mode. No operational packets can
be passed.";
}
enum unknown {
value 4;
description
"Status cannot be determined for some reason.";
}
enum dormant {
value 5;
description
"Waiting for some external event.";
}
enum not-present {
value 6;
description
"Some component (typically hardware) is missing.";
}
enum lower-layer-down {
value 7;
description
"Down due to state of lower-layer interface(s).";
}
}
mandatory true;
description
"The current operational state of the interface.
This leaf has the same semantics as ifOperStatus.";
reference
"RFC 2863: The Interfaces Group MIB - ifOperStatus";
}
leaf last-change {
type yang:date-and-time;
description
"The time the interface entered its current operational
state. If the current state was entered prior to the
last re-initialization of the local network management
subsystem, then this node is not present.";
reference
"RFC 2863: The Interfaces Group MIB - ifLastChange";
}
leaf if-index {
if-feature if-mib;
type int32 {
range "1..2147483647";
}
mandatory true;
description
"The ifIndex value for the ifEntry represented by this
interface.";
reference
"RFC 2863: The Interfaces Group MIB - ifIndex";
}
leaf phys-address {
type yang:phys-address;
description
"The interface's address at its protocol sub-layer. For
example, for an 802.x interface, this object normally
contains a Media Access Control (MAC) address. The
interface's media-specific modules must define the bit
and byte ordering and the format of the value of this
object. For interfaces that do not have such an address
(e.g., a serial line), this node is not present.";
reference
"RFC 2863: The Interfaces Group MIB - ifPhysAddress";
}
leaf-list higher-layer-if {
type interface-state-ref;
description
"A list of references to interfaces layered on top of this
interface.";
reference
"RFC 2863: The Interfaces Group MIB - ifStackTable";
}
leaf-list lower-layer-if {
type interface-state-ref;
description
"A list of references to interfaces layered underneath this
interface.";
reference
"RFC 2863: The Interfaces Group MIB - ifStackTable";
}
leaf speed {
type yang:gauge64;
units "bits/second";
description
"An estimate of the interface's current bandwidth in bits
per second. For interfaces that do not vary in
bandwidth or for those where no accurate estimation can
be made, this node should contain the nominal bandwidth.
For interfaces that have no concept of bandwidth, this
node is not present.";
reference
"RFC 2863: The Interfaces Group MIB -
ifSpeed, ifHighSpeed";
}
container statistics {
description
"A collection of interface-related statistics objects.";
leaf discontinuity-time {
type yang:date-and-time;
mandatory true;
description
"The time on the most recent occasion at which any one or
more of this interface's counters suffered a
discontinuity. If no such discontinuities have occurred
since the last re-initialization of the local management
subsystem, then this node contains the time the local
management subsystem re-initialized itself.";
}
leaf in-octets {
type yang:counter64;
description
"The total number of octets received on the interface,
including framing characters.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifHCInOctets";
}
leaf in-unicast-pkts {
type yang:counter64;
description
"The number of packets, delivered by this sub-layer to a
higher (sub-)layer, that were not addressed to a
multicast or broadcast address at this sub-layer.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts";
}
leaf in-broadcast-pkts {
type yang:counter64;
description
"The number of packets, delivered by this sub-layer to a
higher (sub-)layer, that were addressed to a broadcast
address at this sub-layer.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB -
ifHCInBroadcastPkts";
}
leaf in-multicast-pkts {
type yang:counter64;
description
"The number of packets, delivered by this sub-layer to a
higher (sub-)layer, that were addressed to a multicast
address at this sub-layer. For a MAC-layer protocol,
this includes both Group and Functional addresses.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB -
ifHCInMulticastPkts";
}
leaf in-discards {
type yang:counter32;
description
"The number of inbound packets that were chosen to be
discarded even though no errors had been detected to
prevent their being deliverable to a higher-layer
protocol. One possible reason for discarding such a
packet could be to free up buffer space.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifInDiscards";
}
leaf in-errors {
type yang:counter32;
description
"For packet-oriented interfaces, the number of inbound
packets that contained errors preventing them from being
deliverable to a higher-layer protocol. For character-
oriented or fixed-length interfaces, the number of
inbound transmission units that contained errors
preventing them from being deliverable to a higher-layer
protocol.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifInErrors";
}
leaf in-unknown-protos {
type yang:counter32;
description
"For packet-oriented interfaces, the number of packets
received via the interface that were discarded because
of an unknown or unsupported protocol. For
character-oriented or fixed-length interfaces that
support protocol multiplexing, the number of
transmission units received via the interface that were
discarded because of an unknown or unsupported protocol.
For any interface that does not support protocol
multiplexing, this counter is not present.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifInUnknownProtos";
}
leaf out-octets {
type yang:counter64;
description
"The total number of octets transmitted out of the
interface, including framing characters.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifHCOutOctets";
}
leaf out-unicast-pkts {
type yang:counter64;
description
"The total number of packets that higher-level protocols
requested be transmitted, and that were not addressed
to a multicast or broadcast address at this sub-layer,
including those that were discarded or not sent.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts";
}
leaf out-broadcast-pkts {
type yang:counter64;
description
"The total number of packets that higher-level protocols
requested be transmitted, and that were addressed to a
broadcast address at this sub-layer, including those
that were discarded or not sent.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB -
ifHCOutBroadcastPkts";
}
leaf out-multicast-pkts {
type yang:counter64;
description
"The total number of packets that higher-level protocols
requested be transmitted, and that were addressed to a
multicast address at this sub-layer, including those
that were discarded or not sent. For a MAC-layer
protocol, this includes both Group and Functional
addresses.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB -
ifHCOutMulticastPkts";
}
leaf out-discards {
type yang:counter32;
description
"The number of outbound packets that were chosen to be
discarded even though no errors had been detected to
prevent their being transmitted. One possible reason
for discarding such a packet could be to free up buffer
space.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifOutDiscards";
}
leaf out-errors {
type yang:counter32;
description
"For packet-oriented interfaces, the number of outbound
packets that could not be transmitted because of errors.
For character-oriented or fixed-length interfaces, the
number of outbound transmission units that could not be
transmitted because of errors.
Discontinuities in the value of this counter can occur
at re-initialization of the management system, and at
other times as indicated by the value of
'discontinuity-time'.";
reference
"RFC 2863: The Interfaces Group MIB - ifOutErrors";
}
}
}
}
}

View file

@ -0,0 +1,758 @@
module ietf-ip {
namespace "urn:ietf:params:xml:ns:yang:ietf-ip";
prefix ip;
import ietf-interfaces {
prefix if;
}
import ietf-inet-types {
prefix inet;
}
import ietf-yang-types {
prefix yang;
}
organization
"IETF NETMOD (NETCONF Data Modeling Language) Working Group";
contact
"WG Web: <http://tools.ietf.org/wg/netmod/>
WG List: <mailto:netmod@ietf.org>
WG Chair: Thomas Nadeau
<mailto:tnadeau@lucidvision.com>
WG Chair: Juergen Schoenwaelder
<mailto:j.schoenwaelder@jacobs-university.de>
Editor: Martin Bjorklund
<mailto:mbj@tail-f.com>";
description
"This module contains a collection of YANG definitions for
configuring IP implementations.
Copyright (c) 2014 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 7277; see
the RFC itself for full legal notices.";
revision 2014-06-16 {
description
"Initial revision.";
reference
"RFC 7277: A YANG Data Model for IP Management";
}
/*
* Features
*/
feature ipv4-non-contiguous-netmasks {
description
"Indicates support for configuring non-contiguous
subnet masks.";
}
feature ipv6-privacy-autoconf {
description
"Indicates support for Privacy Extensions for Stateless Address
Autoconfiguration in IPv6.";
reference
"RFC 4941: Privacy Extensions for Stateless Address
Autoconfiguration in IPv6";
}
/*
* Typedefs
*/
typedef ip-address-origin {
type enumeration {
enum other {
description
"None of the following.";
}
enum static {
description
"Indicates that the address has been statically
configured - for example, using NETCONF or a Command Line
Interface.";
}
enum dhcp {
description
"Indicates an address that has been assigned to this
system by a DHCP server.";
}
enum link-layer {
description
"Indicates an address created by IPv6 stateless
autoconfiguration that embeds a link-layer address in its
interface identifier.";
}
enum random {
description
"Indicates an address chosen by the system at
random, e.g., an IPv4 address within 169.254/16, an
RFC 4941 temporary address, or an RFC 7217 semantically
opaque address.";
reference
"RFC 4941: Privacy Extensions for Stateless Address
Autoconfiguration in IPv6
RFC 7217: A Method for Generating Semantically Opaque
Interface Identifiers with IPv6 Stateless
Address Autoconfiguration (SLAAC)";
}
}
description
"The origin of an address.";
}
typedef neighbor-origin {
type enumeration {
enum other {
description
"None of the following.";
}
enum static {
description
"Indicates that the mapping has been statically
configured - for example, using NETCONF or a Command Line
Interface.";
}
enum dynamic {
description
"Indicates that the mapping has been dynamically resolved
using, e.g., IPv4 ARP or the IPv6 Neighbor Discovery
protocol.";
}
}
description
"The origin of a neighbor entry.";
}
/*
* Configuration data nodes
*/
augment "/if:interfaces/if:interface" {
description
"Parameters for configuring IP on interfaces.
If an interface is not capable of running IP, the server
must not allow the client to configure these parameters.";
container ipv4 {
presence
"Enables IPv4 unless the 'enabled' leaf
(which defaults to 'true') is set to 'false'";
description
"Parameters for the IPv4 address family.";
leaf enabled {
type boolean;
default true;
description
"Controls whether IPv4 is enabled or disabled on this
interface. When IPv4 is enabled, this interface is
connected to an IPv4 stack, and the interface can send
and receive IPv4 packets.";
}
leaf forwarding {
type boolean;
default false;
description
"Controls IPv4 packet forwarding of datagrams received by,
but not addressed to, this interface. IPv4 routers
forward datagrams. IPv4 hosts do not (except those
source-routed via the host).";
}
leaf mtu {
type uint16 {
range "68..max";
}
units octets;
description
"The size, in octets, of the largest IPv4 packet that the
interface will send and receive.
The server may restrict the allowed values for this leaf,
depending on the interface's type.
If this leaf is not configured, the operationally used MTU
depends on the interface's type.";
reference
"RFC 791: Internet Protocol";
}
list address {
key "ip";
description
"The list of configured IPv4 addresses on the interface.";
leaf ip {
type inet:ipv4-address-no-zone;
description
"The IPv4 address on the interface.";
}
choice subnet {
mandatory true;
description
"The subnet can be specified as a prefix-length, or,
if the server supports non-contiguous netmasks, as
a netmask.";
leaf prefix-length {
type uint8 {
range "0..32";
}
description
"The length of the subnet prefix.";
}
leaf netmask {
if-feature ipv4-non-contiguous-netmasks;
type yang:dotted-quad;
description
"The subnet specified as a netmask.";
}
}
}
list neighbor {
key "ip";
description
"A list of mappings from IPv4 addresses to
link-layer addresses.
Entries in this list are used as static entries in the
ARP Cache.";
reference
"RFC 826: An Ethernet Address Resolution Protocol";
leaf ip {
type inet:ipv4-address-no-zone;
description
"The IPv4 address of the neighbor node.";
}
leaf link-layer-address {
type yang:phys-address;
mandatory true;
description
"The link-layer address of the neighbor node.";
}
}
}
container ipv6 {
presence
"Enables IPv6 unless the 'enabled' leaf
(which defaults to 'true') is set to 'false'";
description
"Parameters for the IPv6 address family.";
leaf enabled {
type boolean;
default true;
description
"Controls whether IPv6 is enabled or disabled on this
interface. When IPv6 is enabled, this interface is
connected to an IPv6 stack, and the interface can send
and receive IPv6 packets.";
}
leaf forwarding {
type boolean;
default false;
description
"Controls IPv6 packet forwarding of datagrams received by,
but not addressed to, this interface. IPv6 routers
forward datagrams. IPv6 hosts do not (except those
source-routed via the host).";
reference
"RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
Section 6.2.1, IsRouter";
}
leaf mtu {
type uint32 {
range "1280..max";
}
units octets;
description
"The size, in octets, of the largest IPv6 packet that the
interface will send and receive.
The server may restrict the allowed values for this leaf,
depending on the interface's type.
If this leaf is not configured, the operationally used MTU
depends on the interface's type.";
reference
"RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
Section 5";
}
list address {
key "ip";
description
"The list of configured IPv6 addresses on the interface.";
leaf ip {
type inet:ipv6-address-no-zone;
description
"The IPv6 address on the interface.";
}
leaf prefix-length {
type uint8 {
range "0..128";
}
mandatory true;
description
"The length of the subnet prefix.";
}
}
list neighbor {
key "ip";
description
"A list of mappings from IPv6 addresses to
link-layer addresses.
Entries in this list are used as static entries in the
Neighbor Cache.";
reference
"RFC 4861: Neighbor Discovery for IP version 6 (IPv6)";
leaf ip {
type inet:ipv6-address-no-zone;
description
"The IPv6 address of the neighbor node.";
}
leaf link-layer-address {
type yang:phys-address;
mandatory true;
description
"The link-layer address of the neighbor node.";
}
}
leaf dup-addr-detect-transmits {
type uint32;
default 1;
description
"The number of consecutive Neighbor Solicitation messages
sent while performing Duplicate Address Detection on a
tentative address. A value of zero indicates that
Duplicate Address Detection is not performed on
tentative addresses. A value of one indicates a single
transmission with no follow-up retransmissions.";
reference
"RFC 4862: IPv6 Stateless Address Autoconfiguration";
}
container autoconf {
description
"Parameters to control the autoconfiguration of IPv6
addresses, as described in RFC 4862.";
reference
"RFC 4862: IPv6 Stateless Address Autoconfiguration";
leaf create-global-addresses {
type boolean;
default true;
description
"If enabled, the host creates global addresses as
described in RFC 4862.";
reference
"RFC 4862: IPv6 Stateless Address Autoconfiguration
Section 5.5";
}
leaf create-temporary-addresses {
if-feature ipv6-privacy-autoconf;
type boolean;
default false;
description
"If enabled, the host creates temporary addresses as
described in RFC 4941.";
reference
"RFC 4941: Privacy Extensions for Stateless Address
Autoconfiguration in IPv6";
}
leaf temporary-valid-lifetime {
if-feature ipv6-privacy-autoconf;
type uint32;
units "seconds";
default 604800;
description
"The time period during which the temporary address
is valid.";
reference
"RFC 4941: Privacy Extensions for Stateless Address
Autoconfiguration in IPv6
- TEMP_VALID_LIFETIME";
}
leaf temporary-preferred-lifetime {
if-feature ipv6-privacy-autoconf;
type uint32;
units "seconds";
default 86400;
description
"The time period during which the temporary address is
preferred.";
reference
"RFC 4941: Privacy Extensions for Stateless Address
Autoconfiguration in IPv6
- TEMP_PREFERRED_LIFETIME";
}
}
}
}
/*
* Operational state data nodes
*/
augment "/if:interfaces-state/if:interface" {
description
"Data nodes for the operational state of IP on interfaces.";
container ipv4 {
presence "Present if IPv4 is enabled on this interface";
config false;
description
"Interface-specific parameters for the IPv4 address family.";
leaf forwarding {
type boolean;
description
"Indicates whether IPv4 packet forwarding is enabled or
disabled on this interface.";
}
leaf mtu {
type uint16 {
range "68..max";
}
units octets;
description
"The size, in octets, of the largest IPv4 packet that the
interface will send and receive.";
reference
"RFC 791: Internet Protocol";
}
list address {
key "ip";
description
"The list of IPv4 addresses on the interface.";
leaf ip {
type inet:ipv4-address-no-zone;
description
"The IPv4 address on the interface.";
}
choice subnet {
description
"The subnet can be specified as a prefix-length, or,
if the server supports non-contiguous netmasks, as
a netmask.";
leaf prefix-length {
type uint8 {
range "0..32";
}
description
"The length of the subnet prefix.";
}
leaf netmask {
if-feature ipv4-non-contiguous-netmasks;
type yang:dotted-quad;
description
"The subnet specified as a netmask.";
}
}
leaf origin {
type ip-address-origin;
description
"The origin of this address.";
}
}
list neighbor {
key "ip";
description
"A list of mappings from IPv4 addresses to
link-layer addresses.
This list represents the ARP Cache.";
reference
"RFC 826: An Ethernet Address Resolution Protocol";
leaf ip {
type inet:ipv4-address-no-zone;
description
"The IPv4 address of the neighbor node.";
}
leaf link-layer-address {
type yang:phys-address;
description
"The link-layer address of the neighbor node.";
}
leaf origin {
type neighbor-origin;
description
"The origin of this neighbor entry.";
}
}
}
container ipv6 {
presence "Present if IPv6 is enabled on this interface";
config false;
description
"Parameters for the IPv6 address family.";
leaf forwarding {
type boolean;
default false;
description
"Indicates whether IPv6 packet forwarding is enabled or
disabled on this interface.";
reference
"RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
Section 6.2.1, IsRouter";
}
leaf mtu {
type uint32 {
range "1280..max";
}
units octets;
description
"The size, in octets, of the largest IPv6 packet that the
interface will send and receive.";
reference
"RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
Section 5";
}
list address {
key "ip";
description
"The list of IPv6 addresses on the interface.";
leaf ip {
type inet:ipv6-address-no-zone;
description
"The IPv6 address on the interface.";
}
leaf prefix-length {
type uint8 {
range "0..128";
}
mandatory true;
description
"The length of the subnet prefix.";
}
leaf origin {
type ip-address-origin;
description
"The origin of this address.";
}
leaf status {
type enumeration {
enum preferred {
description
"This is a valid address that can appear as the
destination or source address of a packet.";
}
enum deprecated {
description
"This is a valid but deprecated address that should
no longer be used as a source address in new
communications, but packets addressed to such an
address are processed as expected.";
}
enum invalid {
description
"This isn't a valid address, and it shouldn't appear
as the destination or source address of a packet.";
}
enum inaccessible {
description
"The address is not accessible because the interface
to which this address is assigned is not
operational.";
}
enum unknown {
description
"The status cannot be determined for some reason.";
}
enum tentative {
description
"The uniqueness of the address on the link is being
verified. Addresses in this state should not be
used for general communication and should only be
used to determine the uniqueness of the address.";
}
enum duplicate {
description
"The address has been determined to be non-unique on
the link and so must not be used.";
}
enum optimistic {
description
"The address is available for use, subject to
restrictions, while its uniqueness on a link is
being verified.";
}
}
description
"The status of an address. Most of the states correspond
to states from the IPv6 Stateless Address
Autoconfiguration protocol.";
reference
"RFC 4293: Management Information Base for the
Internet Protocol (IP)
- IpAddressStatusTC
RFC 4862: IPv6 Stateless Address Autoconfiguration";
}
}
list neighbor {
key "ip";
description
"A list of mappings from IPv6 addresses to
link-layer addresses.
This list represents the Neighbor Cache.";
reference
"RFC 4861: Neighbor Discovery for IP version 6 (IPv6)";
leaf ip {
type inet:ipv6-address-no-zone;
description
"The IPv6 address of the neighbor node.";
}
leaf link-layer-address {
type yang:phys-address;
description
"The link-layer address of the neighbor node.";
}
leaf origin {
type neighbor-origin;
description
"The origin of this neighbor entry.";
}
leaf is-router {
type empty;
description
"Indicates that the neighbor node acts as a router.";
}
leaf state {
type enumeration {
enum incomplete {
description
"Address resolution is in progress, and the link-layer
address of the neighbor has not yet been
determined.";
}
enum reachable {
description
"Roughly speaking, the neighbor is known to have been
reachable recently (within tens of seconds ago).";
}
enum stale {
description
"The neighbor is no longer known to be reachable, but
until traffic is sent to the neighbor no attempt
should be made to verify its reachability.";
}
enum delay {
description
"The neighbor is no longer known to be reachable, and
traffic has recently been sent to the neighbor.
Rather than probe the neighbor immediately, however,
delay sending probes for a short while in order to
give upper-layer protocols a chance to provide
reachability confirmation.";
}
enum probe {
description
"The neighbor is no longer known to be reachable, and
unicast Neighbor Solicitation probes are being sent
to verify reachability.";
}
}
description
"The Neighbor Unreachability Detection state of this
entry.";
reference
"RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
Section 7.3.2";
}
}
}
}
}

View file

@ -0,0 +1,464 @@
module ietf-netconf-acm {
namespace "urn:ietf:params:xml:ns:yang:ietf-netconf-acm";
prefix nacm;
import ietf-yang-types {
prefix yang;
}
organization
"IETF NETCONF (Network Configuration) Working Group";
contact
"WG Web: <https://datatracker.ietf.org/wg/netconf/>
WG List: <mailto:netconf@ietf.org>
Author: Andy Bierman
<mailto:andy@yumaworks.com>
Author: Martin Bjorklund
<mailto:mbj@tail-f.com>";
description
"Network Configuration Access Control Model.
Copyright (c) 2012 - 2018 IETF Trust and the persons
identified as authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD
License set forth in Section 4.c of the IETF Trust's
Legal Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 8341; see
the RFC itself for full legal notices.";
revision "2018-02-14" {
description
"Added support for YANG 1.1 actions and notifications tied to
data nodes. Clarified how NACM extensions can be used by
other data models.";
reference
"RFC 8341: Network Configuration Access Control Model";
}
revision "2012-02-22" {
description
"Initial version.";
reference
"RFC 6536: Network Configuration Protocol (NETCONF)
Access Control Model";
}
/*
* Extension statements
*/
extension default-deny-write {
description
"Used to indicate that the data model node
represents a sensitive security system parameter.
If present, the NETCONF server will only allow the designated
'recovery session' to have write access to the node. An
explicit access control rule is required for all other users.
If the NACM module is used, then it must be enabled (i.e.,
/nacm/enable-nacm object equals 'true'), or this extension
is ignored.
The 'default-deny-write' extension MAY appear within a data
definition statement. It is ignored otherwise.";
}
extension default-deny-all {
description
"Used to indicate that the data model node
controls a very sensitive security system parameter.
If present, the NETCONF server will only allow the designated
'recovery session' to have read, write, or execute access to
the node. An explicit access control rule is required for all
other users.
If the NACM module is used, then it must be enabled (i.e.,
/nacm/enable-nacm object equals 'true'), or this extension
is ignored.
The 'default-deny-all' extension MAY appear within a data
definition statement, 'rpc' statement, or 'notification'
statement. It is ignored otherwise.";
}
/*
* Derived types
*/
typedef user-name-type {
type string {
length "1..max";
}
description
"General-purpose username string.";
}
typedef matchall-string-type {
type string {
pattern '\*';
}
description
"The string containing a single asterisk '*' is used
to conceptually represent all possible values
for the particular leaf using this data type.";
}
typedef access-operations-type {
type bits {
bit create {
description
"Any protocol operation that creates a
new data node.";
}
bit read {
description
"Any protocol operation or notification that
returns the value of a data node.";
}
bit update {
description
"Any protocol operation that alters an existing
data node.";
}
bit delete {
description
"Any protocol operation that removes a data node.";
}
bit exec {
description
"Execution access to the specified protocol operation.";
}
}
description
"Access operation.";
}
typedef group-name-type {
type string {
length "1..max";
pattern '[^\*].*';
}
description
"Name of administrative group to which
users can be assigned.";
}
typedef action-type {
type enumeration {
enum permit {
description
"Requested action is permitted.";
}
enum deny {
description
"Requested action is denied.";
}
}
description
"Action taken by the server when a particular
rule matches.";
}
typedef node-instance-identifier {
type yang:xpath1.0;
description
"Path expression used to represent a special
data node, action, or notification instance-identifier
string.
A node-instance-identifier value is an
unrestricted YANG instance-identifier expression.
All the same rules as an instance-identifier apply,
except that predicates for keys are optional. If a key
predicate is missing, then the node-instance-identifier
represents all possible server instances for that key.
This XML Path Language (XPath) expression is evaluated in the
following context:
o The set of namespace declarations are those in scope on
the leaf element where this type is used.
o The set of variable bindings contains one variable,
'USER', which contains the name of the user of the
current session.
o The function library is the core function library, but
note that due to the syntax restrictions of an
instance-identifier, no functions are allowed.
o The context node is the root node in the data tree.
The accessible tree includes actions and notifications tied
to data nodes.";
}
/*
* Data definition statements
*/
container nacm {
nacm:default-deny-all;
description
"Parameters for NETCONF access control model.";
leaf enable-nacm {
type boolean;
default "true";
description
"Enables or disables all NETCONF access control
enforcement. If 'true', then enforcement
is enabled. If 'false', then enforcement
is disabled.";
}
leaf read-default {
type action-type;
default "permit";
description
"Controls whether read access is granted if
no appropriate rule is found for a
particular read request.";
}
leaf write-default {
type action-type;
default "deny";
description
"Controls whether create, update, or delete access
is granted if no appropriate rule is found for a
particular write request.";
}
leaf exec-default {
type action-type;
default "permit";
description
"Controls whether exec access is granted if no appropriate
rule is found for a particular protocol operation request.";
}
leaf enable-external-groups {
type boolean;
default "true";
description
"Controls whether the server uses the groups reported by the
NETCONF transport layer when it assigns the user to a set of
NACM groups. If this leaf has the value 'false', any group
names reported by the transport layer are ignored by the
server.";
}
leaf denied-operations {
type yang:zero-based-counter32;
config false;
mandatory true;
description
"Number of times since the server last restarted that a
protocol operation request was denied.";
}
leaf denied-data-writes {
type yang:zero-based-counter32;
config false;
mandatory true;
description
"Number of times since the server last restarted that a
protocol operation request to alter
a configuration datastore was denied.";
}
leaf denied-notifications {
type yang:zero-based-counter32;
config false;
mandatory true;
description
"Number of times since the server last restarted that
a notification was dropped for a subscription because
access to the event type was denied.";
}
container groups {
description
"NETCONF access control groups.";
list group {
key name;
description
"One NACM group entry. This list will only contain
configured entries, not any entries learned from
any transport protocols.";
leaf name {
type group-name-type;
description
"Group name associated with this entry.";
}
leaf-list user-name {
type user-name-type;
description
"Each entry identifies the username of
a member of the group associated with
this entry.";
}
}
}
list rule-list {
key name;
ordered-by user;
description
"An ordered collection of access control rules.";
leaf name {
type string {
length "1..max";
}
description
"Arbitrary name assigned to the rule-list.";
}
leaf-list group {
type union {
type matchall-string-type;
type group-name-type;
}
description
"List of administrative groups that will be
assigned the associated access rights
defined by the 'rule' list.
The string '*' indicates that all groups apply to the
entry.";
}
list rule {
key name;
ordered-by user;
description
"One access control rule.
Rules are processed in user-defined order until a match is
found. A rule matches if 'module-name', 'rule-type', and
'access-operations' match the request. If a rule
matches, the 'action' leaf determines whether or not
access is granted.";
leaf name {
type string {
length "1..max";
}
description
"Arbitrary name assigned to the rule.";
}
leaf module-name {
type union {
type matchall-string-type;
type string;
}
default "*";
description
"Name of the module associated with this rule.
This leaf matches if it has the value '*' or if the
object being accessed is defined in the module with the
specified module name.";
}
choice rule-type {
description
"This choice matches if all leafs present in the rule
match the request. If no leafs are present, the
choice matches all requests.";
case protocol-operation {
leaf rpc-name {
type union {
type matchall-string-type;
type string;
}
description
"This leaf matches if it has the value '*' or if
its value equals the requested protocol operation
name.";
}
}
case notification {
leaf notification-name {
type union {
type matchall-string-type;
type string;
}
description
"This leaf matches if it has the value '*' or if its
value equals the requested notification name.";
}
}
case data-node {
leaf path {
type node-instance-identifier;
mandatory true;
description
"Data node instance-identifier associated with the
data node, action, or notification controlled by
this rule.
Configuration data or state data
instance-identifiers start with a top-level
data node. A complete instance-identifier is
required for this type of path value.
The special value '/' refers to all possible
datastore contents.";
}
}
}
leaf access-operations {
type union {
type matchall-string-type;
type access-operations-type;
}
default "*";
description
"Access operations associated with this rule.
This leaf matches if it has the value '*' or if the
bit corresponding to the requested operation is set.";
}
leaf action {
type action-type;
mandatory true;
description
"The access control action associated with the
rule. If a rule has been determined to match a
particular request, then this object is used
to determine whether to permit or deny the
request.";
}
leaf comment {
type string;
description
"A textual description of the access rule.";
}
}
}
}
}

View file

@ -0,0 +1,385 @@
module ietf-netconf-nmda {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:ietf-netconf-nmda";
prefix ncds;
import ietf-yang-types {
prefix yang;
reference
"RFC 6991: Common YANG Data Types";
}
import ietf-inet-types {
prefix inet;
reference
"RFC 6991: Common YANG Data Types";
}
import ietf-datastores {
prefix ds;
reference
"RFC 8342: Network Management Datastore Architecture
(NMDA)";
}
import ietf-origin {
prefix or;
reference
"RFC 8342: Network Management Datastore Architecture
(NMDA)";
}
import ietf-netconf {
prefix nc;
reference
"RFC 6241: Network Configuration Protocol (NETCONF)";
}
import ietf-netconf-with-defaults {
prefix ncwd;
reference
"RFC 6243: With-defaults Capability for NETCONF";
}
organization
"IETF NETCONF Working Group";
contact
"WG Web: <https://datatracker.ietf.org/wg/netconf/>
WG List: <mailto:netconf@ietf.org>
Author: Martin Bjorklund
<mailto:mbj@tail-f.com>
Author: Juergen Schoenwaelder
<mailto:j.schoenwaelder@jacobs-university.de>
Author: Phil Shafer
<mailto:phil@juniper.net>
Author: Kent Watsen
<mailto:kent+ietf@watsen.net>
Author: Robert Wilton
<mailto:rwilton@cisco.com>";
description
"This YANG module defines a set of NETCONF operations to support
the Network Management Datastore Architecture (NMDA).
The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
'MAY', and 'OPTIONAL' in this document are to be interpreted as
described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
they appear in all capitals, as shown here.
Copyright (c) 2019 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject to
the license terms contained in, the Simplified BSD License set
forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(https://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 8526; see
the RFC itself for full legal notices.";
revision 2019-01-07 {
description
"Initial revision.";
reference
"RFC 8526: NETCONF Extensions to Support the Network Management
Datastore Architecture";
}
feature origin {
description
"Indicates that the server supports the 'origin' annotation.";
reference
"RFC 8342: Network Management Datastore Architecture (NMDA)";
}
feature with-defaults {
description
"NETCONF :with-defaults capability. If the server advertises
the :with-defaults capability for a session, then this
feature must also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference
"RFC 6243: With-defaults Capability for NETCONF, Section 4; and
RFC 8526: NETCONF Extensions to Support the Network Management
Datastore Architecture, Section 3.1.1.2";
}
rpc get-data {
description
"Retrieve data from an NMDA datastore. The content returned
by get-data must satisfy all filters, i.e., the filter
criteria are logically ANDed.
Any ancestor nodes (including list keys) of nodes selected by
the filters are included in the response.
The 'with-origin' parameter is only valid for an operational
datastore. If 'with-origin' is used with an invalid
datastore, then the server MUST return an <rpc-error> element
with an <error-tag> value of 'invalid-value'.
The 'with-defaults' parameter only applies to the operational
datastore if the NETCONF :with-defaults and
:with-operational-defaults capabilities are both advertised.
If the 'with-defaults' parameter is present in a request for
which it is not supported, then the server MUST return an
<rpc-error> element with an <error-tag> value of
'invalid-value'.";
input {
leaf datastore {
type ds:datastore-ref;
mandatory true;
description
"Datastore from which to retrieve data.
If the datastore is not supported by the server, then the
server MUST return an <rpc-error> element with an
<error-tag> value of 'invalid-value'.";
}
choice filter-spec {
description
"The content filter specification for this request.";
anydata subtree-filter {
description
"This parameter identifies the portions of the
target datastore to retrieve.";
reference
"RFC 6241: Network Configuration Protocol (NETCONF),
Section 6";
}
leaf xpath-filter {
if-feature "nc:xpath";
type yang:xpath1.0;
description
"This parameter contains an XPath expression identifying
the portions of the target datastore to retrieve.
If the expression returns a node-set, all nodes in the
node-set are selected by the filter. Otherwise, if the
expression does not return a node-set, then the
<get-data> operation fails.
The expression is evaluated in the following XPath
context:
o The set of namespace declarations are those in
scope on the 'xpath-filter' leaf element.
o The set of variable bindings is empty.
o The function library is the core function library,
and the XPath functions are defined in Section 10
of RFC 7950.
o The context node is the root node of the target
datastore.";
}
}
leaf config-filter {
type boolean;
description
"Filter for nodes with the given value for their 'config'
property. When this leaf is set to 'true', only 'config
true' nodes are selected, and when set to 'false', only
'config false' nodes are selected. If this leaf is not
present, no nodes are filtered.";
}
choice origin-filters {
when 'derived-from-or-self(datastore, "ds:operational")';
if-feature "origin";
description
"Filters configuration nodes based on the 'origin'
annotation. Configuration nodes that do not have an
'origin' annotation are treated as if they have the
'origin' annotation 'or:unknown'.
System state nodes are not affected by origin-filters and
thus not filtered. Note that system state nodes can be
filtered with the 'config-filter' leaf.";
leaf-list origin-filter {
type or:origin-ref;
description
"Filter based on the 'origin' annotation. A
configuration node matches the filter if its 'origin'
annotation is derived from or equal to any of the given
filter values.";
}
leaf-list negated-origin-filter {
type or:origin-ref;
description
"Filter based on the 'origin' annotation. A
configuration node matches the filter if its 'origin'
annotation is neither derived from nor equal to any of
the given filter values.";
}
}
leaf max-depth {
type union {
type uint16 {
range "1..65535";
}
type enumeration {
enum unbounded {
description
"All descendant nodes are included.";
}
}
}
default "unbounded";
description
"For each node selected by the filters, this parameter
selects how many conceptual subtree levels should be
returned in the reply. If the depth is 1, the reply
includes just the selected nodes but no children. If the
depth is 'unbounded', all descendant nodes are included.";
}
leaf with-origin {
when 'derived-from-or-self(../datastore, "ds:operational")';
if-feature "origin";
type empty;
description
"If this parameter is present, the server will return
the 'origin' annotation for the nodes that have one.";
}
uses ncwd:with-defaults-parameters {
if-feature "with-defaults";
}
}
output {
anydata data {
description
"Copy of the source datastore subset that matched
the filter criteria (if any). An empty data
container indicates that the request did not
produce any results.";
}
}
}
rpc edit-data {
description
"Edit data in an NMDA datastore.
If an error condition occurs such that an error severity
<rpc-error> element is generated, the server will stop
processing the <edit-data> operation and restore the
specified configuration to its complete state at
the start of this <edit-data> operation.";
input {
leaf datastore {
type ds:datastore-ref;
mandatory true;
description
"Datastore that is the target of the <edit-data> operation.
If the target datastore is not writable, or is not
supported by the server, then the server MUST return an
<rpc-error> element with an <error-tag> value of
'invalid-value'.";
}
leaf default-operation {
type enumeration {
enum merge {
description
"The default operation is merge.";
}
enum replace {
description
"The default operation is replace.";
}
enum none {
description
"There is no default operation.";
}
}
default "merge";
description
"The default operation to use.";
}
choice edit-content {
mandatory true;
description
"The content for the edit operation.";
anydata config {
description
"Inline config content.";
}
leaf url {
if-feature "nc:url";
type inet:uri;
description
"URL-based config content.";
}
}
}
}
/*
* Augment the <lock> and <unlock> operations with a
* "datastore" parameter.
*/
augment "/nc:lock/nc:input/nc:target/nc:config-target" {
description
"Add NMDA datastore as target.";
leaf datastore {
type ds:datastore-ref;
description
"Datastore to lock.
The <lock> operation is only supported on writable
datastores.
If the <lock> operation is not supported by the server on
the specified target datastore, then the server MUST return
an <rpc-error> element with an <error-tag> value of
'invalid-value'.";
}
}
augment "/nc:unlock/nc:input/nc:target/nc:config-target" {
description
"Add NMDA datastore as target.";
leaf datastore {
type ds:datastore-ref;
description
"Datastore to unlock.
The <unlock> operation is only supported on writable
datastores.
If the <unlock> operation is not supported by the server on
the specified target datastore, then the server MUST return
an <rpc-error> element with an <error-tag> value of
'invalid-value'.";
}
}
/*
* Augment the <validate> operation with a
* "datastore" parameter.
*/
augment "/nc:validate/nc:input/nc:source/nc:config-source" {
description
"Add NMDA datastore as source.";
leaf datastore {
type ds:datastore-ref;
description
"Datastore to validate.
The <validate> operation is supported only on configuration
datastores.
If the <validate> operation is not supported by the server
on the specified target datastore, then the server MUST
return an <rpc-error> element with an <error-tag> value of
'invalid-value'.";
}
}
}

View file

@ -0,0 +1,140 @@
module ietf-netconf-with-defaults {
namespace "urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults";
prefix ncwd;
import ietf-netconf { prefix nc; }
organization
"IETF NETCONF (Network Configuration Protocol) Working Group";
contact
"WG Web: <http://tools.ietf.org/wg/netconf/>
WG List: <netconf@ietf.org>
WG Chair: Bert Wijnen
<bertietf@bwijnen.net>
WG Chair: Mehmet Ersue
<mehmet.ersue@nsn.com>
Editor: Andy Bierman
<andy.bierman@brocade.com>
Editor: Balazs Lengyel
<balazs.lengyel@ericsson.com>";
description
"This module defines an extension to the NETCONF protocol
that allows the NETCONF client to control how default
values are handled by the server in particular NETCONF
operations.
Copyright (c) 2011 IETF Trust and the persons identified as
the document authors. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 6243; see
the RFC itself for full legal notices.";
revision 2011-06-01 {
description
"Initial version.";
reference
"RFC 6243: With-defaults Capability for NETCONF";
}
typedef with-defaults-mode {
description
"Possible modes to report default data.";
reference
"RFC 6243; Section 3.";
type enumeration {
enum report-all {
description
"All default data is reported.";
reference
"RFC 6243; Section 3.1";
}
enum report-all-tagged {
description
"All default data is reported.
Any nodes considered to be default data
will contain a 'default' XML attribute,
set to 'true' or '1'.";
reference
"RFC 6243; Section 3.4";
}
enum trim {
description
"Values are not reported if they contain the default.";
reference
"RFC 6243; Section 3.2";
}
enum explicit {
description
"Report values that contain the definition of
explicitly set data.";
reference
"RFC 6243; Section 3.3";
}
}
}
grouping with-defaults-parameters {
description
"Contains the <with-defaults> parameter for control
of defaults in NETCONF retrieval operations.";
leaf with-defaults {
description
"The explicit defaults processing mode requested.";
reference
"RFC 6243; Section 4.5.1";
type with-defaults-mode;
}
}
// extending the get-config operation
augment /nc:get-config/nc:input {
description
"Adds the <with-defaults> parameter to the
input of the NETCONF <get-config> operation.";
reference
"RFC 6243; Section 4.5.1";
uses with-defaults-parameters;
}
// extending the get operation
augment /nc:get/nc:input {
description
"Adds the <with-defaults> parameter to
the input of the NETCONF <get> operation.";
reference
"RFC 6243; Section 4.5.1";
uses with-defaults-parameters;
}
// extending the copy-config operation
augment /nc:copy-config/nc:input {
description
"Adds the <with-defaults> parameter to
the input of the NETCONF <copy-config> operation.";
reference
"RFC 6243; Section 4.5.1";
uses with-defaults-parameters;
}
}

View file

@ -0,0 +1,934 @@
module ietf-netconf {
// the namespace for NETCONF XML definitions is unchanged
// from RFC 4741, which this document replaces
namespace "urn:ietf:params:xml:ns:netconf:base:1.0";
prefix nc;
import ietf-inet-types {
prefix inet;
}
import ietf-netconf-acm { prefix nacm; }
organization
"IETF NETCONF (Network Configuration) Working Group";
contact
"WG Web: <http://tools.ietf.org/wg/netconf/>
WG List: <netconf@ietf.org>
WG Chair: Bert Wijnen
<bertietf@bwijnen.net>
WG Chair: Mehmet Ersue
<mehmet.ersue@nsn.com>
Editor: Martin Bjorklund
<mbj@tail-f.com>
Editor: Juergen Schoenwaelder
<j.schoenwaelder@jacobs-university.de>
Editor: Andy Bierman
<andy.bierman@brocade.com>";
description
"NETCONF Protocol Data Types and Protocol Operations.
Copyright (c) 2011 IETF Trust and the persons identified as
the document authors. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 6241; see
the RFC itself for full legal notices.";
revision 2011-06-01 {
description
"Initial revision;
2013-09-29: Updated to include NACM attributes,
as specified in RFC 6536: sec 3.2.5 and 3.2.8";
reference
"RFC 6241: Network Configuration Protocol";
}
extension get-filter-element-attributes {
description
"If this extension is present within an 'anyxml'
statement named 'filter', which must be conceptually
defined within the RPC input section for the <get>
and <get-config> protocol operations, then the
following unqualified XML attribute is supported
within the <filter> element, within a <get> or
<get-config> protocol operation:
type : optional attribute with allowed
value strings 'subtree' and 'xpath'.
If missing, the default value is 'subtree'.
If the 'xpath' feature is supported, then the
following unqualified XML attribute is
also supported:
select: optional attribute containing a
string representing an XPath expression.
The 'type' attribute must be equal to 'xpath'
if this attribute is present.";
}
// NETCONF capabilities defined as features
feature writable-running {
description
"NETCONF :writable-running capability;
If the server advertises the :writable-running
capability for a session, then this feature must
also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference "RFC 6241, Section 8.2";
}
feature candidate {
description
"NETCONF :candidate capability;
If the server advertises the :candidate
capability for a session, then this feature must
also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference "RFC 6241, Section 8.3";
}
feature confirmed-commit {
if-feature candidate;
description
"NETCONF :confirmed-commit:1.1 capability;
If the server advertises the :confirmed-commit:1.1
capability for a session, then this feature must
also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference "RFC 6241, Section 8.4";
}
feature rollback-on-error {
description
"NETCONF :rollback-on-error capability;
If the server advertises the :rollback-on-error
capability for a session, then this feature must
also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference "RFC 6241, Section 8.5";
}
feature validate {
description
"NETCONF :validate:1.1 capability;
If the server advertises the :validate:1.1
capability for a session, then this feature must
also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference "RFC 6241, Section 8.6";
}
feature startup {
description
"NETCONF :startup capability;
If the server advertises the :startup
capability for a session, then this feature must
also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference "RFC 6241, Section 8.7";
}
feature url {
description
"NETCONF :url capability;
If the server advertises the :url
capability for a session, then this feature must
also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference "RFC 6241, Section 8.8";
}
feature xpath {
description
"NETCONF :xpath capability;
If the server advertises the :xpath
capability for a session, then this feature must
also be enabled for that session. Otherwise,
this feature must not be enabled.";
reference "RFC 6241, Section 8.9";
}
// NETCONF Simple Types
typedef session-id-type {
type uint32 {
range "1..max";
}
description
"NETCONF Session Id";
}
typedef session-id-or-zero-type {
type uint32;
description
"NETCONF Session Id or Zero to indicate none";
}
typedef error-tag-type {
type enumeration {
enum in-use {
description
"The request requires a resource that
already is in use.";
}
enum invalid-value {
description
"The request specifies an unacceptable value for one
or more parameters.";
}
enum too-big {
description
"The request or response (that would be generated) is
too large for the implementation to handle.";
}
enum missing-attribute {
description
"An expected attribute is missing.";
}
enum bad-attribute {
description
"An attribute value is not correct; e.g., wrong type,
out of range, pattern mismatch.";
}
enum unknown-attribute {
description
"An unexpected attribute is present.";
}
enum missing-element {
description
"An expected element is missing.";
}
enum bad-element {
description
"An element value is not correct; e.g., wrong type,
out of range, pattern mismatch.";
}
enum unknown-element {
description
"An unexpected element is present.";
}
enum unknown-namespace {
description
"An unexpected namespace is present.";
}
enum access-denied {
description
"Access to the requested protocol operation or
data model is denied because authorization failed.";
}
enum lock-denied {
description
"Access to the requested lock is denied because the
lock is currently held by another entity.";
}
enum resource-denied {
description
"Request could not be completed because of
insufficient resources.";
}
enum rollback-failed {
description
"Request to roll back some configuration change (via
rollback-on-error or <discard-changes> operations)
was not completed for some reason.";
}
enum data-exists {
description
"Request could not be completed because the relevant
data model content already exists. For example,
a 'create' operation was attempted on data that
already exists.";
}
enum data-missing {
description
"Request could not be completed because the relevant
data model content does not exist. For example,
a 'delete' operation was attempted on
data that does not exist.";
}
enum operation-not-supported {
description
"Request could not be completed because the requested
operation is not supported by this implementation.";
}
enum operation-failed {
description
"Request could not be completed because the requested
operation failed for some reason not covered by
any other error condition.";
}
enum partial-operation {
description
"This error-tag is obsolete, and SHOULD NOT be sent
by servers conforming to this document.";
}
enum malformed-message {
description
"A message could not be handled because it failed to
be parsed correctly. For example, the message is not
well-formed XML or it uses an invalid character set.";
}
}
description "NETCONF Error Tag";
reference "RFC 6241, Appendix A";
}
typedef error-severity-type {
type enumeration {
enum error {
description "Error severity";
}
enum warning {
description "Warning severity";
}
}
description "NETCONF Error Severity";
reference "RFC 6241, Section 4.3";
}
typedef edit-operation-type {
type enumeration {
enum merge {
description
"The configuration data identified by the
element containing this attribute is merged
with the configuration at the corresponding
level in the configuration datastore identified
by the target parameter.";
}
enum replace {
description
"The configuration data identified by the element
containing this attribute replaces any related
configuration in the configuration datastore
identified by the target parameter. If no such
configuration data exists in the configuration
datastore, it is created. Unlike a
<copy-config> operation, which replaces the
entire target configuration, only the configuration
actually present in the config parameter is affected.";
}
enum create {
description
"The configuration data identified by the element
containing this attribute is added to the
configuration if and only if the configuration
data does not already exist in the configuration
datastore. If the configuration data exists, an
<rpc-error> element is returned with an
<error-tag> value of 'data-exists'.";
}
enum delete {
description
"The configuration data identified by the element
containing this attribute is deleted from the
configuration if and only if the configuration
data currently exists in the configuration
datastore. If the configuration data does not
exist, an <rpc-error> element is returned with
an <error-tag> value of 'data-missing'.";
}
enum remove {
description
"The configuration data identified by the element
containing this attribute is deleted from the
configuration if the configuration
data currently exists in the configuration
datastore. If the configuration data does not
exist, the 'remove' operation is silently ignored
by the server.";
}
}
default "merge";
description "NETCONF 'operation' attribute values";
reference "RFC 6241, Section 7.2";
}
// NETCONF Standard Protocol Operations
rpc get-config {
description
"Retrieve all or part of a specified configuration.";
reference "RFC 6241, Section 7.1";
input {
container source {
description
"Particular configuration to retrieve.";
choice config-source {
mandatory true;
description
"The configuration to retrieve.";
leaf candidate {
if-feature candidate;
type empty;
description
"The candidate configuration is the config source.";
}
leaf running {
type empty;
description
"The running configuration is the config source.";
}
leaf startup {
if-feature startup;
type empty;
description
"The startup configuration is the config source.
This is optional-to-implement on the server because
not all servers will support filtering for this
datastore.";
}
}
}
anyxml filter {
description
"Subtree or XPath filter to use.";
nc:get-filter-element-attributes;
}
}
output {
anyxml data {
description
"Copy of the source datastore subset that matched
the filter criteria (if any). An empty data container
indicates that the request did not produce any results.";
}
}
}
rpc edit-config {
description
"The <edit-config> operation loads all or part of a specified
configuration to the specified target configuration.";
reference "RFC 6241, Section 7.2";
input {
container target {
description
"Particular configuration to edit.";
choice config-target {
mandatory true;
description
"The configuration target.";
leaf candidate {
if-feature candidate;
type empty;
description
"The candidate configuration is the config target.";
}
leaf running {
if-feature writable-running;
type empty;
description
"The running configuration is the config source.";
}
}
}
leaf default-operation {
type enumeration {
enum merge {
description
"The default operation is merge.";
}
enum replace {
description
"The default operation is replace.";
}
enum none {
description
"There is no default operation.";
}
}
default "merge";
description
"The default operation to use.";
}
leaf test-option {
if-feature validate;
type enumeration {
enum test-then-set {
description
"The server will test and then set if no errors.";
}
enum set {
description
"The server will set without a test first.";
}
enum test-only {
description
"The server will only test and not set, even
if there are no errors.";
}
}
default "test-then-set";
description
"The test option to use.";
}
leaf error-option {
type enumeration {
enum stop-on-error {
description
"The server will stop on errors.";
}
enum continue-on-error {
description
"The server may continue on errors.";
}
enum rollback-on-error {
description
"The server will roll back on errors.
This value can only be used if the 'rollback-on-error'
feature is supported.";
}
}
default "stop-on-error";
description
"The error option to use.";
}
choice edit-content {
mandatory true;
description
"The content for the edit operation.";
anyxml config {
description
"Inline Config content.";
}
leaf url {
if-feature url;
type inet:uri;
description
"URL-based config content.";
}
}
}
}
rpc copy-config {
description
"Create or replace an entire configuration datastore with the
contents of another complete configuration datastore.";
reference "RFC 6241, Section 7.3";
input {
container target {
description
"Particular configuration to copy to.";
choice config-target {
mandatory true;
description
"The configuration target of the copy operation.";
leaf candidate {
if-feature candidate;
type empty;
description
"The candidate configuration is the config target.";
}
leaf running {
if-feature writable-running;
type empty;
description
"The running configuration is the config target.
This is optional-to-implement on the server.";
}
leaf startup {
if-feature startup;
type empty;
description
"The startup configuration is the config target.";
}
leaf url {
if-feature url;
type inet:uri;
description
"The URL-based configuration is the config target.";
}
}
}
container source {
description
"Particular configuration to copy from.";
choice config-source {
mandatory true;
description
"The configuration source for the copy operation.";
leaf candidate {
if-feature candidate;
type empty;
description
"The candidate configuration is the config source.";
}
leaf running {
type empty;
description
"The running configuration is the config source.";
}
leaf startup {
if-feature startup;
type empty;
description
"The startup configuration is the config source.";
}
leaf url {
if-feature url;
type inet:uri;
description
"The URL-based configuration is the config source.";
}
anyxml config {
description
"Inline Config content: <config> element. Represents
an entire configuration datastore, not
a subset of the running datastore.";
}
}
}
}
}
rpc delete-config {
nacm:default-deny-all;
description
"Delete a configuration datastore.";
reference "RFC 6241, Section 7.4";
input {
container target {
description
"Particular configuration to delete.";
choice config-target {
mandatory true;
description
"The configuration target to delete.";
leaf startup {
if-feature startup;
type empty;
description
"The startup configuration is the config target.";
}
leaf url {
if-feature url;
type inet:uri;
description
"The URL-based configuration is the config target.";
}
}
}
}
}
rpc lock {
description
"The lock operation allows the client to lock the configuration
system of a device.";
reference "RFC 6241, Section 7.5";
input {
container target {
description
"Particular configuration to lock.";
choice config-target {
mandatory true;
description
"The configuration target to lock.";
leaf candidate {
if-feature candidate;
type empty;
description
"The candidate configuration is the config target.";
}
leaf running {
type empty;
description
"The running configuration is the config target.";
}
leaf startup {
if-feature startup;
type empty;
description
"The startup configuration is the config target.";
}
}
}
}
}
rpc unlock {
description
"The unlock operation is used to release a configuration lock,
previously obtained with the 'lock' operation.";
reference "RFC 6241, Section 7.6";
input {
container target {
description
"Particular configuration to unlock.";
choice config-target {
mandatory true;
description
"The configuration target to unlock.";
leaf candidate {
if-feature candidate;
type empty;
description
"The candidate configuration is the config target.";
}
leaf running {
type empty;
description
"The running configuration is the config target.";
}
leaf startup {
if-feature startup;
type empty;
description
"The startup configuration is the config target.";
}
}
}
}
}
rpc get {
description
"Retrieve running configuration and device state information.";
reference "RFC 6241, Section 7.7";
input {
anyxml filter {
description
"This parameter specifies the portion of the system
configuration and state data to retrieve.";
nc:get-filter-element-attributes;
}
}
output {
anyxml data {
description
"Copy of the running datastore subset and/or state
data that matched the filter criteria (if any).
An empty data container indicates that the request did not
produce any results.";
}
}
}
rpc close-session {
description
"Request graceful termination of a NETCONF session.";
reference "RFC 6241, Section 7.8";
}
rpc kill-session {
nacm:default-deny-all;
description
"Force the termination of a NETCONF session.";
reference "RFC 6241, Section 7.9";
input {
leaf session-id {
type session-id-type;
mandatory true;
description
"Particular session to kill.";
}
}
}
rpc commit {
if-feature candidate;
description
"Commit the candidate configuration as the device's new
current configuration.";
reference "RFC 6241, Section 8.3.4.1";
input {
leaf confirmed {
if-feature confirmed-commit;
type empty;
description
"Requests a confirmed commit.";
reference "RFC 6241, Section 8.3.4.1";
}
leaf confirm-timeout {
if-feature confirmed-commit;
type uint32 {
range "1..max";
}
units "seconds";
default "600"; // 10 minutes
description
"The timeout interval for a confirmed commit.";
reference "RFC 6241, Section 8.3.4.1";
}
leaf persist {
if-feature confirmed-commit;
type string;
description
"This parameter is used to make a confirmed commit
persistent. A persistent confirmed commit is not aborted
if the NETCONF session terminates. The only way to abort
a persistent confirmed commit is to let the timer expire,
or to use the <cancel-commit> operation.
The value of this parameter is a token that must be given
in the 'persist-id' parameter of <commit> or
<cancel-commit> operations in order to confirm or cancel
the persistent confirmed commit.
The token should be a random string.";
reference "RFC 6241, Section 8.3.4.1";
}
leaf persist-id {
if-feature confirmed-commit;
type string;
description
"This parameter is given in order to commit a persistent
confirmed commit. The value must be equal to the value
given in the 'persist' parameter to the <commit> operation.
If it does not match, the operation fails with an
'invalid-value' error.";
reference "RFC 6241, Section 8.3.4.1";
}
}
}
rpc discard-changes {
if-feature candidate;
description
"Revert the candidate configuration to the current
running configuration.";
reference "RFC 6241, Section 8.3.4.2";
}
rpc cancel-commit {
if-feature confirmed-commit;
description
"This operation is used to cancel an ongoing confirmed commit.
If the confirmed commit is persistent, the parameter
'persist-id' must be given, and it must match the value of the
'persist' parameter.";
reference "RFC 6241, Section 8.4.4.1";
input {
leaf persist-id {
type string;
description
"This parameter is given in order to cancel a persistent
confirmed commit. The value must be equal to the value
given in the 'persist' parameter to the <commit> operation.
If it does not match, the operation fails with an
'invalid-value' error.";
}
}
}
rpc validate {
if-feature validate;
description
"Validates the contents of the specified configuration.";
reference "RFC 6241, Section 8.6.4.1";
input {
container source {
description
"Particular configuration to validate.";
choice config-source {
mandatory true;
description
"The configuration source to validate.";
leaf candidate {
if-feature candidate;
type empty;
description
"The candidate configuration is the config source.";
}
leaf running {
type empty;
description
"The running configuration is the config source.";
}
leaf startup {
if-feature startup;
type empty;
description
"The startup configuration is the config source.";
}
leaf url {
if-feature url;
type inet:uri;
description
"The URL-based configuration is the config source.";
}
anyxml config {
description
"Inline Config content: <config> element. Represents
an entire configuration datastore, not
a subset of the running datastore.";
}
}
}
}
}
}

View file

@ -0,0 +1,147 @@
module ietf-origin {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:ietf-origin";
prefix or;
import ietf-yang-metadata {
prefix md;
}
organization
"IETF Network Modeling (NETMOD) Working Group";
contact
"WG Web: <https://datatracker.ietf.org/wg/netmod/>
WG List: <mailto:netmod@ietf.org>
Author: Martin Bjorklund
<mailto:mbj@tail-f.com>
Author: Juergen Schoenwaelder
<mailto:j.schoenwaelder@jacobs-university.de>
Author: Phil Shafer
<mailto:phil@juniper.net>
Author: Kent Watsen
<mailto:kwatsen@juniper.net>
Author: Rob Wilton
<rwilton@cisco.com>";
description
"This YANG module defines an 'origin' metadata annotation and a
set of identities for the origin value.
Copyright (c) 2018 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject to
the license terms contained in, the Simplified BSD License set
forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(https://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 8342
(https://www.rfc-editor.org/info/rfc8342); see the RFC itself
for full legal notices.";
revision 2018-02-14 {
description
"Initial revision.";
reference
"RFC 8342: Network Management Datastore Architecture (NMDA)";
}
/*
* Identities
*/
identity origin {
description
"Abstract base identity for the origin annotation.";
}
identity intended {
base origin;
description
"Denotes configuration from the intended configuration
datastore.";
}
identity dynamic {
base origin;
description
"Denotes configuration from a dynamic configuration
datastore.";
}
identity system {
base origin;
description
"Denotes configuration originated by the system itself.
Examples of system configuration include applied configuration
for an always-existing loopback interface, or interface
configuration that is auto-created due to the hardware
currently present in the device.";
}
identity learned {
base origin;
description
"Denotes configuration learned from protocol interactions with
other devices, instead of via either the intended
configuration datastore or any dynamic configuration
datastore.
Examples of protocols that provide learned configuration
include link-layer negotiations, routing protocols, and
DHCP.";
}
identity default {
base origin;
description
"Denotes configuration that does not have a configured or
learned value but has a default value in use. Covers both
values defined in a 'default' statement and values defined
via an explanation in a 'description' statement.";
}
identity unknown {
base origin;
description
"Denotes configuration for which the system cannot identify the
origin.";
}
/*
* Type definitions
*/
typedef origin-ref {
type identityref {
base origin;
}
description
"An origin identity reference.";
}
/*
* Metadata annotations
*/
md:annotation origin {
type origin-ref;
description
"The 'origin' annotation can be present on any configuration
data node in the operational state datastore. It specifies
from where the node originated. If not specified for a given
configuration data node, then the origin is the same as the
origin of its parent node in the data tree. The origin for
any top-level configuration data nodes must be specified.";
}
}

View file

@ -0,0 +1,278 @@
module ietf-restconf {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:ietf-restconf";
prefix "rc";
organization
"IETF NETCONF (Network Configuration) Working Group";
contact
"WG Web: <https://datatracker.ietf.org/wg/netconf/>
WG List: <mailto:netconf@ietf.org>
Author: Andy Bierman
<mailto:andy@yumaworks.com>
Author: Martin Bjorklund
<mailto:mbj@tail-f.com>
Author: Kent Watsen
<mailto:kwatsen@juniper.net>";
description
"This module contains conceptual YANG specifications
for basic RESTCONF media type definitions used in
RESTCONF protocol messages.
Note that the YANG definitions within this module do not
represent configuration data of any kind.
The 'restconf-media-type' YANG extension statement
provides a normative syntax for XML and JSON
message-encoding purposes.
Copyright (c) 2017 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 8040; see
the RFC itself for full legal notices.";
revision 2017-01-26 {
description
"Initial revision.";
reference
"RFC 8040: RESTCONF Protocol.";
}
extension yang-data {
argument name {
yin-element true;
}
description
"This extension is used to specify a YANG data template that
represents conceptual data defined in YANG. It is
intended to describe hierarchical data independent of
protocol context or specific message-encoding format.
Data definition statements within a yang-data extension
specify the generic syntax for the specific YANG data
template, whose name is the argument of the 'yang-data'
extension statement.
Note that this extension does not define a media type.
A specification using this extension MUST specify the
message-encoding rules, including the content media type.
The mandatory 'name' parameter value identifies the YANG
data template that is being defined. It contains the
template name.
This extension is ignored unless it appears as a top-level
statement. It MUST contain data definition statements
that result in exactly one container data node definition.
An instance of a YANG data template can thus be translated
into an XML instance document, whose top-level element
corresponds to the top-level container.
The module name and namespace values for the YANG module using
the extension statement are assigned to instance document data
conforming to the data definition statements within
this extension.
The substatements of this extension MUST follow the
'data-def-stmt' rule in the YANG ABNF.
The XPath document root is the extension statement itself,
such that the child nodes of the document root are
represented by the data-def-stmt substatements within
this extension. This conceptual document is the context
for the following YANG statements:
- must-stmt
- when-stmt
- path-stmt
- min-elements-stmt
- max-elements-stmt
- mandatory-stmt
- unique-stmt
- ordered-by
- instance-identifier data type
The following data-def-stmt substatements are constrained
when used within a 'yang-data' extension statement.
- The list-stmt is not required to have a key-stmt defined.
- The if-feature-stmt is ignored if present.
- The config-stmt is ignored if present.
- The available identity values for any 'identityref'
leaf or leaf-list nodes are limited to the module
containing this extension statement and the modules
imported into that module.
";
}
rc:yang-data yang-errors {
uses errors;
}
rc:yang-data yang-api {
uses restconf;
}
grouping errors {
description
"A grouping that contains a YANG container
representing the syntax and semantics of a
YANG Patch error report within a response message.";
container errors {
description
"Represents an error report returned by the server if
a request results in an error.";
list error {
description
"An entry containing information about one
specific error that occurred while processing
a RESTCONF request.";
reference
"RFC 6241, Section 4.3.";
leaf error-type {
type enumeration {
enum transport {
description
"The transport layer.";
}
enum rpc {
description
"The rpc or notification layer.";
}
enum protocol {
description
"The protocol operation layer.";
}
enum application {
description
"The server application layer.";
}
}
mandatory true;
description
"The protocol layer where the error occurred.";
}
leaf error-tag {
type string;
mandatory true;
description
"The enumerated error-tag.";
}
leaf error-app-tag {
type string;
description
"The application-specific error-tag.";
}
leaf error-path {
type instance-identifier;
description
"The YANG instance identifier associated
with the error node.";
}
leaf error-message {
type string;
description
"A message describing the error.";
}
anydata error-info {
description
"This anydata value MUST represent a container with
zero or more data nodes representing additional
error information.";
}
}
}
}
grouping restconf {
description
"Conceptual grouping representing the RESTCONF
root resource.";
container restconf {
description
"Conceptual container representing the RESTCONF
root resource.";
container data {
description
"Container representing the datastore resource.
Represents the conceptual root of all state data
and configuration data supported by the server.
The child nodes of this container can be any data
resources that are defined as top-level data nodes
from the YANG modules advertised by the server in
the 'ietf-yang-library' module.";
}
container operations {
description
"Container for all operation resources.
Each resource is represented as an empty leaf with the
name of the RPC operation from the YANG 'rpc' statement.
For example, the 'system-restart' RPC operation defined
in the 'ietf-system' module would be represented as
an empty leaf in the 'ietf-system' namespace. This is
a conceptual leaf and will not actually be found in
the module:
module ietf-system {
leaf system-reset {
type empty;
}
}
To invoke the 'system-restart' RPC operation:
POST /restconf/operations/ietf-system:system-restart
To discover the RPC operations supported by the server:
GET /restconf/operations
In XML, the YANG module namespace identifies the module:
<system-restart
xmlns='urn:ietf:params:xml:ns:yang:ietf-system'/>
In JSON, the YANG module name identifies the module:
{ 'ietf-system:system-restart' : [null] }
";
}
leaf yang-library-version {
type string {
pattern '\d{4}-\d{2}-\d{2}';
}
config false;
mandatory true;
description
"Identifies the revision date of the 'ietf-yang-library'
module that is implemented by this RESTCONF server.
Indicates the year, month, and day in YYYY-MM-DD
numeric format.";
}
}
}
}

View file

@ -0,0 +1,95 @@
module notifications {
namespace "urn:ietf:params:xml:ns:netconf:notification:1.0";
prefix "ncEvent";
import ietf-yang-types { prefix yang; }
organization
"IETF NETCONF WG";
contact
"netconf@ops.ietf.org";
description
"Conversion of the 'ncEvent' XSD in the
NETCONF Notifications RFC.";
reference
"RFC 5277.";
revision 2008-07-14 {
description "RFC 5277 version.";
}
typedef streamNameType {
description
"The name of an event stream.";
type string;
}
rpc create-subscription {
description
"The command to create a notification subscription. It
takes as argument the name of the notification stream
and filter. Both of those options limit the content of
the subscription. In addition, there are two time-related
parameters, startTime and stopTime, which can be used to
select the time interval of interest to the notification
replay feature.";
input {
leaf stream {
description
"An optional parameter that indicates which stream of events
is of interest. If not present, then events in the default
NETCONF stream will be sent.";
type streamNameType;
default "NETCONF";
}
anyxml filter {
description
"An optional parameter that indicates which subset of all
possible events is of interest. The format of this
parameter is the same as that of the filter parameter
in the NETCONF protocol operations. If not present,
all events not precluded by other parameters will
be sent.";
}
leaf startTime {
description
"A parameter used to trigger the replay feature and
indicates that the replay should start at the time
specified. If start time is not present, this is not a
replay subscription.";
type yang:date-and-time;
}
leaf stopTime {
// must ". >= ../startTime";
description
"An optional parameter used with the optional replay
feature to indicate the newest notifications of
interest. If stop time is not present, the notifications
will continue until the subscription is terminated.
Must be used with startTime.";
type yang:date-and-time;
}
}
}
/*container notification {
description "internal struct to start a notification";
config false;
leaf eventTime {
mandatory true;
type yang:date-and-time;
}
// eventType and any data content goes here
}*/
}

View file

@ -0,0 +1,17 @@
module sm-extension {
yang-version 1.1;
namespace "urn:sm-ext";
prefix "sm-ext";
list tlist {
key "name";
leaf name {
type uint32;
}
}
container tcont {
leaf tleaf {
type uint32;
}
}
}

View file

@ -0,0 +1,9 @@
module sm-mod {
yang-version 1.1;
namespace "urn:sm-mod";
prefix "sm-mod";
import sm-modp {
prefix smp;
}
}

Some files were not shown because too many files have changed in this diff Show more