44 uint16_t field = type;
99 while (
BLEN(payload) > 0)
107 if (hdr.
type == wanted_type)
static bool buf_write_u16(struct buffer *dest, uint16_t data)
Append a uint16_t to a buffer in network byte order.
static int buf_read_u16(struct buffer *buf)
Read and consume a uint16_t from the front of a buffer.
static uint8_t * buf_read_alloc(struct buffer *buf, int size)
Consume bytes from the front of a buffer for reading.
static bool buf_safe(const struct buffer *buf, size_t len)
Check whether len bytes can be appended to a buffer.
static void buf_set_read(struct buffer *buf, const uint8_t *data, size_t size)
Initialise a buffer with an externally provided read-only memory region.
static bool buf_advance(struct buffer *buf, ssize_t size)
Advance the content start of a buffer, consuming bytes from the front.
#define BLEN(buf)
Return the length of the buffer content in bytes.
bool ctrl_msg_tlv_write_u16(struct buffer *buf, uint16_t type, bool optional, uint16_t value)
Write a complete TLV whose value is a single 16-bit integer to buf.
bool ctrl_msg_tlv_peek_header(const struct buffer *buf, struct ctrl_msg_tlv_header *hdr)
Read a TLV header from buf without consuming it.
bool ctrl_msg_tlv_write_header(struct buffer *buf, uint16_t type, bool optional, uint16_t value_len)
Write a TLV header (type + optional flag + value length) to buf.
bool ctrl_msg_find_tlv(struct buffer *payload, uint16_t wanted_type, struct buffer *value)
Scan payload for the TLV of type wanted_type, skipping any other TLV type that is marked optional.
bool ctrl_msg_tlv_next(struct buffer *buf, struct ctrl_msg_tlv_header *hdr, struct buffer *value)
Read the next TLV from buf, advancing past its header and value.
TLV framing shared by the TLV-based control messages of the wire protocol.
#define CTRL_MSG_TLV_HEADER_LEN
#define CTRL_MSG_TLV_TYPE_MASK
#define CTRL_MSG_TLV_OPTIONAL_FLAG
Wrapper structure for dynamically allocated memory.