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

libnetconf's functions for handling NETCONF sessions. More...

Macros

#define nc_msgid   char*
 Type representing NETCONF message-id attribute. More...
 

Enumerations

enum  NC_SESSION_STATUS {
  NC_SESSION_STATUS_ERROR = -1, NC_SESSION_STATUS_STARTUP = 0, NC_SESSION_STATUS_WORKING = 1, NC_SESSION_STATUS_CLOSING = 2,
  NC_SESSION_STATUS_CLOSED = 3, NC_SESSION_STATUS_DUMMY = 4
}
 Enumeration of the possible states of a NETCONF session. More...
 
enum  NC_SESSION_TERM_REASON {
  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_SSH_AUTH_TYPE { NC_SSH_AUTH_PUBLIC_KEYS = 1, NC_SSH_AUTH_PASSWORD = 2, NC_SSH_AUTH_INTERACTIVE = 4 }
 Available SSH authentication mechanisms. More...
 
enum  NC_TRANSPORT { NC_TRANSPORT_UNKNOWN = -1, NC_TRANSPORT_SSH, NC_TRANSPORT_TLS }
 Supported NETCONF transport protocols enumeration. To change currently used transport protocol, call nc_session_transport(). More...
 

Functions

void nc_callback_ssh_host_authenticity_check (int(*func)(const char *hostname, ssh_session session))
 Set a callback function to authorize authenticity of the remote host. More...
 
void nc_callback_sshauth_interactive (char *(*func)(const char *name, const char *instruction, const char *prompt, int echo))
 Set a callback function for passing user credentials into the libssh's keyboard-interactive authentication method. More...
 
void nc_callback_sshauth_passphrase (char *(*func)(const char *username, const char *hostname, const char *priv_key_file))
 Set a callback function for passing the user password into the libssh's publickey authentication method when connecting to 'hostname' as 'username'. More...
 
void nc_callback_sshauth_password (char *(*func)(const char *username, const char *hostname))
 Set a callback function for passing the user password into the libssh's password authentication method when connecting to 'hostname' as 'username'. More...
 
int nc_cpblts_add (struct nc_cpblts *capabilities, const char *capability_string)
 Add another capability string into the NETCONF capabilities structure. More...
 
int nc_cpblts_count (const struct nc_cpblts *c)
 Get the number of capabilities in the structure. More...
 
int nc_cpblts_enabled (const struct nc_session *session, const char *capability_string)
 Check if the given capability is supported by the session. More...
 
void nc_cpblts_free (struct nc_cpblts *c)
 Free NETCONF capabilities structure. More...
 
const char * nc_cpblts_get (const struct nc_cpblts *c, const char *capability_string)
 Get complete capability string including parameters. More...
 
const char * nc_cpblts_iter_next (struct nc_cpblts *c)
 Get the next capability string from the given NETCONF capabilities structure. More...
 
void nc_cpblts_iter_start (struct nc_cpblts *c)
 Move NETCONF capabilities structure iterator to the beginning of the capability strings list. More...
 
struct nc_cpblts * nc_cpblts_new (const char *const list[])
 Create a new NETCONF capabilities structure. More...
 
int nc_cpblts_remove (struct nc_cpblts *capabilities, const char *capability_string)
 Remove the specified capability string from the NETCONF capabilities structure. More...
 
int nc_del_keypair_path (const char *privkey, const char *pubkey)
 Remove a private and a public key file. More...
 
struct nc_session * nc_session_accept (const struct nc_cpblts *capabilities)
 Accept NETCONF session from a client. More...
 
struct nc_session * nc_session_accept_inout (const struct nc_cpblts *capabilities, const char *username, int input, int output)
 Accept NETCONF session from a client. It allows to assign the specified username to it and set file descriptors for reading/writing NETCONF data. More...
 
struct nc_session * nc_session_accept_username (const struct nc_cpblts *capabilities, const char *username)
 Accept NETCONF session from a client and assign it to the specified username. More...
 
struct nc_session * nc_session_connect (const char *host, unsigned short port, const char *username, const struct nc_cpblts *cpblts)
 Create NETCONF session to the specified server. More...
 
struct nc_session * nc_session_connect_channel (struct nc_session *session, const struct nc_cpblts *cpblts)
 Create another NETCONF session using already established SSH session. No authentication is needed in this case. More...
 
struct nc_session * nc_session_connect_inout (int fd_in, int fd_out, const struct nc_cpblts *cpblts, const char *host, const char *port, const char *username, NC_TRANSPORT transport)
 Create NETCONF session communicating via given file descriptors. This is an alternative function to nc_session_connect(). More...
 
struct nc_session * nc_session_connect_libssh_sess (const char *host, unsigned short port, const char *username, const struct nc_cpblts *cpblts, ssh_session ssh_sess)
 Create NETCONF session to the specified server using a custom SSH session. More...
 
struct nc_session * nc_session_dummy (const char *sid, const char *username, const char *hostname, struct nc_cpblts *capabilities)
 Create a disconnected session structure. More...
 
void nc_session_free (struct nc_session *session)
 Cleanup the session structure and free all the allocated resources. More...
 
struct nc_cpblts * nc_session_get_cpblts (const struct nc_session *session)
 Get list of capabilities associated with the session. More...
 
struct nc_cpblts * nc_session_get_cpblts_default (void)
 Get NULL terminated list of the default capabilities supported by libnetconf including the list of namespaces provided by the datastores created with ncds_new() and initialized by ncds_init(). More...
 
int nc_session_get_eventfd (const struct nc_session *session)
 Get the input file descriptor to asynchronous control of input events. More...
 
const char * nc_session_get_host (const struct nc_session *session)
 Get NETCONF session host. More...
 
const char * nc_session_get_id (const struct nc_session *session)
 Get NETCONF session ID. More...
 
const char * nc_session_get_port (const struct nc_session *session)
 Get NETCONF session port number. More...
 
NC_SESSION_STATUS nc_session_get_status (const struct nc_session *session)
 Get information about the session current status. More...
 
NC_TRANSPORT nc_session_get_transport (const struct nc_session *session)
 Get transport protocol used for the NETCONF session. More...
 
const char * nc_session_get_user (const struct nc_session *session)
 Get NETCONF session username. More...
 
int nc_session_get_version (const struct nc_session *session)
 Get NETCONF protocol version used in the given session. More...
 
int nc_session_monitor (struct nc_session *session)
 Add the session into the internal list of monitored sessions that are returned as part of netconf-state information defined in RFC 6022. More...
 
int nc_session_notif_allowed (struct nc_session *session)
 Tell me if the notification subscription is allowed on the given session. More...
 
int nc_session_transport (NC_TRANSPORT proto)
 Set transport protocol for the sessions created by subsequent nc_session_connect() calls. By default, transport protocol is set to NC_TRANSPORT_SSH. More...
 
int nc_set_keypair_path (const char *privkey, const char *pubkey)
 Set path to a private and a public key file used in case of SSH authentication via a publickey mechanism. More...
 
void nc_ssh_pref (NC_SSH_AUTH_TYPE type, short int preference)
 Set the preference of the SSH authentication methods. More...
 

Detailed Description

libnetconf's functions for handling NETCONF sessions.

Macro Definition Documentation

#define nc_msgid   char*

Type representing NETCONF message-id attribute.

It corresponds to the following typedef: typedef char* nc_msgid;

We use a macro to avoid compiler warning of 'const nc_msgid' as return type of functions (because const is applied as 'char* const funct()' which is meaningless).

Yes, I know that const char* means "pointer to constant character (not string)", but I want to be clear from the API, that function returns pointer to something that should not be changed.

Enumeration Type Documentation

Enumeration of the possible states of a NETCONF session.

Enumerator
NC_SESSION_STATUS_ERROR 

undefined status or the error return code

NC_SESSION_STATUS_STARTUP 

session is setting up

NC_SESSION_STATUS_WORKING 

session is established and ready to work

NC_SESSION_STATUS_CLOSING 

session is being closed

NC_SESSION_STATUS_CLOSED 

session was closed and could not be used for communication

NC_SESSION_STATUS_DUMMY 

session is DUMMY, only holds information, does not provide connection

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

Enumerator
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

Available SSH authentication mechanisms.

Enumerator
NC_SSH_AUTH_PUBLIC_KEYS 

SSH user authorization via publickeys

NC_SSH_AUTH_PASSWORD 

SSH user authorization via password

NC_SSH_AUTH_INTERACTIVE 

interactive SSH user authorization

Supported NETCONF transport protocols enumeration. To change currently used transport protocol, call nc_session_transport().

Note that NC_TRANSPORT_TLS is supported only when libnetconf is compiled with –enable-tls configure's option. If the option is not used, nc_session_transport() returns EXIT_FAILURE with NC_TRANSPORT_TLS value.

This setting is valuable only for client side NETCONF applications.

Enumerator
NC_TRANSPORT_UNKNOWN 

Unknown transport protocol, this is not acceptable as input value

NC_TRANSPORT_SSH 

NETCONF over SSH, this value is used by default

NC_TRANSPORT_TLS 

NETCONF over TLS

Function Documentation

void nc_callback_ssh_host_authenticity_check ( int(*)(const char *hostname, ssh_session session)  func)

Set a callback function to authorize authenticity of the remote host.

To make this function available, you have to include libnetconf_ssh.h.

If the func parameter is NULL, the callback is set back to the default function.

Parameters
[in]funcCallback function to use. Expected callback return values are:
  • EXIT_SUCCESS - hosts and keys match, the SSH session establishment will continue.
  • EXIT_FAILURE - keys do not match or an error occurred.
void nc_callback_sshauth_interactive ( char *(*)(const char *name, const char *instruction, const char *prompt, int echo)  func)

Set a callback function for passing user credentials into the libssh's keyboard-interactive authentication method.

To make this function available, you have to include libnetconf_ssh.h.

If the func parameter is NULL, the callback is set back to the default function.

Parameters
[in]funcCallback function to use for interactive authentication.
void nc_callback_sshauth_passphrase ( char *(*)(const char *username, const char *hostname, const char *priv_key_file)  func)

Set a callback function for passing the user password into the libssh's publickey authentication method when connecting to 'hostname' as 'username'.

To make this function available, you have to include libnetconf_ssh.h.

If the func parameter is NULL, the callback is set back to the default function.

Parameters
[in]funcCallback function to use.
void nc_callback_sshauth_password ( char *(*)(const char *username, const char *hostname)  func)

Set a callback function for passing the user password into the libssh's password authentication method when connecting to 'hostname' as 'username'.

To make this function available, you have to include libnetconf_ssh.h.

If the func parameter is NULL, the callback is set back to the default function.

Parameters
[in]funcCallback function to use. The callback function should return a password string for the given username and name of the remote host.
int nc_cpblts_add ( struct nc_cpblts *  capabilities,
const char *  capability_string 
)

Add another capability string into the NETCONF capabilities structure.

This function is NOT thread safe.

Parameters
capabilitiesCurrent NETCONF capabilities structure.
capability_stringCapability string to add.
Returns
0 on success
non-zero on error
int nc_cpblts_count ( const struct nc_cpblts *  c)

Get the number of capabilities in the structure.

Use this function to get the count of capabilities held by nc_cpblts structure.

Parameters
cNETCONF capabilities structure.
Returns
Number of capabilities held by structure c.
int nc_cpblts_enabled ( const struct nc_session *  session,
const char *  capability_string 
)

Check if the given capability is supported by the session.

Parameters
sessionEstablished session where the given capability support will be checked.
capability_stringNETCONF capability string to check.
Returns
0 for false result, 1 if the given capability is supported.
void nc_cpblts_free ( struct nc_cpblts *  c)

Free NETCONF capabilities structure.

This function is NOT thread safe.

Parameters
cCapabilities structure to free.
const char* nc_cpblts_get ( const struct nc_cpblts *  c,
const char *  capability_string 
)

Get complete capability string including parameters.

Parameters
[in]cCapabilities structure to be examined
[in]capability_stringCapability identifier, parameters are ignored and only basic identifier is used to retrieve specific identifier including parameters from the given capability structure.
Returns
Constant capability identifier including parameters
const char* nc_cpblts_iter_next ( struct nc_cpblts *  c)

Get the next capability string from the given NETCONF capabilities structure.

To move iterator to the beginning of the capability strings list, use nc_cpblts_iter_start().

This function is NOT thread safe.

Parameters
cNETCONF capabilities structure to be iterated.
Returns
Another capability string, NULL if all strings were already returned.
void nc_cpblts_iter_start ( struct nc_cpblts *  c)

Move NETCONF capabilities structure iterator to the beginning of the capability strings list.

This function is NOT thread safe.

Parameters
cNETCONF capabilities structure to be iterated.
struct nc_cpblts* nc_cpblts_new ( const char *const  list[])

Create a new NETCONF capabilities structure.

Parameters
listNULL terminated list of capabilities strings to initially add into the NETCONF capabilities structure.
Returns
Created NETCONF capabilities structure.
int nc_cpblts_remove ( struct nc_cpblts *  capabilities,
const char *  capability_string 
)

Remove the specified capability string from the NETCONF capabilities structure.

This function is NOT thread safe.

Parameters
capabilitiesCurrent NETCONF capabilities structure.
capability_stringCapability string to remove.
Returns
0 on success
non-zero on error
int nc_del_keypair_path ( const char *  privkey,
const char *  pubkey 
)

Remove a private and a public key file.

To make this function available, you have to include libnetconf_ssh.h.

Parameters
[in]privkeyPath to the private key file.
[in]pubkeyPath to the public key file
Returns
EXIT_SUCCES or EXIT_FAILURE
struct nc_session* nc_session_accept ( const struct nc_cpblts *  capabilities)

Accept NETCONF session from a client.

The caller process of this function is supposed to be launched as a subprocess of the transport protocol server (in case of SSH, it is called SSH Subsystem). Username assigned to the NETCONF session is guessed from the process's UID. This approach supposes that the transport protocol server launches the caller process with the changed UID according to the user logged in (OpenSSH's sshd does this, stunnel does not - see nc_session_accept_username() instead of this function).

Only one NETCONF session can be accepted in a single caller since it communicates with the transport protocol server directly via (redirected) stdin and stdout streams.

Parameters
[in]capabilitiesNETCONF capabilities structure with the capabilities supported by the server. The caller can use nc_session_get_cpblts_default() to get the structure with the list of all the capabilities supported by libnetconf (this is used in case of a NULL parameter).
Returns
Structure describing the accepted NETCONF session or NULL in case of an error.
struct nc_session* nc_session_accept_inout ( const struct nc_cpblts *  capabilities,
const char *  username,
int  input,
int  output 
)

Accept NETCONF session from a client. It allows to assign the specified username to it and set file descriptors for reading/writing NETCONF data.

The same as nc_session_accept_username() except that it allows caller to set file descriptors where the libnetconf will read/write NETCONF (unencrypted) data.

Parameters
[in]capabilitiesNETCONF capabilities structure with the capabilities supported by the server. The caller can use nc_session_get_cpblts_default() to get the structure with the list of all the capabilities supported by libnetconf (this is used in case of a NULL parameter).
[in]usernameName of the user which will be assigned to the NETCONF session. This information is used for example by NACM subsystem. If NULL, the function act the same way as the nc_session_accept() function.
[in]inputFile descriptor from which the NETCONF data will be read.
[in]outputFile descriptor to which the NETCONF data will be written.
Returns
Structure describing the accepted NETCONF session or NULL in case of an error.
struct nc_session* nc_session_accept_username ( const struct nc_cpblts *  capabilities,
const char *  username 
)

Accept NETCONF session from a client and assign it to the specified username.

The same as nc_session_accept() except that instead of guessing username from the process's UID, the specified username is assigned to the NETCONF session. This can be used especially in case that the transport protocol server (sshd, stunnel,...) does not change process's UID automatically.

Parameters
[in]capabilitiesNETCONF capabilities structure with the capabilities supported by the server. The caller can use nc_session_get_cpblts_default() to get the structure with the list of all the capabilities supported by libnetconf (this is used in case of a NULL parameter).
[in]usernameName of the user which will be assigned to the NETCONF session. This information is used for example by NACM subsystem. If NULL, the function act the same way as the nc_session_accept() function.
Returns
Structure describing the accepted NETCONF session or NULL in case of an error.
struct nc_session* nc_session_connect ( const char *  host,
unsigned short  port,
const char *  username,
const struct nc_cpblts *  cpblts 
)

Create NETCONF session to the specified server.

This function can internally use various callbacks set by the client to perform SSH authentication. It selects authentication mechanism from the list provided by the SSH server and based on the preferences set by the client via nc_ssh_pref(). Then, appropriate callback function (set by nc_callback_sshauth_password(), nc_callback_sshauth_passphrase(), nc_set_publickey_path() or nc_set_privatekey_path()) is used to perform the authentication.

Parameters
[in]hostHostname or address (both Ipv4 and IPv6 are accepted). 'localhost' is used by default if NULL is specified.
[in]portPort number of the server. Default value 830 is used if 0 is specified.
[in]usernameName of the user to login to the server. The user running the application (detected from the effective UID) is used if NULL is specified.
[in]cpbltsNETCONF capabilities structure with capabilities supported by the client. Client can use nc_session_get_cpblts_default() to get the structure with the list of all the capabilities supported by libnetconf (this is used in case of a NULL parameter).
Returns
Structure describing the NETCONF session or NULL in case of an error.
struct nc_session* nc_session_connect_channel ( struct nc_session *  session,
const struct nc_cpblts *  cpblts 
)

Create another NETCONF session using already established SSH session. No authentication is needed in this case.

This function works only if libnetconf is compiled with using libssh.

It is not applicable to the sessions created by nc_session_connect_inout().

Parameters
[in]sessionAlready established NETCONF session using nc_session_connect().
[in]cpbltsNETCONF capabilities structure with capabilities supported by the client. Client can use nc_session_get_cpblts_default() to get the structure with the list of all the capabilities supported by libnetconf (this is used in case of a NULL parameter).
Returns
Structure describing the NETCONF session or NULL in case of an error.
struct nc_session* nc_session_connect_inout ( int  fd_in,
int  fd_out,
const struct nc_cpblts *  cpblts,
const char *  host,
const char *  port,
const char *  username,
NC_TRANSPORT  transport 
)

Create NETCONF session communicating via given file descriptors. This is an alternative function to nc_session_connect().

In this case the initiation of the transport session (SSH, TLS, ...) is done externally. libnetconf just uses provided file descriptors to read data from and write data to that external entity (process, functions,...).

Before calling this function, all necessary authentication process must be done so libnetconf can directly start with <hello> messages performing the NETCONF handshake.

Since connecting to a host and authentication is done before, the provided host, port, username anf transport arguments are only informative and libnetconf use them only for returning value by nc_session_get_*() functions. The cpblts argument is used during the NETCONF handshake in the same way as in the nc_session_connect() function.

It is not allowed to use nc_session_connect_channel() on the session created by this function.

Parameters
[in]fd_inOpened file desriptor where the (unencrypted) data from the NETCONF server are read.
[in]fd_outOpened file desriptor where the (unencrypted) data to the NETCONF server are written.
[in]cpbltsNETCONF capabilities structure with capabilities supported by the client. Client can use nc_session_get_cpblts_default() to get the structure with the list of all the capabilities supported by libnetconf (this is used in case of a NULL parameter).
[in]hostName of the host where we are connected to via the provided file descriptors.
[in]portThe port number of the remote host where we are connected.
[in]usernameName of the user we are connected to the remote host as.
[in]transportThe transport protocol used to connect to the remote host.
struct nc_session* nc_session_connect_libssh_sess ( const char *  host,
unsigned short  port,
const char *  username,
const struct nc_cpblts *  cpblts,
ssh_session  ssh_sess 
)

Create NETCONF session to the specified server using a custom SSH session.

This function works only if libnetconf is compiled with using libssh.

It shares all the functionality of nc_session_connect(), but also enables to use a customized SSH session with some specific options set.

Parameters
[in]hostHostname or address (both Ipv4 and IPv6 are accepted). 'localhost' is used by default if NULL is specified.
[in]portPort number of the server. Default value 830 is used if 0 is specified.
[in]usernameName of the user to login to the server. The user running the application (detected from the effective UID) is used if NULL is specified.
[in]cpbltsNETCONF capabilities structure with capabilities supported by the client. Client can use nc_session_get_cpblts_default() to get the structure with the list of all the capabilities supported by libnetconf (this is used in case of a NULL parameter).
[in]ssh_sessCustomized libssh SSH session structure. Options SSH_OPTIONS_HOST, SSH_OPTIONS_USER, SSH_OPTIONS_FD, and SSH_OPTIONS_TIMEOUT should not be set as they will get set internally and previous values will be ignored. The structure will get freed and it should not be manipulated after passed as a parameter.
Returns
Structure describing the NETCONF session or NULL in case of an error.
struct nc_session* nc_session_dummy ( const char *  sid,
const char *  username,
const char *  hostname,
struct nc_cpblts *  capabilities 
)

Create a disconnected session structure.

This creates a dummy session structure which is not supposed to exchange NETCONF messages between client and server. Instead, it can be successfully used by server (e.g. detached process that doesn't hold the real session structure) to access NETCONF datastores via libnetconf.

All the required parameters can be obtained from the real session structure by the session getter functions (nc_session_get_id(), nc_session_get_user() and nc_session_get_cpblts()). NULL values are not allowed.

Parameters
[in]sidSession ID.
[in]usernameName of the user holding the session.
[in]hostnameName (domain name, IP) of the opposite communication side (optional parameter, can be NULL).
[in]capabilitiesList of capabilities supported by the session.
Returns
Structure describing a dummy NETCONF session or NULL in case of an error.
void nc_session_free ( struct nc_session *  session)

Cleanup the session structure and free all the allocated resources.

Do not use the given session structure after this call. If this session was created with nc_session_accept_tls() or nc_session_accept_libssh_channel(), the library transport structures are not freed or modified in any way.

Parameters
[in]sessionSession to free.
struct nc_cpblts* nc_session_get_cpblts ( const struct nc_session *  session)

Get list of capabilities associated with the session.

Returned structure is connected with the session. Do not free or modify it.

Parameters
[in]sessionNETCONF session structure
Returns
NETCONF capabilities structure containing capabilities associated with the given session. NULL is returned on error.
struct nc_cpblts* nc_session_get_cpblts_default ( void  )

Get NULL terminated list of the default capabilities supported by libnetconf including the list of namespaces provided by the datastores created with ncds_new() and initialized by ncds_init().

The caller is supposed to free the returned structure with nc_cpblts_free().

Returns
NETCONF capabilities structure containing capabilities supported by libnetconf.
int nc_session_get_eventfd ( const struct nc_session *  session)

Get the input file descriptor to asynchronous control of input events.

The caller must avoid direct reading from the returned file descriptor. It is supposed to be used only by select, poll, epoll or an event library (e.g. libevent).

Parameters
[in]sessionNETCONF session structure
Returns
Input file descriptor of the communication channel.
const char* nc_session_get_host ( const struct nc_session *  session)

Get NETCONF session host.

Parameters
[in]sessionNETCONF session structure
Returns
Constant string identifying NETCONF session server host.
const char* nc_session_get_id ( const struct nc_session *  session)

Get NETCONF session ID.

Parameters
[in]sessionNETCONF session structure
Returns
Constant string identifying NETCONF session.
const char* nc_session_get_port ( const struct nc_session *  session)

Get NETCONF session port number.

Parameters
[in]sessionNETCONF session structure
Returns
Constant string identifying NETCONF session server host.
NC_SESSION_STATUS nc_session_get_status ( const struct nc_session *  session)

Get information about the session current status.

Parameters
[in]sessionNETCONF session.
Returns
NETCONF session status.
NC_TRANSPORT nc_session_get_transport ( const struct nc_session *  session)

Get transport protocol used for the NETCONF session.

Parameters
[in]sessionNETCONF session structure
Returns
one of NC_TRANSPORT enumeration values.
const char* nc_session_get_user ( const struct nc_session *  session)

Get NETCONF session username.

Parameters
[in]sessionNETCONF session structure
Returns
Constant string identifying NETCONF session server host.
int nc_session_get_version ( const struct nc_session *  session)

Get NETCONF protocol version used in the given session.

Parameters
[in]sessionNETCONF session structure
Returns
NETCONF protocol version, 0 for 1.0, 1 for 1.1
int nc_session_monitor ( struct nc_session *  session)

Add the session into the internal list of monitored sessions that are returned as part of netconf-state information defined in RFC 6022.

Parameters
sessionSession to be monitored;
Returns
0 on success, non-zero on error.
int nc_session_notif_allowed ( struct nc_session *  session)

Tell me if the notification subscription is allowed on the given session.

Parameters
[in]sessionNETCONF session structure
Returns
0 if not, 1 if subscription is currently allowed.
int nc_session_transport ( NC_TRANSPORT  proto)

Set transport protocol for the sessions created by subsequent nc_session_connect() calls. By default, transport protocol is set to NC_TRANSPORT_SSH.

This function is thread-safe. Change made by calling this function applies only to the current thread.

int nc_set_keypair_path ( const char *  privkey,
const char *  pubkey 
)

Set path to a private and a public key file used in case of SSH authentication via a publickey mechanism.

To make this function available, you have to include libnetconf_ssh.h.

Parameters
[in]privkeyPath to the private key file.
[in]pubkeyPath to the public key file
Returns
EXIT_SUCCES or EXIT_FAILURE
void nc_ssh_pref ( NC_SSH_AUTH_TYPE  type,
short int  preference 
)

Set the preference of the SSH authentication methods.

Allowed authentication types are defined as NC_SSH_AUTH_TYPE type. The default preferences are:

  1. interactive (3)
  2. password (2)
  3. public keys (1)

This function has no effect with configure's –disable-libssh option.

To make this function available, you have to include libnetconf_ssh.h header file.

Parameters
[in]typeSetting preference for the given authentication type.
[in]preferencePreference value. Higher value means higher preference. Negative value disables the given authentication type. On equality of values, the last set authentication type is preferred.