home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / internet / tcpipsrc / h / if / sl_compres < prev    next >
Text File  |  1995-02-20  |  4KB  |  114 lines

  1. #ifndef _sl_compress_h
  2. #define _sl_compress_h
  3.  
  4. struct net_ip {
  5.     unsigned int ip_hl:4;        /* header length */
  6.     unsigned int ip_v:4;        /* version */
  7.     unsigned int ip_tos:8;        /* type of service */
  8.     int    ip_len:16;        /* total length */
  9.     u_short    ip_id;            /* identification */
  10.     short    ip_off;            /* fragment offset field */
  11. #define    IP_DF 0x4000            /* dont fragment flag */
  12. #define    IP_MF 0x2000            /* more fragments flag */
  13. #define    IP_OFFMASK 0x1fff        /* mask for fragmenting bits */
  14.     u_char    ip_ttl;            /* time to live */
  15.     u_char    ip_p;            /* protocol */
  16.     u_short    ip_sum;            /* checksum */
  17.         unsigned int ip_src,ip_dst;    /* source and dest address */
  18. };
  19.  
  20.  
  21. /*
  22.  * Copyright (c) 1989 Regents of the University of California.
  23.  * All rights reserved.
  24.  *
  25.  * Redistribution and use in source and binary forms are
  26.  * permitted provided that the above copyright notice and this
  27.  * paragraph are duplicated in all such forms and that any
  28.  * documentation, advertising materials, and other materials
  29.  * related to such distribution and use acknowledge that the
  30.  * software was developed by the University of California,
  31.  * Berkeley.  The name of the University may not be used to
  32.  * endorse or promote products derived from this software
  33.  * without specific prior written permission.
  34.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS
  35.  * OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
  36.  * IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A
  37.  * PARTICULAR PURPOSE.
  38.  */
  39.  
  40. /*   A.1  Definitions and State Data */
  41.  
  42. #define MAX_STATES 16   /* must be >2 and <255 */
  43. #define MAX_HDR 128     /* max TCP+IP hdr length (by protocol def) */
  44.  
  45.    /* packet types */
  46. #define TYPE_IP 0x40
  47. #define TYPE_UNCOMPRESSED_TCP 0x70
  48. #define TYPE_COMPRESSED_TCP 0x80
  49. #define TYPE_ERROR 0x00 /* this is not a type that ever appears on
  50.                          * the wire.  The receive framer uses it to
  51.                          * tell the decompressor there was a packet
  52.                          * transmission error. */
  53. /*
  54.  * Bits in first octet of compressed packet
  55.  */
  56.  
  57. /* flag bits for what changed in a packet */
  58.  
  59. #define NEW_C  0x40
  60. #define NEW_I  0x20
  61. #define TCP_PUSH_BIT 0x10
  62.  
  63. #define NEW_S  0x08
  64. #define NEW_A  0x04
  65. #define NEW_W  0x02
  66. #define NEW_U  0x01
  67.  
  68. /* reserved, special-case values of above */
  69. #define SPECIAL_I (NEW_S|NEW_W|NEW_U)        /* echoed interactive traffic */
  70. #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U)  /* unidirectional data */
  71. #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
  72.  
  73.  
  74. /*
  75.  * "state" data for each active tcp conversation on the wire.  This is
  76.  * basically a copy of the entire IP/TCP header from the last packet together
  77.  * with a small identifier the transmit & receive ends of the line use to
  78.  * locate saved header.
  79.  */
  80. struct cstate {
  81.      struct cstate *cs_next;  /* next most recently used cstate (xmit only) */
  82.      u_short cs_hlen;         /* size of hdr (receive only) */
  83.      u_char cs_id;            /* connection # associated with this state */
  84.      u_char cs_filler;
  85.      union {
  86.           struct net_ip csu_ip;   /* ip/tcp hdr from most recent packet */
  87.           char hdr[MAX_HDR];
  88.      } slcs_u;
  89. };
  90.  
  91. #define cs_ip slcs_u.csu_ip
  92. #define cs_hdr slcs_u.csu_hdr
  93.  
  94. /*
  95.  * all the state data for one serial line (we need one of these per line).
  96.  */
  97. struct slcompress {
  98.      struct cstate *last_cs;            /* most recently used tstate */
  99.      u_char last_recv;                  /* last rcvd conn. id */
  100.      u_char last_xmit;                  /* last sent conn. id */
  101.      u_short flags;
  102.      struct cstate tstate[MAX_STATES];  /* xmit connection states */
  103.      struct cstate rstate[MAX_STATES];  /* receive connection states */
  104. };
  105.  
  106.    /* flag values */
  107. #define SLF_TOSS 1       /* tossing rcvd frames because of input err */
  108.  
  109. int sl_compress_init(struct slcompress **compptr);
  110. u_char sl_compress_tcp(char **bufp, int *len, struct slcompress *comp, int compress_cid);
  111. u_char *sl_uncompress_tcp(char *bufp, int *len, u_int type, struct slcompress *comp);
  112.  
  113. #endif
  114.