sysrepo  5.2.34
YANG-based system repository for all-around configuration management.
subscribed_notifications.h
Go to the documentation of this file.
1 
17 #ifndef SYSREPO_SUBSCRIBED_NOTIFICATIONS_H_
18 #define SYSREPO_SUBSCRIBED_NOTIFICATIONS_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include <sys/stat.h>
25 
26 #include "sysrepo.h"
27 
31 typedef enum {
36 
37 typedef enum {
46 
47 typedef struct {
48  uint32_t sub_id;
49  char *xpath_filter;
50  struct timespec stop_time;
51  uint32_t sent_count;
52  uint32_t excluded_count;
53  int suspended;
54 
56 
57  union {
58  struct {
59  char *stream;
60  struct timespec start_time;
61  } sub_notif;
62  struct {
63  sr_datastore_t ds;
64  uint32_t period;
65  struct timespec anchor_time;
66  } yp_periodic;
67  struct {
68  sr_datastore_t ds;
69  uint32_t dampening_period;
70  int sync_on_start;
71  int excluded_change[SRSN_COUNT_YP_CHANGE];
72  } yp_on_change;
73  };
75 
79 int srsn_filter_subtree2xpath(const struct lyd_node *subtree, sr_session_ctx_t *session, char **xpath_filter);
80 
90 int srsn_stream_collect_mods(const char *stream, const char *xpath_filter, const struct ly_ctx *ly_ctx,
91  struct ly_set **mod_set);
92 
100 int srsn_notif_sent(uint32_t sub_id);
101 
118 int srsn_subscribe(sr_session_ctx_t *session, const char *stream, const char *xpath_filter, const struct timespec *stop_time,
119  const struct timespec *start_time, int sub_no_thread, sr_subscription_ctx_t **sub,
120  struct timespec *replay_start_time, int *fd, uint32_t *sub_id);
121 
136 int srsn_yang_push_periodic(sr_session_ctx_t *session, sr_datastore_t ds, const char *xpath_filter, uint32_t period_ms,
137  const struct timespec *anchor_time, const struct timespec *stop_time, int *fd, uint32_t *sub_id);
138 
158 int srsn_yang_push_on_change(sr_session_ctx_t *session, sr_datastore_t ds, const char *xpath_filter,
159  uint32_t dampening_period_ms, int sync_on_start, int excluded_changes[SRSN_COUNT_YP_CHANGE],
160  const struct timespec *stop_time, int sub_no_thread, sr_subscription_ctx_t **sub, int *fd, uint32_t *sub_id);
161 
170 int srsn_yang_push_on_change_resync(uint32_t sub_id);
171 
181 int srsn_modify_xpath_filter(uint32_t sub_id, const char *xpath_filter);
182 
192 int srsn_modify_stop_time(uint32_t sub_id, const struct timespec *stop_time);
193 
204 int srsn_yang_push_modify_periodic(uint32_t sub_id, uint32_t period_ms, const struct timespec *anchor_time);
205 
215 int srsn_yang_push_modify_on_change(uint32_t sub_id, uint32_t dampening_period_ms);
216 
226 int srsn_suspend(uint32_t sub_id, const char *reason);
227 
236 int srsn_resume(uint32_t sub_id);
237 
251 int srsn_terminate(uint32_t sub_id, const char *reason);
252 
256 int srsn_oper_data_streams_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *module_name, const char *path,
257  const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data);
258 
267 int srsn_oper_data_subscriptions(srsn_state_sub_t **subs, uint32_t *count);
268 
276 int srsn_oper_data_sub(uint32_t sub_id, srsn_state_sub_t **sub);
277 
285 
300 int srsn_read_notif(int fd, const struct ly_ctx *ly_ctx, struct timespec *timestamp, struct lyd_node **notif);
301 
316 int srsn_read_notif_lyb(int fd, struct timespec *timestamp, char **lyb, uint32_t *lyb_size);
317 
328 int srsn_poll(int fd, uint32_t timeout_ms);
329 
337 typedef void (*srsn_notif_cb)(const struct lyd_node *notif, const struct timespec *timestamp, void *cb_data);
338 
354 
358 int srsn_read_dispatch_start(int fd, sr_conn_ctx_t *conn, srsn_notif_cb cb, void *cb_data);
359 
373 int srsn_read_dispatch_add(int fd, void *cb_data);
374 
392 
399 
406 
407 #ifdef __cplusplus
408 }
409 #endif
410 
411 #endif /* SYSREPO_SUBSCRIBED_NOTIFICATIONS_H_ */
struct sr_conn_ctx_s sr_conn_ctx_t
Sysrepo connection.
Definition: sysrepo_types.h:91
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 srsn_notif_sent(uint32_t sub_id)
Increase the sent-notifications counter in case of additional manually-generated notifications (such ...
int srsn_modify_xpath_filter(uint32_t sub_id, const char *xpath_filter)
Modify a generic subscription xpath-filter.
int srsn_yang_push_modify_periodic(uint32_t sub_id, uint32_t period_ms, const struct timespec *anchor_time)
Modify a yang-push periodic subscription.
int srsn_stream_collect_mods(const char *stream, const char *xpath_filter, const struct ly_ctx *ly_ctx, struct ly_set **mod_set)
Collect modules to subscribe to.
int srsn_read_dispatch_start(int fd, sr_conn_ctx_t *conn, srsn_notif_cb cb, void *cb_data)
Deprecated, came functionality as calling srsn_read_dispatch_init() and srsn_read_dispatch_add().
int srsn_read_dispatch_del(int fd)
Remove a subscription from being handled by the dispatched thread and close its FD.
int srsn_poll(int fd, uint32_t timeout_ms)
Poll a file descriptor for data to read.
@ SRSN_YP_CHANGE_MOVE
@ SRSN_YP_CHANGE_REPLACE
@ SRSN_COUNT_YP_CHANGE
@ SRSN_YP_CHANGE_DELETE
@ SRSN_YP_CHANGE_INSERT
@ SRSN_YP_CHANGE_INVALID
@ SRSN_YP_CHANGE_CREATE
int srsn_yang_push_on_change_resync(uint32_t sub_id)
Resync a yang-push on-change subscription.
srsn_sub_type_t
Type of the subscribed-notifications subscription.
@ SRSN_YANG_PUSH_PERIODIC
@ SRSN_YANG_PUSH_ON_CHANGE
int srsn_read_dispatch_add(int fd, void *cb_data)
Add another subscription to be handled by the dispatched thread.
int srsn_yang_push_modify_on_change(uint32_t sub_id, uint32_t dampening_period_ms)
Modify a yang-push on-change subscription.
int srsn_oper_data_subscriptions(srsn_state_sub_t **subs, uint32_t *count)
Get subscription state data with most of the information in the subtree '/ietf-subscribed-notificatio...
int srsn_subscribe(sr_session_ctx_t *session, const char *stream, const char *xpath_filter, const struct timespec *stop_time, const struct timespec *start_time, int sub_no_thread, sr_subscription_ctx_t **sub, struct timespec *replay_start_time, int *fd, uint32_t *sub_id)
Subscribe for receiving notifications according to 'ietf-subscribed-notifications' YANG.
int srsn_filter_subtree2xpath(const struct lyd_node *subtree, sr_session_ctx_t *session, char **xpath_filter)
Deprecated, use sr_filter_subtree2xpath().
uint32_t srsn_read_dispatch_count(void)
Get the number of subscriptions currently handled by the dispatched thread.
int srsn_modify_stop_time(uint32_t sub_id, const struct timespec *stop_time)
Modify a generic subscription stop-time.
int srsn_resume(uint32_t sub_id)
Resume a subscribed-notifications subscription.
int srsn_oper_data_streams_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)
Sysrepo sr_oper_get_items_cb() providing data of the subtree '/ietf-subscribed-notification:streams'.
int srsn_suspend(uint32_t sub_id, const char *reason)
Suspend a subscribed-notifications subscription.
void(* srsn_notif_cb)(const struct lyd_node *notif, const struct timespec *timestamp, void *cb_data)
Callback for reading notifications.
int srsn_terminate(uint32_t sub_id, const char *reason)
Terminate a subscribed-notifications subscription.
int srsn_read_notif(int fd, const struct ly_ctx *ly_ctx, struct timespec *timestamp, struct lyd_node **notif)
Read a notification.
int srsn_yang_push_on_change(sr_session_ctx_t *session, sr_datastore_t ds, const char *xpath_filter, uint32_t dampening_period_ms, int sync_on_start, int excluded_changes[SRSN_COUNT_YP_CHANGE], const struct timespec *stop_time, int sub_no_thread, sr_subscription_ctx_t **sub, int *fd, uint32_t *sub_id)
Subscribe for receiving notifications according to 'ietf-yang-push' YANG on-change subscriptions.
int srsn_yang_push_periodic(sr_session_ctx_t *session, sr_datastore_t ds, const char *xpath_filter, uint32_t period_ms, const struct timespec *anchor_time, const struct timespec *stop_time, int *fd, uint32_t *sub_id)
Subscribe for receiving notifications according to 'ietf-yang-push' YANG periodic subscriptions.
int srsn_read_dispatch_init(sr_conn_ctx_t *conn, srsn_notif_cb cb)
Init read dispatch for notifications, overwrites any previous parameters.
void srsn_oper_data_subscriptions_free(srsn_state_sub_t *subs, uint32_t count)
Free subscription state data.
int srsn_read_dispatch_destroy(void)
Stop the dispatched thread and clear all the used resources.
int srsn_oper_data_sub(uint32_t sub_id, srsn_state_sub_t **sub)
Get subscription state data of a single subscription.
int srsn_read_notif_lyb(int fd, struct timespec *timestamp, char **lyb, uint32_t *lyb_size)
Read a notification without parsing it.
public API sysrepo header
struct sr_session_ctx_s sr_session_ctx_t
Sysrepo session on a connection.
sr_datastore_t
Datastores that sysrepo supports. To change which datastore a session operates on,...