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

Date and Time

Various YANG data models uses YANG date-and-time type for representation of dates and times. The type is defined in ietf-yang-types module that comes from RFC 6021. The date-and-time type is, for example, used in all NETCONF event notifications.

The date-and-time format examples:

2014-06-05T12:19:58Z
2014-06-05T14:19:58+02:00

libnetconf provides two functions to handle timestamps:

  • nc_datetime2time() to convert YANG date-and-time value to ISO C time_t data type representing the time as the number of seconds since Epoch (1970-01-01 00:00:00 +0000 UTC). This data type is used by various standard functions such as localtime() or ctime().
  • nc_time2datetime() is a reverse function to the previous one. Optionally, it accepts specification of the timezone in which the resulting date-and-time value will be returned.

NETCONF Errors Handling

NETCONF protocol specifications (RFC 6241) defines list of errors that can be returned by the server. libnetconf provides a set of functions that server to create, manipulate and process NETCONF errors.

NETCONF error is represented by struct nc_err. Specifying one of the basic errors, a new error structure can be created by calling the nc_err_new() function. If the caller want to change a specific attribute, the nc_err_set() function can be used. To get the value of the specific error attribute, there is nc_err_get() function. If the caller want to create a copy of some existing error structure, nc_err_dup() can be used. And finally to free all allocated resources, the nc_err_free() is available.

To create <rpc-error> reply, the application is supposed to use nc_reply_error() and nc_reply_error_add() to add another error structure to the reply.

On the client side, <rpc-error> replies can be handled manually as any other <rpc-reply> recognizing its type using nc_reply_get_type() and then by getting the error message via nc_reply_get_errormsg() and parsing its content manually. The other, recomended, way how to handle incoming <rpc-error> replies is to specify the callback function via nc_callback_error_reply(). The callback is automatically invoked to process (e.g. print) <rpc-error> message. In this case, all NETCONF error attributes are parsed and passed to the callback function.

Logging Messages

libnetconf provides information about the data processing on several verbose levels. However, by default there is no printing routine, so no message from libnetconf appears until the printing callback is specified using nc_callback_print() function. Application is able to set (and change) the current verbose levels via the nc_verbosity() function.

Mainly for transAPI modules, there is a set of functions to access message printing callback outside the library: