TwitterExample with newer library (2012Aug)

Dependencies:   EthernetNetIf HTTPClient mbed

Committer:
nxpfan
Date:
Wed Aug 29 03:50:19 2012 +0000
Revision:
0:075157567b0c
simple twitter example with newer library

Who changed what in which revision?

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