Official mbed lwIP library (version 1.4.0)

Dependents:   LwIPNetworking NetServicesMin EthernetInterface EthernetInterface_RSF ... more

Legacy Networking Libraries

This is an mbed 2 networking library. For mbed OS 5, lwip has been integrated with built-in networking interfaces. The networking libraries have been revised to better support additional network stacks and thread safety here.

This library is based on the code of lwIP v1.4.0

Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
All rights reserved. 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
   derived from this software without specific prior written permission. 

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.
Committer:
mbed_official
Date:
Mon Mar 14 16:15:36 2016 +0000
Revision:
20:08f08bfc3f3d
Parent:
0:51ac1d130fd4
Synchronized with git revision fec574a5ed6db26aca1b13992ff271bf527d4a0d

Full URL: https://github.com/mbedmicro/mbed/commit/fec574a5ed6db26aca1b13992ff271bf527d4a0d/

Increased allocated netbufs to handle DTLS handshakes

Who changed what in which revision?

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