Skip to content
Snippets Groups Projects
Commit 30ba1e75 authored by Anjan Chanda's avatar Anjan Chanda
Browse files

reserve space for tlv with cmdu_reserve_tlv()

parent 7c40b0a2
Branches
Tags
No related merge requests found
......@@ -348,6 +348,23 @@ int cmdu_put_eom(struct cmdu_buff *c)
return cmdu_put(c, eom, sizeof(eom));
}
struct tlv *cmdu_reserve_tlv(struct cmdu_buff *c, uint16_t tlv_datalen)
{
uint16_t len = tlv_datalen + TLV_HLEN;
if (!c)
return NULL;
if (c->end - c->tail < len) {
fprintf(stderr, "%s: Failed to reserve %hu! Allocate new cmdu fragment\n",
__func__, tlv_datalen);
return NULL;
}
return (struct tlv *)c->tail;
}
int cmdu_parse_tlvs(struct cmdu_buff *c, struct tlv *tv[][16],
struct tlv_policy *policy, int policy_len)
{
......
......@@ -159,6 +159,7 @@ int cmdu_parse_tlvs(struct cmdu_buff *c, struct tlv *tv[][16],
int cmdu_copy_tlvs_linear(struct cmdu_buff *c, uint8_t *tlvs, uint32_t tlvslen);
int cmdu_copy_tlvs(struct cmdu_buff *c, struct tlv *tv[], int tv_arrsize);
struct tlv *cmdu_reserve_tlv(struct cmdu_buff *c, uint16_t tlv_datalen);
int cmdu_put_tlv(struct cmdu_buff *c, struct tlv *t);
int cmdu_put(struct cmdu_buff *c, uint8_t *bytes, int len);
int cmdu_put_eom(struct cmdu_buff *c);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment