Lines Matching +full:helios +full:- +full:4

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
36 * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
37 * - Initial distribution.
85 register struct cstate *tstate = comp->tstate; in sl_compress_init()
88 for (i = max_state; i > 0; --i) { in sl_compress_init()
90 tstate[i].cs_next = &tstate[i - 1]; in sl_compress_init()
94 comp->last_cs = &tstate[0]; in sl_compress_init()
95 comp->last_recv = 255; in sl_compress_init()
96 comp->last_xmit = 255; in sl_compress_init()
97 comp->flags = SLF_TOSS; in sl_compress_init()
101 /* ENCODE encodes a number that is known to be non-zero. ENCODEZ
102 * checks for zero (since zero has to be encoded in the 32-bit, 3 byte
161 register struct cstate *cs = comp->last_cs->cs_next; in sl_compress_tcp()
162 register u_int hlen = ip->ip_hl; in sl_compress_tcp()
175 if ((ip->ip_off & htons(0x3fff)) || m->m_len < 40) { in sl_compress_tcp()
177 ip->ip_off, (unsigned long)m->m_len); in sl_compress_tcp()
189 * Packet is compressible -- we're going to send either a COMPRESSED_TCP or in sl_compress_tcp()
195 slstat->sls_packets++; in sl_compress_tcp()
196 if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr || in sl_compress_tcp()
197 ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr || in sl_compress_tcp()
198 *(int *) th != ((int *) &cs->cs_ip)[cs->cs_ip.ip_hl]) { in sl_compress_tcp()
201 * Wasn't the first -- search for it. in sl_compress_tcp()
208 * state for the datagram, the oldest state is (re-)used. in sl_compress_tcp()
211 register struct cstate *lastcs = comp->last_cs; in sl_compress_tcp()
215 cs = cs->cs_next; in sl_compress_tcp()
216 slstat->sls_searches++; in sl_compress_tcp()
217 if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr in sl_compress_tcp()
218 && ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr in sl_compress_tcp()
219 && *(int *) th == ((int *) &cs->cs_ip)[cs->cs_ip.ip_hl]) in sl_compress_tcp()
224 * Didn't find it -- re-use oldest cstate. Send an uncompressed packet in sl_compress_tcp()
230 slstat->sls_misses++; in sl_compress_tcp()
231 comp->last_cs = lcs; in sl_compress_tcp()
232 #define THOFFSET(th) (th->th_off) in sl_compress_tcp()
233 hlen += th->th_off; in sl_compress_tcp()
235 if (hlen > m->m_len) in sl_compress_tcp()
242 * Found it -- move to the front on the connection list. in sl_compress_tcp()
245 comp->last_cs = lcs; in sl_compress_tcp()
247 lcs->cs_next = cs->cs_next; in sl_compress_tcp()
248 cs->cs_next = lastcs->cs_next; in sl_compress_tcp()
249 lastcs->cs_next = cs; in sl_compress_tcp()
257 * checks the time-to-live and protocol (the protocol check is unnecessary in sl_compress_tcp()
258 * but costless). The 4th line checks the TCP header length. The 5th line in sl_compress_tcp()
263 oth = (struct tcphdr *) & ((int *) &cs->cs_ip)[hlen]; in sl_compress_tcp()
265 hlen += th->th_off; in sl_compress_tcp()
267 if (hlen > m->m_len) in sl_compress_tcp()
270 if (((u_short *) ip)[0] != ((u_short *) & cs->cs_ip)[0] || in sl_compress_tcp()
271 ((u_short *) ip)[3] != ((u_short *) & cs->cs_ip)[3] || in sl_compress_tcp()
272 ((u_short *) ip)[4] != ((u_short *) & cs->cs_ip)[4] || in sl_compress_tcp()
275 memcmp(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) || in sl_compress_tcp()
277 memcmp(th + 1, oth + 1, (THOFFSET(th) - 5) << 2))) { in sl_compress_tcp()
287 deltaS = ntohs(th->th_urp); in sl_compress_tcp()
290 } else if (th->th_urp != oth->th_urp) { in sl_compress_tcp()
293 * argh! URG not set but urp changed -- a sensible implementation should in sl_compress_tcp()
299 deltaS = (u_short) (ntohs(th->th_win) - ntohs(oth->th_win)); in sl_compress_tcp()
304 deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack); in sl_compress_tcp()
312 deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq); in sl_compress_tcp()
331 if (ip->ip_len != cs->cs_ip.ip_len && in sl_compress_tcp()
332 ntohs(cs->cs_ip.ip_len) == hlen) in sl_compress_tcp()
341 * actual changes match one of our special case encodings -- send packet in sl_compress_tcp()
348 deltaS == ntohs(cs->cs_ip.ip_len) - hlen) { in sl_compress_tcp()
356 if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) { in sl_compress_tcp()
364 deltaS = ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id); in sl_compress_tcp()
376 deltaA = ntohs(th->th_sum); in sl_compress_tcp()
377 memcpy(&cs->cs_ip, ip, hlen); in sl_compress_tcp()
380 * We want to use the original packet as our compressed packet. (cp - in sl_compress_tcp()
383 * id and two for the tcp checksum. So, (cp - new_seq) + 4 bytes of header in sl_compress_tcp()
387 deltaS = cp - new_seq; in sl_compress_tcp()
395 if (comp->last_xmit == cs->cs_id && compress_cid) { in sl_compress_tcp()
396 hlen -= deltaS + 3; in sl_compress_tcp()
400 comp->last_xmit = cs->cs_id; in sl_compress_tcp()
401 hlen -= deltaS + 4; in sl_compress_tcp()
404 *cp++ = cs->cs_id; in sl_compress_tcp()
406 m->m_len -= hlen; in sl_compress_tcp()
407 m->m_offset += hlen; in sl_compress_tcp()
411 slstat->sls_compressed++; in sl_compress_tcp()
420 memcpy(&cs->cs_ip, ip, hlen); in sl_compress_tcp()
421 ip->ip_p = cs->cs_id; in sl_compress_tcp()
422 comp->last_xmit = cs->cs_id; in sl_compress_tcp()
442 if (ip->ip_p > max_state) in sl_uncompress_tcp()
444 cs = &comp->rstate[comp->last_recv = ip->ip_p]; in sl_uncompress_tcp()
445 comp->flags &= ~SLF_TOSS; in sl_uncompress_tcp()
446 ip->ip_p = IPPROTO_TCP; in sl_uncompress_tcp()
452 hlen = ip->ip_hl << 2; in sl_uncompress_tcp()
459 memcpy(&cs->cs_ip, ip, hlen); in sl_uncompress_tcp()
460 cs->cs_hlen = hlen; in sl_uncompress_tcp()
461 slstat->sls_uncompressedin++; in sl_uncompress_tcp()
472 slstat->sls_compressedin++; in sl_uncompress_tcp()
482 if (*cp > max_state || comp->last_recv == 255) in sl_uncompress_tcp()
485 comp->flags &= ~SLF_TOSS; in sl_uncompress_tcp()
486 comp->last_recv = *cp++; in sl_uncompress_tcp()
493 if (comp->flags & SLF_TOSS) { in sl_uncompress_tcp()
494 slstat->sls_tossed++; in sl_uncompress_tcp()
498 cs = &comp->rstate[comp->last_recv]; in sl_uncompress_tcp()
499 hlen = cs->cs_ip.ip_hl << 2; in sl_uncompress_tcp()
500 th = (struct tcphdr *) & ((u_char *) & cs->cs_ip)[hlen]; in sl_uncompress_tcp()
501 th->th_sum = htons((*cp << 8) | cp[1]); in sl_uncompress_tcp()
511 register u_int i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen; in sl_uncompress_tcp()
513 th->th_ack = htonl(ntohl(th->th_ack) + i); in sl_uncompress_tcp()
514 th->th_seq = htonl(ntohl(th->th_seq) + i); in sl_uncompress_tcp()
519 th->th_seq = htonl(ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len) in sl_uncompress_tcp()
520 - cs->cs_hlen); in sl_uncompress_tcp()
526 DECODEU(th->th_urp) in sl_uncompress_tcp()
530 DECODES(th->th_win) in sl_uncompress_tcp()
532 DECODEL(th->th_ack) in sl_uncompress_tcp()
536 DECODEL(th->th_seq) in sl_uncompress_tcp()
541 DECODES(cs->cs_ip.ip_id) in sl_uncompress_tcp()
543 cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1); in sl_uncompress_tcp()
546 cs->cs_ip.ip_id, (u_long)ntohl(th->th_seq)); in sl_uncompress_tcp()
555 len -= (cp - *bufp); in sl_uncompress_tcp()
563 *bufp = cp - cs->cs_hlen; in sl_uncompress_tcp()
564 len += cs->cs_hlen; in sl_uncompress_tcp()
565 cs->cs_ip.ip_len = htons(len); in sl_uncompress_tcp()
568 cs->cs_ip.ip_sum = 0; in sl_uncompress_tcp()
569 bp = (u_short *)&cs->cs_ip; in sl_uncompress_tcp()
570 for (changes = 0; hlen > 0; hlen -= 2) in sl_uncompress_tcp()
574 cs->cs_ip.ip_sum = ~changes; in sl_uncompress_tcp()
577 memcpy(*bufp, &cs->cs_ip, cs->cs_hlen); in sl_uncompress_tcp()
581 comp->flags |= SLF_TOSS; in sl_uncompress_tcp()
582 slstat->sls_errorin++; in sl_uncompress_tcp()
589 prompt_Printf(arg->prompt, "VJ compression statistics:\n"); in sl_Show()
590 prompt_Printf(arg->prompt, " Out: %d (compress) / %d (total)", in sl_Show()
591 arg->bundle->ncp.ipcp.vj.slstat.sls_compressed, in sl_Show()
592 arg->bundle->ncp.ipcp.vj.slstat.sls_packets); in sl_Show()
593 prompt_Printf(arg->prompt, " %d (miss) / %d (search)\n", in sl_Show()
594 arg->bundle->ncp.ipcp.vj.slstat.sls_misses, in sl_Show()
595 arg->bundle->ncp.ipcp.vj.slstat.sls_searches); in sl_Show()
596 prompt_Printf(arg->prompt, " In: %d (compress), %d (uncompress)", in sl_Show()
597 arg->bundle->ncp.ipcp.vj.slstat.sls_compressedin, in sl_Show()
598 arg->bundle->ncp.ipcp.vj.slstat.sls_uncompressedin); in sl_Show()
599 prompt_Printf(arg->prompt, " %d (error), %d (tossed)\n", in sl_Show()
600 arg->bundle->ncp.ipcp.vj.slstat.sls_errorin, in sl_Show()
601 arg->bundle->ncp.ipcp.vj.slstat.sls_tossed); in sl_Show()