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