Trial code integration web page update with analogue data and ntp support

Dependencies:   NTPClient_NetServices mbed

Committer:
pmr1
Date:
Fri Aug 06 17:57:45 2010 +0000
Revision:
0:8cc2035bebfc

        

Who changed what in which revision?

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