Loading...
Searching...
No Matches
subscribed_notifications.h
Go to the documentation of this file.
#ifndef SYSREPO_SUBSCRIBED_NOTIFICATIONS_H_
#define SYSREPO_SUBSCRIBED_NOTIFICATIONS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/stat.h>
#include "sysrepo.h"
typedef enum {
SRSN_SUB_NOTIF,
SRSN_YANG_PUSH_PERIODIC,
SRSN_YANG_PUSH_ON_CHANGE
} srsn_sub_type_t;
typedef enum {
SRSN_YP_CHANGE_INVALID = -1,
SRSN_YP_CHANGE_CREATE,
SRSN_YP_CHANGE_DELETE,
SRSN_YP_CHANGE_INSERT,
SRSN_YP_CHANGE_MOVE,
SRSN_YP_CHANGE_REPLACE,
SRSN_COUNT_YP_CHANGE
} srsn_yp_change_t;
typedef struct {
uint32_t sub_id;
char *xpath_filter;
struct timespec stop_time;
uint32_t sent_count;
uint32_t excluded_count;
int suspended;
srsn_sub_type_t type;
union {
struct {
char *stream;
struct timespec start_time;
} sub_notif;
struct {
sr_datastore_t ds;
uint32_t period;
struct timespec anchor_time;
} yp_periodic;
struct {
sr_datastore_t ds;
uint32_t dampening_period;
int sync_on_start;
int excluded_change[SRSN_COUNT_YP_CHANGE];
} yp_on_change;
};
} srsn_state_sub_t;
int srsn_filter_subtree2xpath(const struct lyd_node *subtree, sr_session_ctx_t *session, char **xpath_filter);
int srsn_stream_collect_mods(const char *stream, const char *xpath_filter, const struct ly_ctx *ly_ctx,
struct ly_set **mod_set);
int srsn_notif_sent(uint32_t sub_id);
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);
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);
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);
int srsn_yang_push_on_change_resync(uint32_t sub_id);
int srsn_modify_xpath_filter(uint32_t sub_id, const char *xpath_filter);
int srsn_modify_stop_time(uint32_t sub_id, const struct timespec *stop_time);
int srsn_yang_push_modify_periodic(uint32_t sub_id, uint32_t period_ms, const struct timespec *anchor_time);
int srsn_yang_push_modify_on_change(uint32_t sub_id, uint32_t dampening_period_ms);
int srsn_suspend(uint32_t sub_id, const char *reason);
int srsn_resume(uint32_t sub_id);
int srsn_terminate(uint32_t sub_id, const char *reason);
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);
int srsn_oper_data_subscriptions(srsn_state_sub_t **subs, uint32_t *count);
int srsn_oper_data_sub(uint32_t sub_id, srsn_state_sub_t **sub);
void srsn_oper_data_subscriptions_free(srsn_state_sub_t *subs, uint32_t count);
int srsn_read_notif(int fd, const struct ly_ctx *ly_ctx, struct timespec *timestamp, struct lyd_node **notif);
int srsn_poll(int fd, uint32_t timeout_ms);
typedef void (*srsn_notif_cb)(const struct lyd_node *notif, const struct timespec *timestamp, void *cb_data);
int srsn_read_dispatch_init(sr_conn_ctx_t *conn, srsn_notif_cb cb);
int srsn_read_dispatch_start(int fd, sr_conn_ctx_t *conn, srsn_notif_cb cb, void *cb_data);
int srsn_read_dispatch_add(int fd, void *cb_data);
uint32_t srsn_read_dispatch_count(void);
int srsn_read_dispatch_destroy(void);
#ifdef __cplusplus
}
#endif
#endif /* SYSREPO_SUBSCRIBED_NOTIFICATIONS_H_ */
sr_conn_ctx_t
struct sr_conn_ctx_s sr_conn_ctx_t
Sysrepo connection.
Definition sysrepo_types.h:89
sr_subscription_ctx_t
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...
Definition sysrepo_types.h:479
srsn_notif_sent
int srsn_notif_sent(uint32_t sub_id)
Increase the sent-notifications counter in case of additional manually-generated notifications (such ...
srsn_state_sub_t::stop_time
struct timespec stop_time
Definition subscribed_notifications.h:50
srsn_modify_xpath_filter
int srsn_modify_xpath_filter(uint32_t sub_id, const char *xpath_filter)
Modify a generic subscription xpath-filter.
srsn_yang_push_modify_periodic
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.
srsn_stream_collect_mods
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.
srsn_read_dispatch_start
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().
srsn_state_sub_t.__unnamed0__.yp_periodic::ds
sr_datastore_t ds
srsn_poll
int srsn_poll(int fd, uint32_t timeout_ms)
Poll a file descriptor for data to read.
srsn_yp_change_t
srsn_yp_change_t
Definition subscribed_notifications.h:37
SRSN_YP_CHANGE_MOVE
@ SRSN_YP_CHANGE_MOVE
Definition subscribed_notifications.h:42
SRSN_YP_CHANGE_REPLACE
@ SRSN_YP_CHANGE_REPLACE
Definition subscribed_notifications.h:43
SRSN_COUNT_YP_CHANGE
@ SRSN_COUNT_YP_CHANGE
Definition subscribed_notifications.h:44
SRSN_YP_CHANGE_DELETE
@ SRSN_YP_CHANGE_DELETE
Definition subscribed_notifications.h:40
SRSN_YP_CHANGE_INSERT
@ SRSN_YP_CHANGE_INSERT
Definition subscribed_notifications.h:41
SRSN_YP_CHANGE_INVALID
@ SRSN_YP_CHANGE_INVALID
Definition subscribed_notifications.h:38
SRSN_YP_CHANGE_CREATE
@ SRSN_YP_CHANGE_CREATE
Definition subscribed_notifications.h:39
srsn_state_sub_t::suspended
int suspended
Definition subscribed_notifications.h:53
srsn_yang_push_on_change_resync
int srsn_yang_push_on_change_resync(uint32_t sub_id)
Subscribe for receiving notifications according to 'ietf-subscribed-notifications' YANG.
srsn_sub_type_t
srsn_sub_type_t
Type of the subscribed-notifications subscription.
Definition subscribed_notifications.h:31
SRSN_YANG_PUSH_PERIODIC
@ SRSN_YANG_PUSH_PERIODIC
Definition subscribed_notifications.h:33
SRSN_YANG_PUSH_ON_CHANGE
@ SRSN_YANG_PUSH_ON_CHANGE
Definition subscribed_notifications.h:34
SRSN_SUB_NOTIF
@ SRSN_SUB_NOTIF
Definition subscribed_notifications.h:32
srsn_state_sub_t::sent_count
uint32_t sent_count
Definition subscribed_notifications.h:51
srsn_read_dispatch_add
int srsn_read_dispatch_add(int fd, void *cb_data)
Add another subscription to be handled by the dispatched thread.
srsn_yang_push_modify_on_change
int srsn_yang_push_modify_on_change(uint32_t sub_id, uint32_t dampening_period_ms)
Modify a yang-push on-change subscription.
srsn_oper_data_subscriptions
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...
srsn_state_sub_t.__unnamed0__.yp_on_change::excluded_change
int excluded_change[SRSN_COUNT_YP_CHANGE]
srsn_filter_subtree2xpath
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.
srsn_state_sub_t::type
srsn_sub_type_t type
Definition subscribed_notifications.h:55
srsn_read_dispatch_count
uint32_t srsn_read_dispatch_count(void)
Get the number of subscriptions currently handled by the dispatched thread.
srsn_modify_stop_time
int srsn_modify_stop_time(uint32_t sub_id, const struct timespec *stop_time)
Modify a generic subscription stop-time.
srsn_resume
int srsn_resume(uint32_t sub_id)
Resume a subscribed-notifications subscription.
srsn_oper_data_streams_cb
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'.
srsn_suspend
int srsn_suspend(uint32_t sub_id, const char *reason)
Suspend a subscribed-notifications subscription.
srsn_notif_cb
void(* srsn_notif_cb)(const struct lyd_node *notif, const struct timespec *timestamp, void *cb_data)
Callback for reading notifications.
Definition subscribed_notifications.h:320
srsn_terminate
int srsn_terminate(uint32_t sub_id, const char *reason)
Terminate a subscribed-notifications subscription.
srsn_state_sub_t.__unnamed0__.yp_periodic::period
uint32_t period
srsn_read_notif
int srsn_read_notif(int fd, const struct ly_ctx *ly_ctx, struct timespec *timestamp, struct lyd_node **notif)
Read a notification.
srsn_state_sub_t.__unnamed0__.yp_on_change::dampening_period
uint32_t dampening_period
srsn_state_sub_t::excluded_count
uint32_t excluded_count
Definition subscribed_notifications.h:52
srsn_read_dispatch_init
int srsn_read_dispatch_init(sr_conn_ctx_t *conn, srsn_notif_cb cb)
Init read dispatch for notifications, overwrites any previous parameters.
srsn_state_sub_t.__unnamed0__.sub_notif::start_time
struct timespec start_time
srsn_oper_data_subscriptions_free
void srsn_oper_data_subscriptions_free(srsn_state_sub_t *subs, uint32_t count)
Free subscription state data.
srsn_state_sub_t::sub_id
uint32_t sub_id
Definition subscribed_notifications.h:48
srsn_read_dispatch_destroy
int srsn_read_dispatch_destroy(void)
Stop the dispatched thread and clear all the used resources.
srsn_oper_data_sub
int srsn_oper_data_sub(uint32_t sub_id, srsn_state_sub_t **sub)
Get subscription state data of a single subscription.
srsn_state_sub_t.__unnamed0__.yp_on_change::sync_on_start
int sync_on_start
srsn_state_sub_t.__unnamed0__.yp_periodic::anchor_time
struct timespec anchor_time
srsn_state_sub_t::xpath_filter
char * xpath_filter
Definition subscribed_notifications.h:49
srsn_state_sub_t.__unnamed0__.sub_notif::stream
char * stream
srsn_state_sub_t
Definition subscribed_notifications.h:47
sysrepo.h
public API sysrepo header
sr_session_ctx_t
struct sr_session_ctx_s sr_session_ctx_t
Sysrepo session on a connection.
Definition sysrepo_types.h:99
sr_datastore_t
sr_datastore_t
Datastores that sysrepo supports. To change which datastore a session operates on,...
Definition sysrepo_types.h:121