NetTribute library with debug turned on in FShandler Donatien Garner -> Segundo Equipo -> this version

Committer:
hexley
Date:
Fri Nov 19 01:54:45 2010 +0000
Revision:
0:281d6ff68967

        

Who changed what in which revision?

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