Loading...
Searching...
No Matches
Server Functions
Server
Collaboration diagram for Server Functions:

## Functions

int | nc_server_add_endpt_unix_socket_listen (const char *endpt_name, const char *unix_socket_path, mode_t mode, uid_t uid, gid_t gid)
| Create a new UNIX socket endpoint and start listening.
void | nc_server_del_endpt_unix_socket (const char *endpt_name)
| Deletes a UNIX socket endpoint.
void | nc_server_destroy (void)
| Destroy any dynamically allocated libssh and/or libssl/libcrypto and server resources.
int | nc_server_endpt_count (void)
| Get the number of currently configured listening endpoints. Note that an ednpoint without address and/or port will be included even though it is not, in fact, listening.
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()

void nc_server_destroy | ( | void |  | ) |

Destroy any dynamically allocated libssh and/or libssl/libcrypto and server 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] | ctx | Optional 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_mode | basic-mode with-defaults parameter.
  [in] | also_supported | NC_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_mode | basic-mode parameter.
  [out] | also_supported | also-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] | value | Capability string to be advertised in server's <hello> messages.

## 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_clb | Callback that should return the yang-library content identifier.
  [in] | user_data | Optional arbitrary user data that will be passed to `content_id_clb`.
  [in] | free_user_data | Optional 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] | ctx | Context 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] | ctx | Context to read most capabilities from.
  [in] | version | YANG 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()

int nc_server_endpt_count | ( | void |  | ) |

Get the number of currently configured listening endpoints. Note that an ednpoint without address and/or port will be included even though it is not, in fact, listening.

Returns
  Number of added listening endpoints.

## nc_server_add_endpt_unix_socket_listen()

int nc_server_add_endpt_unix_socket_listen | ( | const char * | endpt_name,
|  | const char * | unix_socket_path,
|  | mode_t | mode,
|  | uid_t | uid,
|  | gid_t | gid
| ) |  |

Create a new UNIX socket endpoint and start listening.

Parameters

  [in] | endpt_name | Arbitrary unique identifier of the endpoint.
  [in] | unix_socket_path | Path to the listening socket.
  [in] | mode | New mode, -1 to use default.
  [in] | uid | New uid, -1 to use default.
  [in] | gid | New gid, -1 to use default.

Returns
  0 on success, 1 on error.

## nc_server_del_endpt_unix_socket()

void nc_server_del_endpt_unix_socket | ( | const char * | endpt_name | ) |

Deletes a UNIX socket endpoint.

Parameters

  [in] | endpt_name | Identifier of the endpoint. Has no effect if the endpoint doesn't exist or if its transport is not UNIX socket.