HTTPClient using static IP

Dependencies:   mbed

Committer:
mr_q
Date:
Mon May 30 11:53:37 2011 +0000
Revision:
0:d8f2f7d5f31b
v0.01 Draft

Who changed what in which revision?

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