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