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 LWIP_PPP_OPTS_H
29 #define LWIP_PPP_OPTS_H
30 
31 #include "lwip/opt.h"
32 
33 /**
34  * PPP_SUPPORT==1: Enable PPP.
35  */
36 #ifndef PPP_SUPPORT
37 #define PPP_SUPPORT                     0
38 #endif
39 
40 /**
41  * PPPOE_SUPPORT==1: Enable PPP Over Ethernet
42  */
43 #ifndef PPPOE_SUPPORT
44 #define PPPOE_SUPPORT                   0
45 #endif
46 
47 /**
48  * PPPOL2TP_SUPPORT==1: Enable PPP Over L2TP
49  */
50 #ifndef PPPOL2TP_SUPPORT
51 #define PPPOL2TP_SUPPORT                0
52 #endif
53 
54 /**
55  * PPPOL2TP_AUTH_SUPPORT==1: Enable PPP Over L2TP Auth (enable MD5 support)
56  */
57 #ifndef PPPOL2TP_AUTH_SUPPORT
58 #define PPPOL2TP_AUTH_SUPPORT           PPPOL2TP_SUPPORT
59 #endif
60 
61 /**
62  * PPPOS_SUPPORT==1: Enable PPP Over Serial
63  */
64 #ifndef PPPOS_SUPPORT
65 #define PPPOS_SUPPORT                   PPP_SUPPORT
66 #endif
67 
68 /**
69  * LWIP_PPP_API==1: Enable PPP API (in pppapi.c)
70  */
71 #ifndef LWIP_PPP_API
72 #define LWIP_PPP_API                    (PPP_SUPPORT && (NO_SYS == 0))
73 #endif
74 
75 /**
76  * MEMP_NUM_PPP_PCB: the number of simultaneously active PPP
77  * connections (requires the PPP_SUPPORT option)
78  */
79 #ifndef MEMP_NUM_PPP_PCB
80 #define MEMP_NUM_PPP_PCB       1
81 #endif
82 
83 #if PPP_SUPPORT
84 
85 /**
86  * MEMP_NUM_PPPOS_INTERFACES: the number of concurrently active PPPoS
87  * interfaces (only used with PPPOS_SUPPORT==1)
88  */
89 #ifndef MEMP_NUM_PPPOS_INTERFACES
90 #define MEMP_NUM_PPPOS_INTERFACES       MEMP_NUM_PPP_PCB
91 #endif
92 
93 /**
94  * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
95  * interfaces (only used with PPPOE_SUPPORT==1)
96  */
97 #ifndef MEMP_NUM_PPPOE_INTERFACES
98 #define MEMP_NUM_PPPOE_INTERFACES       1
99 #endif
100 
101 /**
102  * MEMP_NUM_PPPOL2TP_INTERFACES: the number of concurrently active PPPoL2TP
103  * interfaces (only used with PPPOL2TP_SUPPORT==1)
104  */
105 #ifndef MEMP_NUM_PPPOL2TP_INTERFACES
106 #define MEMP_NUM_PPPOL2TP_INTERFACES       1
107 #endif
108 
109 /**
110  * MEMP_NUM_PPP_API_MSG: Number of concurrent PPP API messages (in pppapi.c)
111  */
112 #ifndef MEMP_NUM_PPP_API_MSG
113 #define MEMP_NUM_PPP_API_MSG 5
114 #endif
115 
116 /**
117  * PPP_DEBUG: Enable debugging for PPP.
118  */
119 #ifndef PPP_DEBUG
120 #define PPP_DEBUG                       LWIP_DBG_OFF
121 #endif
122 
123 /**
124  * PPP_INPROC_IRQ_SAFE==1 call pppos_input() using tcpip_callback().
125  *
126  * Please read the "PPPoS input path" chapter in the PPP documentation about this option.
127  */
128 #ifndef PPP_INPROC_IRQ_SAFE
129 #define PPP_INPROC_IRQ_SAFE             0
130 #endif
131 
132 /**
133  * PRINTPKT_SUPPORT==1: Enable PPP print packet support
134  *
135  * Mandatory for debugging, it displays exchanged packet content in debug trace.
136  */
137 #ifndef PRINTPKT_SUPPORT
138 #define PRINTPKT_SUPPORT                0
139 #endif
140 
141 /**
142  * PPP_IPV4_SUPPORT==1: Enable PPP IPv4 support
143  */
144 #ifndef PPP_IPV4_SUPPORT
145 #define PPP_IPV4_SUPPORT                (LWIP_IPV4)
146 #endif
147 
148 /**
149  * PPP_IPV6_SUPPORT==1: Enable PPP IPv6 support
150  */
151 #ifndef PPP_IPV6_SUPPORT
152 #define PPP_IPV6_SUPPORT                (LWIP_IPV6)
153 #endif
154 
155 /**
156  * PPP_NOTIFY_PHASE==1: Support PPP notify phase support
157  *
158  * PPP notify phase support allows you to set a callback which is
159  * called on change of the internal PPP state machine.
160  *
161  * This can be used for example to set a LED pattern depending on the
162  * current phase of the PPP session.
163  */
164 #ifndef PPP_NOTIFY_PHASE
165 #define PPP_NOTIFY_PHASE                0
166 #endif
167 
168 /**
169  * pbuf_type PPP is using for LCP, PAP, CHAP, EAP, CCP, IPCP and IP6CP packets.
170  *
171  * Memory allocated must be single buffered for PPP to works, it requires pbuf
172  * that are not going to be chained when allocated. This requires setting
173  * PBUF_POOL_BUFSIZE to at least 512 bytes, which is quite huge for small systems.
174  *
175  * Setting PPP_USE_PBUF_RAM to 1 makes PPP use memory from heap where continuous
176  * buffers are required, allowing you to use a smaller PBUF_POOL_BUFSIZE.
177  */
178 #ifndef PPP_USE_PBUF_RAM
179 #define PPP_USE_PBUF_RAM                0
180 #endif
181 
182 /**
183  * PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation for PPPoS
184  */
185 #ifndef PPP_FCS_TABLE
186 #define PPP_FCS_TABLE                   1
187 #endif
188 
189 /**
190  * PAP_SUPPORT==1: Support PAP.
191  */
192 #ifndef PAP_SUPPORT
193 #define PAP_SUPPORT                     0
194 #endif
195 
196 /**
197  * CHAP_SUPPORT==1: Support CHAP.
198  */
199 #ifndef CHAP_SUPPORT
200 #define CHAP_SUPPORT                    0
201 #endif
202 
203 /**
204  * MSCHAP_SUPPORT==1: Support MSCHAP.
205  */
206 #ifndef MSCHAP_SUPPORT
207 #define MSCHAP_SUPPORT                  0
208 #endif
209 #if MSCHAP_SUPPORT
210 /* MSCHAP requires CHAP support */
211 #undef CHAP_SUPPORT
212 #define CHAP_SUPPORT                    1
213 #endif /* MSCHAP_SUPPORT */
214 
215 /**
216  * EAP_SUPPORT==1: Support EAP.
217  */
218 #ifndef EAP_SUPPORT
219 #define EAP_SUPPORT                     0
220 #endif
221 
222 /**
223  * CCP_SUPPORT==1: Support CCP.
224  */
225 #ifndef CCP_SUPPORT
226 #define CCP_SUPPORT                     0
227 #endif
228 
229 /**
230  * MPPE_SUPPORT==1: Support MPPE.
231  */
232 #ifndef MPPE_SUPPORT
233 #define MPPE_SUPPORT                    0
234 #endif
235 #if MPPE_SUPPORT
236 /* MPPE requires CCP support */
237 #undef CCP_SUPPORT
238 #define CCP_SUPPORT                     1
239 /* MPPE requires MSCHAP support */
240 #undef MSCHAP_SUPPORT
241 #define MSCHAP_SUPPORT                  1
242 /* MSCHAP requires CHAP support */
243 #undef CHAP_SUPPORT
244 #define CHAP_SUPPORT                    1
245 #endif /* MPPE_SUPPORT */
246 
247 /**
248  * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
249  */
250 #ifndef CBCP_SUPPORT
251 #define CBCP_SUPPORT                    0
252 #endif
253 
254 /**
255  * ECP_SUPPORT==1: Support ECP. CURRENTLY NOT SUPPORTED! DO NOT SET!
256  */
257 #ifndef ECP_SUPPORT
258 #define ECP_SUPPORT                     0
259 #endif
260 
261 /**
262  * DEMAND_SUPPORT==1: Support dial on demand. CURRENTLY NOT SUPPORTED! DO NOT SET!
263  */
264 #ifndef DEMAND_SUPPORT
265 #define DEMAND_SUPPORT                  0
266 #endif
267 
268 /**
269  * LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets.
270  */
271 #ifndef LQR_SUPPORT
272 #define LQR_SUPPORT                     0
273 #endif
274 
275 /**
276  * PPP_SERVER==1: Enable PPP server support (waiting for incoming PPP session).
277  *
278  * Currently only supported for PPPoS.
279  */
280 #ifndef PPP_SERVER
281 #define PPP_SERVER                      0
282 #endif
283 
284 #if PPP_SERVER
285 /*
286  * PPP_OUR_NAME: Our name for authentication purposes
287  */
288 #ifndef PPP_OUR_NAME
289 #define PPP_OUR_NAME                    "lwIP"
290 #endif
291 #endif /* PPP_SERVER */
292 
293 /**
294  * VJ_SUPPORT==1: Support VJ header compression.
295  */
296 #ifndef VJ_SUPPORT
297 #define VJ_SUPPORT                      1
298 #endif
299 /* VJ compression is only supported for TCP over IPv4 over PPPoS. */
300 #if !PPPOS_SUPPORT || !PPP_IPV4_SUPPORT || !LWIP_TCP
301 #undef VJ_SUPPORT
302 #define VJ_SUPPORT                      0
303 #endif /* !PPPOS_SUPPORT */
304 
305 /**
306  * PPP_MD5_RANDM==1: Use MD5 for better randomness.
307  * Enabled by default if CHAP, EAP, or L2TP AUTH support is enabled.
308  */
309 #ifndef PPP_MD5_RANDM
310 #define PPP_MD5_RANDM                   (CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT)
311 #endif
312 
313 /**
314  * PolarSSL embedded library
315  *
316  *
317  * lwIP contains some files fetched from the latest BSD release of
318  * the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption
319  * methods we need for lwIP PPP support.
320  *
321  * The PolarSSL files were cleaned to contain only the necessary struct
322  * fields and functions needed for lwIP.
323  *
324  * The PolarSSL API was not changed at all, so if you are already using
325  * PolarSSL you can choose to skip the compilation of the included PolarSSL
326  * library into lwIP.
327  *
328  * If you are not using the embedded copy you must include external
329  * libraries into your arch/cc.h port file.
330  *
331  * Beware of the stack requirements which can be a lot larger if you are not
332  * using our cleaned PolarSSL library.
333  */
334 
335 /**
336  * LWIP_USE_EXTERNAL_POLARSSL: Use external PolarSSL library
337  */
338 #ifndef LWIP_USE_EXTERNAL_POLARSSL
339 #define LWIP_USE_EXTERNAL_POLARSSL      0
340 #endif
341 
342 /**
343  * LWIP_USE_EXTERNAL_MBEDTLS: Use external mbed TLS library
344  */
345 #ifndef LWIP_USE_EXTERNAL_MBEDTLS
346 #define LWIP_USE_EXTERNAL_MBEDTLS       0
347 #endif
348 
349 /*
350  * PPP Timeouts
351  */
352 
353 /**
354  * FSM_DEFTIMEOUT: Timeout time in seconds
355  */
356 #ifndef FSM_DEFTIMEOUT
357 #define FSM_DEFTIMEOUT                  6
358 #endif
359 
360 /**
361  * FSM_DEFMAXTERMREQS: Maximum Terminate-Request transmissions
362  */
363 #ifndef FSM_DEFMAXTERMREQS
364 #define FSM_DEFMAXTERMREQS              2
365 #endif
366 
367 /**
368  * FSM_DEFMAXCONFREQS: Maximum Configure-Request transmissions
369  */
370 #ifndef FSM_DEFMAXCONFREQS
371 #define FSM_DEFMAXCONFREQS              10
372 #endif
373 
374 /**
375  * FSM_DEFMAXNAKLOOPS: Maximum number of nak loops
376  */
377 #ifndef FSM_DEFMAXNAKLOOPS
378 #define FSM_DEFMAXNAKLOOPS              5
379 #endif
380 
381 /**
382  * UPAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req
383  */
384 #ifndef UPAP_DEFTIMEOUT
385 #define UPAP_DEFTIMEOUT                 6
386 #endif
387 
388 /**
389  * UPAP_DEFTRANSMITS: Maximum number of auth-reqs to send
390  */
391 #ifndef UPAP_DEFTRANSMITS
392 #define UPAP_DEFTRANSMITS               10
393 #endif
394 
395 #if PPP_SERVER
396 /**
397  * UPAP_DEFREQTIME: Time to wait for auth-req from peer
398  */
399 #ifndef UPAP_DEFREQTIME
400 #define UPAP_DEFREQTIME                 30
401 #endif
402 #endif /* PPP_SERVER */
403 
404 /**
405  * CHAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req
406  */
407 #ifndef CHAP_DEFTIMEOUT
408 #define CHAP_DEFTIMEOUT                 6
409 #endif
410 
411 /**
412  * CHAP_DEFTRANSMITS: max # times to send challenge
413  */
414 #ifndef CHAP_DEFTRANSMITS
415 #define CHAP_DEFTRANSMITS               10
416 #endif
417 
418 #if PPP_SERVER
419 /**
420  * CHAP_DEFRECHALLENGETIME: If this option is > 0, rechallenge the peer every n seconds
421  */
422 #ifndef CHAP_DEFRECHALLENGETIME
423 #define CHAP_DEFRECHALLENGETIME         0
424 #endif
425 #endif /* PPP_SERVER */
426 
427 /**
428  * EAP_DEFREQTIME: Time to wait for peer request
429  */
430 #ifndef EAP_DEFREQTIME
431 #define EAP_DEFREQTIME                  6
432 #endif
433 
434 /**
435  * EAP_DEFALLOWREQ: max # times to accept requests
436  */
437 #ifndef EAP_DEFALLOWREQ
438 #define EAP_DEFALLOWREQ                 10
439 #endif
440 
441 #if PPP_SERVER
442 /**
443  * EAP_DEFTIMEOUT: Timeout (seconds) for rexmit
444  */
445 #ifndef EAP_DEFTIMEOUT
446 #define EAP_DEFTIMEOUT                  6
447 #endif
448 
449 /**
450  * EAP_DEFTRANSMITS: max # times to transmit
451  */
452 #ifndef EAP_DEFTRANSMITS
453 #define EAP_DEFTRANSMITS                10
454 #endif
455 #endif /* PPP_SERVER */
456 
457 /**
458  * LCP_DEFLOOPBACKFAIL: Default number of times we receive our magic number from the peer
459  * before deciding the link is looped-back.
460  */
461 #ifndef LCP_DEFLOOPBACKFAIL
462 #define LCP_DEFLOOPBACKFAIL             10
463 #endif
464 
465 /**
466  * LCP_ECHOINTERVAL: Interval in seconds between keepalive echo requests, 0 to disable.
467  */
468 #ifndef LCP_ECHOINTERVAL
469 #define LCP_ECHOINTERVAL                0
470 #endif
471 
472 /**
473  * LCP_MAXECHOFAILS: Number of unanswered echo requests before failure.
474  */
475 #ifndef LCP_MAXECHOFAILS
476 #define LCP_MAXECHOFAILS                3
477 #endif
478 
479 /**
480  * PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char.
481  */
482 #ifndef PPP_MAXIDLEFLAG
483 #define PPP_MAXIDLEFLAG                 100
484 #endif
485 
486 /**
487  * PPP Packet sizes
488  */
489 
490 /**
491  * PPP_MRU: Default MRU
492  */
493 #ifndef PPP_MRU
494 #define PPP_MRU                         1500
495 #endif
496 
497 /**
498  * PPP_DEFMRU: Default MRU to try
499  */
500 #ifndef PPP_DEFMRU
501 #define PPP_DEFMRU                      1500
502 #endif
503 
504 /**
505  * PPP_MAXMRU: Normally limit MRU to this (pppd default = 16384)
506  */
507 #ifndef PPP_MAXMRU
508 #define PPP_MAXMRU                      1500
509 #endif
510 
511 /**
512  * PPP_MINMRU: No MRUs below this
513  */
514 #ifndef PPP_MINMRU
515 #define PPP_MINMRU                      128
516 #endif
517 
518 /**
519  * PPPOL2TP_DEFMRU: Default MTU and MRU for L2TP
520  * Default = 1500 - PPPoE(6) - PPP Protocol(2) - IPv4 header(20) - UDP Header(8)
521  * - L2TP Header(6) - HDLC Header(2) - PPP Protocol(2) - MPPE Header(2) - PPP Protocol(2)
522  */
523 #if PPPOL2TP_SUPPORT
524 #ifndef PPPOL2TP_DEFMRU
525 #define PPPOL2TP_DEFMRU                 1450
526 #endif
527 #endif /* PPPOL2TP_SUPPORT */
528 
529 /**
530  * MAXNAMELEN: max length of hostname or name for auth
531  */
532 #ifndef MAXNAMELEN
533 #define MAXNAMELEN                      256
534 #endif
535 
536 /**
537  * MAXSECRETLEN: max length of password or secret
538  */
539 #ifndef MAXSECRETLEN
540 #define MAXSECRETLEN                    256
541 #endif
542 
543 /* ------------------------------------------------------------------------- */
544 
545 /*
546  * Build triggers for embedded PolarSSL
547  */
548 #if !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS
549 
550 /* CHAP, EAP, L2TP AUTH and MD5 Random require MD5 support */
551 #if CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM
552 #define LWIP_INCLUDED_POLARSSL_MD5      1
553 #endif /* CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM */
554 
555 #if MSCHAP_SUPPORT
556 
557 /* MSCHAP require MD4 support */
558 #define LWIP_INCLUDED_POLARSSL_MD4      1
559 /* MSCHAP require SHA1 support */
560 #define LWIP_INCLUDED_POLARSSL_SHA1     1
561 /* MSCHAP require DES support */
562 #define LWIP_INCLUDED_POLARSSL_DES      1
563 
564 /* MS-CHAP support is required for MPPE */
565 #if MPPE_SUPPORT
566 /* MPPE require ARC4 support */
567 #define LWIP_INCLUDED_POLARSSL_ARC4     1
568 #endif /* MPPE_SUPPORT */
569 
570 #endif /* MSCHAP_SUPPORT */
571 
572 #endif /* !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS */
573 
574 /* Default value if unset */
575 #ifndef LWIP_INCLUDED_POLARSSL_MD4
576 #define LWIP_INCLUDED_POLARSSL_MD4      0
577 #endif /* LWIP_INCLUDED_POLARSSL_MD4 */
578 #ifndef LWIP_INCLUDED_POLARSSL_MD5
579 #define LWIP_INCLUDED_POLARSSL_MD5      0
580 #endif /* LWIP_INCLUDED_POLARSSL_MD5 */
581 #ifndef LWIP_INCLUDED_POLARSSL_SHA1
582 #define LWIP_INCLUDED_POLARSSL_SHA1     0
583 #endif /* LWIP_INCLUDED_POLARSSL_SHA1 */
584 #ifndef LWIP_INCLUDED_POLARSSL_DES
585 #define LWIP_INCLUDED_POLARSSL_DES      0
586 #endif /* LWIP_INCLUDED_POLARSSL_DES */
587 #ifndef LWIP_INCLUDED_POLARSSL_ARC4
588 #define LWIP_INCLUDED_POLARSSL_ARC4     0
589 #endif /* LWIP_INCLUDED_POLARSSL_ARC4 */
590 
591 #endif /* PPP_SUPPORT */
592 
593 #endif /* LWIP_PPP_OPTS_H */
594