73#if LWIP_TCP && TCP_QUEUE_OOSEQ
76#if LWIP_CHECKSUM_ON_COPY
82#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))
85#define PBUF_POOL_BUFSIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE)
87#if !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ
88#define PBUF_POOL_IS_EMPTY()
92#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL
94#define PBUF_POOL_FREE_OOSEQ_QUEUE_CALL() do { \
95 if(tcpip_callback_with_block(pbuf_free_ooseq_callback, NULL, 0) != ERR_OK) { \
96 SYS_ARCH_PROTECT(old_level); \
97 pbuf_free_ooseq_pending = 0; \
98 SYS_ARCH_UNPROTECT(old_level); \
103volatile u8_t pbuf_free_ooseq_pending;
104#define PBUF_POOL_IS_EMPTY() pbuf_pool_is_empty()
124 pbuf_free_ooseq_pending = 0;
127 for (pcb = tcp_active_pcbs;
NULL != pcb; pcb = pcb->
next) {
128 if (
NULL != pcb->ooseq) {
131 tcp_segs_free(pcb->ooseq);
143pbuf_free_ooseq_callback(
void *
arg)
152pbuf_pool_is_empty(
void)
154#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL
157 pbuf_free_ooseq_pending = 1;
163 queued = pbuf_free_ooseq_pending;
164 pbuf_free_ooseq_pending = 1;
169 PBUF_POOL_FREE_OOSEQ_QUEUE_CALL();
250 LWIP_ASSERT(
"pbuf_alloc: pbuf p->payload properly aligned",
256 LWIP_ASSERT(
"check p->payload + p->len does not overflow pbuf",
257 ((
u8_t*)
p->payload +
p->len <=
259 LWIP_ASSERT(
"PBUF_POOL_BUFSIZE must be bigger than MEM_ALIGNMENT",
271 while (rem_len > 0) {
286 LWIP_ASSERT(
"rem_len < max_u16_t", rem_len < 0xffff);
287 q->tot_len = (
u16_t)rem_len;
291 LWIP_ASSERT(
"pbuf_alloc: pbuf q->payload properly aligned",
293 LWIP_ASSERT(
"check p->payload + p->len does not overflow pbuf",
294 ((
u8_t*)
p->payload +
p->len <=
318 LWIP_ASSERT(
"pbuf_alloc: pbuf->payload properly aligned",
329 (
"pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n",
351#if LWIP_SUPPORT_CUSTOM_PBUF
368 void *payload_mem,
u16_t payload_mem_len)
391 LWIP_ASSERT(
"pbuf_alloced_custom: bad pbuf layer", 0);
401 if (payload_mem !=
NULL) {
404 p->pbuf.payload =
NULL;
407 p->pbuf.len =
p->pbuf.tot_len =
length;
443 if (new_len >=
p->tot_len) {
450 grow = new_len -
p->tot_len;
456 while (rem_len >
q->len) {
461 q->tot_len += (
u16_t)grow;
471 if ((
q->type ==
PBUF_RAM) && (rem_len !=
q->len)) {
481 if (
q->next !=
NULL) {
515 u16_t increment_magnitude;
518 if ((header_size_increment == 0) || (
p ==
NULL)) {
522 if (header_size_increment < 0){
523 increment_magnitude = -header_size_increment;
525 LWIP_ERROR(
"increment_magnitude <= p->len", (increment_magnitude <= p->
len),
return 1;);
527 increment_magnitude = header_size_increment;
532 LWIP_ASSERT(
"p->type == PBUF_RAM || p->type == PBUF_POOL",
535 LWIP_ASSERT(
"p->payload - increment_magnitude >= p + SIZEOF_STRUCT_PBUF",
547 p->payload = (
u8_t *)
p->payload - header_size_increment;
551 (
"pbuf_header: failed as %p < %p (not enough space for new header size)\n",
552 (
void *)
p->payload, (
void *)(
p + 1)));
561 if ((header_size_increment < 0) && (increment_magnitude <= p->
len)) {
563 p->payload = (
u8_t *)
p->payload - header_size_increment;
575 p->len += header_size_increment;
576 p->tot_len += header_size_increment;
579 (
void *)
payload, (
void *)
p->payload, header_size_increment));
628 (
"pbuf_free(p == NULL) was called.\n"));
660#if LWIP_SUPPORT_CUSTOM_PBUF
663 struct pbuf_custom *pc = (
struct pbuf_custom*)
p;
664 LWIP_ASSERT(
"pc->custom_free_function != NULL", pc->custom_free_function !=
NULL);
665 pc->custom_free_function(
p);
749 LWIP_ERROR(
"(h != NULL) && (t != NULL) (programmer violates API)",
755 p->tot_len +=
t->tot_len;
758 LWIP_ASSERT(
"p->tot_len == p->len (of last pbuf in chain)",
p->tot_len ==
p->len);
761 p->tot_len +=
t->tot_len;
812 LWIP_ASSERT(
"p->tot_len == p->len + q->tot_len",
q->tot_len ==
p->tot_len -
p->len);
814 q->tot_len =
p->tot_len -
p->len;
824 (
"pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (
void *)
q));
830 return ((tail_gone > 0) ?
NULL :
q);
854 u16_t offset_to=0, offset_from=0,
len;
857 (
void*)p_to, (
void*)p_from));
860 LWIP_ERROR(
"pbuf_copy: target not big enough to hold source", ((p_to !=
NULL) &&
867 if ((p_to->
len - offset_to) >= (p_from->
len - offset_from)) {
869 len = p_from->
len - offset_from;
872 len = p_to->
len - offset_to;
878 LWIP_ASSERT(
"offset_from <= p_from->len", offset_from <= p_from->
len);
879 if (offset_from >= p_from->
len) {
882 p_from = p_from->
next;
884 if (offset_to == p_to->
len) {
893 LWIP_ERROR(
"pbuf_copy() does not allow packet queues!\n",
898 LWIP_ERROR(
"pbuf_copy() does not allow packet queues!\n",
923 u16_t copied_total = 0;
941 buf_copy_len =
p->len -
offset;
942 if (buf_copy_len >
len)
946 copied_total += buf_copy_len;
947 left += buf_copy_len;
971 u16_t copied_total = 0;
981 for(
p =
buf; total_copy_len != 0;
p =
p->next) {
983 buf_copy_len = total_copy_len;
984 if (buf_copy_len >
p->len) {
986 buf_copy_len =
p->len;
989 MEMCPY(
p->payload, &((
char*)
dataptr)[copied_total], buf_copy_len);
990 total_copy_len -= buf_copy_len;
991 copied_total += buf_copy_len;
993 LWIP_ASSERT(
"did not copy all data", total_copy_len == 0 && copied_total ==
len);
1014 if (
p->next ==
NULL) {
1028#if LWIP_CHECKSUM_ON_COPY
1053 if ((start_offset >=
p->len) || (start_offset +
len >
p->len)) {
1057 dst_ptr = ((
char*)
p->payload) + start_offset;
1058 copy_chksum = LWIP_CHKSUM_COPY(dst_ptr,
dataptr,
len);
1059 if ((start_offset & 1) != 0) {
1083 while ((
q !=
NULL) && (
q->len <= copy_from)) {
1084 copy_from -=
q->len;
1088 if ((
q !=
NULL) && (
q->len > copy_from)) {
1089 return ((
u8_t*)
q->payload)[copy_from];
1117 for(
i = 0;
i <
n;
i++) {
1144 if (
p->tot_len >= mem_len + start_offset) {
1145 for(
i = start_offset;
i <=
max; ) {
1175 if (substr_len >= 0xFFFF) {
ACPI_SIZE strlen(const char *String)
#define LWIP_UNUSED_ARG(x)
#define mem_free(ptr, bsize)
#define SYS_ARCH_UNPROTECT(lev)
#define SYS_ARCH_PROTECT(lev)
#define mem_trim(_m_, _s_)
#define SYS_ARCH_DECL_PROTECT(lev)
void * mem_malloc(mem_size_t size)
#define LWIP_DBG_LEVEL_SERIOUS
#define LWIP_DEBUGF(debug, message)
#define LWIP_DBG_LEVEL_WARNING
#define LWIP_ERROR(message, expression, handler)
#define LWIP_ASSERT(message, assertion)
#define LWIP_MEM_ALIGN(addr)
#define LWIP_MEM_ALIGN_SIZE(size)
GLuint GLuint GLsizei GLenum type
GLuint GLuint GLsizei count
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 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
static u32_t chksum(void *dataptr, u16_t len)
#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)
struct pbuf * pbuf_coalesce(struct pbuf *p, pbuf_layer layer)
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
#define PBUF_POOL_BUFSIZE_ALIGNED
void pbuf_realloc(struct pbuf *p, u16_t new_len)
void pbuf_ref(struct pbuf *p)
void pbuf_cat(struct pbuf *h, struct pbuf *t)
void pbuf_chain(struct pbuf *h, struct pbuf *t)
#define SIZEOF_STRUCT_PBUF
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
u8_t pbuf_clen(struct pbuf *p)
u16_t pbuf_memcmp(struct pbuf *p, u16_t offset, const void *s2, u16_t n)
u8_t pbuf_get_at(struct pbuf *p, u16_t offset)
u16_t pbuf_copy_partial(struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
u8_t pbuf_free(struct pbuf *p)
u16_t pbuf_memfind(struct pbuf *p, const void *mem, u16_t mem_len, u16_t start_offset)
struct pbuf * pbuf_dechain(struct pbuf *p)
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)
u16_t pbuf_strstr(struct pbuf *p, const char *substr)
#define PBUF_POOL_IS_EMPTY()
err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
#define PBUF_FLAG_IS_CUSTOM
#define PBUF_TRANSPORT_HLEN