sysrepo  2.0.53
YANG-based system repository for all-around configuration management.
sysrepo.h
Go to the documentation of this file.
1 
17 #ifndef _SYSREPO_H
18 #define _SYSREPO_H
19 
20 #include <stdint.h>
21 #include <stdlib.h>
22 #include <sys/types.h>
23 #include <time.h>
24 #include <unistd.h>
25 
26 #include <libyang/libyang.h>
27 
28 #include "sysrepo_types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
35 // Logging API
37 
49 const char *sr_strerror(int err_code);
50 
64 void sr_log_stderr(sr_log_level_t log_level);
65 
72 
90 void sr_log_syslog(const char *app_name, sr_log_level_t log_level);
91 
98 
105 void sr_log_set_cb(sr_log_cb log_callback);
106 
110 // Connection / Session Management
112 
131 
144 
151 int sr_connection_count(uint32_t *conn_count);
152 
160 const struct ly_ctx *sr_get_context(sr_conn_ctx_t *conn);
161 
170 
176 uid_t sr_get_su_uid(void);
177 
191 
205 int sr_discard_oper_changes(sr_conn_ctx_t *conn, sr_session_ctx_t *session, const char *xpath, uint32_t timeout_ms);
206 
220 int sr_session_start(sr_conn_ctx_t *conn, const sr_datastore_t datastore, sr_session_ctx_t **session);
221 
235 
246 
259 
270 
278 
288 int sr_session_set_orig_name(sr_session_ctx_t *session, const char *orig_name);
289 
297 
308 int sr_session_push_orig_data(sr_session_ctx_t *session, uint32_t size, const void *data);
309 
316 
326 int sr_session_get_orig_data(sr_session_ctx_t *session, uint32_t idx, uint32_t *size, const void **data);
327 
338 int sr_session_get_error(sr_session_ctx_t *session, const sr_error_info_t **error_info);
339 
348 
361 int sr_session_set_error_message(sr_session_ctx_t *session, const char *format, ...);
362 
371 int sr_session_set_error_format(sr_session_ctx_t *session, const char *error_format);
372 
383 int sr_session_push_error_data(sr_session_ctx_t *session, uint32_t size, const void *data);
384 
394 int sr_get_error_data(sr_error_info_err_t *err, uint32_t idx, uint32_t *size, const void **data);
395 
403 
413 int sr_session_set_user(sr_session_ctx_t *session, const char *user);
414 
421 const char *sr_session_get_user(sr_session_ctx_t *session);
422 
430 
434 // Schema Manipulation API
436 
450 const char *sr_get_repo_path(void);
451 
463 int sr_install_module(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs, const char **features);
464 
475 int sr_install_module_custom_ds(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs,
476  const char **features, const sr_module_ds_t *module_ds);
477 
489 int sr_install_module_data(sr_conn_ctx_t *conn, const char *module_name, const char *data, const char *data_path,
490  LYD_FORMAT format);
491 
501 int sr_remove_module(sr_conn_ctx_t *conn, const char *module_name);
502 
513 int sr_update_module(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs);
514 
524 int sr_cancel_update_module(sr_conn_ctx_t *conn, const char *module_name);
525 
534 int sr_set_module_replay_support(sr_conn_ctx_t *conn, const char *module_name, int replay_support);
535 
547 int sr_set_module_ds_access(sr_conn_ctx_t *conn, const char *module_name, int mod_ds, const char *owner,
548  const char *group, mode_t perm);
549 
553 int sr_set_module_access(sr_conn_ctx_t *conn, const char *module_name, const char *owner, const char *group, mode_t perm);
554 
566 int sr_get_module_ds_access(sr_conn_ctx_t *conn, const char *module_name, int mod_ds, char **owner, char **group,
567  mode_t *perm);
568 
572 int sr_get_module_access(sr_conn_ctx_t *conn, const char *module_name, char **owner, char **group, mode_t *perm);
573 
584 int sr_check_module_ds_access(sr_conn_ctx_t *conn, const char *module_name, int mod_ds, int *read, int *write);
585 
600 int sr_enable_module_feature(sr_conn_ctx_t *conn, const char *module_name, const char *feature_name);
601 
615 int sr_disable_module_feature(sr_conn_ctx_t *conn, const char *module_name, const char *feature_name);
616 
625 int sr_get_module_info(sr_conn_ctx_t *conn, struct lyd_node **sysrepo_data);
626 
630 // Data Retrieval API (get / get-config functionality)
632 
659 int sr_get_item(sr_session_ctx_t *session, const char *path, uint32_t timeout_ms, sr_val_t **value);
660 
678 int sr_get_items(sr_session_ctx_t *session, const char *xpath, uint32_t timeout_ms, const sr_get_oper_options_t opts,
679  sr_val_t **values, size_t *value_cnt);
680 
698 int sr_get_subtree(sr_session_ctx_t *session, const char *path, uint32_t timeout_ms, struct lyd_node **subtree);
699 
724 int sr_get_data(sr_session_ctx_t *session, const char *xpath, uint32_t max_depth, uint32_t timeout_ms,
725  const sr_get_oper_options_t opts, struct lyd_node **data);
726 
732 void sr_free_val(sr_val_t *value);
733 
741 void sr_free_values(sr_val_t *values, size_t count);
742 
746 // Data Manipulation API (edit-config functionality)
748 
778 int sr_set_item(sr_session_ctx_t *session, const char *path, const sr_val_t *value, const sr_edit_options_t opts);
779 
795 int sr_set_item_str(sr_session_ctx_t *session, const char *path, const char *value, const char *origin,
796  const sr_edit_options_t opts);
797 
812 int sr_delete_item(sr_session_ctx_t *session, const char *path, const sr_edit_options_t opts);
813 
826 int sr_oper_delete_item_str(sr_session_ctx_t *session, const char *path, const char *value, const sr_edit_options_t opts);
827 
854 int sr_move_item(sr_session_ctx_t *session, const char *path, const sr_move_position_t position, const char *list_keys,
855  const char *leaflist_value, const char *origin, const sr_edit_options_t opts);
856 
871 int sr_edit_batch(sr_session_ctx_t *session, const struct lyd_node *edit, const char *default_operation);
872 
884 int sr_validate(sr_session_ctx_t *session, const char *module_name, uint32_t timeout_ms);
885 
902 int sr_apply_changes(sr_session_ctx_t *session, uint32_t timeout_ms);
903 
911 
919 
932 int sr_replace_config(sr_session_ctx_t *session, const char *module_name, struct lyd_node *src_config,
933  uint32_t timeout_ms);
934 
952 int sr_copy_config(sr_session_ctx_t *session, const char *module_name, sr_datastore_t src_datastore, uint32_t timeout_ms);
953 
957 // Locking API
959 
980 int sr_lock(sr_session_ctx_t *session, const char *module_name);
981 
991 int sr_unlock(sr_session_ctx_t *session, const char *module_name);
992 
1008 int sr_get_lock(sr_conn_ctx_t *conn, sr_datastore_t datastore, const char *module_name, int *is_locked, uint32_t *id,
1009  struct timespec *timestamp);
1010 
1014 // Subscription API
1016 
1032 int sr_get_event_pipe(sr_subscription_ctx_t *subscription, int *event_pipe);
1033 
1046  struct timespec *stop_time_in);
1047 
1051 int sr_process_events(sr_subscription_ctx_t *subscription, sr_session_ctx_t *session, time_t *stop_time_in);
1052 
1060 
1069 int sr_subscription_get_suspended(sr_subscription_ctx_t *subscription, uint32_t sub_id, int *suspended);
1070 
1079 int sr_subscription_suspend(sr_subscription_ctx_t *subscription, uint32_t sub_id);
1080 
1089 int sr_subscription_resume(sr_subscription_ctx_t *subscription, uint32_t sub_id);
1090 
1104 int sr_unsubscribe_sub(sr_subscription_ctx_t *subscription, uint32_t sub_id);
1105 
1114 
1122 
1132 
1136 // Change Subscriptions API
1138 
1162 int sr_module_change_subscribe(sr_session_ctx_t *session, const char *module_name, const char *xpath,
1163  sr_module_change_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts,
1164  sr_subscription_ctx_t **subscription);
1165 
1177 int sr_module_change_sub_get_info(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char **module_name,
1178  sr_datastore_t *ds, const char **xpath, uint32_t *filtered_out);
1179 
1188 int sr_module_change_sub_modify_xpath(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char *xpath);
1189 
1205 int sr_get_changes_iter(sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter);
1206 
1222 int sr_dup_changes_iter(sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter);
1223 
1243  sr_val_t **old_value, sr_val_t **new_value);
1244 
1268  const struct lyd_node **node, const char **prev_value, const char **prev_list, int *prev_dflt);
1269 
1276 
1280 // RPC (Remote Procedure Calls) and Action API
1282 
1304 int sr_rpc_subscribe(sr_session_ctx_t *session, const char *xpath, sr_rpc_cb callback, void *private_data,
1305  uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1306 
1323 int sr_rpc_subscribe_tree(sr_session_ctx_t *session, const char *xpath, sr_rpc_tree_cb callback,
1324  void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1325 
1345 int sr_rpc_send(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
1346  uint32_t timeout_ms, sr_val_t **output, size_t *output_cnt);
1347 
1361 int sr_rpc_send_tree(sr_session_ctx_t *session, struct lyd_node *input, uint32_t timeout_ms, struct lyd_node **output);
1362 
1366 // Notifications API
1368 
1392 int sr_notif_subscribe(sr_session_ctx_t *session, const char *module_name, const char *xpath,
1393  const struct timespec *start_time, const struct timespec *stop_time, sr_event_notif_cb callback,
1394  void *private_data, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1395 
1414 int sr_notif_subscribe_tree(sr_session_ctx_t *session, const char *module_name, const char *xpath,
1415  const struct timespec *start_time, const struct timespec *stop_time, sr_event_notif_tree_cb callback,
1416  void *private_data, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1417 
1421 int sr_event_notif_subscribe(sr_session_ctx_t *session, const char *module_name, const char *xpath, time_t start_time,
1422  time_t stop_time, sr_event_notif_cb callback, void *private_data, sr_subscr_options_t opts,
1423  sr_subscription_ctx_t **subscription);
1424 
1428 int sr_event_notif_subscribe_tree(sr_session_ctx_t *session, const char *module_name, const char *xpath,
1429  time_t start_time, time_t stop_time, sr_event_notif_tree_cb callback, void *private_data,
1430  sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1431 
1452 int sr_event_notif_send(sr_session_ctx_t *session, const char *path, const sr_val_t *values, const size_t values_cnt,
1453  uint32_t timeout_ms, int wait);
1454 
1472 int sr_event_notif_send_tree(sr_session_ctx_t *session, struct lyd_node *notif, uint32_t timeout_ms, int wait);
1473 
1486 int sr_notif_sub_get_info(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char **module_name,
1487  const char **xpath, struct timespec *start_time, struct timespec *stop_time, uint32_t *filtered_out);
1488 
1492 int sr_event_notif_sub_get_info(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char **module_name,
1493  const char **xpath, time_t *start_time, time_t *stop_time, uint32_t *filtered_out);
1494 
1504 int sr_event_notif_sub_modify_xpath(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char *xpath);
1505 
1515 int sr_notif_sub_modify_stop_time(sr_subscription_ctx_t *subscription, uint32_t sub_id, const struct timespec *stop_time);
1516 
1520 int sr_event_notif_sub_modify_stop_time(sr_subscription_ctx_t *subscription, uint32_t sub_id, time_t stop_time);
1521 
1525 // Operational Data API
1527 
1553 int sr_oper_get_items_subscribe(sr_session_ctx_t *session, const char *module_name, const char *path,
1554  sr_oper_get_items_cb callback, void *private_data, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1555 
1559 // Plugin API
1561 
1572 #define SRP_INIT_CB "sr_plugin_init_cb"
1573 
1579 #define SRP_CLEANUP_CB "sr_plugin_cleanup_cb"
1580 
1587 #define SRPLG_LOG_ERR(plg_name, ...) srplg_log(plg_name, SR_LL_ERR, __VA_ARGS__)
1588 
1595 #define SRPLG_LOG_WRN(plg_name, ...) srplg_log(plg_name, SR_LL_WRN, __VA_ARGS__)
1596 
1603 #define SRPLG_LOG_INF(plg_name, ...) srplg_log(plg_name, SR_LL_INF, __VA_ARGS__)
1604 
1611 #define SRPLG_LOG_DBG(plg_name, ...) srplg_log(plg_name, SR_LL_DBG, __VA_ARGS__)
1612 
1618 #define SRP_LOG_ERR(...) srp_log(SR_LL_ERR, __VA_ARGS__)
1619 
1625 #define SRP_LOG_WRN(...) srp_log(SR_LL_WRN, __VA_ARGS__)
1626 
1632 #define SRP_LOG_INF(...) srp_log(SR_LL_INF, __VA_ARGS__)
1633 
1639 #define SRP_LOG_DBG(...) srp_log(SR_LL_DBG, __VA_ARGS__)
1640 
1652 void srplg_log(const char *plg_name, sr_log_level_t ll, const char *format, ...);
1653 
1662 void srp_log(sr_log_level_t ll, const char *format, ...);
1663 
1664 #ifdef __cplusplus
1665 }
1666 #endif
1667 
1668 #endif /* _SYSREPO_H */
int sr_module_change_sub_modify_xpath(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char *xpath)
Modify an existing change subscription by changing its XPath filter.
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, int *prev_dflt)
Returns the next change from the provided iterator created by sr_get_changes_iter call....
int(* sr_module_change_cb)(sr_session_ctx_t *session, uint32_t sub_id, 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.
sr_change_oper_t
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next.
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_module_change_sub_get_info(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char **module_name, sr_datastore_t *ds, const char **xpath, uint32_t *filtered_out)
Get information about an existing change subscription.
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....
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,...
struct sr_change_iter_s sr_change_iter_t
Iterator used for retrieval of a changeset using sr_get_changes_iter call.
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...
void sr_free_change_iter(sr_change_iter_t *iter)
Frees sr_change_iter_t iterator and all memory allocated within it.
int sr_session_set_orig_name(sr_session_ctx_t *session, const char *orig_name)
Set event originator name used for all events sent on this session. It can then be read from the impl...
int sr_session_set_error_message(sr_session_ctx_t *session, const char *format,...)
Set an error message for a failed callback communicated back to the originator. Does not print the me...
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_session_push_error_data(sr_session_ctx_t *session, uint32_t size, const void *data)
Push (add) another chunk of error data for a failed callback communicated back to the originator....
int sr_session_push_orig_data(sr_session_ctx_t *session, uint32_t size, const void *data)
Push (add) another chunk of event originator data used for all events sent on this session....
const char * sr_session_get_orig_name(sr_session_ctx_t *session)
Get event originator name.
uid_t sr_get_su_uid(void)
Get the sysrepo SUPERUSER UID.
int sr_disconnect(sr_conn_ctx_t *conn)
Disconnect from the sysrepo datastore.
int sr_session_unsubscribe(sr_session_ctx_t *session)
Unsubscribe all subscriptions created by this session.
int sr_session_get_orig_data(sr_session_ctx_t *session, uint32_t idx, uint32_t *size, const void **data)
Get a specific chunk of event originator data in a callback.
int sr_session_stop(sr_session_ctx_t *session)
Stop the session and releases resources tied to it.
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...
int sr_get_error_data(sr_error_info_err_t *err, uint32_t idx, uint32_t *size, const void **data)
Get a specific chunk of error data.
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.
int sr_session_start(sr_conn_ctx_t *conn, const sr_datastore_t datastore, sr_session_ctx_t **session)
Start a new session.
sr_conn_ctx_t * sr_session_get_connection(sr_session_ctx_t *session)
Get the connection the session was created on.
sr_datastore_t sr_session_get_ds(sr_session_ctx_t *session)
Learn the datastore a session operates on.
const char * sr_session_get_user(sr_session_ctx_t *session)
Get the effective user of a session.
int sr_session_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...
uint32_t sr_session_get_id(sr_session_ctx_t *session)
Return the assigned session ID of the sysrepo session.
const 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_connection_count(uint32_t *conn_count)
Learn the current global number of alive connections.
int sr_discard_oper_changes(sr_conn_ctx_t *conn, sr_session_ctx_t *session, const char *xpath, uint32_t timeout_ms)
Discard stored push operational data owned by this connection.
int sr_session_set_error_format(sr_session_ctx_t *session, const char *error_format)
Set error data format identifier for a failed callback communicated back to the originator....
void sr_session_del_orig_data(sr_session_ctx_t *session)
Remove all pushed event originator data.
int sr_session_notif_buffer(sr_session_ctx_t *session)
Use notification buffering for the session.
struct sr_conn_ctx_s sr_conn_ctx_t
Sysrepo connection.
Definition: sysrepo_types.h:87
int sr_session_dup_error(sr_session_ctx_t *src_session, sr_session_ctx_t *trg_session)
Copy the first error (if any) from a session to a callback session.
int 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...
uint32_t sr_get_content_id(sr_conn_ctx_t *conn)
Get content ID of the current YANG module set. It conforms to the requirements for ietf-yang-library ...
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....
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 ...
int sr_copy_config(sr_session_ctx_t *session, const char *module_name, sr_datastore_t src_datastore, uint32_t timeout_ms)
Replaces a conventional datastore with the contents of another conventional datastore....
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....
int sr_replace_config(sr_session_ctx_t *session, const char *module_name, struct lyd_node *src_config, uint32_t timeout_ms)
Replace a datastore with the contents of a data tree. If the module is specified, limit the operation...
sr_move_position_t
Options for specifying move direction of sr_move_item call.
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...
int sr_delete_item(sr_session_ctx_t *session, const char *path, const sr_edit_options_t opts)
Prepare to delete the nodes matching the specified xpath. These changes are applied only after callin...
int sr_discard_changes(sr_session_ctx_t *session)
Discard prepared changes made in the current session.
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....
int sr_has_changes(sr_session_ctx_t *session)
Learn whether there are any prepared non-applied changes in the session.
uint32_t sr_edit_options_t
Options overriding default behavior of data manipulation calls, it is supposed to be bitwise OR-ed va...
int sr_oper_delete_item_str(sr_session_ctx_t *session, const char *path, const char *value, const sr_edit_options_t opts)
Prepare to delete the nodes matching the specified xpath. These changes are applied only after callin...
int sr_apply_changes(sr_session_ctx_t *session, uint32_t timeout_ms)
Apply changes made in the current session. In case the changes could not be applied successfully for ...
void sr_free_val(sr_val_t *value)
Free sr_val_t structure and all memory allocated within it.
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...
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_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_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...
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...
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_unlock(sr_session_ctx_t *session, const char *module_name)
Unlocks the data of the specified module or the whole datastore.
int sr_get_lock(sr_conn_ctx_t *conn, sr_datastore_t datastore, const char *module_name, int *is_locked, uint32_t *id, struct timespec *timestamp)
Check whether the data of the specified module or the whole datastore are locked.
int sr_lock(sr_session_ctx_t *session, const char *module_name)
Locks the data of the specified module or the whole datastore.
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.
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...
void sr_log_stderr(sr_log_level_t log_level)
Enables / disables / changes log level (verbosity) of logging to standard error output.
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.
Definition: sysrepo_types.h:75
sr_log_level_t sr_log_get_stderr(void)
Learn current standard error output log level.
sr_log_level_t sr_log_get_syslog(void)
Learn current system log log level.
sr_log_level_t
Log levels used to determine if message of certain severity should be printed.
Definition: sysrepo_types.h:61
const char * sr_strerror(int err_code)
Returns the error message corresponding to the error code.
int sr_event_notif_sub_modify_xpath(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char *xpath)
Modify an existing notification subscription by changing its XPath filter. Special SR_EV_NOTIF_MODIFI...
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)
Deprecated, use sr_notif_subscribe_tree() instead.
int sr_event_notif_sub_get_info(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char **module_name, const char **xpath, time_t *start_time, time_t *stop_time, uint32_t *filtered_out)
Deprecated, use sr_notif_sub_get_info() instead.
int sr_notif_sub_get_info(sr_subscription_ctx_t *subscription, uint32_t sub_id, const char **module_name, const char **xpath, struct timespec *start_time, struct timespec *stop_time, uint32_t *filtered_out)
Get information about an existing notification subscription.
void(* sr_event_notif_cb)(sr_session_ctx_t *session, uint32_t sub_id, const sr_ev_notif_type_t notif_type, const char *xpath, const sr_val_t *values, const size_t values_cnt, struct timespec *timestamp, void *private_data)
Callback to be called for the delivery of a notification. Data are represented as sr_val_t structures...
void(* sr_event_notif_tree_cb)(sr_session_ctx_t *session, uint32_t sub_id, const sr_ev_notif_type_t notif_type, const struct lyd_node *notif, struct timespec *timestamp, void *private_data)
Callback to be called for the delivery of a notification. Data are represented as libyang subtrees.
int sr_notif_subscribe_tree(sr_session_ctx_t *session, const char *module_name, const char *xpath, const struct timespec *start_time, const struct timespec *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_notif_sub_modify_stop_time(sr_subscription_ctx_t *subscription, uint32_t sub_id, const struct timespec *stop_time)
Modify an existing notification subscription by changing its stop time. Special SR_EV_NOTIF_MODIFIED ...
int sr_event_notif_send(sr_session_ctx_t *session, const char *path, const sr_val_t *values, const size_t values_cnt, uint32_t timeout_ms, int wait)
Send a notification. Data are represented as sr_val_t structures. In case there are particularly many...
int sr_event_notif_send_tree(sr_session_ctx_t *session, struct lyd_node *notif, uint32_t timeout_ms, int wait)
Send a notification. Data are represented as libyang subtrees. In case there are particularly many no...
int sr_notif_subscribe(sr_session_ctx_t *session, const char *module_name, const char *xpath, const struct timespec *start_time, const struct timespec *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.
int sr_event_notif_sub_modify_stop_time(sr_subscription_ctx_t *subscription, uint32_t sub_id, time_t stop_time)
Deprecated, use sr_notif_sub_modify_stop_time() instead.
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)
Deprecated, use sr_notif_subscribe() instead.
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.
int(* sr_oper_get_items_cb)(sr_session_ctx_t *session, uint32_t sub_id, 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...
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_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.
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.
int(* sr_rpc_cb)(sr_session_ctx_t *session, uint32_t sub_id, 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_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_rpc_tree_cb)(sr_session_ctx_t *session, uint32_t sub_id, 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.
int sr_check_module_ds_access(sr_conn_ctx_t *conn, const char *module_name, int mod_ds, int *read, int *write)
Check whether the current application has read/write access to a module.
int sr_set_module_access(sr_conn_ctx_t *conn, const char *module_name, const char *owner, const char *group, mode_t perm)
Deprecated, use sr_set_module_ds_access() instead.
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_remove_module(sr_conn_ctx_t *conn, const char *module_name)
Remove an installed module from sysrepo. Deferred until there are no connections!
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_install_module_custom_ds(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs, const char **features, const sr_module_ds_t *module_ds)
Install a new schema (module) into sysrepo. Deferred until there are no connections!
int sr_get_module_ds_access(sr_conn_ctx_t *conn, const char *module_name, int mod_ds, char **owner, char **group, mode_t *perm)
Learn about module permissions.
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_get_module_access(sr_conn_ctx_t *conn, const char *module_name, char **owner, char **group, mode_t *perm)
Deprecated, use sr_get_module_ds_access() instead.
int sr_set_module_replay_support(sr_conn_ctx_t *conn, const char *module_name, int replay_support)
Change module replay support.
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...
int sr_set_module_ds_access(sr_conn_ctx_t *conn, const char *module_name, int mod_ds, const char *owner, const char *group, mode_t perm)
Change module permissions.
const char * sr_get_repo_path(void)
Get the common path prefix for all sysrepo files.
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 ...
int sr_install_module(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs, const char **features)
Install a new schema (module) into sysrepo. Deferred until there are no connections!
int sr_cancel_update_module(sr_conn_ctx_t *conn, const char *module_name)
Cancel scheduled update of a module.
int sr_subscription_suspend(sr_subscription_ctx_t *subscription, uint32_t sub_id)
Suspend a specific subscription. Special SR_EV_NOTIF_SUSPENDED notification is delivered for suspende...
int sr_unsubscribe_sub(sr_subscription_ctx_t *subscription, uint32_t sub_id)
Unsubscribe a specific or all the subscriptions in a subscription structure.
int sr_subscription_resume(sr_subscription_ctx_t *subscription, uint32_t sub_id)
Resume a previously suspended subscription. Special SR_EV_NOTIF_RESUMED notification is delivered for...
int sr_subscription_get_suspended(sr_subscription_ctx_t *subscription, uint32_t sub_id, int *suspended)
Learn the suspend state of a specific subscription.
int sr_unsubscribe(sr_subscription_ctx_t *subscription)
Unsubscribe all the subscriptions in a subscription structure and free it.
uint32_t sr_subscription_get_last_sub_id(const sr_subscription_ctx_t *subscription)
Get the subscription ID of the last created subscription.
int sr_subscription_process_events(sr_subscription_ctx_t *subscription, sr_session_ctx_t *session, struct timespec *stop_time_in)
Process any pending new events on a subscription. Should not be called unless SR_SUBSCR_NO_THREAD fla...
uint32_t sr_subscr_options_t
Options overriding default behavior of subscriptions, it is supposed to be a bitwise OR-ed value of a...
int sr_subscription_thread_suspend(sr_subscription_ctx_t *subscription)
Suspend the default handler thread of a subscription structure. Meaning it will stop handling any eve...
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...
int sr_process_events(sr_subscription_ctx_t *subscription, sr_session_ctx_t *session, time_t *stop_time_in)
Deprecated, use sr_subscription_process_events() instead.
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...
int sr_subscription_thread_resume(sr_subscription_ctx_t *subscription)
Resume the default handler thread of a subscription structure that was suspended previously.
void srplg_log(const char *plg_name, sr_log_level_t ll, const char *format,...)
void srp_log(sr_log_level_t ll, const char *format,...)
public sysrepo types header
struct sr_session_ctx_s sr_session_ctx_t
Sysrepo session on a connection.
Definition: sysrepo_types.h:92
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.
uint32_t sr_conn_options_t
Options overriding default connection handling by sr_connect call, it is supposed to be bitwise OR-ed...
sr_datastore_t
Datastores that sysrepo supports. To change which datastore a session operates on,...
A single, detailed error message. Used in sr_error_info_t.
Detailed sysrepo session error information.
Custom datastore implementation config for each datastore and notifications of a module.
Structure that contains value of an data element stored in the sysrepo datastore.