Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.

Committer:
andrewbonney
Date:
Fri Apr 08 14:39:41 2011 +0000
Revision:
0:ec559500a63f

        

Who changed what in which revision?

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