2 * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
4 * Copyright (c) 1989 Carnegie Mellon University.
7 * Redistribution and use in source and binary forms are permitted
8 * provided that the above copyright notice and this paragraph are
9 * duplicated in all such forms and that any documentation,
10 * advertising materials, and other materials related to such
11 * distribution and use acknowledge that the software was developed
12 * by Carnegie Mellon University. The name of the
13 * University may not be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 * $Id: fsm.h,v 1.1 1993/11/11 03:54:25 paulus Exp $
23 * Packet header = Code, id, length.
25 #define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
29 * CP (LCP, IPCP, etc.) codes.
31 #define CONFREQ 1 /* Configuration Request */
32 #define CONFACK 2 /* Configuration Ack */
33 #define CONFNAK 3 /* Configuration Nak */
34 #define CONFREJ 4 /* Configuration Reject */
35 #define TERMREQ 5 /* Termination Request */
36 #define TERMACK 6 /* Termination Ack */
37 #define CODEREJ 7 /* Code Reject */
38 #define PROTREJ 8 /* Protocol Reject */
39 #define ECHOREQ 9 /* Echo Request */
40 #define ECHOREP 10 /* Echo Reply */
41 #define DISCREQ 11 /* Discard Request */
42 #define KEEPALIVE 12 /* Keepalive */
46 * Each FSM is described by a fsm_callbacks and a fsm structure.
48 typedef struct fsm_callbacks {
49 void (*resetci)(); /* Reset our Configuration Information */
50 int (*cilen)(); /* Length of our Configuration Information */
51 void (*addci)(); /* Add our Configuration Information */
52 int (*ackci)(); /* ACK our Configuration Information */
53 int (*nakci)(); /* NAK our Configuration Information */
54 int (*rejci)(); /* Reject our Configuration Information */
55 int (*reqci)(); /* Request peer's Configuration Information */
56 void (*up)(); /* Called when fsm reaches OPENED state */
57 void (*down)(); /* Called when fsm leaves OPENED state */
58 void (*starting)(); /* Called when we want the lower layer */
59 void (*finished)(); /* Called when we don't want the lower layer */
60 void (*protreject)(); /* Called when Protocol-Reject received */
61 void (*retransmit)(); /* Retransmission is necessary */
62 int (*extcode)(); /* Called when unknown code received */
63 char *proto_name; /* String name for protocol (for messages) */
68 int unit; /* Interface unit number */
69 int protocol; /* Data Link Layer Protocol field value */
70 int state; /* State */
71 int flags; /* Contains option bits */
72 u_char id; /* Current id */
73 u_char reqid; /* Current request id */
74 int timeouttime; /* Timeout time in milliseconds */
75 int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
76 int retransmits; /* Number of retransmissions left */
77 int maxtermtransmits; /* Maximum Terminate-Request transmissions */
78 int nakloops; /* Number of nak loops since last ack */
79 int maxnakloops; /* Maximum number of nak loops tolerated */
80 fsm_callbacks *callbacks; /* Callback routines */
87 #define INITIAL 0 /* Down, hasn't been opened */
88 #define STARTING 1 /* Down, been opened */
89 #define CLOSED 2 /* Up, hasn't been opened */
90 #define STOPPED 3 /* Open, waiting for down event */
91 #define CLOSING 4 /* Terminating the connection, not open */
92 #define STOPPING 5 /* Terminating, but open */
93 #define REQSENT 6 /* We've sent a Config Request */
94 #define ACKRCVD 7 /* We've received a Config Ack */
95 #define ACKSENT 8 /* We've sent a Config Ack */
96 #define OPENED 9 /* Connection available */
100 * Flags - indicate options controlling FSM operation
102 #define OPT_PASSIVE 1 /* Don't die if we don't get a response */
103 #define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
104 #define OPT_SILENT 4 /* Wait for peer to speak first */
110 #define DEFTIMEOUT 3 /* Timeout time in seconds */
111 #define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
112 #define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
113 #define DEFMAXNAKLOOPS 10 /* Maximum number of nak loops */
119 void fsm_init __ARGS((fsm *));
120 void fsm_lowerup __ARGS((fsm *));
121 void fsm_lowerdown __ARGS((fsm *));
122 void fsm_open __ARGS((fsm *));
123 void fsm_close __ARGS((fsm *));
124 void fsm_input __ARGS((fsm *, u_char *, int));
125 void fsm_protreject __ARGS((fsm *));
126 void fsm_sdata __ARGS((fsm *, int, int, u_char *, int));
132 extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */