KEIS

Dependents:   EthernetInterface

Fork of lwip by mbed official

Committer:
bogdanm
Date:
Tue Sep 10 15:14:39 2013 +0300
Revision:
13:931deec14b08
Parent:
0:51ac1d130fd4
Sync with git revision 171dda705c947bf910926a0b73d6a4797802554d

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 */