Netservices modded to read fragmented HTTP respsonse/payload from special purpose server - 180 bytes only

Committer:
RodColeman
Date:
Thu Sep 08 10:41:36 2011 +0000
Revision:
0:8f5825f330b0
setDataLen hacked to 180bytes

Who changed what in which revision?

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