ppp_fsm.h
Go to the documentation of this file.
1 /**
2  * @file ppp_fsm.h
3  * @brief PPP finite state machine
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.6
29  **/
30 
31 #ifndef _PPP_FSM_H
32 #define _PPP_FSM_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "ppp/ppp.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 
44 /**
45  * @brief This-Layer-Up callback function
46  **/
47 
48 typedef void (*PppThisLayerUp)(PppContext *context);
49 
50 
51 /**
52  * @brief This-Layer-Down callback function
53  **/
54 
55 typedef void (*PppThisLayerDown)(PppContext *context);
56 
57 
58 /**
59  * @brief This-Layer-Started callback function
60  **/
61 
62 typedef void (*PppThisLayerStarted)(PppContext *context);
63 
64 
65 /**
66  * @brief This-Layer-Finished callback function
67  **/
68 
69 typedef void (*PppThisLayerFinished)(PppContext *context);
70 
71 
72 /**
73  * @brief Initialize-Restart-Count callback function
74  **/
75 
76 typedef void (*PppInitRestartCount)(PppContext *context, uint_t value);
77 
78 
79 /**
80  * @brief Zero-Restart-Count callback function
81  **/
82 
83 typedef void (*PppZeroRestartCount)(PppContext *context);
84 
85 
86 /**
87  * @brief Send-Configure-Request callback function
88  **/
89 
90 typedef error_t (*PppSendConfigureReq)(PppContext *context);
91 
92 
93 /**
94  * @brief Send-Configure-Ack callback function
95  **/
96 
98  const PppConfigurePacket *configureReqPacket);
99 
100 
101 /**
102  * @brief Send-Configure-Nak callback function
103  **/
104 
106  const PppConfigurePacket *configureReqPacket);
107 
108 
109 /**
110  * @brief Send-Configure-Reject callback function
111  **/
112 
114  const PppConfigurePacket *configureReqPacket);
115 
116 
117 /**
118  * @brief Send-Terminate-Request callback function
119  **/
120 
122 
123 
124 /**
125  * @brief Send-Terminate-Ack callback function
126  **/
127 
129  const PppTerminatePacket *terminateReqPacket);
130 
131 
132 /**
133  * @brief Send-Code-Reject callback function
134  **/
135 
136 typedef error_t (*PppSendCodeRej)(PppContext *context,
137  const PppPacket *packet);
138 
139 
140 /**
141  * @brief Send-Echo-Reply callback function
142  **/
143 
144 typedef error_t (*PppSendEchoRep)(PppContext *context,
145  const PppEchoPacket *echoReqPacket);
146 
147 
148 /**
149  *@brief PPP FSM actions
150  **/
151 
152 typedef struct
153 {
168 } PppCallbacks;
169 
170 
171 //PPP FSM events
172 void pppUpEvent(PppContext *context, PppFsm *fsm,
173  const PppCallbacks *callbacks);
174 
175 void pppDownEvent(PppContext *context, PppFsm *fsm,
176  const PppCallbacks *callbacks);
177 
178 void pppOpenEvent(PppContext *context, PppFsm *fsm,
179  const PppCallbacks *callbacks);
180 
181 void pppCloseEvent(PppContext *context, PppFsm *fsm,
182  const PppCallbacks *callbacks);
183 
184 void pppTimeoutEvent(PppContext *context, PppFsm *fsm,
185  const PppCallbacks *callbacks);
186 
187 void pppRcvConfigureReqEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks,
188  const PppConfigurePacket *configureReqPacket, PppCode code);
189 
190 void pppRcvConfigureAckEvent(PppContext *context, PppFsm *fsm,
191  const PppCallbacks *callbacks);
192 
193 void pppRcvConfigureNakEvent(PppContext *context, PppFsm *fsm,
194  const PppCallbacks *callbacks);
195 
196 void pppRcvTerminateReqEvent(PppContext *context, PppFsm *fsm,
197  const PppCallbacks *callbacks, const PppTerminatePacket *terminateReqPacket);
198 
199 void pppRcvTerminateAckEvent(PppContext *context, PppFsm *fsm,
200  const PppCallbacks *callbacks);
201 
202 void pppRcvUnknownCodeEvent(PppContext *context, PppFsm *fsm,
203  const PppCallbacks *callbacks, const PppPacket *packet);
204 
205 void pppRcvCodeRejEvent(PppContext *context, PppFsm *fsm,
206  const PppCallbacks *callbacks, bool_t acceptable);
207 
208 void pppRcvEchoReqEvent(PppContext *context, PppFsm *fsm,
209  const PppCallbacks *callbacks, const PppEchoPacket *echoReqPacket);
210 
211 void pppChangeState(PppFsm *fsm, PppState newState);
212 
213 //C++ guard
214 #ifdef __cplusplus
215 }
216 #endif
217 
218 #endif
void(* PppZeroRestartCount)(PppContext *context)
Zero-Restart-Count callback function.
Definition: ppp_fsm.h:83
uint8_t code
Definition: coap_common.h:181
int bool_t
Definition: compiler_port.h:49
#define PppPacket
Definition: ppp.h:37
__start_packed struct @286 PppTerminatePacket
Terminate-Request and Terminate-Ack packet.
error_t(* PppSendTerminateReq)(PppContext *context)
Send-Terminate-Request callback function.
Definition: ppp_fsm.h:121
PppSendConfigureAck sendConfigureAck
Definition: ppp_fsm.h:161
void pppRcvTerminateAckEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks)
Process Receive-Terminate-Ack event.
Definition: ppp_fsm.c:697
PppSendTerminateAck sendTerminateAck
Definition: ppp_fsm.h:165
PppState
LCP/NCP states.
Definition: ppp.h:178
PPP finite state machine.
Definition: ppp.h:395
__start_packed struct @289 PppEchoPacket
Echo-Request and Echo-Reply packet.
void pppRcvConfigureReqEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks, const PppConfigurePacket *configureReqPacket, PppCode code)
Process Receive-Configure-Request event.
Definition: ppp_fsm.c:335
#define PppContext
Definition: ppp.h:38
PPP FSM actions.
Definition: ppp_fsm.h:152
void pppDownEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks)
Process Down event.
Definition: ppp_fsm.c:84
error_t(* PppSendConfigureRej)(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Reject callback function.
Definition: ppp_fsm.h:113
PppThisLayerStarted thisLayerStarted
Definition: ppp_fsm.h:156
PppSendConfigureRej sendConfigureRej
Definition: ppp_fsm.h:163
PppSendCodeRej sendCodeRej
Definition: ppp_fsm.h:166
error_t
Error codes.
Definition: error.h:42
PppSendEchoRep sendEchoRep
Definition: ppp_fsm.h:167
PppThisLayerDown thisLayerDown
Definition: ppp_fsm.h:155
error_t(* PppSendTerminateAck)(PppContext *context, const PppTerminatePacket *terminateReqPacket)
Send-Terminate-Ack callback function.
Definition: ppp_fsm.h:128
void pppChangeState(PppFsm *fsm, PppState newState)
Update PPP FSM state.
Definition: ppp_fsm.c:924
void pppRcvConfigureNakEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks)
Process Receive-Configure-Nak event.
Definition: ppp_fsm.c:586
PppCode
Code field values.
Definition: ppp.h:214
void pppRcvUnknownCodeEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks, const PppPacket *packet)
Process Receive-Unknown-Code event.
Definition: ppp_fsm.c:757
void pppCloseEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks)
Process Close event.
Definition: ppp_fsm.c:189
error_t(* PppSendConfigureNak)(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Nak callback function.
Definition: ppp_fsm.h:105
PppThisLayerUp thisLayerUp
Definition: ppp_fsm.h:154
void pppOpenEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks)
Process Open event.
Definition: ppp_fsm.c:135
PppInitRestartCount initRestartCount
Definition: ppp_fsm.h:158
void pppRcvEchoReqEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks, const PppEchoPacket *echoReqPacket)
Process Receive-Echo-Request event.
Definition: ppp_fsm.c:889
void(* PppThisLayerDown)(PppContext *context)
This-Layer-Down callback function.
Definition: ppp_fsm.h:55
void pppTimeoutEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks)
Process Timeout event.
Definition: ppp_fsm.c:257
error_t(* PppSendConfigureAck)(PppContext *context, const PppConfigurePacket *configureReqPacket)
Send-Configure-Ack callback function.
Definition: ppp_fsm.h:97
__start_packed struct @285 PppConfigurePacket
Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets.
void(* PppThisLayerFinished)(PppContext *context)
This-Layer-Finished callback function.
Definition: ppp_fsm.h:69
error_t(* PppSendEchoRep)(PppContext *context, const PppEchoPacket *echoReqPacket)
Send-Echo-Reply callback function.
Definition: ppp_fsm.h:144
void pppRcvCodeRejEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks, bool_t acceptable)
Process Receive-Code-Reject or Receive-Protocol-Reject event.
Definition: ppp_fsm.c:792
PppSendConfigureNak sendConfigureNak
Definition: ppp_fsm.h:162
error_t(* PppSendCodeRej)(PppContext *context, const PppPacket *packet)
Send-Code-Reject callback function.
Definition: ppp_fsm.h:136
PPP (Point-to-Point Protocol)
void pppRcvConfigureAckEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks)
Process Receive-Configure-Ack event.
Definition: ppp_fsm.c:524
PppSendConfigureReq sendConfigureReq
Definition: ppp_fsm.h:160
PppZeroRestartCount zeroRestartCount
Definition: ppp_fsm.h:159
void pppUpEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks)
Process Up event.
Definition: ppp_fsm.c:50
uint8_t value[]
Definition: dtls_misc.h:150
unsigned int uint_t
Definition: compiler_port.h:45
PppThisLayerFinished thisLayerFinished
Definition: ppp_fsm.h:157
TCP/IP stack core.
void(* PppInitRestartCount)(PppContext *context, uint_t value)
Initialize-Restart-Count callback function.
Definition: ppp_fsm.h:76
error_t(* PppSendConfigureReq)(PppContext *context)
Send-Configure-Request callback function.
Definition: ppp_fsm.h:90
void(* PppThisLayerUp)(PppContext *context)
This-Layer-Up callback function.
Definition: ppp_fsm.h:48
void pppRcvTerminateReqEvent(PppContext *context, PppFsm *fsm, const PppCallbacks *callbacks, const PppTerminatePacket *terminateReqPacket)
Process Receive-Terminate-Req event.
Definition: ppp_fsm.c:648
PppSendTerminateReq sendTerminateReq
Definition: ppp_fsm.h:164
void(* PppThisLayerStarted)(PppContext *context)
This-Layer-Started callback function.
Definition: ppp_fsm.h:62