libnetconf2  1.1.48
NETCONF library for clients and servers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
session.h File Reference

libnetconf2 session manipulation More...

#include "netconf.h"

Go to the source code of this file.

Enumerations

enum  NC_SSH_AUTH_TYPE { NC_SSH_AUTH_PUBLICKEY = 0x01, NC_SSH_AUTH_PASSWORD = 0x02, NC_SSH_AUTH_INTERACTIVE = 0x04 }
 Enumeration of NETCONF SSH authentication methods. More...
 
enum  NC_TLS_CTN_MAPTYPE {
  NC_TLS_CTN_UNKNOWN = 0, NC_TLS_CTN_SPECIFIED, NC_TLS_CTN_SAN_RFC822_NAME, NC_TLS_CTN_SAN_DNS_NAME,
  NC_TLS_CTN_SAN_IP_ADDRESS, NC_TLS_CTN_SAN_ANY, NC_TLS_CTN_COMMON_NAME
}
 Enumeration of cert-to-name mapping types. More...
 
enum  NC_STATUS {
  NC_STATUS_ERR = -1, NC_STATUS_STARTING = 0, NC_STATUS_CLOSING, NC_STATUS_INVALID,
  NC_STATUS_RUNNING
}
 Enumeration of possible session statuses. More...
 
enum  NC_TRANSPORT_IMPL {
  NC_TI_NONE = 0, NC_TI_FD, NC_TI_UNIX, NC_TI_LIBSSH,
  NC_TI_OPENSSL
}
 Enumeration of transport implementations (ways how libnetconf implements NETCONF transport protocol) More...
 
enum  NC_CH_CONN_TYPE { NC_CH_CT_NOT_SET = 0, NC_CH_PERSIST, NC_CH_PERIOD }
 Enumeration of Call Home connection types. More...
 
enum  NC_CH_START_WITH { NC_CH_FIRST_LISTED = 0, NC_CH_LAST_CONNECTED, NC_CH_RANDOM }
 Enumeration of Call Home client priority policy. More...
 
enum  NC_SSH_KEY_TYPE { NC_SSH_KEY_UNKNOWN = 0, NC_SSH_KEY_DSA, NC_SSH_KEY_RSA, NC_SSH_KEY_ECDSA }
 Enumeration of SSH key types. More...
 

Functions

NC_STATUS nc_session_get_status (const struct nc_session *session)
 Get session status. More...
 
NC_SESSION_TERM_REASON nc_session_get_term_reason (const struct nc_session *session)
 Get session termination reason. More...
 
uint32_t nc_session_get_killed_by (const struct nc_session *session)
 Get session killer session ID. More...
 
uint32_t nc_session_get_id (const struct nc_session *session)
 Get session ID. More...
 
uint32_t nc_session_get_refcnt (const struct nc_session *session)
 Get reference count. More...
 
void nc_session_reference (struct nc_session *session)
 Put a reference to the session in order to avoid unwanted release of session. More...
 
void nc_session_dereference (struct nc_session *session)
 Take reference from the session. More...
 
int nc_session_get_version (const struct nc_session *session)
 Get session NETCONF version. More...
 
NC_TRANSPORT_IMPL nc_session_get_ti (const struct nc_session *session)
 Get session transport used. More...
 
const char * nc_session_get_username (const struct nc_session *session)
 Get session username. More...
 
const char * nc_session_get_host (const struct nc_session *session)
 Get session host. More...
 
uint16_t nc_session_get_port (const struct nc_session *session)
 Get session port. More...
 
const char * nc_session_get_path (const struct nc_session *session)
 Get session path (unix socket only). More...
 
struct ly_ctx * nc_session_get_ctx (const struct nc_session *session)
 Get session context. More...
 
void nc_session_set_data (struct nc_session *session, void *data)
 Assign arbitrary data to a session. More...
 
void * nc_session_get_data (const struct nc_session *session)
 Get the data assigned to a session. More...
 
void nc_session_free (struct nc_session *session, void(*data_free)(void *))
 Free the NETCONF session object. More...
 
void nc_thread_destroy (void)
 Free all the dynamically allocated thread-specific libssl/libcrypto resources. More...
 

Detailed Description

libnetconf2 session manipulation

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz Copyright (c) 2015 CESNET, z.s.p.o.

This source code is licensed under BSD 3-Clause License (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at

https://opensource.org/licenses/BSD-3-Clause

Definition in file session.h.

Enumeration Type Documentation

Enumeration of NETCONF SSH authentication methods.

Enumerator
NC_SSH_AUTH_PUBLICKEY 

publickey SSH authentication

NC_SSH_AUTH_PASSWORD 

password SSH authentication

NC_SSH_AUTH_INTERACTIVE 

interactive SSH authentication

Definition at line 29 of file session.h.

Enumeration of cert-to-name mapping types.

Enumerator
NC_TLS_CTN_UNKNOWN 

unknown mapping

NC_TLS_CTN_SPECIFIED 

username explicitly specified

NC_TLS_CTN_SAN_RFC822_NAME 

email address as username

NC_TLS_CTN_SAN_DNS_NAME 

DNS name as username

NC_TLS_CTN_SAN_IP_ADDRESS 

IP address as username

NC_TLS_CTN_SAN_ANY 

any certificate Subject Alternative Name as username

NC_TLS_CTN_COMMON_NAME 

common name as username

Definition at line 42 of file session.h.

enum NC_STATUS

Enumeration of possible session statuses.

Enumerator
NC_STATUS_ERR 

error return code for function getting the session status

NC_STATUS_STARTING 

session is not yet fully initiated

NC_STATUS_CLOSING 

session is being closed

NC_STATUS_INVALID 

session is not running and is supposed to be closed (nc_session_free())

NC_STATUS_RUNNING 

up and running

Definition at line 57 of file session.h.

Enumeration of transport implementations (ways how libnetconf implements NETCONF transport protocol)

Enumerator
NC_TI_NONE 

none - session is not connected yet

NC_TI_FD 

file descriptors - use standard input/output, transport protocol is implemented outside the current application

NC_TI_UNIX 

unix socket

NC_TI_LIBSSH 

libssh - use libssh library, only for NETCONF over SSH transport

NC_TI_OPENSSL 

OpenSSL - use OpenSSL library, only for NETCONF over TLS transport

Definition at line 68 of file session.h.

Enumeration of Call Home connection types.

Enumerator
NC_CH_CT_NOT_SET 
NC_CH_PERSIST 
NC_CH_PERIOD 

Definition at line 84 of file session.h.

Enumeration of Call Home client priority policy.

Enumerator
NC_CH_FIRST_LISTED 
NC_CH_LAST_CONNECTED 
NC_CH_RANDOM 

Definition at line 93 of file session.h.

Enumeration of SSH key types.

Enumerator
NC_SSH_KEY_UNKNOWN 
NC_SSH_KEY_DSA 
NC_SSH_KEY_RSA 
NC_SSH_KEY_ECDSA 

Definition at line 102 of file session.h.

Function Documentation

NC_STATUS nc_session_get_status ( const struct nc_session *  session)

Get session status.

Parameters
[in]sessionSession to get the information from.
Returns
Session status.
NC_SESSION_TERM_REASON nc_session_get_term_reason ( const struct nc_session *  session)

Get session termination reason.

Parameters
[in]sessionSession to get the information from.
Returns
Session termination reason enum value.
uint32_t nc_session_get_killed_by ( const struct nc_session *  session)

Get session killer session ID.

Parameters
[in]sessionSession to get the information from.
Returns
Session killer ID.
uint32_t nc_session_get_id ( const struct nc_session *  session)

Get session ID.

Parameters
[in]sessionSession to get the information from.
Returns
Session ID.
uint32_t nc_session_get_refcnt ( const struct nc_session *  session)

Get reference count.

Parameters
[in]sessionSession to get the information from.
Returns
Session ID.
void nc_session_reference ( struct nc_session *  session)

Put a reference to the session in order to avoid unwanted release of session.

Parameters
[in]sessionSession to get the information from.
Returns
Session ID.
void nc_session_dereference ( struct nc_session *  session)

Take reference from the session.

Parameters
[in]sessionSession to get the information from.
Returns
Session ID.
int nc_session_get_version ( const struct nc_session *  session)

Get session NETCONF version.

Parameters
[in]sessionSession to get the information from.
Returns
0 for version 1.0, non-zero for version 1.1.
NC_TRANSPORT_IMPL nc_session_get_ti ( const struct nc_session *  session)

Get session transport used.

Parameters
[in]sessionSession to get the information from.
Returns
Session transport.
const char* nc_session_get_username ( const struct nc_session *  session)

Get session username.

Parameters
[in]sessionSession to get the information from.
Returns
Session username.
const char* nc_session_get_host ( const struct nc_session *  session)

Get session host.

Parameters
[in]sessionSession to get the information from.
Returns
Session host.
uint16_t nc_session_get_port ( const struct nc_session *  session)

Get session port.

Parameters
[in]sessionSession to get the information from.
Returns
Session port.
const char* nc_session_get_path ( const struct nc_session *  session)

Get session path (unix socket only).

Parameters
[in]sessionSession to get the information from.
Returns
Session unix socket path.
struct ly_ctx* nc_session_get_ctx ( const struct nc_session *  session)

Get session context.

Parameters
[in]sessionSession to get the information from.
Returns
Session context.
void nc_session_set_data ( struct nc_session *  session,
void *  data 
)

Assign arbitrary data to a session.

Parameters
[in]sessionSession to modify.
[in]dataData to be stored in the session.
void* nc_session_get_data ( const struct nc_session *  session)

Get the data assigned to a session.

Parameters
[in]sessionSession to get the data from.
Returns
Session-specific data.
void nc_session_free ( struct nc_session *  session,
void(*)(void *)  data_free 
)

Free the NETCONF session object.

Parameters
[in]sessionObject to free.
[in]data_freeSession user data destructor.
void nc_thread_destroy ( void  )

Free all the dynamically allocated thread-specific libssl/libcrypto resources.

This function should be called only if init (nc_client_init(), respectively nc_server_init()) was called. Call it in every thread your application creates just before the thread exits. In the last thread (usually the main one) call nc_client_destroy(), respectively nc_server_destroy().