58#define PPP_REMOTENAME 0
61#ifndef PPP_IDLETIMELIMIT
62#define PPP_IDLETIMELIMIT 0
65#ifndef PPP_LCP_ADAPTIVE
66#define PPP_LCP_ADAPTIVE 0
70#define PPP_MAXCONNECT 0
73#ifndef PPP_ALLOWED_ADDRS
74#define PPP_ALLOWED_ADDRS 0
77#ifndef PPP_PROTOCOLNAME
78#define PPP_PROTOCOLNAME 0
81#ifndef PPP_STATS_SUPPORT
82#define PPP_STATS_SUPPORT 0
85#ifndef DEFLATE_SUPPORT
86#define DEFLATE_SUPPORT 0
89#ifndef BSDCOMPRESS_SUPPORT
90#define BSDCOMPRESS_SUPPORT 0
93#ifndef PREDICTOR_SUPPORT
94#define PREDICTOR_SUPPORT 0
110#define PPP_PHASE_DEAD 0
111#define PPP_PHASE_MASTER 1
112#define PPP_PHASE_HOLDOFF 2
113#define PPP_PHASE_INITIALIZE 3
114#define PPP_PHASE_SERIALCONN 4
115#define PPP_PHASE_DORMANT 5
116#define PPP_PHASE_ESTABLISH 6
117#define PPP_PHASE_AUTHENTICATE 7
118#define PPP_PHASE_CALLBACK 8
119#define PPP_PHASE_NETWORK 9
120#define PPP_PHASE_RUNNING 10
121#define PPP_PHASE_TERMINATE 11
122#define PPP_PHASE_DISCONNECT 12
126#define PPPERR_PARAM 1
128#define PPPERR_DEVICE 3
129#define PPPERR_ALLOC 4
131#define PPPERR_CONNECT 6
132#define PPPERR_AUTHFAIL 7
133#define PPPERR_PROTOCOL 8
134#define PPPERR_PEERDEAD 9
135#define PPPERR_IDLETIMEOUT 10
136#define PPPERR_CONNECTTIME 11
137#define PPPERR_LOOPBACK 12
140#define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT)
152typedef struct ppp_pcb_s ppp_pcb;
155#ifndef __u_char_defined
156typedef unsigned long u_long;
157typedef unsigned int u_int;
158typedef unsigned short u_short;
159typedef unsigned char u_char;
190typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb,
int err_code,
void *ctx);
195typedef struct ppp_settings_s {
197#if PPP_SERVER && PPP_AUTH_SUPPORT
198 unsigned int auth_required :1;
199 unsigned int null_login :1;
202 unsigned int explicit_remote :1;
205 unsigned int refuse_pap :1;
208 unsigned int refuse_chap :1;
211 unsigned int refuse_mschap :1;
212 unsigned int refuse_mschap_v2 :1;
215 unsigned int refuse_eap :1;
218 unsigned int usepeerdns :1;
220 unsigned int persist :1;
222 unsigned int hide_password :1;
224 unsigned int noremoteip :1;
225 unsigned int lax_recv :1;
226 unsigned int noendpoint :1;
228 unsigned int lcp_echo_adaptive :1;
231 unsigned int require_mppe :1;
232 unsigned int refuse_mppe_40 :1;
233 unsigned int refuse_mppe_128 :1;
234 unsigned int refuse_mppe_stateful :1;
240 u16_t idle_time_limit;
251 char remote_name[MAXNAMELEN + 1];
255 u8_t pap_timeout_time;
256 u8_t pap_max_transmits;
258 u8_t pap_req_timeout;
263 u8_t chap_timeout_time;
264 u8_t chap_max_transmits;
266 u8_t chap_rechallenge_time;
274 u8_t eap_timeout_time;
275 u8_t eap_max_transmits;
281 u8_t fsm_timeout_time;
282 u8_t fsm_max_conf_req_transmits;
283 u8_t fsm_max_term_transmits;
284 u8_t fsm_max_nak_loops;
286 u8_t lcp_loopbackfail;
288 u8_t lcp_echo_interval;
311 ppp_settings settings;
312 const struct link_callbacks *link_cb;
314 void (*link_status_cb)(ppp_pcb *pcb,
int err_code,
void *ctx);
316 void (*notify_phase_cb)(ppp_pcb *pcb, u8_t phase,
void *ctx);
325 unsigned int ask_for_local :1;
326 unsigned int ipcp_is_open :1;
327 unsigned int ipcp_is_up :1;
328 unsigned int if4_up :1;
330 unsigned int proxy_arp_set :1;
334 unsigned int ipv6cp_is_up :1;
335 unsigned int if6_up :1;
337#if PPP_IPV4_SUPPORT && PPP_IPV6_SUPPORT
338 unsigned int ipcp_disabled :1;
339 unsigned int ipv6cp_disabled :1;
341 unsigned int lcp_echo_timer_running :1;
343 unsigned int vj_enabled :1;
346 unsigned int ccp_all_rejected :1;
349 unsigned int mppe_keys_set :1;
354#if PPP_SERVER && defined(HAVE_MULTILINK)
355 char peer_authname[MAXNAMELEN + 1];
365 chap_client_state chap_client;
367 chap_server_state chap_server;
377 lcp_options lcp_wantoptions;
378 lcp_options lcp_gotoptions;
379 lcp_options lcp_allowoptions;
380 lcp_options lcp_hisoptions;
382 u8_t lcp_echos_pending;
383 u8_t lcp_echo_number;
389 struct vjcompress vj_comp;
394 ccp_options ccp_wantoptions;
395 ccp_options ccp_gotoptions;
396 ccp_options ccp_allowoptions;
397 ccp_options ccp_hisoptions;
399 u8_t ccp_receive_method;
400 u8_t ccp_transmit_method;
402 ppp_mppe_state mppe_comp;
403 ppp_mppe_state mppe_decomp;
409 ipcp_options ipcp_wantoptions;
410 ipcp_options ipcp_gotoptions;
411 ipcp_options ipcp_allowoptions;
412 ipcp_options ipcp_hisoptions;
417 ipv6cp_options ipv6cp_wantoptions;
418 ipv6cp_options ipv6cp_gotoptions;
419 ipv6cp_options ipv6cp_allowoptions;
420 ipv6cp_options ipv6cp_hisoptions;
457#define PPPAUTHTYPE_NONE 0x00
458#define PPPAUTHTYPE_PAP 0x01
459#define PPPAUTHTYPE_CHAP 0x02
460#define PPPAUTHTYPE_MSCHAP 0x04
461#define PPPAUTHTYPE_MSCHAP_V2 0x08
462#define PPPAUTHTYPE_EAP 0x10
463#define PPPAUTHTYPE_ANY 0xff
464void ppp_set_auth(ppp_pcb *pcb, u8_t authtype,
const char *user,
const char *passwd);
471#define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval)
481#define ppp_set_ipcp_ouraddr(ppp, addr) do { ppp->ipcp_wantoptions.ouraddr = ip4_addr_get_u32(addr); \
482 ppp->ask_for_local = ppp->ipcp_wantoptions.ouraddr != 0; } while(0)
483#define ppp_set_ipcp_hisaddr(ppp, addr) (ppp->ipcp_wantoptions.hisaddr = ip4_addr_get_u32(addr))
491#define ppp_set_ipcp_dnsaddr(ppp, index, addr) (ppp->ipcp_allowoptions.dnsaddr[index] = ip4_addr_get_u32(addr))
499#define ppp_set_usepeerdns(ppp, boolval) (ppp->settings.usepeerdns = boolval)
505#define PPP_MPPE_DISABLE 0x00
507#define PPP_MPPE_ENABLE 0x01
509#define PPP_MPPE_ALLOW_STATEFUL 0x02
511#define PPP_MPPE_REFUSE_40 0x04
513#define PPP_MPPE_REFUSE_128 0x08
519void ppp_set_mppe(ppp_pcb *pcb, u8_t flags);
529#define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval)
537#define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval)
545#define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval)
553#define ppp_set_neg_pcomp(ppp, boolval) (ppp->lcp_wantoptions.neg_pcompression = \
554 ppp->lcp_allowoptions.neg_pcompression = boolval)
562#define ppp_set_neg_accomp(ppp, boolval) (ppp->lcp_wantoptions.neg_accompression = \
563 ppp->lcp_allowoptions.neg_accompression = boolval)
571#define ppp_set_neg_asyncmap(ppp, boolval) (ppp->lcp_wantoptions.neg_asyncmap = \
572 ppp->lcp_allowoptions.neg_asyncmap = boolval)
585#define ppp_set_asyncmap(ppp, intval) (ppp->lcp_wantoptions.asyncmap = intval)
591#define ppp_set_default(ppp) netif_set_default(ppp->netif)
600typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase,
void *ctx);
601void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
615err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff);
626err_t ppp_listen(ppp_pcb *pcb);
640err_t ppp_close(ppp_pcb *pcb, u8_t nocarrier);
652err_t ppp_free(ppp_pcb *pcb);
660#define PPPCTLG_UPSTATUS 0
666#define PPPCTLG_ERRCODE 1
677err_t ppp_ioctl(ppp_pcb *pcb, u8_t cmd,
void *arg);
680#define ppp_netif(ppp) (ppp->netif)
683#define ppp_set_netif_statuscallback(ppp, status_cb) \
684 netif_set_status_callback(ppp->netif, status_cb);
687#define ppp_set_netif_linkcallback(ppp, link_cb) \
688 netif_set_link_callback(ppp->netif, link_cb);
IP address structure for passing IP addresses by value.