ppp.h
Go to the documentation of this file.
1 /**
2  * @file ppp.h
3  * @brief PPP (Point-to-Point Protocol)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2023 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 2.3.0
29  **/
30 
31 #ifndef _PPP_H
32 #define _PPP_H
33 
34 //Forward declaration of structures
35 struct _PppPacket;
36 struct _PppContext;
37 #define PppPacket struct _PppPacket
38 #define PppContext struct _PppContext
39 
40 //Dependencies
41 #include "core/net.h"
42 #include "ppp/pap.h"
43 #include "ppp/chap.h"
44 
45 //PPP support
46 #ifndef PPP_SUPPORT
47  #define PPP_SUPPORT DISABLED
48 #elif (PPP_SUPPORT != ENABLED && PPP_SUPPORT != DISABLED)
49  #error PPP_SUPPORT parameter is not valid
50 #endif
51 
52 //TX buffer size
53 #ifndef PPP_TX_BUFFER_SIZE
54  #define PPP_TX_BUFFER_SIZE 4096
55 #elif (PPP_TX_BUFFER_SIZE < 3006)
56  #error PPP_TX_BUFFER_SIZE parameter is not valid
57 #endif
58 
59 //RX buffer size
60 #ifndef PPP_RX_BUFFER_SIZE
61  #define PPP_RX_BUFFER_SIZE 8192
62 #elif (PPP_RX_BUFFER_SIZE < 3006)
63  #error PPP_RX_BUFFER_SIZE parameter is not valid
64 #endif
65 
66 //Maximum user name length
67 #ifndef PPP_MAX_USERNAME_LEN
68  #define PPP_MAX_USERNAME_LEN 31
69 #elif (PPP_MAX_USERNAME_LEN < 7)
70  #error PPP_MAX_USERNAME_LEN parameter is not valid
71 #endif
72 
73 //Maximum password length
74 #ifndef PPP_MAX_PASSWORD_LEN
75  #define PPP_MAX_PASSWORD_LEN 31
76 #elif (PPP_MAX_PASSWORD_LEN < 7)
77  #error PPP_MAX_PASSWORD_LEN parameter is not valid
78 #endif
79 
80 //PPP tick interval
81 #ifndef PPP_TICK_INTERVAL
82  #define PPP_TICK_INTERVAL 500
83 #elif (PPP_TICK_INTERVAL < 10)
84  #error PPP_TICK_INTERVAL parameter is not valid
85 #endif
86 
87 //Polling interval for blocking functions
88 #ifndef PPP_POLLING_INTERVAL
89  #define PPP_POLLING_INTERVAL 50
90 #elif (PPP_POLLING_INTERVAL < 1)
91  #error PPP_POLLING_INTERVAL parameter is not valid
92 #endif
93 
94 //Restart timer
95 #ifndef PPP_RESTART_TIMER
96  #define PPP_RESTART_TIMER 3000
97 #elif (PPP_RESTART_TIMER < 1000)
98  #error PPP_RESTART_TIMER parameter is not valid
99 #endif
100 
101 //Maximum number of retransmissions for Configure-Requests
102 #ifndef PPP_MAX_CONFIGURE
103  #define PPP_MAX_CONFIGURE 10
104 #elif (PPP_MAX_CONFIGURE < 1)
105  #error PPP_MAX_CONFIGURE parameter is not valid
106 #endif
107 
108 //Maximum number of retransmissions for Terminate-Requests
109 #ifndef PPP_MAX_TERMINATE
110  #define PPP_MAX_TERMINATE 2
111 #elif (PPP_MAX_TERMINATE < 1)
112  #error PPP_MAX_TERMINATE parameter is not valid
113 #endif
114 
115 //Maximum number of Configure-Nak packets sent
116 #ifndef PPP_MAX_FAILURE
117  #define PPP_MAX_FAILURE 5
118 #elif (PPP_MAX_FAILURE < 1)
119  #error PPP_MAX_FAILURE parameter is not valid
120 #endif
121 
122 //PPP special characters
123 #define PPP_MASK_CHAR 0x20
124 #define PPP_ESC_CHAR 0x7D
125 #define PPP_FLAG_CHAR 0x7E
126 
127 //PPP default MRU
128 #define PPP_DEFAULT_MRU 1500
129 //PPP default async control character map
130 #define PPP_DEFAULT_ACCM 0xFFFFFFFF
131 //PPP default magic number
132 #define PPP_DEFAULT_MAGIC_NUMBER 0
133 
134 //Minimum acceptable value for MRU
135 #define PPP_MIN_MRU 32
136 //Maximum acceptable value for MRU
137 #define PPP_MAX_MRU 1500
138 
139 //Maximum size of Configure-Request packets
140 #define PPP_MAX_CONF_REQ_SIZE 128
141 
142 //Maximum size of PPP frame header
143 #define PPP_FRAME_HEADER_SIZE 4
144 //FCS field size
145 #define PPP_FCS_SIZE 2
146 //Maximum size of PPP frames
147 #define PPP_MAX_FRAME_SIZE (PPP_FRAME_HEADER_SIZE + PPP_MAX_MRU + PPP_FCS_SIZE)
148 
149 //PPP Address field
150 #define PPP_ADDR_FIELD 0xFF
151 ///PPP Control field
152 #define PPP_CTRL_FIELD 0x03
153 
154 //C++ guard
155 #ifdef __cplusplus
156 extern "C" {
157 #endif
158 
159 
160 /**
161  * @brief PPP phases
162  **/
163 
164 typedef enum
165 {
166  PPP_PHASE_DEAD = 0, ///<Link dead
167  PPP_PHASE_ESTABLISH = 1, ///<Link establishment phase
168  PPP_PHASE_AUTHENTICATE = 2, ///<Authentication phase
169  PPP_PHASE_NETWORK = 3, ///<Network-layer protocol phase
170  PPP_PHASE_TERMINATE = 4 ///<Link termination phase
172 
173 
174 /**
175  * @brief LCP/NCP states
176  **/
177 
178 typedef enum
179 {
191 
192 
193 /**
194  * @brief Protocol field values
195  **/
196 
197 typedef enum
198 {
199  PPP_PROTOCOL_IP = 0x0021, ///<Internet Protocol
200  PPP_PROTOCOL_IPV6 = 0x0057, ///<Internet Protocol version 6
201  PPP_PROTOCOL_IPCP = 0x8021, ///<IP Control Protocol
202  PPP_PROTOCOL_IPV6CP = 0x8057, ///<IPv6 Control Protocol
203  PPP_PROTOCOL_LCP = 0xC021, ///<Link Control Protocol
204  PPP_PROTOCOL_PAP = 0xC023, ///<Password Authentication Protocol
205  PPP_PROTOCOL_LQR = 0xC025, ///<Link Quality Report
206  PPP_PROTOCOL_CHAP = 0xC223 ///<Challenge Handshake Authentication Protocol
208 
209 
210 /**
211  * @brief Code field values
212  **/
213 
214 typedef enum
215 {
216  PPP_CODE_CONFIGURE_REQ = 1, ///<Configure-Request
217  PPP_CODE_CONFIGURE_ACK = 2, ///<Configure-Ack
218  PPP_CODE_CONFIGURE_NAK = 3, ///<Configure-Nak
219  PPP_CODE_CONFIGURE_REJ = 4, ///<Configure-Reject
220  PPP_CODE_TERMINATE_REQ = 5, ///<Terminate-Request
221  PPP_CODE_TERMINATE_ACK = 6, ///<Terminate-Ack
222  PPP_CODE_CODE_REJ = 7, ///<Code-Reject
223  PPP_CODE_PROTOCOL_REJ = 8, ///<Protocol-Reject
224  PPP_CODE_ECHO_REQ = 9, ///<Echo-Request
225  PPP_CODE_ECHO_REP = 10, ///<Echo-Reply
226  PPP_CODE_DISCARD_REQ = 11 ///<Discard-Request
228 
229 
230 /**
231  * @brief PPP authentication protocols
232  **/
233 
234 typedef enum
235 {
236  PPP_AUTH_PROTOCOL_PAP = 0x01, //PAP
237  PPP_AUTH_PROTOCOL_CHAP_MD5 = 0x02, //CHAP with MD5
238  PPP_AUTH_PROTOCOL_MS_CHAP = 0x04, //MS-CHAP
239  PPP_AUTH_PROTOCOL_MS_CHAP_2 = 0x08 //MS-CHAP-2
241 
242 
243 //CodeWarrior or Win32 compiler?
244 #if defined(__CWCC__) || defined(_WIN32)
245  #pragma pack(push, 1)
246 #endif
247 
248 
249 /**
250  * @brief LCP/NCP packet header
251  **/
252 
254 {
255  uint8_t code; //0
256  uint8_t identifier; //1
257  uint16_t length; //2-3
258  uint8_t data[]; //4
259 };
260 
261 
262 /**
263  * @brief Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets
264  **/
265 
267 {
268  uint8_t code; //0
269  uint8_t identifier; //1
270  uint16_t length; //2-3
271  uint8_t options[]; //4
273 
274 
275 /**
276  * @brief Terminate-Request and Terminate-Ack packet
277  **/
278 
279 typedef __packed_struct
280 {
281  uint8_t code; //0
282  uint8_t identifier; //1
283  uint16_t length; //2-3
284  uint8_t data[]; //4
286 
287 
288 /**
289  * @brief Code-Reject packet
290  **/
291 
292 typedef __packed_struct
293 {
294  uint8_t code; //0
295  uint8_t identifier; //1
296  uint16_t length; //2-3
297  uint8_t rejectedPacket[]; //4
299 
300 
301 /**
302  * @brief Protocol-Reject packet
303  **/
304 
305 typedef __packed_struct
306 {
307  uint8_t code; //0
308  uint8_t identifier; //1
309  uint16_t length; //2-3
310  uint16_t rejectedProtocol; //4-5
311  uint8_t rejectedInfo[]; //6
313 
314 
315 /**
316  * @brief Echo-Request and Echo-Reply packet
317  **/
318 
319 typedef __packed_struct
320 {
321  uint8_t code; //0
322  uint8_t identifier; //1
323  uint16_t length; //2-3
324  uint32_t magicNumber; //4-7
325  uint8_t data[]; //8
327 
328 
329 /**
330  * @brief PPP Discard-Request packet
331  **/
332 
333 typedef __packed_struct
334 {
335  uint8_t code; //0
336  uint8_t identifier; //1
337  uint16_t length; //2-3
338  uint32_t magicNumber; //4-7
339  uint8_t data[]; //8
341 
342 
343 /**
344  * @brief LCP/NCP option
345  **/
346 
347 typedef __packed_struct
348 {
349  uint8_t type; //0
350  uint8_t length; //1
351  uint8_t data[]; //2
353 
354 
355 //CodeWarrior or Win32 compiler?
356 #if defined(__CWCC__) || defined(_WIN32)
357  #pragma pack(pop)
358 #endif
359 
360 
361 /**
362  * @brief Random data generation callback function
363  **/
364 
365 typedef error_t (*PppRandCallback)(uint8_t *data, size_t length);
366 
367 
368 /**
369  * @brief PPP authentication callback function
370  **/
371 
373  const char_t *username);
374 
375 
376 /**
377  * @brief PPP settings
378  **/
379 
380 typedef struct
381 {
382  NetInterface *interface; ///<Underlying network interface
383  uint16_t mru; ///<Default MRU
384  uint32_t accm; ///<Default async control character map
385  uint_t authProtocol; ///<Allowed authentication protocols
386  PppRandCallback randCallback; ///<Random data generation callback function
387  PppAuthCallback authCallback; ///<PPP authentication callback function
388 } PppSettings;
389 
390 
391 /**
392  * @brief PPP finite state machine
393  **/
394 
395 typedef struct
396 {
397  uint_t state; ///<FSM state
398  uint8_t identifier; ///<Identifier used to match requests and replies
399  uint_t restartCounter; ///<Restart counter
400  uint_t failureCounter; ///<Failure counter
401  systime_t timestamp; ///<Timestamp to manage retransmissions
402 } PppFsm;
403 
404 
405 /**
406  * @brief PPP configuration options
407  **/
408 
409 typedef struct
410 {
411  uint16_t mru;
413  uint32_t accm;
415  uint16_t authProtocol;
416  uint8_t authAlgo;
418  uint32_t magicNumber;
424 #if (IPV4_SUPPORT == ENABLED)
431 #endif
432 #if (IPV6_SUPPORT == ENABLED)
435 #endif
436 } PppConfig;
437 
438 
439 /**
440  * @brief PPP context
441  **/
442 
444 {
445  PppSettings settings; ///PPP settings
446  NetInterface *interface; ///<Underlying network interface
447  systime_t timeout; ///<Timeout for blocking operations
448 
451  char_t peerName[PPP_MAX_USERNAME_LEN + 1]; ///<Peer's name
452 
455 
456  PppPhase pppPhase; ///<PPP phase
457  PppFsm lcpFsm; ///<LCP finite state machine
458 #if (IPV4_SUPPORT == ENABLED)
459  PppFsm ipcpFsm; ///<IPCP finite state machine
460 #endif
461 #if (IPV6_SUPPORT == ENABLED)
462  PppFsm ipv6cpFsm; ///<IPV6CP finite state machine
463 #endif
464 #if (PAP_SUPPORT == ENABLED)
465  PapFsm papFsm; ///<PAP finite state machine
466 #endif
467 #if (CHAP_SUPPORT == ENABLED)
468  ChapFsm chapFsm; ///<CHAP finite state machine
469 #endif
470  PppConfig localConfig; ///<Local configuration options
471  PppConfig peerConfig; ///<Peer configuration options
472  bool_t ipRejected; ///<IPv4 protocol is not supported by the peer
473  bool_t ipv6Rejected; ///<IPv6 protocol is not support by the peer
474 
475  uint8_t frame[PPP_MAX_FRAME_SIZE]; ///<Incoming PPP frame
476 
477  uint8_t txBuffer[PPP_TX_BUFFER_SIZE]; ///<Transmit buffer
481 
482  uint8_t rxBuffer[PPP_RX_BUFFER_SIZE]; ///<Receive buffer
487 };
488 
489 
490 //Tick counter to handle periodic operations
492 
493 //PPP related functions
494 void pppGetDefaultSettings(PppSettings *settings);
495 error_t pppInit(PppContext *context, const PppSettings *settings);
496 
497 error_t pppSetTimeout(NetInterface *interface, systime_t timeout);
498 
499 error_t pppSetAuthInfo(NetInterface *interface, const char_t *username,
500  const char_t *password);
501 
502 bool_t pppCheckPassword(NetInterface *interface, const char_t *password);
503 
504 error_t pppSendAtCommand(NetInterface *interface, const char_t *data);
505 error_t pppReceiveAtCommand(NetInterface *interface, char_t *data, size_t size);
506 
507 error_t pppConnect(NetInterface *interface);
508 error_t pppClose(NetInterface *interface);
509 
510 void pppTick(NetInterface *interface);
511 
512 void pppProcessFrame(NetInterface *interface, uint8_t *frame, size_t length,
513  NetRxAncillary *ancillary);
514 
515 error_t pppSendFrame(NetInterface *interface, NetBuffer *buffer, size_t offset,
516  uint16_t protocol);
517 
518 size_t pppParseFrameHeader(const uint8_t *frame, size_t length, uint16_t *protocol);
519 
520 uint16_t pppCalcFcs(const uint8_t *data, size_t length);
521 uint16_t pppCalcFcsEx(const NetBuffer *buffer, size_t offset, size_t length);
522 
523 NetBuffer *pppAllocBuffer(size_t length, size_t *offset);
524 
525 //C++ guard
526 #ifdef __cplusplus
527 }
528 #endif
529 
530 #endif
error_t pppSetTimeout(NetInterface *interface, systime_t timeout)
Set timeout value for blocking operations.
Definition: ppp.c:199
uint8_t rxBuffer[PPP_RX_BUFFER_SIZE]
Receive buffer.
Definition: ppp.h:482
bool_t localAuthDone
Definition: ppp.h:453
@ PPP_CODE_CONFIGURE_REJ
Configure-Reject.
Definition: ppp.h:219
uint8_t code
Definition: coap_common.h:177
int bool_t
Definition: compiler_port.h:53
uint_t rxWriteIndex
Definition: ppp.h:484
@ PPP_CODE_CONFIGURE_ACK
Configure-Ack.
Definition: ppp.h:217
uint8_t protocol
Definition: ipv4.h:294
bool_t interfaceIdRejected
Definition: ppp.h:434
systime_t pppTickCounter
Definition: ppp.c:53
PPP context.
Definition: ppp.h:444
PppProtocol
Protocol field values.
Definition: ppp.h:198
Eui64
Definition: ethernet.h:208
NetBuffer * pppAllocBuffer(size_t length, size_t *offset)
Allocate a buffer to hold a PPP frame.
Definition: ppp.c:1305
@ PPP_CODE_PROTOCOL_REJ
Protocol-Reject.
Definition: ppp.h:223
@ PPP_AUTH_PROTOCOL_MS_CHAP_2
Definition: ppp.h:239
CHAP (Challenge Handshake Authentication Protocol)
uint32_t accm
Definition: ppp.h:413
void pppTick(NetInterface *interface)
PPP timer handler.
Definition: ppp.c:864
@ PPP_PROTOCOL_CHAP
Challenge Handshake Authentication Protocol.
Definition: ppp.h:206
#define PPP_RX_BUFFER_SIZE
Definition: ppp.h:61
bool_t mruRejected
Definition: ppp.h:412
uint_t authProtocol
Allowed authentication protocols.
Definition: ppp.h:385
bool_t accmRejected
Definition: ppp.h:414
bool_t secondaryDnsRejected
Definition: ppp.h:430
uint_t rxFrameCount
Definition: ppp.h:486
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
void pppProcessFrame(NetInterface *interface, uint8_t *frame, size_t length, NetRxAncillary *ancillary)
Process an incoming PPP frame.
Definition: ppp.c:909
NetInterface * interface
PPP settings.
Definition: ppp.h:446
bool_t ipRejected
IPv4 protocol is not supported by the peer.
Definition: ppp.h:472
systime_t timestamp
Timestamp to manage retransmissions.
Definition: ppp.h:401
PAP finite state machine.
Definition: pap.h:153
char_t username[PPP_MAX_USERNAME_LEN+1]
User name.
Definition: ppp.h:449
PppAuthCallback authCallback
PPP authentication callback function.
Definition: ppp.h:387
uint16_t mru
Default MRU.
Definition: ppp.h:383
PppState
LCP/NCP states.
Definition: ppp.h:179
@ PPP_AUTH_PROTOCOL_MS_CHAP
Definition: ppp.h:238
uint16_t rejectedProtocol
Definition: ppp.h:310
PppConfigurePacket
Definition: ppp.h:272
bool_t pfc
Definition: ppp.h:420
uint8_t options[]
Definition: ppp.h:271
PPP finite state machine.
Definition: ppp.h:396
@ PPP_PHASE_NETWORK
Network-layer protocol phase.
Definition: ppp.h:169
@ PPP_STATE_5_STOPPING
Definition: ppp.h:185
uint_t txReadIndex
Definition: ppp.h:480
PppDiscardReqPacket
Definition: ppp.h:340
uint16_t authProtocol
Definition: ppp.h:415
Eui64 interfaceId
Definition: ppp.h:433
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:267
uint_t state
FSM state.
Definition: ppp.h:397
uint32_t magicNumber
Definition: ppp.h:418
#define PppContext
Definition: ppp.h:38
#define PPP_TX_BUFFER_SIZE
Definition: ppp.h:54
PppCodeRejPacket
Definition: ppp.h:298
uint32_t accm
Default async control character map.
Definition: ppp.h:384
uint_t rxReadIndex
Definition: ppp.h:485
@ PPP_CODE_CODE_REJ
Code-Reject.
Definition: ppp.h:222
@ PPP_CODE_CONFIGURE_REQ
Configure-Request.
Definition: ppp.h:216
error_t pppSendAtCommand(NetInterface *interface, const char_t *data)
Send AT command.
Definition: ppp.c:330
Ipv4Addr secondaryDns
Definition: ppp.h:429
bool_t pppCheckPassword(NetInterface *interface, const char_t *password)
Password verification.
Definition: ppp.c:283
uint8_t identifier
Definition: ppp.h:256
error_t pppClose(NetInterface *interface)
Close a PPP connection.
Definition: ppp.c:744
uint_t rxBufferLen
Definition: ppp.h:483
uint8_t frame[PPP_MAX_FRAME_SIZE]
Incoming PPP frame.
Definition: ppp.h:475
@ PPP_STATE_1_STARTING
Definition: ppp.h:181
bool_t ipv6Rejected
IPv6 protocol is not support by the peer.
Definition: ppp.h:473
@ PPP_STATE_9_OPENED
Definition: ppp.h:189
@ PPP_CODE_ECHO_REP
Echo-Reply.
Definition: ppp.h:225
void pppGetDefaultSettings(PppSettings *settings)
Initialize settings with default values.
Definition: ppp.c:98
error_t
Error codes.
Definition: error.h:43
char_t peerName[PPP_MAX_USERNAME_LEN+1]
Peer's name.
Definition: ppp.h:451
@ PPP_AUTH_PROTOCOL_PAP
Definition: ppp.h:236
error_t(* PppRandCallback)(uint8_t *data, size_t length)
Random data generation callback function.
Definition: ppp.h:365
bool_t pfcRejected
Definition: ppp.h:421
PapFsm papFsm
PAP finite state machine.
Definition: ppp.h:465
@ PPP_STATE_3_STOPPED
Definition: ppp.h:183
@ PPP_PHASE_AUTHENTICATE
Authentication phase.
Definition: ppp.h:168
#define NetRxAncillary
Definition: net_misc.h:40
systime_t timeout
Timeout for blocking operations.
Definition: ppp.h:447
#define NetInterface
Definition: net.h:36
PppCode
Code field values.
Definition: ppp.h:215
PppConfig localConfig
Local configuration options.
Definition: ppp.h:470
PppSettings settings
Definition: ppp.h:445
PppPhase pppPhase
PPP phase.
Definition: ppp.h:456
bool_t authProtocolRejected
Definition: ppp.h:417
uint8_t authAlgo
Definition: ppp.h:416
uint8_t rejectedPacket[]
Definition: ppp.h:297
@ PPP_PHASE_DEAD
Link dead.
Definition: ppp.h:166
@ PPP_CODE_CONFIGURE_NAK
Configure-Nak.
Definition: ppp.h:218
PppFsm ipv6cpFsm
IPV6CP finite state machine.
Definition: ppp.h:462
Ipv4Addr primaryDns
Definition: ppp.h:427
@ PPP_PROTOCOL_IPV6
Internet Protocol version 6.
Definition: ppp.h:200
uint16_t pppCalcFcs(const uint8_t *data, size_t length)
FCS calculation.
Definition: ppp.c:1220
uint32_t magicNumber
Definition: ppp.h:324
@ PPP_PROTOCOL_IPV6CP
IPv6 Control Protocol.
Definition: ppp.h:202
__packed_struct _PppPacket
LCP/NCP packet header.
Definition: ppp.h:254
bool_t primaryDnsRejected
Definition: ppp.h:428
bool_t acfc
Definition: ppp.h:422
bool_t ipAddrRejected
Definition: ppp.h:426
@ PPP_STATE_8_ACK_SENT
Definition: ppp.h:188
bool_t(* PppAuthCallback)(NetInterface *interface, const char_t *username)
PPP authentication callback function.
Definition: ppp.h:372
@ PPP_CODE_TERMINATE_ACK
Terminate-Ack.
Definition: ppp.h:221
bool_t magicNumberRejected
Definition: ppp.h:419
uint8_t type
Definition: coap_common.h:174
uint8_t txBuffer[PPP_TX_BUFFER_SIZE]
Transmit buffer.
Definition: ppp.h:477
uint8_t data[]
Definition: ppp.h:258
@ PPP_CODE_DISCARD_REQ
Discard-Request.
Definition: ppp.h:226
uint32_t systime_t
System time.
bool_t acfcRejected
Definition: ppp.h:423
error_t pppSendFrame(NetInterface *interface, NetBuffer *buffer, size_t offset, uint16_t protocol)
Send a PPP frame.
Definition: ppp.c:1035
ChapFsm chapFsm
CHAP finite state machine.
Definition: ppp.h:468
PppAuthProtocol
PPP authentication protocols.
Definition: ppp.h:235
char char_t
Definition: compiler_port.h:48
uint_t txBufferLen
Definition: ppp.h:478
@ PPP_PROTOCOL_LCP
Link Control Protocol.
Definition: ppp.h:203
@ PPP_STATE_6_REQ_SENT
Definition: ppp.h:186
PppEchoPacket
Definition: ppp.h:326
uint16_t mru
Definition: ppp.h:411
@ PPP_CODE_ECHO_REQ
Echo-Request.
Definition: ppp.h:224
@ PPP_PROTOCOL_IPCP
IP Control Protocol.
Definition: ppp.h:201
@ PPP_AUTH_PROTOCOL_CHAP_MD5
Definition: ppp.h:237
Ipv4Addr ipAddr
Definition: ppp.h:425
@ PPP_STATE_7_ACK_RCVD
Definition: ppp.h:187
PppPhase
PPP phases.
Definition: ppp.h:165
size_t pppParseFrameHeader(const uint8_t *frame, size_t length, uint16_t *protocol)
Parse PPP frame header.
Definition: ppp.c:1148
PppFsm lcpFsm
LCP finite state machine.
Definition: ppp.h:457
PPP settings.
Definition: ppp.h:381
PppTerminatePacket
Definition: ppp.h:285
PPP configuration options.
Definition: ppp.h:410
@ PPP_STATE_0_INITIAL
Definition: ppp.h:180
PppConfig peerConfig
Peer configuration options.
Definition: ppp.h:471
error_t pppSetAuthInfo(NetInterface *interface, const char_t *username, const char_t *password)
Set PPP authentication information.
Definition: ppp.c:236
uint8_t identifier
Identifier used to match requests and replies.
Definition: ppp.h:398
uint16_t length
Definition: ppp.h:257
#define PPP_MAX_FRAME_SIZE
Definition: ppp.h:147
uint_t failureCounter
Failure counter.
Definition: ppp.h:400
NetInterface * interface
Underlying network interface.
Definition: ppp.h:382
#define PPP_MAX_PASSWORD_LEN
Definition: ppp.h:75
error_t pppInit(PppContext *context, const PppSettings *settings)
PPP initialization.
Definition: ppp.c:124
uint_t txWriteIndex
Definition: ppp.h:479
uint16_t pppCalcFcsEx(const NetBuffer *buffer, size_t offset, size_t length)
Calculate FCS over a multi-part buffer.
Definition: ppp.c:1248
PppOption
Definition: ppp.h:352
@ PPP_STATE_4_CLOSING
Definition: ppp.h:184
error_t pppConnect(NetInterface *interface)
Establish a PPP connection.
Definition: ppp.c:475
@ PPP_PHASE_TERMINATE
Link termination phase.
Definition: ppp.h:170
@ PPP_PROTOCOL_IP
Internet Protocol.
Definition: ppp.h:199
char_t password[PPP_MAX_PASSWORD_LEN+1]
Password.
Definition: ppp.h:450
bool_t peerAuthDone
Definition: ppp.h:454
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
PppRandCallback randCallback
Random data generation callback function.
Definition: ppp.h:386
uint_t restartCounter
Restart counter.
Definition: ppp.h:399
@ PPP_PROTOCOL_LQR
Link Quality Report.
Definition: ppp.h:205
PAP (Password Authentication Protocol)
@ PPP_STATE_2_CLOSED
Definition: ppp.h:182
@ PPP_CODE_TERMINATE_REQ
Terminate-Request.
Definition: ppp.h:220
PppFsm ipcpFsm
IPCP finite state machine.
Definition: ppp.h:459
typedef __packed_struct
Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets.
Definition: ppp.h:267
error_t pppReceiveAtCommand(NetInterface *interface, char_t *data, size_t size)
Wait for an incoming AT command.
Definition: ppp.c:394
PppProtocolRejPacket
Definition: ppp.h:312
CHAP finite state machine.
Definition: chap.h:180
@ PPP_PROTOCOL_PAP
Password Authentication Protocol.
Definition: ppp.h:204
uint8_t rejectedInfo[]
Definition: ppp.h:311
@ PPP_PHASE_ESTABLISH
Link establishment phase.
Definition: ppp.h:167
#define PPP_MAX_USERNAME_LEN
Definition: ppp.h:68