CliXoN
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
clixon_proto_client.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/syslog.h>
#include <cligen/cligen.h>
#include "clixon_queue.h"
#include "clixon_chunk.h"
#include "clixon_log.h"
#include "clixon_hash.h"
#include "clixon_handle.h"
#include "clixon_yang.h"
#include "clixon_options.h"
#include "clixon_xml.h"
#include "clixon_xsl.h"
#include "clixon_proto.h"
#include "clixon_err.h"
#include "clixon_proto_client.h"

Functions

int clicon_rpc_msg (clicon_handle h, struct clicon_msg *msg, cxobj **xret0, int *sock0)
 
int clicon_rpc_netconf (clicon_handle h, char *xmlstr, cxobj **xret, int *sp)
 
int clicon_rpc_netconf_xml (clicon_handle h, cxobj *xml, cxobj **xret, int *sp)
 
int clicon_rpc_generate_error (cxobj *xerr)
 
int clicon_rpc_get_config (clicon_handle h, char *db, char *xpath, cxobj **xt)
 
int clicon_rpc_edit_config (clicon_handle h, char *db, enum operation_type op, char *api_path, char *xmlstr)
 
int clicon_rpc_copy_config (clicon_handle h, char *db1, char *db2)
 
int clicon_rpc_delete_config (clicon_handle h, char *db)
 
int clicon_rpc_lock (clicon_handle h, char *db)
 
int clicon_rpc_unlock (clicon_handle h, char *db)
 
int clicon_rpc_close_session (clicon_handle h)
 
int clicon_rpc_kill_session (clicon_handle h, int session_id)
 
int clicon_rpc_validate (clicon_handle h, char *db)
 
int clicon_rpc_commit (clicon_handle h)
 
int clicon_rpc_discard_changes (clicon_handle h)
 
int clicon_rpc_create_subscription (clicon_handle h, char *stream, char *filter, int *s0)
 
int clicon_rpc_debug (clicon_handle h, int level)
 

Function Documentation

int clicon_rpc_close_session ( clicon_handle  h)

Close a (user) session

Parameters
[in]hCLICON handle
int clicon_rpc_commit ( clicon_handle  h)

Commit changes send a commit request to backend daemon

Parameters
[in]hCLICON handle
Return values
0OK
int clicon_rpc_copy_config ( clicon_handle  h,
char *  db1,
char *  db2 
)

Send a request to backend to copy a file from one location to another Note this assumes the backend can access these files and (usually) assumes clients and servers have the access to the same filesystem.

Parameters
[in]hCLICON handle
[in]db1src database, eg "running"
[in]db2dst database, eg "startup"
if (clicon_rpc_copy_config(h, "running", "startup") < 0)
err;
int clicon_rpc_create_subscription ( clicon_handle  h,
char *  stream,
char *  filter,
int *  s0 
)

Create a new notification subscription

Parameters
[in]hClicon handle
in]stream name of notificatio/log stream (CLICON is predefined)
in]filter message filter, eg xpath for xml notifications
[out]s0socket returned where notification mesages will appear
Note
When using netconf create-subsrciption,status and format is not supported
int clicon_rpc_debug ( clicon_handle  h,
int  level 
)

Send a debug request to backend server

Parameters
[in]hCLICON handle
[in]levelDebug level
int clicon_rpc_delete_config ( clicon_handle  h,
char *  db 
)

Send a request to backend to delete a config database

Parameters
[in]hCLICON handle
[in]dbdatabase, eg "running"
if (clicon_rpc_delete_config(h, "startup") < 0)
err;
int clicon_rpc_discard_changes ( clicon_handle  h)

Discard all changes in candidate / revert to running

Parameters
[in]hCLICON handle
Return values
0OK
int clicon_rpc_edit_config ( clicon_handle  h,
char *  db,
enum operation_type  op,
char *  api_path,
char *  xmlstr 
)

Send database entries as XML to backend daemon

Parameters
[in]hCLICON handle
[in]dbName of database
[in]opOperation on database item: OP_MERGE, OP_REPLACE
[in]api_pathrestconf API Path (or "")
[in]xmlXML string. Ex: <config>.....</config>
Return values
0OK
-1Error
Note
xml arg need to have <config> as top element
if (clicon_rpc_edit_config(h, "running", OP_MERGE, "/",
"<config><a>4</a></config>") < 0)
err;
int clicon_rpc_generate_error ( cxobj *  xerr)

Generate clicon error function call from Netconf error message

Parameters
[in]xerrNetconf error message on the level: <rpc-reply><rpc-error>
int clicon_rpc_get_config ( clicon_handle  h,
char *  db,
char *  xpath,
cxobj **  xt 
)

Get database configuration Same as clicon_proto_change just with a cvec instead of lvec

Parameters
[in]hCLICON handle
[in]dbName of database
[in]xpathXPath (or "")
[out]xtXML tree. must be freed by caller with xml_free
Return values
0OK
-1Error, fatal or xml
cxobj *xt = NULL;
if (clicon_rpc_get_config(h, "running", "/", &xt) < 0)
err;
if (xt)
xml_free(xt);
int clicon_rpc_kill_session ( clicon_handle  h,
int  session_id 
)

Kill other user sessions

Parameters
[in]hCLICON handle
[in]session_idSession id of other user session
int clicon_rpc_lock ( clicon_handle  h,
char *  db 
)

Lock a database

Parameters
[in]hCLICON handle
[in]dbdatabase, eg "running"
int clicon_rpc_msg ( clicon_handle  h,
struct clicon_msg *  msg,
cxobj **  xret0,
int *  sock0 
)

Send internal netconf rpc from client to backend

Parameters
[in]hCLICON handle
[in]msgEncoded message. Deallocate woth free
[out]xretReturn value from backend as netconf xml tree. Free w xml_free
[in,out]sock0If pointer exists, do not close socket to backend on success and return it here. For keeping a notify socket open Note: sock0 is if connection should be persistent, like a notification/subscribe api
int clicon_rpc_netconf ( clicon_handle  h,
char *  xmlstr,
cxobj **  xret,
int *  sp 
)

Generic xml netconf clicon rpc Want to go over to use netconf directly between client and server,...

Parameters
[in]hclicon handle
[in]xmlstrXML netconf tree as string
[out]xretReturn XML netconf tree, error or OK
[out]spSocket pointer for notification, otherwise NULL
See Also
clicon_rpc_netconf_xml xml as tree instead of string
int clicon_rpc_netconf_xml ( clicon_handle  h,
cxobj *  xml,
cxobj **  xret,
int *  sp 
)

Generic xml netconf clicon rpc Want to go over to use netconf directly between client and server,...

Parameters
[in]hclicon handle
[in]xmlXML netconf tree
[out]xretReturn XML netconf tree, error or OK
[out]spSocket pointer for notification, otherwise NULL
See Also
clicon_rpc_netconf xml as string instead of tree
int clicon_rpc_unlock ( clicon_handle  h,
char *  db 
)

Unlock a database

Parameters
[in]hCLICON handle
[in]dbdatabase, eg "running"
int clicon_rpc_validate ( clicon_handle  h,
char *  db 
)

Send validate request to backend daemon

Parameters
[in]hCLICON handle
[in]dbName of database
Return values
0OK