libnetconf2  3.5.1
NETCONF server and client library in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Server Messages

Functions to create NETCONF Event notifications and replies to the NETCONF RPCs (or actions). More...

Collaboration diagram for Server Messages:

Typedefs

typedef enum NC_ERROR NC_ERR
 Enumeration of NETCONF errors. More...
 
typedef enum NC_ERROR_TYPE NC_ERR_TYPE
 Enumeration of NETCONF error type (layer) More...
 

Enumerations

enum  NC_ERROR {
  NC_ERR_UNKNOWN = 0, NC_ERR_IN_USE, NC_ERR_INVALID_VALUE, NC_ERR_TOO_BIG,
  NC_ERR_MISSING_ATTR, NC_ERR_BAD_ATTR, NC_ERR_UNKNOWN_ATTR, NC_ERR_MISSING_ELEM,
  NC_ERR_BAD_ELEM, NC_ERR_UNKNOWN_ELEM, NC_ERR_UNKNOWN_NS, NC_ERR_ACCESS_DENIED,
  NC_ERR_LOCK_DENIED, NC_ERR_RES_DENIED, NC_ERR_ROLLBACK_FAILED, NC_ERR_DATA_EXISTS,
  NC_ERR_DATA_MISSING, NC_ERR_OP_NOT_SUPPORTED, NC_ERR_OP_FAILED, NC_ERR_MALFORMED_MSG
}
 Enumeration of NETCONF errors. More...
 
enum  NC_ERROR_TYPE {
  NC_ERR_TYPE_UNKNOWN = 0, NC_ERR_TYPE_TRAN, NC_ERR_TYPE_RPC, NC_ERR_TYPE_PROT,
  NC_ERR_TYPE_APP
}
 Enumeration of NETCONF error type (layer) More...
 

Functions

struct lyd_node * nc_err (const struct ly_ctx *ctx, NC_ERR tag,...)
 Create a server error structure. Its <error-message> is filled with a general description of the specific error. More...
 
int nc_err_add_bad_attr (struct lyd_node *err, const char *attr_name)
 Add a <bad-attribute> element to an error. More...
 
int nc_err_add_bad_elem (struct lyd_node *err, const char *elem_name)
 Add a <bad-element> element to an error. More...
 
int nc_err_add_bad_ns (struct lyd_node *err, const char *ns_name)
 Add a <bad-namespace> element to an error. More...
 
int nc_err_add_info_other (struct lyd_node *err, struct lyd_node *other)
 Add an additional custom element to an error. More...
 
const char * nc_err_get_app_tag (const struct lyd_node *err)
 Get the <error-app-tag> of a server error. More...
 
const char * nc_err_get_msg (const struct lyd_node *err)
 Get the <error-message> of a server error. More...
 
const char * nc_err_get_path (const struct lyd_node *err)
 Get the <error-path> of a server error. More...
 
NC_ERR nc_err_get_tag (const struct lyd_node *err)
 Get the <error-tag> of a server error. More...
 
NC_ERR_TYPE nc_err_get_type (const struct lyd_node *err)
 Get the <error-type> of a server error. More...
 
int nc_err_set_app_tag (struct lyd_node *err, const char *error_app_tag)
 Set the <error-app-tag> element of an error. Any previous value will be overwritten. More...
 
int nc_err_set_msg (struct lyd_node *err, const char *error_message, const char *lang)
 Set the <error-message> element of an error. Any previous value will be overwritten. More...
 
int nc_err_set_path (struct lyd_node *err, const char *error_path)
 Set the <error-path> element of an error. Any previous value will be overwritten. More...
 
int nc_err_set_sid (struct lyd_node *err, uint32_t session_id)
 Set the <session-id> element of an error. Any previous value will be overwritten. More...
 
void nc_server_notif_free (struct nc_server_notif *notif)
 Free a server Event Notification object. More...
 
const char * nc_server_notif_get_time (const struct nc_server_notif *notif)
 Get the notification timestamp. More...
 
struct nc_server_notif * nc_server_notif_new (struct lyd_node *event, char *eventtime, NC_PARAMTYPE paramtype)
 Create Event Notification object to be sent to the subscribed client(s). More...
 
NC_MSG_TYPE nc_server_notif_send (struct nc_session *session, struct nc_server_notif *notif, int timeout)
 Send NETCONF Event Notification via the session. More...
 
int nc_server_reply_add_err (struct nc_server_reply *reply, struct lyd_node *err)
 Add another error opaque data node tree to an ERROR rpc-reply object. More...
 
struct nc_server_reply * nc_server_reply_data (struct lyd_node *data, NC_WD_MODE wd, NC_PARAMTYPE paramtype)
 Create a DATA rpc-reply object. More...
 
struct nc_server_reply * nc_server_reply_err (struct lyd_node *err)
 Create an ERROR rpc-reply object. More...
 
void nc_server_reply_free (struct nc_server_reply *reply)
 Free a server rpc-reply object. More...
 
struct lyd_node * nc_server_reply_get_last_err (const struct nc_server_reply *reply)
 Get last error from an ERROR rpc-reply object. More...
 
struct nc_server_reply * nc_server_reply_ok (void)
 Create an OK rpc-reply object. More...
 

Detailed Description

Functions to create NETCONF Event notifications and replies to the NETCONF RPCs (or actions).

Typedef Documentation

typedef enum NC_ERROR NC_ERR

Enumeration of NETCONF errors.

typedef enum NC_ERROR_TYPE NC_ERR_TYPE

Enumeration of NETCONF error type (layer)

Enumeration Type Documentation

enum NC_ERROR

Enumeration of NETCONF errors.

Enumerator
NC_ERR_UNKNOWN 

unknown error

NC_ERR_IN_USE 

in-use error

NC_ERR_INVALID_VALUE 

invalid-value error

NC_ERR_TOO_BIG 

too-big error

NC_ERR_MISSING_ATTR 

missing-attribute error

NC_ERR_BAD_ATTR 

bad-attribute error

NC_ERR_UNKNOWN_ATTR 

unknown-attribute error

NC_ERR_MISSING_ELEM 

missing-element error

NC_ERR_BAD_ELEM 

bad-element error

NC_ERR_UNKNOWN_ELEM 

unknown-element error

NC_ERR_UNKNOWN_NS 

unknown-namespace error

NC_ERR_ACCESS_DENIED 

access-denied error

NC_ERR_LOCK_DENIED 

lock-denied error

NC_ERR_RES_DENIED 

resource-denied error

NC_ERR_ROLLBACK_FAILED 

rollback-failed error

NC_ERR_DATA_EXISTS 

data-exists error

NC_ERR_DATA_MISSING 

data-missing error

NC_ERR_OP_NOT_SUPPORTED 

operation-not-supported error

NC_ERR_OP_FAILED 

operation-failed error

NC_ERR_MALFORMED_MSG 

malformed-message error

Definition at line 42 of file messages_server.h.

Enumeration of NETCONF error type (layer)

Enumerator
NC_ERR_TYPE_UNKNOWN 

unknown layer

NC_ERR_TYPE_TRAN 

transport layer

NC_ERR_TYPE_RPC 

RPC layer

NC_ERR_TYPE_PROT 

protocol layer

NC_ERR_TYPE_APP 

application layer

Definition at line 68 of file messages_server.h.

Function Documentation

struct nc_server_reply* nc_server_reply_ok ( void  )

Create an OK rpc-reply object.

Returns
rpc-reply object, NULL on error.
struct nc_server_reply* nc_server_reply_data ( struct lyd_node *  data,
NC_WD_MODE  wd,
NC_PARAMTYPE  paramtype 
)

Create a DATA rpc-reply object.

Parameters
[in]dataReply data tree pointing to the RPC/action itself. This tree must be valid according to the RPC output of the RPC this is a reply to.
[in]wdwith-default mode if applicable
[in]paramtypeDetermines how the data parameter is treated.
Returns
rpc-reply object, NULL on error.
struct nc_server_reply* nc_server_reply_err ( struct lyd_node *  err)

Create an ERROR rpc-reply object.

Parameters
[in]errErrors created by nc_err(). It will be freed with the returned object.
Returns
rpc-reply object, NULL on error.
int nc_server_reply_add_err ( struct nc_server_reply *  reply,
struct lyd_node *  err 
)

Add another error opaque data node tree to an ERROR rpc-reply object.

Parameters
[in]replyERROR reply to add to.
[in]errError created by nc_err(). It will be freed with the returned object.
Returns
0 on success, -1 on errror.
struct lyd_node* nc_server_reply_get_last_err ( const struct nc_server_reply *  reply)

Get last error from an ERROR rpc-reply object.

Parameters
[in]replyERROR reply to read from.
Returns
Last error opaque data tree, NULL on failure.
struct lyd_node* nc_err ( const struct ly_ctx *  ctx,
NC_ERR  tag,
  ... 
)

Create a server error structure. Its <error-message> is filled with a general description of the specific error.

Parameters
[in]ctxlibyang context to use.
[in]tag<error-tag> of the server error specified as NC_ERR value. According to the tag, the specific additional parameters are required:
[in]...Additional arguments depending on the tag used.
Returns
Opaque data node tree representing the error.
NC_ERR_TYPE nc_err_get_type ( const struct lyd_node *  err)

Get the <error-type> of a server error.

Parameters
[in]errError opaque data node tree to read from.
Returns
Server error type, 0 on error.
NC_ERR nc_err_get_tag ( const struct lyd_node *  err)

Get the <error-tag> of a server error.

Parameters
[in]errError opaque data node tree to read from.
Returns
Server error tag, 0 on error.
int nc_err_set_app_tag ( struct lyd_node *  err,
const char *  error_app_tag 
)

Set the <error-app-tag> element of an error. Any previous value will be overwritten.

Parameters
[in]errError opaque data node tree to modify.
[in]error_app_tagNew value of <error-app-tag>.
Returns
0 on success, -1 on error.
const char* nc_err_get_app_tag ( const struct lyd_node *  err)

Get the <error-app-tag> of a server error.

Parameters
[in]errError opaque data node tree to read from.
Returns
Server error app tag, NULL on error.
int nc_err_set_path ( struct lyd_node *  err,
const char *  error_path 
)

Set the <error-path> element of an error. Any previous value will be overwritten.

Parameters
[in]errError opaque data node tree to modify.
[in]error_pathNew value of <error-path>.
Returns
0 on success, -1 on error.
const char* nc_err_get_path ( const struct lyd_node *  err)

Get the <error-path> of a server error.

Parameters
[in]errError opaque data node tree to read from.
Returns
Server error path, NULL on error.
int nc_err_set_msg ( struct lyd_node *  err,
const char *  error_message,
const char *  lang 
)

Set the <error-message> element of an error. Any previous value will be overwritten.

Parameters
[in]errError opaque data node tree to modify.
[in]error_messageNew value of <error-message>.
[in]langOptional language of error_message.
Returns
0 on success, -1 on error.
const char* nc_err_get_msg ( const struct lyd_node *  err)

Get the <error-message> of a server error.

Parameters
[in]errError opaque data node tree to read from.
Returns
Server error message, NULL on error.
int nc_err_set_sid ( struct lyd_node *  err,
uint32_t  session_id 
)

Set the <session-id> element of an error. Any previous value will be overwritten.

Parameters
[in]errError opaque data node tree to modify.
[in]session_idNew value of <session-id>.
Returns
0 on success, -1 on error.
int nc_err_add_bad_attr ( struct lyd_node *  err,
const char *  attr_name 
)

Add a <bad-attribute> element to an error.

Parameters
[in]errError opaque data node tree to modify.
[in]attr_nameValue of the new <bad-attribute> element.
Returns
0 on success, -1 on error.
int nc_err_add_bad_elem ( struct lyd_node *  err,
const char *  elem_name 
)

Add a <bad-element> element to an error.

Parameters
[in]errError opaque data node tree to modify.
[in]elem_nameValue of the new <bad-element> element.
Returns
0 on success, -1 on error.
int nc_err_add_bad_ns ( struct lyd_node *  err,
const char *  ns_name 
)

Add a <bad-namespace> element to an error.

Parameters
[in]errError opaque data node tree to modify.
[in]ns_nameValue of the new <bad-namespace> element.
Returns
0 on success, -1 on error.
int nc_err_add_info_other ( struct lyd_node *  err,
struct lyd_node *  other 
)

Add an additional custom element to an error.

Parameters
[in]errError opaque data node tree to modify.
[in]otherOther error opaque data node tree.
Returns
0 on success, -1 on error.
void nc_server_reply_free ( struct nc_server_reply *  reply)

Free a server rpc-reply object.

Parameters
[in]replyServer rpc-reply object to free.
struct nc_server_notif* nc_server_notif_new ( struct lyd_node *  event,
char *  eventtime,
NC_PARAMTYPE  paramtype 
)

Create Event Notification object to be sent to the subscribed client(s).

Parameters
[in]eventNotification data tree (valid as LYD_OPT_NOTIF) from libyang. The tree is directly used in created object, so the caller is supposed to not free the tree on its own, but only via freeing the created object.
[in]eventtimeYANG dateTime format value of the time when the event was generated by the event source. Caller can use nc_timespec2datetime() to create the value from a timespec value.
[in]paramtypeHow to further manage data parameters.
Returns
Newly created structure of the Event Notification object to be sent to the clients via nc_server_notif_send() and freed using nc_server_notif_free().
NC_MSG_TYPE nc_server_notif_send ( struct nc_session *  session,
struct nc_server_notif *  notif,
int  timeout 
)

Send NETCONF Event Notification via the session.

Parameters
[in]sessionNETCONF session where the Event Notification will be written.
[in]notifNETCONF Notification object to send via specified session. Object can be created by nc_server_notif_new() function.
[in]timeoutTimeout for writing in milliseconds. Use negative value for infinite waiting and 0 for return if data cannot be sent immediately.
Returns
NC_MSG_NOTIF on success, NC_MSG_WOULDBLOCK in case of a busy session, and NC_MSG_ERROR on error.
void nc_server_notif_free ( struct nc_server_notif *  notif)

Free a server Event Notification object.

Parameters
[in]notifServer Event Notification object to free.
const char* nc_server_notif_get_time ( const struct nc_server_notif *  notif)

Get the notification timestamp.

Parameters
[in]notifServer notification to read from.
Returns
Datetime timestamp of the notification, NULL on error.