pandora: defconfig: update
[pandora-kernel.git] / drivers / net / slip / slhc.c
1 /*
2  * Routines to compress and uncompress tcp packets (for transmission
3  * over low speed serial lines).
4  *
5  * Copyright (c) 1989 Regents of the University of California.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  *      Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
21  *      - Initial distribution.
22  *
23  *
24  * modified for KA9Q Internet Software Package by
25  * Katie Stevens (dkstevens@ucdavis.edu)
26  * University of California, Davis
27  * Computing Services
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
33  *
34  *      - Feb 1991      Bill_Simpson@um.cc.umich.edu
35  *                      variable number of conversation slots
36  *                      allow zero or one slots
37  *                      separate routines
38  *                      status display
39  *      - Jul 1994      Dmitry Gorodchanin
40  *                      Fixes for memory leaks.
41  *      - Oct 1994      Dmitry Gorodchanin
42  *                      Modularization.
43  *      - Jan 1995      Bjorn Ekwall
44  *                      Use ip_fast_csum from ip.h
45  *      - July 1995     Christos A. Polyzols
46  *                      Spotted bug in tcp option checking
47  *
48  *
49  *      This module is a difficult issue. It's clearly inet code but it's also clearly
50  *      driver code belonging close to PPP and SLIP
51  */
52
53 #include <linux/module.h>
54 #include <linux/slab.h>
55 #include <linux/types.h>
56 #include <linux/string.h>
57 #include <linux/errno.h>
58 #include <linux/kernel.h>
59 #include <net/slhc_vj.h>
60
61 #ifdef CONFIG_INET
62 /* Entire module is for IP only */
63 #include <linux/mm.h>
64 #include <linux/socket.h>
65 #include <linux/sockios.h>
66 #include <linux/termios.h>
67 #include <linux/in.h>
68 #include <linux/fcntl.h>
69 #include <linux/inet.h>
70 #include <linux/netdevice.h>
71 #include <net/ip.h>
72 #include <net/protocol.h>
73 #include <net/icmp.h>
74 #include <net/tcp.h>
75 #include <linux/skbuff.h>
76 #include <net/sock.h>
77 #include <linux/timer.h>
78 #include <asm/system.h>
79 #include <asm/uaccess.h>
80 #include <net/checksum.h>
81 #include <asm/unaligned.h>
82
83 static unsigned char *encode(unsigned char *cp, unsigned short n);
84 static long decode(unsigned char **cpp);
85 static unsigned char * put16(unsigned char *cp, unsigned short x);
86 static unsigned short pull16(unsigned char **cpp);
87
88 /* Allocate compression data structure
89  *      slots must be in range 0 to 255 (zero meaning no compression)
90  * Returns pointer to structure or ERR_PTR() on error.
91  */
92 struct slcompress *
93 slhc_init(int rslots, int tslots)
94 {
95         register short i;
96         register struct cstate *ts;
97         struct slcompress *comp;
98
99         if (rslots < 0 || rslots > 255 || tslots < 0 || tslots > 255)
100                 return ERR_PTR(-EINVAL);
101
102         comp = kzalloc(sizeof(struct slcompress), GFP_KERNEL);
103         if (! comp)
104                 goto out_fail;
105
106         if (rslots > 0) {
107                 size_t rsize = rslots * sizeof(struct cstate);
108                 comp->rstate = kzalloc(rsize, GFP_KERNEL);
109                 if (! comp->rstate)
110                         goto out_free;
111                 comp->rslot_limit = rslots - 1;
112         }
113
114         if (tslots > 0) {
115                 size_t tsize = tslots * sizeof(struct cstate);
116                 comp->tstate = kzalloc(tsize, GFP_KERNEL);
117                 if (! comp->tstate)
118                         goto out_free2;
119                 comp->tslot_limit = tslots - 1;
120         }
121
122         comp->xmit_oldest = 0;
123         comp->xmit_current = 255;
124         comp->recv_current = 255;
125         /*
126          * don't accept any packets with implicit index until we get
127          * one with an explicit index.  Otherwise the uncompress code
128          * will try to use connection 255, which is almost certainly
129          * out of range
130          */
131         comp->flags |= SLF_TOSS;
132
133         if ( tslots > 0 ) {
134                 ts = comp->tstate;
135                 for(i = comp->tslot_limit; i > 0; --i){
136                         ts[i].cs_this = i;
137                         ts[i].next = &(ts[i - 1]);
138                 }
139                 ts[0].next = &(ts[comp->tslot_limit]);
140                 ts[0].cs_this = 0;
141         }
142         return comp;
143
144 out_free2:
145         kfree(comp->rstate);
146 out_free:
147         kfree(comp);
148 out_fail:
149         return ERR_PTR(-ENOMEM);
150 }
151
152
153 /* Free a compression data structure */
154 void
155 slhc_free(struct slcompress *comp)
156 {
157         if ( comp == NULLSLCOMPR )
158                 return;
159
160         if ( comp->tstate != NULLSLSTATE )
161                 kfree( comp->tstate );
162
163         if ( comp->rstate != NULLSLSTATE )
164                 kfree( comp->rstate );
165
166         kfree( comp );
167 }
168
169
170 /* Put a short in host order into a char array in network order */
171 static inline unsigned char *
172 put16(unsigned char *cp, unsigned short x)
173 {
174         *cp++ = x >> 8;
175         *cp++ = x;
176
177         return cp;
178 }
179
180
181 /* Encode a number */
182 static unsigned char *
183 encode(unsigned char *cp, unsigned short n)
184 {
185         if(n >= 256 || n == 0){
186                 *cp++ = 0;
187                 cp = put16(cp,n);
188         } else {
189                 *cp++ = n;
190         }
191         return cp;
192 }
193
194 /* Pull a 16-bit integer in host order from buffer in network byte order */
195 static unsigned short
196 pull16(unsigned char **cpp)
197 {
198         short rval;
199
200         rval = *(*cpp)++;
201         rval <<= 8;
202         rval |= *(*cpp)++;
203         return rval;
204 }
205
206 /* Decode a number */
207 static long
208 decode(unsigned char **cpp)
209 {
210         register int x;
211
212         x = *(*cpp)++;
213         if(x == 0){
214                 return pull16(cpp) & 0xffff;    /* pull16 returns -1 on error */
215         } else {
216                 return x & 0xff;                /* -1 if PULLCHAR returned error */
217         }
218 }
219
220 /*
221  * icp and isize are the original packet.
222  * ocp is a place to put a copy if necessary.
223  * cpp is initially a pointer to icp.  If the copy is used,
224  *    change it to ocp.
225  */
226
227 int
228 slhc_compress(struct slcompress *comp, unsigned char *icp, int isize,
229         unsigned char *ocp, unsigned char **cpp, int compress_cid)
230 {
231         register struct cstate *ocs = &(comp->tstate[comp->xmit_oldest]);
232         register struct cstate *lcs = ocs;
233         register struct cstate *cs = lcs->next;
234         register unsigned long deltaS, deltaA;
235         register short changes = 0;
236         int hlen;
237         unsigned char new_seq[16];
238         register unsigned char *cp = new_seq;
239         struct iphdr *ip;
240         struct tcphdr *th, *oth;
241         __sum16 csum;
242
243
244         /*
245          *      Don't play with runt packets.
246          */
247
248         if(isize<sizeof(struct iphdr))
249                 return isize;
250
251         ip = (struct iphdr *) icp;
252
253         /* Bail if this packet isn't TCP, or is an IP fragment */
254         if (ip->protocol != IPPROTO_TCP || (ntohs(ip->frag_off) & 0x3fff)) {
255                 /* Send as regular IP */
256                 if(ip->protocol != IPPROTO_TCP)
257                         comp->sls_o_nontcp++;
258                 else
259                         comp->sls_o_tcp++;
260                 return isize;
261         }
262         /* Extract TCP header */
263
264         th = (struct tcphdr *)(((unsigned char *)ip) + ip->ihl*4);
265         hlen = ip->ihl*4 + th->doff*4;
266
267         /*  Bail if the TCP packet isn't `compressible' (i.e., ACK isn't set or
268          *  some other control bit is set). Also uncompressible if
269          *  it's a runt.
270          */
271         if(hlen > isize || th->syn || th->fin || th->rst ||
272             ! (th->ack)){
273                 /* TCP connection stuff; send as regular IP */
274                 comp->sls_o_tcp++;
275                 return isize;
276         }
277         /*
278          * Packet is compressible -- we're going to send either a
279          * COMPRESSED_TCP or UNCOMPRESSED_TCP packet.  Either way,
280          * we need to locate (or create) the connection state.
281          *
282          * States are kept in a circularly linked list with
283          * xmit_oldest pointing to the end of the list.  The
284          * list is kept in lru order by moving a state to the
285          * head of the list whenever it is referenced.  Since
286          * the list is short and, empirically, the connection
287          * we want is almost always near the front, we locate
288          * states via linear search.  If we don't find a state
289          * for the datagram, the oldest state is (re-)used.
290          */
291         for ( ; ; ) {
292                 if( ip->saddr == cs->cs_ip.saddr
293                  && ip->daddr == cs->cs_ip.daddr
294                  && th->source == cs->cs_tcp.source
295                  && th->dest == cs->cs_tcp.dest)
296                         goto found;
297
298                 /* if current equal oldest, at end of list */
299                 if ( cs == ocs )
300                         break;
301                 lcs = cs;
302                 cs = cs->next;
303                 comp->sls_o_searches++;
304         }
305         /*
306          * Didn't find it -- re-use oldest cstate.  Send an
307          * uncompressed packet that tells the other side what
308          * connection number we're using for this conversation.
309          *
310          * Note that since the state list is circular, the oldest
311          * state points to the newest and we only need to set
312          * xmit_oldest to update the lru linkage.
313          */
314         comp->sls_o_misses++;
315         comp->xmit_oldest = lcs->cs_this;
316         goto uncompressed;
317
318 found:
319         /*
320          * Found it -- move to the front on the connection list.
321          */
322         if(lcs == ocs) {
323                 /* found at most recently used */
324         } else if (cs == ocs) {
325                 /* found at least recently used */
326                 comp->xmit_oldest = lcs->cs_this;
327         } else {
328                 /* more than 2 elements */
329                 lcs->next = cs->next;
330                 cs->next = ocs->next;
331                 ocs->next = cs;
332         }
333
334         /*
335          * Make sure that only what we expect to change changed.
336          * Check the following:
337          * IP protocol version, header length & type of service.
338          * The "Don't fragment" bit.
339          * The time-to-live field.
340          * The TCP header length.
341          * IP options, if any.
342          * TCP options, if any.
343          * If any of these things are different between the previous &
344          * current datagram, we send the current datagram `uncompressed'.
345          */
346         oth = &cs->cs_tcp;
347
348         if(ip->version != cs->cs_ip.version || ip->ihl != cs->cs_ip.ihl
349          || ip->tos != cs->cs_ip.tos
350          || (ip->frag_off & htons(0x4000)) != (cs->cs_ip.frag_off & htons(0x4000))
351          || ip->ttl != cs->cs_ip.ttl
352          || th->doff != cs->cs_tcp.doff
353          || (ip->ihl > 5 && memcmp(ip+1,cs->cs_ipopt,((ip->ihl)-5)*4) != 0)
354          || (th->doff > 5 && memcmp(th+1,cs->cs_tcpopt,((th->doff)-5)*4) != 0)){
355                 goto uncompressed;
356         }
357
358         /*
359          * Figure out which of the changing fields changed.  The
360          * receiver expects changes in the order: urgent, window,
361          * ack, seq (the order minimizes the number of temporaries
362          * needed in this section of code).
363          */
364         if(th->urg){
365                 deltaS = ntohs(th->urg_ptr);
366                 cp = encode(cp,deltaS);
367                 changes |= NEW_U;
368         } else if(th->urg_ptr != oth->urg_ptr){
369                 /* argh! URG not set but urp changed -- a sensible
370                  * implementation should never do this but RFC793
371                  * doesn't prohibit the change so we have to deal
372                  * with it. */
373                 goto uncompressed;
374         }
375         if((deltaS = ntohs(th->window) - ntohs(oth->window)) != 0){
376                 cp = encode(cp,deltaS);
377                 changes |= NEW_W;
378         }
379         if((deltaA = ntohl(th->ack_seq) - ntohl(oth->ack_seq)) != 0L){
380                 if(deltaA > 0x0000ffff)
381                         goto uncompressed;
382                 cp = encode(cp,deltaA);
383                 changes |= NEW_A;
384         }
385         if((deltaS = ntohl(th->seq) - ntohl(oth->seq)) != 0L){
386                 if(deltaS > 0x0000ffff)
387                         goto uncompressed;
388                 cp = encode(cp,deltaS);
389                 changes |= NEW_S;
390         }
391
392         switch(changes){
393         case 0: /* Nothing changed. If this packet contains data and the
394                  * last one didn't, this is probably a data packet following
395                  * an ack (normal on an interactive connection) and we send
396                  * it compressed.  Otherwise it's probably a retransmit,
397                  * retransmitted ack or window probe.  Send it uncompressed
398                  * in case the other side missed the compressed version.
399                  */
400                 if(ip->tot_len != cs->cs_ip.tot_len &&
401                    ntohs(cs->cs_ip.tot_len) == hlen)
402                         break;
403                 goto uncompressed;
404                 break;
405         case SPECIAL_I:
406         case SPECIAL_D:
407                 /* actual changes match one of our special case encodings --
408                  * send packet uncompressed.
409                  */
410                 goto uncompressed;
411         case NEW_S|NEW_A:
412                 if(deltaS == deltaA &&
413                     deltaS == ntohs(cs->cs_ip.tot_len) - hlen){
414                         /* special case for echoed terminal traffic */
415                         changes = SPECIAL_I;
416                         cp = new_seq;
417                 }
418                 break;
419         case NEW_S:
420                 if(deltaS == ntohs(cs->cs_ip.tot_len) - hlen){
421                         /* special case for data xfer */
422                         changes = SPECIAL_D;
423                         cp = new_seq;
424                 }
425                 break;
426         }
427         deltaS = ntohs(ip->id) - ntohs(cs->cs_ip.id);
428         if(deltaS != 1){
429                 cp = encode(cp,deltaS);
430                 changes |= NEW_I;
431         }
432         if(th->psh)
433                 changes |= TCP_PUSH_BIT;
434         /* Grab the cksum before we overwrite it below.  Then update our
435          * state with this packet's header.
436          */
437         csum = th->check;
438         memcpy(&cs->cs_ip,ip,20);
439         memcpy(&cs->cs_tcp,th,20);
440         /* We want to use the original packet as our compressed packet.
441          * (cp - new_seq) is the number of bytes we need for compressed
442          * sequence numbers.  In addition we need one byte for the change
443          * mask, one for the connection id and two for the tcp checksum.
444          * So, (cp - new_seq) + 4 bytes of header are needed.
445          */
446         deltaS = cp - new_seq;
447         if(compress_cid == 0 || comp->xmit_current != cs->cs_this){
448                 cp = ocp;
449                 *cpp = ocp;
450                 *cp++ = changes | NEW_C;
451                 *cp++ = cs->cs_this;
452                 comp->xmit_current = cs->cs_this;
453         } else {
454                 cp = ocp;
455                 *cpp = ocp;
456                 *cp++ = changes;
457         }
458         *(__sum16 *)cp = csum;
459         cp += 2;
460 /* deltaS is now the size of the change section of the compressed header */
461         memcpy(cp,new_seq,deltaS);      /* Write list of deltas */
462         memcpy(cp+deltaS,icp+hlen,isize-hlen);
463         comp->sls_o_compressed++;
464         ocp[0] |= SL_TYPE_COMPRESSED_TCP;
465         return isize - hlen + deltaS + (cp - ocp);
466
467         /* Update connection state cs & send uncompressed packet (i.e.,
468          * a regular ip/tcp packet but with the 'conversation id' we hope
469          * to use on future compressed packets in the protocol field).
470          */
471 uncompressed:
472         memcpy(&cs->cs_ip,ip,20);
473         memcpy(&cs->cs_tcp,th,20);
474         if (ip->ihl > 5)
475           memcpy(cs->cs_ipopt, ip+1, ((ip->ihl) - 5) * 4);
476         if (th->doff > 5)
477           memcpy(cs->cs_tcpopt, th+1, ((th->doff) - 5) * 4);
478         comp->xmit_current = cs->cs_this;
479         comp->sls_o_uncompressed++;
480         memcpy(ocp, icp, isize);
481         *cpp = ocp;
482         ocp[9] = cs->cs_this;
483         ocp[0] |= SL_TYPE_UNCOMPRESSED_TCP;
484         return isize;
485 }
486
487
488 int
489 slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
490 {
491         register int changes;
492         long x;
493         register struct tcphdr *thp;
494         register struct iphdr *ip;
495         register struct cstate *cs;
496         int len, hdrlen;
497         unsigned char *cp = icp;
498
499         /* We've got a compressed packet; read the change byte */
500         comp->sls_i_compressed++;
501         if(isize < 3){
502                 comp->sls_i_error++;
503                 return 0;
504         }
505         changes = *cp++;
506         if(changes & NEW_C){
507                 /* Make sure the state index is in range, then grab the state.
508                  * If we have a good state index, clear the 'discard' flag.
509                  */
510                 x = *cp++;      /* Read conn index */
511                 if(x < 0 || x > comp->rslot_limit)
512                         goto bad;
513
514                 comp->flags &=~ SLF_TOSS;
515                 comp->recv_current = x;
516         } else {
517                 /* this packet has an implicit state index.  If we've
518                  * had a line error since the last time we got an
519                  * explicit state index, we have to toss the packet. */
520                 if(comp->flags & SLF_TOSS){
521                         comp->sls_i_tossed++;
522                         return 0;
523                 }
524         }
525         cs = &comp->rstate[comp->recv_current];
526         thp = &cs->cs_tcp;
527         ip = &cs->cs_ip;
528
529         thp->check = *(__sum16 *)cp;
530         cp += 2;
531
532         thp->psh = (changes & TCP_PUSH_BIT) ? 1 : 0;
533 /*
534  * we can use the same number for the length of the saved header and
535  * the current one, because the packet wouldn't have been sent
536  * as compressed unless the options were the same as the previous one
537  */
538
539         hdrlen = ip->ihl * 4 + thp->doff * 4;
540
541         switch(changes & SPECIALS_MASK){
542         case SPECIAL_I:         /* Echoed terminal traffic */
543                 {
544                 register short i;
545                 i = ntohs(ip->tot_len) - hdrlen;
546                 thp->ack_seq = htonl( ntohl(thp->ack_seq) + i);
547                 thp->seq = htonl( ntohl(thp->seq) + i);
548                 }
549                 break;
550
551         case SPECIAL_D:                 /* Unidirectional data */
552                 thp->seq = htonl( ntohl(thp->seq) +
553                                   ntohs(ip->tot_len) - hdrlen);
554                 break;
555
556         default:
557                 if(changes & NEW_U){
558                         thp->urg = 1;
559                         if((x = decode(&cp)) == -1) {
560                                 goto bad;
561                         }
562                         thp->urg_ptr = htons(x);
563                 } else
564                         thp->urg = 0;
565                 if(changes & NEW_W){
566                         if((x = decode(&cp)) == -1) {
567                                 goto bad;
568                         }
569                         thp->window = htons( ntohs(thp->window) + x);
570                 }
571                 if(changes & NEW_A){
572                         if((x = decode(&cp)) == -1) {
573                                 goto bad;
574                         }
575                         thp->ack_seq = htonl( ntohl(thp->ack_seq) + x);
576                 }
577                 if(changes & NEW_S){
578                         if((x = decode(&cp)) == -1) {
579                                 goto bad;
580                         }
581                         thp->seq = htonl( ntohl(thp->seq) + x);
582                 }
583                 break;
584         }
585         if(changes & NEW_I){
586                 if((x = decode(&cp)) == -1) {
587                         goto bad;
588                 }
589                 ip->id = htons (ntohs (ip->id) + x);
590         } else
591                 ip->id = htons (ntohs (ip->id) + 1);
592
593         /*
594          * At this point, cp points to the first byte of data in the
595          * packet.  Put the reconstructed TCP and IP headers back on the
596          * packet.  Recalculate IP checksum (but not TCP checksum).
597          */
598
599         len = isize - (cp - icp);
600         if (len < 0)
601                 goto bad;
602         len += hdrlen;
603         ip->tot_len = htons(len);
604         ip->check = 0;
605
606         memmove(icp + hdrlen, cp, len - hdrlen);
607
608         cp = icp;
609         memcpy(cp, ip, 20);
610         cp += 20;
611
612         if (ip->ihl > 5) {
613           memcpy(cp, cs->cs_ipopt, (ip->ihl - 5) * 4);
614           cp += (ip->ihl - 5) * 4;
615         }
616
617         put_unaligned(ip_fast_csum(icp, ip->ihl),
618                       &((struct iphdr *)icp)->check);
619
620         memcpy(cp, thp, 20);
621         cp += 20;
622
623         if (thp->doff > 5) {
624           memcpy(cp, cs->cs_tcpopt, ((thp->doff) - 5) * 4);
625           cp += ((thp->doff) - 5) * 4;
626         }
627
628         return len;
629 bad:
630         comp->sls_i_error++;
631         return slhc_toss( comp );
632 }
633
634
635 int
636 slhc_remember(struct slcompress *comp, unsigned char *icp, int isize)
637 {
638         register struct cstate *cs;
639         unsigned ihl;
640
641         unsigned char index;
642
643         if(isize < 20) {
644                 /* The packet is shorter than a legal IP header */
645                 comp->sls_i_runt++;
646                 return slhc_toss( comp );
647         }
648         /* Peek at the IP header's IHL field to find its length */
649         ihl = icp[0] & 0xf;
650         if(ihl < 20 / 4){
651                 /* The IP header length field is too small */
652                 comp->sls_i_runt++;
653                 return slhc_toss( comp );
654         }
655         index = icp[9];
656         icp[9] = IPPROTO_TCP;
657
658         if (ip_fast_csum(icp, ihl)) {
659                 /* Bad IP header checksum; discard */
660                 comp->sls_i_badcheck++;
661                 return slhc_toss( comp );
662         }
663         if(index > comp->rslot_limit) {
664                 comp->sls_i_error++;
665                 return slhc_toss(comp);
666         }
667
668         /* Update local state */
669         cs = &comp->rstate[comp->recv_current = index];
670         comp->flags &=~ SLF_TOSS;
671         memcpy(&cs->cs_ip,icp,20);
672         memcpy(&cs->cs_tcp,icp + ihl*4,20);
673         if (ihl > 5)
674           memcpy(cs->cs_ipopt, icp + sizeof(struct iphdr), (ihl - 5) * 4);
675         if (cs->cs_tcp.doff > 5)
676           memcpy(cs->cs_tcpopt, icp + ihl*4 + sizeof(struct tcphdr), (cs->cs_tcp.doff - 5) * 4);
677         cs->cs_hsize = ihl*2 + cs->cs_tcp.doff*2;
678         /* Put headers back on packet
679          * Neither header checksum is recalculated
680          */
681         comp->sls_i_uncompressed++;
682         return isize;
683 }
684
685 int
686 slhc_toss(struct slcompress *comp)
687 {
688         if ( comp == NULLSLCOMPR )
689                 return 0;
690
691         comp->flags |= SLF_TOSS;
692         return 0;
693 }
694
695 #else /* CONFIG_INET */
696
697 int
698 slhc_toss(struct slcompress *comp)
699 {
700   printk(KERN_DEBUG "Called IP function on non IP-system: slhc_toss");
701   return -EINVAL;
702 }
703 int
704 slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
705 {
706   printk(KERN_DEBUG "Called IP function on non IP-system: slhc_uncompress");
707   return -EINVAL;
708 }
709 int
710 slhc_compress(struct slcompress *comp, unsigned char *icp, int isize,
711         unsigned char *ocp, unsigned char **cpp, int compress_cid)
712 {
713   printk(KERN_DEBUG "Called IP function on non IP-system: slhc_compress");
714   return -EINVAL;
715 }
716
717 int
718 slhc_remember(struct slcompress *comp, unsigned char *icp, int isize)
719 {
720   printk(KERN_DEBUG "Called IP function on non IP-system: slhc_remember");
721   return -EINVAL;
722 }
723
724 void
725 slhc_free(struct slcompress *comp)
726 {
727   printk(KERN_DEBUG "Called IP function on non IP-system: slhc_free");
728 }
729 struct slcompress *
730 slhc_init(int rslots, int tslots)
731 {
732   printk(KERN_DEBUG "Called IP function on non IP-system: slhc_init");
733   return NULL;
734 }
735
736 #endif /* CONFIG_INET */
737
738 /* VJ header compression */
739 EXPORT_SYMBOL(slhc_init);
740 EXPORT_SYMBOL(slhc_free);
741 EXPORT_SYMBOL(slhc_remember);
742 EXPORT_SYMBOL(slhc_compress);
743 EXPORT_SYMBOL(slhc_uncompress);
744 EXPORT_SYMBOL(slhc_toss);
745
746 MODULE_LICENSE("Dual BSD/GPL");