Home | History | Annotate | Download | only in api

Lines Matching refs:buf

58   struct netbuf *buf;
60 buf = (struct netbuf *)memp_malloc(MEMP_NETBUF);
61 if (buf != NULL) {
62 buf->p = NULL;
63 buf->ptr = NULL;
64 ip_addr_set_any(&buf->addr);
65 buf->port = 0;
68 buf->flags = 0;
70 buf->toport_chksum = 0;
72 ip_addr_set_any(&buf->toaddr);
75 return buf;
84 * @param buf pointer to a netbuf allocated by netbuf_new()
87 netbuf_delete(struct netbuf *buf)
89 if (buf != NULL) {
90 if (buf->p != NULL) {
91 pbuf_free(buf->p);
92 buf->p = buf->ptr = NULL;
94 memp_free(MEMP_NETBUF, buf);
101 * @param buf the netbuf for which to allocate a packet buffer
107 netbuf_alloc(struct netbuf *buf, u16_t size)
109 LWIP_ERROR("netbuf_alloc: invalid buf", (buf != NULL), return NULL;);
112 if (buf->p != NULL) {
113 pbuf_free(buf->p);
115 buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM);
116 if (buf->p == NULL) {
120 (buf->p->len >= size));
121 buf->ptr = buf->p;
122 return buf->p->payload;
128 * @param buf pointer to the netbuf which contains the packet buffer to free
131 netbuf_free(struct netbuf *buf)
133 LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;);
134 if (buf->p != NULL) {
135 pbuf_free(buf->p);
137 buf->p = buf->ptr = NULL;
143 * @param buf netbuf which should reference the data
150 netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size)
152 LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;);
153 if (buf->p != NULL) {
154 pbuf_free(buf->p);
156 buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF);
157 if (buf->p == NULL) {
158 buf->ptr = NULL;
161 buf->p->payload = (void*)dataptr;
162 buf->p->len = buf->p->tot_len = size;
163 buf->ptr = buf->p;
186 * @param buf netbuf to get the data from
193 netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
195 LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;);
199 if (buf->ptr == NULL) {
202 *dataptr = buf->ptr->payload;
203 *len = buf->ptr->len;
212 * @param buf the netbuf to modify
218 netbuf_next(struct netbuf *buf)
220 LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return -1;);
221 if (buf->ptr->next == NULL) {
224 buf->ptr = buf->ptr->next;
225 if (buf->ptr->next == NULL) {
236 * @param buf the netbuf to modify
239 netbuf_first(struct netbuf *buf)
241 LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;);
242 buf->ptr = buf->p;