22 #ifndef ETCPAL_ACN_PDU_H_
23 #define ETCPAL_ACN_PDU_H_
57 #define ACN_PDU_L_FLAG_SET(flags_byte) ((bool)((flags_byte)&0x80u))
64 #define ACN_PDU_V_FLAG_SET(flags_byte) ((bool)((flags_byte)&0x40u))
71 #define ACN_PDU_H_FLAG_SET(flags_byte) ((bool)((flags_byte)&0x20u))
78 #define ACN_PDU_D_FLAG_SET(flags_byte) ((bool)((flags_byte)&0x10u))
89 #define ACN_PDU_LENGTH(pdu_buf) \
90 ((uint32_t)(ACN_PDU_L_FLAG_SET(pdu_buf[0]) \
91 ? ((uint32_t)((pdu_buf[0] & 0x0fu) << 16) | (uint32_t)(pdu_buf[1] << 8) | (uint32_t)pdu_buf[2]) \
92 : ((uint32_t)((pdu_buf[0] & 0x0fu) << 8) | (uint32_t)pdu_buf[1])))
105 #define ACN_PDU_SET_L_FLAG(flags_byte) (flags_byte |= 0x80u)
111 #define ACN_PDU_SET_V_FLAG(flags_byte) (flags_byte |= 0x40u)
117 #define ACN_PDU_SET_H_FLAG(flags_byte) (flags_byte |= 0x20u)
123 #define ACN_PDU_SET_D_FLAG(flags_byte) (flags_byte |= 0x10u)
137 #define ACN_PDU_PACK_NORMAL_LEN(pdu_buf, length) \
140 (pdu_buf)[0] = (uint8_t)(((pdu_buf)[0] & 0xf0) | (((length) >> 8) & 0x0fu)); \
141 (pdu_buf)[1] = (uint8_t)(length)&0xffu; \
152 #define ACN_PDU_PACK_EXT_LEN(pdu_buf, length) \
155 (pdu_buf)[0] = (uint8_t)(((pdu_buf)[0] & 0xf0) | (((length) >> 16) & 0x0fu)); \
156 (pdu_buf)[1] = (uint8_t)(((length) >> 8) & 0xffu); \
157 (pdu_buf)[2] = (uint8_t)(length)&0xffu; \
172 #define ACN_PDU_INIT \
174 NULL, NULL, NULL, 0, NULL \
183 #define ACN_INIT_PDU(pduptr) \
186 (pduptr)->pvector = NULL; \
187 (pduptr)->pheader = NULL; \
188 (pduptr)->pdata = NULL; \
189 (pduptr)->data_len = 0; \
190 (pduptr)->pnextpdu = NULL; \
struct AcnPdu AcnPdu
Holds state data used when parsing multiple PDUs in a PDU block.
struct AcnPduConstraints AcnPduConstraints
Contains specific PDU info used by the generic helper acn_parse_pdu().
bool acn_parse_pdu(const uint8_t *buf, size_t buflen, const AcnPduConstraints *constraints, AcnPdu *pdu)
Parse a generic ACN PDU.
Definition: acn_pdu.c:35
Contains specific PDU info used by the generic helper acn_parse_pdu().
Definition: acn_pdu.h:195
size_t vector_size
The size of the Vector segment of this PDU.
Definition: acn_pdu.h:196
size_t header_size
The size of the Header segment of this PDU.
Definition: acn_pdu.h:197
Holds state data used when parsing multiple PDUs in a PDU block.
Definition: acn_pdu.h:162
const uint8_t * pvector
Pointer to the most recent PDU's vector.
Definition: acn_pdu.h:163
const uint8_t * pdata
Pointer to the most recent PDU's data.
Definition: acn_pdu.h:165
const uint8_t * pnextpdu
Pointer to the beginning of the next PDU.
Definition: acn_pdu.h:167
const uint8_t * pheader
Pointer to the most recent PDU's header.
Definition: acn_pdu.h:164
size_t data_len
Length of the PDU's data section.
Definition: acn_pdu.h:166