Experimental HTTPClient with proxy support

Committer:
igorsk
Date:
Wed Jun 29 16:01:58 2011 +0000
Revision:
0:b56b6a05cad4

        

Who changed what in which revision?

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