Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

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