31 #include <sys/types.h>
34 #include <libyang/libyang.h>
780 sr_val_t **values,
size_t *value_cnt);
826 const sr_get_oper_options_t opts,
struct lyd_node **data);
926 const sr_edit_options_t opts);
968 const char *leaflist_value,
const char *origin,
const sr_edit_options_t opts);
1045 uint32_t timeout_ms,
int wait);
1124 uint32_t *nc_id, time_t *timestamp);
1337 sr_event_t event, uint32_t request_id,
void *private_data);
1358 sr_module_change_cb callback,
void *private_data, uint32_t priority, sr_subscr_options_t opts,
1439 const struct lyd_node **node,
const char **prev_value,
const char **prev_list,
bool *prev_dflt);
1477 sr_event_t event, uint32_t request_id,
sr_val_t **output,
size_t *output_cnt,
void *private_data);
1494 sr_event_t event, uint32_t request_id,
struct lyd_node *output,
void *private_data);
1532 void *private_data, uint32_t priority, sr_subscr_options_t opts,
sr_subscription_ctx_t **subscription);
1554 uint32_t timeout_ms,
sr_val_t **output,
size_t *output_cnt);
1612 const sr_val_t *values,
const size_t values_cnt, time_t timestamp,
void *private_data);
1626 const struct lyd_node *notif, time_t timestamp,
void *private_data);
1647 time_t stop_time,
sr_event_notif_cb callback,
void *private_data, sr_subscr_options_t opts,
1768 const char *request_xpath, uint32_t request_id,
struct lyd_node **parent,
void *private_data);
1807 #define SRP_INIT_CB "sr_plugin_init_cb"
1812 #define SRP_CLEANUP_CB "sr_plugin_cleanup_cb"
1842 #define SRP_LOG_ERR(...) srp_log(SR_LL_ERR, __VA_ARGS__)
1849 #define SRP_LOG_WRN(...) srp_log(SR_LL_WRN, __VA_ARGS__)
1856 #define SRP_LOG_INF(...) srp_log(SR_LL_INF, __VA_ARGS__)
1863 #define SRP_LOG_DBG(...) srp_log(SR_LL_DBG, __VA_ARGS__)
1870 #define SRP_LOG_ERRMSG(msg) srp_log(SR_LL_ERR, msg)
1877 #define SRP_LOG_WRNMSG(msg) srp_log(SR_LL_WRN, msg)
1884 #define SRP_LOG_INFMSG(msg) srp_log(SR_LL_INF, msg)
1891 #define SRP_LOG_DBGMSG(msg) srp_log(SR_LL_DBG, msg)
int sr_session_switch_ds(sr_session_ctx_t *session, sr_datastore_t ds)
Change datastore which the session operates on. All subsequent calls will be issued on the chosen dat...
int sr_discard_changes(sr_session_ctx_t *session)
Discard prepared changes made in the current session.
int sr_event_notif_subscribe(sr_session_ctx_t *session, const char *module_name, const char *xpath, time_t start_time, time_t stop_time, sr_event_notif_cb callback, void *private_data, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription)
Subscribe for the delivery of a notification(s). Data are represented as sr_val_t structures...
sr_get_oper_flag_e
Flags used to override default data get behaviour on SR_DS_OPERATIONAL by sr_get_data call...
The subscriber will be called before any other subscribers for the particular module with an addition...
const char * sr_strerror(int err_code)
Returns the error message corresponding to the error code.
enum sr_datastore_e sr_datastore_t
Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds.
struct sr_val_s sr_val_t
Structure that contains value of an data element stored in the sysrepo datastore. ...
sr_conn_flag_e
Flags used to override default connection handling by sr_connect call.
int sr_get_lock(sr_conn_ctx_t *conn, sr_datastore_t datastore, const char *module_name, int *is_locked, uint32_t *id, uint32_t *nc_id, time_t *timestamp)
Check whether the data of the specified module or the whole datastore are locked. ...
This option enables the application to re-use an already existing subscription context previously ret...
sr_conn_ctx_t * sr_session_get_connection(sr_session_ctx_t *session)
Get the connection the session was created on.
enum sr_subscr_flag_e sr_subscr_flag_t
Flags used to override default handling of subscriptions.
int sr_get_subtree(sr_session_ctx_t *session, const char *path, uint32_t timeout_ms, struct lyd_node **subtree)
Retrieve a single subtree whose root node is selected by the provided path. Data are represented as l...
int sr_get_item(sr_session_ctx_t *session, const char *path, uint32_t timeout_ms, sr_val_t **value)
Retrieve a single data element selected by the provided path. Data are represented as sr_val_t struct...
Structure that contains value of an data element stored in the sysrepo datastore. ...
sr_log_level_t sr_log_get_stderr(void)
Learn current standard error output log level.
enum sr_change_oper_e sr_change_oper_t
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next.
int sr_set_item_str(sr_session_ctx_t *session, const char *path, const char *value, const char *origin, const sr_edit_options_t opts)
Prepare to set (create) the value of a leaf, leaf-list, list, or presence container. These changes are applied only after calling sr_apply_changes. Data are represented as pairs of a path and string value.
int sr_session_start(sr_conn_ctx_t *conn, const sr_datastore_t datastore, sr_session_ctx_t **session)
Start a new session.
int sr_get_module_access(sr_conn_ctx_t *conn, const char *module_name, char **owner, char **group, mode_t *perm)
Learn about module filesystem permissions.
int sr_get_items(sr_session_ctx_t *session, const char *xpath, uint32_t timeout_ms, const sr_get_oper_options_t opts, sr_val_t **values, size_t *value_cnt)
Retrieve an array of data elements selected by the provided XPath. Data are represented as sr_val_t s...
sr_datastore_e
Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds.
void(* sr_event_notif_cb)(sr_session_ctx_t *session, const sr_ev_notif_type_t notif_type, const char *xpath, const sr_val_t *values, const size_t values_cnt, time_t timestamp, void *private_data)
Callback to be called for the delivery of a notification. Data are represented as sr_val_t structures...
int sr_event_notif_send(sr_session_ctx_t *session, const char *path, const sr_val_t *values, const size_t values_cnt)
Send a notification. Data are represented as sr_val_t structures. In case there are particularly many...
uint32_t sr_edit_options_t
Options overriding default behavior of data manipulation calls, it is supposed to be bitwise OR-ed va...
void sr_free_change_iter(sr_change_iter_t *iter)
Frees sr_change_iter_t iterator and all memory allocated within it.
int(* srp_init_cb_t)(sr_session_ctx_t *session, void **private_data)
Sysrepo plugin initialization callback.
enum sr_conn_flag_e sr_conn_flag_t
Flags used to override default connection handling by sr_connect call.
int sr_event_notif_subscribe_tree(sr_session_ctx_t *session, const char *module_name, const char *xpath, time_t start_time, time_t stop_time, sr_event_notif_tree_cb callback, void *private_data, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription)
Subscribes for the delivery of a notification(s). Data are represented as libyang subtrees...
int sr_get_module_info(sr_conn_ctx_t *conn, struct lyd_node **sysrepo_data)
Get internal sysrepo data tree, which holds information about installed modules. These data are from ...
void sr_log_syslog(const char *app_name, sr_log_level_t log_level)
Enables / disables / changes log level (verbosity) of logging to system log.
sr_edit_flag_e
Flags used to override default behavior of data manipulation calls.
Default behavior of the subscription. In case of sr_module_change_subscribe call it means that: ...
Instead of removing any previous existing matching data before getting them from an operational subsc...
void sr_free_val(sr_val_t *value)
Free sr_val_t structure and all memory allocated within it.
void sr_session_set_nc_id(sr_session_ctx_t *session, uint32_t nc_sid)
Set a NETCONF session ID for a sysrepo session. Any application callbacks handling operations initiat...
int sr_process_events(sr_subscription_ctx_t *subscription, sr_session_ctx_t *session, time_t *stop_time_in)
Process any pending new events on a subscription. Should not be called unless SR_SUBSCR_NO_THREAD fla...
int sr_event_notif_sub_suspend(sr_subscription_ctx_t *subscription, uint32_t sub_id)
Suspend a notification subscription, special SR_EV_NOTIF_SUSPENDED notification is delivered...
sr_log_level_t
Log levels used to determine if message of certain severity should be printed.
int sr_copy_config(sr_session_ctx_t *session, const char *module_name, sr_datastore_t src_datastore, uint32_t timeout_ms, int wait)
Replaces a conventional datastore with the contents of another conventional datastore. If the module is specified, limits the operation only to the specified module. If it is not specified, the operation is performed on all modules.
int sr_set_item(sr_session_ctx_t *session, const char *path, const sr_val_t *value, const sr_edit_options_t opts)
Prepare to set (create) the value of a leaf, leaf-list, list, or presence container. These changes are applied only after calling sr_apply_changes. Data are represented as sr_val_t structures.
int(* sr_rpc_tree_cb)(sr_session_ctx_t *session, const char *op_path, const struct lyd_node *input, sr_event_t event, uint32_t request_id, struct lyd_node *output, void *private_data)
Callback to be called for the delivery of an RPC/action. Data are represented as libyang subtrees...
Detailed sysrepo session error information.
void sr_free_values(sr_val_t *values, size_t count)
Free array of sr_val_t structures (and all memory allocated within of each array element).
int(* sr_oper_get_items_cb)(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data)
Callback to be called when operational data at the selected xpath are requested. Data are represented...
void sr_log_set_cb(sr_log_cb log_callback)
Sets callback that will be called when a log entry would be populated. Callback will be called for ev...
int sr_event_notif_sub_resume(sr_subscription_ctx_t *subscription, uint32_t sub_id)
Resume a previously suspended notification subscription, special SR_EV_NOTIF_RESUMED notification is ...
int sr_has_changes(sr_session_ctx_t *session)
Learn whether there are any prepared non-applied changes in the session.
sr_type_e
Possible types of a data element stored in the sysrepo datastore.
int sr_remove_module(sr_conn_ctx_t *conn, const char *module_name)
Remove an installed module from sysrepo. Deferred until there are no connections! ...
The subscriber wants to be notified about the current configuration at the moment of subscribing...
enum sr_ev_notif_type_e sr_ev_notif_type_t
Type of the notification passed to the sr_event_notif_cb and sr_event_notif_tree_cb callbacks...
enum sr_edit_flag_e sr_edit_flag_t
Flags used to override default behavior of data manipulation calls.
void(* sr_event_notif_tree_cb)(sr_session_ctx_t *session, const sr_ev_notif_type_t notif_type, const struct lyd_node *notif, time_t timestamp, void *private_data)
Callback to be called for the delivery of a notification. Data are represented as libyang subtrees...
struct sr_subscription_ctx_s sr_subscription_ctx_t
Sysrepo subscription context returned from sr_*_subscribe calls, it is supposed to be released by the...
uint32_t sr_session_get_event_sr_id(sr_session_ctx_t *session)
Return the session ID of the event originator sysrepo session. Should be used on the implicit session...
int sr_connection_count(uint32_t *conn_count)
Learn the current global number of alive connections.
enum sr_move_position_e sr_move_position_t
Options for specifying move direction of sr_move_item call.
int sr_update_module(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs)
Update an installed schema (module) to a new revision. Deferred until there are no connections! ...
int sr_delete_item(sr_session_ctx_t *session, const char *path, const sr_edit_options_t opts)
Prepare to selete the nodes matching the specified xpath. These changes are applied only after callin...
int sr_unsubscribe(sr_subscription_ctx_t *subscription)
Unsubscribes from a subscription acquired by any of sr_*_subscribe calls and releases all subscriptio...
int sr_dup_changes_iter(sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter)
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in mod...
Data of an element (if applicable), properly set according to the type.
const char * sr_get_repo_path(void)
Get the common path prefix for all sysrepo files.
sr_error_e
Sysrepo error codes.
int sr_event_notif_send_tree(sr_session_ctx_t *session, struct lyd_node *notif)
Send a notification. Data are represented as libyang subtrees. In case there are particularly many no...
void sr_log_stderr(sr_log_level_t log_level)
Enables / disables / changes log level (verbosity) of logging to standard error output.
enum sr_event_e sr_event_t
Type of the event that has occurred (passed to application callbacks).
int sr_cancel_update_module(sr_conn_ctx_t *conn, const char *module_name)
Cancel scheduled update of a module.
uint32_t sr_get_oper_options_t
Options overriding default get handling by sr_get_data call, it is supposed to be bitwise OR-ed value...
enum sr_get_oper_flag_e sr_get_oper_flag_t
Flags used to override default data get behaviour on SR_DS_OPERATIONAL by sr_get_data call...
int sr_session_notif_buffer(sr_session_ctx_t *session)
Use notification buffering for the session.
int(* sr_diff_check_cb)(sr_session_ctx_t *session, const struct lyd_node *diff)
Callback to be called before applying a diff. Set it using sr_set_diff_check_callback.
The options should not be used as it is deprecated and ignored. Callbacks can always modify other sub...
struct sr_conn_ctx_s sr_conn_ctx_t
Sysrepo connection.
uint32_t sr_session_get_event_nc_id(sr_session_ctx_t *session)
Learn NETCONF session ID set for the event originator sysrepo session. Should be used on the implicit...
int sr_rpc_send(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt, uint32_t timeout_ms, sr_val_t **output, size_t *output_cnt)
Send an RPC/action and wait for the result. Data are represented as sr_val_t structures.
The subscriber does not support verification of the changes and wants to be notified only after the c...
struct sr_session_ctx_s sr_session_ctx_t
Sysrepo session on a connection.
sr_error_info_msg_t * err
int sr_rpc_send_tree(sr_session_ctx_t *session, struct lyd_node *input, uint32_t timeout_ms, struct lyd_node **output)
Send an RPC/action and wait for the result. Data are represented as libyang subtrees.
sr_datastore_t sr_session_get_ds(sr_session_ctx_t *session)
Learn the datastore a session operates on.
int sr_unlock(sr_session_ctx_t *session, const char *module_name)
Unlocks the data of the specified module or the whole datastore.
int sr_oper_get_items_subscribe(sr_session_ctx_t *session, const char *module_name, const char *path, sr_oper_get_items_cb callback, void *private_data, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription)
Register for providing operational data at the given xpath.
struct sr_change_iter_s sr_change_iter_t
Iterator used for retrieval of a changeset using sr_get_changes_iter call.
int sr_lock(sr_session_ctx_t *session, const char *module_name)
Locks the data of the specified module or the whole datastore.
int sr_install_module_data(sr_conn_ctx_t *conn, const char *module_name, const char *data, const char *data_path, LYD_FORMAT format)
Set newly installed module startup and running data. It is necessary in case empty data are not valid...
uint32_t sr_session_get_id(sr_session_ctx_t *session)
Return the assigned session ID of the sysrepo session.
int sr_set_module_access(sr_conn_ctx_t *conn, const char *module_name, const char *owner, const char *group, mode_t perm)
Change module filesystem permissions.
int(* sr_rpc_cb)(sr_session_ctx_t *session, const char *xpath, const sr_val_t *input, const size_t input_cnt, sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data)
Callback to be called for the delivery of an RPC/action. Data are represented as sr_val_t structures...
int sr_validate(sr_session_ctx_t *session, const char *module_name, uint32_t timeout_ms)
Perform the validation a datastore and any changes made in the current session, but do not apply nor ...
const char * sr_session_get_user(sr_session_ctx_t *session)
Get the effective user of a session.
int sr_get_error(sr_session_ctx_t *session, const sr_error_info_t **error_info)
Retrieve information about the error that has occurred during the last operation executed within prov...
int sr_get_data(sr_session_ctx_t *session, const char *xpath, uint32_t max_depth, uint32_t timeout_ms, const sr_get_oper_options_t opts, struct lyd_node **data)
Retrieve a tree whose root nodes match the provided XPath. Data are represented as libyang subtrees...
int sr_apply_changes(sr_session_ctx_t *session, uint32_t timeout_ms, int wait)
Apply changes made in the current session. In case the changes could not be applied successfully for ...
void(* sr_log_cb)(sr_log_level_t level, const char *message)
Sets callback that will be called when a log entry would be populated.
void sr_set_diff_check_callback(sr_conn_ctx_t *conn, sr_diff_check_cb callback)
Set callback for checking every diff before it is applied on the datastore. The diff is final (only C...
int sr_module_change_subscribe(sr_session_ctx_t *session, const char *module_name, const char *xpath, sr_module_change_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription)
Subscribe for changes made in the specified module. If there are changes made in several modules...
int sr_session_stop(sr_session_ctx_t *session)
Stop current session and releases resources tied to the session.
int sr_get_changes_iter(sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter)
Create an iterator for retrieving the changes (list of newly added / removed / modified nodes) in mod...
int sr_rpc_subscribe(sr_session_ctx_t *session, const char *xpath, sr_rpc_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription)
Subscribe for the delivery of an RPC/action. Data are represented as sr_val_t structures.
int sr_install_module(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs, const char **features, int feat_count)
Install a new schema (module) into sysrepo. Deferred until there are no connections! ...
There will be no thread created for handling this subscription meaning no event will be processed! Us...
struct sr_error_info_msg_s sr_error_info_msg_t
A single, detailed error message. Used in sr_error_info_s.
sr_ev_notif_type_e
Type of the notification passed to the sr_event_notif_cb and sr_event_notif_tree_cb callbacks...
sr_event_e
Type of the event that has occurred (passed to application callbacks).
sr_change_oper_e
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next.
struct sr_error_info_s sr_error_info_t
Detailed sysrepo session error information.
uint32_t sr_session_get_nc_id(sr_session_ctx_t *session)
Learn NETCONF session ID set for a sysrepo session.
enum sr_error_e sr_error_t
Sysrepo error codes.
int sr_rpc_subscribe_tree(sr_session_ctx_t *session, const char *xpath, sr_rpc_tree_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription)
Subscribe for the delivery of an RPC/action. Data are represented as libyang subtrees.
int sr_set_module_replay_support(sr_conn_ctx_t *conn, const char *module_name, int replay_support)
Change module replay support.
int sr_enable_module_feature(sr_conn_ctx_t *conn, const char *module_name, const char *feature_name)
Enable a module feature. Deferred until there are no connections!
int sr_set_error(sr_session_ctx_t *session, const char *path, const char *format,...)
Set detailed error information into provided session. Used to notify the client library about errors ...
int sr_get_event_pipe(sr_subscription_ctx_t *subscription, int *event_pipe)
Get the event pipe of a subscription. Do not call unless SR_SUBSCR_NO_THREAD flag was used when subsc...
sr_move_position_e
Options for specifying move direction of sr_move_item call.
int sr_move_item(sr_session_ctx_t *session, const char *path, const sr_move_position_t position, const char *list_keys, const char *leaflist_value, const char *origin, const sr_edit_options_t opts)
Prepare to move/create the instance of an user-ordered list or leaf-list to the specified position...
uint32_t sr_subscr_options_t
Options overriding default behavior of subscriptions, it is supposed to be a bitwise OR-ed value of a...
void srp_log(sr_log_level_t ll, const char *format,...)
struct ly_ctx * sr_get_context(sr_conn_ctx_t *conn)
Get the libyang context used by a connection. Can be used in an application for working with data and...
int sr_replace_config(sr_session_ctx_t *session, const char *module_name, struct lyd_node *src_config, uint32_t timeout_ms, int wait)
Replace a datastore with the contents of a data tree. If the module is specified, limit the operation...
int sr_session_set_user(sr_session_ctx_t *session, const char *user)
Set the effective user of a session to a different one that the process owner.
enum sr_type_e sr_type_t
Possible types of a data element stored in the sysrepo datastore.
int sr_edit_batch(sr_session_ctx_t *session, const struct lyd_node *edit, const char *default_operation)
Provide a prepared edit data tree to be applied. These changes are applied only after calling sr_appl...
sr_subscr_flag_e
Flags used to override default handling of subscriptions.
int sr_disable_module_feature(sr_conn_ctx_t *conn, const char *module_name, const char *feature_name)
Disable a module feature. Deferred until there are no connections!
int(* sr_module_change_cb)(sr_session_ctx_t *session, const char *module_name, const char *xpath, sr_event_t event, uint32_t request_id, void *private_data)
Callback to be called on the event of changing datastore content of the specified module...
A single, detailed error message. Used in sr_error_info_s.
union sr_data_u sr_data_t
Data of an element (if applicable), properly set according to the type.
int sr_connect(const sr_conn_options_t opts, sr_conn_ctx_t **conn)
Connects to the sysrepo datastore. If possible (no other connections exist), also apply any scheduled...
The subscriber is not the "owner" of the subscribed data tree, just a passive watcher for changes...
uint32_t sr_event_notif_sub_id_get_last(const sr_subscription_ctx_t *subscription)
Get the subscription ID of the last notification subscription.
int sr_disconnect(sr_conn_ctx_t *conn)
Disconnect from the sysrepo datastore.
void(* srp_cleanup_cb_t)(sr_session_ctx_t *session, void *private_data)
Sysrepo plugin cleanup callback.
sr_log_level_t sr_log_get_syslog(void)
Learn current system log log level.
int sr_get_change_next(sr_session_ctx_t *session, sr_change_iter_t *iter, sr_change_oper_t *operation, sr_val_t **old_value, sr_val_t **new_value)
Return the next change from the provided iterator created by sr_get_changes_iter call. Data are represented as sr_val_t structures.
uint32_t sr_conn_options_t
Options overriding default connection handling by sr_connect call, it is supposed to be bitwise OR-ed...
const char * sr_session_get_event_user(sr_session_ctx_t *session)
Get the effective user of the event originator sysrepo session. Should be used on the implicit sessio...
int sr_get_change_tree_next(sr_session_ctx_t *session, sr_change_iter_t *iter, sr_change_oper_t *operation, const struct lyd_node **node, const char **prev_value, const char **prev_list, bool *prev_dflt)
Returns the next change from the provided iterator created by sr_get_changes_iter call...