Remove __P macros from src/usr.bin and src/usr.sbin.
[dragonfly.git] / usr.sbin / pppd / fsm.h
... / ...
CommitLineData
1/*
2 * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
3 *
4 * Copyright (c) 1989 Carnegie Mellon University.
5 * All rights reserved.
6 *
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.
18 *
19 * $FreeBSD: src/usr.sbin/pppd/fsm.h,v 1.7 1999/08/28 01:19:03 peter Exp $
20 * $DragonFly: src/usr.sbin/pppd/fsm.h,v 1.3 2003/11/03 19:31:40 eirikn Exp $
21 */
22
23/*
24 * Packet header = Code, id, length.
25 */
26#define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
27
28
29/*
30 * CP (LCP, IPCP, etc.) codes.
31 */
32#define CONFREQ 1 /* Configuration Request */
33#define CONFACK 2 /* Configuration Ack */
34#define CONFNAK 3 /* Configuration Nak */
35#define CONFREJ 4 /* Configuration Reject */
36#define TERMREQ 5 /* Termination Request */
37#define TERMACK 6 /* Termination Ack */
38#define CODEREJ 7 /* Code Reject */
39
40
41/*
42 * Each FSM is described by an fsm structure and fsm callbacks.
43 */
44typedef struct fsm {
45 int unit; /* Interface unit number */
46 int protocol; /* Data Link Layer Protocol field value */
47 int state; /* State */
48 int flags; /* Contains option bits */
49 u_char id; /* Current id */
50 u_char reqid; /* Current request id */
51 u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
52 int timeouttime; /* Timeout time in milliseconds */
53 int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
54 int retransmits; /* Number of retransmissions left */
55 int maxtermtransmits; /* Maximum Terminate-Request transmissions */
56 int nakloops; /* Number of nak loops since last ack */
57 int maxnakloops; /* Maximum number of nak loops tolerated */
58 struct fsm_callbacks *callbacks; /* Callback routines */
59 char *term_reason; /* Reason for closing protocol */
60 int term_reason_len; /* Length of term_reason */
61} fsm;
62
63
64typedef struct fsm_callbacks {
65 void (*resetci) /* Reset our Configuration Information */
66 (fsm *);
67 int (*cilen) /* Length of our Configuration Information */
68 (fsm *);
69 void (*addci) /* Add our Configuration Information */
70 (fsm *, u_char *, int *);
71 int (*ackci) /* ACK our Configuration Information */
72 (fsm *, u_char *, int);
73 int (*nakci) /* NAK our Configuration Information */
74 (fsm *, u_char *, int);
75 int (*rejci) /* Reject our Configuration Information */
76 (fsm *, u_char *, int);
77 int (*reqci) /* Request peer's Configuration Information */
78 (fsm *, u_char *, int *, int);
79 void (*up) /* Called when fsm reaches OPENED state */
80 (fsm *);
81 void (*down) /* Called when fsm leaves OPENED state */
82 (fsm *);
83 void (*starting) /* Called when we want the lower layer */
84 (fsm *);
85 void (*finished) /* Called when we don't want the lower layer */
86 (fsm *);
87 void (*protreject) /* Called when Protocol-Reject received */
88 (int);
89 void (*retransmit) /* Retransmission is necessary */
90 (fsm *);
91 int (*extcode) /* Called when unknown code received */
92 (fsm *, int, int, u_char *, int);
93 char *proto_name; /* String name for protocol (for messages) */
94} fsm_callbacks;
95
96
97/*
98 * Link states.
99 */
100#define INITIAL 0 /* Down, hasn't been opened */
101#define STARTING 1 /* Down, been opened */
102#define CLOSED 2 /* Up, hasn't been opened */
103#define STOPPED 3 /* Open, waiting for down event */
104#define CLOSING 4 /* Terminating the connection, not open */
105#define STOPPING 5 /* Terminating, but open */
106#define REQSENT 6 /* We've sent a Config Request */
107#define ACKRCVD 7 /* We've received a Config Ack */
108#define ACKSENT 8 /* We've sent a Config Ack */
109#define OPENED 9 /* Connection available */
110
111
112/*
113 * Flags - indicate options controlling FSM operation
114 */
115#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
116#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
117#define OPT_SILENT 4 /* Wait for peer to speak first */
118
119
120/*
121 * Timeouts.
122 */
123#define DEFTIMEOUT 3 /* Timeout time in seconds */
124#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
125#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
126#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
127
128
129/*
130 * Prototypes
131 */
132void fsm_init(fsm *);
133void fsm_lowerup(fsm *);
134void fsm_lowerdown(fsm *);
135void fsm_open(fsm *);
136void fsm_close(fsm *, char *);
137void fsm_input(fsm *, u_char *, int);
138void fsm_protreject(fsm *);
139void fsm_sdata(fsm *, int, int, u_char *, int);
140
141
142/*
143 * Variables
144 */
145extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */