#!/usr/bin/env bash # Netconf framing functionality # See RFC6242 and RFC 4742 # See test_netconf_hello.sh for hello protocol negotiation only # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example cfg=$dir/conf_yang.xml fyang=$dir/clixon-example.yang tmp=$dir/tmp.x cat < $cfg $cfg ietf-netconf:startup 42 ${YANG_INSTALLDIR} $fyang /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/backend example_backend.so$ /usr/local/lib/$APPNAME/netconf 1 /usr/local/lib/$APPNAME/restconf /usr/local/lib/$APPNAME/cli $APPNAME $dir/$APPNAME.sock /usr/local/var/run/$APPNAME.pidfile /usr/local/var/$APPNAME true EOF cat < $fyang module clixon-example{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; /* Generic config data */ container table{ list parameter{ key name; leaf name{ type string; } leaf value{ type string; } } } } EOF new "test params: -f $cfg -- -s" # Bring your own backend if [ $BE -ne 0 ]; then # kill old backend (if any) new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg -- -s" start_backend -s init -f $cfg -- -s fi new "wait backend" wait_backend # Hello new "Netconf 1.0 eom framing, edit-config" expecteof "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=0" 0 "urn:ietf:params:netconf:base:1.0]]>]]>mergea
]]>]]>$" "^]]>]]>$" new "Netconf 1.0 eom framing get-config" expecteof "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=0" 0 "urn:ietf:params:netconf:base:1.0]]>]]>]]>]]>$" "^a
]]>]]>$" new "Netconf 1.1 eom framing, expect error" expecteof "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=1" 255 "urn:ietf:params:netconf:base:1.1]]>]]>]]>]]>$" "" new "Netconf 1.1 chunked framing" expecteof_netconf "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=1" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" "" "" "a
" # cant use expecteof_netconf since it relies on a whole frame, here we split into multiple rpc=$(cat <urn:ietf:params:netconf:base:1.1]]>]]> #85 ## EOF ) new "Netconf 1.1 multi-chunked framing" expecteof_netconf "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=1" 0 "$rpc" "" "" "a
" if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill pid=$(pgrep -u root -f clixon_backend) if [ -z "$pid" ]; then err "backend already dead" fi # kill backend stop_backend -f $cfg fi rm -rf $dir new "endtest" endtest