Leest de waarde van een sensor binnen een maakt deze beschikbaar via internet

Dependencies:   NTPClient_NetServices mbed

Committer:
hendrikvincent
Date:
Mon Dec 02 09:01:23 2013 +0000
Revision:
0:05ccbd4f84f1
eerste programma;

Who changed what in which revision?

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