This library is stripped down version of NetServices library. HTTP server and client function is NOT supported.

Dependents:   imu-daq-eth

Committer:
idinor
Date:
Wed Jul 20 11:45:39 2011 +0000
Revision:
0:dcf3c92487ca

        

Who changed what in which revision?

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