82 netbuf *netbuf_new(
void)
88 memset(buf, 0,
sizeof(
struct netbuf));
100 netbuf_delete(
struct netbuf *buf)
103 if (buf->p != NULL) {
105 buf->p = buf->ptr = NULL;
121 netbuf_alloc(
struct netbuf *buf, u16_t size)
123 LWIP_ERROR(
"netbuf_alloc: invalid buf", (buf != NULL),
return NULL;);
126 if (buf->p != NULL) {
130 if (buf->p == NULL) {
133 LWIP_ASSERT(
"check that first pbuf can hold size",
134 (buf->p->len >= size));
136 return buf->p->payload;
146 netbuf_free(
struct netbuf *buf)
148 LWIP_ERROR(
"netbuf_free: invalid buf", (buf != NULL),
return;);
149 if (buf->p != NULL) {
152 buf->p = buf->ptr = NULL;
166 netbuf_ref(
struct netbuf *buf,
const void *dataptr, u16_t size)
168 LWIP_ERROR(
"netbuf_ref: invalid buf", (buf != NULL),
return ERR_ARG;);
169 if (buf->p != NULL) {
173 if (buf->p == NULL) {
177 ((
struct pbuf_rom*)buf->p)->payload = dataptr;
178 buf->p->len = buf->p->tot_len = size;
191 netbuf_chain(
struct netbuf *head,
struct netbuf *tail)
193 LWIP_ERROR(
"netbuf_chain: invalid head", (head != NULL),
return;);
194 LWIP_ERROR(
"netbuf_chain: invalid tail", (tail != NULL),
return;);
211 netbuf_data(
struct netbuf *buf,
void **dataptr, u16_t *len)
213 LWIP_ERROR(
"netbuf_data: invalid buf", (buf != NULL),
return ERR_ARG;);
214 LWIP_ERROR(
"netbuf_data: invalid dataptr", (dataptr != NULL),
return ERR_ARG;);
215 LWIP_ERROR(
"netbuf_data: invalid len", (len != NULL),
return ERR_ARG;);
217 if (buf->ptr == NULL) {
220 *dataptr = buf->ptr->payload;
221 *len = buf->ptr->len;
237 netbuf_next(
struct netbuf *buf)
239 LWIP_ERROR(
"netbuf_next: invalid buf", (buf != NULL),
return -1;);
240 if (buf->ptr->next == NULL) {
243 buf->ptr = buf->ptr->next;
244 if (buf->ptr->next == NULL) {
259 netbuf_first(
struct netbuf *buf)
261 LWIP_ERROR(
"netbuf_first: invalid buf", (buf != NULL),
return;);
void memp_free(memp_t type, void *mem)
void pbuf_cat(struct pbuf *h, struct pbuf *t)
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
u8_t pbuf_free(struct pbuf *p)
void * memp_malloc(memp_t type)