CPU: Wrong CPU Load %.
[tomato.git] / release / src / router / ppp / pppd / fsm.h
blobb53eb73cfd1a5b086bc0743556da34155cda5e6d
1 /*
2 * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
4 * Copyright (c) 1989 Carnegie Mellon University.
5 * All rights reserved.
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.1.4 2003/10/14 08:09:53 sparq Exp $
23 * Packet header = Code, id, length.
25 #define HEADERLEN 4
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 */
39 extern const char code_log_details[16][32];
41 #define PNAME(f) (f->callbacks ? f->callbacks->proto_name : "?")
45 * Each FSM is described by an fsm structure and fsm callbacks.
47 typedef struct fsm {
48 int unit; /* Interface unit number */
49 int protocol; /* Data Link Layer Protocol field value */
50 int state; /* State */
51 int flags; /* Contains option bits */
52 u_char id; /* Current id */
53 u_char reqid; /* Current request id */
54 u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
55 int timeouttime; /* Timeout time in milliseconds */
56 int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
57 int retransmits; /* Number of retransmissions left */
58 int maxtermtransmits; /* Maximum Terminate-Request transmissions */
59 int nakloops; /* Number of nak loops since last ack */
60 int maxnakloops; /* Maximum number of nak loops tolerated */
61 struct fsm_callbacks *callbacks; /* Callback routines */
62 char *term_reason; /* Reason for closing protocol */
63 int term_reason_len; /* Length of term_reason */
64 } fsm;
67 typedef struct fsm_callbacks {
68 void (*resetci) /* Reset our Configuration Information */
69 __P((fsm *));
70 int (*cilen) /* Length of our Configuration Information */
71 __P((fsm *));
72 void (*addci) /* Add our Configuration Information */
73 __P((fsm *, u_char *, int *));
74 int (*ackci) /* ACK our Configuration Information */
75 __P((fsm *, u_char *, int));
76 int (*nakci) /* NAK our Configuration Information */
77 __P((fsm *, u_char *, int));
78 int (*rejci) /* Reject our Configuration Information */
79 __P((fsm *, u_char *, int));
80 int (*reqci) /* Request peer's Configuration Information */
81 __P((fsm *, u_char *, int *, int));
82 void (*up) /* Called when fsm reaches OPENED state */
83 __P((fsm *));
84 void (*down) /* Called when fsm leaves OPENED state */
85 __P((fsm *));
86 void (*starting) /* Called when we want the lower layer */
87 __P((fsm *));
88 void (*finished) /* Called when we don't want the lower layer */
89 __P((fsm *));
90 void (*protreject) /* Called when Protocol-Reject received */
91 __P((int));
92 void (*retransmit) /* Retransmission is necessary */
93 __P((fsm *));
94 int (*extcode) /* Called when unknown code received */
95 __P((fsm *, int, int, u_char *, int));
96 char *proto_name; /* String name for protocol (for messages) */
97 } fsm_callbacks;
101 * Link states.
103 #define INITIAL 0 /* Down, hasn't been opened */
104 #define STARTING 1 /* Down, been opened */
105 #define CLOSED 2 /* Up, hasn't been opened */
106 #define STOPPED 3 /* Open, waiting for down event */
107 #define CLOSING 4 /* Terminating the connection, not open */
108 #define STOPPING 5 /* Terminating, but open */
109 #define REQSENT 6 /* We've sent a Config Request */
110 #define ACKRCVD 7 /* We've received a Config Ack */
111 #define ACKSENT 8 /* We've sent a Config Ack */
112 #define OPENED 9 /* Connection available */
116 * Flags - indicate options controlling FSM operation
118 #define OPT_PASSIVE 1 /* Don't die if we don't get a response */
119 #define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
120 #define OPT_SILENT 4 /* Wait for peer to speak first */
124 * Timeouts.
126 #define DEFTIMEOUT 3 /* Timeout time in seconds */
127 #define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
128 #define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
129 #define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
133 * Prototypes
135 void fsm_init __P((fsm *));
136 void fsm_lowerup __P((fsm *));
137 void fsm_lowerdown __P((fsm *));
138 void fsm_open __P((fsm *));
139 void fsm_close __P((fsm *, char *));
140 void fsm_input __P((fsm *, u_char *, int));
141 void fsm_protreject __P((fsm *));
142 void fsm_sdata __P((fsm *, int, int, u_char *, int));
146 * Variables
148 extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */