15 Client API


This section is not complete and outdated. A new Client API is developed as part of the Clixon controller.

Clixon’s client API provides a way to communicate with the built-in XML datastore. This can be used to fetch or manipulate configurations handled by Clixon from any other application running on a host system. For example, a deamon running on a host system may need to read a configured value from the Clixon datastore.

Clixon integration normally uses dynamic plugins, but the client API shown here is an alternative.

Below is a minimal example application which connects to Clixon to get a value stored under “/table/parameter” in the XML store:

#include <unistd.h>
#include <stdio.h>
#include <stdint.h>

#include <clixon/clixon_client.h>

int main(int argc, char **argv)
    clixon_handle h = NULL;
    clixon_client_handle ch = NULL;

    uint32_t n = 0;

    if ((h = clixon_client_init("/usr/local/etc/clixon/example.xml")) == NULL)
        return -1;

    if ((ch = clixon_client_connect(h, CLIXON_CLIENT_NETCONF)) == NULL)
        return -1;

    if (clixon_client_get_uint32(ch, &n, "urn:example:clixon", "/table/parameter[name='a']/value") < 0)
        return -1;

    printf("Response: %n\n", u);


    return 0;

Clixon data paths use full XPATHs:


One can make the same index access as well (eg [0]). This means that one can make direct indexed accesses as an alternative to looping.

15.1 Clixon and ConfD Examples

This describes how to create a minimal YANG specification and use it together with Clixon. First, a YANG model is added. Then, NETCONF messages are sent to Clixon which is thereafter accessed in the Clixon CLI.

This guide assumes that you have Clixon installed and running. Please refer to the respective for installation and initial configuration.

15.1.1 YANG model

The YANG model consists of a table with a list of parameters where each parameter have a name and a value:

module example {
    yang-version 1.1;
    namespace "urn:example:clixon";
      "Tiny example to be used with Clixon and ConfD.
    revision 2021-01-26 {
      description "Added example.";

    container example{
      list parameter{
          key name;
          leaf name{
              type string;
          leaf value{
              type string;

The YANG model is saved as example.yang.

15.1.2 Installating the YANG model

It is assumed that the example application shipped with Clixon is installed. If not it can be found in the source tree under “example/main”.

The YANG file example.yang is copied to the folder where Clixon expects to find YANG models (usually /usr/local/share/clixon):

$ sudo cp example.yang /usr/local/share/clixon/example.yang

The Clixons configuration should look something like:

<clixon-config xmlns="http://clicon.org/config">

After this is done, the Clixon backend can be restarted, and the new model should be present.

15.1.3 Testing with NETCONF

The next step is to modify configuration values with NETCONF. A new test parameter is added with value 1234.

In the example, NETCONF is running over SSH. The SSH configuration needs to contain the following line:

Subsystem netconf /usr/local/bin/clixon_netconf -f /usr/local/etc/clixon/example.xml

The following NETCONF operation is used:

<?xml version="1.0" encoding="UTF-8"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
      <table xmlns="urn:example:clixon">
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">

The XML is saved as “example.xml” and use the following commands to test it:

$ ssh -s netconf < example.xml

If everything went fine, a reply is returned saying OK:

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">

Finally, the config can be viewed from the CLI:

root@debian10-clixon /> show configuration
example {
    parameter {
        name test;
        value 1234;