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

alloc unfragmented tx-cmdu with cmdu_alloc_simple()

parent 98ad9d5a
No related branches found
No related tags found
No related merge requests found
...@@ -165,6 +165,33 @@ struct cmdu_buff *cmdu_alloc_default(void) ...@@ -165,6 +165,33 @@ struct cmdu_buff *cmdu_alloc_default(void)
return cmdu_alloc(ETH_FRAME_SZ); return cmdu_alloc(ETH_FRAME_SZ);
} }
struct cmdu_buff *cmdu_alloc_simple(uint16_t type, uint16_t mid)
{
struct cmdu_buff *f;
f = cmdu_alloc_default();
if (!f) {
fprintf(stderr, "%s: -ENOMEM\n", __func__);
return NULL;
}
f->cdata = (struct cmdu_linear *)(f->head + 18);
if (type <= CMDU_TYPE_MAX)
cmdu_set_type(f, type);
if (mid == 0)
mid = cmdu_get_next_mid();
cmdu_set_mid(f, mid);
CMDU_SET_LAST_FRAGMENT(f->cdata);
f->data = (uint8_t *)(f->cdata + 1);
f->tail = f->data;
return f;
}
void cmdu_free(struct cmdu_buff *c) void cmdu_free(struct cmdu_buff *c)
{ {
if (c) { if (c) {
......
...@@ -96,6 +96,8 @@ void tlv_free_linear(struct tlv *t); ...@@ -96,6 +96,8 @@ void tlv_free_linear(struct tlv *t);
struct cmdu_buff *cmdu_alloc(int size); struct cmdu_buff *cmdu_alloc(int size);
struct cmdu_buff *cmdu_alloc_default(void); struct cmdu_buff *cmdu_alloc_default(void);
struct cmdu_buff *cmdu_alloc_simple(uint16_t type, uint16_t mid);
void cmdu_free(struct cmdu_buff *c); void cmdu_free(struct cmdu_buff *c);
static inline void cmdu_set_type(struct cmdu_buff *c, uint16_t type) static inline void cmdu_set_type(struct cmdu_buff *c, uint16_t type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment