diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f06872d..00c31beb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,8 @@ Developers may need to change their code ### Corrected Bugs +* Fixed: [clixon_netconf does not respond to hello #136](https://github.com/clicon/clixon/issues/136) + * The error showed only when CLICON_MODULE_LIBRARY_RFC7895 was disabled. * Fixed: Do not check min/max constraints on state data in config validate code * Fixed: [min-elements attribute prevents from deleting list entries #133](https://github.com/clicon/clixon/issues/133) * Fixed: [xmldb_get0 returns invalid candidate on startup transaction callbacks #126](https://github.com/clicon/clixon/issues/126). Always clear candidate-db before db initialization. diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index 1f5f4aae..e056a44a 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -595,9 +595,14 @@ main(int argc, goto done; clicon_session_id_set(h, id); - /* Send hello to northbound client */ - if (!quiet) - send_hello(h, 1, id); + /* Send hello to northbound client + * Note that this is a violation of RDFC 6241 Sec 8.1: + * When the NETCONF session is opened, each peer(both client and server) MUST send a ", NETCONF_BASE_NAMESPACE); cprintf(cb, ""); - cprintf(cb, "urn:ietf:params:netconf:base:1.0"); - if (xml_chardata_encode(&encstr, "urn:ietf:params:netconf:capability:yang-library:1.0?revision=%s&module-set-id=%s", - ietf_yang_library_revision, - module_set_id) < 0) - goto done; - cprintf(cb, "%s", encstr); + cprintf(cb, "urn:ietf:params:netconf:base:1.0"); + /* Check if RFC7895 loaded and revision found */ + if ((ietf_yang_library_revision = yang_modules_revision(h)) != NULL){ + if (xml_chardata_encode(&encstr, "urn:ietf:params:netconf:capability:yang-library:1.0?revision=%s&module-set-id=%s", + ietf_yang_library_revision, + module_set_id) < 0) + goto done; + cprintf(cb, "%s", encstr); + } cprintf(cb, "urn:ietf:params:netconf:capability:candidate:1.0"); cprintf(cb, "urn:ietf:params:netconf:capability:validate:1.1"); cprintf(cb, "urn:ietf:params:netconf:capability:startup:1.0"); diff --git a/lib/src/clixon_proto_client.c b/lib/src/clixon_proto_client.c index e87f93fd..d6312136 100644 --- a/lib/src/clixon_proto_client.c +++ b/lib/src/clixon_proto_client.c @@ -1061,11 +1061,14 @@ clicon_rpc_debug(clicon_handle h, return retval; } -/*! Send a debug request to backend server +/*! Send a hello request to the backend server * @param[in] h CLICON handle * @param[in] level Debug level * @retval 0 OK * @retval -1 Error and logged to syslog + * @note this is internal netconf to backend, not northbound to user client + * @note this deviates from RFC6241 slightly in that it waits for a reply, the RFC does not + * stipulate that. */ int clicon_hello_req(clicon_handle h, diff --git a/test/test_netconf.sh b/test/test_netconf.sh index 04fbe0e5..3e921f9a 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -29,6 +29,7 @@ cat < $cfg $dir/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME + true EOF @@ -51,6 +52,9 @@ fi new "netconf hello" expecteof "$clixon_netconf -f $cfg" 0 "]]>]]>" "^urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:capability:yang-library:1.0?revision=2016-06-21&module-set-id=42urn:ietf:params:netconf:capability:candidate:1.0urn:ietf:params:netconf:capability:validate:1.1urn:ietf:params:netconf:capability:startup:1.0urn:ietf:params:netconf:capability:xpath:1.0urn:ietf:params:netconf:capability:notification:1.0[0-9]*]]>]]>]]>]]>$" +new "netconf hello, disable RFC7895/ietf-yang-library" +expecteof "$clixon_netconf -f $cfg -o CLICON_MODULE_LIBRARY_RFC7895=0" 0 "]]>]]>" "^urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:capability:candidate:1.0urn:ietf:params:netconf:capability:validate:1.1urn:ietf:params:netconf:capability:startup:1.0urn:ietf:params:netconf:capability:xpath:1.0urn:ietf:params:netconf:capability:notification:1.0[0-9]*]]>]]>]]>]]>$" + new "netconf get-config double quotes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$"