ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

fsm.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 * fsm.h - Network Control Protocol Finite State Machine header file.
00003 *
00004 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
00005 * Copyright (c) 1997 Global Election Systems Inc.
00006 *
00007 * The authors hereby grant permission to use, copy, modify, distribute,
00008 * and license this software and its documentation for any purpose, provided
00009 * that existing copyright notices are retained in all copies and that this
00010 * notice and the following disclaimer are included verbatim in any 
00011 * distributions. No written agreement, license, or royalty fee is required
00012 * for any of the authorized uses.
00013 *
00014 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
00015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
00017 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00024 *
00025 ******************************************************************************
00026 * REVISION HISTORY
00027 *
00028 * 03-01-01 Marc Boucher <marc@mbsi.ca>
00029 *   Ported to lwIP.
00030 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
00031 *   Original based on BSD code.
00032 *****************************************************************************/
00033 /*
00034  * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
00035  *
00036  * Copyright (c) 1989 Carnegie Mellon University.
00037  * All rights reserved.
00038  *
00039  * Redistribution and use in source and binary forms are permitted
00040  * provided that the above copyright notice and this paragraph are
00041  * duplicated in all such forms and that any documentation,
00042  * advertising materials, and other materials related to such
00043  * distribution and use acknowledge that the software was developed
00044  * by Carnegie Mellon University.  The name of the
00045  * University may not be used to endorse or promote products derived
00046  * from this software without specific prior written permission.
00047  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
00048  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
00049  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00050  *
00051  * $Id: fsm.h,v 1.5 2009/12/31 17:08:08 goldsimon Exp $
00052  */
00053 
00054 #ifndef FSM_H
00055 #define FSM_H
00056 
00057 /*
00058  * LCP Packet header = Code, id, length.
00059  */
00060 #define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
00061 
00062 
00063 /*
00064  *  CP (LCP, IPCP, etc.) codes.
00065  */
00066 #define CONFREQ     1 /* Configuration Request */
00067 #define CONFACK     2 /* Configuration Ack */
00068 #define CONFNAK     3 /* Configuration Nak */
00069 #define CONFREJ     4 /* Configuration Reject */
00070 #define TERMREQ     5 /* Termination Request */
00071 #define TERMACK     6 /* Termination Ack */
00072 #define CODEREJ     7 /* Code Reject */
00073 
00074 
00075 /*
00076  * Each FSM is described by an fsm structure and fsm callbacks.
00077  */
00078 typedef struct fsm {
00079   int unit;                        /* Interface unit number */
00080   u_short protocol;                /* Data Link Layer Protocol field value */
00081   int state;                       /* State */
00082   int flags;                       /* Contains option bits */
00083   u_char id;                       /* Current id */
00084   u_char reqid;                    /* Current request id */
00085   u_char seen_ack;                 /* Have received valid Ack/Nak/Rej to Req */
00086   int timeouttime;                 /* Timeout time in milliseconds */
00087   int maxconfreqtransmits;         /* Maximum Configure-Request transmissions */
00088   int retransmits;                 /* Number of retransmissions left */
00089   int maxtermtransmits;            /* Maximum Terminate-Request transmissions */
00090   int nakloops;                    /* Number of nak loops since last ack */
00091   int maxnakloops;                 /* Maximum number of nak loops tolerated */
00092   struct fsm_callbacks* callbacks; /* Callback routines */
00093   char* term_reason;               /* Reason for closing protocol */
00094   int term_reason_len;             /* Length of term_reason */
00095 } fsm;
00096 
00097 
00098 typedef struct fsm_callbacks {
00099   void (*resetci)(fsm*);                            /* Reset our Configuration Information */
00100   int  (*cilen)(fsm*);                              /* Length of our Configuration Information */
00101   void (*addci)(fsm*, u_char*, int*);               /* Add our Configuration Information */
00102   int  (*ackci)(fsm*, u_char*, int);                /* ACK our Configuration Information */
00103   int  (*nakci)(fsm*, u_char*, int);                /* NAK our Configuration Information */
00104   int  (*rejci)(fsm*, u_char*, int);                /* Reject our Configuration Information */
00105   int  (*reqci)(fsm*, u_char*, int*, int);          /* Request peer's Configuration Information */
00106   void (*up)(fsm*);                                 /* Called when fsm reaches LS_OPENED state */
00107   void (*down)(fsm*);                               /* Called when fsm leaves LS_OPENED state */
00108   void (*starting)(fsm*);                           /* Called when we want the lower layer */
00109   void (*finished)(fsm*);                           /* Called when we don't want the lower layer */
00110   void (*protreject)(int);                          /* Called when Protocol-Reject received */
00111   void (*retransmit)(fsm*);                         /* Retransmission is necessary */
00112   int  (*extcode)(fsm*, int, u_char, u_char*, int); /* Called when unknown code received */
00113   char *proto_name;                                 /* String name for protocol (for messages) */
00114 } fsm_callbacks;
00115 
00116 
00117 /*
00118  * Link states.
00119  */
00120 #define LS_INITIAL  0 /* Down, hasn't been opened */
00121 #define LS_STARTING 1 /* Down, been opened */
00122 #define LS_CLOSED   2 /* Up, hasn't been opened */
00123 #define LS_STOPPED  3 /* Open, waiting for down event */
00124 #define LS_CLOSING  4 /* Terminating the connection, not open */
00125 #define LS_STOPPING 5 /* Terminating, but open */
00126 #define LS_REQSENT  6 /* We've sent a Config Request */
00127 #define LS_ACKRCVD  7 /* We've received a Config Ack */
00128 #define LS_ACKSENT  8 /* We've sent a Config Ack */
00129 #define LS_OPENED   9 /* Connection available */
00130 
00131 /*
00132  * Flags - indicate options controlling FSM operation
00133  */
00134 #define OPT_PASSIVE 1 /* Don't die if we don't get a response */
00135 #define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
00136 #define OPT_SILENT  4 /* Wait for peer to speak first */
00137 
00138 
00139 /*
00140  * Prototypes
00141  */
00142 void fsm_init (fsm*);
00143 void fsm_lowerup (fsm*);
00144 void fsm_lowerdown (fsm*);
00145 void fsm_open (fsm*);
00146 void fsm_close (fsm*, char*);
00147 void fsm_input (fsm*, u_char*, int);
00148 void fsm_protreject (fsm*);
00149 void fsm_sdata (fsm*, u_char, u_char, u_char*, int);
00150 
00151 
00152 /*
00153  * Variables
00154  */
00155 extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
00156 
00157 #endif /* FSM_H */

Generated on Sun May 27 2012 04:36:05 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.