libnetconf  0.10.0-146_trunk
NETCONF Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
NETCONF rpc (libxml2)

libnetconf's functions for handling the NETCONF <rpc> messages. These functions accepts parameters as libxml2 structures. More...

Functions

struct nc_filter * ncxml_filter_new (NC_FILTER_TYPE type,...)
 Create a new NETCONF filter of the specified type. More...
 
nc_rpcncxml_rpc_build (xmlDocPtr rpc_dump, const struct nc_session *session)
 Build <rpc> message from the libxml2 document structure. This is the reverse function of the ncxml_rpc_dump(). More...
 
nc_rpcncxml_rpc_copyconfig (NC_DATASTORE source, NC_DATASTORE target,...)
 Create <copy-config> NETCONF rpc message. More...
 
xmlDocPtr ncxml_rpc_dump (const nc_rpc *rpc)
 Dump the rpc message into a libxml2 document structure. More...
 
nc_rpcncxml_rpc_editconfig (NC_DATASTORE target, NC_DATASTORE source, NC_EDIT_DEFOP_TYPE default_operation, NC_EDIT_ERROPT_TYPE error_option, NC_EDIT_TESTOPT_TYPE test_option,...)
 Create <edit-config> NETCONF rpc message. More...
 
nc_rpcncxml_rpc_generic (const xmlNodePtr data)
 Create a generic NETCONF rpc message with the specified content. More...
 
xmlNodePtr ncxml_rpc_get_config (const nc_rpc *rpc)
 Get <config> element from the RPC operation including its content. This function is valid only for <copy-config> and <edit-config> RPCs. More...
 
xmlNodePtr ncxml_rpc_get_op_content (const nc_rpc *rpc)
 Get the content of the operation specification from the given rpc. More...
 

Detailed Description

libnetconf's functions for handling the NETCONF <rpc> messages. These functions accepts parameters as libxml2 structures.

Function Documentation

struct nc_filter* ncxml_filter_new ( NC_FILTER_TYPE  type,
  ... 
)

Create a new NETCONF filter of the specified type.

Parameters
[in]typeType of the filter.
[in]...Filter content:
  • for NC_FILTER_SUBTREE type, single variadic parameter const xmlNodePtr filter with the content for the <filter> element is accepted. The filter parameter is not supposed to contain <filter> element, but only its content. The node is taken as a node list, so the sibling nodes are also added into the filter definition. If NULL is specified, the Empty filter (RFC 6241 sec 6.4.2) is created.
Returns
Created NETCONF filter structure.
nc_rpc* ncxml_rpc_build ( xmlDocPtr  rpc_dump,
const struct nc_session *  session 
)

Build <rpc> message from the libxml2 document structure. This is the reverse function of the ncxml_rpc_dump().

Parameters
[in]rpc_dumpXML document structure with the NETCONF <rpc> message. The structure is integrated into the internal rpc structure and caller should not access (or free) given XML document anymore.
[in]sessionSession information needed for ACM. If NULL, ACM structure is not prepared and no ACM rules will be applied to the created RPC message.
Returns
Complete rpc structure used by libnetconf's functions.
nc_rpc* ncxml_rpc_copyconfig ( NC_DATASTORE  source,
NC_DATASTORE  target,
  ... 
)

Create <copy-config> NETCONF rpc message.

Variadic parameters:

  • the source is specified as NC_DATASTORE_CONFIG:
    • nc_rpc_copyconfig() accepts as the first variadic parameter const xmlNodePtr source_config providing the complete configuration data to copy.
  • the source is specified as NC_DATASTORE_URL:
    • nc_rpc_copyconfig() accepts as the first variadic parameter const char* source_url providing the URL to the file
  • target is specified as NC_DATASTORE_URL:
    • nc_rpc_copyconfig() accepts as another (first or second according to eventual previous variadic parameter) variadic parameter const char* target_url providing the URL to the target file.

The file that the url refers to contains the complete datastore, encoded in XML under the element <config> in the "urn:ietf:params:xml:ns:netconf:base:1.0" namespace.

Parameters
[in]sourceSource configuration datastore type. If the NC_DATASTORE_NONE is specified, data parameter is used as the complete configuration to copy.
[in]targetTarget configuration datastore type to be replaced.
[in]...Specific parameters according to the source and target parameters.
Returns
Created rpc message.
xmlDocPtr ncxml_rpc_dump ( const nc_rpc rpc)

Dump the rpc message into a libxml2 document structure.

Parameters
[in]rpcrpc message.
Returns
XML document of the NETCONF's <rpc> message. Caller is supposed to free the returned structure with xmlFreeDoc().
nc_rpc* ncxml_rpc_editconfig ( NC_DATASTORE  target,
NC_DATASTORE  source,
NC_EDIT_DEFOP_TYPE  default_operation,
NC_EDIT_ERROPT_TYPE  error_option,
NC_EDIT_TESTOPT_TYPE  test_option,
  ... 
)

Create <edit-config> NETCONF rpc message.

Parameters
[in]targetTarget configuration datastore type to be edited.
[in]sourceSpecifies the type of the source data taken from the variadic parameter. Only NC_DATASTORE_CONFIG (variadic parameter contains the <config> data) and NC_DATASTORE_URL (variadic parameter contains URL for <url> element) values are accepted.
[in]default_operationDefault operation for this request, 0 to skip the setting of this parameter and use default server ('merge') behavior.
[in]error_optionSet the response to an error, 0 for the server default behavior.
[in]test_optionSet test-option element according to :validate:1.1 capability specified in RFC 6241.
[in]...According to the source parameter, variadic parameter can be one of the following:
  • const xmlNodePtr config defining the content of the <config> element in case the source parameter is specified as NC_DATASTORE_CONFIG. The config parameter can points to the node list.
  • const char* source_url specifying URL, in case the source parameter is specified as NC_DATASTORE_URL. The URL must refer to the file containing configuration data hierarchy to be modified, encoded in XML under the element <config> in the "urn:ietf:params:xml:ns:netconf:base:1.0" namespace.
Returns
Created rpc message.
nc_rpc* ncxml_rpc_generic ( const xmlNodePtr  data)

Create a generic NETCONF rpc message with the specified content.

The function recieves the data parameter and envelopes it into an <rpc> container. Caller is fully responsible for the correctness of the given data.

Parameters
[in]dataXML content of the <rpc> request to be sent.
Returns
Created rpc message.
xmlNodePtr ncxml_rpc_get_config ( const nc_rpc rpc)

Get <config> element from the RPC operation including its content. This function is valid only for <copy-config> and <edit-config> RPCs.

Parameters
[in]rpc<copy-config> or <edit-config> rpc message.
Returns
XML node <config> with its content or NULL on error. Note that <config> can contain no data. Caller is supposed to free the returned structure with xmlFreeNode().
xmlNodePtr ncxml_rpc_get_op_content ( const nc_rpc rpc)

Get the content of the operation specification from the given rpc.

Parameters
[in]rpcrpc message.
Returns
libxml2 node structure with the NETCONF operation element(s) and its content. Caller is supposed to free the returned structure with xmlFreeNodeList().