]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/lwIP_MCF5235_GCC/lwip/src/include/lwip/pbuf.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / lwIP_MCF5235_GCC / lwip / src / include / lwip / pbuf.h
1 /*\r
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.\r
3  * All rights reserved. \r
4  * \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
7  *\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
15  *\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
25  * OF SUCH DAMAGE.\r
26  *\r
27  * This file is part of the lwIP TCP/IP stack.\r
28  * \r
29  * Author: Adam Dunkels <adam@sics.se>\r
30  *\r
31  */\r
32 \r
33 #ifndef __LWIP_PBUF_H__\r
34 #define __LWIP_PBUF_H__\r
35 \r
36 #include "arch/cc.h"\r
37 \r
38 \r
39 #define PBUF_TRANSPORT_HLEN 20\r
40 #define PBUF_IP_HLEN        20\r
41 \r
42 typedef enum {\r
43   PBUF_TRANSPORT,\r
44   PBUF_IP,\r
45   PBUF_LINK,\r
46   PBUF_RAW\r
47 } pbuf_layer;\r
48 \r
49 typedef enum {\r
50   PBUF_RAM,\r
51   PBUF_ROM,\r
52   PBUF_REF,\r
53   PBUF_POOL\r
54 } pbuf_flag;\r
55 \r
56 /* Definitions for the pbuf flag field. These are NOT the flags that\r
57  * are passed to pbuf_alloc(). */\r
58 #define PBUF_FLAG_RAM   0x00U    /* Flags that pbuf data is stored in RAM */\r
59 #define PBUF_FLAG_ROM   0x01U    /* Flags that pbuf data is stored in ROM */\r
60 #define PBUF_FLAG_POOL  0x02U    /* Flags that the pbuf comes from the pbuf pool */\r
61 #define PBUF_FLAG_REF   0x04U    /* Flags thet the pbuf payload refers to RAM */\r
62 \r
63 /** indicates this packet was broadcast on the link */\r
64 #define PBUF_FLAG_LINK_BROADCAST 0x80U\r
65 \r
66 struct pbuf {\r
67   /** next pbuf in singly linked pbuf chain */\r
68   struct pbuf *next;\r
69 \r
70   /** pointer to the actual data in the buffer */\r
71   void *payload;\r
72   \r
73   /**\r
74    * total length of this buffer and all next buffers in chain\r
75    * belonging to the same packet.\r
76    *\r
77    * For non-queue packet chains this is the invariant:\r
78    * p->tot_len == p->len + (p->next? p->next->tot_len: 0)\r
79    */\r
80   u16_t tot_len;\r
81   \r
82   /** length of this buffer */\r
83   u16_t len;  \r
84 \r
85   /** flags telling the type of pbuf, see PBUF_FLAG_ */\r
86   u16_t flags;\r
87   \r
88   /**\r
89    * the reference count always equals the number of pointers\r
90    * that refer to this pbuf. This can be pointers from an application,\r
91    * the stack itself, or pbuf->next pointers from a chain.\r
92    */\r
93   u16_t ref;\r
94   \r
95 };\r
96 \r
97 void pbuf_init(void);\r
98 \r
99 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag);\r
100 void pbuf_realloc(struct pbuf *p, u16_t size); \r
101 u8_t pbuf_header(struct pbuf *p, s16_t header_size);\r
102 void pbuf_ref(struct pbuf *p);\r
103 void pbuf_ref_chain(struct pbuf *p);\r
104 u8_t pbuf_free(struct pbuf *p);\r
105 u8_t pbuf_clen(struct pbuf *p);  \r
106 void pbuf_cat(struct pbuf *h, struct pbuf *t);\r
107 void pbuf_chain(struct pbuf *h, struct pbuf *t);\r
108 struct pbuf *pbuf_take(struct pbuf *f);\r
109 struct pbuf *pbuf_dechain(struct pbuf *p);\r
110 void pbuf_queue(struct pbuf *p, struct pbuf *n);\r
111 struct pbuf * pbuf_dequeue(struct pbuf *p);\r
112 \r
113 #endif /* __LWIP_PBUF_H__ */\r