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
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 
84 int srsn_filter_subtree2xpath(const struct lyd_node *subtree, sr_session_ctx_t *session, char **xpath_filter);
85 
95 int srsn_stream_collect_mods(const char *stream, const char *xpath_filter, const struct ly_ctx *ly_ctx,
96  struct ly_set **mod_set);
97 
105 int srsn_notif_sent(uint32_t sub_id);
106 
123 int srsn_subscribe(sr_session_ctx_t *session, const char *stream, const char *xpath_filter, const struct timespec *stop_time,
124  const struct timespec *start_time, int sub_no_thread, sr_subscription_ctx_t **sub,
125  struct timespec *replay_start_time, int *fd, uint32_t *sub_id);
126 
141 int srsn_yang_push_periodic(sr_session_ctx_t *session, sr_datastore_t ds, const char *xpath_filter, uint32_t period_ms,
142  const struct timespec *anchor_time, const struct timespec *stop_time, int *fd, uint32_t *sub_id);
143 
162 int srsn_yang_push_on_change(sr_session_ctx_t *session, sr_datastore_t ds, const char *xpath_filter,
163  uint32_t dampening_period_ms, int sync_on_start, int excluded_changes[SRSN_COUNT_YP_CHANGE],
164  const struct timespec *stop_time, int sub_no_thread, sr_subscription_ctx_t **sub, int *fd, uint32_t *sub_id);
165 
172 int srsn_yang_push_on_change_resync(uint32_t sub_id);
173 
183 int srsn_modify_xpath_filter(uint32_t sub_id, const char *xpath_filter);
184 
194 int srsn_modify_stop_time(uint32_t sub_id, const struct timespec *stop_time);
195 
206 int srsn_yang_push_modify_periodic(uint32_t sub_id, uint32_t period_ms, const struct timespec *anchor_time);
207 
217 int srsn_yang_push_modify_on_change(uint32_t sub_id, uint32_t dampening_period_ms);
218 
228 int srsn_suspend(uint32_t sub_id, const char *reason);
229 
238 int srsn_resume(uint32_t sub_id);
239 
252 int srsn_terminate(uint32_t sub_id, const char *reason);
253 
257 int srsn_oper_data_streams_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *module_name, const char *path,
258  const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data);
259 
268 int srsn_oper_data_subscriptions(srsn_state_sub_t **subs, uint32_t *count);
269 
277 int srsn_oper_data_sub(uint32_t sub_id, srsn_state_sub_t **sub);
278 
285 void srsn_oper_data_subscriptions_free(srsn_state_sub_t *subs, uint32_t count);
286 
299 int srsn_read_notif(int fd, const struct ly_ctx *ly_ctx, struct timespec *timestamp, struct lyd_node **notif);
300 
311 int srsn_poll(int fd, uint32_t timeout_ms);
312 
320 typedef void (*srsn_notif_cb)(const struct lyd_node *notif, const struct timespec *timestamp, void *cb_data);
321 
330 
334 int srsn_read_dispatch_start(int fd, sr_conn_ctx_t *conn, srsn_notif_cb cb, void *cb_data);
335 
346 int srsn_read_dispatch_add(int fd, void *cb_data);
347 
353 uint32_t srsn_read_dispatch_count(void);
354 
361 
362 #ifdef __cplusplus
363 }
364 #endif
365 
366 #endif /* SYSREPO_SUBSCRIBED_NOTIFICATIONS_H_ */
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 &#39;ietf-subscribed-notifications&#39; YANG...
public API sysrepo header
int srsn_filter_subtree2xpath(const struct lyd_node *subtree, sr_session_ctx_t *session, char **xpath_filter)
Transform a subtree filter into an XPath filter.
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 &#39;ietf-yang-push&#39; YANG periodic subscriptions...
sr_datastore_t
Datastores that sysrepo supports. To change which datastore a session operates on, use sr_session_switch_ds.
int srsn_suspend(uint32_t sub_id, const char *reason)
Suspend a subscribed-notifications subscription.
int srsn_resume(uint32_t sub_id)
Resume a subscribed-notifications subscription.
int srsn_modify_xpath_filter(uint32_t sub_id, const char *xpath_filter)
Modify a generic subscription xpath-filter.
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_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_read_dispatch_init(sr_conn_ctx_t *conn, srsn_notif_cb cb)
Init read dispatch for notifications, overwrites any previous parameters.
int srsn_read_dispatch_destroy(void)
Stop the dispatched thread and clear all the used resources.
struct sr_session_ctx_s sr_session_ctx_t
Sysrepo session on a connection.
Definition: sysrepo_types.h:99
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 &#39;ietf-yang-push&#39; YANG on-change subscriptions...
struct sr_conn_ctx_s sr_conn_ctx_t
Sysrepo connection.
Definition: sysrepo_types.h:89
int srsn_notif_sent(uint32_t sub_id)
Increase the sent-notifications counter in case of additional manually-generated notifications (such ...
int srsn_yang_push_on_change_resync(uint32_t sub_id)
Resync a yang-push on-change subscription.
int srsn_read_dispatch_add(int fd, void *cb_data)
Add another subscription to be handled by the dispatched thread.
srsn_sub_type_t
Type of the subscribed-notifications subscription.
uint32_t srsn_read_dispatch_count(void)
Get the number of subscriptions currently handled by the dispatched thread.
void(* srsn_notif_cb)(const struct lyd_node *notif, const struct timespec *timestamp, void *cb_data)
Callback for reading notifications.
void srsn_oper_data_subscriptions_free(srsn_state_sub_t *subs, uint32_t count)
Free subscription state data.
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_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_poll(int fd, uint32_t timeout_ms)
Poll a file descriptor for data to read.
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 &#39;/ietf-subscribed-notification:streams&#39;...
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_oper_data_sub(uint32_t sub_id, srsn_state_sub_t **sub)
Get subscription state data of a single subscription.
int srsn_modify_stop_time(uint32_t sub_id, const struct timespec *stop_time)
Modify a generic subscription stop-time.
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 &#39;/ietf-subscribed-notificatio...
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().