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 * fsm.h - Network Control Protocol Finite State Machine header file.
mbed_official 0:51ac1d130fd4 3 *
mbed_official 0:51ac1d130fd4 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
mbed_official 0:51ac1d130fd4 5 * Copyright (c) 1997 Global Election Systems Inc.
mbed_official 0:51ac1d130fd4 6 *
mbed_official 0:51ac1d130fd4 7 * The authors hereby grant permission to use, copy, modify, distribute,
mbed_official 0:51ac1d130fd4 8 * and license this software and its documentation for any purpose, provided
mbed_official 0:51ac1d130fd4 9 * that existing copyright notices are retained in all copies and that this
mbed_official 0:51ac1d130fd4 10 * notice and the following disclaimer are included verbatim in any
mbed_official 0:51ac1d130fd4 11 * distributions. No written agreement, license, or royalty fee is required
mbed_official 0:51ac1d130fd4 12 * for any of the authorized uses.
mbed_official 0:51ac1d130fd4 13 *
mbed_official 0:51ac1d130fd4 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
mbed_official 0:51ac1d130fd4 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
mbed_official 0:51ac1d130fd4 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
mbed_official 0:51ac1d130fd4 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
mbed_official 0:51ac1d130fd4 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
mbed_official 0:51ac1d130fd4 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
mbed_official 0:51ac1d130fd4 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
mbed_official 0:51ac1d130fd4 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 0:51ac1d130fd4 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
mbed_official 0:51ac1d130fd4 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 0:51ac1d130fd4 24 *
mbed_official 0:51ac1d130fd4 25 ******************************************************************************
mbed_official 0:51ac1d130fd4 26 * REVISION HISTORY
mbed_official 0:51ac1d130fd4 27 *
mbed_official 0:51ac1d130fd4 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
mbed_official 0:51ac1d130fd4 29 * Ported to lwIP.
mbed_official 0:51ac1d130fd4 30 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
mbed_official 0:51ac1d130fd4 31 * Original based on BSD code.
mbed_official 0:51ac1d130fd4 32 *****************************************************************************/
mbed_official 0:51ac1d130fd4 33 /*
mbed_official 0:51ac1d130fd4 34 * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
mbed_official 0:51ac1d130fd4 35 *
mbed_official 0:51ac1d130fd4 36 * Copyright (c) 1989 Carnegie Mellon University.
mbed_official 0:51ac1d130fd4 37 * All rights reserved.
mbed_official 0:51ac1d130fd4 38 *
mbed_official 0:51ac1d130fd4 39 * Redistribution and use in source and binary forms are permitted
mbed_official 0:51ac1d130fd4 40 * provided that the above copyright notice and this paragraph are
mbed_official 0:51ac1d130fd4 41 * duplicated in all such forms and that any documentation,
mbed_official 0:51ac1d130fd4 42 * advertising materials, and other materials related to such
mbed_official 0:51ac1d130fd4 43 * distribution and use acknowledge that the software was developed
mbed_official 0:51ac1d130fd4 44 * by Carnegie Mellon University. The name of the
mbed_official 0:51ac1d130fd4 45 * University may not be used to endorse or promote products derived
mbed_official 0:51ac1d130fd4 46 * from this software without specific prior written permission.
mbed_official 0:51ac1d130fd4 47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
mbed_official 0:51ac1d130fd4 48 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
mbed_official 0:51ac1d130fd4 49 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
mbed_official 0:51ac1d130fd4 50 *
mbed_official 0:51ac1d130fd4 51 * $Id: fsm.h,v 1.5 2009/12/31 17:08:08 goldsimon Exp $
mbed_official 0:51ac1d130fd4 52 */
mbed_official 0:51ac1d130fd4 53
mbed_official 0:51ac1d130fd4 54 #ifndef FSM_H
mbed_official 0:51ac1d130fd4 55 #define FSM_H
mbed_official 0:51ac1d130fd4 56
mbed_official 0:51ac1d130fd4 57 /*
mbed_official 0:51ac1d130fd4 58 * LCP Packet header = Code, id, length.
mbed_official 0:51ac1d130fd4 59 */
mbed_official 0:51ac1d130fd4 60 #define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
mbed_official 0:51ac1d130fd4 61
mbed_official 0:51ac1d130fd4 62
mbed_official 0:51ac1d130fd4 63 /*
mbed_official 0:51ac1d130fd4 64 * CP (LCP, IPCP, etc.) codes.
mbed_official 0:51ac1d130fd4 65 */
mbed_official 0:51ac1d130fd4 66 #define CONFREQ 1 /* Configuration Request */
mbed_official 0:51ac1d130fd4 67 #define CONFACK 2 /* Configuration Ack */
mbed_official 0:51ac1d130fd4 68 #define CONFNAK 3 /* Configuration Nak */
mbed_official 0:51ac1d130fd4 69 #define CONFREJ 4 /* Configuration Reject */
mbed_official 0:51ac1d130fd4 70 #define TERMREQ 5 /* Termination Request */
mbed_official 0:51ac1d130fd4 71 #define TERMACK 6 /* Termination Ack */
mbed_official 0:51ac1d130fd4 72 #define CODEREJ 7 /* Code Reject */
mbed_official 0:51ac1d130fd4 73
mbed_official 0:51ac1d130fd4 74
mbed_official 0:51ac1d130fd4 75 /*
mbed_official 0:51ac1d130fd4 76 * Each FSM is described by an fsm structure and fsm callbacks.
mbed_official 0:51ac1d130fd4 77 */
mbed_official 0:51ac1d130fd4 78 typedef struct fsm {
mbed_official 0:51ac1d130fd4 79 int unit; /* Interface unit number */
mbed_official 0:51ac1d130fd4 80 u_short protocol; /* Data Link Layer Protocol field value */
mbed_official 0:51ac1d130fd4 81 int state; /* State */
mbed_official 0:51ac1d130fd4 82 int flags; /* Contains option bits */
mbed_official 0:51ac1d130fd4 83 u_char id; /* Current id */
mbed_official 0:51ac1d130fd4 84 u_char reqid; /* Current request id */
mbed_official 0:51ac1d130fd4 85 u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
mbed_official 0:51ac1d130fd4 86 int timeouttime; /* Timeout time in milliseconds */
mbed_official 0:51ac1d130fd4 87 int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
mbed_official 0:51ac1d130fd4 88 int retransmits; /* Number of retransmissions left */
mbed_official 0:51ac1d130fd4 89 int maxtermtransmits; /* Maximum Terminate-Request transmissions */
mbed_official 0:51ac1d130fd4 90 int nakloops; /* Number of nak loops since last ack */
mbed_official 0:51ac1d130fd4 91 int maxnakloops; /* Maximum number of nak loops tolerated */
mbed_official 0:51ac1d130fd4 92 struct fsm_callbacks* callbacks; /* Callback routines */
mbed_official 0:51ac1d130fd4 93 char* term_reason; /* Reason for closing protocol */
mbed_official 0:51ac1d130fd4 94 int term_reason_len; /* Length of term_reason */
mbed_official 0:51ac1d130fd4 95 } fsm;
mbed_official 0:51ac1d130fd4 96
mbed_official 0:51ac1d130fd4 97
mbed_official 0:51ac1d130fd4 98 typedef struct fsm_callbacks {
mbed_official 0:51ac1d130fd4 99 void (*resetci)(fsm*); /* Reset our Configuration Information */
mbed_official 0:51ac1d130fd4 100 int (*cilen)(fsm*); /* Length of our Configuration Information */
mbed_official 0:51ac1d130fd4 101 void (*addci)(fsm*, u_char*, int*); /* Add our Configuration Information */
mbed_official 0:51ac1d130fd4 102 int (*ackci)(fsm*, u_char*, int); /* ACK our Configuration Information */
mbed_official 0:51ac1d130fd4 103 int (*nakci)(fsm*, u_char*, int); /* NAK our Configuration Information */
mbed_official 0:51ac1d130fd4 104 int (*rejci)(fsm*, u_char*, int); /* Reject our Configuration Information */
mbed_official 0:51ac1d130fd4 105 int (*reqci)(fsm*, u_char*, int*, int); /* Request peer's Configuration Information */
mbed_official 0:51ac1d130fd4 106 void (*up)(fsm*); /* Called when fsm reaches LS_OPENED state */
mbed_official 0:51ac1d130fd4 107 void (*down)(fsm*); /* Called when fsm leaves LS_OPENED state */
mbed_official 0:51ac1d130fd4 108 void (*starting)(fsm*); /* Called when we want the lower layer */
mbed_official 0:51ac1d130fd4 109 void (*finished)(fsm*); /* Called when we don't want the lower layer */
mbed_official 0:51ac1d130fd4 110 void (*protreject)(int); /* Called when Protocol-Reject received */
mbed_official 0:51ac1d130fd4 111 void (*retransmit)(fsm*); /* Retransmission is necessary */
mbed_official 0:51ac1d130fd4 112 int (*extcode)(fsm*, int, u_char, u_char*, int); /* Called when unknown code received */
mbed_official 0:51ac1d130fd4 113 char *proto_name; /* String name for protocol (for messages) */
mbed_official 0:51ac1d130fd4 114 } fsm_callbacks;
mbed_official 0:51ac1d130fd4 115
mbed_official 0:51ac1d130fd4 116
mbed_official 0:51ac1d130fd4 117 /*
mbed_official 0:51ac1d130fd4 118 * Link states.
mbed_official 0:51ac1d130fd4 119 */
mbed_official 0:51ac1d130fd4 120 #define LS_INITIAL 0 /* Down, hasn't been opened */
mbed_official 0:51ac1d130fd4 121 #define LS_STARTING 1 /* Down, been opened */
mbed_official 0:51ac1d130fd4 122 #define LS_CLOSED 2 /* Up, hasn't been opened */
mbed_official 0:51ac1d130fd4 123 #define LS_STOPPED 3 /* Open, waiting for down event */
mbed_official 0:51ac1d130fd4 124 #define LS_CLOSING 4 /* Terminating the connection, not open */
mbed_official 0:51ac1d130fd4 125 #define LS_STOPPING 5 /* Terminating, but open */
mbed_official 0:51ac1d130fd4 126 #define LS_REQSENT 6 /* We've sent a Config Request */
mbed_official 0:51ac1d130fd4 127 #define LS_ACKRCVD 7 /* We've received a Config Ack */
mbed_official 0:51ac1d130fd4 128 #define LS_ACKSENT 8 /* We've sent a Config Ack */
mbed_official 0:51ac1d130fd4 129 #define LS_OPENED 9 /* Connection available */
mbed_official 0:51ac1d130fd4 130
mbed_official 0:51ac1d130fd4 131 /*
mbed_official 0:51ac1d130fd4 132 * Flags - indicate options controlling FSM operation
mbed_official 0:51ac1d130fd4 133 */
mbed_official 0:51ac1d130fd4 134 #define OPT_PASSIVE 1 /* Don't die if we don't get a response */
mbed_official 0:51ac1d130fd4 135 #define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
mbed_official 0:51ac1d130fd4 136 #define OPT_SILENT 4 /* Wait for peer to speak first */
mbed_official 0:51ac1d130fd4 137
mbed_official 0:51ac1d130fd4 138
mbed_official 0:51ac1d130fd4 139 /*
mbed_official 0:51ac1d130fd4 140 * Prototypes
mbed_official 0:51ac1d130fd4 141 */
mbed_official 0:51ac1d130fd4 142 void fsm_init (fsm*);
mbed_official 0:51ac1d130fd4 143 void fsm_lowerup (fsm*);
mbed_official 0:51ac1d130fd4 144 void fsm_lowerdown (fsm*);
mbed_official 0:51ac1d130fd4 145 void fsm_open (fsm*);
mbed_official 0:51ac1d130fd4 146 void fsm_close (fsm*, char*);
mbed_official 0:51ac1d130fd4 147 void fsm_input (fsm*, u_char*, int);
mbed_official 0:51ac1d130fd4 148 void fsm_protreject (fsm*);
mbed_official 0:51ac1d130fd4 149 void fsm_sdata (fsm*, u_char, u_char, u_char*, int);
mbed_official 0:51ac1d130fd4 150
mbed_official 0:51ac1d130fd4 151
mbed_official 0:51ac1d130fd4 152 /*
mbed_official 0:51ac1d130fd4 153 * Variables
mbed_official 0:51ac1d130fd4 154 */
mbed_official 0:51ac1d130fd4 155 extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
mbed_official 0:51ac1d130fd4 156
mbed_official 0:51ac1d130fd4 157 #endif /* FSM_H */