ReactOS  0.4.14-dev-41-g31d7680
pbuf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 
33 #ifndef __LWIP_PBUF_H__
34 #define __LWIP_PBUF_H__
35 
36 #include "lwip/opt.h"
37 #include "lwip/err.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
45 #define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF)
46 
47 #define PBUF_TRANSPORT_HLEN 20
48 #define PBUF_IP_HLEN 20
49 
50 typedef enum {
55 } pbuf_layer;
56 
57 typedef enum {
58  PBUF_RAM, /* pbuf data is stored in RAM */
59  PBUF_ROM, /* pbuf data is stored in ROM */
60  PBUF_REF, /* pbuf comes from the pbuf pool */
61  PBUF_POOL /* pbuf payload refers to RAM */
62 } pbuf_type;
63 
64 
66 #define PBUF_FLAG_PUSH 0x01U
67 
69 #define PBUF_FLAG_IS_CUSTOM 0x02U
70 
71 #define PBUF_FLAG_MCASTLOOP 0x04U
72 
73 #define PBUF_FLAG_LLBCAST 0x08U
74 
75 #define PBUF_FLAG_LLMCAST 0x10U
76 
77 #define PBUF_FLAG_TCP_FIN 0x20U
78 
79 struct pbuf {
81  struct pbuf *next;
82 
84  void *payload;
85 
94 
97 
99  u8_t /*pbuf_type*/ type;
100 
103 
110 };
111 
112 #if LWIP_SUPPORT_CUSTOM_PBUF
113 
114 typedef void (*pbuf_free_custom_fn)(struct pbuf *p);
115 
117 struct pbuf_custom {
119  struct pbuf pbuf;
121  pbuf_free_custom_fn custom_free_function;
122 };
123 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
124 
125 #if LWIP_TCP && TCP_QUEUE_OOSEQ
126 
127 #ifndef PBUF_POOL_FREE_OOSEQ
128 #define PBUF_POOL_FREE_OOSEQ 1
129 #endif /* PBUF_POOL_FREE_OOSEQ */
130 #if NO_SYS && PBUF_POOL_FREE_OOSEQ
131 extern volatile u8_t pbuf_free_ooseq_pending;
132 void pbuf_free_ooseq();
136 #define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \
137  /* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \
138  ooseq queued pbufs now */ \
139  pbuf_free_ooseq(); }}while(0)
140 #endif /* NO_SYS && PBUF_POOL_FREE_OOSEQ*/
141 #endif /* LWIP_TCP && TCP_QUEUE_OOSEQ */
142 
143 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
144 #define pbuf_init()
145 
147 #if LWIP_SUPPORT_CUSTOM_PBUF
148 struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type,
149  struct pbuf_custom *p, void *payload_mem,
150  u16_t payload_mem_len);
151 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
152 void pbuf_realloc(struct pbuf *p, u16_t size);
153 u8_t pbuf_header(struct pbuf *p, s16_t header_size);
154 void pbuf_ref(struct pbuf *p);
155 u8_t pbuf_free(struct pbuf *p);
156 u8_t pbuf_clen(struct pbuf *p);
157 void pbuf_cat(struct pbuf *head, struct pbuf *tail);
158 void pbuf_chain(struct pbuf *head, struct pbuf *tail);
159 struct pbuf *pbuf_dechain(struct pbuf *p);
160 err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
162 err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
163 struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
164 #if LWIP_CHECKSUM_ON_COPY
165 err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
166  u16_t len, u16_t *chksum);
167 #endif /* LWIP_CHECKSUM_ON_COPY */
168 
169 u8_t pbuf_get_at(struct pbuf* p, u16_t offset);
170 u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n);
171 u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);
172 u16_t pbuf_strstr(struct pbuf* p, const char* substr);
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* __LWIP_PBUF_H__ */
u16_t pbuf_memcmp(struct pbuf *p, u16_t offset, const void *s2, u16_t n)
Definition: pbuf.c:1104
u16_t tot_len
Definition: pbuf.h:93
void pbuf_chain(struct pbuf *head, struct pbuf *tail)
Definition: pbuf.c:786
struct S2 s2
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
struct outqueuenode * tail
Definition: adnsresfilter.c:66
struct pbuf * next
Definition: pbuf.h:81
u16_t len
Definition: pbuf.h:96
struct outqueuenode * head
Definition: adnsresfilter.c:66
u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset)
Definition: pbuf.c:918
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
u8_t pbuf_clen(struct pbuf *p)
Definition: pbuf.c:704
GLintptr offset
Definition: glext.h:5920
GLdouble n
Definition: glext.h:7729
struct pbuf * pbuf_dechain(struct pbuf *p)
Definition: pbuf.c:803
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:618
void pbuf_ref(struct pbuf *p)
Definition: pbuf.c:723
u8_t pbuf_header(struct pbuf *p, s16_t header_size)
Definition: pbuf.c:511
Definition: pbuf.h:58
Definition: pbuf.h:53
u8_t pbuf_get_at(struct pbuf *p, u16_t offset)
Definition: pbuf.c:1077
s8_t err_t
Definition: err.h:47
Definition: pbuf.h:54
u8_t flags
Definition: pbuf.h:102
r l[0]
Definition: byte_order.h:167
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
u16_t pbuf_strstr(struct pbuf *p, const char *substr)
Definition: pbuf.c:1168
GLsizeiptr size
Definition: glext.h:5919
Definition: pbuf.h:79
void pbuf_cat(struct pbuf *head, struct pbuf *tail)
Definition: pbuf.c:745
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
Definition: pbuf.h:61
Definition: pbuf.h:59
GLenum GLsizei len
Definition: glext.h:6722
pbuf_type
Definition: pbuf.h:57
struct pbuf * pbuf_coalesce(struct pbuf *p, pbuf_layer layer)
Definition: pbuf.c:1010
static u32_t chksum(void *dataptr, u16_t len)
Definition: inet6.c:55
Definition: pbuf.h:60
unsigned char u8_t
Definition: cc.h:23
void * payload
Definition: pbuf.h:84
Definition: mem.c:156
err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
Definition: pbuf.c:852
void pbuf_realloc(struct pbuf *p, u16_t size)
Definition: pbuf.c:430
Definition: pbuf.h:52
u16_t pbuf_memfind(struct pbuf *p, const void *mem, u16_t mem_len, u16_t start_offset)
Definition: pbuf.c:1140
int const JOCTET * dataptr
Definition: jpeglib.h:1027
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)
Definition: pbuf.c:966
struct pbuf * pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type)
Definition: pbuf.c:207
u8_t type
Definition: pbuf.h:99
unsigned short u16_t
Definition: cc.h:24
static substr_t substr(const WCHAR *str, size_t len)
Definition: internet.h:204
pbuf_layer
Definition: pbuf.h:50
GLfloat GLfloat p
Definition: glext.h:8902
u16_t ref
Definition: pbuf.h:109
signed short s16_t
Definition: cc.h:29