slcompress.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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@ee.lbl.gov), Dec 31, 1989:
  20. * - Initial distribution.
  21. */
  22. /*
  23. * Compressed packet format:
  24. *
  25. * The first octet contains the packet type (top 3 bits), TCP
  26. * 'push' bit, and flags that indicate which of the 4 TCP sequence
  27. * numbers have changed (bottom 5 bits). The next octet is a
  28. * conversation number that associates a saved IP/TCP header with
  29. * the compressed packet. The next two octets are the TCP checksum
  30. * from the original datagram. The next 0 to 15 octets are
  31. * sequence number changes, one change per bit set in the header
  32. * (there may be no changes and there are two special cases where
  33. * the receiver implicitly knows what changed -- see below).
  34. *
  35. * There are 5 numbers which can change (they are always inserted
  36. * in the following order): TCP urgent pointer, window,
  37. * acknowlegement, sequence number and IP ID. (The urgent pointer
  38. * is different from the others in that its value is sent, not the
  39. * change in value.) Since typical use of SLIP links is biased
  40. * toward small packets (see comments on MTU/MSS below), changes
  41. * use a variable length coding with one octet for numbers in the
  42. * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
  43. * range 256 - 65535 or 0. (If the change in sequence number or
  44. * ack is more than 65535, an uncompressed packet is sent.)
  45. */
  46. /*
  47. * Packet types (must not conflict with IP protocol version)
  48. *
  49. * The top nibble of the first octet is the packet type. There are
  50. * three possible types: IP (not proto TCP or tcp with one of the
  51. * control flags set); uncompressed TCP (a normal IP/TCP packet but
  52. * with the 8-bit protocol field replaced by an 8-bit connection id --
  53. * this type of packet syncs the sender & receiver); and compressed
  54. * TCP (described above).
  55. *
  56. * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
  57. * is logically part of the 4-bit "changes" field that follows. Top
  58. * three bits are actual packet type. For backward compatibility
  59. * and in the interest of conserving bits, numbers are chosen so the
  60. * IP protocol version number (4) which normally appears in this nibble
  61. * means "IP packet".
  62. */
  63. /* packet types */
  64. #define TYPE_IP 0x40
  65. #define TYPE_UNCOMPRESSED_TCP 0x70
  66. #define TYPE_COMPRESSED_TCP 0x80
  67. #define TYPE_ERROR 0x00
  68. /* Bits in first octet of compressed packet */
  69. #define NEW_C 0x40 /* flag bits for what changed in a packet */
  70. #define NEW_I 0x20
  71. #define NEW_S 0x08
  72. #define NEW_A 0x04
  73. #define NEW_W 0x02
  74. #define NEW_U 0x01
  75. /* reserved, special-case values of above */
  76. #define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
  77. #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
  78. #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
  79. #define TCP_PUSH_BIT 0x10