sysrepo  1.4.168
YANG datastore
sysrepo.h
Go to the documentation of this file.
1 
23 #ifndef _SYSREPO_H
24 #define _SYSREPO_H
25 
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include <stdlib.h>
29 #include <time.h>
30 #ifdef __APPLE__
31  #include <sys/types.h>
32 #endif
33 
34 #include <libyang/libyang.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
41 // Logging API
43 
52 typedef enum sr_error_e {
53  SR_ERR_OK = 0,
71 
78 const char *sr_strerror(int err_code);
79 
83 typedef enum {
84  SR_LL_NONE = 0,
88  SR_LL_DBG
90 
105 
112 
130 void sr_log_syslog(const char *app_name, sr_log_level_t log_level);
131 
138 
145 typedef void (*sr_log_cb)(sr_log_level_t level, const char *message);
146 
153 void sr_log_set_cb(sr_log_cb log_callback);
154 
158 // Connection / Session Management
160 
169 typedef struct sr_conn_ctx_s sr_conn_ctx_t;
170 
174 typedef struct sr_session_ctx_s sr_session_ctx_t;
175 
179 typedef enum sr_conn_flag_e {
188 
193 typedef uint32_t sr_conn_options_t;
194 
199 typedef enum sr_datastore_e {
203  SR_DS_OPERATIONAL = 3
205 
209 typedef struct sr_error_info_msg_s {
210  char *message;
211  char *xpath;
213 
217 typedef struct sr_error_info_s {
220  size_t err_count;
222 
236 
249 
256 int sr_connection_count(uint32_t *conn_count);
257 
265 const struct ly_ctx *sr_get_context(sr_conn_ctx_t *conn);
266 
274 typedef int (*sr_diff_check_cb)(sr_session_ctx_t *session, const struct lyd_node *diff);
275 
288 
302 int sr_session_start(sr_conn_ctx_t *conn, const sr_datastore_t datastore, sr_session_ctx_t **session);
303 
317 
330 
341 
349 
360 int sr_get_error(sr_session_ctx_t *session, const sr_error_info_t **error_info);
361 
376 int sr_set_error(sr_session_ctx_t *session, const char *path, const char *format, ...);
377 
385 
394 
403 void sr_session_set_nc_id(sr_session_ctx_t *session, uint32_t nc_sid);
404 
412 
421 
431 int sr_session_set_user(sr_session_ctx_t *session, const char *user);
432 
441 const char *sr_session_get_user(sr_session_ctx_t *session);
442 
451 
459 
463 // Schema Manipulation API
465 
479 const char *sr_get_repo_path(void);
480 
491 int sr_install_module(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs, const char **features,
492  int feat_count);
493 
505 int sr_install_module_data(sr_conn_ctx_t *conn, const char *module_name, const char *data, const char *data_path,
506  LYD_FORMAT format);
507 
517 int sr_remove_module(sr_conn_ctx_t *conn, const char *module_name);
518 
529 int sr_update_module(sr_conn_ctx_t *conn, const char *schema_path, const char *search_dirs);
530 
540 int sr_cancel_update_module(sr_conn_ctx_t *conn, const char *module_name);
541 
550 int sr_set_module_replay_support(sr_conn_ctx_t *conn, const char *module_name, int replay_support);
551 
564 int sr_set_module_access(sr_conn_ctx_t *conn, const char *module_name, const char *owner, const char *group, mode_t perm);
565 
578 int sr_get_module_access(sr_conn_ctx_t *conn, const char *module_name, char **owner, char **group, mode_t *perm);
579 
594 int sr_enable_module_feature(sr_conn_ctx_t *conn, const char *module_name, const char *feature_name);
595 
609 int sr_disable_module_feature(sr_conn_ctx_t *conn, const char *module_name, const char *feature_name);
610 
619 int sr_get_module_info(sr_conn_ctx_t *conn, struct lyd_node **sysrepo_data);
620 
624 // Data Retrieval API (get / get-config functionality)
626 
635 typedef enum sr_type_e {
636  /* special types that does not contain any data */
645  /* types containing some data */
663  SR_ANYDATA_T
665 
669 typedef union sr_data_u {
670  char *binary_val;
671  char *bits_val;
672  bool bool_val;
673  double decimal64_val;
677  char *enum_val;
680  int8_t int8_val;
681  int16_t int16_val;
682  int32_t int32_val;
683  int64_t int64_val;
684  char *string_val;
685  uint8_t uint8_val;
686  uint16_t uint16_val;
687  uint32_t uint32_val;
688  uint64_t uint64_val;
689  char *anyxml_val;
690  char *anydata_val;
692 
696 typedef struct sr_val_s {
698  char *xpath;
699 
702 
709  bool dflt;
710 
712  char *origin;
713 
716 
718 
722 typedef enum sr_get_oper_flag_e {
725  SR_OPER_NO_CONFIG = 2,
729  SR_OPER_WITH_ORIGIN = 16
732 
737 typedef uint32_t sr_get_oper_options_t;
738 
760 int sr_get_item(sr_session_ctx_t *session, const char *path, uint32_t timeout_ms, sr_val_t **value);
761 
779 int sr_get_items(sr_session_ctx_t *session, const char *xpath, uint32_t timeout_ms, const sr_get_oper_options_t opts,
780  sr_val_t **values, size_t *value_cnt);
781 
799 int sr_get_subtree(sr_session_ctx_t *session, const char *path, uint32_t timeout_ms, struct lyd_node **subtree);
800 
825 int sr_get_data(sr_session_ctx_t *session, const char *xpath, uint32_t max_depth, uint32_t timeout_ms,
826  const sr_get_oper_options_t opts, struct lyd_node **data);
827 
833 void sr_free_val(sr_val_t *value);
834 
842 void sr_free_values(sr_val_t *values, size_t count);
843 
847 // Data Manipulation API (edit-config functionality)
849 
858 typedef enum sr_edit_flag_e {
862  SR_EDIT_STRICT = 2,
865  SR_EDIT_ISOLATE = 4
870 
875 typedef uint32_t sr_edit_options_t;
876 
880 typedef enum sr_move_position_e {
884  SR_MOVE_LAST = 3
886 
909 int sr_set_item(sr_session_ctx_t *session, const char *path, const sr_val_t *value, const sr_edit_options_t opts);
910 
925 int sr_set_item_str(sr_session_ctx_t *session, const char *path, const char *value, const char *origin,
926  const sr_edit_options_t opts);
927 
941 int sr_delete_item(sr_session_ctx_t *session, const char *path, const sr_edit_options_t opts);
942 
967 int sr_move_item(sr_session_ctx_t *session, const char *path, const sr_move_position_t position, const char *list_keys,
968  const char *leaflist_value, const char *origin, const sr_edit_options_t opts);
969 
981 int sr_edit_batch(sr_session_ctx_t *session, const struct lyd_node *edit, const char *default_operation);
982 
994 int sr_validate(sr_session_ctx_t *session, const char *module_name, uint32_t timeout_ms);
995 
1013 int sr_apply_changes(sr_session_ctx_t *session, uint32_t timeout_ms, int wait);
1014 
1022 
1030 
1044 int sr_replace_config(sr_session_ctx_t *session, const char *module_name, struct lyd_node *src_config,
1045  uint32_t timeout_ms, int wait);
1046 
1065 int sr_copy_config(sr_session_ctx_t *session, const char *module_name, sr_datastore_t src_datastore, uint32_t timeout_ms,
1066  int wait);
1067 
1071 // Locking API
1073 
1094 int sr_lock(sr_session_ctx_t *session, const char *module_name);
1095 
1105 int sr_unlock(sr_session_ctx_t *session, const char *module_name);
1106 
1123 int sr_get_lock(sr_conn_ctx_t *conn, sr_datastore_t datastore, const char *module_name, int *is_locked, uint32_t *id,
1124  uint32_t *nc_id, time_t *timestamp);
1125 
1129 // Subscription API
1131 
1140 typedef enum sr_subscr_flag_e {
1152 
1159 
1166 
1173 
1180 
1188 
1196 
1202 
1208  SR_SUBSCR_OPER_MERGE = 128
1209 
1211 
1216 typedef struct sr_subscription_ctx_s sr_subscription_ctx_t;
1217 
1222 typedef uint32_t sr_subscr_options_t;
1223 
1234 int sr_get_event_pipe(sr_subscription_ctx_t *subscription, int *event_pipe);
1235 
1247 int sr_process_events(sr_subscription_ctx_t *subscription, sr_session_ctx_t *session, time_t *stop_time_in);
1248 
1262 
1266 // Change Subscriptions API
1268 
1282 typedef enum sr_event_e {
1283  SR_EV_UPDATE,
1286  SR_EV_CHANGE,
1290  SR_EV_DONE,
1293  SR_EV_ABORT,
1299  SR_EV_ENABLED,
1303  SR_EV_RPC
1305 
1309 typedef enum sr_change_oper_e {
1313  SR_OP_MOVED
1315 
1319 typedef struct sr_change_iter_s sr_change_iter_t;
1320 
1336 typedef int (*sr_module_change_cb)(sr_session_ctx_t *session, const char *module_name, const char *xpath,
1337  sr_event_t event, uint32_t request_id, void *private_data);
1338 
1357 int sr_module_change_subscribe(sr_session_ctx_t *session, const char *module_name, const char *xpath,
1358  sr_module_change_cb callback, void *private_data, uint32_t priority, sr_subscr_options_t opts,
1359  sr_subscription_ctx_t **subscription);
1360 
1376 int sr_get_changes_iter(sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter);
1377 
1393 int sr_dup_changes_iter(sr_session_ctx_t *session, const char *xpath, sr_change_iter_t **iter);
1394 
1414  sr_val_t **old_value, sr_val_t **new_value);
1415 
1439  const struct lyd_node **node, const char **prev_value, const char **prev_list, bool *prev_dflt);
1440 
1447 
1451 // RPC (Remote Procedure Calls) and Action API
1453 
1476 typedef int (*sr_rpc_cb)(sr_session_ctx_t *session, const char *xpath, const sr_val_t *input, const size_t input_cnt,
1477  sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data);
1478 
1493 typedef int (*sr_rpc_tree_cb)(sr_session_ctx_t *session, const char *op_path, const struct lyd_node *input,
1494  sr_event_t event, uint32_t request_id, struct lyd_node *output, void *private_data);
1495 
1512 int sr_rpc_subscribe(sr_session_ctx_t *session, const char *xpath, sr_rpc_cb callback, void *private_data,
1513  uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1514 
1531 int sr_rpc_subscribe_tree(sr_session_ctx_t *session, const char *xpath, sr_rpc_tree_cb callback,
1532  void *private_data, uint32_t priority, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1533 
1553 int sr_rpc_send(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt,
1554  uint32_t timeout_ms, sr_val_t **output, size_t *output_cnt);
1555 
1569 int sr_rpc_send_tree(sr_session_ctx_t *session, struct lyd_node *input, uint32_t timeout_ms, struct lyd_node **output);
1570 
1574 // Notifications API
1576 
1585 typedef enum sr_ev_notif_type_e {
1596 
1611 typedef void (*sr_event_notif_cb)(sr_session_ctx_t *session, const sr_ev_notif_type_t notif_type, const char *xpath,
1612  const sr_val_t *values, const size_t values_cnt, time_t timestamp, void *private_data);
1613 
1625 typedef void (*sr_event_notif_tree_cb)(sr_session_ctx_t *session, const sr_ev_notif_type_t notif_type,
1626  const struct lyd_node *notif, time_t timestamp, void *private_data);
1627 
1646 int sr_event_notif_subscribe(sr_session_ctx_t *session, const char *module_name, const char *xpath, time_t start_time,
1647  time_t stop_time, sr_event_notif_cb callback, void *private_data, sr_subscr_options_t opts,
1648  sr_subscription_ctx_t **subscription);
1649 
1668 int sr_event_notif_subscribe_tree(sr_session_ctx_t *session, const char *module_name, const char *xpath,
1669  time_t start_time, time_t stop_time, sr_event_notif_tree_cb callback, void *private_data,
1670  sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1671 
1688 int sr_event_notif_send(sr_session_ctx_t *session, const char *path, const sr_val_t *values, const size_t values_cnt);
1689 
1703 int sr_event_notif_send_tree(sr_session_ctx_t *session, struct lyd_node *notif);
1704 
1712 
1720 int sr_event_notif_sub_suspend(sr_subscription_ctx_t *subscription, uint32_t sub_id);
1721 
1730 int sr_event_notif_sub_resume(sr_subscription_ctx_t *subscription, uint32_t sub_id);
1731 
1735 // Operational Data API
1737 
1767 typedef int (*sr_oper_get_items_cb)(sr_session_ctx_t *session, const char *module_name, const char *path,
1768  const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data);
1769 
1790 int sr_oper_get_items_subscribe(sr_session_ctx_t *session, const char *module_name, const char *path,
1791  sr_oper_get_items_cb callback, void *private_data, sr_subscr_options_t opts, sr_subscription_ctx_t **subscription);
1792 
1796 // Plugin API
1798 
1807 #define SRP_INIT_CB "sr_plugin_init_cb"
1808 
1812 #define SRP_CLEANUP_CB "sr_plugin_cleanup_cb"
1813 
1825 typedef int (*srp_init_cb_t)(sr_session_ctx_t *session, void **private_data);
1826 
1835 typedef void (*srp_cleanup_cb_t)(sr_session_ctx_t *session, void *private_data);
1836 
1842 #define SRP_LOG_ERR(...) srp_log(SR_LL_ERR, __VA_ARGS__)
1843 
1849 #define SRP_LOG_WRN(...) srp_log(SR_LL_WRN, __VA_ARGS__)
1850 
1856 #define SRP_LOG_INF(...) srp_log(SR_LL_INF, __VA_ARGS__)
1857 
1863 #define SRP_LOG_DBG(...) srp_log(SR_LL_DBG, __VA_ARGS__)
1864 
1870 #define SRP_LOG_ERRMSG(msg) srp_log(SR_LL_ERR, msg)
1871 
1877 #define SRP_LOG_WRNMSG(msg) srp_log(SR_LL_WRN, msg)
1878 
1884 #define SRP_LOG_INFMSG(msg) srp_log(SR_LL_INF, msg)
1885 
1891 #define SRP_LOG_DBGMSG(msg) srp_log(SR_LL_DBG, msg)
1892 
1903 void srp_log(sr_log_level_t ll, const char *format, ...);
1904 
1905 #ifdef __cplusplus
1906 }
1907 #endif
1908 
1909 #endif /* _SYSREPO_H */
enum sr_event_e sr_event_t
Type of the event that has occurred (passed to application callbacks).
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_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_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,...
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....
struct sr_change_iter_s sr_change_iter_t
Iterator used for retrieval of a changeset using sr_get_changes_iter call.
Definition: sysrepo.h:1319
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...
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.
Definition: sysrepo.h:1336
sr_event_e
Type of the event that has occurred (passed to application callbacks).
Definition: sysrepo.h:1282
sr_change_oper_e
Type of the operation made on an item, used by changeset retrieval in sr_get_change_next.
Definition: sysrepo.h:1309
void sr_free_change_iter(sr_change_iter_t *iter)
Frees sr_change_iter_t iterator and all memory allocated within it.
@ SR_EV_RPC
Definition: sysrepo.h:1303
@ SR_EV_ENABLED
Definition: sysrepo.h:1299
@ SR_EV_UPDATE
Definition: sysrepo.h:1283
@ SR_EV_DONE
Definition: sysrepo.h:1290
@ SR_EV_CHANGE
Definition: sysrepo.h:1286
@ SR_EV_ABORT
Definition: sysrepo.h:1293
@ SR_OP_CREATED
Definition: sysrepo.h:1310
@ SR_OP_MOVED
Definition: sysrepo.h:1313
@ SR_OP_MODIFIED
Definition: sysrepo.h:1311
@ SR_OP_DELETED
Definition: sysrepo.h:1312
sr_error_t err_code
Definition: sysrepo.h:218
sr_error_info_msg_t * err
Definition: sysrepo.h:219
size_t err_count
Definition: sysrepo.h:220
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...
struct sr_session_ctx_s sr_session_ctx_t
Sysrepo session on a connection.
Definition: sysrepo.h:174
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.
Definition: sysrepo.h:274
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_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 ...
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_disconnect(sr_conn_ctx_t *conn)
Disconnect from the sysrepo datastore.
struct sr_error_info_msg_s sr_error_info_msg_t
A single, detailed error message. Used in sr_error_info_s.
uint32_t sr_conn_options_t
Options overriding default connection handling by sr_connect call, it is supposed to be bitwise OR-ed...
Definition: sysrepo.h:193
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...
struct sr_error_info_s sr_error_info_t
Detailed sysrepo session error information.
int sr_session_stop(sr_session_ctx_t *session)
Stop current session and releases resources tied to the session.
enum sr_conn_flag_e sr_conn_flag_t
Flags used to override default connection handling by sr_connect call.
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...
enum sr_datastore_e sr_datastore_t
Datastores that sysrepo supports. To change which datastore a session operates on,...
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_event_user(sr_session_ctx_t *session)
Get the effective user of the event originator sysrepo session. Should be used on the implicit sessio...
const char * sr_session_get_user(sr_session_ctx_t *session)
Get the effective user of a session.
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...
sr_datastore_e
Datastores that sysrepo supports. To change which datastore a session operates on,...
Definition: sysrepo.h:199
int sr_connection_count(uint32_t *conn_count)
Learn the current global number of alive connections.
sr_conn_flag_e
Flags used to override default connection handling by sr_connect call.
Definition: sysrepo.h:179
uint32_t sr_session_get_nc_id(sr_session_ctx_t *session)
Learn NETCONF session ID set for a sysrepo session.
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_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.h:169
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...
@ SR_DS_RUNNING
Definition: sysrepo.h:201
@ SR_DS_CANDIDATE
Definition: sysrepo.h:202
@ SR_DS_OPERATIONAL
Definition: sysrepo.h:203
@ SR_DS_STARTUP
Definition: sysrepo.h:200
@ SR_CONN_NO_SCHED_CHANGES
Definition: sysrepo.h:183
@ SR_CONN_DEFAULT
Definition: sysrepo.h:180
@ SR_CONN_CACHE_RUNNING
Definition: sysrepo.h:181
@ SR_CONN_ERR_ON_SCHED_FAIL
Definition: sysrepo.h:185
A single, detailed error message. Used in sr_error_info_s.
Definition: sysrepo.h:209
Detailed sysrepo session error information.
Definition: sysrepo.h:217
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_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_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 ...
sr_move_position_e
Options for specifying move direction of sr_move_item call.
Definition: sysrepo.h:880
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 selete the nodes matching the specified xpath. These changes are applied only after callin...
enum sr_edit_flag_e sr_edit_flag_t
Flags used to override default behavior of data manipulation calls.
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...
Definition: sysrepo.h:875
sr_edit_flag_e
Flags used to override default behavior of data manipulation calls.
Definition: sysrepo.h:858
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....
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...
enum sr_move_position_e sr_move_position_t
Options for specifying move direction of sr_move_item call.
@ SR_MOVE_LAST
Definition: sysrepo.h:884
@ SR_MOVE_FIRST
Definition: sysrepo.h:883
@ SR_MOVE_AFTER
Definition: sysrepo.h:882
@ SR_MOVE_BEFORE
Definition: sysrepo.h:881
@ SR_EDIT_DEFAULT
Definition: sysrepo.h:859
@ SR_EDIT_STRICT
Definition: sysrepo.h:862
@ SR_EDIT_ISOLATE
Definition: sysrepo.h:865
@ SR_EDIT_NON_RECURSIVE
Definition: sysrepo.h:860
char * origin
Definition: sysrepo.h:712
char * string_val
Definition: sysrepo.h:684
char * enum_val
Definition: sysrepo.h:677
bool bool_val
Definition: sysrepo.h:672
char * binary_val
Definition: sysrepo.h:670
sr_data_t data
Definition: sysrepo.h:715
uint32_t uint32_val
Definition: sysrepo.h:687
int32_t int32_val
Definition: sysrepo.h:682
char * instanceid_val
Definition: sysrepo.h:679
int64_t int64_val
Definition: sysrepo.h:683
uint8_t uint8_val
Definition: sysrepo.h:685
uint64_t uint64_val
Definition: sysrepo.h:688
sr_type_t type
Definition: sysrepo.h:701
bool dflt
Definition: sysrepo.h:709
int8_t int8_val
Definition: sysrepo.h:680
int16_t int16_val
Definition: sysrepo.h:681
char * anyxml_val
Definition: sysrepo.h:689
char * identityref_val
Definition: sysrepo.h:678
double decimal64_val
Definition: sysrepo.h:673
uint16_t uint16_val
Definition: sysrepo.h:686
char * anydata_val
Definition: sysrepo.h:690
char * xpath
Definition: sysrepo.h:698
char * bits_val
Definition: sysrepo.h:671
struct sr_val_s sr_val_t
Structure that contains value of an data element stored in the sysrepo datastore.
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...
Definition: sysrepo.h:737
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).
enum sr_type_e sr_type_t
Possible types of a data element stored in the sysrepo datastore.
union sr_data_u sr_data_t
Data of an element (if applicable), properly set according to the type.
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.
sr_type_e
Possible types of a data element stored in the sysrepo datastore.
Definition: sysrepo.h:635
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.
sr_get_oper_flag_e
Flags used to override default data get behaviour on SR_DS_OPERATIONAL by sr_get_data call.
Definition: sysrepo.h:722
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...
@ SR_INT64_T
Definition: sysrepo.h:656
@ SR_UNKNOWN_T
Definition: sysrepo.h:637
@ SR_LEAF_EMPTY_T
Definition: sysrepo.h:642
@ SR_INT8_T
Definition: sysrepo.h:653
@ SR_BINARY_T
Definition: sysrepo.h:646
@ SR_CONTAINER_T
Definition: sysrepo.h:640
@ SR_INT32_T
Definition: sysrepo.h:655
@ SR_INT16_T
Definition: sysrepo.h:654
@ SR_ANYDATA_T
Definition: sysrepo.h:663
@ SR_UINT8_T
Definition: sysrepo.h:658
@ SR_STRING_T
Definition: sysrepo.h:657
@ SR_UINT32_T
Definition: sysrepo.h:660
@ SR_IDENTITYREF_T
Definition: sysrepo.h:651
@ SR_BITS_T
Definition: sysrepo.h:647
@ SR_ENUM_T
Definition: sysrepo.h:650
@ SR_ANYXML_T
Definition: sysrepo.h:662
@ SR_NOTIFICATION_T
Definition: sysrepo.h:643
@ SR_CONTAINER_PRESENCE_T
Definition: sysrepo.h:641
@ SR_UINT64_T
Definition: sysrepo.h:661
@ SR_LIST_T
Definition: sysrepo.h:639
@ SR_INSTANCEID_T
Definition: sysrepo.h:652
@ SR_UINT16_T
Definition: sysrepo.h:659
@ SR_BOOL_T
Definition: sysrepo.h:648
@ SR_DECIMAL64_T
Definition: sysrepo.h:649
@ SR_OPER_NO_STATE
Definition: sysrepo.h:724
@ SR_OPER_NO_STORED
Definition: sysrepo.h:728
@ SR_OPER_NO_CONFIG
Definition: sysrepo.h:725
@ SR_OPER_DEFAULT
Definition: sysrepo.h:723
@ SR_OPER_NO_SUBS
Definition: sysrepo.h:727
@ SR_OPER_WITH_ORIGIN
Definition: sysrepo.h:729
Structure that contains value of an data element stored in the sysrepo datastore.
Definition: sysrepo.h:696
Data of an element (if applicable), properly set according to the type.
Definition: sysrepo.h:669
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.
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_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.h:145
enum sr_error_e sr_error_t
Sysrepo error codes.
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.h:83
sr_error_e
Sysrepo error codes.
Definition: sysrepo.h:52
const char * sr_strerror(int err_code)
Returns the error message corresponding to the error code.
@ SR_LL_ERR
Definition: sysrepo.h:85
@ SR_LL_INF
Definition: sysrepo.h:87
@ SR_LL_NONE
Definition: sysrepo.h:84
@ SR_LL_WRN
Definition: sysrepo.h:86
@ SR_LL_DBG
Definition: sysrepo.h:88
@ SR_ERR_LY
Definition: sysrepo.h:55
@ SR_ERR_NOT_FOUND
Definition: sysrepo.h:58
@ SR_ERR_NOMEM
Definition: sysrepo.h:57
@ SR_ERR_UNSUPPORTED
Definition: sysrepo.h:61
@ SR_ERR_LOCKED
Definition: sysrepo.h:65
@ SR_ERR_OPERATION_FAILED
Definition: sysrepo.h:63
@ SR_ERR_EXISTS
Definition: sysrepo.h:59
@ SR_ERR_VALIDATION_FAILED
Definition: sysrepo.h:62
@ SR_ERR_OK
Definition: sysrepo.h:53
@ SR_ERR_CALLBACK_SHELVE
Definition: sysrepo.h:68
@ SR_ERR_CALLBACK_FAILED
Definition: sysrepo.h:67
@ SR_ERR_INVAL_ARG
Definition: sysrepo.h:54
@ SR_ERR_INTERNAL
Definition: sysrepo.h:60
@ SR_ERR_SYS
Definition: sysrepo.h:56
@ SR_ERR_UNAUTHORIZED
Definition: sysrepo.h:64
@ SR_ERR_TIME_OUT
Definition: sysrepo.h:66
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.
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.
Definition: sysrepo.h:1625
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.
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_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_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...
Definition: sysrepo.h:1611
sr_ev_notif_type_e
Type of the notification passed to the sr_event_notif_cb and sr_event_notif_tree_cb callbacks.
Definition: sysrepo.h:1585
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...
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.
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_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_EV_NOTIF_SUSPENDED
Definition: sysrepo.h:1592
@ SR_EV_NOTIF_REALTIME
Definition: sysrepo.h:1586
@ SR_EV_NOTIF_STOP
Definition: sysrepo.h:1590
@ SR_EV_NOTIF_RESUMED
Definition: sysrepo.h:1593
@ SR_EV_NOTIF_REPLAY_COMPLETE
Definition: sysrepo.h:1588
@ SR_EV_NOTIF_REPLAY
Definition: sysrepo.h:1587
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, 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...
Definition: sysrepo.h:1767
int(* srp_init_cb_t)(sr_session_ctx_t *session, void **private_data)
Sysrepo plugin initialization callback.
Definition: sysrepo.h:1825
void(* srp_cleanup_cb_t)(sr_session_ctx_t *session, void *private_data)
Sysrepo plugin cleanup callback.
Definition: sysrepo.h:1835
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_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.
Definition: sysrepo.h:1493
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, 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.
Definition: sysrepo.h:1476
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_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_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_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_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!
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_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...
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_cancel_update_module(sr_conn_ctx_t *conn, const char *module_name)
Cancel scheduled update of a module.
int sr_unsubscribe(sr_subscription_ctx_t *subscription)
Unsubscribes from a subscription acquired by any of sr_*_subscribe calls and releases all subscriptio...
uint32_t sr_subscr_options_t
Options overriding default behavior of subscriptions, it is supposed to be a bitwise OR-ed value of a...
Definition: sysrepo.h:1222
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...
Definition: sysrepo.h:1216
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...
sr_subscr_flag_e
Flags used to override default handling of subscriptions.
Definition: sysrepo.h:1140
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...
enum sr_subscr_flag_e sr_subscr_flag_t
Flags used to override default handling of subscriptions.
@ SR_SUBSCR_DONE_ONLY
The subscriber does not support verification of the changes and wants to be notified only after the c...
Definition: sysrepo.h:1179
@ SR_SUBSCR_CTX_REUSE
This option enables the application to re-use an already existing subscription context previously ret...
Definition: sysrepo.h:1158
@ SR_SUBSCR_UNLOCKED
The options should not be used as it is deprecated and ignored. Callbacks can always modify other sub...
Definition: sysrepo.h:1201
@ SR_SUBSCR_PASSIVE
The subscriber is not the "owner" of the subscribed data tree, just a passive watcher for changes....
Definition: sysrepo.h:1172
@ SR_SUBSCR_DEFAULT
Default behavior of the subscription. In case of sr_module_change_subscribe call it means that:
Definition: sysrepo.h:1151
@ SR_SUBSCR_UPDATE
The subscriber will be called before any other subscribers for the particular module with an addition...
Definition: sysrepo.h:1195
@ SR_SUBSCR_NO_THREAD
There will be no thread created for handling this subscription meaning no event will be processed!...
Definition: sysrepo.h:1165
@ SR_SUBSCR_ENABLED
The subscriber wants to be notified about the current configuration at the moment of subscribing....
Definition: sysrepo.h:1187
@ SR_SUBSCR_OPER_MERGE
Instead of removing any previous existing matching data before getting them from an operational subsc...
Definition: sysrepo.h:1208
void srp_log(sr_log_level_t ll, const char *format,...)