I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

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