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-2024 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.4.4
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 //CC-RX, CodeWarrior or Win32 compiler?
244 #if defined(__CCRX__)
245  #pragma pack
246 #elif defined(__CWCC__) || defined(_WIN32)
247  #pragma pack(push, 1)
248 #endif
249 
250 
251 /**
252  * @brief LCP/NCP packet header
253  **/
254 
256 {
257  uint8_t code; //0
258  uint8_t identifier; //1
259  uint16_t length; //2-3
260  uint8_t data[]; //4
261 };
262 
263 
264 /**
265  * @brief Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets
266  **/
267 
269 {
270  uint8_t code; //0
271  uint8_t identifier; //1
272  uint16_t length; //2-3
273  uint8_t options[]; //4
275 
276 
277 /**
278  * @brief Terminate-Request and Terminate-Ack packet
279  **/
280 
281 typedef __packed_struct
282 {
283  uint8_t code; //0
284  uint8_t identifier; //1
285  uint16_t length; //2-3
286  uint8_t data[]; //4
288 
289 
290 /**
291  * @brief Code-Reject packet
292  **/
293 
294 typedef __packed_struct
295 {
296  uint8_t code; //0
297  uint8_t identifier; //1
298  uint16_t length; //2-3
299  uint8_t rejectedPacket[]; //4
301 
302 
303 /**
304  * @brief Protocol-Reject packet
305  **/
306 
307 typedef __packed_struct
308 {
309  uint8_t code; //0
310  uint8_t identifier; //1
311  uint16_t length; //2-3
312  uint16_t rejectedProtocol; //4-5
313  uint8_t rejectedInfo[]; //6
315 
316 
317 /**
318  * @brief Echo-Request and Echo-Reply packet
319  **/
320 
321 typedef __packed_struct
322 {
323  uint8_t code; //0
324  uint8_t identifier; //1
325  uint16_t length; //2-3
326  uint32_t magicNumber; //4-7
327  uint8_t data[]; //8
329 
330 
331 /**
332  * @brief PPP Discard-Request packet
333  **/
334 
335 typedef __packed_struct
336 {
337  uint8_t code; //0
338  uint8_t identifier; //1
339  uint16_t length; //2-3
340  uint32_t magicNumber; //4-7
341  uint8_t data[]; //8
343 
344 
345 /**
346  * @brief LCP/NCP option
347  **/
348 
349 typedef __packed_struct
350 {
351  uint8_t type; //0
352  uint8_t length; //1
353  uint8_t data[]; //2
355 
356 
357 //CC-RX, CodeWarrior or Win32 compiler?
358 #if defined(__CCRX__)
359  #pragma unpack
360 #elif defined(__CWCC__) || defined(_WIN32)
361  #pragma pack(pop)
362 #endif
363 
364 
365 /**
366  * @brief Random data generation callback function
367  **/
368 
369 typedef error_t (*PppRandCallback)(uint8_t *data, size_t length);
370 
371 
372 /**
373  * @brief PPP authentication callback function
374  **/
375 
377  const char_t *username);
378 
379 
380 /**
381  * @brief PPP settings
382  **/
383 
384 typedef struct
385 {
386  NetInterface *interface; ///<Underlying network interface
387  uint16_t mru; ///<Default MRU
388  uint32_t accm; ///<Default async control character map
389  uint_t authProtocol; ///<Allowed authentication protocols
390  PppRandCallback randCallback; ///<Random data generation callback function
391  PppAuthCallback authCallback; ///<PPP authentication callback function
392 } PppSettings;
393 
394 
395 /**
396  * @brief PPP finite state machine
397  **/
398 
399 typedef struct
400 {
401  uint_t state; ///<FSM state
402  uint8_t identifier; ///<Identifier used to match requests and replies
403  uint_t restartCounter; ///<Restart counter
404  uint_t failureCounter; ///<Failure counter
405  systime_t timestamp; ///<Timestamp to manage retransmissions
406 } PppFsm;
407 
408 
409 /**
410  * @brief PPP configuration options
411  **/
412 
413 typedef struct
414 {
415  uint16_t mru;
417  uint32_t accm;
419  uint16_t authProtocol;
420  uint8_t authAlgo;
422  uint32_t magicNumber;
428 #if (IPV4_SUPPORT == ENABLED)
435 #endif
436 #if (IPV6_SUPPORT == ENABLED)
439 #endif
440 } PppConfig;
441 
442 
443 /**
444  * @brief PPP context
445  **/
446 
448 {
449  PppSettings settings; ///PPP settings
450  NetInterface *interface; ///<Underlying network interface
451  systime_t timeout; ///<Timeout for blocking operations
452 
455  char_t peerName[PPP_MAX_USERNAME_LEN + 1]; ///<Peer's name
456 
459 
460  PppPhase pppPhase; ///<PPP phase
461  PppFsm lcpFsm; ///<LCP finite state machine
462 #if (IPV4_SUPPORT == ENABLED)
463  PppFsm ipcpFsm; ///<IPCP finite state machine
464 #endif
465 #if (IPV6_SUPPORT == ENABLED)
466  PppFsm ipv6cpFsm; ///<IPV6CP finite state machine
467 #endif
468 #if (PAP_SUPPORT == ENABLED)
469  PapFsm papFsm; ///<PAP finite state machine
470 #endif
471 #if (CHAP_SUPPORT == ENABLED)
472  ChapFsm chapFsm; ///<CHAP finite state machine
473 #endif
474  PppConfig localConfig; ///<Local configuration options
475  PppConfig peerConfig; ///<Peer configuration options
476  bool_t ipRejected; ///<IPv4 protocol is not supported by the peer
477  bool_t ipv6Rejected; ///<IPv6 protocol is not support by the peer
478 
479  uint8_t frame[PPP_MAX_FRAME_SIZE]; ///<Incoming PPP frame
480 
481  uint8_t txBuffer[PPP_TX_BUFFER_SIZE]; ///<Transmit buffer
485 
486  uint8_t rxBuffer[PPP_RX_BUFFER_SIZE]; ///<Receive buffer
491 };
492 
493 
494 //Tick counter to handle periodic operations
496 
497 //PPP related functions
498 void pppGetDefaultSettings(PppSettings *settings);
499 error_t pppInit(PppContext *context, const PppSettings *settings);
500 
501 error_t pppSetTimeout(NetInterface *interface, systime_t timeout);
502 
503 error_t pppSetAuthInfo(NetInterface *interface, const char_t *username,
504  const char_t *password);
505 
506 bool_t pppCheckPassword(NetInterface *interface, const char_t *password);
507 
508 error_t pppSendAtCommand(NetInterface *interface, const char_t *data);
509 error_t pppReceiveAtCommand(NetInterface *interface, char_t *data, size_t size);
510 
511 error_t pppConnect(NetInterface *interface);
512 error_t pppClose(NetInterface *interface);
513 
514 void pppTick(NetInterface *interface);
515 
516 void pppProcessFrame(NetInterface *interface, uint8_t *frame, size_t length,
517  NetRxAncillary *ancillary);
518 
519 error_t pppSendFrame(NetInterface *interface, NetBuffer *buffer, size_t offset,
520  uint16_t protocol);
521 
522 size_t pppParseFrameHeader(const uint8_t *frame, size_t length, uint16_t *protocol);
523 
524 uint16_t pppCalcFcs(const uint8_t *data, size_t length);
525 uint16_t pppCalcFcsEx(const NetBuffer *buffer, size_t offset, size_t length);
526 
527 NetBuffer *pppAllocBuffer(size_t length, size_t *offset);
528 
529 //C++ guard
530 #ifdef __cplusplus
531 }
532 #endif
533 
534 #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:486
bool_t localAuthDone
Definition: ppp.h:457
@ PPP_CODE_CONFIGURE_REJ
Configure-Reject.
Definition: ppp.h:219
uint8_t code
Definition: coap_common.h:179
int bool_t
Definition: compiler_port.h:53
uint_t rxWriteIndex
Definition: ppp.h:488
@ PPP_CODE_CONFIGURE_ACK
Configure-Ack.
Definition: ppp.h:217
uint8_t protocol
Definition: ipv4.h:326
bool_t interfaceIdRejected
Definition: ppp.h:438
systime_t pppTickCounter
Definition: ppp.c:53
PPP context.
Definition: ppp.h:448
PppProtocol
Protocol field values.
Definition: ppp.h:198
Eui64
Definition: ethernet.h:210
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:417
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:416
uint_t authProtocol
Allowed authentication protocols.
Definition: ppp.h:389
bool_t accmRejected
Definition: ppp.h:418
bool_t secondaryDnsRejected
Definition: ppp.h:434
uint_t rxFrameCount
Definition: ppp.h:490
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:450
bool_t ipRejected
IPv4 protocol is not supported by the peer.
Definition: ppp.h:476
systime_t timestamp
Timestamp to manage retransmissions.
Definition: ppp.h:405
PAP finite state machine.
Definition: pap.h:157
char_t username[PPP_MAX_USERNAME_LEN+1]
User name.
Definition: ppp.h:453
PppAuthCallback authCallback
PPP authentication callback function.
Definition: ppp.h:391
uint16_t mru
Default MRU.
Definition: ppp.h:387
PppState
LCP/NCP states.
Definition: ppp.h:179
@ PPP_AUTH_PROTOCOL_MS_CHAP
Definition: ppp.h:238
uint16_t rejectedProtocol
Definition: ppp.h:312
PppConfigurePacket
Definition: ppp.h:274
uint8_t type
Definition: coap_common.h:176
bool_t pfc
Definition: ppp.h:424
uint8_t options[]
Definition: ppp.h:273
PPP finite state machine.
Definition: ppp.h:400
@ 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:484
PppDiscardReqPacket
Definition: ppp.h:342
uint16_t authProtocol
Definition: ppp.h:419
Eui64 interfaceId
Definition: ppp.h:437
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:297
uint_t state
FSM state.
Definition: ppp.h:401
uint32_t magicNumber
Definition: ppp.h:422
#define PppContext
Definition: ppp.h:38
#define PPP_TX_BUFFER_SIZE
Definition: ppp.h:54
PppCodeRejPacket
Definition: ppp.h:300
uint32_t accm
Default async control character map.
Definition: ppp.h:388
uint_t rxReadIndex
Definition: ppp.h:489
@ 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:433
bool_t pppCheckPassword(NetInterface *interface, const char_t *password)
Password verification.
Definition: ppp.c:283
uint8_t identifier
Definition: ppp.h:258
error_t pppClose(NetInterface *interface)
Close a PPP connection.
Definition: ppp.c:744
uint_t rxBufferLen
Definition: ppp.h:487
uint8_t frame[PPP_MAX_FRAME_SIZE]
Incoming PPP frame.
Definition: ppp.h:479
@ PPP_STATE_1_STARTING
Definition: ppp.h:181
bool_t ipv6Rejected
IPv6 protocol is not support by the peer.
Definition: ppp.h:477
@ 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:455
@ 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:369
bool_t pfcRejected
Definition: ppp.h:425
PapFsm papFsm
PAP finite state machine.
Definition: ppp.h:469
@ 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:451
#define NetInterface
Definition: net.h:36
PppCode
Code field values.
Definition: ppp.h:215
PppConfig localConfig
Local configuration options.
Definition: ppp.h:474
PppSettings settings
Definition: ppp.h:449
PppPhase pppPhase
PPP phase.
Definition: ppp.h:460
bool_t authProtocolRejected
Definition: ppp.h:421
uint8_t authAlgo
Definition: ppp.h:420
uint8_t rejectedPacket[]
Definition: ppp.h:299
@ 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:466
Ipv4Addr primaryDns
Definition: ppp.h:431
@ 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:326
@ PPP_PROTOCOL_IPV6CP
IPv6 Control Protocol.
Definition: ppp.h:202
__packed_struct _PppPacket
LCP/NCP packet header.
Definition: ppp.h:256
bool_t primaryDnsRejected
Definition: ppp.h:432
bool_t acfc
Definition: ppp.h:426
bool_t ipAddrRejected
Definition: ppp.h:430
@ 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:376
@ PPP_CODE_TERMINATE_ACK
Terminate-Ack.
Definition: ppp.h:221
bool_t magicNumberRejected
Definition: ppp.h:423
uint8_t txBuffer[PPP_TX_BUFFER_SIZE]
Transmit buffer.
Definition: ppp.h:481
uint8_t data[]
Definition: ppp.h:260
@ PPP_CODE_DISCARD_REQ
Discard-Request.
Definition: ppp.h:226
uint32_t systime_t
System time.
bool_t acfcRejected
Definition: ppp.h:427
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:472
PppAuthProtocol
PPP authentication protocols.
Definition: ppp.h:235
char char_t
Definition: compiler_port.h:48
uint_t txBufferLen
Definition: ppp.h:482
@ PPP_PROTOCOL_LCP
Link Control Protocol.
Definition: ppp.h:203
@ PPP_STATE_6_REQ_SENT
Definition: ppp.h:186
PppEchoPacket
Definition: ppp.h:328
uint16_t mru
Definition: ppp.h:415
@ 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:429
@ 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:461
PPP settings.
Definition: ppp.h:385
PppTerminatePacket
Definition: ppp.h:287
PPP configuration options.
Definition: ppp.h:414
@ PPP_STATE_0_INITIAL
Definition: ppp.h:180
PppConfig peerConfig
Peer configuration options.
Definition: ppp.h:475
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:402
uint16_t length
Definition: ppp.h:259
#define PPP_MAX_FRAME_SIZE
Definition: ppp.h:147
uint_t failureCounter
Failure counter.
Definition: ppp.h:404
NetInterface * interface
Underlying network interface.
Definition: ppp.h:386
#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:483
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:354
@ 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:454
bool_t peerAuthDone
Definition: ppp.h:458
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
PppRandCallback randCallback
Random data generation callback function.
Definition: ppp.h:390
uint_t restartCounter
Restart counter.
Definition: ppp.h:403
@ 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:463
typedef __packed_struct
Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets.
Definition: ppp.h:269
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:314
CHAP finite state machine.
Definition: chap.h:184
@ PPP_PROTOCOL_PAP
Password Authentication Protocol.
Definition: ppp.h:204
uint8_t rejectedInfo[]
Definition: ppp.h:313
@ PPP_PHASE_ESTABLISH
Link establishment phase.
Definition: ppp.h:167
#define PPP_MAX_USERNAME_LEN
Definition: ppp.h:68