Lines Matching refs:buf
58 struct netbuf *buf; in netbuf_new() local
60 buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); in netbuf_new()
61 if (buf != NULL) { in netbuf_new()
62 buf->p = NULL; in netbuf_new()
63 buf->ptr = NULL; in netbuf_new()
64 ip_addr_set_any(&buf->addr); in netbuf_new()
65 buf->port = 0; in netbuf_new()
68 buf->flags = 0; in netbuf_new()
70 buf->toport_chksum = 0; in netbuf_new()
72 ip_addr_set_any(&buf->toaddr); in netbuf_new()
75 return buf; in netbuf_new()
87 netbuf_delete(struct netbuf *buf) in netbuf_delete() argument
89 if (buf != NULL) { in netbuf_delete()
90 if (buf->p != NULL) { in netbuf_delete()
91 pbuf_free(buf->p); in netbuf_delete()
92 buf->p = buf->ptr = NULL; in netbuf_delete()
94 memp_free(MEMP_NETBUF, buf); in netbuf_delete()
107 netbuf_alloc(struct netbuf *buf, u16_t size) in netbuf_alloc() argument
109 LWIP_ERROR("netbuf_alloc: invalid buf", (buf != NULL), return NULL;); in netbuf_alloc()
112 if (buf->p != NULL) { in netbuf_alloc()
113 pbuf_free(buf->p); in netbuf_alloc()
115 buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM); in netbuf_alloc()
116 if (buf->p == NULL) { in netbuf_alloc()
120 (buf->p->len >= size)); in netbuf_alloc()
121 buf->ptr = buf->p; in netbuf_alloc()
122 return buf->p->payload; in netbuf_alloc()
131 netbuf_free(struct netbuf *buf) in netbuf_free() argument
133 LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;); in netbuf_free()
134 if (buf->p != NULL) { in netbuf_free()
135 pbuf_free(buf->p); in netbuf_free()
137 buf->p = buf->ptr = NULL; in netbuf_free()
150 netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size) in netbuf_ref() argument
152 LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;); in netbuf_ref()
153 if (buf->p != NULL) { in netbuf_ref()
154 pbuf_free(buf->p); in netbuf_ref()
156 buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF); in netbuf_ref()
157 if (buf->p == NULL) { in netbuf_ref()
158 buf->ptr = NULL; in netbuf_ref()
161 buf->p->payload = (void*)dataptr; in netbuf_ref()
162 buf->p->len = buf->p->tot_len = size; in netbuf_ref()
163 buf->ptr = buf->p; in netbuf_ref()
193 netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len) in netbuf_data() argument
195 LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;); in netbuf_data()
199 if (buf->ptr == NULL) { in netbuf_data()
202 *dataptr = buf->ptr->payload; in netbuf_data()
203 *len = buf->ptr->len; in netbuf_data()
218 netbuf_next(struct netbuf *buf) in netbuf_next() argument
220 LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return -1;); in netbuf_next()
221 if (buf->ptr->next == NULL) { in netbuf_next()
224 buf->ptr = buf->ptr->next; in netbuf_next()
225 if (buf->ptr->next == NULL) { in netbuf_next()
239 netbuf_first(struct netbuf *buf) in netbuf_first() argument
241 LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;); in netbuf_first()
242 buf->ptr = buf->p; in netbuf_first()