libnetconf2  3.5.4
NETCONF server and client library in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
session.h File Reference

libnetconf2 session manipulation More...

#include "netconf.h"
Include dependency graph for session.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

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_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_SSH_KNOWNHOSTS_MODE {
  NC_SSH_KNOWNHOSTS_ASK = 0, NC_SSH_KNOWNHOSTS_STRICT, NC_SSH_KNOWNHOSTS_ACCEPT_NEW, NC_SSH_KNOWNHOSTS_ACCEPT,
  NC_SSH_KNOWNHOSTS_SKIP
}
 Enumeration of host key checking and known_hosts entry adding modes. 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_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_TLS_VERSION { NC_TLS_VERSION_10 = 1, NC_TLS_VERSION_11 = 2, NC_TLS_VERSION_12 = 4, NC_TLS_VERSION_13 = 8 }
 Enumeration of TLS versions. More...
 
enum  NC_TRANSPORT_IMPL {
  NC_TI_NONE = 0, NC_TI_FD, NC_TI_UNIX, NC_TI_SSH,
  NC_TI_TLS
}
 Enumeration of transport implementations (ways how libnetconf implements NETCONF transport protocol) More...
 

Functions

void nc_session_free (struct nc_session *session, void(*data_free)(void *))
 Free the NETCONF session object. More...
 
struct ly_ctx * nc_session_get_ctx (const struct nc_session *session)
 Get session context. More...
 
void * nc_session_get_data (const struct nc_session *session)
 Get the data assigned to a session. More...
 
const char * nc_session_get_host (const struct nc_session *session)
 Get session host. More...
 
uint32_t nc_session_get_id (const struct nc_session *session)
 Get session ID. More...
 
uint32_t nc_session_get_killed_by (const struct nc_session *session)
 Get session killer session ID. More...
 
const char * nc_session_get_path (const struct nc_session *session)
 Get session path (unix socket only). More...
 
uint16_t nc_session_get_port (const struct nc_session *session)
 Get session port. More...
 
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...
 
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...
 
int nc_session_get_version (const struct nc_session *session)
 Get session NETCONF version. More...
 
int nc_session_is_callhome (const struct nc_session *session)
 Learn whether a session was created using Call Home or not. More...
 
void nc_session_set_data (struct nc_session *session, void *data)
 Assign arbitrary data to a session. More...
 
const char * nc_session_ssh_get_banner (const struct nc_session *session)
 Get the SSH banner sent by the peer. More...
 

Detailed Description

libnetconf2 session manipulation

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz
Michal Vasko mvask.nosp@m.o@ce.nosp@m.snet..nosp@m.cz

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 31 of file session.h.

Enumeration of host key checking and known_hosts entry adding modes.

Enumerator
NC_SSH_KNOWNHOSTS_ASK 

add a known_hosts entry, but with a prompt

NC_SSH_KNOWNHOSTS_STRICT 

do not add a known_hosts entry and the server's host key must be present in the configured known_hosts file

NC_SSH_KNOWNHOSTS_ACCEPT_NEW 

add a known_hosts entry without a prompt

NC_SSH_KNOWNHOSTS_ACCEPT 

add a known_hosts entry without a prompt and allow connections to servers which changed their host key

NC_SSH_KNOWNHOSTS_SKIP 

do not add a known_hosts entry and skip all host key checks

Definition at line 40 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 51 of file session.h.

Enumeration of TLS versions.

Enumerator
NC_TLS_VERSION_10 

TLS1.0

NC_TLS_VERSION_11 

TLS1.1

NC_TLS_VERSION_12 

TLS1.2

NC_TLS_VERSION_13 

TLS1.3

Definition at line 64 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 76 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_SSH 

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

NC_TI_TLS 

TLS - use either OpenSSL or MbedTLS library, only for NETCONF over TLS transport

Definition at line 87 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 102 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 111 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.
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_ssh_get_banner ( const struct nc_session *  session)

Get the SSH banner sent by the peer.

Parameters
[in]sessionSession to get the banner from.
Returns
SSH banner on success, NULL on error.
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.
int nc_session_is_callhome ( const struct nc_session *  session)

Learn whether a session was created using Call Home or not.

Parameters
[in]sessionSession to get the information from.
Returns
0 if a standard session, non-zero if a Call Home session.
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.