80#if LWIP_TCP && TCP_QUEUE_OOSEQ
83#if LWIP_CHECKSUM_ON_COPY
89#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))
92#define PBUF_POOL_BUFSIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE)
94static const struct pbuf *
97#if !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ
98#define PBUF_POOL_IS_EMPTY()
102#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL
104#define PBUF_POOL_FREE_OOSEQ_QUEUE_CALL() do { \
105 if (tcpip_try_callback(pbuf_free_ooseq_callback, NULL) != ERR_OK) { \
106 SYS_ARCH_PROTECT(old_level); \
107 pbuf_free_ooseq_pending = 0; \
108 SYS_ARCH_UNPROTECT(old_level); \
113volatile u8_t pbuf_free_ooseq_pending;
114#define PBUF_POOL_IS_EMPTY() pbuf_pool_is_empty()
133 for (pcb = tcp_active_pcbs;
NULL != pcb; pcb = pcb->
next) {
134 if (pcb->ooseq !=
NULL) {
148pbuf_free_ooseq_callback(
void *
arg)
157pbuf_pool_is_empty(
void)
159#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL
165 queued = pbuf_free_ooseq_pending;
166 pbuf_free_ooseq_pending = 1;
171 PBUF_POOL_FREE_OOSEQ_QUEUE_CALL();
182 p->payload = payload;
183 p->tot_len = tot_len;
255 rem_len, qlen,
type, 0);
256 LWIP_ASSERT(
"pbuf_alloc: pbuf q->payload properly aligned",
258 LWIP_ASSERT(
"PBUF_POOL_BUFSIZE must be bigger than MEM_ALIGNMENT",
268 rem_len = (
u16_t)(rem_len - qlen);
270 }
while (rem_len > 0);
290 LWIP_ASSERT(
"pbuf_alloc: pbuf->payload properly aligned",
335 (
"pbuf_alloc_reference: Could not allocate MEMP_PBUF for PBUF_%s.\n",
344#if LWIP_SUPPORT_CUSTOM_PBUF
364 void *payload_mem,
u16_t payload_mem_len)
375 if (payload_mem !=
NULL) {
411 if (new_len >=
p->tot_len) {
418 shrink = (
u16_t)(
p->tot_len - new_len);
424 while (rem_len >
q->len) {
426 rem_len = (
u16_t)(rem_len -
q->len);
428 q->tot_len = (
u16_t)(
q->tot_len - shrink);
455 if (
q->next !=
NULL) {
480 u16_t increment_magnitude;
483 if ((
p ==
NULL) || (header_size_increment > 0xFFFF)) {
486 if (header_size_increment == 0) {
490 increment_magnitude = (
u16_t)header_size_increment;
492 if ((
u16_t)(increment_magnitude +
p->tot_len) < increment_magnitude) {
505 (
"pbuf_add_header: failed as %p < %p (not enough space for new header size)\n",
522 (
void *)
p->payload, (
void *)
payload, increment_magnitude));
526 p->len = (
u16_t)(
p->len + increment_magnitude);
527 p->tot_len = (
u16_t)(
p->tot_len + increment_magnitude);
588 u16_t increment_magnitude;
591 if ((
p ==
NULL) || (header_size_decrement > 0xFFFF)) {
594 if (header_size_decrement == 0) {
598 increment_magnitude = (
u16_t)header_size_decrement;
600 LWIP_ERROR(
"increment_magnitude <= p->len", (increment_magnitude <= p->
len),
return 1;);
607 p->payload = (
u8_t *)
p->payload + header_size_decrement;
609 p->len = (
u16_t)(
p->len - increment_magnitude);
610 p->tot_len = (
u16_t)(
p->tot_len - increment_magnitude);
613 (
void *)
payload, (
void *)
p->payload, increment_magnitude));
621 if (header_size_increment < 0) {
678 while (free_left &&
p) {
679 if (free_left >=
p->len) {
681 free_left = (
u16_t)(free_left -
p->len);
737 (
"pbuf_free(p == NULL) was called.\n"));
765#if LWIP_SUPPORT_CUSTOM_PBUF
768 struct pbuf_custom *pc = (
struct pbuf_custom *)
p;
769 LWIP_ASSERT(
"pc->custom_free_function != NULL", pc->custom_free_function !=
NULL);
770 pc->custom_free_function(
p);
859 LWIP_ERROR(
"(h != NULL) && (t != NULL) (programmer violates API)",
865 p->tot_len = (
u16_t)(
p->tot_len +
t->tot_len);
868 LWIP_ASSERT(
"p->tot_len == p->len (of last pbuf in chain)",
p->tot_len ==
p->len);
871 p->tot_len = (
u16_t)(
p->tot_len +
t->tot_len);
923 LWIP_ASSERT(
"p->tot_len == p->len + q->tot_len",
q->tot_len ==
p->tot_len -
p->len);
925 q->tot_len = (
u16_t)(
p->tot_len -
p->len);
935 (
"pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (
void *)
q));
941 return ((tail_gone > 0) ?
NULL :
q);
962 (
const void *)p_to, (
const void *)p_from));
988 size_t offset_to =
offset, offset_from = 0,
len;
991 (
const void *)p_to, (
const void *)p_from, copy_len,
offset));
994 LWIP_ERROR(
"pbuf_copy_partial_pbuf: copy_len bigger than source", ((p_from !=
NULL) &&
997 LWIP_ERROR(
"pbuf_copy_partial_pbuf: target not big enough", ((p_to !=
NULL) &&
1003 if ((p_to->
len - offset_to) >= (p_from->
len - offset_from)) {
1005 len = p_from->
len - offset_from;
1008 len = p_to->
len - offset_to;
1014 copy_len = (
u16_t)(copy_len -
len);
1016 LWIP_ASSERT(
"offset_from <= p_from->len", offset_from <= p_from->
len);
1017 if (offset_from >= p_from->
len) {
1020 p_from = p_from->
next;
1023 if (offset_to == p_to->
len) {
1032 LWIP_ERROR(
"pbuf_copy_partial_pbuf() does not allow packet queues!",
1037 LWIP_ERROR(
"pbuf_copy_partial_pbuf() does not allow packet queues!",
1060 const struct pbuf *
p;
1063 u16_t copied_total = 0;
1076 if (buf_copy_len >
len) {
1081 copied_total = (
u16_t)(copied_total + buf_copy_len);
1087 return copied_total;
1107 const struct pbuf *
q;
1116 if (
q->len >= (out_offset +
len)) {
1118 return (
u8_t *)
q->payload + out_offset;
1131#if LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE
1144void pbuf_split_64k(
struct pbuf *
p,
struct pbuf **rest)
1148 u16_t tot_len_front =
p->len;
1153 while ((
r !=
NULL) && ((
u16_t)(tot_len_front +
r->len) >= tot_len_front)) {
1154 tot_len_front = (
u16_t)(tot_len_front +
r->len);
1165 i->tot_len = (
u16_t)(
i->tot_len -
r->tot_len);
1167 (
i->next !=
NULL) || (
i->tot_len ==
i->len));
1182static const struct pbuf *
1185 u16_t offset_left = in_offset;
1189 while ((
q !=
NULL) && (
q->len <= offset_left)) {
1190 offset_left = (
u16_t)(offset_left -
q->len);
1193 if (out_offset !=
NULL) {
1194 *out_offset = offset_left;
1230 size_t buf_copy_len;
1231 size_t total_copy_len =
len;
1232 size_t copied_total = 0;
1243 for (
p =
buf; total_copy_len != 0;
p =
p->next) {
1245 buf_copy_len = total_copy_len;
1246 if (buf_copy_len >
p->len) {
1248 buf_copy_len =
p->len;
1251 MEMCPY(
p->payload, &((
const char *)
dataptr)[copied_total], buf_copy_len);
1252 total_copy_len -= buf_copy_len;
1253 copied_total += buf_copy_len;
1255 LWIP_ASSERT(
"did not copy all data", total_copy_len == 0 && copied_total ==
len);
1273 u16_t target_offset;
1277 if ((
q !=
NULL) && (
q->tot_len >= target_offset +
len)) {
1281 u16_t first_copy_len;
1285 remaining_len = (
u16_t)(remaining_len - first_copy_len);
1286 src_ptr += first_copy_len;
1287 if (remaining_len > 0) {
1288 return pbuf_take(
q->next, src_ptr, remaining_len);
1312 if (
p->next ==
NULL) {
1351#if LWIP_CHECKSUM_ON_COPY
1376 if ((start_offset >=
p->len) || (start_offset +
len >
p->len)) {
1380 dst_ptr = ((
char *)
p->payload) + start_offset;
1381 copy_chksum = LWIP_CHKSUM_COPY(dst_ptr,
dataptr,
len);
1382 if ((start_offset & 1) != 0) {
1426 if ((
q !=
NULL) && (
q->len > q_idx)) {
1427 return ((
u8_t *)
q->payload)[q_idx];
1448 if ((
q !=
NULL) && (
q->len > q_idx)) {
1468 const struct pbuf *
q =
p;
1483 for (
i = 0;
i <
n;
i++) {
1510 u16_t max_cmp_start = (
u16_t)(
p->tot_len - mem_len);
1511 if (
p->tot_len >= mem_len + start_offset) {
1512 for (
i = start_offset;
i <= max_cmp_start;
i++) {
1541 if (substr_len >= 0xFFFF) {
ACPI_SIZE strlen(const char *String)
#define mem_free(ptr, bsize)
#define SYS_ARCH_UNPROTECT(lev)
#define SYS_ARCH_PROTECT(lev)
#define SYS_ARCH_DECL_PROTECT(lev)
void * mem_trim(void *rmem, mem_size_t new_size)
void * mem_malloc(mem_size_t size_in)
#define LWIP_DEBUGF(debug, message)
#define LWIP_ERROR(message, expression, handler)
#define LWIP_ASSERT(message, assertion)
GLuint GLuint GLsizei GLenum type
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble GLdouble q
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLenum GLuint GLsizei bufsize
GLenum GLuint GLint GLint layer
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define LWIP_UNUSED_ARG(x)
#define LWIP_CONST_CAST(target_type, val)
#define LWIP_MEM_ALIGN(addr)
#define LWIP_MEM_ALIGN_SIZE(size)
#define LWIP_DBG_LEVEL_SERIOUS
#define LWIP_DBG_LEVEL_WARNING
struct pbuf * pbuf_coalesce(struct pbuf *p, pbuf_layer layer)
u16_t pbuf_memfind(const struct pbuf *p, const void *mem, u16_t mem_len, u16_t start_offset)
u16_t pbuf_memcmp(const struct pbuf *p, u16_t offset, const void *s2, u16_t n)
void pbuf_realloc(struct pbuf *p, u16_t new_len)
struct pbuf * pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type)
u8_t pbuf_get_at(const struct pbuf *p, u16_t offset)
void * pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset)
void pbuf_ref(struct pbuf *p)
void pbuf_cat(struct pbuf *h, struct pbuf *t)
void pbuf_chain(struct pbuf *h, struct pbuf *t)
int pbuf_try_get_at(const struct pbuf *p, u16_t offset)
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
u8_t pbuf_free(struct pbuf *p)
err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
struct pbuf * pbuf_skip(struct pbuf *in, u16_t in_offset, u16_t *out_offset)
u16_t pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
struct pbuf * pbuf_clone(pbuf_layer layer, pbuf_type type, struct pbuf *p)
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)
err_t pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_len, u16_t offset)
err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset)
void pbuf_put_at(struct pbuf *p, u16_t offset, u8_t data)
#define SWAP_BYTES_IN_WORD(w)
static substr_t substr(const WCHAR *str, size_t len)
int const JOCTET * dataptr
#define MEMCPY(DST, SRC, BYTES)
void * memp_malloc(memp_t type)
void memp_free(memp_t type, void *mem)
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
u8_t pbuf_add_header(struct pbuf *p, size_t header_size_increment)
#define PBUF_POOL_BUFSIZE_ALIGNED
static const struct pbuf * pbuf_skip_const(const struct pbuf *in, u16_t in_offset, u16_t *out_offset)
static u8_t pbuf_add_header_impl(struct pbuf *p, size_t header_size_increment, u8_t force)
u16_t pbuf_clen(const struct pbuf *p)
static u8_t pbuf_header_impl(struct pbuf *p, s16_t header_size_increment, u8_t force)
static void pbuf_init_alloced_pbuf(struct pbuf *p, void *payload, u16_t tot_len, u16_t len, pbuf_type type, u8_t flags)
#define SIZEOF_STRUCT_PBUF
u16_t pbuf_strstr(const struct pbuf *p, const char *substr)
struct pbuf * pbuf_free_header(struct pbuf *q, u16_t size)
u8_t pbuf_remove_header(struct pbuf *p, size_t header_size_decrement)
struct pbuf * pbuf_dechain(struct pbuf *p)
u8_t pbuf_header_force(struct pbuf *p, s16_t header_size_increment)
u8_t pbuf_add_header_force(struct pbuf *p, size_t header_size_increment)
#define PBUF_POOL_IS_EMPTY()
#define PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF_POOL
#define PBUF_FLAG_TCP_FIN
#define PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF
#define PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS
#define pbuf_get_allocsrc(p)
#define LWIP_SUPPORT_CUSTOM_PBUF
#define pbuf_match_allocsrc(p, type)
#define PBUF_TYPE_ALLOC_SRC_MASK_STD_HEAP
#define PBUF_FLAG_IS_CUSTOM
#define SYS_ARCH_SET(var, val)