Lines Matching refs:buf

65   struct netbuf *buf;
67 buf = (struct netbuf *)memp_malloc(MEMP_NETBUF);
68 if (buf != NULL) {
69 memset(buf, 0, sizeof(struct netbuf));
71 return buf;
78 * @param buf pointer to a netbuf allocated by netbuf_new()
81 netbuf_delete(struct netbuf *buf)
83 if (buf != NULL) {
84 if (buf->p != NULL) {
85 pbuf_free(buf->p);
86 buf->p = buf->ptr = NULL;
88 memp_free(MEMP_NETBUF, buf);
96 * @param buf the netbuf for which to allocate a packet buffer
102 netbuf_alloc(struct netbuf *buf, u16_t size)
104 LWIP_ERROR("netbuf_alloc: invalid buf", (buf != NULL), return NULL;);
107 if (buf->p != NULL) {
108 pbuf_free(buf->p);
110 buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM);
111 if (buf->p == NULL) {
115 (buf->p->len >= size));
116 buf->ptr = buf->p;
117 return buf->p->payload;
124 * @param buf pointer to the netbuf which contains the packet buffer to free
127 netbuf_free(struct netbuf *buf)
129 LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;);
130 if (buf->p != NULL) {
131 pbuf_free(buf->p);
133 buf->p = buf->ptr = NULL;
135 buf->flags = 0;
136 buf->toport_chksum = 0;
144 * @param buf netbuf which should reference the data
151 netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size)
153 LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;);
154 if (buf->p != NULL) {
155 pbuf_free(buf->p);
157 buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF);
158 if (buf->p == NULL) {
159 buf->ptr = NULL;
162 ((struct pbuf_rom *)buf->p)->payload = dataptr;
163 buf->p->len = buf->p->tot_len = size;
164 buf->ptr = buf->p;
189 * @param buf netbuf to get the data from
196 netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
198 LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;);
202 if (buf->ptr == NULL) {
205 *dataptr = buf->ptr->payload;
206 *len = buf->ptr->len;
216 * @param buf the netbuf to modify
222 netbuf_next(struct netbuf *buf)
224 LWIP_ERROR("netbuf_next: invalid buf", (buf != NULL), return -1;);
225 if (buf->ptr->next == NULL) {
228 buf->ptr = buf->ptr->next;
229 if (buf->ptr->next == NULL) {
241 * @param buf the netbuf to modify
244 netbuf_first(struct netbuf *buf)
246 LWIP_ERROR("netbuf_first: invalid buf", (buf != NULL), return;);
247 buf->ptr = buf->p;