HAMMER: MFC to 2.0
[dragonfly.git] / contrib / tcpdump-3.9 / slcompress.h
blobd8a596cf5290374de994de551ee1b53f780f9d82
1 /*
2 * Definitions for tcp compression routines.
4 * @(#) $Header: /tcpdump/master/tcpdump/slcompress.h,v 1.2 2000/10/09 02:03:44 guy Exp $ (LBL)
6 * Copyright (c) 1989, 1990, 1992, 1993 Regents of the University of
7 * California. All rights reserved.
9 * Redistribution and use in source and binary forms are permitted
10 * provided that the above copyright notice and this paragraph are
11 * duplicated in all such forms and that any documentation,
12 * advertising materials, and other materials related to such
13 * distribution and use acknowledge that the software was developed
14 * by the University of California, Berkeley. The name of the
15 * University may not be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * Van Jacobson (van@ee.lbl.gov), Dec 31, 1989:
22 * - Initial distribution.
26 * Compressed packet format:
28 * The first octet contains the packet type (top 3 bits), TCP
29 * 'push' bit, and flags that indicate which of the 4 TCP sequence
30 * numbers have changed (bottom 5 bits). The next octet is a
31 * conversation number that associates a saved IP/TCP header with
32 * the compressed packet. The next two octets are the TCP checksum
33 * from the original datagram. The next 0 to 15 octets are
34 * sequence number changes, one change per bit set in the header
35 * (there may be no changes and there are two special cases where
36 * the receiver implicitly knows what changed -- see below).
38 * There are 5 numbers which can change (they are always inserted
39 * in the following order): TCP urgent pointer, window,
40 * acknowlegement, sequence number and IP ID. (The urgent pointer
41 * is different from the others in that its value is sent, not the
42 * change in value.) Since typical use of SLIP links is biased
43 * toward small packets (see comments on MTU/MSS below), changes
44 * use a variable length coding with one octet for numbers in the
45 * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
46 * range 256 - 65535 or 0. (If the change in sequence number or
47 * ack is more than 65535, an uncompressed packet is sent.)
51 * Packet types (must not conflict with IP protocol version)
53 * The top nibble of the first octet is the packet type. There are
54 * three possible types: IP (not proto TCP or tcp with one of the
55 * control flags set); uncompressed TCP (a normal IP/TCP packet but
56 * with the 8-bit protocol field replaced by an 8-bit connection id --
57 * this type of packet syncs the sender & receiver); and compressed
58 * TCP (described above).
60 * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
61 * is logically part of the 4-bit "changes" field that follows. Top
62 * three bits are actual packet type. For backward compatibility
63 * and in the interest of conserving bits, numbers are chosen so the
64 * IP protocol version number (4) which normally appears in this nibble
65 * means "IP packet".
68 /* packet types */
69 #define TYPE_IP 0x40
70 #define TYPE_UNCOMPRESSED_TCP 0x70
71 #define TYPE_COMPRESSED_TCP 0x80
72 #define TYPE_ERROR 0x00
74 /* Bits in first octet of compressed packet */
75 #define NEW_C 0x40 /* flag bits for what changed in a packet */
76 #define NEW_I 0x20
77 #define NEW_S 0x08
78 #define NEW_A 0x04
79 #define NEW_W 0x02
80 #define NEW_U 0x01
82 /* reserved, special-case values of above */
83 #define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
84 #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
85 #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
87 #define TCP_PUSH_BIT 0x10