slcompress.h revision 190207
1234949Sbapt/* 2272953Srodrigc * Definitions for tcp compression routines. 3234949Sbapt * 4234949Sbapt * @(#) $Header: /tcpdump/master/tcpdump/slcompress.h,v 1.2 2000-10-09 02:03:44 guy Exp $ (LBL) 5272953Srodrigc * 6272953Srodrigc * Copyright (c) 1989, 1990, 1992, 1993 Regents of the University of 7268899Sbapt * California. All rights reserved. 8268899Sbapt * 9268899Sbapt * Redistribution and use in source and binary forms are permitted 10268899Sbapt * provided that the above copyright notice and this paragraph are 11268899Sbapt * duplicated in all such forms and that any documentation, 12268899Sbapt * advertising materials, and other materials related to such 13268899Sbapt * distribution and use acknowledge that the software was developed 14268899Sbapt * by the University of California, Berkeley. The name of the 15268899Sbapt * University may not be used to endorse or promote products derived 16272953Srodrigc * from this software without specific prior written permission. 17268899Sbapt * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 18268899Sbapt * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 19272953Srodrigc * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20268899Sbapt * 21268899Sbapt * Van Jacobson (van@ee.lbl.gov), Dec 31, 1989: 22268899Sbapt * - Initial distribution. 23268899Sbapt */ 24272953Srodrigc 25268899Sbapt/* 26268899Sbapt * Compressed packet format: 27268899Sbapt * 28268899Sbapt * The first octet contains the packet type (top 3 bits), TCP 29268899Sbapt * 'push' bit, and flags that indicate which of the 4 TCP sequence 30268899Sbapt * numbers have changed (bottom 5 bits). The next octet is a 31268899Sbapt * conversation number that associates a saved IP/TCP header with 32268899Sbapt * the compressed packet. The next two octets are the TCP checksum 33268899Sbapt * from the original datagram. The next 0 to 15 octets are 34268899Sbapt * sequence number changes, one change per bit set in the header 35268899Sbapt * (there may be no changes and there are two special cases where 36268899Sbapt * the receiver implicitly knows what changed -- see below). 37268899Sbapt * 38272953Srodrigc * There are 5 numbers which can change (they are always inserted 39268899Sbapt * in the following order): TCP urgent pointer, window, 40268899Sbapt * acknowlegement, sequence number and IP ID. (The urgent pointer 41268899Sbapt * is different from the others in that its value is sent, not the 42268899Sbapt * change in value.) Since typical use of SLIP links is biased 43268899Sbapt * toward small packets (see comments on MTU/MSS below), changes 44268899Sbapt * use a variable length coding with one octet for numbers in the 45268899Sbapt * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the 46268899Sbapt * range 256 - 65535 or 0. (If the change in sequence number or 47268899Sbapt * ack is more than 65535, an uncompressed packet is sent.) 48268899Sbapt */ 49268899Sbapt 50268899Sbapt/* 51268899Sbapt * Packet types (must not conflict with IP protocol version) 52268899Sbapt * 53268899Sbapt * The top nibble of the first octet is the packet type. There are 54268899Sbapt * three possible types: IP (not proto TCP or tcp with one of the 55268899Sbapt * control flags set); uncompressed TCP (a normal IP/TCP packet but 56268899Sbapt * with the 8-bit protocol field replaced by an 8-bit connection id -- 57268899Sbapt * this type of packet syncs the sender & receiver); and compressed 58234949Sbapt * TCP (described above). 59234949Sbapt * 60234949Sbapt * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and 61234949Sbapt * is logically part of the 4-bit "changes" field that follows. Top 62268899Sbapt * three bits are actual packet type. For backward compatibility 63268899Sbapt * and in the interest of conserving bits, numbers are chosen so the 64234949Sbapt * IP protocol version number (4) which normally appears in this nibble 65234949Sbapt * means "IP packet". 66234949Sbapt */ 67234949Sbapt 68234949Sbapt/* packet types */ 69234949Sbapt#define TYPE_IP 0x40 70272953Srodrigc#define TYPE_UNCOMPRESSED_TCP 0x70 71234949Sbapt#define TYPE_COMPRESSED_TCP 0x80 72234949Sbapt#define TYPE_ERROR 0x00 73234949Sbapt 74272953Srodrigc/* Bits in first octet of compressed packet */ 75268899Sbapt#define NEW_C 0x40 /* flag bits for what changed in a packet */ 76268899Sbapt#define NEW_I 0x20 77268899Sbapt#define NEW_S 0x08 78268899Sbapt#define NEW_A 0x04 79268899Sbapt#define NEW_W 0x02 80268899Sbapt#define NEW_U 0x01 81268899Sbapt 82268899Sbapt/* reserved, special-case values of above */ 83268899Sbapt#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ 84234949Sbapt#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ 85268899Sbapt#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) 86268899Sbapt 87268899Sbapt#define TCP_PUSH_BIT 0x10 88268899Sbapt