# Clixon yang routing example ## Compile and run ``` cd example make && sudo make install ``` Start backend: ``` clixon_backend -f /usr/local/etc/routing.conf -I ``` Edit cli: ``` clixon_cli -f /usr/local/etc/routing.conf ``` Send netconf command: ``` clixon_netconf -f /usr/local/etc/routing.conf ``` ## Setting data example using netconf ``` eth1 true
9.2.3.4 24
]]>]]> ``` ## Getting data using netconf ``` ]]>]]> ]]>]]> ]]>]]> ]]>]]> ]]>]]> ]]>]]> ``` ## Creating notification The example has an example notification triggering every 10s. To start a notification stream in the session, create a subscription: ``` ROUTING]]>]]> ]]>]]> Routing notification]]>]]> Routing notification]]>]]> ... ``` This can also be triggered via the CLI: ``` cli> notify cli> Routing notification Routing notification ... ``` ## Operation data Clixon implements Yang RPC operations by an extension mechanism. The extension mechanism enables you to add application-specific operations. It works by adding user-defined callbacks for added netconf operations. It is possible to use the extension mechanism independent of the yang rpc construct, but it is recommended to use that, and the example includes such an example: Example: ``` cli> rpc ipv4 ``` The example works by creating a netconf rpc call and sending it to the backend: (see the fib_route_rpc() function). ``` ipv4 ``` The backend in turn registers a callback (fib_route()) which handles the RPC. ``` static int fib_route(clicon_handle h, cxobj *xe, /* Request: */ struct client_entry *ce, /* Client session */ cbuf *cbret, /* Reply eg ... */ void *arg) /* Argument given at register */ { cprintf(cbret, ""); return 0; } int plugin_init(clicon_handle h) { ... backend_rpc_cb_register(h, fib_route, NULL, "fib-route"); ... } ``` ## 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 ```