diff --git a/CHANGELOG.md b/CHANGELOG.md index d7120d5d..3ec9d819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,7 @@ * Added yang_spec_parse_file ### Minor changes - +* Yang 1.1 action syntax added (but function is not supported) * New function: clicon_conf_xml() returns configuration tree * Obsoleted COMPAT_CLIV and COMPAT_XSL that were optional in 3.7 * Added timeout option -t for clixon_netconf - quit after max time. diff --git a/lib/clixon/clixon_yang.h b/lib/clixon/clixon_yang.h index 3996b806..78906109 100644 --- a/lib/clixon/clixon_yang.h +++ b/lib/clixon/clixon_yang.h @@ -57,7 +57,8 @@ * - Cant use the symbols in this file because yacc needs token definitions */ enum rfc_6020{ - Y_ANYXML = 0, + Y_ACTION = 0, + Y_ANYXML, Y_ARGUMENT, Y_AUGMENT, Y_BASE, diff --git a/lib/src/clixon_yang_parse.l b/lib/src/clixon_yang_parse.l index 8c65cbd1..d059993a 100644 --- a/lib/src/clixon_yang_parse.l +++ b/lib/src/clixon_yang_parse.l @@ -111,6 +111,7 @@ clixon_yang_parsewrap(void) \} { return *yytext; } /* RFC 6020 keywords */ +action { BEGIN(ARGUMENT); return K_ACTION; } anyxml { BEGIN(ARGUMENT); return K_ANYXML; } argument { BEGIN(ARGUMENT); return K_ARGUMENT; } augment { BEGIN(ARGUMENT); return K_AUGMENT; } diff --git a/lib/src/clixon_yang_parse.y b/lib/src/clixon_yang_parse.y index 8fd7ed38..0bd24e9f 100644 --- a/lib/src/clixon_yang_parse.y +++ b/lib/src/clixon_yang_parse.y @@ -64,6 +64,7 @@ * - Dont want to expose a generated yacc file to the API * - Cant use the symbols in this file because yacc needs token definitions */ +%token K_ACTION %token K_ANYXML %token K_ARGUMENT %token K_AUGMENT @@ -523,6 +524,7 @@ container_substmt : when_stmt { clicon_debug(2,"container-substmt -> when- | typedef_stmt { clicon_debug(2,"container-substmt -> typedef-stmt"); } | grouping_stmt { clicon_debug(2,"container-substmt -> grouping-stmt"); } | data_def_stmt { clicon_debug(2,"container-substmt -> data-def-stmt");} + | action_stmt { clicon_debug(2,"container-substmt -> action-stmt");} | notification_stmt { clicon_debug(2,"container-substmt -> notification-stmt");} | unknown_stmt { clicon_debug(2,"container-substmt -> unknown-stmt");} | { clicon_debug(2,"container-substmt ->");} @@ -621,6 +623,7 @@ list_substmt : when_stmt { clicon_debug(2,"list-substmt -> when-stmt | typedef_stmt { clicon_debug(2,"list-substmt -> typedef-stmt"); } | grouping_stmt { clicon_debug(2,"list-substmt -> grouping-stmt"); } | data_def_stmt { clicon_debug(2,"list-substmt -> data-def-stmt"); } + | action_stmt { clicon_debug(2,"list-substmt -> action-stmt"); } | notification_stmt { clicon_debug(2,"list-substmt -> notification-stmt"); } | unknown_stmt { clicon_debug(2,"list-substmt -> unknown-stmt");} | { clicon_debug(2,"list-substmt -> "); } @@ -796,6 +799,7 @@ augment_substmt : when_stmt { clicon_debug(2,"augment-substmt -> when-s | reference_stmt { clicon_debug(2,"augment-substmt -> reference-stmt"); } | data_def_stmt { clicon_debug(2,"augment-substmt -> data-def-stmt"); } | case_stmt { clicon_debug(2,"augment-substmt -> case-stmt");} + | action_stmt { clicon_debug(2,"augment-substmt -> action-stmt");} | notification_stmt { clicon_debug(2,"augment-substmt -> notification-stmt");} | { clicon_debug(2,"augment-substmt -> "); } ; @@ -850,6 +854,17 @@ rpc_substmt : if_feature_stmt { clicon_debug(2,"rpc-substmt -> if-feature-stm | { clicon_debug(2,"rpc-substmt -> "); } ; +/* action */ +action_stmt : K_ACTION id_arg_str ';' + { if (ysp_add(_yy, Y_ACTION, $2, NULL) == NULL) _YYERROR("39"); + clicon_debug(2,"action-stmt -> ACTION id-arg-str ;"); } + | K_ACTION id_arg_str + { if (ysp_add_push(_yy, Y_ACTION, $2) == NULL) _YYERROR("40"); } + '{' rpc_substmts '}' + { if (ystack_pop(_yy) < 0) _YYERROR("41"); + clicon_debug(2,"action-stmt -> ACTION id-arg-str { rpc-substmts }"); } + ; + /* input */ input_stmt : K_INPUT { if (ysp_add_push(_yy, Y_INPUT, NULL) == NULL) _YYERROR("42"); } @@ -996,6 +1011,7 @@ grouping_substmt : status_stmt { clicon_debug(2,"grouping-substmt -> st | typedef_stmt { clicon_debug(2,"grouping-substmt -> typedef-stmt"); } | grouping_stmt { clicon_debug(2,"grouping-substmt -> grouping-stmt"); } | data_def_stmt { clicon_debug(2,"grouping-substmt -> data-def-stmt"); } + | action_stmt { clicon_debug(2,"grouping-substmt -> action-stmt"); } | notification_stmt { clicon_debug(2,"grouping-substmt -> notification-stmt"); } | { clicon_debug(2,"grouping-substmt -> "); } ; diff --git a/test/test_netconf.sh b/test/test_netconf.sh index 29b53581..26fa1ef3 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -45,9 +45,18 @@ module example{ } rpc empty { } + list server { + key name; + leaf name { + type string; + } + action reset { + } + } identity eth { base if:interface-type; } + rpc client-rpc { description "Example local client-side RPC that is processed by the the netconf/restconf and not sent to the backend.