Annotation of 43BSDReno/sys/net/slcompress.h, revision 1.1

1.1     ! root        1: /*     slcompress.h    7.4     90/06/28        */
        !             2: /*
        !             3:  * Definitions for tcp compression routines.
        !             4:  *
        !             5:  * $Header: slcompress.h,v 1.10 89/12/31 08:53:02 van Exp $
        !             6:  *
        !             7:  * Copyright (c) 1989 Regents of the University of California.
        !             8:  * All rights reserved.
        !             9:  *
        !            10:  * Redistribution is only permitted until one year after the first shipment
        !            11:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
        !            12:  * binary forms are permitted provided that: (1) source distributions retain
        !            13:  * this entire copyright notice and comment, and (2) distributions including
        !            14:  * binaries display the following acknowledgement:  This product includes
        !            15:  * software developed by the University of California, Berkeley and its
        !            16:  * contributors'' in the documentation or other materials provided with the
        !            17:  * distribution and in all advertising materials mentioning features or use
        !            18:  * of this software.  Neither the name of the University nor the names of
        !            19:  * its contributors may be used to endorse or promote products derived from
        !            20:  * this software without specific prior written permission.
        !            21:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            22:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            23:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            24:  *
        !            25:  *     Van Jacobson ([email protected]), Dec 31, 1989:
        !            26:  *     - Initial distribution.
        !            27:  */
        !            28: 
        !            29: #define MAX_STATES 16          /* must be > 2 and < 256 */
        !            30: #define MAX_HDR MLEN           /* XXX 4bsd-ism: should really be 128 */
        !            31: 
        !            32: /*
        !            33:  * Compressed packet format:
        !            34:  *
        !            35:  * The first octet contains the packet type (top 3 bits), TCP
        !            36:  * 'push' bit, and flags that indicate which of the 4 TCP sequence
        !            37:  * numbers have changed (bottom 5 bits).  The next octet is a
        !            38:  * conversation number that associates a saved IP/TCP header with
        !            39:  * the compressed packet.  The next two octets are the TCP checksum
        !            40:  * from the original datagram.  The next 0 to 15 octets are
        !            41:  * sequence number changes, one change per bit set in the header
        !            42:  * (there may be no changes and there are two special cases where
        !            43:  * the receiver implicitly knows what changed -- see below).
        !            44:  * 
        !            45:  * There are 5 numbers which can change (they are always inserted
        !            46:  * in the following order): TCP urgent pointer, window,
        !            47:  * acknowlegement, sequence number and IP ID.  (The urgent pointer
        !            48:  * is different from the others in that its value is sent, not the
        !            49:  * change in value.)  Since typical use of SLIP links is biased
        !            50:  * toward small packets (see comments on MTU/MSS below), changes
        !            51:  * use a variable length coding with one octet for numbers in the
        !            52:  * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
        !            53:  * range 256 - 65535 or 0.  (If the change in sequence number or
        !            54:  * ack is more than 65535, an uncompressed packet is sent.)
        !            55:  */
        !            56: 
        !            57: /*
        !            58:  * Packet types (must not conflict with IP protocol version)
        !            59:  *
        !            60:  * The top nibble of the first octet is the packet type.  There are
        !            61:  * three possible types: IP (not proto TCP or tcp with one of the
        !            62:  * control flags set); uncompressed TCP (a normal IP/TCP packet but
        !            63:  * with the 8-bit protocol field replaced by an 8-bit connection id --
        !            64:  * this type of packet syncs the sender & receiver); and compressed
        !            65:  * TCP (described above).
        !            66:  *
        !            67:  * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
        !            68:  * is logically part of the 4-bit "changes" field that follows.  Top
        !            69:  * three bits are actual packet type.  For backward compatibility
        !            70:  * and in the interest of conserving bits, numbers are chosen so the
        !            71:  * IP protocol version number (4) which normally appears in this nibble
        !            72:  * means "IP packet".
        !            73:  */
        !            74: 
        !            75: /* packet types */
        !            76: #define TYPE_IP 0x40
        !            77: #define TYPE_UNCOMPRESSED_TCP 0x70
        !            78: #define TYPE_COMPRESSED_TCP 0x80
        !            79: #define TYPE_ERROR 0x00
        !            80: 
        !            81: /* Bits in first octet of compressed packet */
        !            82: #define NEW_C  0x40    /* flag bits for what changed in a packet */
        !            83: #define NEW_I  0x20
        !            84: #define NEW_S  0x08
        !            85: #define NEW_A  0x04
        !            86: #define NEW_W  0x02
        !            87: #define NEW_U  0x01
        !            88: 
        !            89: /* reserved, special-case values of above */
        !            90: #define SPECIAL_I (NEW_S|NEW_W|NEW_U)          /* echoed interactive traffic */
        !            91: #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U)    /* unidirectional data */
        !            92: #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
        !            93: 
        !            94: #define TCP_PUSH_BIT 0x10
        !            95: 
        !            96: 
        !            97: /*
        !            98:  * "state" data for each active tcp conversation on the wire.  This is
        !            99:  * basically a copy of the entire IP/TCP header from the last packet
        !           100:  * we saw from the conversation together with a small identifier
        !           101:  * the transmit & receive ends of the line use to locate saved header.
        !           102:  */
        !           103: struct cstate {
        !           104:        struct cstate *cs_next; /* next most recently used cstate (xmit only) */
        !           105:        u_short cs_hlen;        /* size of hdr (receive only) */
        !           106:        u_char cs_id;           /* connection # associated with this state */
        !           107:        u_char cs_filler;
        !           108:        union {
        !           109:                char csu_hdr[MAX_HDR];
        !           110:                struct ip csu_ip;       /* ip/tcp hdr from most recent packet */
        !           111:        } slcs_u;
        !           112: };
        !           113: #define cs_ip slcs_u.csu_ip
        !           114: #define cs_hdr slcs_u.csu_hdr
        !           115: 
        !           116: /*
        !           117:  * all the state data for one serial line (we need one of these
        !           118:  * per line).
        !           119:  */
        !           120: struct slcompress {
        !           121:        struct cstate *last_cs; /* most recently used tstate */
        !           122:        u_char last_recv;       /* last rcvd conn. id */
        !           123:        u_char last_xmit;       /* last sent conn. id */
        !           124:        u_short flags;
        !           125: #ifndef SL_NO_STATS
        !           126:        int sls_packets;        /* outbound packets */
        !           127:        int sls_compressed;     /* outbound compressed packets */
        !           128:        int sls_searches;       /* searches for connection state */
        !           129:        int sls_misses;         /* times couldn't find conn. state */
        !           130:        int sls_uncompressedin; /* inbound uncompressed packets */
        !           131:        int sls_compressedin;   /* inbound compressed packets */
        !           132:        int sls_errorin;        /* inbound unknown type packets */
        !           133:        int sls_tossed;         /* inbound packets tossed because of error */
        !           134: #endif
        !           135:        struct cstate tstate[MAX_STATES];       /* xmit connection states */
        !           136:        struct cstate rstate[MAX_STATES];       /* receive connection states */
        !           137: };
        !           138: /* flag values */
        !           139: #define SLF_TOSS 1             /* tossing rcvd frames because of input err */
        !           140: 
        !           141: extern void sl_compress_init(/* struct slcompress * */);
        !           142: extern u_char sl_compress_tcp(/* struct mbuf *, struct ip *,
        !           143:                                struct slcompress *, int compress_cid_flag */);
        !           144: extern int sl_uncompress_tcp(/* u_char **, int,  u_char, struct slcompress * */);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.