32#if PPP_SUPPORT && VJ_SUPPORT
42#define INCR(counter) ++comp->stats.counter
48vj_compress_init(
struct vjcompress *comp)
51 struct cstate *tstate = comp->tstate;
54 memset((
char *)comp, 0,
sizeof(*comp));
56 comp->maxSlotIndex = MAX_SLOTS - 1;
57 comp->compressSlot = 0;
58 for (
i = MAX_SLOTS - 1;
i > 0; --
i) {
60 tstate[
i].cs_next = &tstate[
i - 1];
62 tstate[0].cs_next = &tstate[MAX_SLOTS - 1];
64 comp->last_cs = &tstate[0];
65 comp->last_recv = 255;
66 comp->last_xmit = 255;
67 comp->flags = VJF_TOSS;
76 if ((u16_t)(n) >= 256) { \
79 cp[0] = (u8_t)((n) >> 8); \
86 if ((u16_t)(n) >= 256 || (u16_t)(n) == 0) { \
89 cp[0] = (u8_t)((n) >> 8); \
98 u32_t tmp_ = lwip_ntohl(f) + ((cp[1] << 8) | cp[2]); \
99 (f) = lwip_htonl(tmp_); \
102 u32_t tmp_ = lwip_ntohl(f) + (u32_t)*cp++; \
103 (f) = lwip_htonl(tmp_); \
107#define DECODES(f) { \
109 u16_t tmp_ = lwip_ntohs(f) + (((u16_t)cp[1] << 8) | cp[2]); \
110 (f) = lwip_htons(tmp_); \
113 u16_t tmp_ = lwip_ntohs(f) + (u16_t)*cp++; \
114 (f) = lwip_htons(tmp_); \
118#define DECODEU(f) { \
120 (f) = lwip_htons(((u16_t)cp[1] << 8) | cp[2]); \
123 (f) = lwip_htons((u16_t)*cp++); \
128#ifdef PACK_STRUCT_USE_INCLUDES
136#ifdef PACK_STRUCT_USE_INCLUDES
140#ifdef PACK_STRUCT_USE_INCLUDES
148#ifdef PACK_STRUCT_USE_INCLUDES
160vj_compress_tcp(
struct vjcompress *comp,
struct pbuf **pb)
162 struct pbuf *np = *pb;
164 struct cstate *
cs = comp->last_cs->cs_next;
169 u16_t deltaS, deltaA = 0;
190 th = (
struct tcp_hdr *)&((
struct vj_u32_t*)
ip)[ilen];
198 if (np->
len < hlen) {
199 PPPDEBUG(
LOG_INFO, (
"vj_compress_tcp: header len %d spans buffers\n", hlen));
221 if (!ip4_addr_eq(&
ip->src, &
cs->cs_ip.src)
222 || !ip4_addr_eq(&
ip->dest, &
cs->cs_ip.dest)
223 || (*(
struct vj_u32_t*)th).v != (((
struct vj_u32_t*)&
cs->cs_ip)[
IPH_HL(&
cs->cs_ip)]).
v) {
237 struct cstate *lastcs = comp->last_cs;
240 lcs =
cs;
cs =
cs->cs_next;
242 if (ip4_addr_eq(&
ip->src, &
cs->cs_ip.src)
243 && ip4_addr_eq(&
ip->dest, &
cs->cs_ip.dest)
244 && (*(
struct vj_u32_t*)th).v == (((
struct vj_u32_t*)&
cs->cs_ip)[
IPH_HL(&
cs->cs_ip)]).v) {
247 }
while (
cs != lastcs);
268 lcs->cs_next =
cs->cs_next;
269 cs->cs_next = lastcs->cs_next;
270 lastcs->cs_next =
cs;
274 oth = (
struct tcp_hdr *)&((
struct vj_u32_t*)&
cs->cs_ip)[ilen];
288 if ((((
struct vj_u16_t*)
ip)[0]).v != (((
struct vj_u16_t*)&
cs->cs_ip)[0]).
v
289 || (((
struct vj_u16_t*)
ip)[3]).v != (((
struct vj_u16_t*)&
cs->cs_ip)[3]).
v
290 || (((
struct vj_u16_t*)
ip)[4]).v != (((
struct vj_u16_t*)&
cs->cs_ip)[4]).
v
292 || (deltaS > 5 && BCMP(
ip + 1, &
cs->cs_ip + 1, (deltaS - 5) << 2))
307 }
else if (th->urgp != oth->urgp) {
321 if (deltaL > 0xffff) {
324 deltaA = (
u16_t)deltaL;
330 if (deltaL > 0xffff) {
333 deltaS = (
u16_t)deltaL;
406 deltaS = (
u16_t)(
cp - new_seq);
407 if (!comp->compressSlot || comp->last_xmit !=
cs->cs_id) {
408 comp->last_xmit =
cs->cs_id;
426 *
cp++ = (
u8_t)(deltaA >> 8);
429 INCR(vjs_compressed);
430 return (TYPE_COMPRESSED_TCP);
440 comp->last_xmit =
cs->cs_id;
441 return (TYPE_UNCOMPRESSED_TCP);
448vj_uncompress_err(
struct vjcompress *comp)
450 comp->flags |= VJF_TOSS;
459vj_uncompress_uncomp(
struct pbuf *nb,
struct vjcompress *comp)
472 PPPDEBUG(
LOG_INFO, (
"vj_uncompress_uncomp: bad cid=%d, hlen=%d buflen=%d\n",
474 vj_uncompress_err(comp);
478 comp->flags &=~ VJF_TOSS;
484 INCR(vjs_uncompressedin);
497vj_uncompress_tcp(
struct pbuf **nb,
struct vjcompress *comp)
503 struct pbuf *n0 = *nb;
507 INCR(vjs_compressedin);
515 if (*
cp >= MAX_SLOTS) {
516 PPPDEBUG(
LOG_INFO, (
"vj_uncompress_tcp: bad cid=%d\n", *
cp));
520 comp->flags &=~ VJF_TOSS;
521 comp->last_recv = *
cp++;
528 if (comp->flags & VJF_TOSS) {
529 PPPDEBUG(
LOG_INFO, (
"vj_uncompress_tcp: tossing\n"));
534 cs = &comp->rstate[comp->last_recv];
545 switch (
changes & SPECIALS_MASK) {
582 DECODES(
cs->cs_ip._id);
594 if (n0->
len < vjlen) {
599 PPPDEBUG(
LOG_INFO, (
"vj_uncompress_tcp: head buffer %d too short %d\n",
604#if BYTE_ORDER == LITTLE_ENDIAN
612 bp = (
struct vj_u16_t*) &
cs->cs_ip;
614 for (tmp = 0; hlen > 0; hlen -= 2) {
617 tmp = (tmp & 0xffff) + (tmp >> 16);
618 tmp = (tmp & 0xffff) + (tmp >> 16);
641 PPPDEBUG(
LOG_WARNING, (
"vj_uncompress_tcp: realign failed\n"));
667 PPPDEBUG(
LOG_WARNING, (
"vj_uncompress_tcp: prepend failed\n"));
681 vj_uncompress_err(comp);
#define PACK_STRUCT_STRUCT
#define LWIP_ASSERT(message, assertion)
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 PACK_STRUCT_BEGIN
#define LWIP_MEM_ALIGN(addr)
#define PACK_STRUCT_FIELD(x)
#define PBUF_POOL_BUFSIZE
void pbuf_cat(struct pbuf *h, struct pbuf *t)
void pbuf_chain(struct pbuf *h, struct pbuf *t)
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
u8_t pbuf_free(struct pbuf *p)
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)
#define TCPH_HDRLEN_BYTES(phdr)
#define TCPH_SET_FLAG(phdr, flags)
#define TCPH_HDRLEN(phdr)
#define TCPH_UNSET_FLAG(phdr, flags)
#define MEMCPY(DST, SRC, BYTES)
static const BYTE uncompressed[]
u8_t pbuf_add_header(struct pbuf *p, size_t header_size_increment)
u8_t pbuf_remove_header(struct pbuf *p, size_t header_size_decrement)
struct pbuf * pbuf_dechain(struct pbuf *p)
#define IPH_LEN_SET(hdr, len)
#define IPH_ID_SET(hdr, id)
#define IPH_PROTO_SET(hdr, proto)
#define IPH_CHKSUM_SET(hdr, chksum)