libnetconf2  1.1.48
NETCONF library for clients and servers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Miscellaneous

Miscellaneous macros, types, structure and functions for a generic use by both server and client applications. More...

Macros

#define NC_NS_BASE   "urn:ietf:params:xml:ns:netconf:base:1.0"
 Base NETCONF namespace. More...
 
#define NC_NS_NOTIF   "urn:ietf:params:xml:ns:netconf:notification:1.0"
 Notifications namespace. More...
 
#define NC_PORT_SSH   830
 Default NETCONF over SSH port. More...
 
#define NC_PORT_CH_SSH   4334
 Default NETCONF over SSH Call Home port. More...
 
#define NC_PORT_TLS   6513
 Default NETCONF over TLS port. More...
 
#define NC_PORT_CH_TLS   4335
 Default NETCONF over TLS Call Home port. More...
 
#define nc_set_rpc_callback(node, cb)   lys_set_private(node, cb)
 Set RPC callback to a schema node. More...
 

Typedefs

typedef enum NC_SESSION_TERM_REASON NC_SESSION_TERM_REASON
 Enumeration of reasons of the NETCONF session termination as defined in RFC 6470. More...
 
typedef enum NC_MSG_TYPE NC_MSG_TYPE
 Enumeration of NETCONF message types. More...
 
typedef enum NC_DATASTORE_TYPE NC_DATASTORE
 Enumeration of the supported types of datastores defined by NETCONF. More...
 
typedef enum NC_WITHDEFAULTS_MODE NC_WD_MODE
 Enumeration of NETCONF with-defaults capability modes. More...
 
typedef enum NC_REPLY NC_RPL
 Enumeration of NETCONF (both server and client) rpc-reply types. More...
 
typedef enum NC_PARAMTYPE NC_PARAMTYPE
 Enumeration of function parameter treatments. More...
 
typedef enum NC_VERB_LEVEL NC_VERB_LEVEL
 Verbosity levels. More...
 

Enumerations

enum  NC_SESSION_TERM_REASON {
  NC_SESSION_TERM_ERR = -1, NC_SESSION_TERM_NONE = 0, NC_SESSION_TERM_CLOSED, NC_SESSION_TERM_KILLED,
  NC_SESSION_TERM_DROPPED, NC_SESSION_TERM_TIMEOUT, NC_SESSION_TERM_BADHELLO, NC_SESSION_TERM_OTHER
}
 Enumeration of reasons of the NETCONF session termination as defined in RFC 6470. More...
 
enum  NC_MSG_TYPE {
  NC_MSG_ERROR, NC_MSG_WOULDBLOCK, NC_MSG_NONE, NC_MSG_HELLO,
  NC_MSG_BAD_HELLO, NC_MSG_RPC, NC_MSG_REPLY, NC_MSG_REPLY_ERR_MSGID,
  NC_MSG_NOTIF
}
 Enumeration of NETCONF message types. More...
 
enum  NC_DATASTORE_TYPE {
  NC_DATASTORE_ERROR = 0, NC_DATASTORE_CONFIG, NC_DATASTORE_URL, NC_DATASTORE_RUNNING,
  NC_DATASTORE_STARTUP, NC_DATASTORE_CANDIDATE
}
 Enumeration of the supported types of datastores defined by NETCONF. More...
 
enum  NC_WITHDEFAULTS_MODE {
  NC_WD_UNKNOWN = 0, NC_WD_ALL, NC_WD_ALL_TAG, NC_WD_TRIM,
  NC_WD_EXPLICIT
}
 Enumeration of NETCONF with-defaults capability modes. More...
 
enum  NC_REPLY { NC_RPL_OK, NC_RPL_DATA, NC_RPL_ERROR, NC_RPL_NOTIF }
 Enumeration of NETCONF (both server and client) rpc-reply types. More...
 
enum  NC_PARAMTYPE { NC_PARAMTYPE_CONST, NC_PARAMTYPE_FREE, NC_PARAMTYPE_DUP_AND_FREE }
 Enumeration of function parameter treatments. More...
 
enum  NC_VERB_LEVEL {
  NC_VERB_ERROR = 0, NC_VERB_WARNING = 1, NC_VERB_VERBOSE = 2, NC_VERB_DEBUG = 3,
  NC_VERB_DEBUG_LOWLVL = 4
}
 Verbosity levels. More...
 

Functions

char * nc_time2datetime (time_t time, const char *tz, char *buf)
 Transform given time_t (seconds since the epoch) into the RFC 3339 format accepted by NETCONF functions. More...
 
time_t nc_datetime2time (const char *datetime)
 Transform given string in RFC 3339 compliant format to the time_t (seconds since the epoch) accepted by most Linux functions. More...
 
void nc_verbosity (NC_VERB_LEVEL level)
 Set libnetconf's verbosity level. More...
 
void nc_libssh_thread_verbosity (int level)
 Set libssh verbosity level. More...
 
void nc_set_print_clb (void(*clb)(NC_VERB_LEVEL, const char *))
 Set libnetconf's print callback. More...
 

Variables

const char * nc_msgtype2str []
 Messages of NETCONF message type enum. More...
 

Detailed Description

Miscellaneous macros, types, structure and functions for a generic use by both server and client applications.

Macro Definition Documentation

#define NC_NS_BASE   "urn:ietf:params:xml:ns:netconf:base:1.0"

Base NETCONF namespace.

Definition at line 30 of file netconf.h.

#define NC_NS_NOTIF   "urn:ietf:params:xml:ns:netconf:notification:1.0"

Notifications namespace.

Definition at line 32 of file netconf.h.

#define NC_PORT_SSH   830

Default NETCONF over SSH port.

Definition at line 35 of file netconf.h.

#define NC_PORT_CH_SSH   4334

Default NETCONF over SSH Call Home port.

Definition at line 37 of file netconf.h.

#define NC_PORT_TLS   6513

Default NETCONF over TLS port.

Definition at line 40 of file netconf.h.

#define NC_PORT_CH_TLS   4335

Default NETCONF over TLS Call Home port.

Definition at line 42 of file netconf.h.

#define nc_set_rpc_callback (   node,
  cb 
)    lys_set_private(node, cb)

Set RPC callback to a schema node.

Parameters
[in]nodeconst struct lys_node *node
[in]cbnc_rpc_clb cb

Definition at line 50 of file netconf.h.

Typedef Documentation

Enumeration of reasons of the NETCONF session termination as defined in RFC 6470.

typedef enum NC_MSG_TYPE NC_MSG_TYPE

Enumeration of NETCONF message types.

Enumeration of the supported types of datastores defined by NETCONF.

Enumeration of NETCONF with-defaults capability modes.

typedef enum NC_REPLY NC_RPL

Enumeration of NETCONF (both server and client) rpc-reply types.

typedef enum NC_PARAMTYPE NC_PARAMTYPE

Enumeration of function parameter treatments.

Verbosity levels.

Enumeration Type Documentation

Enumeration of reasons of the NETCONF session termination as defined in RFC 6470.

Enumerator
NC_SESSION_TERM_ERR 

error return code for function getting the session termination reason

NC_SESSION_TERM_NONE 

session still running

NC_SESSION_TERM_CLOSED 

closed by client in a normal fashion

NC_SESSION_TERM_KILLED 

session was terminated by <kill-session> operation

NC_SESSION_TERM_DROPPED 

transport layer connection was unexpectedly closed

NC_SESSION_TERM_TIMEOUT 

terminated because of inactivity

NC_SESSION_TERM_BADHELLO 

<hello> message was invalid

NC_SESSION_TERM_OTHER 

terminated for some other reason

Definition at line 55 of file netconf.h.

Enumeration of NETCONF message types.

Enumerator
NC_MSG_ERROR 

error return value

NC_MSG_WOULDBLOCK 

timeout return value

NC_MSG_NONE 

no message at input or message was processed internally

NC_MSG_HELLO 

<hello> message

NC_MSG_BAD_HELLO 

<hello> message parsing failed

NC_MSG_RPC 

<rpc> message

NC_MSG_REPLY 

<rpc-reply> message

NC_MSG_REPLY_ERR_MSGID 

<rpc-reply> message with missing or wrong message-id attribute value

NC_MSG_NOTIF 

<notification> message

Definition at line 69 of file netconf.h.

Enumeration of the supported types of datastores defined by NETCONF.

Enumerator
NC_DATASTORE_ERROR 

error state of functions returning the datastore type

NC_DATASTORE_CONFIG 

value describing that the datastore is set as config

NC_DATASTORE_URL 

value describing that the datastore data should be given from the URL

NC_DATASTORE_RUNNING 

base NETCONF's datastore containing the current device configuration

NC_DATASTORE_STARTUP 

separated startup datastore as defined in Distinct Startup Capability

NC_DATASTORE_CANDIDATE 

separated working datastore as defined in Candidate Configuration Capability

Definition at line 89 of file netconf.h.

Enumeration of NETCONF with-defaults capability modes.

Enumerator
NC_WD_UNKNOWN 

invalid mode

NC_WD_ALL 

report-all mode

NC_WD_ALL_TAG 

report-all-tagged mode

NC_WD_TRIM 

trim mode

NC_WD_EXPLICIT 

explicit mode

Definition at line 101 of file netconf.h.

enum NC_REPLY

Enumeration of NETCONF (both server and client) rpc-reply types.

Enumerator
NC_RPL_OK 

OK rpc-reply

NC_RPL_DATA 

DATA rpc-reply

NC_RPL_ERROR 

ERROR rpc-reply

NC_RPL_NOTIF 

notification (client-only)

Definition at line 112 of file netconf.h.

Enumeration of function parameter treatments.

Enumerator
NC_PARAMTYPE_CONST 

use the parameter directly, do not free

NC_PARAMTYPE_FREE 

use the parameter directly, free afterwards

NC_PARAMTYPE_DUP_AND_FREE 

make a copy of the argument, free afterwards

Definition at line 122 of file netconf.h.

Verbosity levels.

Enumerator
NC_VERB_ERROR 

Print only error messages.

NC_VERB_WARNING 

Print error and warning messages.

NC_VERB_VERBOSE 

Besides errors and warnings, print some other verbose messages.

NC_VERB_DEBUG 

Print almost all messages including some development debug messages.

NC_VERB_DEBUG_LOWLVL 

Print all messages including low level debug messages.

Definition at line 30 of file log.h.

Function Documentation

char* nc_time2datetime ( time_t  time,
const char *  tz,
char *  buf 
)

Transform given time_t (seconds since the epoch) into the RFC 3339 format accepted by NETCONF functions.

This is a reverse function to nc_datetime2time().

Parameters
[in]timeTime to convert.
[in]tzTimezone name for the result. See tzselect(1) for list of correct values. If not specified (NULL) or unknown/invalid, the result is provided in UTC (Zulu).
[in]bufOptional buffer to print the datetime into, should be at least 26 characters long!
Returns
Printed string in a format compliant to RFC 3339 stored in buf if provided, otherwise it is up to the caller to free the returned string. NULL on error.
time_t nc_datetime2time ( const char *  datetime)

Transform given string in RFC 3339 compliant format to the time_t (seconds since the epoch) accepted by most Linux functions.

This is a reverse function to nc_time2datetime().

Parameters
[in]datetimeTime structure returned e.g. by localtime().
Returns
time_t value of the given string, -1 on error.
void nc_verbosity ( NC_VERB_LEVEL  level)

Set libnetconf's verbosity level.

This level is set for libnetconf2 and alo libyang that is used internally. libyang verbose level can be set explicitly, but must be done so after calling this function. However, if debug verbosity is used, selecting displayed libyang debug message groups must be done explicitly.

Parameters
[in]levelEnabled verbosity level (includes all the levels with higher priority).
void nc_libssh_thread_verbosity ( int  level)

Set libssh verbosity level.

libssh verbosity is set separately because it defines more verbose levels than libnetconf2. Also, you need to set this for every thread unlike libnetconf verbosity.

Values:

  • 0 - no logging,
  • 1 - rare conditions or warnings,
  • 2 - API-accessible entrypoints,
  • 3 - packet id and size,
  • 4 - functions entering and leaving.
Parameters
[in]levellibssh verbosity level.
void nc_set_print_clb ( void(*)(NC_VERB_LEVEL, const char *)  clb)

Set libnetconf's print callback.

This callback is set for libnetconf2 and also libyang that is used internally. libyang callback can be set explicitly, but must be done so after calling this function.

Parameters
[in]clbCallback that is called for every message.

Variable Documentation

const char* nc_msgtype2str[]

Messages of NETCONF message type enum.