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

Committer:
RodColeman
Date:
Thu Sep 08 10:48:09 2011 +0000
Revision:
0:850eacf3e945
revised fixed length to 178 bytes

Who changed what in which revision?

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