#include <stdbool.h>
#include <stdint.h>
#include "ptp_types.h"
Go to the source code of this file.
|
void | msgb_init (PtpMsgBuf *buf, PtpMsgBufBlock *pool, uint32_t n) |
|
RawPtpMessage * | msgb_alloc (PtpMsgBuf *buf, uint32_t tag, uint32_t ttl) |
|
void | msgb_commit (PtpMsgBuf *buf, RawPtpMessage *msg) |
|
void | msgb_free (PtpMsgBuf *buf, RawPtpMessage *msg) |
|
RawPtpMessage * | msgb_get_oldest (PtpMsgBuf *buf) |
|
RawPtpMessage * | msgb_get_by_uid (PtpMsgBuf *buf, uint32_t uid) |
|
void | msgb_set_sent (PtpMsgBuf *buf, RawPtpMessage *msg) |
|
uint32_t | msgb_get_uid (const PtpMsgBuf *buf, const RawPtpMessage *msg) |
|
RawPtpMessage * | msgb_get_sent_by_tag (PtpMsgBuf *buf, uint32_t tag) |
|
void | msgb_tick (PtpMsgBuf *buf) |
|
void | msgb_report (PtpMsgBuf *buf) |
|
uint32_t | msgb_get_error (PtpMsgBuf *buf) |
|
◆ MSGBUF_TAG_OVERWRITE
#define MSGBUF_TAG_OVERWRITE (0x80000000) |
Overwrite if a message exists with the same tag.
Definition at line 15 of file msg_buf.h.
◆ MSGBUF_TTL_DONT_AGE
#define MSGBUF_TTL_DONT_AGE (0xFFFFFFFF) |
Do not age messages.
Definition at line 13 of file msg_buf.h.
◆ PtpMsgBufError
Error enumeration for the message buffer.
Enumerator |
---|
MSGB_ERR_NONE | No error.
|
MSGB_ERR_FULL | The buffer is full, cannot allocate a slot.
|
MSGB_ERR_EXISTS | An allocated message has already been stored under the same tag.
|
MSGB_ERR_MISC | Miscellaneous allocation error.
|
Definition at line 33 of file msg_buf.h.
◆ msgb_alloc()
Allocate a block.
- Parameters
-
buf | pointer to the PtpMsgBuf object |
tag | unique tag |
ttl | Time-to-Live in ticks |
- Returns
- pointer to a RawPtpMessage object or NULL if there's a block already allocated with the current tag or the buffer is full
Definition at line 39 of file msg_buf.c.
◆ msgb_commit()
Commit a previous allocation, make the message available for later pulling.
- Parameters
-
buf | pointer to the PtpMsgBuf object |
msg | pointer to the allocated message |
Definition at line 98 of file msg_buf.c.
◆ msgb_free()
Release an allocated message block.
- Parameters
-
buf | pointer to the PtpMsgBuf object |
msg | pointer to the allocated message |
Definition at line 115 of file msg_buf.c.
◆ msgb_get_by_uid()
Get message by its UID.
- Parameters
-
buf | pointer to the PtpMsgBuf object |
uid | uid of the message sought |
- Returns
- message with the UID or NULL if not found
Definition at line 170 of file msg_buf.c.
◆ msgb_get_error()
Read and clear last error.
- Parameters
-
- Returns
- error code
Definition at line 253 of file msg_buf.c.
◆ msgb_get_oldest()
Get oldest message from the buffer. (i.e. sequential reading)
- Parameters
-
- Returns
- pointer to the oldest message or NULL if the buffer is empty
Definition at line 143 of file msg_buf.c.
◆ msgb_get_sent_by_tag()
Get sent message by tag.
- Parameters
-
buf | pointer to the PtpMsgBuf object |
tag | tag of the message sought |
- Returns
- message with the tag or NULL if not found
Definition at line 197 of file msg_buf.c.
◆ msgb_get_uid()
Get the UID of an allocated message.
- Parameters
-
buf | pointer to PtpMsgBuf object |
msg | pointer to an allocated message |
- Returns
- message UID
Definition at line 221 of file msg_buf.c.
◆ msgb_init()
Initialize PTP message buffer.
- Parameters
-
buf | pointer to an empty (non-initialized) PtpMsgBuf object |
pool | pointer to an allocated pool for n pieces of PtpMsgBufEntry |
n | number of supported elements |
Definition at line 12 of file msg_buf.c.
◆ msgb_report()
Report the message buffer state.
- Parameters
-
Definition at line 240 of file msg_buf.c.
◆ msgb_set_sent()
Set sent flag for a message.
- Parameters
-
buf | pointer to PtpMsgBuf object |
msg | pointer to an allocated message |
Definition at line 216 of file msg_buf.c.
◆ msgb_tick()
Tick the storage.
- Parameters
-
Definition at line 226 of file msg_buf.c.