Parse or pack a generic PDU or PDU block.
#include "lwpa_pdu.h"
|
#define | pdu_length(pdu_buf) |
| Get the length from the Length field of a PDU. More...
|
|
#define | pdu_pack_normal_len(pdu_buf, length) |
| Fill in the Length field of a PDU which has a length less than 4096. More...
|
|
#define | pdu_pack_ext_len(pdu_buf, length) |
| Fill in the Length field of a PDU which has a length 4096 or greater. More...
|
|
#define | PDU_INIT |
| Default LwpaPdu initializer values; must be used to intialize a struct pdu when parsing the first PDU in a block. More...
|
|
#define | init_pdu(pduptr) |
| An alternative to PDU_INIT which can be used on an existing LwpaPdu to re-initialize its values. More...
|
|
|
The first byte of each PDU contains a flags field which indicates the inheritance properties of that PDU.
For more information, see ANSI E1.17, ACN Architecture, s. 2.4.
|
#define | l_flag_set(flags_byte) ((bool)(flags_byte & 0x80)) |
| Determine whether the L flag is set in a PDU flags field. More...
|
|
#define | v_flag_set(flags_byte) ((bool)(flags_byte & 0x40)) |
| Determine whether the V flag is set in a PDU flags field. More...
|
|
#define | h_flag_set(flags_byte) ((bool)(flags_byte & 0x20)) |
| Determine whether the H flag is set in a PDU flags field. More...
|
|
#define | d_flag_set(flags_byte) ((bool)(flags_byte & 0x10)) |
| Determine whether the D flag is set in a PDU flags field. More...
|
|
|
The first byte of each PDU contains a flags field which indicates the inheritance properties of that PDU.
For more information, see ANSI E1.17, ACN Architecture, s. 2.4.
|
#define | set_l_flag(flags_byte) (flags_byte |= 0x80) |
| Set the L flag in a PDU flags field. More...
|
|
#define | set_v_flag(flags_byte) (flags_byte |= 0x40) |
| Set the V flag in a PDU flags field. More...
|
|
#define | set_h_flag(flags_byte) (flags_byte |= 0x20) |
| Set the H flag in a PDU flags field. More...
|
|
#define | set_d_flag(flags_byte) (flags_byte |= 0x10) |
| Set the D flag in a PDU flags field. More...
|
|
◆ d_flag_set
#define d_flag_set |
( |
|
flags_byte | ) |
((bool)(flags_byte & 0x10)) |
Determine whether the D flag is set in a PDU flags field.
- Parameters
-
flags_byte | The first byte of the PDU. |
- Returns
- true (the D flag is set) or false (the D flag is not set).
◆ h_flag_set
#define h_flag_set |
( |
|
flags_byte | ) |
((bool)(flags_byte & 0x20)) |
Determine whether the H flag is set in a PDU flags field.
- Parameters
-
flags_byte | The first byte of the PDU. |
- Returns
- true (the H flag is set) or false (the H flag is not set).
◆ init_pdu
#define init_pdu |
( |
|
pduptr | ) |
|
Value: do \
{ \
(pduptr)->pvector = NULL; \
(pduptr)->pheader = NULL; \
(pduptr)->pdata = NULL; \
(pduptr)->datalen = 0; \
(pduptr)->pnextpdu = NULL; \
} while (0)
An alternative to PDU_INIT which can be used on an existing LwpaPdu to re-initialize its values.
- Parameters
-
pduptr | Pointer to LwpaPdu to initialize. |
◆ l_flag_set
#define l_flag_set |
( |
|
flags_byte | ) |
((bool)(flags_byte & 0x80)) |
Determine whether the L flag is set in a PDU flags field.
- Parameters
-
flags_byte | The first byte of the PDU. |
- Returns
- true (the L flag is set) or false (the L flags is not set).
◆ PDU_INIT
Value: { \
NULL, NULL, NULL, 0, NULL \
}
Default LwpaPdu initializer values; must be used to intialize a struct pdu when parsing the first PDU in a block.
◆ pdu_length
#define pdu_length |
( |
|
pdu_buf | ) |
|
Value: ((uint32_t)(
l_flag_set(pdu_buf[0]) ? (((pdu_buf[0] & 0x0f) << 16) | (pdu_buf[1] << 8) | pdu_buf[2]) \
: (((pdu_buf[0] & 0x0f) << 8) | pdu_buf[1])))
#define l_flag_set(flags_byte)
Determine whether the L flag is set in a PDU flags field.
Definition: lwpa_pdu.h:47
Get the length from the Length field of a PDU.
- Parameters
-
pdu_buf | Pointer to the start of the PDU buffer. |
- Returns
- The length of the PDU.
◆ pdu_pack_ext_len
#define pdu_pack_ext_len |
( |
|
pdu_buf, |
|
|
|
length |
|
) |
| |
Value: do \
{ \
(pdu_buf)[0] = (((pdu_buf)[0] & 0xf0) | (((length) >> 16) & 0x0f)); \
(pdu_buf)[1] = (((length) >> 8) & 0xff); \
(pdu_buf)[2] = (length)&0xff; \
} while (0)
Fill in the Length field of a PDU which has a length 4096 or greater.
The L flag of this PDU must be set to 1.
- Parameters
-
pdu_buf | Pointer to the start of the PDU buffer. |
length | Length of this PDU. |
◆ pdu_pack_normal_len
#define pdu_pack_normal_len |
( |
|
pdu_buf, |
|
|
|
length |
|
) |
| |
Value: do \
{ \
(pdu_buf)[0] = (((pdu_buf)[0] & 0xf0) | (((length) >> 8) & 0x0f)); \
(pdu_buf)[1] = (length)&0xff; \
} while (0)
Fill in the Length field of a PDU which has a length less than 4096.
The L flag of this PDU must be set to 0.
- Parameters
-
pdu_buf | Pointer to the start of the PDU buffer. |
length | Length of this PDU. |
◆ set_d_flag
#define set_d_flag |
( |
|
flags_byte | ) |
(flags_byte |= 0x10) |
Set the D flag in a PDU flags field.
- Parameters
-
flags_byte | The first byte of the PDU. |
◆ set_h_flag
#define set_h_flag |
( |
|
flags_byte | ) |
(flags_byte |= 0x20) |
Set the H flag in a PDU flags field.
- Parameters
-
flags_byte | The first byte of the PDU. |
◆ set_l_flag
#define set_l_flag |
( |
|
flags_byte | ) |
(flags_byte |= 0x80) |
Set the L flag in a PDU flags field.
- Parameters
-
flags_byte | The first byte of the PDU. |
◆ set_v_flag
#define set_v_flag |
( |
|
flags_byte | ) |
(flags_byte |= 0x40) |
Set the V flag in a PDU flags field.
- Parameters
-
flags_byte | The first byte of the PDU. |
◆ v_flag_set
#define v_flag_set |
( |
|
flags_byte | ) |
((bool)(flags_byte & 0x40)) |
Determine whether the V flag is set in a PDU flags field.
- Parameters
-
flags_byte | The first byte of the PDU. |
- Returns
- true (the V flag is set) or false (the V flag is not set).
◆ parse_pdu()
Parse a generic PDU.
A function to parse a generic PDU. The specific PDU info needed for parsing is contained in a struct pdu_constraints. Uses LwpaPdu to maintain state across multiple PDUs in a block.
- Parameters
-
[in] | buf | Byte buffer containing a PDU. |
[in] | buflen | Size in bytes of buf. |
[in] | constraints | Specific information about the PDU being parsed |
[in,out] | pdu | PDU data from the last PDU in the block. The data is used and then replaced with data from this PDU. |
- Returns
- true (PDU was parsed successfully) or false (parse error or no more PDUs in the block).