sysrepo  3.3.4
YANG-based system repository for all-around configuration management.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
RPC/Action Subscription API

Functions

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. More...
 
int sr_rpc_send_tree (sr_session_ctx_t *session, struct lyd_node *input, uint32_t timeout_ms, sr_data_t **output)
 Send an RPC/action and wait for the result. Data are represented as libyang subtrees. More...
 
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. More...
 
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. More...
 
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...
 

Detailed Description

Typedef Documentation

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.

Note
Callback must not modify any RPC/action subscriptions, it would result in a deadlock.
Parameters
[in]sessionImplicit session (do not stop) with information about event originator session IDs.
[in]sub_idSubscription ID.
[in]xpathFull operation xpath identifying the exact RPC/action executed.
[in]inputArray of input parameters.
[in]input_cntNumber of input parameters.
[in]eventType of the callback event that has occurred.
[in]request_idRequest ID unique for the specific op_path.
[out]outputArray of output parameters. Should be allocated on heap, will be freed by sysrepo after sending of the RPC response.
[out]output_cntNumber of output parameters.
[in]private_dataPrivate context opaque to sysrepo, as passed to sr_rpc_subscribe call.
Returns
User error code (SR_ERR_OK on success).

Definition at line 578 of file sysrepo_types.h.

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.

Note
Callback must not modify any RPC/action subscriptions, it would result in a deadlock.
Parameters
[in]sessionImplicit session (do not stop) with information about the event originator session IDs.
[in]sub_idSubscription ID.
[in]op_pathSimple operation path identifying the RPC/action.
[in]inputData tree of input parameters. Always points to the RPC/action itself, even for nested operations.
[in]eventType of the callback event that has occurred.
[in]request_idRequest ID unique for the specific op_path.
[out]outputData tree for appending any output parameters, the operation root node is provided..
[in]private_dataPrivate context opaque to sysrepo, as passed to sr_rpc_subscribe_tree call.
Returns
User error code (SR_ERR_OK on success).

Definition at line 597 of file sysrepo_types.h.

Function Documentation

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.

Required READ access.

Note
RPC/action must be valid in (is validated against) the operational datastore context.
Parameters
[in]sessionSession (not DS-specific) to use.
[in]pathPath identifying the RPC/action.
[in]inputArray of input parameters (array of all nodes that hold some data in RPC/action input subtree - same as sr_get_items would return).
[in]input_cntNumber of input parameters.
[in]timeout_msRPC/action callback timeout in milliseconds. If 0, default is used.
[out]outputArray of output parameters (all nodes that hold some data in RPC/action output subtree). Will be allocated by sysrepo and should be freed by caller using sr_free_values.
[out]output_cntNumber of output parameters.
Returns
Error code (SR_ERR_OK on success).
int sr_rpc_send_tree ( sr_session_ctx_t session,
struct lyd_node *  input,
uint32_t  timeout_ms,
sr_data_t **  output 
)

Send an RPC/action and wait for the result. Data are represented as libyang subtrees.

Required READ access.

Note
RPC/action must be valid in (is validated against) the operational datastore context.
Parameters
[in]sessionSession (not DS-specific) to use.
[in,out]inputInput data tree in session connection libyang context, is validated.
[in]timeout_msRPC/action callback timeout in milliseconds. If 0, default is used.
[out]outputSR data with the output data tree.
Returns
Error code (SR_ERR_OK on success).
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.

Required WRITE access.

Parameters
[in]sessionSession (not DS-specific) to use.
[in]xpathXPath identifying the RPC/action. Any predicates are allowed.
[in]callbackCallback to be called.
[in]private_dataPrivate context passed to the callback function, opaque to sysrepo.
[in]prioritySpecifies the order in which the callbacks (within RPC/action) will be called, higher first.
[in]optsOptions overriding default behavior of the subscription, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags.
[in,out]subscriptionSubscription context, zeroed for first subscription, freed by sr_unsubscribe.
Returns
Error code (SR_ERR_OK on success).
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.

Required WRITE access.

Parameters
[in]sessionSession (not DS-specific) to use.
[in]xpathXPath identifying the RPC/action. Any predicates are allowed.
[in]callbackCallback to be called.
[in]private_dataPrivate context passed to the callback function, opaque to sysrepo.
[in]prioritySpecifies the order in which the callbacks (within RPC/action) will be called, higher first.
[in]optsOptions overriding default behavior of the subscription, it is supposed to be a bitwise OR-ed value of any sr_subscr_flag_t flags.
[in,out]subscriptionSubscription context, zeroed for first subscription, freed by sr_unsubscribe.
Returns
Error code (SR_ERR_OK on success).