34 #include "netif/ppp/ppp_opts.h" 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 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 128 #define PPPERR_PARAM 1 129 #define PPPERR_OPEN 2 130 #define PPPERR_DEVICE 3 131 #define PPPERR_ALLOC 4 132 #define PPPERR_USER 5 133 #define PPPERR_CONNECT 6 134 #define PPPERR_AUTHFAIL 7 135 #define PPPERR_PROTOCOL 8 136 #define PPPERR_PEERDEAD 9 137 #define PPPERR_IDLETIMEOUT 10 138 #define PPPERR_CONNECTTIME 11 139 #define PPPERR_LOOPBACK 12 142 #define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT) 154 typedef struct ppp_pcb_s ppp_pcb;
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;
182 #include "chap-new.h" 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;
201 unsigned int null_login :1;
204 unsigned int explicit_remote :1;
207 unsigned int refuse_pap :1;
210 unsigned int refuse_chap :1;
213 unsigned int refuse_mschap :1;
214 unsigned int refuse_mschap_v2 :1;
217 unsigned int refuse_eap :1;
220 unsigned int usepeerdns :1;
222 unsigned int persist :1;
224 unsigned int hide_password :1;
226 unsigned int noremoteip :1;
227 unsigned int lax_recv :1;
228 unsigned int noendpoint :1;
230 unsigned int lcp_echo_adaptive :1;
233 unsigned int require_mppe :1;
234 unsigned int refuse_mppe_40 :1;
235 unsigned int refuse_mppe_128 :1;
236 unsigned int refuse_mppe_stateful :1;
241 #if PPP_IDLETIMELIMIT 242 u16_t idle_time_limit;
253 char remote_name[MAXNAMELEN + 1];
257 u8_t pap_timeout_time;
258 u8_t pap_max_transmits;
260 u8_t pap_req_timeout;
265 u8_t chap_timeout_time;
266 u8_t chap_max_transmits;
268 u8_t chap_rechallenge_time;
276 u8_t eap_timeout_time;
277 u8_t eap_max_transmits;
283 u8_t fsm_timeout_time;
284 u8_t fsm_max_conf_req_transmits;
285 u8_t fsm_max_term_transmits;
286 u8_t fsm_max_nak_loops;
288 u8_t lcp_loopbackfail;
290 u8_t lcp_echo_interval;
298 ip4_addr_t our_ipaddr, his_ipaddr, netmask;
300 ip4_addr_t dns1, dns2;
304 ip6_addr_t our6_ipaddr, his6_ipaddr;
313 ppp_settings settings;
314 const struct link_callbacks *link_cb;
316 void (*link_status_cb)(ppp_pcb *pcb,
int err_code,
void *ctx);
318 void (*notify_phase_cb)(ppp_pcb *pcb, u8_t phase,
void *ctx);
327 unsigned int ask_for_local :1;
328 unsigned int ipcp_is_open :1;
329 unsigned int ipcp_is_up :1;
330 unsigned int if4_up :1;
332 unsigned int proxy_arp_set :1;
336 unsigned int ipv6cp_is_up :1;
337 unsigned int if6_up :1;
339 unsigned int lcp_echo_timer_running :1;
341 unsigned int vj_enabled :1;
344 unsigned int ccp_all_rejected :1;
347 unsigned int mppe_keys_set :1;
352 #if PPP_SERVER && defined(HAVE_MULTILINK) 353 char peer_authname[MAXNAMELEN + 1];
363 chap_client_state chap_client;
365 chap_server_state chap_server;
375 lcp_options lcp_wantoptions;
376 lcp_options lcp_gotoptions;
377 lcp_options lcp_allowoptions;
378 lcp_options lcp_hisoptions;
380 u8_t lcp_echos_pending;
381 u8_t lcp_echo_number;
387 struct vjcompress vj_comp;
392 ccp_options ccp_wantoptions;
393 ccp_options ccp_gotoptions;
394 ccp_options ccp_allowoptions;
395 ccp_options ccp_hisoptions;
397 u8_t ccp_receive_method;
398 u8_t ccp_transmit_method;
400 ppp_mppe_state mppe_comp;
401 ppp_mppe_state mppe_decomp;
407 ipcp_options ipcp_wantoptions;
408 ipcp_options ipcp_gotoptions;
409 ipcp_options ipcp_allowoptions;
410 ipcp_options ipcp_hisoptions;
415 ipv6cp_options ipv6cp_wantoptions;
416 ipv6cp_options ipv6cp_gotoptions;
417 ipv6cp_options ipv6cp_allowoptions;
418 ipv6cp_options ipv6cp_hisoptions;
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);
469 #define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval) 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)) 489 #define ppp_set_ipcp_dnsaddr(ppp, index, addr) (ppp->ipcp_allowoptions.dnsaddr[index] = ip4_addr_get_u32(addr)) 497 #define ppp_set_usepeerdns(ppp, boolval) (ppp->settings.usepeerdns = boolval) 503 #define PPP_MPPE_DISABLE 0x00 505 #define PPP_MPPE_ENABLE 0x01 507 #define PPP_MPPE_ALLOW_STATEFUL 0x02 509 #define PPP_MPPE_REFUSE_40 0x04 511 #define PPP_MPPE_REFUSE_128 0x08 517 void ppp_set_mppe(ppp_pcb *pcb, u8_t flags);
527 #define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval) 535 #define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval) 543 #define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval) 551 #define ppp_set_neg_pcomp(ppp, boolval) (ppp->lcp_wantoptions.neg_pcompression = \ 552 ppp->lcp_allowoptions.neg_pcompression = boolval) 560 #define ppp_set_neg_accomp(ppp, boolval) (ppp->lcp_wantoptions.neg_accompression = \ 561 ppp->lcp_allowoptions.neg_accompression = boolval) 569 #define ppp_set_neg_asyncmap(ppp, boolval) (ppp->lcp_wantoptions.neg_asyncmap = \ 570 ppp->lcp_allowoptions.neg_asyncmap = boolval) 583 #define ppp_set_asyncmap(ppp, intval) (ppp->lcp_wantoptions.asyncmap = intval) 589 #define ppp_set_default(ppp) netif_set_default(ppp->netif) 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);
613 err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff);
624 err_t ppp_listen(ppp_pcb *pcb);
638 err_t ppp_close(ppp_pcb *pcb, u8_t nocarrier);
650 err_t ppp_free(ppp_pcb *pcb);
658 #define PPPCTLG_UPSTATUS 0 664 #define PPPCTLG_ERRCODE 1 675 err_t ppp_ioctl(ppp_pcb *pcb, u8_t
cmd,
void *arg);
678 #define ppp_netif(ppp) (ppp->netif) 681 #define ppp_set_netif_statuscallback(ppp, status_cb) \ 682 netif_set_status_callback(ppp->netif, status_cb); 685 #define ppp_set_netif_linkcallback(ppp, link_cb) \ 686 netif_set_link_callback(ppp->netif, link_cb);