Mbed OS Reference
Loading...
Searching...
No Matches
ppp_opts.h
1/*
2 * Redistribution and use in source and binary forms, with or without modification,
3 * are permitted provided that the following conditions are met:
4 *
5 * 1. Redistributions of source code must retain the above copyright notice,
6 * this list of conditions and the following disclaimer.
7 * 2. Redistributions in binary form must reproduce the above copyright notice,
8 * this list of conditions and the following disclaimer in the documentation
9 * and/or other materials provided with the distribution.
10 * 3. The name of the author may not be used to endorse or promote products
11 * derived from this software without specific prior written permission.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
16 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
18 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
21 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
22 * OF SUCH DAMAGE.
23 *
24 * This file is part of the lwIP TCP/IP stack.
25 *
26 */
27
28#ifndef PPP_OPTS_H
29#define PPP_OPTS_H
30
31#include "nsapi_types.h"
32
33// Enable PPP for now either from lwIP PPP configuration (obsolete) or from PPP service configuration
34#if MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED
35
36#define PPP_SUPPORT 1
37
38// For LWIP stack enable PPP Ipv4/Ipv6 support from LWIP IP version flags
39#define LWIP 0x11991199
40
41#if MBED_CONF_PPP_IPV4_ENABLED || ((MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && MBED_CONF_LWIP_IPV4_ENABLED)
42#define PPP_IPV4_SUPPORT 1
43#endif
44
45#if MBED_CONF_PPP_IPV6_ENABLED || ((MBED_CONF_NSAPI_DEFAULT_STACK == LWIP) && MBED_CONF_LWIP_IPV6_ENABLED)
46#define PPP_IPV6_SUPPORT 1
47#endif
48#undef LWIP
49
50#if MBED_CONF_PPP_ENABLE_TRACE
51// Traces every packet
52#define PPP_TRACE_ENABLE 1
53#define PPP_TRACE_BUFFER_SIZE 0 //50000
54#endif
55
56#endif
57
58#if PPP_SUPPORT
59
60#define CHAP_SUPPORT 1
61#define PPP_INPROC_IRQ_SAFE 1
62#define NO_SYS 1
63// Save RAM
64#define PAP_SUPPORT 0
65#define VJ_SUPPORT 0
66#define PRINTPKT_SUPPORT 0
67
68#define MAXNAMELEN 64 /* max length of hostname or name for auth */
69#define MAXSECRETLEN 64
70
71#define PPP_DNS 1
72
73// Used as maximum size for output buffer, to restrict the memory manager get_pool_alloc_unit()
74#ifndef PBUF_POOL_BUFSIZE
75#define PBUF_POOL_BUFSIZE 536 + 40
76#endif
77
78#endif // PPP_SUPPORT
79
80#include "ppp_service_if.h"
81
82/**
83 * PPP_SUPPORT==1: Enable PPP.
84 */
85#ifndef PPP_SUPPORT
86#define PPP_SUPPORT 0
87#endif
88
89/**
90 * PPPOE_SUPPORT==1: Enable PPP Over Ethernet
91 */
92#ifndef PPPOE_SUPPORT
93#define PPPOE_SUPPORT 0
94#endif
95
96/**
97 * PPPOL2TP_SUPPORT==1: Enable PPP Over L2TP
98 */
99#ifndef PPPOL2TP_SUPPORT
100#define PPPOL2TP_SUPPORT 0
101#endif
102
103/**
104 * PPPOL2TP_AUTH_SUPPORT==1: Enable PPP Over L2TP Auth (enable MD5 support)
105 */
106#ifndef PPPOL2TP_AUTH_SUPPORT
107#define PPPOL2TP_AUTH_SUPPORT PPPOL2TP_SUPPORT
108#endif
109
110/**
111 * PPPOS_SUPPORT==1: Enable PPP Over Serial
112 */
113#ifndef PPPOS_SUPPORT
114#define PPPOS_SUPPORT PPP_SUPPORT
115#endif
116
117/**
118 * PPP_API==1: Enable PPP API (in pppapi.c)
119 */
120#ifndef PPP_API
121#define PPP_API 0 //(PPP_SUPPORT && (NO_SYS == 0))
122#endif
123
124#if PPP_SUPPORT
125
126/**
127 * MEMP_NUM_PPP_PCB: the number of simultaneously active PPP
128 * connections (requires the PPP_SUPPORT option)
129 */
130#ifndef MEMP_NUM_PPP_PCB
131#define MEMP_NUM_PPP_PCB 1
132#endif
133
134/**
135 * PPP_NUM_TIMEOUTS_PER_PCB: the number of sys_timeouts running in parallel per
136 * ppp_pcb. See the detailed explanation at the end of ppp_impl.h about simultaneous
137 * timers analysis.
138 */
139#ifndef PPP_NUM_TIMEOUTS_PER_PCB
140#define PPP_NUM_TIMEOUTS_PER_PCB (1 + PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT + CCP_SUPPORT)
141#endif
142
143/* The number of sys_timeouts required for the PPP module */
144#define PPP_NUM_TIMEOUTS (PPP_SUPPORT * PPP_NUM_TIMEOUTS_PER_PCB * MEMP_NUM_PPP_PCB)
145
146/**
147 * MEMP_NUM_PPPOS_INTERFACES: the number of concurrently active PPPoS
148 * interfaces (only used with PPPOS_SUPPORT==1)
149 */
150#ifndef MEMP_NUM_PPPOS_INTERFACES
151#define MEMP_NUM_PPPOS_INTERFACES MEMP_NUM_PPP_PCB
152#endif
153
154/**
155 * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
156 * interfaces (only used with PPPOE_SUPPORT==1)
157 */
158#ifndef MEMP_NUM_PPPOE_INTERFACES
159#define MEMP_NUM_PPPOE_INTERFACES 1
160#endif
161
162/**
163 * MEMP_NUM_PPPOL2TP_INTERFACES: the number of concurrently active PPPoL2TP
164 * interfaces (only used with PPPOL2TP_SUPPORT==1)
165 */
166#ifndef MEMP_NUM_PPPOL2TP_INTERFACES
167#define MEMP_NUM_PPPOL2TP_INTERFACES 1
168#endif
169
170/**
171 * MEMP_NUM_PPP_API_MSG: Number of concurrent PPP API messages (in pppapi.c)
172 */
173#ifndef MEMP_NUM_PPP_API_MSG
174#define MEMP_NUM_PPP_API_MSG 5
175#endif
176
177
178/**
179 * PPP_INPROC_IRQ_SAFE==1 call pppos_input() using tcpip_callback().
180 *
181 * Please read the "PPPoS input path" chapter in the PPP documentation about this option.
182 */
183#ifndef PPP_INPROC_IRQ_SAFE
184#define PPP_INPROC_IRQ_SAFE 1
185#endif
186
187/**
188 * PRINTPKT_SUPPORT==1: Enable PPP print packet support
189 *
190 * Mandatory for debugging, it displays exchanged packet content in debug trace.
191 */
192#ifndef PRINTPKT_SUPPORT
193#define PRINTPKT_SUPPORT 0
194#endif
195
196/**
197 * PPP_NOTIFY_PHASE==1: Support PPP notify phase support
198 *
199 * PPP notify phase support allows you to set a callback which is
200 * called on change of the internal PPP state machine.
201 *
202 * This can be used for example to set a LED pattern depending on the
203 * current phase of the PPP session.
204 */
205#ifndef PPP_NOTIFY_PHASE
206#define PPP_NOTIFY_PHASE 0
207#endif
208
209/**
210 * pbuf_type PPP is using for LCP, PAP, CHAP, EAP, CCP, IPCP and IP6CP packets.
211 *
212 * Memory allocated must be single buffered for PPP to works, it requires pbuf
213 * that are not going to be chained when allocated. This requires setting
214 * PBUF_POOL_BUFSIZE to at least 512 bytes, which is quite huge for small systems.
215 *
216 * Setting PPP_USE_PBUF_RAM to 1 makes PPP use memory from heap where continuous
217 * buffers are required, allowing you to use a smaller PBUF_POOL_BUFSIZE.
218 */
219#ifndef PPP_USE_PBUF_RAM
220#define PPP_USE_PBUF_RAM 0
221#endif
222
223/**
224 * PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation for PPPoS
225 */
226#ifndef PPP_FCS_TABLE
227#define PPP_FCS_TABLE 1
228#endif
229
230/**
231 * PAP_SUPPORT==1: Support PAP.
232 */
233#ifndef PAP_SUPPORT
234#define PAP_SUPPORT 0
235#endif
236
237/**
238 * CHAP_SUPPORT==1: Support CHAP.
239 */
240#ifndef CHAP_SUPPORT
241#define CHAP_SUPPORT 0
242#endif
243
244/**
245 * MSCHAP_SUPPORT==1: Support MSCHAP.
246 */
247#ifndef MSCHAP_SUPPORT
248#define MSCHAP_SUPPORT 0
249#endif
250#if MSCHAP_SUPPORT
251/* MSCHAP requires CHAP support */
252#undef CHAP_SUPPORT
253#define CHAP_SUPPORT 1
254#endif /* MSCHAP_SUPPORT */
255
256/**
257 * EAP_SUPPORT==1: Support EAP.
258 */
259#ifndef EAP_SUPPORT
260#define EAP_SUPPORT 0
261#endif
262
263/**
264 * CCP_SUPPORT==1: Support CCP.
265 */
266#ifndef CCP_SUPPORT
267#define CCP_SUPPORT 0
268#endif
269
270/**
271 * MPPE_SUPPORT==1: Support MPPE.
272 */
273#ifndef MPPE_SUPPORT
274#define MPPE_SUPPORT 0
275#endif
276#if MPPE_SUPPORT
277/* MPPE requires CCP support */
278#undef CCP_SUPPORT
279#define CCP_SUPPORT 1
280/* MPPE requires MSCHAP support */
281#undef MSCHAP_SUPPORT
282#define MSCHAP_SUPPORT 1
283/* MSCHAP requires CHAP support */
284#undef CHAP_SUPPORT
285#define CHAP_SUPPORT 1
286#endif /* MPPE_SUPPORT */
287
288/**
289 * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
290 */
291#ifndef CBCP_SUPPORT
292#define CBCP_SUPPORT 0
293#endif
294
295/**
296 * ECP_SUPPORT==1: Support ECP. CURRENTLY NOT SUPPORTED! DO NOT SET!
297 */
298#ifndef ECP_SUPPORT
299#define ECP_SUPPORT 0
300#endif
301
302/**
303 * DEMAND_SUPPORT==1: Support dial on demand. CURRENTLY NOT SUPPORTED! DO NOT SET!
304 */
305#ifndef DEMAND_SUPPORT
306#define DEMAND_SUPPORT 0
307#endif
308
309/**
310 * LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets.
311 */
312#ifndef LQR_SUPPORT
313#define LQR_SUPPORT 0
314#endif
315
316/**
317 * PPP_SERVER==1: Enable PPP server support (waiting for incoming PPP session).
318 *
319 * Currently only supported for PPPoS.
320 */
321#ifndef PPP_SERVER
322#define PPP_SERVER 0
323#endif
324
325#if PPP_SERVER
326/*
327 * PPP_OUR_NAME: Our name for authentication purposes
328 */
329#ifndef PPP_OUR_NAME
330#define PPP_OUR_NAME "ppp"
331#endif
332#endif /* PPP_SERVER */
333
334/**
335 * VJ_SUPPORT==1: Support VJ header compression.
336 */
337#ifndef VJ_SUPPORT
338#define VJ_SUPPORT 1
339#endif
340/* VJ compression is only supported for TCP over IPv4 over PPPoS. */
341#if !PPPOS_SUPPORT || !PPP_IPV4_SUPPORT || !LWIP_TCP
342#undef VJ_SUPPORT
343#define VJ_SUPPORT 0
344#endif /* !PPPOS_SUPPORT */
345
346/**
347 * PPP_MD5_RANDM==1: Use MD5 for better randomness.
348 * Enabled by default if CHAP, EAP, or L2TP AUTH support is enabled.
349 */
350#ifndef PPP_MD5_RANDM
351#define PPP_MD5_RANDM (CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT)
352#endif
353
354/**
355 * PolarSSL embedded library
356 *
357 *
358 * PPP contains some files fetched from the latest BSD release of
359 * the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption
360 * methods we need for PPP support.
361 *
362 * The PolarSSL files were cleaned to contain only the necessary struct
363 * fields and functions needed for PPP.
364 *
365 * The PolarSSL API was not changed at all, so if you are already using
366 * PolarSSL you can choose to skip the compilation of the included PolarSSL
367 * library into PPP.
368 *
369 * If you are not using the embedded copy you must include external
370 * libraries into your arch/cc.h port file.
371 *
372 * Beware of the stack requirements which can be a lot larger if you are not
373 * using our cleaned PolarSSL library.
374 */
375
376/**
377 * PPP_USE_EXTERNAL_POLARSSL: Use external PolarSSL library
378 */
379#ifndef PPP_USE_EXTERNAL_POLARSSL
380#define PPP_USE_EXTERNAL_POLARSSL 0
381#endif
382
383/**
384 * PPP_USE_EXTERNAL_MBEDTLS: Use external mbed TLS library
385 */
386#ifndef PPP_USE_EXTERNAL_MBEDTLS
387#define PPP_USE_EXTERNAL_MBEDTLS 0
388#endif
389
390/*
391 * PPP Timeouts
392 */
393
394/**
395 * FSM_DEFTIMEOUT: Timeout time in seconds
396 */
397#ifndef FSM_DEFTIMEOUT
398#define FSM_DEFTIMEOUT 6
399#endif
400
401/**
402 * FSM_DEFMAXTERMREQS: Maximum Terminate-Request transmissions
403 */
404#ifndef FSM_DEFMAXTERMREQS
405#define FSM_DEFMAXTERMREQS 2
406#endif
407
408/**
409 * FSM_DEFMAXCONFREQS: Maximum Configure-Request transmissions
410 */
411#ifndef FSM_DEFMAXCONFREQS
412#define FSM_DEFMAXCONFREQS 10
413#endif
414
415/**
416 * FSM_DEFMAXNAKLOOPS: Maximum number of nak loops
417 */
418#ifndef FSM_DEFMAXNAKLOOPS
419#define FSM_DEFMAXNAKLOOPS 5
420#endif
421
422/**
423 * UPAP_DEFTIMEOUT: Timeout (seconds) for re-transmitting req
424 */
425#ifndef UPAP_DEFTIMEOUT
426#define UPAP_DEFTIMEOUT 6
427#endif
428
429/**
430 * UPAP_DEFTRANSMITS: Maximum number of auth-reqs to send
431 */
432#ifndef UPAP_DEFTRANSMITS
433#define UPAP_DEFTRANSMITS 10
434#endif
435
436#if PPP_SERVER
437/**
438 * UPAP_DEFREQTIME: Time to wait for auth-req from peer
439 */
440#ifndef UPAP_DEFREQTIME
441#define UPAP_DEFREQTIME 30
442#endif
443#endif /* PPP_SERVER */
444
445/**
446 * CHAP_DEFTIMEOUT: Timeout (seconds) for re-transmitting req
447 */
448#ifndef CHAP_DEFTIMEOUT
449#define CHAP_DEFTIMEOUT 6
450#endif
451
452/**
453 * CHAP_DEFTRANSMITS: max # times to send challenge
454 */
455#ifndef CHAP_DEFTRANSMITS
456#define CHAP_DEFTRANSMITS 10
457#endif
458
459#if PPP_SERVER
460/**
461 * CHAP_DEFRECHALLENGETIME: If this option is > 0, re-challenge the peer every n seconds
462 */
463#ifndef CHAP_DEFRECHALLENGETIME
464#define CHAP_DEFRECHALLENGETIME 0
465#endif
466#endif /* PPP_SERVER */
467
468/**
469 * EAP_DEFREQTIME: Time to wait for peer request
470 */
471#ifndef EAP_DEFREQTIME
472#define EAP_DEFREQTIME 6
473#endif
474
475/**
476 * EAP_DEFALLOWREQ: max # times to accept requests
477 */
478#ifndef EAP_DEFALLOWREQ
479#define EAP_DEFALLOWREQ 10
480#endif
481
482#if PPP_SERVER
483/**
484 * EAP_DEFTIMEOUT: Timeout (seconds) for rexmit
485 */
486#ifndef EAP_DEFTIMEOUT
487#define EAP_DEFTIMEOUT 6
488#endif
489
490/**
491 * EAP_DEFTRANSMITS: max # times to transmit
492 */
493#ifndef EAP_DEFTRANSMITS
494#define EAP_DEFTRANSMITS 10
495#endif
496#endif /* PPP_SERVER */
497
498/**
499 * LCP_DEFLOOPBACKFAIL: Default number of times we receive our magic number from the peer
500 * before deciding the link is looped-back.
501 */
502#ifndef LCP_DEFLOOPBACKFAIL
503#define LCP_DEFLOOPBACKFAIL 10
504#endif
505
506/**
507 * LCP_ECHOINTERVAL: Interval in seconds between keepalive echo requests, 0 to disable.
508 */
509#ifndef LCP_ECHOINTERVAL
510#define LCP_ECHOINTERVAL 0
511#endif
512
513/**
514 * LCP_MAXECHOFAILS: Number of unanswered echo requests before failure.
515 */
516#ifndef LCP_MAXECHOFAILS
517#define LCP_MAXECHOFAILS 3
518#endif
519
520/**
521 * PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char.
522 */
523#ifndef PPP_MAXIDLEFLAG
524#define PPP_MAXIDLEFLAG 100
525#endif
526
527/**
528 * PPP Packet sizes
529 */
530
531/**
532 * PPP_MRU: Default MRU
533 */
534#ifndef PPP_MRU
535#define PPP_MRU 1500
536#endif
537
538/**
539 * PPP_DEFMRU: Default MRU to try
540 */
541#ifndef PPP_DEFMRU
542#define PPP_DEFMRU 1500
543#endif
544
545/**
546 * PPP_MAXMRU: Normally limit MRU to this (pppd default = 16384)
547 */
548#ifndef PPP_MAXMRU
549#define PPP_MAXMRU 1500
550#endif
551
552/**
553 * PPP_MINMRU: No MRUs below this
554 */
555#ifndef PPP_MINMRU
556#define PPP_MINMRU 128
557#endif
558
559/**
560 * PPPOL2TP_DEFMRU: Default MTU and MRU for L2TP
561 * Default = 1500 - PPPoE(6) - PPP Protocol(2) - IPv4 header(20) - UDP Header(8)
562 * - L2TP Header(6) - HDLC Header(2) - PPP Protocol(2) - MPPE Header(2) - PPP Protocol(2)
563 */
564#if PPPOL2TP_SUPPORT
565#ifndef PPPOL2TP_DEFMRU
566#define PPPOL2TP_DEFMRU 1450
567#endif
568#endif /* PPPOL2TP_SUPPORT */
569
570/**
571 * MAXNAMELEN: max length of hostname or name for auth
572 */
573#ifndef MAXNAMELEN
574#define MAXNAMELEN 256
575#endif
576
577/**
578 * MAXSECRETLEN: max length of password or secret
579 */
580#ifndef MAXSECRETLEN
581#define MAXSECRETLEN 256
582#endif
583
584/* ------------------------------------------------------------------------- */
585
586/*
587 * Build triggers for embedded PolarSSL
588 */
589
590/* CHAP, EAP, L2TP AUTH and MD5 Random require MD5 support */
591#if CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM
592#define PPP_INCLUDED_POLARSSL_MD5 1
593#endif /* CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM */
594
595#if MSCHAP_SUPPORT
596
597/* MSCHAP require MD4 support */
598#define PPP_INCLUDED_POLARSSL_MD4 1
599/* MSCHAP require SHA1 support */
600#define PPP_INCLUDED_POLARSSL_SHA1 1
601/* MSCHAP require DES support */
602#define PPP_INCLUDED_POLARSSL_DES 1
603
604/* MS-CHAP support is required for MPPE */
605#if MPPE_SUPPORT
606/* MPPE require ARC4 support */
607#define PPP_INCLUDED_POLARSSL_ARC4 1
608#endif /* MPPE_SUPPORT */
609
610#endif /* MSCHAP_SUPPORT */
611
612/* Default value if unset */
613#ifndef PPP_INCLUDED_POLARSSL_MD4
614#define PPP_INCLUDED_POLARSSL_MD4 0
615#endif /* PPP_INCLUDED_POLARSSL_MD4 */
616#ifndef PPP_INCLUDED_POLARSSL_MD5
617#define PPP_INCLUDED_POLARSSL_MD5 0
618#endif /* PPP_INCLUDED_POLARSSL_MD5 */
619#ifndef PPP_INCLUDED_POLARSSL_SHA1
620#define PPP_INCLUDED_POLARSSL_SHA1 0
621#endif /* PPP_INCLUDED_POLARSSL_SHA1 */
622#ifndef PPP_INCLUDED_POLARSSL_DES
623#define PPP_INCLUDED_POLARSSL_DES 0
624#endif /* PPP_INCLUDED_POLARSSL_DES */
625#ifndef PPP_INCLUDED_POLARSSL_ARC4
626#define PPP_INCLUDED_POLARSSL_ARC4 0
627#endif /* PPP_INCLUDED_POLARSSL_ARC4 */
628
629#endif /* PPP_SUPPORT */
630
631/* Default value if unset */
632#ifndef PPP_NUM_TIMEOUTS
633#define PPP_NUM_TIMEOUTS 0
634#endif /* PPP_NUM_TIMEOUTS */
635
636#endif /* PPP_OPTS_H */