diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h index b7ea58b..0ed616e 100644 --- a/src/include/lwip/priv/tcp_priv.h +++ b/src/include/lwip/priv/tcp_priv.h @@ -186,7 +186,7 @@ PACK_STRUCT_END #define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags)) #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags)) -#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (TCPH_FLAGS(phdr) & ~(flags)) ) +#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~htons(flags)) #define TCP_TCPLEN(seg) ((seg)->len + (((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0) ? 1U : 0U)) diff --git a/src/include/netif/ppp/vj.h b/src/include/netif/ppp/vj.h index b8e4669..d4cc713 100644 --- a/src/include/netif/ppp/vj.h +++ b/src/include/netif/ppp/vj.h @@ -107,9 +107,9 @@ */ struct cstate { struct cstate *cs_next; /* next most recently used state (xmit only) */ - u_short cs_hlen; /* size of hdr (receive only) */ - u_char cs_id; /* connection # associated with this state */ - u_char cs_filler; + u16_t cs_hlen; /* size of hdr (receive only) */ + u8_t cs_id; /* connection # associated with this state */ + u8_t cs_filler; union { char csu_hdr[MAX_HDR]; struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */ @@ -120,14 +120,14 @@ struct cstate { struct vjstat { - unsigned long vjs_packets; /* outbound packets */ - unsigned long vjs_compressed; /* outbound compressed packets */ - unsigned long vjs_searches; /* searches for connection state */ - unsigned long vjs_misses; /* times couldn't find conn. state */ - unsigned long vjs_uncompressedin; /* inbound uncompressed packets */ - unsigned long vjs_compressedin; /* inbound compressed packets */ - unsigned long vjs_errorin; /* inbound unknown type packets */ - unsigned long vjs_tossed; /* inbound packets tossed because of error */ + u32_t vjs_packets; /* outbound packets */ + u32_t vjs_compressed; /* outbound compressed packets */ + u32_t vjs_searches; /* searches for connection state */ + u32_t vjs_misses; /* times couldn't find conn. state */ + u32_t vjs_uncompressedin; /* inbound uncompressed packets */ + u32_t vjs_compressedin; /* inbound compressed packets */ + u32_t vjs_errorin; /* inbound unknown type packets */ + u32_t vjs_tossed; /* inbound packets tossed because of error */ }; /* @@ -135,11 +135,11 @@ struct vjstat { */ struct vjcompress { struct cstate *last_cs; /* most recently used tstate */ - u_char last_recv; /* last rcvd conn. id */ - u_char last_xmit; /* last sent conn. id */ - u_short flags; - u_char maxSlotIndex; - u_char compressSlot; /* Flag indicating OK to compress slot ID. */ + u8_t last_recv; /* last rcvd conn. id */ + u8_t last_xmit; /* last sent conn. id */ + u16_t flags; + u8_t maxSlotIndex; + u8_t compressSlot; /* Flag indicating OK to compress slot ID. */ #if LINK_STATS struct vjstat stats; #endif @@ -151,7 +151,7 @@ struct vjcompress { #define VJF_TOSS 1U /* tossing rcvd frames because of input err */ extern void vj_compress_init (struct vjcompress *comp); -extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb); +extern u32_t vj_compress_tcp (struct vjcompress *comp, struct pbuf **pb); extern void vj_uncompress_err (struct vjcompress *comp); extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp); extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp); diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index aecd7a1..f5f6506 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -488,16 +488,46 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc * this is an IP packet. */ if (protocol == PPP_IP && pcb->vj_enabled) { - switch (vj_compress_tcp(&pcb->vj_comp, pb)) { + + int i; + printf("--------------OUTPUT PATH-------------------------\nframe before (%d/%d): ", pb->len, pb->tot_len); + for (i = 0; i < pb->len; i++) { + printf("%.2x ", ((u8_t*)pb->payload)[i]); + } + printf("\n"); + + switch (vj_compress_tcp(&pcb->vj_comp, &pb)) { case TYPE_IP: /* No change... protocol = PPP_IP_PROTOCOL; */ break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; + + printf("frame after (%d/%d): ", pb->len, pb->tot_len); + for (i = 0; i < pb->len; i++) { + printf("%.2x ", ((u8_t*)pb->payload)[i]); + } + printf("\n"); + + err = pcb->link_cb->netif_output(pcb, pcb->link_ctx_cb, pb, protocol); + pbuf_free(pb); + return err; + break; case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; + + printf("frame after (%d/%d): ", pb->len, pb->tot_len); + for (i = 0; i < pb->len; i++) { + printf("%.2x ", ((u8_t*)pb->payload)[i]); + } + printf("\n"); + + err = pcb->link_cb->netif_output(pcb, pcb->link_ctx_cb, pb, protocol); + pbuf_free(pb); + return err; + break; default: PPPDEBUG(LOG_WARNING, ("ppp_netif_output[%d]: bad IP packet\n", pcb->netif->num)); @@ -506,6 +536,13 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc MIB2_STATS_NETIF_INC(pcb->netif, ifoutdiscards); return ERR_VAL; } + + + printf("frame after (%d/%d): ", pb->len, pb->tot_len); + for (i = 0; i < pb->len; i++) { + printf("%.2x ", ((u8_t*)pb->payload)[i]); + } + printf("\n"); } #endif /* VJ_SUPPORT && LWIP_TCP */ @@ -820,30 +857,78 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) { #if VJ_SUPPORT && LWIP_TCP case PPP_VJC_COMP: /* VJ compressed TCP */ + + { + int i; + printf("--------INPUT PATH-----COMPRESSED--------------------------\nframe before (%d/%d): ", pb->len, pb->tot_len); + for (i = 0; i < pb->len; i++) { + printf("%.2x ", ((u8_t*)pb->payload)[i]); + } + printf("\n"); + } + /* * Clip off the VJ header and prepend the rebuilt TCP/IP header and * pass the result to IP. */ - PPPDEBUG(LOG_INFO, ("ppp_input[%d]: vj_comp in pbuf len=%d\n", pcb->netif->num, pb->len)); + PPPDEBUG(LOG_INFO, ("ppp_input[%d]: vj_comp in pbuf len=%d\n", pcb->netif->num, pb->tot_len)); + printf("ppp_input[%d]: vj_comp in pbuf len=%d\n", pcb->netif->num, pb->tot_len); if (pcb->vj_enabled && vj_uncompress_tcp(&pb, &pcb->vj_comp) >= 0) { + + + { + int i; + printf("frame after (%d/%d): ", pb->len, pb->tot_len); + for (i = 0; i < pb->len; i++) { + printf("%.2x ", ((u8_t*)pb->payload)[i]); + } + printf("\n"); + } + + ip4_input(pb, pcb->netif); return; } /* Something's wrong so drop it. */ + printf("ppp_input[%d]: Dropping VJ compressed\n", pcb->netif->num); PPPDEBUG(LOG_WARNING, ("ppp_input[%d]: Dropping VJ compressed\n", pcb->netif->num)); break; case PPP_VJC_UNCOMP: /* VJ uncompressed TCP */ - /* + + { + int i; + printf("------INPUT PATH-------UNCOMPRESSED--------------------------\nframe before (%d/%d): ", pb->len, pb->tot_len); + for (i = 0; i < pb->len; i++) { + printf("%.2x ", ((u8_t*)pb->payload)[i]); + } + printf("\n"); + } + + /* * Process the TCP/IP header for VJ header compression and then pass * the packet to IP. */ - PPPDEBUG(LOG_INFO, ("ppp_input[%d]: vj_un in pbuf len=%d\n", pcb->netif->num, pb->len)); + PPPDEBUG(LOG_INFO, ("ppp_input[%d]: vj_un in pbuf len=%d\n", pcb->netif->num, pb->tot_len)); + printf("ppp_input[%d]: vj_un in pbuf len=%d\n", pcb->netif->num, pb->tot_len); if (pcb->vj_enabled && vj_uncompress_uncomp(pb, &pcb->vj_comp) >= 0) { + + + { + int i; + printf("frame after (%d/%d): ", pb->len, pb->tot_len); + for (i = 0; i < pb->len; i++) { + printf("%.2x ", ((u8_t*)pb->payload)[i]); + } + printf("\n"); + } + + ip4_input(pb, pcb->netif); return; } /* Something's wrong so drop it. */ +// printf("ppp_input[%d]: Dropping VJ uncompressed\n", pcb->netif->num); PPPDEBUG(LOG_WARNING, ("ppp_input[%d]: Dropping VJ uncompressed\n", pcb->netif->num)); break; #endif /* VJ_SUPPORT && LWIP_TCP */ @@ -1102,6 +1187,8 @@ int sifvjcomp(ppp_pcb *pcb, int vjcomp, int cidcomp, int maxcid) { pcb->vj_enabled = vjcomp; pcb->vj_comp.compressSlot = cidcomp; pcb->vj_comp.maxSlotIndex = maxcid; + printf("sifvjcomp[%d]: VJ compress enable=%d slot=%d max slot=%d\n", + pcb->netif->num, vjcomp, cidcomp, maxcid); PPPDEBUG(LOG_INFO, ("sifvjcomp[%d]: VJ compress enable=%d slot=%d max slot=%d\n", pcb->netif->num, vjcomp, cidcomp, maxcid)); return 0; diff --git a/src/netif/ppp/vj.c b/src/netif/ppp/vj.c index 0819afe..4ca5840 100644 --- a/src/netif/ppp/vj.c +++ b/src/netif/ppp/vj.c @@ -47,8 +47,8 @@ void vj_compress_init(struct vjcompress *comp) { - register u_char i; - register struct cstate *tstate = comp->tstate; + u8_t i; + struct cstate *tstate = comp->tstate; #if MAX_SLOTS == 0 memset((char *)comp, 0, sizeof(*comp)); @@ -73,23 +73,23 @@ vj_compress_init(struct vjcompress *comp) * form). */ #define ENCODE(n) { \ - if ((u_short)(n) >= 256) { \ + if ((u16_t)(n) >= 256) { \ *cp++ = 0; \ - cp[1] = (u_char)(n); \ - cp[0] = (u_char)((n) >> 8); \ + cp[1] = (u8_t)(n); \ + cp[0] = (u8_t)((n) >> 8); \ cp += 2; \ } else { \ - *cp++ = (u_char)(n); \ + *cp++ = (u8_t)(n); \ } \ } #define ENCODEZ(n) { \ - if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \ + if ((u16_t)(n) >= 256 || (u16_t)(n) == 0) { \ *cp++ = 0; \ - cp[1] = (u_char)(n); \ - cp[0] = (u_char)((n) >> 8); \ + cp[1] = (u8_t)(n); \ + cp[0] = (u8_t)((n) >> 8); \ cp += 2; \ } else { \ - *cp++ = (u_char)(n); \ + *cp++ = (u8_t)(n); \ } \ } @@ -106,21 +106,21 @@ vj_compress_init(struct vjcompress *comp) #define DECODES(f) { \ if (*cp == 0) {\ - u_short tmp_ = ntohs(f) + (((u_short)cp[1] << 8) | cp[2]); \ + u16_t tmp_ = ntohs(f) + (((u16_t)cp[1] << 8) | cp[2]); \ (f) = htons(tmp_); \ cp += 3; \ } else { \ - u_short tmp_ = ntohs(f) + (u_short)*cp++; \ + u16_t tmp_ = ntohs(f) + (u16_t)*cp++; \ (f) = htons(tmp_); \ } \ } #define DECODEU(f) { \ if (*cp == 0) {\ - (f) = htons(((u_short)cp[1] << 8) | cp[2]); \ + (f) = htons(((u16_t)cp[1] << 8) | cp[2]); \ cp += 3; \ } else { \ - (f) = htons((u_short)*cp++); \ + (f) = htons((u16_t)*cp++); \ } \ } @@ -131,37 +131,60 @@ vj_compress_init(struct vjcompress *comp) * Return the VJ type code indicating whether or not the packet was * compressed. */ -u_int -vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) +u32_t +vj_compress_tcp(struct vjcompress *comp, struct pbuf **pb) { - register struct ip_hdr *ip = (struct ip_hdr *)pb->payload; - register struct cstate *cs = comp->last_cs->cs_next; - register u_short hlen = IPH_HL(ip); - register struct tcp_hdr *oth; - register struct tcp_hdr *th; - register u_short deltaS, deltaA = 0; - register u_long deltaL; - register u_int changes = 0; - u_char new_seq[16]; - register u_char *cp = new_seq; - + struct ip_hdr *ip; + struct cstate *cs = comp->last_cs->cs_next; + u16_t hlen; + struct tcp_hdr *oth; + struct tcp_hdr *th; + u16_t deltaS, deltaA = 0; + u32_t deltaL; + u32_t changes = 0; + u8_t new_seq[16]; + u8_t *cp = new_seq; + + err_t err; + struct pbuf *np; + + /* TCP stack requires that we don't change the packet payload, therefore we copy + * the whole packet before encryption. + */ + np = pbuf_alloc(PBUF_RAW, (*pb)->tot_len, PBUF_POOL); + if (!np) { + return ERR_MEM; + } + + if ((err = pbuf_copy(np, *pb)) != ERR_OK) { + pbuf_free(np); + return err; + } + *pb = np; + + ip = (struct ip_hdr *)(*pb)->payload; + hlen = IPH_HL(ip); + /* * Check that the packet is IP proto TCP. */ if (IPH_PROTO(ip) != IP_PROTO_TCP) { return (TYPE_IP); } - +printf("YES, it's IP !\n"); /* * Bail if this is an IP fragment or if the TCP packet isn't * `compressible' (i.e., ACK isn't set or some other control bit is * set). */ - if ((IPH_OFFSET(ip) & PP_HTONS(0x3fff)) || pb->tot_len < 40) { + if ((IPH_OFFSET(ip) & PP_HTONS(0x3fff)) || (*pb)->tot_len < 40) { + printf("IP fragment\n"); return (TYPE_IP); } - th = (struct tcp_hdr *)&((long *)ip)[hlen]; + printf("hlen = %d\n", hlen); + th = (struct tcp_hdr *)&((u32_t*)ip)[hlen]; if ((TCPH_FLAGS(th) & (TCP_SYN|TCP_FIN|TCP_RST|TCP_ACK)) != TCP_ACK) { + printf("Not compressible, flags: %x\n", TCPH_FLAGS(th)); return (TYPE_IP); } /* @@ -174,7 +197,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) INCR(vjs_packets); if (!ip4_addr_cmp(&ip->src, &cs->cs_ip.src) || !ip4_addr_cmp(&ip->dest, &cs->cs_ip.dest) - || *(long *)th != ((long *)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]) { + || *(u32_t*)th != ((u32_t*)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]) { /* * Wasn't the first -- search for it. * @@ -187,19 +210,21 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) * states via linear search. If we don't find a state * for the datagram, the oldest state is (re-)used. */ - register struct cstate *lcs; - register struct cstate *lastcs = comp->last_cs; + struct cstate *lcs; + struct cstate *lastcs = comp->last_cs; do { lcs = cs; cs = cs->cs_next; INCR(vjs_searches); if (ip4_addr_cmp(&ip->src, &cs->cs_ip.src) && ip4_addr_cmp(&ip->dest, &cs->cs_ip.dest) - && *(long *)th == ((long *)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]) { + && *(u32_t*)th == ((u32_t*)&cs->cs_ip)[IPH_HL(&cs->cs_ip)]) { goto found; } } while (cs != lastcs); + printf("CS NOT found\n"); + /* * Didn't find it -- re-use oldest cstate. Send an * uncompressed packet that tells the other side what @@ -213,7 +238,8 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) hlen += TCPH_HDRLEN(th); hlen <<= 2; /* Check that the IP/TCP headers are contained in the first buffer. */ - if (hlen > pb->len) { + if (hlen > (*pb)->len) { + printf("IP/TCP headers are NOT contained in the first buffer\n"); return (TYPE_IP); } goto uncompressed; @@ -230,13 +256,14 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) lastcs->cs_next = cs; } } + printf("CS found: %p, id: %d\n", (void*)cs, cs->cs_id); - oth = (struct tcp_hdr *)&((long *)&cs->cs_ip)[hlen]; + oth = (struct tcp_hdr *)&((u32_t*)&cs->cs_ip)[hlen]; deltaS = hlen; hlen += TCPH_HDRLEN(th); hlen <<= 2; /* Check that the IP/TCP headers are contained in the first buffer. */ - if (hlen > pb->len) { + if (hlen > (*pb)->len) { PPPDEBUG(LOG_INFO, ("vj_compress_tcp: header len %d spans buffers\n", hlen)); return (TYPE_IP); } @@ -252,9 +279,9 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) * different between the previous & current datagram, we send the * current datagram `uncompressed'. */ - if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] - || ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] - || ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] + if (((u16_t *)ip)[0] != ((u16_t *)&cs->cs_ip)[0] + || ((u16_t *)ip)[3] != ((u16_t *)&cs->cs_ip)[3] + || ((u16_t *)ip)[4] != ((u16_t *)&cs->cs_ip)[4] || TCPH_HDRLEN(th) != TCPH_HDRLEN(oth) || (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) || (TCPH_HDRLEN(th) > 5 && BCMP(th + 1, oth + 1, (TCPH_HDRLEN(th) - 5) << 2))) { @@ -271,6 +298,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) deltaS = ntohs(th->urgp); ENCODEZ(deltaS); changes |= NEW_U; + printf("NEW_U !\n"); } else if (th->urgp != oth->urgp) { /* argh! URG not set but urp changed -- a sensible * implementation should never do this but RFC793 @@ -279,7 +307,8 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) goto uncompressed; } - if ((deltaS = (u_short)(ntohs(th->wnd) - ntohs(oth->wnd))) != 0) { + if ((deltaS = (u16_t)(ntohs(th->wnd) - ntohs(oth->wnd))) != 0) { + printf("NEW_W, old %u, new %u, delta %u\n", ntohs(oth->wnd), ntohs(th->wnd), deltaS); ENCODE(deltaS); changes |= NEW_W; } @@ -288,7 +317,8 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) if (deltaL > 0xffff) { goto uncompressed; } - deltaA = (u_short)deltaL; + deltaA = (u16_t)deltaL; + printf("NEW_A, old %u, new %u, delta %u\n", ntohl(oth->ackno), ntohl(th->ackno), deltaL); ENCODE(deltaA); changes |= NEW_A; } @@ -297,7 +327,8 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) if (deltaL > 0xffff) { goto uncompressed; } - deltaS = (u_short)deltaL; + deltaS = (u16_t)deltaL; + printf("NEW_S, old %u, new %u, delta %u\n", ntohl(oth->seqno), ntohl(th->seqno), deltaL); ENCODE(deltaS); changes |= NEW_S; } @@ -314,6 +345,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) */ if (IPH_LEN(ip) != IPH_LEN(&cs->cs_ip) && ntohs(IPH_LEN(&cs->cs_ip)) == hlen) { + printf("nothing changed !\n"); break; } /* no break */ @@ -325,6 +357,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) * actual changes match one of our special case encodings -- * send packet uncompressed. */ + printf("SPECIAL_I or SPECIAL_D\n"); goto uncompressed; case NEW_S|NEW_A: @@ -332,6 +365,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) /* special case for echoed terminal traffic */ changes = SPECIAL_I; cp = new_seq; + printf("coin\n"); } break; @@ -340,13 +374,14 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) /* special case for data xfer */ changes = SPECIAL_D; cp = new_seq; + printf("pan\n"); } break; default: break; } - deltaS = (u_short)(ntohs(IPH_ID(ip)) - ntohs(IPH_ID(&cs->cs_ip))); + deltaS = (u16_t)(ntohs(IPH_ID(ip)) - ntohs(IPH_ID(&cs->cs_ip))); if (deltaS != 1) { ENCODEZ(deltaS); changes |= NEW_I; @@ -370,28 +405,32 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) * many bytes of the original packet to toss so subtract the two to * get the new packet size. */ - deltaS = (u_short)(cp - new_seq); + deltaS = (u16_t)(cp - new_seq); if (!comp->compressSlot || comp->last_xmit != cs->cs_id) { comp->last_xmit = cs->cs_id; hlen -= deltaS + 4; - if (pbuf_header(pb, -(s16_t)hlen)){ + if (pbuf_header(*pb, -(s16_t)hlen)){ /* Can we cope with this failing? Just assert for now */ LWIP_ASSERT("pbuf_header failed\n", 0); } - cp = (u_char *)pb->payload; - *cp++ = (u_char)(changes | NEW_C); + cp = (u8_t*)(*pb)->payload; + printf("changes: %x\n", (u8_t)(changes | NEW_C)); + *cp++ = (u8_t)(changes | NEW_C); + printf("id: %d\n", cs->cs_id); *cp++ = cs->cs_id; } else { hlen -= deltaS + 3; - if (pbuf_header(pb, -(s16_t)hlen)) { + if (pbuf_header(*pb, -(s16_t)hlen)) { /* Can we cope with this failing? Just assert for now */ LWIP_ASSERT("pbuf_header failed\n", 0); } - cp = (u_char *)pb->payload; - *cp++ = (u_char)changes; + cp = (u8_t*)(*pb)->payload; + *cp++ = (u8_t)changes; + printf("changes: %x\n", (u8_t)changes); } - *cp++ = (u_char)(deltaA >> 8); - *cp++ = (u_char)deltaA; + *cp++ = (u8_t)(deltaA >> 8); + *cp++ = (u8_t)deltaA; + printf("deltaA: %x\n", deltaA); MEMCPY(cp, new_seq, deltaS); INCR(vjs_compressed); return (TYPE_COMPRESSED_TCP); @@ -425,9 +464,9 @@ vj_uncompress_err(struct vjcompress *comp) int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) { - register u_int hlen; - register struct cstate *cs; - register struct ip_hdr *ip; + u32_t hlen; + struct cstate *cs; + struct ip_hdr *ip; ip = (struct ip_hdr *)nb->payload; hlen = IPH_HL(ip) << 2; @@ -446,7 +485,7 @@ vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) comp->flags &=~ VJF_TOSS; IPH_PROTO_SET(ip, IP_PROTO_TCP); MEMCPY(&cs->cs_ip, ip, hlen); - cs->cs_hlen = (u_short)hlen; + cs->cs_hlen = (u16_t)hlen; INCR(vjs_uncompressedin); return 0; } @@ -462,16 +501,16 @@ vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) int vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) { - u_char *cp; + u8_t *cp; struct tcp_hdr *th; struct cstate *cs; - u_short *bp; + u16_t *bp; struct pbuf *n0 = *nb; u32_t tmp; - u_int vjlen, hlen, changes; + u32_t vjlen, hlen, changes; INCR(vjs_compressedin); - cp = (u_char *)n0->payload; + cp = (u8_t*)n0->payload; changes = *cp++; if (changes & NEW_C) { /* @@ -499,7 +538,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) } cs = &comp->rstate[comp->last_recv]; hlen = IPH_HL(&cs->cs_ip) << 2; - th = (struct tcp_hdr *)&((u_char *)&cs->cs_ip)[hlen]; + th = (struct tcp_hdr *)&((u8_t*)&cs->cs_ip)[hlen]; th->chksum = htons((*cp << 8) | cp[1]); cp += 2; if (changes & TCP_PUSH_BIT) { @@ -511,7 +550,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) switch (changes & SPECIALS_MASK) { case SPECIAL_I: { - register u32_t i = ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; + u32_t i = ntohs(IPH_LEN(&cs->cs_ip)) - cs->cs_hlen; /* some compilers can't nest inline assembler.. */ tmp = ntohl(th->ackno) + i; th->ackno = htonl(tmp); @@ -556,7 +595,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) * packet. Fill in the IP total length and update the IP * header checksum. */ - vjlen = (u_short)(cp - (u_char*)n0->payload); + vjlen = (u16_t)(cp - (u8_t*)n0->payload); if (n0->len < vjlen) { /* * We must have dropped some characters (crc should detect @@ -569,20 +608,20 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) #if BYTE_ORDER == LITTLE_ENDIAN tmp = n0->tot_len - vjlen + cs->cs_hlen; - IPH_LEN_SET(&cs->cs_ip, htons((u_short)tmp)); + IPH_LEN_SET(&cs->cs_ip, htons((u16_t)tmp)); #else IPH_LEN_SET(&cs->cs_ip, htons(n0->tot_len - vjlen + cs->cs_hlen)); #endif /* recompute the ip header checksum */ - bp = (u_short *) &cs->cs_ip; + bp = (u16_t *) &cs->cs_ip; IPH_CHKSUM_SET(&cs->cs_ip, 0); for (tmp = 0; hlen > 0; hlen -= 2) { tmp += *bp++; } tmp = (tmp & 0xffff) + (tmp >> 16); tmp = (tmp & 0xffff) + (tmp >> 16); - IPH_CHKSUM_SET(&cs->cs_ip, (u_short)(~tmp)); + IPH_CHKSUM_SET(&cs->cs_ip, (u16_t)(~tmp)); /* Remove the compressed header and prepend the uncompressed header. */ if (pbuf_header(n0, -(s16_t)vjlen)) {