Documentation

Documentation

Includes

netif/ppp/ppp_opts.h

#include "netif/ppp/ppp_opts.h"
#include "netif/ppp/ppp_opts.h"

lwip/def.h

#include "lwip/def.h"
#include "lwip/def.h"

lwip/stats.h

#include "lwip/stats.h"
#include "lwip/stats.h"

lwip/mem.h

#include "lwip/mem.h"
#include "lwip/mem.h"

lwip/netif.h

#include "lwip/netif.h"
#include "lwip/netif.h"

lwip/sys.h

#include "lwip/sys.h"
#include "lwip/sys.h"

lwip/timeouts.h

#include "lwip/timeouts.h"
#include "lwip/timeouts.h"

lwip/ip6_addr.h

#include "lwip/ip6_addr.h"
#include "lwip/ip6_addr.h"

fsm.h

#include "fsm.h"
#include "fsm.h"

lcp.h

#include "lcp.h"
#include "lcp.h"

ccp.h

#include "ccp.h"
#include "ccp.h"

mppe.h

#include "mppe.h"
#include "mppe.h"

ipcp.h

#include "ipcp.h"
#include "ipcp.h"

ipv6cp.h

#include "ipv6cp.h"
#include "ipv6cp.h"

upap.h

#include "upap.h"
#include "upap.h"

chap-new.h

#include "chap-new.h"
#include "chap-new.h"

eap.h

#include "eap.h"
#include "eap.h"

vj.h

#include "vj.h"
#include "vj.h"

Macros

Marco PPP_H

#define PPP_H


      

Marco PPP_OPTIONS

#define PPP_OPTIONS        0


      

Marco PPP_NOTIFY

#define PPP_NOTIFY         0


      

Marco PPP_REMOTENAME

#define PPP_REMOTENAME     0


      

Marco PPP_IDLETIMELIMIT

#define PPP_IDLETIMELIMIT  0


      

Marco PPP_LCP_ADAPTIVE

#define PPP_LCP_ADAPTIVE   0


      

Marco PPP_MAXCONNECT

#define PPP_MAXCONNECT     0


      

Marco PPP_ALLOWED_ADDRS

#define PPP_ALLOWED_ADDRS  0


      

Marco PPP_PROTOCOLNAME

#define PPP_PROTOCOLNAME   0


      

Marco PPP_STATS_SUPPORT

#define PPP_STATS_SUPPORT  0


      

Marco DEFLATE_SUPPORT

#define DEFLATE_SUPPORT    0


      

Marco BSDCOMPRESS_SUPPORT

#define BSDCOMPRESS_SUPPORT 0


      

Marco PREDICTOR_SUPPORT

#define PREDICTOR_SUPPORT  0


      

Marco PPP_HDRLEN

#define PPP_HDRLEN 4 /* octets for standard ppp header */
/*
 * The basic PPP frame.
 */

Marco PPP_FCSLEN

#define PPP_FCSLEN 2 /* octets for FCS */


      

Marco PPP_PHASE_DEAD

#define PPP_PHASE_DEAD         0
/*
 * Values for phase.
 */

Marco PPP_PHASE_MASTER

#define PPP_PHASE_MASTER       1


      

Marco PPP_PHASE_HOLDOFF

#define PPP_PHASE_HOLDOFF      2


      

Marco PPP_PHASE_INITIALIZE

#define PPP_PHASE_INITIALIZE   3


      

Marco PPP_PHASE_SERIALCONN

#define PPP_PHASE_SERIALCONN   4


      

Marco PPP_PHASE_DORMANT

#define PPP_PHASE_DORMANT      5


      

Marco PPP_PHASE_ESTABLISH

#define PPP_PHASE_ESTABLISH    6


      

Marco PPP_PHASE_AUTHENTICATE

#define PPP_PHASE_AUTHENTICATE 7


      

Marco PPP_PHASE_CALLBACK

#define PPP_PHASE_CALLBACK     8


      

Marco PPP_PHASE_NETWORK

#define PPP_PHASE_NETWORK      9


      

Marco PPP_PHASE_RUNNING

#define PPP_PHASE_RUNNING      10


      

Marco PPP_PHASE_TERMINATE

#define PPP_PHASE_TERMINATE    11


      

Marco PPP_PHASE_DISCONNECT

#define PPP_PHASE_DISCONNECT   12


      

Marco PPPERR_NONE

#define PPPERR_NONE        0 /* No error. */
/* Error codes. */

Marco PPPERR_PARAM

#define PPPERR_PARAM       1 /* Invalid parameter. */


      

Marco PPPERR_OPEN

#define PPPERR_OPEN        2 /* Unable to open PPP session. */


      

Marco PPPERR_DEVICE

#define PPPERR_DEVICE      3 /* Invalid I/O device for PPP. */


      

Marco PPPERR_ALLOC

#define PPPERR_ALLOC       4 /* Unable to allocate resources. */


      

Marco PPPERR_USER

#define PPPERR_USER        5 /* User interrupt. */


      

Marco PPPERR_CONNECT

#define PPPERR_CONNECT     6 /* Connection lost. */


      

Marco PPPERR_AUTHFAIL

#define PPPERR_AUTHFAIL    7 /* Failed authentication challenge. */


      

Marco PPPERR_PROTOCOL

#define PPPERR_PROTOCOL    8 /* Failed to meet protocol. */


      

Marco PPPERR_PEERDEAD

#define PPPERR_PEERDEAD    9 /* Connection timeout */


      

Marco PPPERR_IDLETIMEOUT

#define PPPERR_IDLETIMEOUT 10 /* Idle Timeout */


      

Marco PPPERR_CONNECTTIME

#define PPPERR_CONNECTTIME 11 /* Max connect time reached */


      

Marco PPPERR_LOOPBACK

#define PPPERR_LOOPBACK    12 /* Loopback detected */


      

Marco PPP_AUTH_SUPPORT

#define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT)
/* Whether auth support is enabled at all */

Marco PPPAUTHTYPE_NONE

#define PPPAUTHTYPE_NONE     0
/*
 * Set PPP authentication.
 *
 * Warning: Using PPPAUTHTYPE_ANY might have security consequences.
 * RFC 1994 says:
 *
 * In practice, within or associated with each PPP server, there is a
 * database which associates "user" names with authentication
 * information ("secrets").  It is not anticipated that a particular
 * named user would be authenticated by multiple methods.  This would
 * make the user vulnerable to attacks which negotiate the least secure
 * method from among a set (such as PAP rather than CHAP).  If the same
 * secret was used, PAP would reveal the secret to be used later with
 * CHAP.
 *
 * Instead, for each user name there should be an indication of exactly
 * one method used to authenticate that user name.  If a user needs to
 * make use of different authentication methods under different
 * circumstances, then distinct user names SHOULD be employed, each of
 * which identifies exactly one authentication method.
 *
 * Default is none auth type, unset (NULL) user and passwd.
 */

Marco PPPAUTHTYPE_PAP

#define PPPAUTHTYPE_PAP      1


      

Marco PPPAUTHTYPE_CHAP

#define PPPAUTHTYPE_CHAP     2


      

Marco PPPAUTHTYPE_MSCHAP

#define PPPAUTHTYPE_MSCHAP   4


      

Marco PPPAUTHTYPE_MSCHAP_V2

#define PPPAUTHTYPE_MSCHAP_V2 8


      

Marco PPPAUTHTYPE_EAP

#define PPPAUTHTYPE_EAP      16


      

Marco PPPAUTHTYPE_ANY

#define PPPAUTHTYPE_ANY      255


      

Marco ppp_set_auth_required(ppp, boolval)

#define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval)
/*
 * If set, peer is required to authenticate. This is mostly necessary for PPP server support.
 *
 * Default is false.
 */

Marco ppp_set_ipcp_ouraddr(ppp, addr)

#define ppp_set_ipcp_ouraddr(ppp, addr) do { ppp->ipcp_wantoptions.ouraddr = ip4_addr_get_u32(addr); \
                                            ppp->ask_for_local = ppp->ipcp_wantoptions.ouraddr != 0; } while(0)
/*
 * Set PPP interface "our" and "his" IPv4 addresses. This is mostly necessary for PPP server
 * support but it can also be used on a PPP link where each side choose its own IP address.
 *
 * Default is unset (0.0.0.0).
 */

Marco ppp_set_ipcp_hisaddr(ppp, addr)

#define ppp_set_ipcp_hisaddr(ppp, addr) (ppp->ipcp_wantoptions.hisaddr = ip4_addr_get_u32(addr))


      

Marco ppp_set_ipcp_dnsaddr(ppp, index, addr)

#define ppp_set_ipcp_dnsaddr(ppp, index, addr) (ppp->ipcp_allowoptions.dnsaddr[index] = ip4_addr_get_u32(addr))
/*
 * Set DNS server addresses that are sent if the peer asks for them. This is mostly necessary
 * for PPP server support.
 *
 * Default is unset (0.0.0.0).
 */

Marco ppp_set_usepeerdns(ppp, boolval)

#define ppp_set_usepeerdns(ppp, boolval) (ppp->settings.usepeerdns = boolval)
/*
 * If set, we ask the peer for up to 2 DNS server addresses. Received DNS server addresses are
 * registered using the dns_setserver() function.
 *
 * Default is false.
 */

Marco PPP_MPPE_DISABLE

#define PPP_MPPE_DISABLE          0
/* Disable MPPE (Microsoft Point to Point Encryption). This parameter is exclusive. */

Marco PPP_MPPE_ENABLE

#define PPP_MPPE_ENABLE           1
/* Require the use of MPPE (Microsoft Point to Point Encryption). */

Marco PPP_MPPE_ALLOW_STATEFUL

#define PPP_MPPE_ALLOW_STATEFUL   2
/* Allow MPPE to use stateful mode. Stateless mode is still attempted first. */

Marco PPP_MPPE_REFUSE_40

#define PPP_MPPE_REFUSE_40        4
/* Refuse the use of MPPE with 40-bit encryption. Conflict with PPP_MPPE_REFUSE_128. */

Marco PPP_MPPE_REFUSE_128

#define PPP_MPPE_REFUSE_128       8
/* Refuse the use of MPPE with 128-bit encryption. Conflict with PPP_MPPE_REFUSE_40. */

Marco ppp_set_listen_time(ppp, intval)

#define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval)
/*
 * Wait for up to intval milliseconds for a valid PPP packet from the peer.
 * At the end of this  time, or when a valid PPP packet is received from the
 * peer, we commence negotiation by sending our first LCP packet.
 *
 * Default is 0.
 */

Marco ppp_set_passive(ppp, boolval)

#define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval)
/*
 * If set, we will attempt to initiate a connection but if no reply is received from
 * the peer, we will then just wait passively for a valid LCP packet from the peer.
 *
 * Default is false.
 */

Marco ppp_set_silent(ppp, boolval)

#define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval)
/*
 * If set, we will not transmit LCP packets to initiate a connection until a valid
 * LCP packet is received from the peer. This is what we usually call the server mode.
 *
 * Default is false.
 */

Marco ppp_set_neg_pcomp(ppp, boolval)

#define ppp_set_neg_pcomp(ppp, boolval) (ppp->lcp_wantoptions.neg_pcompression = \
                                        ppp->lcp_allowoptions.neg_pcompression = boolval)
/*
 * If set, enable protocol field compression negotiation in both the receive and
 * the transmit direction.
 *
 * Default is true.
 */

Marco ppp_set_neg_accomp(ppp, boolval)

#define ppp_set_neg_accomp(ppp, boolval) (ppp->lcp_wantoptions.neg_accompression = \
                                         ppp->lcp_allowoptions.neg_accompression = boolval)
/*
 * If set, enable Address/Control compression in both the receive and the transmit
 * direction.
 *
 * Default is true.
 */

Marco ppp_set_neg_asyncmap(ppp, boolval)

#define ppp_set_neg_asyncmap(ppp, boolval) (ppp->lcp_wantoptions.neg_asyncmap = \
                                           ppp->lcp_allowoptions.neg_asyncmap = boolval)
/*
 * If set, enable asyncmap negotiation. Otherwise forcing all control characters to
 * be escaped for both the transmit and the receive direction.
 *
 * Default is true.
 */

Marco ppp_set_asyncmap(ppp, intval)

#define ppp_set_asyncmap(ppp, intval) (ppp->lcp_wantoptions.asyncmap = intval)
/*
 * This option sets the Async-Control-Character-Map (ACCM) for this end of the link.
 * The ACCM is a set of 32 bits, one for each of the ASCII control characters with
 * values from 0 to 31, where a 1 bit  indicates that the corresponding control
 * character should not be used in PPP packets sent to this system. The map is
 * an unsigned 32 bits integer where the least significant bit (00000001) represents
 * character 0 and the most significant bit (80000000) represents character 31.
 * We will then ask the peer to send these characters as a 2-byte escape sequence.
 *
 * Default is 0.
 */

Marco ppp_set_default(ppp)

#define ppp_set_default(ppp)        netif_set_default(ppp->netif)
/*
 * Set a PPP interface as the default network interface
 * (used to output all packets for which no specific route is found).
 */

Marco PPPCTLG_UPSTATUS

#define PPPCTLG_UPSTATUS 0
/*
 * PPP IOCTL commands.
 *
 * Get the up status - 0 for down, non-zero for up.  The argument must
 * point to an int.
 */

Marco PPPCTLG_ERRCODE

#define PPPCTLG_ERRCODE 1
/*
 * Get the PPP error code.  The argument must point to an int.
 * Returns a PPPERR_* value.
 */

Marco PPPCTLG_FD

#define PPPCTLG_FD      2
/*
 * Get the fd associated with a PPP over serial
 */

Marco ppp_netif(ppp)

#define ppp_netif(ppp)              (ppp->netif)
/* Get the PPP netif interface */

Marco ppp_set_netif_statuscallback(ppp, status_cb)

#define ppp_set_netif_statuscallback(ppp, status_cb)      \
       netif_set_status_callback(ppp->netif, status_cb);
/* Set an lwIP-style status-callback for the selected PPP device */
#define ppp_set_netif_linkcallback(ppp, link_cb)          \
       netif_set_link_callback(ppp->netif, link_cb);
/* Set an lwIP-style link-callback for the selected PPP device */

Functions

Func ppp_set_auth

void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);


      

Func ppp_set_mppe

void ppp_set_mppe(ppp_pcb *pcb, u8_t flags);
/*
 * Set MPPE configuration
 *
 * Default is disabled.
 */

Func ppp_set_notify_phase_callback

void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);


      

Func ppp_connect

err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff);
/*
 * Initiate a PPP connection.
 *
 * This can only be called if PPP is in the dead phase.
 *
 * Holdoff is the time to wait (in seconds) before initiating
 * the connection.
 *
 * If this port connects to a modem, the modem connection must be
 * established before calling this.
 */

Func ppp_listen

err_t ppp_listen(ppp_pcb *pcb);
/*
 * Listen for an incoming PPP connection.
 *
 * This can only be called if PPP is in the dead phase.
 *
 * If this port connects to a modem, the modem connection must be
 * established before calling this.
 */

Func ppp_close

err_t ppp_close(ppp_pcb *pcb, u8_t nocarrier);
/*
 * Initiate the end of a PPP connection.
 * Any outstanding packets in the queues are dropped.
 *
 * Setting nocarrier to 1 close the PPP connection without initiating the
 * shutdown procedure. Always using nocarrier = 0 is still recommended,
 * this is going to take a little longer time if your link is down, but
 * is a safer choice for the PPP state machine.
 *
 * Return 0 on success, an error code on failure.
 */

Func ppp_free

err_t ppp_free(ppp_pcb *pcb);
/*
 * Release the control block.
 *
 * This can only be called if PPP is in the dead phase.
 *
 * You must use ppp_close() before if you wish to terminate
 * an established PPP session.
 *
 * Return 0 on success, an error code on failure.
 */

Func ppp_ioctl

err_t ppp_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg);
/*
 * Get and set parameters for the given connection.
 * Return 0 on success, an error code on failure.
 */

Vars

Consts

Types

Typedefs

Typedef ppp_pcb

typedef struct ppp_pcb_s ppp_pcb;
/*
 * Other headers require ppp_pcb definition for prototypes, but ppp_pcb
 * require some structure definition from other headers as well, we are
 * fixing the dependency loop here by declaring the ppp_pcb type then
 * by including headers containing necessary struct definition for ppp_pcb
 */

Typedef u_long

typedef unsigned long u_long;


      

Typedef u_int

typedef unsigned int  u_int;


      

Typedef u_short

typedef unsigned short u_short;


      

Typedef u_char

typedef unsigned char u_char;


      
      
typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx);
/* Link status callback function prototype */

Typedef ppp_settings;

typedef struct ppp_settings_s {

#if PPP_SERVER && PPP_AUTH_SUPPORT
 unsigned int auth_required      :1;     /* Peer is required to authenticate */
 unsigned int null_login         :1;     /* Username of "" and a password of "" are acceptable */
#endif /* PPP_SERVER && PPP_AUTH_SUPPORT */
#if PPP_REMOTENAME
 unsigned int explicit_remote    :1;     /* remote_name specified with remotename opt */
#endif /* PPP_REMOTENAME */
#if PAP_SUPPORT
 unsigned int refuse_pap         :1;     /* Don't proceed auth. with PAP */
#endif /* PAP_SUPPORT */
#if CHAP_SUPPORT
 unsigned int refuse_chap        :1;     /* Don't proceed auth. with CHAP */
#endif /* CHAP_SUPPORT */
#if MSCHAP_SUPPORT
 unsigned int refuse_mschap      :1;     /* Don't proceed auth. with MS-CHAP */
 unsigned int refuse_mschap_v2   :1;     /* Don't proceed auth. with MS-CHAPv2 */
#endif /* MSCHAP_SUPPORT */
#if EAP_SUPPORT
 unsigned int refuse_eap         :1;     /* Don't proceed auth. with EAP */
#endif /* EAP_SUPPORT */
#if LWIP_DNS
 unsigned int usepeerdns         :1;     /* Ask peer for DNS adds */
#endif /* LWIP_DNS */
 unsigned int persist            :1;     /* Persist mode, always try to open the connection */
#if PRINTPKT_SUPPORT
 unsigned int hide_password      :1;     /* Hide password in dumped packets */
#endif /* PRINTPKT_SUPPORT */
 unsigned int noremoteip         :1;     /* Let him have no IP address */
 unsigned int lax_recv           :1;     /* accept control chars in asyncmap */
 unsigned int noendpoint         :1;     /* don't send/accept endpoint discriminator */
#if PPP_LCP_ADAPTIVE
 unsigned int lcp_echo_adaptive   :1;     /* request echo only if the link was idle */
#endif /* PPP_LCP_ADAPTIVE */
#if MPPE_SUPPORT
 unsigned int require_mppe        :1;     /* Require MPPE (Microsoft Point to Point Encryption) */
 unsigned int refuse_mppe_40      :1;     /* Allow MPPE 40-bit mode? */
 unsigned int refuse_mppe_128     :1;     /* Allow MPPE 128-bit mode? */
 unsigned int refuse_mppe_stateful :1;     /* Allow MPPE stateful mode? */
#endif /* MPPE_SUPPORT */

 u16_t listen_time;                /* time to listen first (ms), waiting for peer to send LCP packet */

#if PPP_IDLETIMELIMIT
 u16_t idle_time_limit;            /* Disconnect if idle for this many seconds */
#endif /* PPP_IDLETIMELIMIT */
#if PPP_MAXCONNECT
 u32_t maxconnect;                 /* Maximum connect time (seconds) */
#endif /* PPP_MAXCONNECT */

#if PPP_AUTH_SUPPORT
 /* auth data */
 const char *user;                  /* Username for PAP */
 const char *passwd;                /* Password for PAP, secret for CHAP */
#if PPP_REMOTENAME
 char remote_name[MAXNAMELEN  + 1]; /* Peer's name for authentication */
#endif /* PPP_REMOTENAME */

#if PAP_SUPPORT
 u8_t pap_timeout_time;       /* Timeout (seconds) for auth-req retrans. */
 u8_t pap_max_transmits;      /* Number of auth-reqs sent */
#if PPP_SERVER
 u8_t pap_req_timeout;        /* Time to wait for auth-req from peer */
#endif /* PPP_SERVER */
#endif /* PAP_SUPPPORT */

#if CHAP_SUPPORT
 u8_t chap_timeout_time;      /* Timeout (seconds) for retransmitting req */
 u8_t chap_max_transmits;     /* max # times to send challenge */
#if PPP_SERVER
 u8_t chap_rechallenge_time;  /* Time to wait for auth-req from peer */
#endif /* PPP_SERVER */
#endif /* CHAP_SUPPPORT */

#if EAP_SUPPORT
 u8_t eap_req_time;           /* Time to wait (for retransmit/fail) */
 u8_t eap_allow_req;          /* Max Requests allowed */
#if PPP_SERVER
 u8_t eap_timeout_time;       /* Time to wait (for retransmit/fail) */
 u8_t eap_max_transmits;      /* Max Requests allowed */
#endif /* PPP_SERVER */
#endif /* EAP_SUPPORT */

#endif /* PPP_AUTH_SUPPORT */

 u8_t fsm_timeout_time;           /* Timeout time in seconds */
 u8_t fsm_max_conf_req_transmits; /* Maximum Configure-Request transmissions */
 u8_t fsm_max_term_transmits;     /* Maximum Terminate-Request transmissions */
 u8_t fsm_max_nak_loops;          /* Maximum number of nak loops tolerated */

 u8_t lcp_loopbackfail;    /* Number of times we receive our magic number from the peer
                                 before deciding the link is looped-back. */
 u8_t lcp_echo_interval;   /* Interval between LCP echo-requests */
 u8_t lcp_echo_fails;      /* Tolerance to unanswered echo-requests */

} ppp_settings;
/*
 * PPP configuration.
 */

Typedef ppp_notify_phase_cb_fn

typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx);
/*
 * Set a PPP notify phase callback.
 *
 * This can be used for example to set a LED pattern depending on the
 * current phase of the PPP session.
 */