sysrepo  2.11.7
YANG-based system repository for all-around configuration management.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sysrepo_types.h File Reference

public sysrepo types header More...

#include <fcntl.h>
#include <inttypes.h>
#include <stddef.h>
#include <sys/stat.h>
Include dependency graph for sysrepo_types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sr_data_t
 Structure that safely wraps libyang data and prevents unexpected context changes. More...
 
struct  sr_error_info_err_t
 A single, detailed error message. Used in sr_error_info_t. More...
 
struct  sr_error_info_t
 Detailed sysrepo session error information. More...
 
struct  sr_install_mod_t
 Information about a module to be installed. More...
 
union  sr_install_mod_t.__unnamed__
 
struct  sr_module_ds_t
 Custom datastore implementation config for each datastore and notifications of a module. More...
 
union  sr_val_data_t
 Data of an element (if applicable), properly set according to the type. More...
 
struct  sr_val_t
 Structure that contains value of an data element stored in the sysrepo datastore. More...
 

Typedefs

typedef 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. More...
 
typedef 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. More...
 
typedef 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 as libyang subtrees. More...
 
typedef int(* srp_init_cb_t )(sr_session_ctx_t *session, void **private_data)
 Sysrepo plugin initialization callback. More...
 
typedef void(* srp_cleanup_cb_t )(sr_session_ctx_t *session, void *private_data)
 Sysrepo plugin cleanup callback. More...
 
enum  sr_error_t {
  SR_ERR_OK = 0, SR_ERR_INVAL_ARG, SR_ERR_LY, SR_ERR_SYS,
  SR_ERR_NO_MEMORY, SR_ERR_NOT_FOUND, SR_ERR_EXISTS, SR_ERR_INTERNAL,
  SR_ERR_UNSUPPORTED, SR_ERR_VALIDATION_FAILED, SR_ERR_OPERATION_FAILED, SR_ERR_UNAUTHORIZED,
  SR_ERR_LOCKED, SR_ERR_TIME_OUT, SR_ERR_CALLBACK_FAILED, SR_ERR_CALLBACK_SHELVE
}
 Sysrepo error codes. More...
 
enum  sr_log_level_t {
  SR_LL_NONE = 0, SR_LL_ERR, SR_LL_WRN, SR_LL_INF,
  SR_LL_DBG
}
 Log levels used to determine if message of certain severity should be printed. More...
 
typedef 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. More...
 
#define SR_DS_COUNT   4
 Count of all the standard (modifiable) datastore types. More...
 
#define SR_DS_READ_COUNT   5
 Count of all the readable datastore types. More...
 
#define SR_MOD_DS_NOTIF   5
 Special notification datastore of a module. More...
 
#define SR_MOD_DS_PLUGIN_COUNT   6
 Count of all module plugin types (datastores and notifications). More...
 
enum  sr_conn_flag_t { SR_CONN_DEFAULT = 0x0, SR_CONN_CACHE_RUNNING = 0x1, SR_CONN_CTX_SET_PRIV_PARSED = 0x2 }
 Flags used to override default connection handling by sr_connect call. More...
 
enum  sr_datastore_t {
  SR_DS_STARTUP = 0, SR_DS_RUNNING = 1, SR_DS_CANDIDATE = 2, SR_DS_OPERATIONAL = 3,
  SR_DS_FACTORY_DEFAULT = 4
}
 Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds. More...
 
typedef struct sr_conn_ctx_s sr_conn_ctx_t
 Sysrepo connection. More...
 
typedef uint32_t sr_cid_t
 Connection ID. More...
 
typedef struct sr_session_ctx_s sr_session_ctx_t
 Sysrepo session on a connection. More...
 
typedef uint32_t sr_conn_options_t
 Options overriding default connection handling by sr_connect call, it is supposed to be bitwise OR-ed value of any sr_conn_flag_t flags. More...
 
#define SR_OPER_MASK   0xFFFF
 
enum  sr_val_type_t {
  SR_UNKNOWN_T, SR_LIST_T, SR_CONTAINER_T, SR_CONTAINER_PRESENCE_T,
  SR_LEAF_EMPTY_T, SR_NOTIFICATION_T, SR_BINARY_T, SR_BITS_T,
  SR_BOOL_T, SR_DECIMAL64_T, SR_ENUM_T, SR_IDENTITYREF_T,
  SR_INSTANCEID_T, SR_INT8_T, SR_INT16_T, SR_INT32_T,
  SR_INT64_T, SR_STRING_T, SR_UINT8_T, SR_UINT16_T,
  SR_UINT32_T, SR_UINT64_T, SR_ANYXML_T, SR_ANYDATA_T
}
 Possible types of a data element stored in the sysrepo datastore. More...
 
enum  sr_get_oper_flag_t {
  SR_OPER_DEFAULT = 0x00, SR_OPER_NO_STATE = 0x01, SR_OPER_NO_CONFIG = 0x02, SR_OPER_NO_SUBS = 0x04,
  SR_OPER_NO_STORED = 0x08, SR_OPER_WITH_ORIGIN = 0x10, SR_OPER_NO_POLL_CACHED = 0x20, SR_OPER_NO_RUN_CACHED = 0x40
}
 Flags used to override default data get behaviour on SR_DS_OPERATIONAL. More...
 
enum  sr_get_flag_t { SR_GET_NO_FILTER = 0x010000 }
 Flags used to override default data get behavior. More...
 
typedef uint32_t sr_get_options_t
 Options overriding default get handling by sr_get_data call, it is supposed to be a bitmask sr_get_oper_flag_t and sr_get_flag_t flags. More...
 
enum  sr_edit_flag_t { SR_EDIT_DEFAULT = 0x0, SR_EDIT_NON_RECURSIVE = 0x1, SR_EDIT_STRICT = 0x2, SR_EDIT_ISOLATE = 0x4 }
 Flags used to override default behavior of data manipulation calls. More...
 
enum  sr_move_position_t { SR_MOVE_BEFORE = 0, SR_MOVE_AFTER = 1, SR_MOVE_FIRST = 2, SR_MOVE_LAST = 3 }
 Options for specifying move direction of sr_move_item call. More...
 
typedef uint32_t sr_edit_options_t
 Options overriding default behavior of data manipulation calls, it is supposed to be bitwise OR-ed value of any sr_edit_flag_t flags. More...
 
enum  sr_subscr_flag_t {
  SR_SUBSCR_DEFAULT = 0x00, SR_SUBSCR_NO_THREAD = 0x01, SR_SUBSCR_PASSIVE = 0x02, SR_SUBSCR_DONE_ONLY = 0x04,
  SR_SUBSCR_ENABLED = 0x08, SR_SUBSCR_UPDATE = 0x10, SR_SUBSCR_OPER_MERGE = 0x20, SR_SUBSCR_THREAD_SUSPEND = 0x40,
  SR_SUBSCR_OPER_POLL_DIFF = 0x80, SR_SUBSCR_FILTER_ORIG = 0x100
}
 Flags used to override default handling of subscriptions. More...
 
typedef 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 caller using sr_unsubscribe call. More...
 
typedef uint32_t sr_subscr_options_t
 Options overriding default behavior of subscriptions, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags. More...
 
enum  sr_event_t {
  SR_EV_UPDATE, SR_EV_CHANGE, SR_EV_DONE, SR_EV_ABORT,
  SR_EV_ENABLED, SR_EV_RPC
}
 Type of the event that has occurred (passed to application callbacks). More...
 
enum  sr_change_oper_t { SR_OP_CREATED, SR_OP_MODIFIED, SR_OP_DELETED, SR_OP_MOVED }
 Type of the operation made on an item, used by changeset retrieval in sr_get_change_next. More...
 
typedef struct sr_change_iter_s sr_change_iter_t
 Iterator used for retrieval of a changeset using sr_get_changes_iter call. More...
 
typedef 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. More...
 
enum  sr_ev_notif_type_t {
  SR_EV_NOTIF_REALTIME, SR_EV_NOTIF_REPLAY, SR_EV_NOTIF_REPLAY_COMPLETE, SR_EV_NOTIF_TERMINATED,
  SR_EV_NOTIF_MODIFIED, SR_EV_NOTIF_SUSPENDED, SR_EV_NOTIF_RESUMED, SR_EV_NOTIF_STOP_TIME
}
 Type of the notification passed to the sr_event_notif_cb and sr_event_notif_tree_cb callbacks. More...
 
typedef 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. More...
 
typedef 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. More...
 

Detailed Description

public sysrepo types header

Author
Michal Vasko mvask.nosp@m.o@ce.nosp@m.snet..nosp@m.cz

This source code is licensed under BSD 3-Clause License (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at

https://opensource.org/licenses/BSD-3-Clause

Definition in file sysrepo_types.h.


Data Structure Documentation

struct sr_error_info_err_t

A single, detailed error message. Used in sr_error_info_t.

Definition at line 159 of file sysrepo_types.h.

Data Fields
sr_error_t err_code

Error code.

void * error_data

Opaque error data specific for error_format.

char * error_format

Error format identifier.

char * message

Error message.

struct sr_error_info_t

Detailed sysrepo session error information.

Definition at line 169 of file sysrepo_types.h.

Data Fields
sr_error_info_err_t * err

Array of all generated errors.

uint32_t err_count

Error count.

struct sr_install_mod_t

Information about a module to be installed.

Definition at line 177 of file sysrepo_types.h.

Data Fields
union sr_install_mod_t __unnamed__
const char ** features

Optional array of features to enable ('*' enables all) terminated by NULL.

const char * group

Optional module data group, process group by default.

sr_module_ds_t module_ds

Optional datastore implementation plugin names for each datastore. If NULL is used for SR_DS_RUNNING, it means it is disabled (mirrors SR_DS_STARTUP).

const char * owner

Optional module data owner, process user by default.

mode_t perm

Optional module data permissions.

union sr_install_mod_t.__unnamed__

Definition at line 178 of file sysrepo_types.h.

Data Fields
const char * schema_path

Path to the schema file.

const char * schema_yang

YANG data of the schema.

struct sr_module_ds_t

Custom datastore implementation config for each datastore and notifications of a module.

Definition at line 152 of file sysrepo_types.h.

Data Fields
const char * plugin_name[6]

Datastore plugin name.

union sr_val_data_t

Data of an element (if applicable), properly set according to the type.

Definition at line 245 of file sysrepo_types.h.

Data Fields
char * anydata_val

Unknown set of nodes, encoded in XML (RFC 7950 sec 7.10)

char * anyxml_val

Unknown chunk of XML (RFC 7950 sec 7.10)

char * binary_val

Base64-encoded binary data (RFC 7950 sec 9.8)

char * bits_val

A set of bits or flags (RFC 7950 sec 9.7)

int bool_val

A boolean value (RFC 7950 sec 9.5)

double decimal64_val

64-bit signed decimal number (RFC 7950 sec 9.3) Be careful with this value! It is not always possible and the value can change when converting between a double and YANG decimal64. Because of that you may see some unexpected behavior setting or reading this value. To avoid these problems, use *_tree() API variants instead.

char * enum_val

A string from enumerated strings list (RFC 7950 sec 9.6)

char * identityref_val

A reference to an abstract identity (RFC 7950 sec 9.10)

char * instanceid_val

References a data tree node (RFC 7950 sec 9.13)

int16_t int16_val

16-bit signed integer (RFC 7950 sec 9.2)

int32_t int32_val

32-bit signed integer (RFC 7950 sec 9.2)

int64_t int64_val

64-bit signed integer (RFC 7950 sec 9.2)

int8_t int8_val

8-bit signed integer (RFC 7950 sec 9.2)

char * string_val

Human-readable string (RFC 7950 sec 9.4)

uint16_t uint16_val

16-bit unsigned integer (RFC 7950 sec 9.2)

uint32_t uint32_val

32-bit unsigned integer (RFC 7950 sec 9.2)

uint64_t uint64_val

64-bit unsigned integer (RFC 7950 sec 9.2)

uint8_t uint8_val

8-bit unsigned integer (RFC 7950 sec 9.2)

struct sr_val_t

Structure that contains value of an data element stored in the sysrepo datastore.

Definition at line 272 of file sysrepo_types.h.

Data Fields
sr_val_data_t data

Data of an element (if applicable), properly set according to the type.

int dflt

Flag for node with default value (applicable only for leaves). It is set to TRUE only if the value was implicitly set by the datastore as per module schema. Explicitly set/modified data element (through the sysrepo API) always has this flag unset regardless of the entered value.

char * origin

Origin of the value.

sr_val_type_t type

Type of an element.

char * xpath

XPath (or rather path) identifier of the data element.

Macro Definition Documentation

#define SR_DS_COUNT   4

Count of all the standard (modifiable) datastore types.

Definition at line 132 of file sysrepo_types.h.

#define SR_DS_READ_COUNT   5

Count of all the readable datastore types.

Definition at line 137 of file sysrepo_types.h.

#define SR_MOD_DS_NOTIF   5

Special notification datastore of a module.

Definition at line 142 of file sysrepo_types.h.

#define SR_MOD_DS_PLUGIN_COUNT   6

Count of all module plugin types (datastores and notifications).

Definition at line 147 of file sysrepo_types.h.

#define SR_OPER_MASK   0xFFFF

Mask for all get oper data flags.

Definition at line 312 of file sysrepo_types.h.

Typedef Documentation

typedef uint32_t sr_cid_t

Connection ID.

Definition at line 94 of file sysrepo_types.h.

typedef uint32_t sr_conn_options_t

Options overriding default connection handling by sr_connect call, it is supposed to be bitwise OR-ed value of any sr_conn_flag_t flags.

Definition at line 115 of file sysrepo_types.h.

typedef uint32_t sr_get_options_t

Options overriding default get handling by sr_get_data call, it is supposed to be a bitmask sr_get_oper_flag_t and sr_get_flag_t flags.

Definition at line 327 of file sysrepo_types.h.

typedef struct sr_session_ctx_s sr_session_ctx_t

Sysrepo session on a connection.

Definition at line 99 of file sysrepo_types.h.

typedef void(* srp_cleanup_cb_t)(sr_session_ctx_t *session, void *private_data)

Sysrepo plugin cleanup callback.

Parameters
[in]sessionSysrepo session that can be used for any API calls needed for plugin cleanup (mainly for unsubscribing of subscriptions initialized in srp_init_cb_t).
[in]private_dataPrivate context as passed in srp_init_cb_t.

Definition at line 714 of file sysrepo_types.h.

typedef int(* srp_init_cb_t)(sr_session_ctx_t *session, void **private_data)

Sysrepo plugin initialization callback.

Parameters
[in]sessionSysrepo session that can be used for any API calls needed for plugin initialization (mainly for reading of startup configuration and subscribing for notifications).
[out]private_dataPrivate context (opaque to sysrepo) that will be passed to srp_cleanup_cb_t when plugin cleanup is requested.
Returns
Error code (SR_ERR_OK on success).

Definition at line 704 of file sysrepo_types.h.

Enumeration Type Documentation

Flags used to override default connection handling by sr_connect call.

Enumerator
SR_CONN_DEFAULT 

No special behaviour.

SR_CONN_CACHE_RUNNING 

Always cache running datastore data which makes mainly repeated retrieval of data much faster. Affects all sessions created on this connection.

SR_CONN_CTX_SET_PRIV_PARSED 

Use LY_CTX_SET_PRIV_PARSED option for the connection libyang context.

Definition at line 104 of file sysrepo_types.h.

Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds.

Enumerator
SR_DS_STARTUP 

Contains configuration data that will be loaded when a device starts.

SR_DS_RUNNING 

Contains current configuration data.

SR_DS_CANDIDATE 

Contains prepared configuration data that do not affect actual configuration.

SR_DS_OPERATIONAL 

Contains currently used configuration (see operational datastore).

SR_DS_FACTORY_DEFAULT 

Contains factory-default configuration to be used when factory-reset RPC is executed.

Definition at line 121 of file sysrepo_types.h.

Flags used to override default data get behavior.

Enumerator
SR_GET_NO_FILTER 

Do not apply the filter and return the whole "base" data which the filter would normally be applied on. The filter is used only when deciding what data to retrieve from subscribers and similar optimization cases.

Definition at line 317 of file sysrepo_types.h.

Flags used to override default data get behaviour on SR_DS_OPERATIONAL.

Enumerator
SR_OPER_DEFAULT 

No special behaviour.

SR_OPER_NO_STATE 

Return only configuration data.

SR_OPER_NO_CONFIG 

Return only state data. If there are some state subtrees with configuration parents, these are also returned (with keys if lists).

SR_OPER_NO_SUBS 

Return only stored operational data (push), do not call subscriber callbacks (pull).

SR_OPER_NO_STORED 

Do not merge with stored operational data (push).

SR_OPER_WITH_ORIGIN 

Return data with their origin attributes. Nodes without one inherit the origin from parents.

SR_OPER_NO_POLL_CACHED 

Do not use cached oper data from operational poll subscriptions even if available.

SR_OPER_NO_RUN_CACHED 

Do not use connection running datastore cache data even if the connection supports it, may prevent some dead locks.

Definition at line 297 of file sysrepo_types.h.

Possible types of a data element stored in the sysrepo datastore.

Enumerator
SR_UNKNOWN_T 

Element unknown to sysrepo (unsupported element).

SR_LIST_T 

List instance. (RFC 7950 sec 7.8)

SR_CONTAINER_T 

Non-presence container. (RFC 7950 sec 7.5)

SR_CONTAINER_PRESENCE_T 

Presence container. (RFC 7950 sec 7.5.1)

SR_LEAF_EMPTY_T 

A leaf that does not hold any value (RFC 7950 sec 9.11)

SR_NOTIFICATION_T 

Notification instance (RFC 7095 sec 7.16)

SR_BINARY_T 

Base64-encoded binary data (RFC 7950 sec 9.8)

SR_BITS_T 

A set of bits or flags (RFC 7950 sec 9.7)

SR_BOOL_T 

A boolean value (RFC 7950 sec 9.5)

SR_DECIMAL64_T 

64-bit signed decimal number (RFC 7950 sec 9.3)

SR_ENUM_T 

A string from enumerated strings list (RFC 7950 sec 9.6)

SR_IDENTITYREF_T 

A reference to an abstract identity (RFC 7950 sec 9.10)

SR_INSTANCEID_T 

References a data tree node (RFC 7950 sec 9.13)

SR_INT8_T 

8-bit signed integer (RFC 7950 sec 9.2)

SR_INT16_T 

16-bit signed integer (RFC 7950 sec 9.2)

SR_INT32_T 

32-bit signed integer (RFC 7950 sec 9.2)

SR_INT64_T 

64-bit signed integer (RFC 7950 sec 9.2)

SR_STRING_T 

Human-readable string (RFC 7950 sec 9.4)

SR_UINT8_T 

8-bit unsigned integer (RFC 7950 sec 9.2)

SR_UINT16_T 

16-bit unsigned integer (RFC 7950 sec 9.2)

SR_UINT32_T 

32-bit unsigned integer (RFC 7950 sec 9.2)

SR_UINT64_T 

64-bit unsigned integer (RFC 7950 sec 9.2)

SR_ANYXML_T 

Unknown chunk of XML (RFC 7950 sec 7.10)

SR_ANYDATA_T 

Unknown set of nodes, encoded in XML (RFC 7950 sec 7.10)

Definition at line 211 of file sysrepo_types.h.