37#define PppPacket struct _PppPacket
38#define PppContext struct _PppContext
47 #define PPP_SUPPORT DISABLED
48#elif (PPP_SUPPORT != ENABLED && PPP_SUPPORT != DISABLED)
49 #error PPP_SUPPORT parameter is not valid
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
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
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
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
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
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
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
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
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
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
123#define PPP_MASK_CHAR 0x20
124#define PPP_ESC_CHAR 0x7D
125#define PPP_FLAG_CHAR 0x7E
128#define PPP_DEFAULT_MRU 1500
130#define PPP_DEFAULT_ACCM 0xFFFFFFFF
132#define PPP_DEFAULT_MAGIC_NUMBER 0
135#define PPP_MIN_MRU 32
137#define PPP_MAX_MRU 1500
140#define PPP_MAX_CONF_REQ_SIZE 128
143#define PPP_FRAME_HEADER_SIZE 4
145#define PPP_FCS_SIZE 2
147#define PPP_MAX_FRAME_SIZE (PPP_FRAME_HEADER_SIZE + PPP_MAX_MRU + PPP_FCS_SIZE)
150#define PPP_ADDR_FIELD 0xFF
152#define PPP_CTRL_FIELD 0x03
180 PPP_STATE_0_INITIAL = 0,
181 PPP_STATE_1_STARTING = 1,
182 PPP_STATE_2_CLOSED = 2,
183 PPP_STATE_3_STOPPED = 3,
184 PPP_STATE_4_CLOSING = 4,
185 PPP_STATE_5_STOPPING = 5,
186 PPP_STATE_6_REQ_SENT = 6,
187 PPP_STATE_7_ACK_RCVD = 7,
188 PPP_STATE_8_ACK_SENT = 8,
189 PPP_STATE_9_OPENED = 9
236 PPP_AUTH_PROTOCOL_PAP = 0x01,
237 PPP_AUTH_PROTOCOL_CHAP_MD5 = 0x02,
238 PPP_AUTH_PROTOCOL_MS_CHAP = 0x04,
239 PPP_AUTH_PROTOCOL_MS_CHAP_2 = 0x08
244#if defined(__CWCC__) || defined(_WIN32)
245 #pragma pack(push, 1)
297 uint8_t rejectedPacket[];
310 uint16_t rejectedProtocol;
311 uint8_t rejectedInfo[];
312} PppProtocolRejPacket;
324 uint32_t magicNumber;
338 uint32_t magicNumber;
340} PppDiscardReqPacket;
356#if defined(__CWCC__) || defined(_WIN32)
415 uint16_t authProtocol;
417 bool_t authProtocolRejected;
418 uint32_t magicNumber;
419 bool_t magicNumberRejected;
424#if (IPV4_SUPPORT == ENABLED)
426 bool_t ipAddrRejected;
428 bool_t primaryDnsRejected;
430 bool_t secondaryDnsRejected;
432#if (IPV6_SUPPORT == ENABLED)
434 bool_t interfaceIdRejected;
453 bool_t localAuthDone;
458#if (IPV4_SUPPORT == ENABLED)
461#if (IPV6_SUPPORT == ENABLED)
464#if (PAP_SUPPORT == ENABLED)
467#if (CHAP_SUPPORT == ENABLED)
499error_t pppSetAuthInfo(NetInterface *interface,
const char_t *username,
500 const char_t *password);
502bool_t pppCheckPassword(NetInterface *interface,
const char_t *password);
504error_t pppSendAtCommand(NetInterface *interface,
const char_t *data);
505error_t pppReceiveAtCommand(NetInterface *interface, char_t *data,
size_t size);
507error_t pppConnect(NetInterface *interface);
508error_t pppClose(NetInterface *interface);
510void pppTick(NetInterface *interface);
512void pppProcessFrame(NetInterface *interface, uint8_t *frame,
size_t length,
513 NetRxAncillary *ancillary);
515error_t pppSendFrame(NetInterface *interface,
NetBuffer *buffer,
size_t offset,
518size_t pppParseFrameHeader(
const uint8_t *frame,
size_t length, uint16_t *protocol);
520uint16_t pppCalcFcs(
const uint8_t *data,
size_t length);
521uint16_t pppCalcFcsEx(
const NetBuffer *buffer,
size_t offset,
size_t length);
523NetBuffer *pppAllocBuffer(
size_t length,
size_t *offset);
CHAP (Challenge Handshake Authentication Protocol)
error_t
Error codes.
Definition error.h:43
uint32_t Ipv4Addr
IPv4 network address.
Definition ipv4.h:267
uint32_t systime_t
System time.
Definition os_port_none.h:90
PAP (Password Authentication Protocol)
error_t(* PppRandCallback)(uint8_t *data, size_t length)
Random data generation callback function.
Definition ppp.h:365
PppState
LCP/NCP states.
Definition ppp.h:179
PppProtocol
Protocol field values.
Definition ppp.h:198
@ PPP_PROTOCOL_IPCP
IP Control Protocol.
Definition ppp.h:201
@ PPP_PROTOCOL_LQR
Link Quality Report.
Definition ppp.h:205
@ PPP_PROTOCOL_LCP
Link Control Protocol.
Definition ppp.h:203
@ PPP_PROTOCOL_IP
Internet Protocol.
Definition ppp.h:199
@ PPP_PROTOCOL_IPV6CP
IPv6 Control Protocol.
Definition ppp.h:202
@ PPP_PROTOCOL_CHAP
Challenge Handshake Authentication Protocol.
Definition ppp.h:206
@ PPP_PROTOCOL_PAP
Password Authentication Protocol.
Definition ppp.h:204
@ PPP_PROTOCOL_IPV6
Internet Protocol version 6.
Definition ppp.h:200
PppAuthProtocol
PPP authentication protocols.
Definition ppp.h:235
PppCode
Code field values.
Definition ppp.h:215
@ PPP_CODE_ECHO_REP
Echo-Reply.
Definition ppp.h:225
@ PPP_CODE_CONFIGURE_REQ
Configure-Request.
Definition ppp.h:216
@ PPP_CODE_CONFIGURE_REJ
Configure-Reject.
Definition ppp.h:219
@ PPP_CODE_PROTOCOL_REJ
Protocol-Reject.
Definition ppp.h:223
@ PPP_CODE_TERMINATE_ACK
Terminate-Ack.
Definition ppp.h:221
@ PPP_CODE_TERMINATE_REQ
Terminate-Request.
Definition ppp.h:220
@ PPP_CODE_CODE_REJ
Code-Reject.
Definition ppp.h:222
@ PPP_CODE_DISCARD_REQ
Discard-Request.
Definition ppp.h:226
@ PPP_CODE_CONFIGURE_ACK
Configure-Ack.
Definition ppp.h:217
@ PPP_CODE_ECHO_REQ
Echo-Request.
Definition ppp.h:224
@ PPP_CODE_CONFIGURE_NAK
Configure-Nak.
Definition ppp.h:218
PppPhase
PPP phases.
Definition ppp.h:165
@ PPP_PHASE_TERMINATE
Link termination phase.
Definition ppp.h:170
@ PPP_PHASE_ESTABLISH
Link establishment phase.
Definition ppp.h:167
@ PPP_PHASE_AUTHENTICATE
Authentication phase.
Definition ppp.h:168
@ PPP_PHASE_DEAD
Link dead.
Definition ppp.h:166
@ PPP_PHASE_NETWORK
Network-layer protocol phase.
Definition ppp.h:169
bool_t(* PppAuthCallback)(NetInterface *interface, const char_t *username)
PPP authentication callback function.
Definition ppp.h:372
typedef __packed_struct
Configure-Request, Configure-Ack, Configure-Nak and Configure-Reject packets.
Definition ppp.h:267
__packed_struct _PppPacket
LCP/NCP packet header.
Definition ppp.h:254
CHAP finite state machine.
Definition chap.h:180
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89
PAP finite state machine.
Definition pap.h:153
PPP configuration options.
Definition ppp.h:410
PPP finite state machine.
Definition ppp.h:396
uint_t restartCounter
Restart counter.
Definition ppp.h:399
systime_t timestamp
Timestamp to manage retransmissions.
Definition ppp.h:401
uint8_t identifier
Identifier used to match requests and replies.
Definition ppp.h:398
uint_t state
FSM state.
Definition ppp.h:397
uint_t failureCounter
Failure counter.
Definition ppp.h:400
PPP settings.
Definition ppp.h:381
PppRandCallback randCallback
Random data generation callback function.
Definition ppp.h:386
NetInterface * interface
Underlying network interface.
Definition ppp.h:382
PppAuthCallback authCallback
PPP authentication callback function.
Definition ppp.h:387
uint32_t accm
Default async control character map.
Definition ppp.h:384
uint16_t mru
Default MRU.
Definition ppp.h:383
uint_t authProtocol
Allowed authentication protocols.
Definition ppp.h:385
PPP context.
Definition ppp.h:444
bool_t ipv6Rejected
IPv6 protocol is not support by the peer.
Definition ppp.h:473
ChapFsm chapFsm
CHAP finite state machine.
Definition ppp.h:468
char_t peerName[PPP_MAX_USERNAME_LEN+1]
Peer's name.
Definition ppp.h:451
char_t password[PPP_MAX_PASSWORD_LEN+1]
Password.
Definition ppp.h:450
uint8_t frame[PPP_MAX_FRAME_SIZE]
Incoming PPP frame.
Definition ppp.h:475
systime_t timeout
Timeout for blocking operations.
Definition ppp.h:447
PppConfig localConfig
Local configuration options.
Definition ppp.h:470
PppFsm ipv6cpFsm
IPV6CP finite state machine.
Definition ppp.h:462
uint8_t txBuffer[PPP_TX_BUFFER_SIZE]
Transmit buffer.
Definition ppp.h:477
PppConfig peerConfig
Peer configuration options.
Definition ppp.h:471
PapFsm papFsm
PAP finite state machine.
Definition ppp.h:465
PppFsm lcpFsm
LCP finite state machine.
Definition ppp.h:457
PppFsm ipcpFsm
IPCP finite state machine.
Definition ppp.h:459
bool_t ipRejected
IPv4 protocol is not supported by the peer.
Definition ppp.h:472
NetInterface * interface
PPP settings.
Definition ppp.h:446
char_t username[PPP_MAX_USERNAME_LEN+1]
User name.
Definition ppp.h:449
uint8_t rxBuffer[PPP_RX_BUFFER_SIZE]
Receive buffer.
Definition ppp.h:482
PppPhase pppPhase
PPP phase.
Definition ppp.h:456