Used in Live Traffic Update Nokia LCD Display Project

Fork of NetServices by Segundo Equipo

Committer:
rrajan8
Date:
Wed Mar 06 19:07:23 2013 +0000
Revision:
8:92b57208ab99
Parent:
0:ac1725ba162c
This project utilizes mbed's networking features to display live traffic updates on the Nokia LCD using the MapQuest API's Traffic Web Service.

Who changed what in which revision?

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