28 for (uint32_t i = 0; i < buf->
n; i++) {
65 for (uint32_t i = 0; i < buf->
n; i++) {
96#define RAW_MSG_TO_BLOCK(rmsg) ((PtpMsgBufBlock *)(((uint8_t *)(rmsg)) - (sizeof(PtpMsgBufBlock) - sizeof(RawPtpMessage))))
128 if (buf->
used == 0) {
133 for (uint32_t i = 0; i < buf->
n; i++) {
136 ((oldestBlock == NULL) || (block->
uid < oldestBlock->
uid))) {
148 return &(block->
msg);
161 for (uint32_t i = 0; i < buf->
n; i++) {
175 return &(block->
msg);
188 for (uint32_t i = 0; i < buf->
n; i++) {
202 return &(block->
msg);
227 for (uint32_t i = 0; i < buf->
n; i++) {
230 if (block->
ttl == 0) {
234 block->
ttl = (block->
ttl > 0) ? (block->
ttl - 1) : block->
ttl;
241 MSG(
"----------------------------------\n");
242 for (uint32_t i = 0; i < buf->
n; i++) {
245 MSG(
"[% 3u] A % 8X % 8X % 4u %c %c\n", i, block->
tag, block->
uid, block->
ttl, block->
committed ?
'C' :
' ', block->
sent ?
'S' :
' ');
247 MSG(
"[% 3u] F -------------------\n", i);
250 MSG(
"----------------------------------\n");
void msgb_set_sent(PtpMsgBuf *buf, RawPtpMessage *msg)
static PtpMsgBufBlock * msgb_get_oldest_block(PtpMsgBuf *buf)
RawPtpMessage * msgb_get_oldest(PtpMsgBuf *buf)
static void msgb_set_block_sent(PtpMsgBuf *buf, PtpMsgBufBlock *block)
RawPtpMessage * msgb_get_by_uid(PtpMsgBuf *buf, uint32_t uid)
static PtpMsgBufBlock * msgb_get_entry_by_tag(PtpMsgBuf *buf, uint32_t tag)
static PtpMsgBufBlock * msgb_get_block_by_uid(PtpMsgBuf *buf, uint32_t uid)
void msgb_report(PtpMsgBuf *buf)
void msgb_init(PtpMsgBuf *buf, PtpMsgBufBlock *pool, uint32_t n)
void msgb_commit(PtpMsgBuf *buf, RawPtpMessage *msg)
RawPtpMessage * msgb_get_sent_by_tag(PtpMsgBuf *buf, uint32_t tag)
uint32_t msgb_get_uid(const PtpMsgBuf *buf, const RawPtpMessage *msg)
static void msgb_free_block(PtpMsgBuf *buf, PtpMsgBufBlock *block)
#define MSGB_DEBUG
Message buffer debugging.
static PtpMsgBufBlock * msgb_get_sent_block_by_tag(PtpMsgBuf *buf, uint32_t tag)
RawPtpMessage * msgb_alloc(PtpMsgBuf *buf, uint32_t tag, uint32_t ttl)
#define RAW_MSG_TO_BLOCK(rmsg)
Get block address by message address.
void msgb_free(PtpMsgBuf *buf, RawPtpMessage *msg)
void msgb_tick(PtpMsgBuf *buf)
uint32_t msgb_get_error(PtpMsgBuf *buf)
#define MSGBUF_TTL_DONT_AGE
Do not age messages.
#define MSGBUF_TAG_OVERWRITE
Overwrite if a message exists with the same tag.
PtpMsgBufError
Error enumeration for the message buffer.
Core of the PTP implementation. Defines functions for message processing, clock tuning,...
PTP message buffer entry.
bool allocated
This block has been allocated.
bool committed
This block has been committed.
RawPtpMessage msg
The contained PTP message.
bool sent
This block has been sent.
uint32_t ttl
Time-to-Live in ticks.
uint32_t uid
Unique ID, a sequence number.
PtpMsgBufBlock * blocks
Block pool.
uint32_t n
Number of blocks.
uint32_t used
Number of used blocks.
uint32_t lastUId
Last UID.
uint32_t error
Last error.