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