1 /*****************************************************************************
2 * ppp.h - Network Point to Point Protocol header file.
4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 * portions Copyright (c) 1997 Global Election Systems Inc.
7 * The authors hereby grant permission to use, copy, modify, distribute,
8 * and license this software and its documentation for any purpose, provided
9 * that existing copyright notices are retained in all copies and that this
10 * notice and the following disclaimer are included verbatim in any
11 * distributions. No written agreement, license, or royalty fee is required
12 * for any of the authorized uses.
14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 ******************************************************************************
28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
30 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
31 * Original derived from BSD codes.
32 *****************************************************************************/
34 #include "netif/ppp/ppp_opts.h"
35 #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
41 #include "lwip/stats.h"
43 #include "lwip/netif.h"
45 #include "lwip/timeouts.h"
47 #include "lwip/ip6_addr.h"
48 #endif /* PPP_IPV6_SUPPORT */
50 /* Disable non-working or rarely used PPP feature, so rarely that we don't want to bloat ppp_opts.h with them */
59 #ifndef PPP_REMOTENAME
60 #define PPP_REMOTENAME 0
63 #ifndef PPP_IDLETIMELIMIT
64 #define PPP_IDLETIMELIMIT 0
67 #ifndef PPP_LCP_ADAPTIVE
68 #define PPP_LCP_ADAPTIVE 0
71 #ifndef PPP_MAXCONNECT
72 #define PPP_MAXCONNECT 0
75 #ifndef PPP_ALLOWED_ADDRS
76 #define PPP_ALLOWED_ADDRS 0
79 #ifndef PPP_PROTOCOLNAME
80 #define PPP_PROTOCOLNAME 0
83 #ifndef PPP_STATS_SUPPORT
84 #define PPP_STATS_SUPPORT 0
87 #ifndef DEFLATE_SUPPORT
88 #define DEFLATE_SUPPORT 0
91 #ifndef BSDCOMPRESS_SUPPORT
92 #define BSDCOMPRESS_SUPPORT 0
95 #ifndef PREDICTOR_SUPPORT
96 #define PREDICTOR_SUPPORT 0
99 /*************************
100 *** PUBLIC DEFINITIONS ***
101 *************************/
104 * The basic PPP frame.
106 #define PPP_HDRLEN 4 /* octets for standard ppp header */
107 #define PPP_FCSLEN 2 /* octets for FCS */
112 #define PPP_PHASE_DEAD 0
113 #define PPP_PHASE_MASTER 1
114 #define PPP_PHASE_HOLDOFF 2
115 #define PPP_PHASE_INITIALIZE 3
116 #define PPP_PHASE_SERIALCONN 4
117 #define PPP_PHASE_DORMANT 5
118 #define PPP_PHASE_ESTABLISH 6
119 #define PPP_PHASE_AUTHENTICATE 7
120 #define PPP_PHASE_CALLBACK 8
121 #define PPP_PHASE_NETWORK 9
122 #define PPP_PHASE_RUNNING 10
123 #define PPP_PHASE_TERMINATE 11
124 #define PPP_PHASE_DISCONNECT 12
127 #define PPPERR_NONE 0 /* No error. */
128 #define PPPERR_PARAM 1 /* Invalid parameter. */
129 #define PPPERR_OPEN 2 /* Unable to open PPP session. */
130 #define PPPERR_DEVICE 3 /* Invalid I/O device for PPP. */
131 #define PPPERR_ALLOC 4 /* Unable to allocate resources. */
132 #define PPPERR_USER 5 /* User interrupt. */
133 #define PPPERR_CONNECT 6 /* Connection lost. */
134 #define PPPERR_AUTHFAIL 7 /* Failed authentication challenge. */
135 #define PPPERR_PROTOCOL 8 /* Failed to meet protocol. */
136 #define PPPERR_PEERDEAD 9 /* Connection timeout */
137 #define PPPERR_IDLETIMEOUT 10 /* Idle Timeout */
138 #define PPPERR_CONNECTTIME 11 /* Max connect time reached */
139 #define PPPERR_LOOPBACK 12 /* Loopback detected */
141 /* Whether auth support is enabled at all */
142 #define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT)
144 /************************
145 *** PUBLIC DATA TYPES ***
146 ************************/
149 * Other headers require ppp_pcb definition for prototypes, but ppp_pcb
150 * require some structure definition from other headers as well, we are
151 * fixing the dependency loop here by declaring the ppp_pcb type then
152 * by including headers containing necessary struct definition for ppp_pcb
154 typedef struct ppp_pcb_s ppp_pcb
;
156 /* Type definitions for BSD code. */
157 #ifndef __u_char_defined
158 typedef unsigned long u_long
;
159 typedef unsigned int u_int
;
160 typedef unsigned short u_short
;
161 typedef unsigned char u_char
;
168 #endif /* CCP_SUPPORT */
171 #endif /* MPPE_SUPPORT */
174 #endif /* PPP_IPV4_SUPPORT */
177 #endif /* PPP_IPV6_SUPPORT */
180 #endif /* PAP_SUPPORT */
182 #include "chap-new.h"
183 #endif /* CHAP_SUPPORT */
186 #endif /* EAP_SUPPORT */
189 #endif /* VJ_SUPPORT */
191 /* Link status callback function prototype */
192 typedef void (*ppp_link_status_cb_fn
)(ppp_pcb
*pcb
, int err_code
, void *ctx
);
197 typedef struct ppp_settings_s
{
199 #if PPP_SERVER && PPP_AUTH_SUPPORT
200 unsigned int auth_required
:1; /* Peer is required to authenticate */
201 unsigned int null_login
:1; /* Username of "" and a password of "" are acceptable */
202 #endif /* PPP_SERVER && PPP_AUTH_SUPPORT */
204 unsigned int explicit_remote
:1; /* remote_name specified with remotename opt */
205 #endif /* PPP_REMOTENAME */
207 unsigned int refuse_pap
:1; /* Don't proceed auth. with PAP */
208 #endif /* PAP_SUPPORT */
210 unsigned int refuse_chap
:1; /* Don't proceed auth. with CHAP */
211 #endif /* CHAP_SUPPORT */
213 unsigned int refuse_mschap
:1; /* Don't proceed auth. with MS-CHAP */
214 unsigned int refuse_mschap_v2
:1; /* Don't proceed auth. with MS-CHAPv2 */
215 #endif /* MSCHAP_SUPPORT */
217 unsigned int refuse_eap
:1; /* Don't proceed auth. with EAP */
218 #endif /* EAP_SUPPORT */
220 unsigned int usepeerdns
:1; /* Ask peer for DNS adds */
221 #endif /* LWIP_DNS */
222 unsigned int persist
:1; /* Persist mode, always try to open the connection */
224 unsigned int hide_password
:1; /* Hide password in dumped packets */
225 #endif /* PRINTPKT_SUPPORT */
226 unsigned int noremoteip
:1; /* Let him have no IP address */
227 unsigned int lax_recv
:1; /* accept control chars in asyncmap */
228 unsigned int noendpoint
:1; /* don't send/accept endpoint discriminator */
230 unsigned int lcp_echo_adaptive
:1; /* request echo only if the link was idle */
231 #endif /* PPP_LCP_ADAPTIVE */
233 unsigned int require_mppe
:1; /* Require MPPE (Microsoft Point to Point Encryption) */
234 unsigned int refuse_mppe_40
:1; /* Allow MPPE 40-bit mode? */
235 unsigned int refuse_mppe_128
:1; /* Allow MPPE 128-bit mode? */
236 unsigned int refuse_mppe_stateful
:1; /* Allow MPPE stateful mode? */
237 #endif /* MPPE_SUPPORT */
239 u16_t listen_time
; /* time to listen first (ms), waiting for peer to send LCP packet */
241 #if PPP_IDLETIMELIMIT
242 u16_t idle_time_limit
; /* Disconnect if idle for this many seconds */
243 #endif /* PPP_IDLETIMELIMIT */
245 u32_t maxconnect
; /* Maximum connect time (seconds) */
246 #endif /* PPP_MAXCONNECT */
250 const char *user
; /* Username for PAP */
251 const char *passwd
; /* Password for PAP, secret for CHAP */
253 char remote_name
[MAXNAMELEN
+ 1]; /* Peer's name for authentication */
254 #endif /* PPP_REMOTENAME */
257 u8_t pap_timeout_time
; /* Timeout (seconds) for auth-req retrans. */
258 u8_t pap_max_transmits
; /* Number of auth-reqs sent */
260 u8_t pap_req_timeout
; /* Time to wait for auth-req from peer */
261 #endif /* PPP_SERVER */
262 #endif /* PAP_SUPPPORT */
265 u8_t chap_timeout_time
; /* Timeout (seconds) for retransmitting req */
266 u8_t chap_max_transmits
; /* max # times to send challenge */
268 u8_t chap_rechallenge_time
; /* Time to wait for auth-req from peer */
269 #endif /* PPP_SERVER */
270 #endif /* CHAP_SUPPPORT */
273 u8_t eap_req_time
; /* Time to wait (for retransmit/fail) */
274 u8_t eap_allow_req
; /* Max Requests allowed */
276 u8_t eap_timeout_time
; /* Time to wait (for retransmit/fail) */
277 u8_t eap_max_transmits
; /* Max Requests allowed */
278 #endif /* PPP_SERVER */
279 #endif /* EAP_SUPPORT */
281 #endif /* PPP_AUTH_SUPPORT */
283 u8_t fsm_timeout_time
; /* Timeout time in seconds */
284 u8_t fsm_max_conf_req_transmits
; /* Maximum Configure-Request transmissions */
285 u8_t fsm_max_term_transmits
; /* Maximum Terminate-Request transmissions */
286 u8_t fsm_max_nak_loops
; /* Maximum number of nak loops tolerated */
288 u8_t lcp_loopbackfail
; /* Number of times we receive our magic number from the peer
289 before deciding the link is looped-back. */
290 u8_t lcp_echo_interval
; /* Interval between LCP echo-requests */
291 u8_t lcp_echo_fails
; /* Tolerance to unanswered echo-requests */
298 ip4_addr_t our_ipaddr
, his_ipaddr
, netmask
;
300 ip4_addr_t dns1
, dns2
;
301 #endif /* LWIP_DNS */
302 #endif /* PPP_IPV4_SUPPORT */
304 ip6_addr_t our6_ipaddr
, his6_ipaddr
;
305 #endif /* PPP_IPV6_SUPPORT */
307 #endif /* PPP_SERVER */
310 * PPP interface control block.
313 ppp_settings settings
;
314 const struct link_callbacks
*link_cb
;
316 void (*link_status_cb
)(ppp_pcb
*pcb
, int err_code
, void *ctx
); /* Status change callback */
318 void (*notify_phase_cb
)(ppp_pcb
*pcb
, u8_t phase
, void *ctx
); /* Notify phase callback */
319 #endif /* PPP_NOTIFY_PHASE */
320 void *ctx_cb
; /* Callbacks optional pointer */
321 struct netif
*netif
; /* PPP interface */
322 u8_t phase
; /* where the link is at */
323 u8_t err_code
; /* Code indicating why interface is down. */
327 unsigned int ask_for_local
:1; /* request our address from peer */
328 unsigned int ipcp_is_open
:1; /* haven't called np_finished() */
329 unsigned int ipcp_is_up
:1; /* have called ipcp_up() */
330 unsigned int if4_up
:1; /* True when the IPv4 interface is up. */
331 #if 0 /* UNUSED - PROXY ARP */
332 unsigned int proxy_arp_set
:1; /* Have created proxy arp entry */
333 #endif /* UNUSED - PROXY ARP */
334 #endif /* PPP_IPV4_SUPPORT */
336 unsigned int ipv6cp_is_up
:1; /* have called ip6cp_up() */
337 unsigned int if6_up
:1; /* True when the IPv6 interface is up. */
338 #endif /* PPP_IPV6_SUPPORT */
339 unsigned int lcp_echo_timer_running
:1; /* set if a timer is running */
341 unsigned int vj_enabled
:1; /* Flag indicating VJ compression enabled. */
342 #endif /* VJ_SUPPORT */
344 unsigned int ccp_all_rejected
:1; /* we rejected all peer's options */
345 #endif /* CCP_SUPPORT */
347 unsigned int mppe_keys_set
:1; /* Have the MPPE keys been set? */
348 #endif /* MPPE_SUPPORT */
352 #if PPP_SERVER && defined(HAVE_MULTILINK)
353 char peer_authname
[MAXNAMELEN
+ 1]; /* The name by which the peer authenticated itself to us. */
354 #endif /* PPP_SERVER && defined(HAVE_MULTILINK) */
355 u16_t auth_pending
; /* Records which authentication operations haven't completed yet. */
356 u16_t auth_done
; /* Records which authentication operations have been completed. */
359 upap_state upap
; /* PAP data */
360 #endif /* PAP_SUPPORT */
363 chap_client_state chap_client
; /* CHAP client data */
365 chap_server_state chap_server
; /* CHAP server data */
366 #endif /* PPP_SERVER */
367 #endif /* CHAP_SUPPORT */
370 eap_state eap
; /* EAP data */
371 #endif /* EAP_SUPPORT */
372 #endif /* PPP_AUTH_SUPPORT */
374 fsm lcp_fsm
; /* LCP fsm structure */
375 lcp_options lcp_wantoptions
; /* Options that we want to request */
376 lcp_options lcp_gotoptions
; /* Options that peer ack'd */
377 lcp_options lcp_allowoptions
; /* Options we allow peer to request */
378 lcp_options lcp_hisoptions
; /* Options that we ack'd */
379 u16_t peer_mru
; /* currently negotiated peer MRU */
380 u8_t lcp_echos_pending
; /* Number of outstanding echo msgs */
381 u8_t lcp_echo_number
; /* ID number of next echo frame */
383 u8_t num_np_open
; /* Number of network protocols which we have opened. */
384 u8_t num_np_up
; /* Number of network protocols which have come up. */
387 struct vjcompress vj_comp
; /* Van Jacobson compression header. */
388 #endif /* VJ_SUPPORT */
391 fsm ccp_fsm
; /* CCP fsm structure */
392 ccp_options ccp_wantoptions
; /* what to request the peer to use */
393 ccp_options ccp_gotoptions
; /* what the peer agreed to do */
394 ccp_options ccp_allowoptions
; /* what we'll agree to do */
395 ccp_options ccp_hisoptions
; /* what we agreed to do */
396 u8_t ccp_localstate
; /* Local state (mainly for handling reset-reqs and reset-acks). */
397 u8_t ccp_receive_method
; /* Method chosen on receive path */
398 u8_t ccp_transmit_method
; /* Method chosen on transmit path */
400 ppp_mppe_state mppe_comp
; /* MPPE "compressor" structure */
401 ppp_mppe_state mppe_decomp
; /* MPPE "decompressor" structure */
402 #endif /* MPPE_SUPPORT */
403 #endif /* CCP_SUPPORT */
406 fsm ipcp_fsm
; /* IPCP fsm structure */
407 ipcp_options ipcp_wantoptions
; /* Options that we want to request */
408 ipcp_options ipcp_gotoptions
; /* Options that peer ack'd */
409 ipcp_options ipcp_allowoptions
; /* Options we allow peer to request */
410 ipcp_options ipcp_hisoptions
; /* Options that we ack'd */
411 #endif /* PPP_IPV4_SUPPORT */
414 fsm ipv6cp_fsm
; /* IPV6CP fsm structure */
415 ipv6cp_options ipv6cp_wantoptions
; /* Options that we want to request */
416 ipv6cp_options ipv6cp_gotoptions
; /* Options that peer ack'd */
417 ipv6cp_options ipv6cp_allowoptions
; /* Options we allow peer to request */
418 ipv6cp_options ipv6cp_hisoptions
; /* Options that we ack'd */
419 #endif /* PPP_IPV6_SUPPORT */
422 /************************
423 *** PUBLIC FUNCTIONS ***
424 ************************/
427 * WARNING: For multi-threads environment, all ppp_set_* functions most
428 * only be called while the PPP is in the dead phase (i.e. disconnected).
433 * Set PPP authentication.
435 * Warning: Using PPPAUTHTYPE_ANY might have security consequences.
438 * In practice, within or associated with each PPP server, there is a
439 * database which associates "user" names with authentication
440 * information ("secrets"). It is not anticipated that a particular
441 * named user would be authenticated by multiple methods. This would
442 * make the user vulnerable to attacks which negotiate the least secure
443 * method from among a set (such as PAP rather than CHAP). If the same
444 * secret was used, PAP would reveal the secret to be used later with
447 * Instead, for each user name there should be an indication of exactly
448 * one method used to authenticate that user name. If a user needs to
449 * make use of different authentication methods under different
450 * circumstances, then distinct user names SHOULD be employed, each of
451 * which identifies exactly one authentication method.
453 * Default is none auth type, unset (NULL) user and passwd.
455 #define PPPAUTHTYPE_NONE 0x00
456 #define PPPAUTHTYPE_PAP 0x01
457 #define PPPAUTHTYPE_CHAP 0x02
458 #define PPPAUTHTYPE_MSCHAP 0x04
459 #define PPPAUTHTYPE_MSCHAP_V2 0x08
460 #define PPPAUTHTYPE_EAP 0x10
461 #define PPPAUTHTYPE_ANY 0xff
462 void ppp_set_auth(ppp_pcb
*pcb
, u8_t authtype
, const char *user
, const char *passwd
);
465 * If set, peer is required to authenticate. This is mostly necessary for PPP server support.
469 #define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval)
470 #endif /* PPP_AUTH_SUPPORT */
474 * Set PPP interface "our" and "his" IPv4 addresses. This is mostly necessary for PPP server
475 * support but it can also be used on a PPP link where each side choose its own IP address.
477 * Default is unset (0.0.0.0).
479 #define ppp_set_ipcp_ouraddr(ppp, addr) do { ppp->ipcp_wantoptions.ouraddr = ip4_addr_get_u32(addr); \
480 ppp->ask_for_local = ppp->ipcp_wantoptions.ouraddr != 0; } while(0)
481 #define ppp_set_ipcp_hisaddr(ppp, addr) (ppp->ipcp_wantoptions.hisaddr = ip4_addr_get_u32(addr))
484 * Set DNS server addresses that are sent if the peer asks for them. This is mostly necessary
485 * for PPP server support.
487 * Default is unset (0.0.0.0).
489 #define ppp_set_ipcp_dnsaddr(ppp, index, addr) (ppp->ipcp_allowoptions.dnsaddr[index] = ip4_addr_get_u32(addr))
492 * If set, we ask the peer for up to 2 DNS server addresses. Received DNS server addresses are
493 * registered using the dns_setserver() function.
497 #define ppp_set_usepeerdns(ppp, boolval) (ppp->settings.usepeerdns = boolval)
498 #endif /* LWIP_DNS */
499 #endif /* PPP_IPV4_SUPPORT */
502 /* Disable MPPE (Microsoft Point to Point Encryption). This parameter is exclusive. */
503 #define PPP_MPPE_DISABLE 0x00
504 /* Require the use of MPPE (Microsoft Point to Point Encryption). */
505 #define PPP_MPPE_ENABLE 0x01
506 /* Allow MPPE to use stateful mode. Stateless mode is still attempted first. */
507 #define PPP_MPPE_ALLOW_STATEFUL 0x02
508 /* Refuse the use of MPPE with 40-bit encryption. Conflict with PPP_MPPE_REFUSE_128. */
509 #define PPP_MPPE_REFUSE_40 0x04
510 /* Refuse the use of MPPE with 128-bit encryption. Conflict with PPP_MPPE_REFUSE_40. */
511 #define PPP_MPPE_REFUSE_128 0x08
513 * Set MPPE configuration
515 * Default is disabled.
517 void ppp_set_mppe(ppp_pcb
*pcb
, u8_t flags
);
518 #endif /* MPPE_SUPPORT */
521 * Wait for up to intval milliseconds for a valid PPP packet from the peer.
522 * At the end of this time, or when a valid PPP packet is received from the
523 * peer, we commence negotiation by sending our first LCP packet.
527 #define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval)
530 * If set, we will attempt to initiate a connection but if no reply is received from
531 * the peer, we will then just wait passively for a valid LCP packet from the peer.
535 #define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval)
538 * If set, we will not transmit LCP packets to initiate a connection until a valid
539 * LCP packet is received from the peer. This is what we usually call the server mode.
543 #define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval)
546 * If set, enable protocol field compression negotiation in both the receive and
547 * the transmit direction.
551 #define ppp_set_neg_pcomp(ppp, boolval) (ppp->lcp_wantoptions.neg_pcompression = \
552 ppp->lcp_allowoptions.neg_pcompression = boolval)
555 * If set, enable Address/Control compression in both the receive and the transmit
560 #define ppp_set_neg_accomp(ppp, boolval) (ppp->lcp_wantoptions.neg_accompression = \
561 ppp->lcp_allowoptions.neg_accompression = boolval)
564 * If set, enable asyncmap negotiation. Otherwise forcing all control characters to
565 * be escaped for both the transmit and the receive direction.
569 #define ppp_set_neg_asyncmap(ppp, boolval) (ppp->lcp_wantoptions.neg_asyncmap = \
570 ppp->lcp_allowoptions.neg_asyncmap = boolval)
573 * This option sets the Async-Control-Character-Map (ACCM) for this end of the link.
574 * The ACCM is a set of 32 bits, one for each of the ASCII control characters with
575 * values from 0 to 31, where a 1 bit indicates that the corresponding control
576 * character should not be used in PPP packets sent to this system. The map is
577 * an unsigned 32 bits integer where the least significant bit (00000001) represents
578 * character 0 and the most significant bit (80000000) represents character 31.
579 * We will then ask the peer to send these characters as a 2-byte escape sequence.
583 #define ppp_set_asyncmap(ppp, intval) (ppp->lcp_wantoptions.asyncmap = intval)
586 * Set a PPP interface as the default network interface
587 * (used to output all packets for which no specific route is found).
589 #define ppp_set_default(ppp) netif_set_default(ppp->netif)
593 * Set a PPP notify phase callback.
595 * This can be used for example to set a LED pattern depending on the
596 * current phase of the PPP session.
598 typedef void (*ppp_notify_phase_cb_fn
)(ppp_pcb
*pcb
, u8_t phase
, void *ctx
);
599 void ppp_set_notify_phase_callback(ppp_pcb
*pcb
, ppp_notify_phase_cb_fn notify_phase_cb
);
600 #endif /* PPP_NOTIFY_PHASE */
603 * Initiate a PPP connection.
605 * This can only be called if PPP is in the dead phase.
607 * Holdoff is the time to wait (in seconds) before initiating
610 * If this port connects to a modem, the modem connection must be
611 * established before calling this.
613 err_t
ppp_connect(ppp_pcb
*pcb
, u16_t holdoff
);
617 * Listen for an incoming PPP connection.
619 * This can only be called if PPP is in the dead phase.
621 * If this port connects to a modem, the modem connection must be
622 * established before calling this.
624 err_t
ppp_listen(ppp_pcb
*pcb
);
625 #endif /* PPP_SERVER */
628 * Initiate the end of a PPP connection.
629 * Any outstanding packets in the queues are dropped.
631 * Setting nocarrier to 1 close the PPP connection without initiating the
632 * shutdown procedure. Always using nocarrier = 0 is still recommended,
633 * this is going to take a little longer time if your link is down, but
634 * is a safer choice for the PPP state machine.
636 * Return 0 on success, an error code on failure.
638 err_t
ppp_close(ppp_pcb
*pcb
, u8_t nocarrier
);
641 * Release the control block.
643 * This can only be called if PPP is in the dead phase.
645 * You must use ppp_close() before if you wish to terminate
646 * an established PPP session.
648 * Return 0 on success, an error code on failure.
650 err_t
ppp_free(ppp_pcb
*pcb
);
653 * PPP IOCTL commands.
655 * Get the up status - 0 for down, non-zero for up. The argument must
658 #define PPPCTLG_UPSTATUS 0
661 * Get the PPP error code. The argument must point to an int.
662 * Returns a PPPERR_* value.
664 #define PPPCTLG_ERRCODE 1
667 * Get the fd associated with a PPP over serial
672 * Get and set parameters for the given connection.
673 * Return 0 on success, an error code on failure.
675 err_t
ppp_ioctl(ppp_pcb
*pcb
, u8_t cmd
, void *arg
);
677 /* Get the PPP netif interface */
678 #define ppp_netif(ppp) (ppp->netif)
680 /* Set an lwIP-style status-callback for the selected PPP device */
681 #define ppp_set_netif_statuscallback(ppp, status_cb) \
682 netif_set_status_callback(ppp->netif, status_cb);
684 /* Set an lwIP-style link-callback for the selected PPP device */
685 #define ppp_set_netif_linkcallback(ppp, link_cb) \
686 netif_set_link_callback(ppp->netif, link_cb);
690 #endif /* PPP_SUPPORT */