sysrepo  2.2.170
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 
93 int srsn_notif_sent(uint32_t sub_id);
94 
111 int srsn_subscribe(sr_session_ctx_t *session, const char *stream, const char *xpath_filter, const struct timespec *stop_time,
112  const struct timespec *start_time, int sub_no_thread, sr_subscription_ctx_t **sub,
113  struct timespec *replay_start_time, int *fd, uint32_t *sub_id);
114 
129 int srsn_yang_push_periodic(sr_session_ctx_t *session, sr_datastore_t ds, const char *xpath_filter, uint32_t period_ms,
130  const struct timespec *anchor_time, const struct timespec *stop_time, int *fd, uint32_t *sub_id);
131 
150 int srsn_yang_push_on_change(sr_session_ctx_t *session, sr_datastore_t ds, const char *xpath_filter,
151  uint32_t dampening_period_ms, int sync_on_start, int excluded_changes[SRSN_COUNT_YP_CHANGE],
152  const struct timespec *stop_time, int sub_no_thread, sr_subscription_ctx_t **sub, int *fd, uint32_t *sub_id);
153 
160 int srsn_yang_push_on_change_resync(uint32_t sub_id);
161 
171 int srsn_modify_xpath_filter(uint32_t sub_id, const char *xpath_filter);
172 
182 int srsn_modify_stop_time(uint32_t sub_id, const struct timespec *stop_time);
183 
194 int srsn_yang_push_modify_periodic(uint32_t sub_id, uint32_t period_ms, const struct timespec *anchor_time);
195 
205 int srsn_yang_push_modify_on_change(uint32_t sub_id, uint32_t dampening_period_ms);
206 
216 int srsn_suspend(uint32_t sub_id, const char *reason);
217 
226 int srsn_resume(uint32_t sub_id);
227 
238 int srsn_terminate(uint32_t sub_id, const char *reason);
239 
243 int srsn_oper_data_streams_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *module_name, const char *path,
244  const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data);
245 
254 int srsn_oper_data_subscriptions(srsn_state_sub_t **subs, uint32_t *count);
255 
263 int srsn_oper_data_sub(uint32_t sub_id, srsn_state_sub_t **sub);
264 
271 void srsn_oper_data_subscriptions_free(srsn_state_sub_t *subs, uint32_t count);
272 
285 int srsn_read_notif(int fd, const struct ly_ctx *ly_ctx, struct timespec *timestamp, struct lyd_node **notif);
286 
297 int srsn_poll(int fd, uint32_t timeout_ms);
298 
306 typedef void (*srsn_notif_cb)(const struct lyd_node *notif, const struct timespec *timestamp, void *cb_data);
307 
320 int srsn_read_dispatch_start(int fd, sr_conn_ctx_t *conn, srsn_notif_cb cb, void *cb_data);
321 
329 int srsn_read_dispatch_add(int fd, void *cb_data);
330 
336 uint32_t srsn_read_dispatch_count(void);
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 
342 #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.
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_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)
Dispatch a per-process thread for reading notifications.