45#define INCR(counter) ++comp->stats.counter
57 memset((
char *)comp, 0,
sizeof(*comp));
60 comp->compressSlot = 0;
67 comp->last_cs = &tstate[0];
68 comp->last_recv = 255;
69 comp->last_xmit = 255;
79 if ((u_short)(n) >= 256) { \
81 cp[1] = (u_char)(n); \
82 cp[0] = (u_char)((n) >> 8); \
85 *cp++ = (u_char)(n); \
89 if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \
91 cp[1] = (u_char)(n); \
92 cp[0] = (u_char)((n) >> 8); \
95 *cp++ = (u_char)(n); \
101 u32_t tmp = ntohl(f) + ((cp[1] << 8) | cp[2]); \
105 u32_t tmp = ntohl(f) + (u32_t)*cp++; \
110#define DECODES(f) { \
112 u_short tmp = ntohs(f) + (((u_short)cp[1] << 8) | cp[2]); \
116 u_short tmp = ntohs(f) + (u_short)*cp++; \
121#define DECODEU(f) { \
123 (f) = htons(((u_short)cp[1] << 8) | cp[2]); \
126 (f) = htons((u_short)*cp++); \
145 register u_short deltaS, deltaA;
166 th = (
struct tcp_hdr *)&((
long *)
ip)[hlen];
167 if ((TCPH_FLAGS(th) & (TCP_SYN|TCP_FIN|TCP_RST|TCP_ACK)) != TCP_ACK) {
180 || *(
long *)th != ((
long *)&
cs->cs_ip)[
IPH_HL(&
cs->cs_ip)]) {
193 register struct cstate *lcs;
197 lcs =
cs;
cs =
cs->cs_next;
201 && *(
long *)th == ((
long *)&
cs->cs_ip)[
IPH_HL(&
cs->cs_ip)]) {
204 }
while (
cs != lastcs);
216 hlen += TCPH_HDRLEN(th);
219 if (hlen > pb->
len) {
237 oth = (
struct tcp_hdr *)&((
long *)&
cs->cs_ip)[hlen];
239 hlen += TCPH_HDRLEN(th);
242 if (hlen > pb->
len) {
243 PPPDEBUG(
LOG_INFO, (
"vj_compress_tcp: header len %d spans buffers\n", hlen));
261 || TCPH_HDRLEN(th) != TCPH_HDRLEN(oth)
262 || (deltaS > 5 && BCMP(
ip + 1, &
cs->cs_ip + 1, (deltaS - 5) << 2))
263 || (TCPH_HDRLEN(th) > 5 && BCMP(th + 1, oth + 1, (TCPH_HDRLEN(th) - 5) << 2))) {
273 if (TCPH_FLAGS(th) & TCP_URG) {
274 deltaS =
ntohs(th->urgp);
277 }
else if (th->urgp != oth->urgp) {
290 if ((deltaL =
ntohl(th->ackno) -
ntohl(oth->ackno)) != 0) {
291 if (deltaL > 0xffff) {
299 if ((deltaL =
ntohl(th->seqno) -
ntohl(oth->seqno)) != 0) {
300 if (deltaL > 0xffff) {
334 if (deltaS == deltaA && deltaS ==
ntohs(
IPH_LEN(&
cs->cs_ip)) - hlen) {
355 if (TCPH_FLAGS(th) & TCP_PSH) {
362 deltaA =
ntohs(th->chksum);
363 BCOPY(
ip, &
cs->cs_ip, hlen);
396 BCOPY(new_seq,
cp, deltaS);
397 INCR(vjs_compressed);
406 BCOPY(
ip, &
cs->cs_ip, hlen);
437 || (hlen += TCPH_HDRLEN(((
struct tcp_hdr *)&((
char *)
ip)[hlen])) << 2)
440 PPPDEBUG(
LOG_INFO, (
"vj_uncompress_uncomp: bad cid=%d, hlen=%d buflen=%d\n",
447 comp->
flags &=~ VJF_TOSS;
449 BCOPY(
ip, &
cs->cs_ip, hlen);
451 INCR(vjs_uncompressedin);
470 struct pbuf *n0 = *nb;
474 INCR(vjs_compressedin);
487 comp->
flags &=~ VJF_TOSS;
507 TCPH_SET_FLAG(th, TCP_PSH);
509 TCPH_UNSET_FLAG(th, TCP_PSH);
517 tmp =
ntohl(th->ackno) +
i;
518 th->ackno =
htonl(tmp);
519 tmp =
ntohl(th->seqno) +
i;
520 th->seqno =
htonl(tmp);
527 th->seqno =
htonl(tmp);
532 TCPH_SET_FLAG(th, TCP_URG);
535 TCPH_UNSET_FLAG(th, TCP_URG);
549 DECODES(
cs->cs_ip._id);
561 if (n0->
len < vjlen) {
571#if BYTE_ORDER == LITTLE_ENDIAN
581 for (tmp = 0; hlen > 0; hlen -= 2) {
584 tmp = (tmp & 0xffff) + (tmp >> 16);
585 tmp = (tmp & 0xffff) + (tmp >> 16);
#define IPH_LEN_SET(hdr, len)
#define IPH_ID_SET(hdr, id)
#define IPH_PROTO_SET(hdr, proto)
#define IPH_CHKSUM_SET(hdr, chksum)
#define LWIP_ASSERT(message, assertion)
#define LWIP_MEM_ALIGN(addr)
GLdouble GLdouble GLdouble GLdouble q
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 ip_addr_cmp(addr1, addr2)
#define MEMCPY(DST, SRC, BYTES)
static const BYTE uncompressed[]
#define PBUF_POOL_BUFSIZE
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
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_dechain(struct pbuf *p)
struct cstate rstate[MAX_SLOTS]
struct cstate tstate[MAX_SLOTS]
static unsigned int bufptr
void vj_compress_init(struct vjcompress *comp)
int vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
#define TYPE_UNCOMPRESSED_TCP
void vj_uncompress_err(struct vjcompress *comp)
#define TYPE_COMPRESSED_TCP
int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp)
u_int vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb)