Make the LINT kernel compile with -W -Wreturn-type -Wcomment -Werror, and
[unix-history] / sys / net / slcompress.h
CommitLineData
15637ed4
RG
1/* slcompress.h 7.4 90/06/28 */
2/*
3 * Definitions for tcp compression routines.
4 *
8ace4366 5 * $Id: slcompress.h,v 1.2 1993/08/27 02:10:32 rgrimes Exp $
8b3438a6
RG
6 * From: slcompress.h,v 1.13 1993/08/09 02:37:32 paulus Exp
7 * From: slcompress.h,v 1.10 89/12/31 08:53:02 van Exp
15637ed4
RG
8 *
9 * Copyright (c) 1989 Regents of the University of California.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
41 * - Initial distribution.
8b3438a6
RG
42 *
43 * Paul Mackerras (paulus@cs.anu.edu.au), June 1993:
44 * - added sl_uncompress_tcp_part.
15637ed4
RG
45 */
46
8ace4366
GW
47#ifndef _NET_SLCOMPRESS_H_
48#define _NET_SLCOMPRESS_H_ 1
49
15637ed4
RG
50#define MAX_STATES 16 /* must be > 2 and < 256 */
51#define MAX_HDR MLEN /* XXX 4bsd-ism: should really be 128 */
52
53/*
54 * Compressed packet format:
55 *
56 * The first octet contains the packet type (top 3 bits), TCP
57 * 'push' bit, and flags that indicate which of the 4 TCP sequence
58 * numbers have changed (bottom 5 bits). The next octet is a
59 * conversation number that associates a saved IP/TCP header with
60 * the compressed packet. The next two octets are the TCP checksum
61 * from the original datagram. The next 0 to 15 octets are
62 * sequence number changes, one change per bit set in the header
63 * (there may be no changes and there are two special cases where
64 * the receiver implicitly knows what changed -- see below).
65 *
66 * There are 5 numbers which can change (they are always inserted
67 * in the following order): TCP urgent pointer, window,
68 * acknowlegement, sequence number and IP ID. (The urgent pointer
69 * is different from the others in that its value is sent, not the
70 * change in value.) Since typical use of SLIP links is biased
71 * toward small packets (see comments on MTU/MSS below), changes
72 * use a variable length coding with one octet for numbers in the
73 * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
74 * range 256 - 65535 or 0. (If the change in sequence number or
75 * ack is more than 65535, an uncompressed packet is sent.)
76 */
77
78/*
79 * Packet types (must not conflict with IP protocol version)
80 *
81 * The top nibble of the first octet is the packet type. There are
82 * three possible types: IP (not proto TCP or tcp with one of the
83 * control flags set); uncompressed TCP (a normal IP/TCP packet but
84 * with the 8-bit protocol field replaced by an 8-bit connection id --
85 * this type of packet syncs the sender & receiver); and compressed
86 * TCP (described above).
87 *
88 * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
89 * is logically part of the 4-bit "changes" field that follows. Top
90 * three bits are actual packet type. For backward compatibility
91 * and in the interest of conserving bits, numbers are chosen so the
92 * IP protocol version number (4) which normally appears in this nibble
93 * means "IP packet".
94 */
95
96/* packet types */
97#define TYPE_IP 0x40
98#define TYPE_UNCOMPRESSED_TCP 0x70
99#define TYPE_COMPRESSED_TCP 0x80
100#define TYPE_ERROR 0x00
101
102/* Bits in first octet of compressed packet */
103#define NEW_C 0x40 /* flag bits for what changed in a packet */
104#define NEW_I 0x20
105#define NEW_S 0x08
106#define NEW_A 0x04
107#define NEW_W 0x02
108#define NEW_U 0x01
109
110/* reserved, special-case values of above */
111#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
112#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
113#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
114
115#define TCP_PUSH_BIT 0x10
116
117
118/*
119 * "state" data for each active tcp conversation on the wire. This is
120 * basically a copy of the entire IP/TCP header from the last packet
121 * we saw from the conversation together with a small identifier
122 * the transmit & receive ends of the line use to locate saved header.
123 */
124struct cstate {
125 struct cstate *cs_next; /* next most recently used cstate (xmit only) */
126 u_short cs_hlen; /* size of hdr (receive only) */
127 u_char cs_id; /* connection # associated with this state */
128 u_char cs_filler;
129 union {
130 char csu_hdr[MAX_HDR];
131 struct ip csu_ip; /* ip/tcp hdr from most recent packet */
132 } slcs_u;
133};
134#define cs_ip slcs_u.csu_ip
135#define cs_hdr slcs_u.csu_hdr
136
137/*
138 * all the state data for one serial line (we need one of these
139 * per line).
140 */
141struct slcompress {
142 struct cstate *last_cs; /* most recently used tstate */
143 u_char last_recv; /* last rcvd conn. id */
144 u_char last_xmit; /* last sent conn. id */
145 u_short flags;
146#ifndef SL_NO_STATS
147 int sls_packets; /* outbound packets */
148 int sls_compressed; /* outbound compressed packets */
149 int sls_searches; /* searches for connection state */
150 int sls_misses; /* times couldn't find conn. state */
151 int sls_uncompressedin; /* inbound uncompressed packets */
152 int sls_compressedin; /* inbound compressed packets */
153 int sls_errorin; /* inbound unknown type packets */
154 int sls_tossed; /* inbound packets tossed because of error */
155#endif
156 struct cstate tstate[MAX_STATES]; /* xmit connection states */
157 struct cstate rstate[MAX_STATES]; /* receive connection states */
158};
159/* flag values */
160#define SLF_TOSS 1 /* tossing rcvd frames because of input err */
161
8b3438a6
RG
162extern void sl_compress_init __P((struct slcompress *));
163extern u_char sl_compress_tcp __P((struct mbuf *m, struct ip *ip,
164 struct slcompress *, int comp_cid_flag));
165extern int sl_uncompress_tcp __P((u_char **bufp, int len, u_int type,
166 struct slcompress *));
167extern int sl_uncompress_tcp_part __P((u_char **bufp, int buflen,
168 int total_len, u_int type,
169 struct slcompress *));
8ace4366 170#endif /* _NET_SLCOMPRESS_H_ */