17 #ifndef SYSREPO_UDP_NOTIF_H_
18 #define SYSREPO_UDP_NOTIF_H_
25 #include <netinet/in.h>
46 #define SRUDPN_VERSION 1
49 #define SRUDPN_HDR_SIZE 12
52 #define SRUDPN_OPT_SEGMENTATION 1
55 #define SRUDPN_OPT_SEGMENTATION_SIZE 4
58 #define SRUDPN_ADDR_STRLEN (INET6_ADDRSTRLEN + IF_NAMESIZE)
332 const uint8_t *payload, uint32_t payload_len, uint16_t max_segment_size,
srudpn_dgram_t **dgrams);
UDP-Notif collector diagnostic counters.
void srudpn_notif_free(srudpn_notif_t *notif)
Free a parsed notification.
int srudpn_get_fd(const srudpn_t *udp)
Get the socket of a collector for polling.
srudpn_stats_t srudpn_get_stats(const srudpn_t *udp)
Get the diagnostic counters of a collector.
const srudpn_hdr_t * srudpn_msg_get_hdr(const srudpn_msg_t *msg)
Get the header of a message.
struct srudpn_notif_s srudpn_notif_t
Parsed notification of a UDP-Notif message.
const struct lyd_node * srudpn_notif_get_tree(const srudpn_notif_t *notif)
Get the notification data tree of a parsed notification.
uint16_t srudpn_get_port(const srudpn_t *udp)
Get the port a collector is bound to.
void srudpn_msg_free(srudpn_msg_t *msg)
Free a message.
void srudpn_msg_get_source(const srudpn_msg_t *msg, char *addr, uint16_t *port)
Get the source address and port of a message.
int srudpn_read_msg(srudpn_t *udp, int32_t timeout_ms, srudpn_msg_t **msg)
Read one complete UDP-Notif message.
srudpn_media_type_t srudpn_msg_get_media_type(const srudpn_msg_t *msg)
Get the media type of a message.
const struct timespec * srudpn_notif_get_event_time(const srudpn_notif_t *notif)
Get the event time of a parsed notification.
struct srudpn_s srudpn_t
UDP-Notif collector receiving and reassembling notifications over UDP.
const struct lyd_node * srudpn_notif_get_envelope(const srudpn_notif_t *notif)
Get the envelope of a parsed notification.
void srudpn_close(srudpn_t *udp)
Close a collector, any incomplete messages are dropped.
int srudpn_msg_parse(const srudpn_msg_t *msg, const struct ly_ctx *ly_ctx, srudpn_notif_t **notif)
Parse the notification of a message.
struct srudpn_msg_s srudpn_msg_t
Complete (reassembled) UDP-Notif message.
int srudpn_open(const char *address, uint16_t port, srudpn_t **udp)
Open a UDP-Notif collector bound to a local address.
void srudpn_msg_get_payload(const srudpn_msg_t *msg, const uint8_t **payload, uint32_t *payload_len)
Get the payload of a message.
Parsed header of one UDP-Notif datagram.
srudpn_media_type_t
UDP-Notif media types (MT values with the S-flag unset).
#define SRUDPN_OPT_SEGMENTATION_SIZE
One encoded UDP-Notif datagram, header and data to be sent together.
int srudpn_build_dgrams(srudpn_media_type_t media_type, uint32_t publisher_id, uint32_t message_id, const uint8_t *payload, uint32_t payload_len, uint16_t max_segment_size, srudpn_dgram_t **dgrams)
Encode a payload into UDP-Notif datagrams.
int srudpn_encode_notification(const struct lyd_node *notif, const struct timespec *event_time, srudpn_media_type_t media_type, uint8_t **payload, uint32_t *payload_len)
Encode a notification in the RFC 5277 envelope.
public API sysrepo header