From 96f341d8fcd096b160d11634d1f1d8d979395d53 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sat, 8 Jul 2017 11:11:46 +0200 Subject: [PATCH] state doc --- doc/FAQ.md | 30 ++---------------------------- example/README.md | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/doc/FAQ.md b/doc/FAQ.md index 7aa328eb..a0cd18a9 100644 --- a/doc/FAQ.md +++ b/doc/FAQ.md @@ -207,32 +207,6 @@ Netconf and restconf GET also returns state data, in contrast to config data. In YANG state data is specified with "config false;". To return state data, you need to write a backend state data callback -with the name "plugin_statedata" where you return an XML tree. +with the name "plugin_statedata()" where you return an XML tree. -A static example of returning state data is as follows, although a real example would poll or get the interface counters via a system call, as well as use the "xpath" argument to identify the requested state data. - -``` -int -plugin_statedata(clicon_handle h, - char *xpath, - cxobj *xstate) -{ - int retval = -1; - cxobj **xvec = NULL; - - if ((xml_parse("" - "eth0" - "eth" - "up" - "up" - "42" - "1000000000" - "", xstate)) < 0) - goto done; - retval = 0; - done: - if (xvec) - free(xvec); - return retval; -} -``` +Please look at the example for an example on how to write a state data callback. diff --git a/example/README.md b/example/README.md index 8c325b60..b833feee 100644 --- a/example/README.md +++ b/example/README.md @@ -81,8 +81,28 @@ cli> downcall "This is a string" This is a string ``` +## State data + +Netconf and restconf GET also returns state data, in contrast to +config data. + +In YANG state data is specified with "config false;". In the example, interface-state is state data. + +To return state data, you need to write a backend state data callback +with the name "plugin_statedata" where you return an XML tree with +state. This is then merged with config data by the system. + +pA static example of returning state data is in the example. Note that +a real example would poll or get the interface counters via a system +call, as well as use the "xpath" argument to identify the requested +state data. + + ## Run as docker container ``` cd docker # look in README -``` \ No newline at end of file +``` + + +