2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without modification,
\r
6 * are permitted provided that the following conditions are met:
\r
8 * 1. Redistributions of source code must retain the above copyright notice,
\r
9 * this list of conditions and the following disclaimer.
\r
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
11 * this list of conditions and the following disclaimer in the documentation
\r
12 * and/or other materials provided with the distribution.
\r
13 * 3. The name of the author may not be used to endorse or promote products
\r
14 * derived from this software without specific prior written permission.
\r
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
\r
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
\r
19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
\r
21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
\r
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
\r
27 * This file is part of the lwIP TCP/IP stack.
\r
29 * Author: Adam Dunkels <adam@sics.se>
\r
33 #ifndef __LWIP_PBUF_H__
\r
34 #define __LWIP_PBUF_H__
\r
36 #include "lwip/opt.h"
\r
37 #include "lwip/err.h"
\r
43 #define PBUF_TRANSPORT_HLEN 20
\r
44 #define PBUF_IP_HLEN 20
\r
54 PBUF_RAM, /* pbuf data is stored in RAM */
\r
55 PBUF_ROM, /* pbuf data is stored in ROM */
\r
56 PBUF_REF, /* pbuf comes from the pbuf pool */
\r
57 PBUF_POOL /* pbuf payload refers to RAM */
\r
61 /** indicates this packet's data should be immediately passed to the application */
\r
62 #define PBUF_FLAG_PUSH 0x01U
\r
65 /** next pbuf in singly linked pbuf chain */
\r
68 /** pointer to the actual data in the buffer */
\r
72 * total length of this buffer and all next buffers in chain
\r
73 * belonging to the same packet.
\r
75 * For non-queue packet chains this is the invariant:
\r
76 * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
\r
80 /** length of this buffer */
\r
83 /** pbuf_type as u8_t instead of enum to save space */
\r
84 u8_t /*pbuf_type*/ type;
\r
90 * the reference count always equals the number of pointers
\r
91 * that refer to this pbuf. This can be pointers from an application,
\r
92 * the stack itself, or pbuf->next pointers from a chain.
\r
98 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
\r
101 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type);
\r
102 void pbuf_realloc(struct pbuf *p, u16_t size);
\r
103 u8_t pbuf_header(struct pbuf *p, s16_t header_size);
\r
104 void pbuf_ref(struct pbuf *p);
\r
105 void pbuf_ref_chain(struct pbuf *p);
\r
106 u8_t pbuf_free(struct pbuf *p);
\r
107 u8_t pbuf_clen(struct pbuf *p);
\r
108 void pbuf_cat(struct pbuf *head, struct pbuf *tail);
\r
109 void pbuf_chain(struct pbuf *head, struct pbuf *tail);
\r
110 struct pbuf *pbuf_dechain(struct pbuf *p);
\r
111 err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
\r
112 u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
\r
118 #endif /* __LWIP_PBUF_H__ */
\r