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