sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
fsm.h
Go to the documentation of this file.
1
/*
2
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
3
*
4
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
*
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
*
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in
15
* the documentation and/or other materials provided with the
16
* distribution.
17
*
18
* 3. The name "Carnegie Mellon University" must not be used to
19
* endorse or promote products derived from this software without
20
* prior written permission. For permission or any legal
21
* details, please contact
22
* Office of Technology Transfer
23
* Carnegie Mellon University
24
* 5000 Forbes Avenue
25
* Pittsburgh, PA 15213-3890
26
* (412) 268-4387, fax: (412) 268-7395
27
* tech-transfer@andrew.cmu.edu
28
*
29
* 4. Redistributions of any form whatsoever must retain the following
30
* acknowledgment:
31
* "This product includes software developed by Computing Services
32
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
33
*
34
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
35
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
37
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
38
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
39
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
40
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
41
*
42
* $Id: fsm.h,v 1.10 2004/11/13 02:28:15 paulus Exp $
43
*/
44
49
#include "
netif/ppp/ppp_opts.h
"
50
#if PPP_SUPPORT
/* don't build if not configured for use in lwipopts.h */
51
52
#ifndef FSM_H
53
#define FSM_H
54
55
#include "
ppp.h
"
56
57
#ifdef __cplusplus
58
extern
"C"
{
59
#endif
60
61
/*
62
* Packet header = Code, id, length.
63
*/
64
#define HEADERLEN 4
65
66
67
/*
68
* CP (LCP, IPCP, etc.) codes.
69
*/
70
#define CONFREQ 1
/* Configuration Request */
71
#define CONFACK 2
/* Configuration Ack */
72
#define CONFNAK 3
/* Configuration Nak */
73
#define CONFREJ 4
/* Configuration Reject */
74
#define TERMREQ 5
/* Termination Request */
75
#define TERMACK 6
/* Termination Ack */
76
#define CODEREJ 7
/* Code Reject */
77
78
79
/*
80
* Each FSM is described by an fsm structure and fsm callbacks.
81
*/
82
typedef
struct
fsm {
83
ppp_pcb *pcb;
/* PPP Interface */
84
const
struct
fsm_callbacks *callbacks;
/* Callback routines */
85
const
char
*term_reason;
/* Reason for closing protocol */
86
u8_t seen_ack;
/* Have received valid Ack/Nak/Rej to Req */
87
/* -- This is our only flag, we might use u_int :1 if we have more flags */
88
u16_t protocol;
/* Data Link Layer Protocol field value */
89
u8_t state;
/* State */
90
u8_t flags;
/* Contains option bits */
91
u8_t id;
/* Current id */
92
u8_t reqid;
/* Current request id */
93
u8_t retransmits;
/* Number of retransmissions left */
94
u8_t nakloops;
/* Number of nak loops since last ack */
95
u8_t rnakloops;
/* Number of naks received */
96
u8_t maxnakloops;
/* Maximum number of nak loops tolerated
97
(necessary because IPCP require a custom large max nak loops value) */
98
u8_t term_reason_len;
/* Length of term_reason */
99
} fsm;
100
101
102
typedef
struct
fsm_callbacks {
103
void (*resetci)
/* Reset our Configuration Information */
104
(fsm *);
105
int (*cilen)
/* Length of our Configuration Information */
106
(fsm *);
107
void (*addci)
/* Add our Configuration Information */
108
(fsm *, u_char *,
int
*);
109
int (*ackci)
/* ACK our Configuration Information */
110
(fsm *, u_char *, int);
111
int (*nakci)
/* NAK our Configuration Information */
112
(fsm *, u_char *, int, int);
113
int (*rejci)
/* Reject our Configuration Information */
114
(fsm *, u_char *, int);
115
int (*reqci)
/* Request peer's Configuration Information */
116
(fsm *, u_char *,
int
*, int);
117
void (*up)
/* Called when fsm reaches PPP_FSM_OPENED state */
118
(fsm *);
119
void (*down)
/* Called when fsm leaves PPP_FSM_OPENED state */
120
(fsm *);
121
void (*starting)
/* Called when we want the lower layer */
122
(fsm *);
123
void (*finished)
/* Called when we don't want the lower layer */
124
(fsm *);
125
void (*protreject)
/* Called when Protocol-Reject received */
126
(int);
127
void (*retransmit)
/* Retransmission is necessary */
128
(fsm *);
129
int (*extcode)
/* Called when unknown code received */
130
(fsm *, int, int, u_char *, int);
131
const
char
*proto_name;
/* String name for protocol (for messages) */
132
} fsm_callbacks;
133
134
135
/*
136
* Link states.
137
*/
138
#define PPP_FSM_INITIAL 0
/* Down, hasn't been opened */
139
#define PPP_FSM_STARTING 1
/* Down, been opened */
140
#define PPP_FSM_CLOSED 2
/* Up, hasn't been opened */
141
#define PPP_FSM_STOPPED 3
/* Open, waiting for down event */
142
#define PPP_FSM_CLOSING 4
/* Terminating the connection, not open */
143
#define PPP_FSM_STOPPING 5
/* Terminating, but open */
144
#define PPP_FSM_REQSENT 6
/* We've sent a Config Request */
145
#define PPP_FSM_ACKRCVD 7
/* We've received a Config Ack */
146
#define PPP_FSM_ACKSENT 8
/* We've sent a Config Ack */
147
#define PPP_FSM_OPENED 9
/* Connection available */
148
149
150
/*
151
* Flags - indicate options controlling FSM operation
152
*/
153
#define OPT_PASSIVE 1
/* Don't die if we don't get a response */
154
#define OPT_RESTART 2
/* Treat 2nd OPEN as DOWN, UP */
155
#define OPT_SILENT 4
/* Wait for peer to speak first */
156
157
158
/*
159
* Timeouts.
160
*/
161
#if 0
/* moved to ppp_opts.h */
162
#define DEFTIMEOUT 3
/* Timeout time in seconds */
163
#define DEFMAXTERMREQS 2
/* Maximum Terminate-Request transmissions */
164
#define DEFMAXCONFREQS 10
/* Maximum Configure-Request transmissions */
165
#define DEFMAXNAKLOOPS 5
/* Maximum number of nak loops */
166
#endif
/* moved to ppp_opts.h */
167
168
169
/*
170
* Prototypes
171
*/
172
void
fsm_init(fsm *f);
173
void
fsm_lowerup(fsm *f);
174
void
fsm_lowerdown(fsm *f);
175
void
fsm_open(fsm *f);
176
void
fsm_close(fsm *f,
const
char
*reason);
177
void
fsm_input(fsm *f, u_char *inpacket,
int
l);
178
void
fsm_protreject(fsm *f);
179
void
fsm_sdata(fsm *f, u_char code, u_char
id
,
const
u_char *data,
int
datalen);
180
181
#ifdef __cplusplus
182
}
183
#endif
184
185
#endif
/* FSM_H */
186
#endif
/* PPP_SUPPORT */
ppp.h
ppp_opts.h
core
ps2ip
include
lwip_include
netif
ppp
fsm.h
Generated by
1.18.0