libnetconf2 4.6.1
NETCONF server and client library in C.
Loading...
Searching...
No Matches
Server Functions
Collaboration diagram for Server Functions:

Functions

int nc_server_destroy (void)
 Destroy any dynamically allocated libssh and/or libssl/libcrypto and server resources.
 
uint32_t nc_server_endpt_count (void)
 Get the number of currently configured listening endpoints.
 
void nc_server_get_capab_withdefaults (NC_WD_MODE *basic_mode, int *also_supported)
 Get with-defaults capability extra parameters.
 
char ** nc_server_get_cpblts (const struct ly_ctx *ctx)
 Get all the server capabilities including all the schemas.
 
char ** nc_server_get_cpblts_version (const struct ly_ctx *ctx, LYS_VERSION version)
 Get the server capabilities including the schemas with the specified YANG version.
 
int nc_server_init (void)
 Initialize libssh and/or libssl/libcrypto and the server.
 
int nc_server_init_ctx (struct ly_ctx **ctx)
 Initialize a context which can serve as a default server context.
 
int nc_server_set_capab_withdefaults (NC_WD_MODE basic_mode, int also_supported)
 Set the with-defaults capability extra parameters.
 
int nc_server_set_capability (const char *value)
 Set capability of the server.
 
void nc_server_set_content_id_clb (char *(*content_id_clb)(void *user_data), void *user_data, void(*free_user_data)(void *user_data))
 Set the callback for getting yang-library capability identifier. If none is set, libyang context change count is used.
 

Detailed Description

Function Documentation

◆ nc_server_init()

int nc_server_init ( void  )

Initialize libssh and/or libssl/libcrypto and the server.

Must be called before other nc_server* functions.

Returns
0 on success, -1 on error.

◆ nc_server_destroy()

int nc_server_destroy ( void  )

Destroy any dynamically allocated libssh and/or libssl/libcrypto and server resources.

No other server API call may run concurrently with this function and there must be no session being accepted or authenticated. Established sessions are not affected, but the data of the user callbacks set through the API (nc_server_ssh_set_interactive_auth_clb(), nc_server_ch_set_dispatch_data(), ...) is released here, so an authentication still running in one of them would use freed data. Call Home client threads are stopped, but only the ones dispatched before this call.

Returns
0 on success, 1 on error - failed to synchronize with other threads (timed out waiting for locks or failed to join threads). Safe to call again to retry freeing resources.

◆ nc_server_init_ctx()

int nc_server_init_ctx ( struct ly_ctx **  ctx)

Initialize a context which can serve as a default server context.

Loads the default modules ietf-netconf and ietf-netconf-monitoring and their enabled features - ietf-netconf enabled features are : writable-running, candidate, rollback-on-error, validate, startup, url, xpath, confirmed-commit and ietf-netconf-monitoring has no features.

If ctx is :

  • NULL: a new context will be created and if the call is successful you have to free it,
  • non NULL: context will be searched for the two modules and their features and if anything is missing, it will be implemented.
Parameters
[in,out]ctxOptional context in which the modules will be loaded. Created if ctx is null.
Returns
0 on success, -1 on error.

◆ nc_server_set_capab_withdefaults()

int nc_server_set_capab_withdefaults ( NC_WD_MODE  basic_mode,
int  also_supported 
)

Set the with-defaults capability extra parameters.

For the capability to be actually advertised, the server context must also include the ietf-netconf-with-defaults model.

Changing this option has the same ill effects as changing capabilities while sessions are already established.

Parameters
[in]basic_modebasic-mode with-defaults parameter.
[in]also_supportedNC_WD_MODE bit array, also-supported with-defaults parameter.
Returns
0 on success, -1 on error.

◆ nc_server_get_capab_withdefaults()

void nc_server_get_capab_withdefaults ( NC_WD_MODE basic_mode,
int *  also_supported 
)

Get with-defaults capability extra parameters.

At least one argument must be non-NULL.

Parameters
[out]basic_modebasic-mode parameter.
[out]also_supportedalso-supported parameter.

◆ nc_server_set_capability()

int nc_server_set_capability ( const char *  value)

Set capability of the server.

Capability can be used when some behavior or extension of the server is not defined as a YANG module. The provided value will be advertised in the server's <hello> messages. Note, that libnetconf only checks that the provided value is non-empty string.

Parameters
[in]valueCapability string to be advertised in server's <hello> messages.
Returns
0 on success, -1 on error.

◆ nc_server_set_content_id_clb()

void nc_server_set_content_id_clb ( char *(*)(void *user_data)  content_id_clb,
void *  user_data,
void(*)(void *user_data)  free_user_data 
)

Set the callback for getting yang-library capability identifier. If none is set, libyang context change count is used.

Parameters
[in]content_id_clbCallback that should return the yang-library content identifier.
[in]user_dataOptional arbitrary user data that will be passed to content_id_clb.
[in]free_user_dataOptional callback that will be called during cleanup to free any user_data.

◆ nc_server_get_cpblts()

char ** nc_server_get_cpblts ( const struct ly_ctx *  ctx)

Get all the server capabilities including all the schemas.

A few capabilities (with-defaults, interleave) depend on the current server options.

Parameters
[in]ctxContext to read most capabilities from.
Returns
Array of capabilities, NULL on error.

◆ nc_server_get_cpblts_version()

char ** nc_server_get_cpblts_version ( const struct ly_ctx *  ctx,
LYS_VERSION  version 
)

Get the server capabilities including the schemas with the specified YANG version.

A few capabilities (with-defaults, interleave) depend on the current server options.

Parameters
[in]ctxContext to read most capabilities from.
[in]versionYANG version of the schemas to be included in result, with LYS_VERSION_UNDEF the result is the same as from nc_server_get_cpblts().
Returns
Array of capabilities, NULL on error.

◆ nc_server_endpt_count()

uint32_t nc_server_endpt_count ( void  )

Get the number of currently configured listening endpoints.

Returns
Number of listening endpoints.