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

libnetconf's functions for handling NETCONF <rpc-reply> messages. More...

Typedefs

typedef struct nc_msg nc_reply
 reply message. More...
 

Enumerations

enum  NC_REPLY_TYPE {
  NC_REPLY_UNKNOWN, NC_REPLY_HELLO, NC_REPLY_OK, NC_REPLY_ERROR,
  NC_REPLY_DATA
}
 Enumeration of <rpc-reply> types. More...
 

Functions

void nc_callback_error_reply (void(*func)(const char *tag, const char *type, const char *severity, const char *apptag, const char *path, const char *message, const char *attribute, const char *element, const char *ns, const char *sid))
 Set a callback function to process (e.g. print) NETCONF <rpc-error> message items.If the func parameter is NULL, the callback is set back to the default (no) function. More...
 
nc_replync_reply_build (const char *reply_dump)
 Build <rpc-reply> message from the string. This is the reverse function of the nc_reply_dump(). More...
 
nc_replync_reply_data (const char *data)
 Create rpc-reply response with <data> content (in urn:ietf:params:xml:ns:netconf:base:1.0 namespace). More...
 
nc_replync_reply_data_ns (const char *data, const char *ns)
 Create rpc-reply response with <data> content in the specified namespace. More...
 
char * nc_reply_dump (const nc_reply *reply)
 Dump the rpc-reply message into a string. More...
 
nc_replync_reply_dup (const nc_reply *reply)
 Duplicate <reply> message. More...
 
nc_replync_reply_error (struct nc_err *error)
 Create rpc-reply response with <rpc-error> content. More...
 
int nc_reply_error_add (nc_reply *reply, struct nc_err *error)
 Add another error description into the existing rpc-reply with <rpc-error> content. More...
 
void nc_reply_free (nc_reply *reply)
 Free reply message. More...
 
char * nc_reply_get_data (const nc_reply *reply)
 Get content of the <data> element in <rpc-reply>. More...
 
const char * nc_reply_get_data_ns (const nc_reply *reply)
 Get namespace of the <data> element in <rpc-reply>. More...
 
const char * nc_reply_get_errormsg (const nc_reply *reply)
 Get error-message from the server's <rpc-error> reply. More...
 
const nc_msgid nc_reply_get_msgid (const nc_reply *reply)
 Get message-id of the given rpc-reply. More...
 
NC_REPLY_TYPE nc_reply_get_type (const nc_reply *reply)
 Get the type of the rpc-reply message. More...
 
nc_replync_reply_merge (int count,...)
 Merge reply messages. All messages MUST be of the same type. More...
 
nc_replync_reply_ok (void)
 Create <ok> rpc-reply response. More...
 
NC_MSG_TYPE nc_session_recv_reply (struct nc_session *session, int timeout, nc_reply **reply)
 Receive <rpc-reply> response from the specified NETCONF session. This function is supposed to be performed only by NETCONF clients. More...
 
const nc_msgid nc_session_send_reply (struct nc_session *session, const nc_rpc *rpc, const nc_reply *reply)
 Send <rpc-reply> response via specified NETCONF session. This function is supposed to be performed only by NETCONF servers. More...
 

Detailed Description

libnetconf's functions for handling NETCONF <rpc-reply> messages.

Typedef Documentation

typedef struct nc_msg nc_reply

reply message.

Enumeration Type Documentation

Enumeration of <rpc-reply> types.

Enumerator
NC_REPLY_UNKNOWN 

value describing that no rpc-reply type was detected so far

NC_REPLY_HELLO 

<hello> message type, same as NC_RPC_HELLO

NC_REPLY_OK 

<ok> rpc-reply message type

NC_REPLY_ERROR 

<rpc-error> rpc-reply message type

NC_REPLY_DATA 

rpc-reply message containing <data>

Function Documentation

void nc_callback_error_reply ( void(*)(const char *tag, const char *type, const char *severity, const char *apptag, const char *path, const char *message, const char *attribute, const char *element, const char *ns, const char *sid)  func)

Set a callback function to process (e.g. print) NETCONF <rpc-error> message items.If the func parameter is NULL, the callback is set back to the default (no) function.

Parameters
[in]funcCallback function to use. Passed parameters are:
  • tag - error tag,
  • type - error layer where the error occurred,
  • severity - error severity,
  • apptag - the data-model-specific or implementation-specific error condition, if one exists,
  • path - XPATH expression identifying element with the error,
  • message - human-readable description of the error,
  • attribute - name of the data-model-specific XML attribute that caused the error,
  • element - name of the data-model-specific XML element that caused the error,
  • ns - name of the unexpected XML namespace that caused the error,
  • sid - session ID of the session holding the requested lock.
nc_reply* nc_reply_build ( const char *  reply_dump)

Build <rpc-reply> message from the string. This is the reverse function of the nc_reply_dump().

Parameters
[in]reply_dumpString containing the NETCONF <rpc-reply> message.
Returns
Complete reply structure used by libnetconf's functions.
nc_reply* nc_reply_data ( const char *  data)

Create rpc-reply response with <data> content (in urn:ietf:params:xml:ns:netconf:base:1.0 namespace).

Parameters
[in]dataSerialized XML content of the <data> element for the <rpc-reply> message being created.
Returns
Created <rpc-reply> message.
nc_reply* nc_reply_data_ns ( const char *  data,
const char *  ns 
)

Create rpc-reply response with <data> content in the specified namespace.

Parameters
[in]dataSerialized XML content of the <data> element for the <rpc-reply> message being created.
[in]nsDefault namespace for the data element.
Returns
Created <rpc-reply> message.
char* nc_reply_dump ( const nc_reply reply)

Dump the rpc-reply message into a string.

Parameters
[in]replyrpc-reply message.
Returns
String in XML format containing the NETCONF's <rpc-reply> element and all of its content. Caller is responsible for freeing the returned string with free().
nc_reply* nc_reply_dup ( const nc_reply reply)

Duplicate <reply> message.

Parameters
[in]reply<reply> message to replicate.
Returns
Copy of the given <reply> message.
nc_reply* nc_reply_error ( struct nc_err *  error)

Create rpc-reply response with <rpc-error> content.

Parameters
[in]errorNETCONF error description structure for the reply message. From now, the error is connected with the reply and should not be used by the caller.
Returns
Created <rpc-reply> message.
int nc_reply_error_add ( nc_reply reply,
struct nc_err *  error 
)

Add another error description into the existing rpc-reply with <rpc-error> content.

This function can be applied only to reply messages created by nc_reply_error().

Parameters
[in,out]replyReply structure to which the given error description will be added.
[in]errorNETCONF error description structure for the reply message. From now, the error is connected with the reply and should not be used by the caller.
Returns
0 on success, non-zero else.
void nc_reply_free ( nc_reply reply)

Free reply message.

Parameters
[in]replyreply message to free.
char* nc_reply_get_data ( const nc_reply reply)

Get content of the <data> element in <rpc-reply>.

Parameters
replyrpc-reply message.
Returns
String with the content of the <data> element. Caller is responsible for freeing the returned string with free().
const char* nc_reply_get_data_ns ( const nc_reply reply)

Get namespace of the <data> element in <rpc-reply>.

Parameters
replyrpc-reply message.
Returns
Namespace of the <data> element. Do not free.
const char* nc_reply_get_errormsg ( const nc_reply reply)

Get error-message from the server's <rpc-error> reply.

Parameters
replyrpc-reply message of the NC_REPLY_ERROR type.
Returns
String with the content of the <error-message> element. Referenced string is a part of the reply, so it can not be used after freeing the given reply.
const nc_msgid nc_reply_get_msgid ( const nc_reply reply)

Get message-id of the given rpc-reply.

Parameters
[in]replyrpc-reply message.
Returns
message-id of the given rpc-reply message.
NC_REPLY_TYPE nc_reply_get_type ( const nc_reply reply)

Get the type of the rpc-reply message.

<rpc-reply> message can contain <ok>, <rpc-error> or <data>

Parameters
[in]replyrpc-reply message
Returns
One of the NC_REPLY_TYPE.
nc_reply* nc_reply_merge ( int  count,
  ... 
)

Merge reply messages. All messages MUST be of the same type.

Function merges a number of <rpc-reply> specified by the count parameter (at least 2) into one <rpc-reply> message which is returned as the result. When the merge is successful, all input messages are freed and MUST NOT be used after this call. Merge can fail only because of an invalid input parameter. In such a case, NULL is returned and input messages are left unchanged.

Parameters
[in]countNumber of messages to merge
[in]...Messages to merge (all are of nc_reply* type). Total number of messages MUST be equal to count.
Returns
Pointer to a new reply message with the merged content of the messages to merge. If an error occurs (due to the invalid input parameters), NULL is returned and the messages to merge are not freed.
nc_reply* nc_reply_ok ( void  )

Create <ok> rpc-reply response.

Returns
Created <rpc-reply> message.
NC_MSG_TYPE nc_session_recv_reply ( struct nc_session *  session,
int  timeout,
nc_reply **  reply 
)

Receive <rpc-reply> response from the specified NETCONF session. This function is supposed to be performed only by NETCONF clients.

Parameters
[in]sessionNETCONF session to use.
[in]timeoutTimeout in microseconds, -1 for infinite timeout, 0 for non-blocking
[out]replyReceived <rpc-reply>
Returns
const nc_msgid nc_session_send_reply ( struct nc_session *  session,
const nc_rpc rpc,
const nc_reply reply 
)

Send <rpc-reply> response via specified NETCONF session. This function is supposed to be performed only by NETCONF servers.

This function IS thread safe.

Parameters
[in]sessionNETCONF session to use.
[in]rpc<rpc> message which is request for the sending reply
[in]reply<repc-reply> message to send.
Returns
0 on error,
message-id of sent message on success.