Receiving, reassembling and parsing UDP-Notif messages.
More...
|
| 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...
|
| |
|
| 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 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.
◆ srudpn_stats_t
UDP-Notif collector diagnostic counters.
Definition at line 101 of file udp_notif.h.
| Data Fields |
|
uint32_t |
datagrams |
all received datagrams
|
|
uint32_t |
dup_segments |
duplicate segments dropped
|
|
uint32_t |
malformed |
datagrams discarded for an invalid header or length
|
|
uint32_t |
messages |
complete messages returned
|
|
uint32_t |
reasm_discarded |
incomplete messages dropped on a timeout or eviction
|
|
uint32_t |
unsupported |
datagrams discarded for a version, option or media type
|
◆ srudpn_msg_t
Complete (reassembled) UDP-Notif message.
Definition at line 1 of file udp_notif.h.
◆ 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:
<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"> <- srudpn_notif_get_envelope()
<eventTime>2026-10-23T10:00:00Z</eventTime> <- srudpn_notif_get_event_time()
<link-down xmlns="urn:example:interfaces"> <- srudpn_notif_get_tree()
<if-name>eth0</if-name>
</link-down>
</notification>
Definition at line 1 of file udp_notif.h.
◆ srudpn_t
UDP-Notif collector receiving and reassembling notifications over UDP.
Definition at line 1 of file udp_notif.h.
◆ srudpn_close()
Close a collector, any incomplete messages are dropped.
- Parameters
-
| [in] | udp | Collector to close. |
◆ srudpn_get_fd()
| 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.
- Parameters
-
- Returns
- Socket file descriptor.
◆ srudpn_get_port()
| uint16_t srudpn_get_port |
( |
const srudpn_t * |
udp | ) |
|
Get the port a collector is bound to.
- Parameters
-
- Returns
- Bound port.
◆ srudpn_get_stats()
Get the diagnostic counters of a collector.
- Parameters
-
- Returns
- Current counters.
◆ srudpn_msg_free()
Free a message.
- Parameters
-
◆ srudpn_msg_get_hdr()
Get the header of a message.
- Parameters
-
- Returns
- Header of the message.
◆ srudpn_msg_get_media_type()
◆ srudpn_msg_get_payload()
| void srudpn_msg_get_payload |
( |
const srudpn_msg_t * |
msg, |
|
|
const uint8_t ** |
payload, |
|
|
uint32_t * |
payload_len |
|
) |
| |
◆ srudpn_msg_get_source()
| void srudpn_msg_get_source |
( |
const srudpn_msg_t * |
msg, |
|
|
char * |
addr, |
|
|
uint16_t * |
port |
|
) |
| |
Get the source address and port of a message.
- Parameters
-
| [in] | msg | Message to use. |
| [out] | addr | Buffer of SRUDPN_ADDR_STRLEN for the numeric IPv4 or IPv6 source address. |
| [out] | port | Source port. |
◆ srudpn_msg_parse()
Parse the notification of a message.
- Parameters
-
| [in] | msg | Message to parse. |
| [in] | ly_ctx | Libyang context to use for parsing. |
| [out] | notif | Parsed notification, free with srudpn_notif_free(). |
- Returns
- Error code (SR_ERR_OK on success).
◆ srudpn_notif_free()
Free a parsed notification.
- Parameters
-
| [in] | notif | Parsed notification to free. |
◆ srudpn_notif_get_envelope()
| 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 notification element of RFC 5277 (RFC 8040 for JSON) with the eventTime, without the notification data itself, see srudpn_notif_t.
- Note
- The envelope nodes are opaque (no schema), read them with LYD_NAME() and lyd_get_value().
- Parameters
-
| [in] | notif | Parsed notification to use. |
- Returns
- Envelope data tree.
◆ srudpn_notif_get_event_time()
| const struct timespec* srudpn_notif_get_event_time |
( |
const srudpn_notif_t * |
notif | ) |
|
Get the event time of a parsed notification.
- Parameters
-
| [in] | notif | Parsed notification to use. |
- Returns
- Event time from the notification envelope.
◆ srudpn_notif_get_tree()
| const struct lyd_node* srudpn_notif_get_tree |
( |
const srudpn_notif_t * |
notif | ) |
|
Get the notification data tree of a parsed notification.
- Parameters
-
| [in] | notif | Parsed notification to use. |
- Returns
- Notification data tree.
◆ srudpn_open()
| int srudpn_open |
( |
const char * |
address, |
|
|
uint16_t |
port, |
|
|
srudpn_t ** |
udp |
|
) |
| |
Open a UDP-Notif collector bound to a local address.
- Parameters
-
| [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. |
- Returns
- Error code (SR_ERR_OK on success).
◆ srudpn_read_msg()
Read one complete UDP-Notif message.
- Parameters
-
| [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(). |
- Returns
- SR_ERR_OK on success,
-
SR_ERR_TIME_OUT if no message was completed in time or a signal interrupted the wait,
-
another error code on failure.