]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/lwIP_MCF5235_GCC/lwip/src/netif/ppp/vj.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / lwIP_MCF5235_GCC / lwip / src / netif / ppp / vj.h
1 /*\r
2  * Definitions for tcp compression routines.\r
3  *\r
4  * $Id: vj.h,v 1.2 2006/08/29 18:53:47 wolti Exp $\r
5  *\r
6  * Copyright (c) 1989 Regents of the University of California.\r
7  * All rights reserved.\r
8  *\r
9  * Redistribution and use in source and binary forms are permitted\r
10  * provided that the above copyright notice and this paragraph are\r
11  * duplicated in all such forms and that any documentation,\r
12  * advertising materials, and other materials related to such\r
13  * distribution and use acknowledge that the software was developed\r
14  * by the University of California, Berkeley.  The name of the\r
15  * University may not be used to endorse or promote products derived\r
16  * from this software without specific prior written permission.\r
17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR\r
18  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED\r
19  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\r
20  *\r
21  *      Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:\r
22  *      - Initial distribution.\r
23  */\r
24 \r
25 #ifndef VJ_H\r
26 #define VJ_H\r
27 \r
28 #include "vjbsdhdr.h"\r
29 \r
30 #define MAX_SLOTS       16                      /* must be > 2 and < 256 */\r
31 #define MAX_HDR         128\r
32 \r
33 /*\r
34  * Compressed packet format:\r
35  *\r
36  * The first octet contains the packet type (top 3 bits), TCP\r
37  * 'push' bit, and flags that indicate which of the 4 TCP sequence\r
38  * numbers have changed (bottom 5 bits).  The next octet is a\r
39  * conversation number that associates a saved IP/TCP header with\r
40  * the compressed packet.  The next two octets are the TCP checksum\r
41  * from the original datagram.  The next 0 to 15 octets are\r
42  * sequence number changes, one change per bit set in the header\r
43  * (there may be no changes and there are two special cases where\r
44  * the receiver implicitly knows what changed -- see below).\r
45  * \r
46  * There are 5 numbers which can change (they are always inserted\r
47  * in the following order): TCP urgent pointer, window,\r
48  * acknowlegement, sequence number and IP ID.  (The urgent pointer\r
49  * is different from the others in that its value is sent, not the\r
50  * change in value.)  Since typical use of SLIP links is biased\r
51  * toward small packets (see comments on MTU/MSS below), changes\r
52  * use a variable length coding with one octet for numbers in the\r
53  * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the\r
54  * range 256 - 65535 or 0.  (If the change in sequence number or\r
55  * ack is more than 65535, an uncompressed packet is sent.)\r
56  */\r
57 \r
58 /*\r
59  * Packet types (must not conflict with IP protocol version)\r
60  *\r
61  * The top nibble of the first octet is the packet type.  There are\r
62  * three possible types: IP (not proto TCP or tcp with one of the\r
63  * control flags set); uncompressed TCP (a normal IP/TCP packet but\r
64  * with the 8-bit protocol field replaced by an 8-bit connection id --\r
65  * this type of packet syncs the sender & receiver); and compressed\r
66  * TCP (described above).\r
67  *\r
68  * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and\r
69  * is logically part of the 4-bit "changes" field that follows.  Top\r
70  * three bits are actual packet type.  For backward compatibility\r
71  * and in the interest of conserving bits, numbers are chosen so the\r
72  * IP protocol version number (4) which normally appears in this nibble\r
73  * means "IP packet".\r
74  */\r
75 \r
76 /* packet types */\r
77 #define TYPE_IP 0x40\r
78 #define TYPE_UNCOMPRESSED_TCP 0x70\r
79 #define TYPE_COMPRESSED_TCP 0x80\r
80 #define TYPE_ERROR 0x00\r
81 \r
82 /* Bits in first octet of compressed packet */\r
83 #define NEW_C   0x40    /* flag bits for what changed in a packet */\r
84 #define NEW_I   0x20\r
85 #define NEW_S   0x08\r
86 #define NEW_A   0x04\r
87 #define NEW_W   0x02\r
88 #define NEW_U   0x01\r
89 \r
90 /* reserved, special-case values of above */\r
91 #define SPECIAL_I (NEW_S|NEW_W|NEW_U)           /* echoed interactive traffic */\r
92 #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U)     /* unidirectional data */\r
93 #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)\r
94 \r
95 #define TCP_PUSH_BIT 0x10\r
96 \r
97 \r
98 /*\r
99  * "state" data for each active tcp conversation on the wire.  This is\r
100  * basically a copy of the entire IP/TCP header from the last packet\r
101  * we saw from the conversation together with a small identifier\r
102  * the transmit & receive ends of the line use to locate saved header.\r
103  */\r
104 struct cstate {\r
105     struct cstate *cs_next;     /* next most recently used state (xmit only) */\r
106     u_short cs_hlen;            /* size of hdr (receive only) */\r
107     u_char cs_id;                       /* connection # associated with this state */\r
108     u_char cs_filler;\r
109     union {\r
110                 char csu_hdr[MAX_HDR];\r
111                 struct ip csu_ip;       /* ip/tcp hdr from most recent packet */\r
112     } vjcs_u;\r
113 };\r
114 #define cs_ip vjcs_u.csu_ip\r
115 #define cs_hdr vjcs_u.csu_hdr\r
116 \r
117 \r
118 struct vjstat {\r
119     unsigned long vjs_packets;                  /* outbound packets */\r
120     unsigned long vjs_compressed;               /* outbound compressed packets */\r
121     unsigned long vjs_searches;                 /* searches for connection state */\r
122     unsigned long vjs_misses;                   /* times couldn't find conn. state */\r
123     unsigned long vjs_uncompressedin;   /* inbound uncompressed packets */\r
124     unsigned long vjs_compressedin;             /* inbound compressed packets */\r
125     unsigned long vjs_errorin;                  /* inbound unknown type packets */\r
126     unsigned long vjs_tossed;                   /* inbound packets tossed because of error */\r
127 };\r
128 \r
129 /*\r
130  * all the state data for one serial line (we need one of these per line).\r
131  */\r
132 struct vjcompress {\r
133     struct cstate *last_cs;     /* most recently used tstate */\r
134     u_char last_recv;           /* last rcvd conn. id */\r
135     u_char last_xmit;           /* last sent conn. id */\r
136     u_short flags;\r
137     u_char maxSlotIndex;\r
138     u_char compressSlot;        /* Flag indicating OK to compress slot ID. */\r
139 #if LINK_STATS\r
140     struct vjstat stats;\r
141 #endif\r
142     struct cstate tstate[MAX_SLOTS];    /* xmit connection states */\r
143     struct cstate rstate[MAX_SLOTS];    /* receive connection states */\r
144 };\r
145 \r
146 /* flag values */\r
147 #define VJF_TOSS 1U             /* tossing rcvd frames because of input err */\r
148 \r
149 extern void  vj_compress_init (struct vjcompress *comp);\r
150 extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb);\r
151 extern void  vj_uncompress_err (struct vjcompress *comp);\r
152 extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp);\r
153 extern int vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp);\r
154 \r
155 #endif /* VJ_H */\r