![]() |
sysrepo
5.3.0
YANG-based system repository for all-around configuration management.
|
Receiving, reassembling and parsing UDP-Notif messages. More...
Data Structures | |
| struct | srudpn_stats_t |
| UDP-Notif collector diagnostic counters. More... | |
Typedefs | |
| typedef struct srudpn_msg_s | srudpn_msg_t |
| Complete (reassembled) UDP-Notif message. More... | |
| typedef struct srudpn_notif_s | srudpn_notif_t |
| Parsed notification of a UDP-Notif message. More... | |
| typedef struct srudpn_s | srudpn_t |
| UDP-Notif collector receiving and reassembling notifications over UDP. More... | |
Functions | |
| void | srudpn_close (srudpn_t *udp) |
| Close a collector, any incomplete messages are dropped. More... | |
| int | srudpn_get_fd (const srudpn_t *udp) |
| Get the socket of a collector for polling. More... | |
| uint16_t | srudpn_get_port (const srudpn_t *udp) |
| Get the port a collector is bound to. More... | |
| srudpn_stats_t | srudpn_get_stats (const srudpn_t *udp) |
| Get the diagnostic counters of a collector. More... | |
| void | srudpn_msg_free (srudpn_msg_t *msg) |
| Free a message. More... | |
| const srudpn_hdr_t * | srudpn_msg_get_hdr (const srudpn_msg_t *msg) |
| Get the header of a message. More... | |
| srudpn_media_type_t | srudpn_msg_get_media_type (const srudpn_msg_t *msg) |
| Get the media type of a message. More... | |
| void | srudpn_msg_get_payload (const srudpn_msg_t *msg, const uint8_t **payload, uint32_t *payload_len) |
| Get the payload of a message. More... | |
| void | srudpn_msg_get_source (const srudpn_msg_t *msg, char *addr, uint16_t *port) |
| Get the source address and port of a message. More... | |
| 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. More... | |
| void | srudpn_notif_free (srudpn_notif_t *notif) |
| Free a parsed notification. More... | |
| const struct lyd_node * | srudpn_notif_get_envelope (const srudpn_notif_t *notif) |
| Get the envelope of a parsed notification. More... | |
| const struct timespec * | srudpn_notif_get_event_time (const srudpn_notif_t *notif) |
| Get the event time of a parsed notification. More... | |
| const char * | srudpn_notif_get_hostname (const srudpn_notif_t *notif) |
| Get the hostname of the publisher from the YANG-Push envelope of a parsed notification. More... | |
| const uint32_t * | srudpn_notif_get_sequence_number (const srudpn_notif_t *notif) |
| Get the sequence number of the message from the YANG-Push envelope of a parsed notification. More... | |
| const struct lyd_node * | srudpn_notif_get_tree (const srudpn_notif_t *notif) |
| Get the notification data tree of a parsed notification. More... | |
| int | srudpn_open (const char *address, uint16_t port, srudpn_t **udp) |
| Open a UDP-Notif collector bound to a local address. More... | |
| int | srudpn_read_msg (srudpn_t *udp, int32_t timeout_ms, srudpn_msg_t **msg) |
| Read one complete UDP-Notif message. More... | |
Receiving, reassembling and parsing UDP-Notif messages.
| struct srudpn_stats_t |
UDP-Notif collector diagnostic counters.
Definition at line 102 of file udp_notif.h.
| typedef struct srudpn_msg_s srudpn_msg_t |
Complete (reassembled) UDP-Notif message.
Definition at line 1 of file udp_notif.h.
| typedef struct srudpn_notif_s srudpn_notif_t |
Parsed notification of a UDP-Notif message.
The notification is sent in the RFC 5277 envelope (RFC 8040 for JSON), the getters return these parts of it:
or in the YANG-Push notification envelope (draft-ietf-netconf-notif-envelope):
Definition at line 1 of file udp_notif.h.
| typedef struct srudpn_s srudpn_t |
UDP-Notif collector receiving and reassembling notifications over UDP.
Definition at line 1 of file udp_notif.h.
| void srudpn_close | ( | srudpn_t * | udp | ) |
Close a collector, any incomplete messages are dropped.
| [in] | udp | Collector to close. |
| int srudpn_get_fd | ( | const srudpn_t * | udp | ) |
Get the socket of a collector for polling.
The socket must not be closed or read from.
| [in] | udp | Collector to use. |
| uint16_t srudpn_get_port | ( | const srudpn_t * | udp | ) |
Get the port a collector is bound to.
| [in] | udp | Collector to use. |
| srudpn_stats_t srudpn_get_stats | ( | const srudpn_t * | udp | ) |
Get the diagnostic counters of a collector.
| [in] | udp | Collector to use. |
| void srudpn_msg_free | ( | srudpn_msg_t * | msg | ) |
Free a message.
| [in] | msg | Message to free. |
| const srudpn_hdr_t* srudpn_msg_get_hdr | ( | const srudpn_msg_t * | msg | ) |
Get the header of a message.
| [in] | msg | Message to use. |
| srudpn_media_type_t srudpn_msg_get_media_type | ( | const srudpn_msg_t * | msg | ) |
Get the media type of a message.
Only SRUDPN_MT_JSON, SRUDPN_MT_XML and SRUDPN_MT_CBOR can be parsed by srudpn_msg_parse(), any other media type has to be decoded from srudpn_msg_get_payload() by the caller.
| [in] | msg | Message to use. |
| void srudpn_msg_get_payload | ( | const srudpn_msg_t * | msg, |
| const uint8_t ** | payload, | ||
| uint32_t * | payload_len | ||
| ) |
Get the payload of a message.
Meant for the media types srudpn_msg_parse() cannot parse, see srudpn_msg_get_media_type().
| [in] | msg | Message to use. |
| [out] | payload | Reassembled payload. |
| [out] | payload_len | Length of payload. |
| void srudpn_msg_get_source | ( | const srudpn_msg_t * | msg, |
| char * | addr, | ||
| uint16_t * | port | ||
| ) |
Get the source address and port of a message.
| [in] | msg | Message to use. |
| [out] | addr | Buffer of SRUDPN_ADDR_STRLEN for the numeric IPv4 or IPv6 source address. |
| [out] | port | Source port. |
| 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.
| [in] | msg | Message to parse. |
| [in] | ly_ctx | Libyang context to use for parsing. |
| [out] | notif | Parsed notification, free with srudpn_notif_free(). |
| void srudpn_notif_free | ( | srudpn_notif_t * | notif | ) |
Free a parsed notification.
| [in] | notif | Parsed notification to free. |
| const struct lyd_node* srudpn_notif_get_envelope | ( | const srudpn_notif_t * | notif | ) |
Get the envelope of a parsed notification.
The envelope is the outer element with the event time and any other metadata, without the notification data itself, see srudpn_notif_t.
| [in] | notif | Parsed notification to use. |
| const struct timespec* srudpn_notif_get_event_time | ( | const srudpn_notif_t * | notif | ) |
Get the event time of a parsed notification.
| [in] | notif | Parsed notification to use. |
| const char* srudpn_notif_get_hostname | ( | const srudpn_notif_t * | notif | ) |
Get the hostname of the publisher from the YANG-Push envelope of a parsed notification.
| [in] | notif | Parsed notification to use. |
| const uint32_t* srudpn_notif_get_sequence_number | ( | const srudpn_notif_t * | notif | ) |
Get the sequence number of the message from the YANG-Push envelope of a parsed notification.
| [in] | notif | Parsed notification to use. |
| const struct lyd_node* srudpn_notif_get_tree | ( | const srudpn_notif_t * | notif | ) |
Get the notification data tree of a parsed notification.
| [in] | notif | Parsed notification to use. |
| int srudpn_open | ( | const char * | address, |
| uint16_t | port, | ||
| srudpn_t ** | udp | ||
| ) |
Open a UDP-Notif collector bound to a local address.
| [in] | address | Numeric IPv4 or IPv6 address to bind to, NULL for all local addresses. |
| [in] | port | Port to bind to, 0 for any free port. |
| [out] | udp | Created collector. |
| int srudpn_read_msg | ( | srudpn_t * | udp, |
| int32_t | timeout_ms, | ||
| srudpn_msg_t ** | msg | ||
| ) |
Read one complete UDP-Notif message.
| [in] | udp | Collector to read from. |
| [in] | timeout_ms | Timeout of the whole call, -1 for infinite, 0 to only process the already queued datagrams without waiting. |
| [out] | msg | Read message, free with srudpn_msg_free(). |