Lines Matching +full:cs +full:- +full:number
21 * - Initial distribution.
28 * - 01-31-90 initial adaptation (from 1.19)
29 * PPP.05 02-15-90 [ks]
30 * PPP.08 05-02-90 [ks] use PPP protocol field to signal compression
31 * PPP.15 09-90 [ks] improve mbuf handling
32 * PPP.16 11-02 [karn] substantially rewritten to use NOS facilities
34 * - Feb 1991 Bill_Simpson@um.cc.umich.edu
35 * variable number of conversation slots
39 * - Jul 1994 Dmitry Gorodchanin
41 * - Oct 1994 Dmitry Gorodchanin
43 * - Jan 1995 Bjorn Ekwall
45 * - July 1995 Christos A. Polyzols
99 return ERR_PTR(-EINVAL); in slhc_init()
107 comp->rstate = kzalloc(rsize, GFP_KERNEL); in slhc_init()
108 if (! comp->rstate) in slhc_init()
110 comp->rslot_limit = rslots - 1; in slhc_init()
115 comp->tstate = kzalloc(tsize, GFP_KERNEL); in slhc_init()
116 if (! comp->tstate) in slhc_init()
118 comp->tslot_limit = tslots - 1; in slhc_init()
121 comp->xmit_oldest = 0; in slhc_init()
122 comp->xmit_current = 255; in slhc_init()
123 comp->recv_current = 255; in slhc_init()
130 comp->flags |= SLF_TOSS; in slhc_init()
133 ts = comp->tstate; in slhc_init()
134 for(i = comp->tslot_limit; i > 0; --i){ in slhc_init()
136 ts[i].next = &(ts[i - 1]); in slhc_init()
138 ts[0].next = &(ts[comp->tslot_limit]); in slhc_init()
144 kfree(comp->rstate); in slhc_init()
148 return ERR_PTR(-ENOMEM); in slhc_init()
159 if ( comp->tstate != NULLSLSTATE ) in slhc_free()
160 kfree( comp->tstate ); in slhc_free()
162 if ( comp->rstate != NULLSLSTATE ) in slhc_free()
163 kfree( comp->rstate ); in slhc_free()
180 /* Encode a number */
193 /* Pull a 16-bit integer in host order from buffer in network byte order */
205 /* Decode a number */
213 return pull16(cpp) & 0xffff; /* pull16 returns -1 on error */ in decode()
215 return x & 0xff; /* -1 if PULLCHAR returned error */ in decode()
230 struct cstate *ocs = &(comp->tstate[comp->xmit_oldest]); in slhc_compress()
232 struct cstate *cs = lcs->next; in slhc_compress() local
251 if (ip->version != 4 || ip->ihl < 5) in slhc_compress()
255 if (ip->protocol != IPPROTO_TCP || (ntohs(ip->frag_off) & 0x3fff)) { in slhc_compress()
257 if(ip->protocol != IPPROTO_TCP) in slhc_compress()
258 comp->sls_o_nontcp++; in slhc_compress()
260 comp->sls_o_tcp++; in slhc_compress()
263 nlen = ip->ihl * 4; in slhc_compress()
268 if (th->doff < sizeof(struct tcphdr) / 4) in slhc_compress()
270 hlen = nlen + th->doff * 4; in slhc_compress()
276 if(hlen > isize || th->syn || th->fin || th->rst || in slhc_compress()
277 ! (th->ack)){ in slhc_compress()
279 comp->sls_o_tcp++; in slhc_compress()
283 * Packet is compressible -- we're going to send either a in slhc_compress()
294 * for the datagram, the oldest state is (re-)used. in slhc_compress()
297 if( ip->saddr == cs->cs_ip.saddr in slhc_compress()
298 && ip->daddr == cs->cs_ip.daddr in slhc_compress()
299 && th->source == cs->cs_tcp.source in slhc_compress()
300 && th->dest == cs->cs_tcp.dest) in slhc_compress()
304 if ( cs == ocs ) in slhc_compress()
306 lcs = cs; in slhc_compress()
307 cs = cs->next; in slhc_compress()
308 comp->sls_o_searches++; in slhc_compress()
311 * Didn't find it -- re-use oldest cstate. Send an in slhc_compress()
313 * connection number we're using for this conversation. in slhc_compress()
319 comp->sls_o_misses++; in slhc_compress()
320 comp->xmit_oldest = lcs->cs_this; in slhc_compress()
325 * Found it -- move to the front on the connection list. in slhc_compress()
329 } else if (cs == ocs) { in slhc_compress()
331 comp->xmit_oldest = lcs->cs_this; in slhc_compress()
334 lcs->next = cs->next; in slhc_compress()
335 cs->next = ocs->next; in slhc_compress()
336 ocs->next = cs; in slhc_compress()
344 * The time-to-live field. in slhc_compress()
351 oth = &cs->cs_tcp; in slhc_compress()
353 if(ip->version != cs->cs_ip.version || ip->ihl != cs->cs_ip.ihl in slhc_compress()
354 || ip->tos != cs->cs_ip.tos in slhc_compress()
355 || (ip->frag_off & htons(0x4000)) != (cs->cs_ip.frag_off & htons(0x4000)) in slhc_compress()
356 || ip->ttl != cs->cs_ip.ttl in slhc_compress()
357 || th->doff != cs->cs_tcp.doff in slhc_compress()
358 || (ip->ihl > 5 && memcmp(ip+1,cs->cs_ipopt,((ip->ihl)-5)*4) != 0) in slhc_compress()
359 || (th->doff > 5 && memcmp(th+1,cs->cs_tcpopt,((th->doff)-5)*4) != 0)){ in slhc_compress()
366 * ack, seq (the order minimizes the number of temporaries in slhc_compress()
369 if(th->urg){ in slhc_compress()
370 deltaS = ntohs(th->urg_ptr); in slhc_compress()
373 } else if(th->urg_ptr != oth->urg_ptr){ in slhc_compress()
374 /* argh! URG not set but urp changed -- a sensible in slhc_compress()
380 if((deltaS = ntohs(th->window) - ntohs(oth->window)) != 0){ in slhc_compress()
384 if((deltaA = ntohl(th->ack_seq) - ntohl(oth->ack_seq)) != 0L){ in slhc_compress()
390 if((deltaS = ntohl(th->seq) - ntohl(oth->seq)) != 0L){ in slhc_compress()
405 if(ip->tot_len != cs->cs_ip.tot_len && in slhc_compress()
406 ntohs(cs->cs_ip.tot_len) == hlen) in slhc_compress()
411 /* actual changes match one of our special case encodings -- in slhc_compress()
417 deltaS == ntohs(cs->cs_ip.tot_len) - hlen){ in slhc_compress()
424 if(deltaS == ntohs(cs->cs_ip.tot_len) - hlen){ in slhc_compress()
431 deltaS = ntohs(ip->id) - ntohs(cs->cs_ip.id); in slhc_compress()
436 if(th->psh) in slhc_compress()
441 csum = th->check; in slhc_compress()
442 memcpy(&cs->cs_ip,ip,20); in slhc_compress()
443 memcpy(&cs->cs_tcp,th,20); in slhc_compress()
445 * (cp - new_seq) is the number of bytes we need for compressed in slhc_compress()
448 * So, (cp - new_seq) + 4 bytes of header are needed. in slhc_compress()
450 deltaS = cp - new_seq; in slhc_compress()
451 if(compress_cid == 0 || comp->xmit_current != cs->cs_this){ in slhc_compress()
455 *cp++ = cs->cs_this; in slhc_compress()
456 comp->xmit_current = cs->cs_this; in slhc_compress()
466 memcpy(cp+deltaS,icp+hlen,isize-hlen); in slhc_compress()
467 comp->sls_o_compressed++; in slhc_compress()
469 return isize - hlen + deltaS + (cp - ocp); in slhc_compress()
471 /* Update connection state cs & send uncompressed packet (i.e., in slhc_compress()
476 memcpy(&cs->cs_ip,ip,20); in slhc_compress()
477 memcpy(&cs->cs_tcp,th,20); in slhc_compress()
478 if (ip->ihl > 5) in slhc_compress()
479 memcpy(cs->cs_ipopt, ip+1, ((ip->ihl) - 5) * 4); in slhc_compress()
480 if (th->doff > 5) in slhc_compress()
481 memcpy(cs->cs_tcpopt, th+1, ((th->doff) - 5) * 4); in slhc_compress()
482 comp->xmit_current = cs->cs_this; in slhc_compress()
483 comp->sls_o_uncompressed++; in slhc_compress()
486 ocp[9] = cs->cs_this; in slhc_compress()
499 struct cstate *cs; in slhc_uncompress() local
504 comp->sls_i_compressed++; in slhc_uncompress()
506 comp->sls_i_error++; in slhc_uncompress()
515 if(x < 0 || x > comp->rslot_limit) in slhc_uncompress()
519 if (!comp->rstate[x].initialized) in slhc_uncompress()
522 comp->flags &=~ SLF_TOSS; in slhc_uncompress()
523 comp->recv_current = x; in slhc_uncompress()
528 if(comp->flags & SLF_TOSS){ in slhc_uncompress()
529 comp->sls_i_tossed++; in slhc_uncompress()
533 cs = &comp->rstate[comp->recv_current]; in slhc_uncompress()
534 thp = &cs->cs_tcp; in slhc_uncompress()
535 ip = &cs->cs_ip; in slhc_uncompress()
537 thp->check = *(__sum16 *)cp; in slhc_uncompress()
540 thp->psh = (changes & TCP_PUSH_BIT) ? 1 : 0; in slhc_uncompress()
542 * we can use the same number for the length of the saved header and in slhc_uncompress()
547 hdrlen = ip->ihl * 4 + thp->doff * 4; in slhc_uncompress()
553 i = ntohs(ip->tot_len) - hdrlen; in slhc_uncompress()
554 thp->ack_seq = htonl( ntohl(thp->ack_seq) + i); in slhc_uncompress()
555 thp->seq = htonl( ntohl(thp->seq) + i); in slhc_uncompress()
560 thp->seq = htonl( ntohl(thp->seq) + in slhc_uncompress()
561 ntohs(ip->tot_len) - hdrlen); in slhc_uncompress()
566 thp->urg = 1; in slhc_uncompress()
567 if((x = decode(&cp)) == -1) { in slhc_uncompress()
570 thp->urg_ptr = htons(x); in slhc_uncompress()
572 thp->urg = 0; in slhc_uncompress()
574 if((x = decode(&cp)) == -1) { in slhc_uncompress()
577 thp->window = htons( ntohs(thp->window) + x); in slhc_uncompress()
580 if((x = decode(&cp)) == -1) { in slhc_uncompress()
583 thp->ack_seq = htonl( ntohl(thp->ack_seq) + x); in slhc_uncompress()
586 if((x = decode(&cp)) == -1) { in slhc_uncompress()
589 thp->seq = htonl( ntohl(thp->seq) + x); in slhc_uncompress()
594 if((x = decode(&cp)) == -1) { in slhc_uncompress()
597 ip->id = htons (ntohs (ip->id) + x); in slhc_uncompress()
599 ip->id = htons (ntohs (ip->id) + 1); in slhc_uncompress()
607 len = isize - (cp - icp); in slhc_uncompress()
611 ip->tot_len = htons(len); in slhc_uncompress()
612 ip->check = 0; in slhc_uncompress()
614 memmove(icp + hdrlen, cp, len - hdrlen); in slhc_uncompress()
620 if (ip->ihl > 5) { in slhc_uncompress()
621 memcpy(cp, cs->cs_ipopt, (ip->ihl - 5) * 4); in slhc_uncompress()
622 cp += (ip->ihl - 5) * 4; in slhc_uncompress()
625 put_unaligned(ip_fast_csum(icp, ip->ihl), in slhc_uncompress()
626 &((struct iphdr *)icp)->check); in slhc_uncompress()
631 if (thp->doff > 5) { in slhc_uncompress()
632 memcpy(cp, cs->cs_tcpopt, ((thp->doff) - 5) * 4); in slhc_uncompress()
633 cp += ((thp->doff) - 5) * 4; in slhc_uncompress()
638 comp->sls_i_error++; in slhc_uncompress()
649 struct cstate *cs; in slhc_remember() local
657 comp->sls_i_runt++; in slhc_remember()
662 ihl = iph->ihl; in slhc_remember()
670 index = iph->protocol; in slhc_remember()
671 iph->protocol = IPPROTO_TCP; in slhc_remember()
675 comp->sls_i_badcheck++; in slhc_remember()
678 if (index > comp->rslot_limit) { in slhc_remember()
679 comp->sls_i_error++; in slhc_remember()
683 if (th->doff < sizeof(struct tcphdr) / 4) in slhc_remember()
685 if (isize < ihl * 4 + th->doff * 4) in slhc_remember()
688 cs = &comp->rstate[comp->recv_current = index]; in slhc_remember()
689 comp->flags &=~ SLF_TOSS; in slhc_remember()
690 memcpy(&cs->cs_ip, iph, sizeof(*iph)); in slhc_remember()
691 memcpy(&cs->cs_tcp, th, sizeof(*th)); in slhc_remember()
693 memcpy(cs->cs_ipopt, &iph[1], (ihl - 5) * 4); in slhc_remember()
694 if (th->doff > 5) in slhc_remember()
695 memcpy(cs->cs_tcpopt, &th[1], (th->doff - 5) * 4); in slhc_remember()
696 cs->cs_hsize = ihl*2 + th->doff*2; in slhc_remember()
697 cs->initialized = true; in slhc_remember()
701 comp->sls_i_uncompressed++; in slhc_remember()
711 comp->flags |= SLF_TOSS; in slhc_toss()
720 printk(KERN_DEBUG "Called IP function on non IP-system: slhc_toss"); in slhc_toss()
721 return -EINVAL; in slhc_toss()
726 printk(KERN_DEBUG "Called IP function on non IP-system: slhc_uncompress"); in slhc_uncompress()
727 return -EINVAL; in slhc_uncompress()
733 printk(KERN_DEBUG "Called IP function on non IP-system: slhc_compress"); in slhc_compress()
734 return -EINVAL; in slhc_compress()
740 printk(KERN_DEBUG "Called IP function on non IP-system: slhc_remember"); in slhc_remember()
741 return -EINVAL; in slhc_remember()
747 printk(KERN_DEBUG "Called IP function on non IP-system: slhc_free"); in slhc_free()
752 printk(KERN_DEBUG "Called IP function on non IP-system: slhc_init"); in slhc_init()