Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sherckuith 0:479ce5546098 1 /*
sherckuith 0:479ce5546098 2 * Definitions for tcp compression routines.
sherckuith 0:479ce5546098 3 *
sherckuith 0:479ce5546098 4 * $Id: vj.h,v 1.7 2010/02/22 17:52:09 goldsimon Exp $
sherckuith 0:479ce5546098 5 *
sherckuith 0:479ce5546098 6 * Copyright (c) 1989 Regents of the University of California.
sherckuith 0:479ce5546098 7 * All rights reserved.
sherckuith 0:479ce5546098 8 *
sherckuith 0:479ce5546098 9 * Redistribution and use in source and binary forms are permitted
sherckuith 0:479ce5546098 10 * provided that the above copyright notice and this paragraph are
sherckuith 0:479ce5546098 11 * duplicated in all such forms and that any documentation,
sherckuith 0:479ce5546098 12 * advertising materials, and other materials related to such
sherckuith 0:479ce5546098 13 * distribution and use acknowledge that the software was developed
sherckuith 0:479ce5546098 14 * by the University of California, Berkeley. The name of the
sherckuith 0:479ce5546098 15 * University may not be used to endorse or promote products derived
sherckuith 0:479ce5546098 16 * from this software without specific prior written permission.
sherckuith 0:479ce5546098 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
sherckuith 0:479ce5546098 18 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
sherckuith 0:479ce5546098 19 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
sherckuith 0:479ce5546098 20 *
sherckuith 0:479ce5546098 21 * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
sherckuith 0:479ce5546098 22 * - Initial distribution.
sherckuith 0:479ce5546098 23 */
sherckuith 0:479ce5546098 24
sherckuith 0:479ce5546098 25 #ifndef VJ_H
sherckuith 0:479ce5546098 26 #define VJ_H
sherckuith 0:479ce5546098 27
sherckuith 0:479ce5546098 28 #include "lwip/ip.h"
sherckuith 0:479ce5546098 29 #include "lwip/tcp_impl.h"
sherckuith 0:479ce5546098 30
sherckuith 0:479ce5546098 31 #define MAX_SLOTS 16 /* must be > 2 and < 256 */
sherckuith 0:479ce5546098 32 #define MAX_HDR 128
sherckuith 0:479ce5546098 33
sherckuith 0:479ce5546098 34 /*
sherckuith 0:479ce5546098 35 * Compressed packet format:
sherckuith 0:479ce5546098 36 *
sherckuith 0:479ce5546098 37 * The first octet contains the packet type (top 3 bits), TCP
sherckuith 0:479ce5546098 38 * 'push' bit, and flags that indicate which of the 4 TCP sequence
sherckuith 0:479ce5546098 39 * numbers have changed (bottom 5 bits). The next octet is a
sherckuith 0:479ce5546098 40 * conversation number that associates a saved IP/TCP header with
sherckuith 0:479ce5546098 41 * the compressed packet. The next two octets are the TCP checksum
sherckuith 0:479ce5546098 42 * from the original datagram. The next 0 to 15 octets are
sherckuith 0:479ce5546098 43 * sequence number changes, one change per bit set in the header
sherckuith 0:479ce5546098 44 * (there may be no changes and there are two special cases where
sherckuith 0:479ce5546098 45 * the receiver implicitly knows what changed -- see below).
sherckuith 0:479ce5546098 46 *
sherckuith 0:479ce5546098 47 * There are 5 numbers which can change (they are always inserted
sherckuith 0:479ce5546098 48 * in the following order): TCP urgent pointer, window,
sherckuith 0:479ce5546098 49 * acknowlegement, sequence number and IP ID. (The urgent pointer
sherckuith 0:479ce5546098 50 * is different from the others in that its value is sent, not the
sherckuith 0:479ce5546098 51 * change in value.) Since typical use of SLIP links is biased
sherckuith 0:479ce5546098 52 * toward small packets (see comments on MTU/MSS below), changes
sherckuith 0:479ce5546098 53 * use a variable length coding with one octet for numbers in the
sherckuith 0:479ce5546098 54 * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
sherckuith 0:479ce5546098 55 * range 256 - 65535 or 0. (If the change in sequence number or
sherckuith 0:479ce5546098 56 * ack is more than 65535, an uncompressed packet is sent.)
sherckuith 0:479ce5546098 57 */
sherckuith 0:479ce5546098 58
sherckuith 0:479ce5546098 59 /*
sherckuith 0:479ce5546098 60 * Packet types (must not conflict with IP protocol version)
sherckuith 0:479ce5546098 61 *
sherckuith 0:479ce5546098 62 * The top nibble of the first octet is the packet type. There are
sherckuith 0:479ce5546098 63 * three possible types: IP (not proto TCP or tcp with one of the
sherckuith 0:479ce5546098 64 * control flags set); uncompressed TCP (a normal IP/TCP packet but
sherckuith 0:479ce5546098 65 * with the 8-bit protocol field replaced by an 8-bit connection id --
sherckuith 0:479ce5546098 66 * this type of packet syncs the sender & receiver); and compressed
sherckuith 0:479ce5546098 67 * TCP (described above).
sherckuith 0:479ce5546098 68 *
sherckuith 0:479ce5546098 69 * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
sherckuith 0:479ce5546098 70 * is logically part of the 4-bit "changes" field that follows. Top
sherckuith 0:479ce5546098 71 * three bits are actual packet type. For backward compatibility
sherckuith 0:479ce5546098 72 * and in the interest of conserving bits, numbers are chosen so the
sherckuith 0:479ce5546098 73 * IP protocol version number (4) which normally appears in this nibble
sherckuith 0:479ce5546098 74 * means "IP packet".
sherckuith 0:479ce5546098 75 */
sherckuith 0:479ce5546098 76
sherckuith 0:479ce5546098 77 /* packet types */
sherckuith 0:479ce5546098 78 #define TYPE_IP 0x40
sherckuith 0:479ce5546098 79 #define TYPE_UNCOMPRESSED_TCP 0x70
sherckuith 0:479ce5546098 80 #define TYPE_COMPRESSED_TCP 0x80
sherckuith 0:479ce5546098 81 #define TYPE_ERROR 0x00
sherckuith 0:479ce5546098 82
sherckuith 0:479ce5546098 83 /* Bits in first octet of compressed packet */
sherckuith 0:479ce5546098 84 #define NEW_C 0x40 /* flag bits for what changed in a packet */
sherckuith 0:479ce5546098 85 #define NEW_I 0x20
sherckuith 0:479ce5546098 86 #define NEW_S 0x08
sherckuith 0:479ce5546098 87 #define NEW_A 0x04
sherckuith 0:479ce5546098 88 #define NEW_W 0x02
sherckuith 0:479ce5546098 89 #define NEW_U 0x01
sherckuith 0:479ce5546098 90
sherckuith 0:479ce5546098 91 /* reserved, special-case values of above */
sherckuith 0:479ce5546098 92 #define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
sherckuith 0:479ce5546098 93 #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
sherckuith 0:479ce5546098 94 #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
sherckuith 0:479ce5546098 95
sherckuith 0:479ce5546098 96 #define TCP_PUSH_BIT 0x10
sherckuith 0:479ce5546098 97
sherckuith 0:479ce5546098 98
sherckuith 0:479ce5546098 99 /*
sherckuith 0:479ce5546098 100 * "state" data for each active tcp conversation on the wire. This is
sherckuith 0:479ce5546098 101 * basically a copy of the entire IP/TCP header from the last packet
sherckuith 0:479ce5546098 102 * we saw from the conversation together with a small identifier
sherckuith 0:479ce5546098 103 * the transmit & receive ends of the line use to locate saved header.
sherckuith 0:479ce5546098 104 */
sherckuith 0:479ce5546098 105 struct cstate {
sherckuith 0:479ce5546098 106 struct cstate *cs_next; /* next most recently used state (xmit only) */
sherckuith 0:479ce5546098 107 u_short cs_hlen; /* size of hdr (receive only) */
sherckuith 0:479ce5546098 108 u_char cs_id; /* connection # associated with this state */
sherckuith 0:479ce5546098 109 u_char cs_filler;
sherckuith 0:479ce5546098 110 union {
sherckuith 0:479ce5546098 111 char csu_hdr[MAX_HDR];
sherckuith 0:479ce5546098 112 struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */
sherckuith 0:479ce5546098 113 } vjcs_u;
sherckuith 0:479ce5546098 114 };
sherckuith 0:479ce5546098 115 #define cs_ip vjcs_u.csu_ip
sherckuith 0:479ce5546098 116 #define cs_hdr vjcs_u.csu_hdr
sherckuith 0:479ce5546098 117
sherckuith 0:479ce5546098 118
sherckuith 0:479ce5546098 119 struct vjstat {
sherckuith 0:479ce5546098 120 unsigned long vjs_packets; /* outbound packets */
sherckuith 0:479ce5546098 121 unsigned long vjs_compressed; /* outbound compressed packets */
sherckuith 0:479ce5546098 122 unsigned long vjs_searches; /* searches for connection state */
sherckuith 0:479ce5546098 123 unsigned long vjs_misses; /* times couldn't find conn. state */
sherckuith 0:479ce5546098 124 unsigned long vjs_uncompressedin; /* inbound uncompressed packets */
sherckuith 0:479ce5546098 125 unsigned long vjs_compressedin; /* inbound compressed packets */
sherckuith 0:479ce5546098 126 unsigned long vjs_errorin; /* inbound unknown type packets */
sherckuith 0:479ce5546098 127 unsigned long vjs_tossed; /* inbound packets tossed because of error */
sherckuith 0:479ce5546098 128 };
sherckuith 0:479ce5546098 129
sherckuith 0:479ce5546098 130 /*
sherckuith 0:479ce5546098 131 * all the state data for one serial line (we need one of these per line).
sherckuith 0:479ce5546098 132 */
sherckuith 0:479ce5546098 133 struct vjcompress {
sherckuith 0:479ce5546098 134 struct cstate *last_cs; /* most recently used tstate */
sherckuith 0:479ce5546098 135 u_char last_recv; /* last rcvd conn. id */
sherckuith 0:479ce5546098 136 u_char last_xmit; /* last sent conn. id */
sherckuith 0:479ce5546098 137 u_short flags;
sherckuith 0:479ce5546098 138 u_char maxSlotIndex;
sherckuith 0:479ce5546098 139 u_char compressSlot; /* Flag indicating OK to compress slot ID. */
sherckuith 0:479ce5546098 140 #if LINK_STATS
sherckuith 0:479ce5546098 141 struct vjstat stats;
sherckuith 0:479ce5546098 142 #endif
sherckuith 0:479ce5546098 143 struct cstate tstate[MAX_SLOTS]; /* xmit connection states */
sherckuith 0:479ce5546098 144 struct cstate rstate[MAX_SLOTS]; /* receive connection states */
sherckuith 0:479ce5546098 145 };
sherckuith 0:479ce5546098 146
sherckuith 0:479ce5546098 147 /* flag values */
sherckuith 0:479ce5546098 148 #define VJF_TOSS 1U /* tossing rcvd frames because of input err */
sherckuith 0:479ce5546098 149
sherckuith 0:479ce5546098 150 extern void vj_compress_init (struct vjcompress *comp);
sherckuith 0:479ce5546098 151 extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb);
sherckuith 0:479ce5546098 152 extern void vj_uncompress_err (struct vjcompress *comp);
sherckuith 0:479ce5546098 153 extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp);
sherckuith 0:479ce5546098 154 extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp);
sherckuith 0:479ce5546098 155
sherckuith 0:479ce5546098 156 #endif /* VJ_H */