mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-20 07:06:53 +08:00
Merge branch 'ppp-new'
Based from pppd 2.4.5, released 2009-11-17, with huge changes to match code size and memory requirements for embedded devices, including: - Gluing together the previous low-level PPP code in lwIP to pppd 2.4.5, which is more or less what pppd sys-* files are, so that we get something working using the unix port. - Merged some patchs from lwIP Git repository which add interesting features or fix bugs. - Merged some patchs from Debian pppd package which add interesting features or fix bugs. - Ported PPP timeout handling to the lwIP timers system - Disabled all the PPP code using filesystem access, replaced in necessary cases to configuration variables. - Disabled all the PPP code forking processes. - Removed IPX support, lwIP does not support IPX. - Ported and improved random module from the previous PPP port. - Removed samba TDB (file-driven database) usage, because it needs a filesystem. - MS-CHAP required a DES implementation, we added the latest PolarSSL DES implementation which is under a BSD-ish license. - Also switched to PolarSSL MD4,MD5,SHA1 implementations, which are meant to be used in embedded devices with reduced memory footprint. - Removed PPP configuration file parsing support. - Added macro definition EAP_SUPPORT to make EAP support optional. - Added macro definition CHAP_SUPPORT to make CHAP support optional. - Added macro definition MSCHAP_SUPPORT to make MSCHAP support optional. - Added macro definition PAP_SUPPORT to make PAP support optional. - Cleared all Linux syscall calls. - Disabled demand support using a macro, so that it can be ported later. - Disabled ECP support using a macro, so that it can be ported later. - Disabled CCP support using a macro, so that it can be ported later. - Disabled CBCP support using a macro, so that it can be ported later. - Disabled LQR support using a macro, so that it can be ported later. - Print packet debug feature optional, through PRINTPKT_SUPPORT - Removed POSIX signal usage. - Fully ported PPPoS code from the previous port. - Fully ported PPPoE code from the previous port. - Fully ported VJ compression protocol code from the previous port. - Removed all malloc()/free() use from PPP, replaced by stack usage or PBUF. - Disabled PPP server support using a macro, so that it can be ported later. - Switched all PPP debug to lwIP debug system. - Created PPP Control Block (PPP PCB), removed PPP unit integer everywhere, removed all global variables everywhere, did everything necessary for the PPP stack to support more than one PPP session (pppd only support one session per process). - Removed the statically allocated output buffer, now using PBUF. - Improved structure size of all PPP modules, deep analyze of code to reduce variables size to the bare minimum. Switched all boolean type (char type in most architecture) to compiler generated bitfields. - Added PPP IPv6 support, glued lwIP IPv6 support to PPP. - Now using a persistent netif interface which can then be used in lwIP functions requiring a netif. - Now initializing PPP in lwip_init() function. - Reworked completely the PPP state machine, so that we don't end up in anymore in inconsistent state, especially with PPPoE. - Improved the way we handle PPP reconnection after disconnect, cleaning everything required so that we start the PPP connection again from a clean state. - Added PPP holdoff support, allow the lwIP user to wait a little bit before reconnecting, prevents connection flood, especially when using PPPoL2TP. - Added PPPoL2TP LAC support (a.k.a. UDP tunnels), adding a VPN client feature to lwIP, L2TP being a widely used tunnel protocol. - Switched all used PPP types to lwIP types (u8t, u16t, u32t, ...) - Added PPP API "sequential" thread-safe API, based from NETIFAPI.
This commit is contained in:
@@ -99,9 +99,16 @@ LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE,
|
||||
#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST")
|
||||
#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
#if PPP_SUPPORT && PPPOE_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
|
||||
#endif /* PPP_SUPPORT && PPPOE_SUPPORT */
|
||||
|
||||
#if PPP_SUPPORT
|
||||
LWIP_MEMPOOL(PPP_PCB, MEMP_NUM_PPP_PCB, sizeof(ppp_pcb), "PPP_PCB")
|
||||
#if PPPOE_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOL2TP_PCB, MEMP_NUM_PPPOL2TP_INTERFACES, sizeof(pppol2tp_pcb), "PPPOL2TP_PCB")
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
||||
#if LWIP_IPV6 && LWIP_ND6_QUEUEING
|
||||
LWIP_MEMPOOL(ND6_QUEUE, MEMP_NUM_ND6_QUEUE, sizeof(struct nd6_q_entry), "ND6_QUEUE")
|
||||
|
||||
@@ -323,7 +323,7 @@
|
||||
* The formula expects settings to be either '0' or '1'.
|
||||
*/
|
||||
#ifndef MEMP_NUM_SYS_TIMEOUT
|
||||
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0))
|
||||
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0))
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -409,6 +409,14 @@
|
||||
#define MEMP_NUM_LOCALHOSTLIST 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_PPP_PCB: the number of simultaneously active PPP
|
||||
* connections (requires the PPP_SUPPORT option)
|
||||
*/
|
||||
#ifndef MEMP_NUM_PPP_PCB
|
||||
#define MEMP_NUM_PPP_PCB 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
|
||||
* interfaces (only used with PPPOE_SUPPORT==1)
|
||||
@@ -417,6 +425,14 @@
|
||||
#define MEMP_NUM_PPPOE_INTERFACES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_PPPOL2TP_INTERFACES: the number of concurrently active PPPoL2TP
|
||||
* interfaces (only used with PPPOL2TP_SUPPORT==1)
|
||||
*/
|
||||
#ifndef MEMP_NUM_PPPOL2TP_INTERFACES
|
||||
#define MEMP_NUM_PPPOL2TP_INTERFACES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
|
||||
*/
|
||||
@@ -1360,31 +1376,6 @@
|
||||
#define SLIPIF_THREAD_PRIO 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_THREAD_NAME: The name assigned to the pppInputThread.
|
||||
*/
|
||||
#ifndef PPP_THREAD_NAME
|
||||
#define PPP_THREAD_NAME "pppInputThread"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_THREAD_STACKSIZE: The stack size used by the pppInputThread.
|
||||
* The stack size value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#ifndef PPP_THREAD_STACKSIZE
|
||||
#define PPP_THREAD_STACKSIZE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_THREAD_PRIO: The priority assigned to the pppInputThread.
|
||||
* The priority value itself is platform-dependent, but is passed to
|
||||
* sys_thread_new() when the thread is created.
|
||||
*/
|
||||
#ifndef PPP_THREAD_PRIO
|
||||
#define PPP_THREAD_PRIO 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread.
|
||||
*/
|
||||
@@ -1761,6 +1752,20 @@
|
||||
#define PPPOE_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPPOL2TP_SUPPORT==1: Enable PPP Over L2TP
|
||||
*/
|
||||
#ifndef PPPOL2TP_SUPPORT
|
||||
#define PPPOL2TP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPPOL2TP_AUTH_SUPPORT==1: Enable PPP Over L2TP Auth (enable MD5 support)
|
||||
*/
|
||||
#ifndef PPPOL2TP_AUTH_SUPPORT
|
||||
#define PPPOL2TP_AUTH_SUPPORT PPPOL2TP_SUPPORT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPPOS_SUPPORT==1: Enable PPP Over Serial
|
||||
*/
|
||||
@@ -1771,10 +1776,40 @@
|
||||
#if PPP_SUPPORT
|
||||
|
||||
/**
|
||||
* NUM_PPP: Max PPP sessions.
|
||||
* PPP_INPROC_MULTITHREADED==1 call ppp_input() using tcpip_callback().
|
||||
* Set this to 0 if pppos_input() is called inside tcpip_thread or with NO_SYS==1.
|
||||
* Default is 1 for NO_SYS==0 (multithreaded) and 0 for NO_SYS==1 (single-threaded).
|
||||
*/
|
||||
#ifndef NUM_PPP
|
||||
#define NUM_PPP 1
|
||||
#ifndef PPP_INPROC_MULTITHREADED
|
||||
#define PPP_INPROC_MULTITHREADED (NO_SYS==0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_PPP_API==1: Support PPP API (in pppapi.c)
|
||||
*/
|
||||
#ifndef LWIP_PPP_API
|
||||
#define LWIP_PPP_API 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* pbuf_type PPP is using for LCP, PAP, CHAP, EAP, IPCP and IP6CP packets.
|
||||
*
|
||||
* Memory allocated must be single buffered for PPP to works, it requires pbuf
|
||||
* that are not going to be chained when allocated. This requires setting
|
||||
* PBUF_POOL_BUFSIZE to at least 512 bytes, which is quite huge for small systems.
|
||||
*
|
||||
* Setting PPP_USE_PBUF_RAM to 1 makes PPP use memory from heap where continuous
|
||||
* buffers are required, allowing you to use a smaller PBUF_POOL_BUFSIZE.
|
||||
*/
|
||||
#ifndef PPP_USE_PBUF_RAM
|
||||
#define PPP_USE_PBUF_RAM 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation
|
||||
*/
|
||||
#ifndef PPP_FCS_TABLE
|
||||
#define PPP_FCS_TABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -1792,11 +1827,15 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MSCHAP_SUPPORT==1: Support MSCHAP. CURRENTLY NOT SUPPORTED! DO NOT SET!
|
||||
* MSCHAP_SUPPORT==1: Support MSCHAP.
|
||||
*/
|
||||
#ifndef MSCHAP_SUPPORT
|
||||
#define MSCHAP_SUPPORT 0
|
||||
#endif
|
||||
#if MSCHAP_SUPPORT
|
||||
#undef CHAP_SUPPORT
|
||||
#define CHAP_SUPPORT 1 /* MSCHAP require CHAP support */
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/**
|
||||
* CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
|
||||
@@ -1813,19 +1852,92 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* VJ_SUPPORT==1: Support VJ header compression.
|
||||
* ECP_SUPPORT==1: Support ECP. CURRENTLY NOT SUPPORTED! DO NOT SET!
|
||||
*/
|
||||
#ifndef VJ_SUPPORT
|
||||
#define VJ_SUPPORT 0
|
||||
#ifndef ECP_SUPPORT
|
||||
#define ECP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MD5_SUPPORT==1: Support MD5 (see also CHAP).
|
||||
* LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets.
|
||||
*/
|
||||
#ifndef MD5_SUPPORT
|
||||
#define MD5_SUPPORT 0
|
||||
#ifndef LQR_SUPPORT
|
||||
#define LQR_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* VJ_SUPPORT==1: Support VJ header compression.
|
||||
*/
|
||||
#ifndef VJ_SUPPORT
|
||||
#define VJ_SUPPORT 1
|
||||
#endif
|
||||
#if !PPPOS_SUPPORT
|
||||
#undef VJ_SUPPORT
|
||||
#define VJ_SUPPORT 0 /* Only PPPoS may need VJ compression */
|
||||
#endif /* !PPPOS_SUPPORT */
|
||||
|
||||
/**
|
||||
* PPP_MD5_RANDM==1: Use MD5 for better randomness. Automatically enabled if CHAP or L2TP AUTH support is enabled.
|
||||
*/
|
||||
#ifndef PPP_MD5_RANDM
|
||||
#define PPP_MD5_RANDM 0
|
||||
#endif
|
||||
#if CHAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT
|
||||
#undef PPP_MD5_RANDM
|
||||
#define PPP_MD5_RANDM 1 /* MD5 Random is required for CHAP and L2TP AUTH */
|
||||
#endif /* CHAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT */
|
||||
|
||||
/**
|
||||
* PolarSSL library, used if necessary and not previously disabled
|
||||
*
|
||||
*
|
||||
* lwIP contains some files fetched from the latest BSD release of
|
||||
* the PolarSSL project for ciphers and encryption methods we need for lwIP
|
||||
* PPP support.
|
||||
*
|
||||
* The PolarSSL files were cleaned to contain only the necessary struct
|
||||
* fields and functions needed for lwIP.
|
||||
*
|
||||
* The PolarSSL API was not changed at all, so if you are already using
|
||||
* PolarSSL you can choose to skip the compilation of the included PolarSSL
|
||||
* library into lwIP:
|
||||
*
|
||||
* The following defines are available for flexibility:
|
||||
*
|
||||
* LWIP_INCLUDED_POLARSSL_MD4 ; Use lwIP internal PolarSSL for MD4
|
||||
* LWIP_INCLUDED_POLARSSL_MD5 ; Use lwIP internal PolarSSL for MD5
|
||||
* LWIP_INCLUDED_POLARSSL_SHA1 ; Use lwIP internal PolarSSL for SHA1
|
||||
* LWIP_INCLUDED_POLARSSL_DES ; Use lwIP internal PolarSSL for DES
|
||||
*
|
||||
* If set (=1), the default if required by another enabled PPP feature unless
|
||||
* explicitly set to 0, using included lwIP PolarSSL.
|
||||
*
|
||||
* If clear (=0), using external PolarSSL.
|
||||
*
|
||||
* Undefined if not needed.
|
||||
*
|
||||
* Beware of the stack requirements which can be a lot larger if you are not
|
||||
* using our cleaned PolarSSL library.
|
||||
*/
|
||||
|
||||
#if CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_MD5
|
||||
#define LWIP_INCLUDED_POLARSSL_MD5 1 /* CHAP, EAP, L2TP AUTH and MD5 Random require MD5 support */
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD5 */
|
||||
#endif /* CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM */
|
||||
|
||||
#if MSCHAP_SUPPORT
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_MD4
|
||||
#define LWIP_INCLUDED_POLARSSL_MD4 1 /* MSCHAP require MD4 support */
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD4 */
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_SHA1
|
||||
#define LWIP_INCLUDED_POLARSSL_SHA1 1 /* MSCHAP require SHA1 support */
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_DES
|
||||
#define LWIP_INCLUDED_POLARSSL_DES 1 /* MSCHAP require DES support */
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_DES */
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* Timeouts
|
||||
*/
|
||||
@@ -1849,18 +1961,54 @@
|
||||
#define UPAP_DEFTIMEOUT 6 /* Timeout (seconds) for retransmitting req */
|
||||
#endif
|
||||
|
||||
#ifndef UPAP_DEFTRANSMITS
|
||||
#define UPAP_DEFTRANSMITS 10 /* Maximum number of auth-reqs to send */
|
||||
#endif
|
||||
|
||||
#if PPP_SERVER
|
||||
#ifndef UPAP_DEFREQTIME
|
||||
#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */
|
||||
#endif
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
#ifndef CHAP_DEFTIMEOUT
|
||||
#define CHAP_DEFTIMEOUT 6 /* Timeout time in seconds */
|
||||
#define CHAP_DEFTIMEOUT 6 /* Timeout (seconds) for retransmitting req */
|
||||
#endif
|
||||
|
||||
#ifndef CHAP_DEFTRANSMITS
|
||||
#define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */
|
||||
#endif
|
||||
|
||||
#if PPP_SERVER
|
||||
#ifndef CHAP_DEFREQTIME
|
||||
#define CHAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */
|
||||
#endif
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
#ifndef EAP_DEFREQTIME
|
||||
#define EAP_DEFREQTIME 6 /* Time to wait for peer request */
|
||||
#endif
|
||||
|
||||
#ifndef EAP_DEFALLOWREQ
|
||||
#define EAP_DEFALLOWREQ 10 /* max # times to accept requests */
|
||||
#endif
|
||||
|
||||
#if PPP_SERVER
|
||||
#ifndef EAP_DEFTIMEOUT
|
||||
#define EAP_DEFTIMEOUT 6 /* Timeout (seconds) for rexmit */
|
||||
#endif
|
||||
|
||||
#ifndef EAP_DEFTRANSMITS
|
||||
#define EAP_DEFTRANSMITS 10 /* max # times to transmit */
|
||||
#endif
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/* Default number of times we receive our magic number from the peer
|
||||
before deciding the link is looped-back. */
|
||||
#ifndef LCP_DEFLOOPBACKFAIL
|
||||
#define LCP_DEFLOOPBACKFAIL 10
|
||||
#endif
|
||||
|
||||
/* Interval in seconds between keepalive echo requests, 0 to disable. */
|
||||
#ifndef LCP_ECHOINTERVAL
|
||||
#define LCP_ECHOINTERVAL 0
|
||||
|
||||
151
src/include/lwip/pppapi.h
Normal file
151
src/include/lwip/pppapi.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LWIP_PPPAPI_H__
|
||||
#define __LWIP_PPPAPI_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_PPP_API /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "netif/ppp/ppp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct pppapi_msg_msg {
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
sys_sem_t sem;
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
int err;
|
||||
ppp_pcb *ppp;
|
||||
union {
|
||||
struct {
|
||||
u8_t authtype;
|
||||
char *user;
|
||||
char *passwd;
|
||||
} setauth;
|
||||
#if PPP_NOTIFY_PHASE
|
||||
struct {
|
||||
ppp_notify_phase_cb_fn notify_phase_cb;
|
||||
} setnotifyphasecb;
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
#if PPPOS_SUPPORT
|
||||
struct {
|
||||
sio_fd_t fd;
|
||||
ppp_link_status_cb_fn link_status_cb;
|
||||
void *ctx_cb;
|
||||
} serialcreate;
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
#if PPPOE_SUPPORT
|
||||
struct {
|
||||
struct netif *ethif;
|
||||
const char *service_name;
|
||||
const char *concentrator_name;
|
||||
ppp_link_status_cb_fn link_status_cb;
|
||||
void *ctx_cb;
|
||||
} ethernetcreate;
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
struct {
|
||||
struct netif *netif;
|
||||
ip_addr_t *ipaddr;
|
||||
u16_t port;
|
||||
#if PPPOL2TP_AUTH_SUPPORT
|
||||
u8_t *secret;
|
||||
u8_t secret_len;
|
||||
#endif /* PPPOL2TP_AUTH_SUPPORT */
|
||||
ppp_link_status_cb_fn link_status_cb;
|
||||
void *ctx_cb;
|
||||
} l2tpcreate;
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
struct {
|
||||
u16_t holdoff;
|
||||
} open;
|
||||
struct {
|
||||
int cmd;
|
||||
void *arg;
|
||||
} ioctl;
|
||||
#if LWIP_NETIF_STATUS_CALLBACK
|
||||
struct {
|
||||
netif_status_callback_fn status_callback;
|
||||
} netifstatuscallback;
|
||||
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||
#if LWIP_NETIF_LINK_CALLBACK
|
||||
struct {
|
||||
netif_status_callback_fn link_callback;
|
||||
} netiflinkcallback;
|
||||
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||
} msg;
|
||||
};
|
||||
|
||||
struct pppapi_msg {
|
||||
void (* function)(struct pppapi_msg_msg *msg);
|
||||
struct pppapi_msg_msg msg;
|
||||
};
|
||||
|
||||
/* API for application */
|
||||
ppp_pcb *pppapi_new(void);
|
||||
void pppapi_set_default(ppp_pcb *pcb);
|
||||
void pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd);
|
||||
#if PPP_NOTIFY_PHASE
|
||||
void pppapi_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
#if PPPOS_SUPPORT
|
||||
int pppapi_over_serial_create(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
#if PPPOE_SUPPORT
|
||||
int pppapi_over_ethernet_create(ppp_pcb *pcb, struct netif *ethif, const char *service_name,
|
||||
const char *concentrator_name, ppp_link_status_cb_fn link_status_cb,
|
||||
void *ctx_cb);
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
int pppapi_over_l2tp_create(ppp_pcb *pcb, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
|
||||
u8_t *secret, u8_t secret_len,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
int pppapi_open(ppp_pcb *pcb, u16_t holdoff);
|
||||
int pppapi_close(ppp_pcb *pcb);
|
||||
void pppapi_sighup(ppp_pcb *pcb);
|
||||
int pppapi_delete(ppp_pcb *pcb);
|
||||
int pppapi_ioctl(ppp_pcb *pcb, int cmd, void *arg);
|
||||
#if LWIP_NETIF_STATUS_CALLBACK
|
||||
void pppapi_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback);
|
||||
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||
#if LWIP_NETIF_LINK_CALLBACK
|
||||
void pppapi_set_netif_linkcallback(ppp_pcb *pcb, netif_status_callback_fn link_callback);
|
||||
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_PPP_API */
|
||||
|
||||
#endif /* __LWIP_PPPAPI_H__ */
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include "lwip/api_msg.h"
|
||||
#include "lwip/netifapi.h"
|
||||
#include "lwip/pppapi.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/sys.h"
|
||||
@@ -77,6 +78,8 @@ extern sys_mutex_t lock_tcpip_core;
|
||||
#define TCPIP_APIMSG_ACK(m)
|
||||
#define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
|
||||
#define TCPIP_NETIFAPI_ACK(m)
|
||||
#define TCPIP_PPPAPI(m) tcpip_pppapi_lock(m)
|
||||
#define TCPIP_PPPAPI_ACK(m)
|
||||
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#define LOCK_TCPIP_CORE()
|
||||
#define UNLOCK_TCPIP_CORE()
|
||||
@@ -85,6 +88,8 @@ extern sys_mutex_t lock_tcpip_core;
|
||||
#define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
|
||||
#define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
|
||||
#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
|
||||
#define TCPIP_PPPAPI(m) tcpip_pppapi(m)
|
||||
#define TCPIP_PPPAPI_ACK(m) sys_sem_signal(&m->sem)
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
|
||||
@@ -139,6 +144,13 @@ err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#endif /* LWIP_NETIF_API */
|
||||
|
||||
#if LWIP_PPP_API
|
||||
err_t tcpip_pppapi(struct pppapi_msg *pppapimsg);
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
err_t tcpip_pppapi_lock(struct pppapi_msg *pppapimsg);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#endif /* LWIP_PPP_API */
|
||||
|
||||
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
|
||||
#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
|
||||
|
||||
@@ -163,6 +175,9 @@ enum tcpip_msg_type {
|
||||
#if LWIP_NETIF_API
|
||||
TCPIP_MSG_NETIFAPI,
|
||||
#endif /* LWIP_NETIF_API */
|
||||
#if LWIP_PPP_API
|
||||
TCPIP_MSG_PPPAPI,
|
||||
#endif /* LWIP_PPP_API */
|
||||
#if LWIP_TCPIP_TIMEOUT
|
||||
TCPIP_MSG_TIMEOUT,
|
||||
TCPIP_MSG_UNTIMEOUT,
|
||||
@@ -181,6 +196,9 @@ struct tcpip_msg {
|
||||
#if LWIP_NETIF_API
|
||||
struct netifapi_msg *netifapimsg;
|
||||
#endif /* LWIP_NETIF_API */
|
||||
#if LWIP_PPP_API
|
||||
struct pppapi_msg *pppapimsg;
|
||||
#endif /* LWIP_PPP_API */
|
||||
struct {
|
||||
struct pbuf *p;
|
||||
struct netif *netif;
|
||||
|
||||
57
src/include/netif/ppp/ccp.h
Normal file
57
src/include/netif/ppp/ccp.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* ccp.h - Definitions for PPP Compression Control Protocol.
|
||||
*
|
||||
* Copyright (c) 1994-2002 Paul Mackerras. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ccp.h,v 1.12 2004/11/04 10:02:26 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && CCP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
typedef struct ccp_options {
|
||||
bool bsd_compress; /* do BSD Compress? */
|
||||
bool deflate; /* do Deflate? */
|
||||
bool predictor_1; /* do Predictor-1? */
|
||||
bool predictor_2; /* do Predictor-2? */
|
||||
bool deflate_correct; /* use correct code for deflate? */
|
||||
bool deflate_draft; /* use draft RFC code for deflate? */
|
||||
bool mppe; /* do MPPE? */
|
||||
u_short bsd_bits; /* # bits/code for BSD Compress */
|
||||
u_short deflate_size; /* lg(window size) for Deflate */
|
||||
short method; /* code for chosen compression method */
|
||||
} ccp_options;
|
||||
|
||||
extern fsm ccp_fsm[];
|
||||
extern ccp_options ccp_wantoptions[];
|
||||
extern ccp_options ccp_gotoptions[];
|
||||
extern ccp_options ccp_allowoptions[];
|
||||
extern ccp_options ccp_hisoptions[];
|
||||
|
||||
extern const struct protent ccp_protent;
|
||||
|
||||
#endif /* PPP_SUPPORT && CCP_SUPPORT */
|
||||
36
src/include/netif/ppp/chap-md5.h
Normal file
36
src/include/netif/ppp/chap-md5.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* chap-md5.h - New CHAP/MD5 implementation.
|
||||
*
|
||||
* Copyright (c) 2003 Paul Mackerras. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
extern const struct chap_digest_type md5_digest;
|
||||
|
||||
#endif /* PPP_SUPPORT && CHAP_SUPPORT */
|
||||
193
src/include/netif/ppp/chap-new.h
Normal file
193
src/include/netif/ppp/chap-new.h
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* chap-new.c - New CHAP implementation.
|
||||
*
|
||||
* Copyright (c) 2003 Paul Mackerras. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef CHAP_H
|
||||
#define CHAP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* CHAP packets begin with a standard header with code, id, len (2 bytes).
|
||||
*/
|
||||
#define CHAP_HDRLEN 4
|
||||
|
||||
/*
|
||||
* Values for the code field.
|
||||
*/
|
||||
#define CHAP_CHALLENGE 1
|
||||
#define CHAP_RESPONSE 2
|
||||
#define CHAP_SUCCESS 3
|
||||
#define CHAP_FAILURE 4
|
||||
|
||||
/*
|
||||
* CHAP digest codes.
|
||||
*/
|
||||
#define CHAP_MD5 5
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_MICROSOFT 0x80
|
||||
#define CHAP_MICROSOFT_V2 0x81
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* Semi-arbitrary limits on challenge and response fields.
|
||||
*/
|
||||
#define MAX_CHALLENGE_LEN 64
|
||||
#define MAX_RESPONSE_LEN 64
|
||||
|
||||
/*
|
||||
* These limits apply to challenge and response packets we send.
|
||||
* The +4 is the +1 that we actually need rounded up.
|
||||
*/
|
||||
#define CHAL_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_CHALLENGE_LEN + MAXNAMELEN)
|
||||
#define RESP_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_RESPONSE_LEN + MAXNAMELEN)
|
||||
|
||||
/* bitmask of supported algorithms */
|
||||
#if MSCHAP_SUPPORT
|
||||
#define MDTYPE_MICROSOFT_V2 0x1
|
||||
#define MDTYPE_MICROSOFT 0x2
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
#define MDTYPE_MD5 0x4
|
||||
#define MDTYPE_NONE 0
|
||||
|
||||
#if MSCHAP_SUPPORT
|
||||
/* Return the digest alg. ID for the most preferred digest type. */
|
||||
#define CHAP_DIGEST(mdtype) \
|
||||
((mdtype) & MDTYPE_MD5)? CHAP_MD5: \
|
||||
((mdtype) & MDTYPE_MICROSOFT_V2)? CHAP_MICROSOFT_V2: \
|
||||
((mdtype) & MDTYPE_MICROSOFT)? CHAP_MICROSOFT: \
|
||||
0
|
||||
#else /* !MSCHAP_SUPPORT */
|
||||
#define CHAP_DIGEST(mdtype) \
|
||||
((mdtype) & MDTYPE_MD5)? CHAP_MD5: \
|
||||
0
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/* Return the bit flag (lsb set) for our most preferred digest type. */
|
||||
#define CHAP_MDTYPE(mdtype) ((mdtype) ^ ((mdtype) - 1)) & (mdtype)
|
||||
|
||||
/* Return the bit flag for a given digest algorithm ID. */
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_MDTYPE_D(digest) \
|
||||
((digest) == CHAP_MICROSOFT_V2)? MDTYPE_MICROSOFT_V2: \
|
||||
((digest) == CHAP_MICROSOFT)? MDTYPE_MICROSOFT: \
|
||||
((digest) == CHAP_MD5)? MDTYPE_MD5: \
|
||||
0
|
||||
#else /* !MSCHAP_SUPPORT */
|
||||
#define CHAP_MDTYPE_D(digest) \
|
||||
((digest) == CHAP_MD5)? MDTYPE_MD5: \
|
||||
0
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/* Can we do the requested digest? */
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_CANDIGEST(mdtype, digest) \
|
||||
((digest) == CHAP_MICROSOFT_V2)? (mdtype) & MDTYPE_MICROSOFT_V2: \
|
||||
((digest) == CHAP_MICROSOFT)? (mdtype) & MDTYPE_MICROSOFT: \
|
||||
((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \
|
||||
0
|
||||
#else /* !MSCHAP_SUPPORT */
|
||||
#define CHAP_CANDIGEST(mdtype, digest) \
|
||||
((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \
|
||||
0
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* The code for each digest type has to supply one of these.
|
||||
*/
|
||||
struct chap_digest_type {
|
||||
int code;
|
||||
|
||||
#if PPP_SERVER
|
||||
/*
|
||||
* Note: challenge and response arguments below are formatted as
|
||||
* a length byte followed by the actual challenge/response data.
|
||||
*/
|
||||
void (*generate_challenge)(unsigned char *challenge);
|
||||
int (*verify_response)(int id, char *name,
|
||||
unsigned char *secret, int secret_len,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space);
|
||||
#endif /* PPP_SERVER */
|
||||
void (*make_response)(unsigned char *response, int id, char *our_name,
|
||||
unsigned char *challenge, char *secret, int secret_len,
|
||||
unsigned char *priv);
|
||||
int (*check_success)(unsigned char *pkt, int len, unsigned char *priv);
|
||||
void (*handle_failure)(unsigned char *pkt, int len);
|
||||
};
|
||||
|
||||
/*
|
||||
* Each interface is described by chap structure.
|
||||
*/
|
||||
#if CHAP_SUPPORT
|
||||
typedef struct chap_client_state {
|
||||
u8_t flags;
|
||||
char *name;
|
||||
const struct chap_digest_type *digest;
|
||||
unsigned char priv[64]; /* private area for digest's use */
|
||||
} chap_client_state;
|
||||
|
||||
#if PPP_SERVER
|
||||
typedef struct chap_server_state {
|
||||
u8_t flags;
|
||||
int id;
|
||||
char *name;
|
||||
const struct chap_digest_type *digest;
|
||||
int challenge_xmits;
|
||||
int challenge_pktlen;
|
||||
unsigned char challenge[CHAL_MAX_PKTLEN];
|
||||
char message[256];
|
||||
} chap_server_state;
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
/* Hook for a plugin to validate CHAP challenge */
|
||||
extern int (*chap_verify_hook)(char *name, char *ourname, int id,
|
||||
const struct chap_digest_type *digest,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space);
|
||||
#endif /* UNUSED */
|
||||
|
||||
#if PPP_SERVER
|
||||
/* Called by authentication code to start authenticating the peer. */
|
||||
extern void chap_auth_peer(ppp_pcb *pcb, char *our_name, int digest_code);
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/* Called by auth. code to start authenticating us to the peer. */
|
||||
extern void chap_auth_with_peer(ppp_pcb *pcb, char *our_name, int digest_code);
|
||||
|
||||
/* Represents the CHAP protocol to the main pppd code */
|
||||
extern const struct protent chap_protent;
|
||||
|
||||
#endif /* CHAP_H */
|
||||
#endif /* PPP_SUPPORT && CHAP_SUPPORT */
|
||||
115
src/include/netif/ppp/chap_ms.h
Normal file
115
src/include/netif/ppp/chap_ms.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* chap_ms.h - Challenge Handshake Authentication Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1995 Eric Rosenquist. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef __CHAPMS_INCLUDE__
|
||||
|
||||
#define MD4_SIGNATURE_SIZE 16 /* 16 bytes in a MD4 message digest */
|
||||
#define MAX_NT_PASSWORD 256 /* Max (Unicode) chars in an NT pass */
|
||||
|
||||
#define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */
|
||||
#define MS_CHAP2_RESPONSE_LEN 49 /* Response length for MS-CHAPv2 */
|
||||
#define MS_AUTH_RESPONSE_LENGTH 40 /* MS-CHAPv2 authenticator response, */
|
||||
/* as ASCII */
|
||||
|
||||
/* Error codes for MS-CHAP failure messages. */
|
||||
#define MS_CHAP_ERROR_RESTRICTED_LOGON_HOURS 646
|
||||
#define MS_CHAP_ERROR_ACCT_DISABLED 647
|
||||
#define MS_CHAP_ERROR_PASSWD_EXPIRED 648
|
||||
#define MS_CHAP_ERROR_NO_DIALIN_PERMISSION 649
|
||||
#define MS_CHAP_ERROR_AUTHENTICATION_FAILURE 691
|
||||
#define MS_CHAP_ERROR_CHANGING_PASSWORD 709
|
||||
|
||||
/*
|
||||
* Offsets within the response field for MS-CHAP
|
||||
*/
|
||||
#define MS_CHAP_LANMANRESP 0
|
||||
#define MS_CHAP_LANMANRESP_LEN 24
|
||||
#define MS_CHAP_NTRESP 24
|
||||
#define MS_CHAP_NTRESP_LEN 24
|
||||
#define MS_CHAP_USENT 48
|
||||
|
||||
/*
|
||||
* Offsets within the response field for MS-CHAP2
|
||||
*/
|
||||
#define MS_CHAP2_PEER_CHALLENGE 0
|
||||
#define MS_CHAP2_PEER_CHAL_LEN 16
|
||||
#define MS_CHAP2_RESERVED_LEN 8
|
||||
#define MS_CHAP2_NTRESP 24
|
||||
#define MS_CHAP2_NTRESP_LEN 24
|
||||
#define MS_CHAP2_FLAGS 48
|
||||
|
||||
#ifdef MPPE
|
||||
#include "mppe.h" /* MPPE_MAX_KEY_LEN */
|
||||
extern u_char mppe_send_key[MPPE_MAX_KEY_LEN];
|
||||
extern u_char mppe_recv_key[MPPE_MAX_KEY_LEN];
|
||||
extern int mppe_keys_set;
|
||||
|
||||
/* These values are the RADIUS attribute values--see RFC 2548. */
|
||||
#define MPPE_ENC_POL_ENC_ALLOWED 1
|
||||
#define MPPE_ENC_POL_ENC_REQUIRED 2
|
||||
#define MPPE_ENC_TYPES_RC4_40 2
|
||||
#define MPPE_ENC_TYPES_RC4_128 4
|
||||
|
||||
/* used by plugins (using above values) */
|
||||
extern void set_mppe_enc_types(int, int);
|
||||
#endif
|
||||
|
||||
/* Are we the authenticator or authenticatee? For MS-CHAPv2 key derivation. */
|
||||
#define MS_CHAP2_AUTHENTICATEE 0
|
||||
#define MS_CHAP2_AUTHENTICATOR 1
|
||||
|
||||
void ChapMS (u_char *, char *, int, u_char *);
|
||||
void ChapMS2 (u_char *, u_char *, char *, char *, int,
|
||||
u_char *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int);
|
||||
#ifdef MPPE
|
||||
void mppe_set_keys (u_char *, u_char[MD4_SIGNATURE_SIZE]);
|
||||
void mppe_set_keys2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
|
||||
u_char NTResponse[24], int IsServer);
|
||||
#endif
|
||||
|
||||
void ChallengeHash (u_char[16], u_char *, char *, u_char[8]);
|
||||
|
||||
void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
|
||||
u_char NTResponse[24], u_char PeerChallenge[16],
|
||||
u_char *rchallenge, char *username,
|
||||
u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]);
|
||||
|
||||
extern const struct chap_digest_type chapms_digest;
|
||||
extern const struct chap_digest_type chapms2_digest;
|
||||
|
||||
#define __CHAPMS_INCLUDE__
|
||||
#endif /* __CHAPMS_INCLUDE__ */
|
||||
|
||||
#endif /* PPP_SUPPORT && MSCHAP_SUPPORT */
|
||||
168
src/include/netif/ppp/eap.h
Normal file
168
src/include/netif/ppp/eap.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* eap.h - Extensible Authentication Protocol for PPP (RFC 2284)
|
||||
*
|
||||
* Copyright (c) 2001 by Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Non-exclusive rights to redistribute, modify, translate, and use
|
||||
* this software in source and binary forms, in whole or in part, is
|
||||
* hereby granted, provided that the above copyright notice is
|
||||
* duplicated in any source form, and that neither the name of the
|
||||
* copyright holder nor the author is used to endorse or promote
|
||||
* products derived from this software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Original version by James Carlson
|
||||
*
|
||||
* $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPP_EAP_H
|
||||
#define PPP_EAP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define EAP_HEADERLEN 4
|
||||
|
||||
|
||||
/* EAP message codes. */
|
||||
#define EAP_REQUEST 1
|
||||
#define EAP_RESPONSE 2
|
||||
#define EAP_SUCCESS 3
|
||||
#define EAP_FAILURE 4
|
||||
|
||||
/* EAP types */
|
||||
#define EAPT_IDENTITY 1
|
||||
#define EAPT_NOTIFICATION 2
|
||||
#define EAPT_NAK 3 /* (response only) */
|
||||
#define EAPT_MD5CHAP 4
|
||||
#define EAPT_OTP 5 /* One-Time Password; RFC 1938 */
|
||||
#define EAPT_TOKEN 6 /* Generic Token Card */
|
||||
/* 7 and 8 are unassigned. */
|
||||
#define EAPT_RSA 9 /* RSA Public Key Authentication */
|
||||
#define EAPT_DSS 10 /* DSS Unilateral */
|
||||
#define EAPT_KEA 11 /* KEA */
|
||||
#define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */
|
||||
#define EAPT_TLS 13 /* EAP-TLS */
|
||||
#define EAPT_DEFENDER 14 /* Defender Token (AXENT) */
|
||||
#define EAPT_W2K 15 /* Windows 2000 EAP */
|
||||
#define EAPT_ARCOT 16 /* Arcot Systems */
|
||||
#define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */
|
||||
#define EAPT_NOKIACARD 18 /* Nokia IP smart card */
|
||||
#define EAPT_SRP 19 /* Secure Remote Password */
|
||||
/* 20 is deprecated */
|
||||
|
||||
/* EAP SRP-SHA1 Subtypes */
|
||||
#define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */
|
||||
#define EAPSRP_CKEY 1 /* Response 1 - Client Key */
|
||||
#define EAPSRP_SKEY 2 /* Request 2 - Server Key */
|
||||
#define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */
|
||||
#define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */
|
||||
#define EAPSRP_ACK 3 /* Response 3 - final ack */
|
||||
#define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */
|
||||
|
||||
#define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */
|
||||
|
||||
#define SRP_PSEUDO_ID "pseudo_"
|
||||
#define SRP_PSEUDO_LEN 7
|
||||
|
||||
#define MD5_SIGNATURE_SIZE 16
|
||||
#define EAP_MIN_CHALLENGE_LENGTH 16
|
||||
#define EAP_MAX_CHALLENGE_LENGTH 24
|
||||
|
||||
#define EAP_STATES \
|
||||
"Initial", "Pending", "Closed", "Listen", "Identify", \
|
||||
"SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
|
||||
|
||||
#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen)
|
||||
#if PPP_SERVER
|
||||
#define eap_server_active(pcb) \
|
||||
((pcb)->eap.es_server.ea_state >= eapIdentify && \
|
||||
(pcb)->eap.es_server.ea_state <= eapMD5Chall)
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/*
|
||||
* Complete EAP state for one PPP session.
|
||||
*/
|
||||
enum eap_state_code {
|
||||
eapInitial = 0, /* No EAP authentication yet requested */
|
||||
eapPending, /* Waiting for LCP (no timer) */
|
||||
eapClosed, /* Authentication not in use */
|
||||
eapListen, /* Client ready (and timer running) */
|
||||
eapIdentify, /* EAP Identify sent */
|
||||
eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */
|
||||
eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */
|
||||
eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */
|
||||
eapMD5Chall, /* Sent MD5-Challenge */
|
||||
eapOpen, /* Completed authentication */
|
||||
eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */
|
||||
eapBadAuth /* Failed authentication */
|
||||
};
|
||||
|
||||
struct eap_auth {
|
||||
char *ea_name; /* Our name */
|
||||
char *ea_peer; /* Peer's name */
|
||||
void *ea_session; /* Authentication library linkage */
|
||||
u_char *ea_skey; /* Shared encryption key */
|
||||
u_short ea_namelen; /* Length of our name */
|
||||
u_short ea_peerlen; /* Length of peer's name */
|
||||
enum eap_state_code ea_state;
|
||||
u_char ea_id; /* Current id */
|
||||
u_char ea_requests; /* Number of Requests sent/received */
|
||||
u_char ea_responses; /* Number of Responses */
|
||||
u_char ea_type; /* One of EAPT_* */
|
||||
u32_t ea_keyflags; /* SRP shared key usage flags */
|
||||
};
|
||||
|
||||
#ifndef EAP_MAX_CHALLENGE_LENGTH
|
||||
#define EAP_MAX_CHALLENGE_LENGTH 24
|
||||
#endif
|
||||
typedef struct eap_state {
|
||||
struct eap_auth es_client; /* Client (authenticatee) data */
|
||||
#if PPP_SERVER
|
||||
struct eap_auth es_server; /* Server (authenticator) data */
|
||||
#endif /* PPP_SERVER */
|
||||
int es_savedtime; /* Saved timeout */
|
||||
int es_rechallenge; /* EAP rechallenge interval */
|
||||
int es_lwrechallenge; /* SRP lightweight rechallenge inter */
|
||||
u8_t es_usepseudo; /* Use SRP Pseudonym if offered one */
|
||||
int es_usedpseudo; /* Set if we already sent PN */
|
||||
int es_challen; /* Length of challenge string */
|
||||
u_char es_challenge[EAP_MAX_CHALLENGE_LENGTH];
|
||||
} eap_state;
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#if 0 /* moved to opt.h */
|
||||
#define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */
|
||||
#define EAP_DEFTRANSMITS 10 /* max # times to transmit */
|
||||
#define EAP_DEFREQTIME 20 /* Time to wait for peer request */
|
||||
#define EAP_DEFALLOWREQ 20 /* max # times to accept requests */
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
void eap_authwithpeer(ppp_pcb *pcb, char *localname);
|
||||
void eap_authpeer(ppp_pcb *pcb, char *localname);
|
||||
|
||||
extern const struct protent eap_protent;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PPP_EAP_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && EAP_SUPPORT */
|
||||
50
src/include/netif/ppp/ecp.h
Normal file
50
src/include/netif/ppp/ecp.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* ecp.h - Definitions for PPP Encryption Control Protocol.
|
||||
*
|
||||
* Copyright (c) 2002 Google, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
typedef struct ecp_options {
|
||||
bool required; /* Is ECP required? */
|
||||
unsigned enctype; /* Encryption type */
|
||||
} ecp_options;
|
||||
|
||||
extern fsm ecp_fsm[];
|
||||
extern ecp_options ecp_wantoptions[];
|
||||
extern ecp_options ecp_gotoptions[];
|
||||
extern ecp_options ecp_allowoptions[];
|
||||
extern ecp_options ecp_hisoptions[];
|
||||
|
||||
extern const struct protent ecp_protent;
|
||||
|
||||
#endif /* PPP_SUPPORT && ECP_SUPPORT */
|
||||
94
src/include/netif/ppp/eui64.h
Normal file
94
src/include/netif/ppp/eui64.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* eui64.h - EUI64 routines for IPv6CP.
|
||||
*
|
||||
* Copyright (c) 1999 Tommi Komulainen. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Tommi Komulainen
|
||||
* <Tommi.Komulainen@iki.fi>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef __EUI64_H__
|
||||
#define __EUI64_H__
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
*
|
||||
* Maybe this should be done by processing struct in6_addr directly...
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
u8_t e8[8];
|
||||
u16_t e16[4];
|
||||
u32_t e32[2];
|
||||
} eui64_t;
|
||||
|
||||
#define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0)
|
||||
#define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \
|
||||
((e).e32[1] == (o).e32[1]))
|
||||
#define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0;
|
||||
|
||||
#define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t))
|
||||
|
||||
#define eui64_magic(e) do { \
|
||||
(e).e32[0] = magic(); \
|
||||
(e).e32[1] = magic(); \
|
||||
(e).e8[0] &= ~2; \
|
||||
} while (0)
|
||||
#define eui64_magic_nz(x) do { \
|
||||
eui64_magic(x); \
|
||||
} while (eui64_iszero(x))
|
||||
#define eui64_magic_ne(x, y) do { \
|
||||
eui64_magic(x); \
|
||||
} while (eui64_equals(x, y))
|
||||
|
||||
#define eui64_get(ll, cp) do { \
|
||||
eui64_copy((*cp), (ll)); \
|
||||
(cp) += sizeof(eui64_t); \
|
||||
} while (0)
|
||||
|
||||
#define eui64_put(ll, cp) do { \
|
||||
eui64_copy((ll), (*cp)); \
|
||||
(cp) += sizeof(eui64_t); \
|
||||
} while (0)
|
||||
|
||||
#define eui64_set32(e, l) do { \
|
||||
(e).e32[0] = 0; \
|
||||
(e).e32[1] = htonl(l); \
|
||||
} while (0)
|
||||
#define eui64_setlo32(e, l) eui64_set32(e, l)
|
||||
|
||||
char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */
|
||||
|
||||
#endif /* __EUI64_H__ */
|
||||
#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */
|
||||
175
src/include/netif/ppp/fsm.h
Normal file
175
src/include/netif/ppp/fsm.h
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: fsm.h,v 1.10 2004/11/13 02:28:15 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef FSM_H
|
||||
#define FSM_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* CP (LCP, IPCP, etc.) codes.
|
||||
*/
|
||||
#define CONFREQ 1 /* Configuration Request */
|
||||
#define CONFACK 2 /* Configuration Ack */
|
||||
#define CONFNAK 3 /* Configuration Nak */
|
||||
#define CONFREJ 4 /* Configuration Reject */
|
||||
#define TERMREQ 5 /* Termination Request */
|
||||
#define TERMACK 6 /* Termination Ack */
|
||||
#define CODEREJ 7 /* Code Reject */
|
||||
|
||||
|
||||
/*
|
||||
* Each FSM is described by an fsm structure and fsm callbacks.
|
||||
*/
|
||||
typedef struct fsm {
|
||||
ppp_pcb *pcb; /* PPP Interface */
|
||||
const struct fsm_callbacks *callbacks; /* Callback routines */
|
||||
char *term_reason; /* Reason for closing protocol */
|
||||
u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */
|
||||
/* -- This is our only flag, we might use u_int :1 if we have more flags */
|
||||
u16_t protocol; /* Data Link Layer Protocol field value */
|
||||
u8_t state; /* State */
|
||||
u8_t flags; /* Contains option bits */
|
||||
u8_t id; /* Current id */
|
||||
u8_t reqid; /* Current request id */
|
||||
u8_t retransmits; /* Number of retransmissions left */
|
||||
u8_t nakloops; /* Number of nak loops since last ack */
|
||||
u8_t rnakloops; /* Number of naks received */
|
||||
u8_t maxnakloops; /* Maximum number of nak loops tolerated
|
||||
(necessary because IPCP require a custom large max nak loops value) */
|
||||
u8_t term_reason_len; /* Length of term_reason */
|
||||
} fsm;
|
||||
|
||||
|
||||
typedef struct fsm_callbacks {
|
||||
void (*resetci) /* Reset our Configuration Information */
|
||||
(fsm *);
|
||||
int (*cilen) /* Length of our Configuration Information */
|
||||
(fsm *);
|
||||
void (*addci) /* Add our Configuration Information */
|
||||
(fsm *, u_char *, int *);
|
||||
int (*ackci) /* ACK our Configuration Information */
|
||||
(fsm *, u_char *, int);
|
||||
int (*nakci) /* NAK our Configuration Information */
|
||||
(fsm *, u_char *, int, int);
|
||||
int (*rejci) /* Reject our Configuration Information */
|
||||
(fsm *, u_char *, int);
|
||||
int (*reqci) /* Request peer's Configuration Information */
|
||||
(fsm *, u_char *, int *, int);
|
||||
void (*up) /* Called when fsm reaches PPP_FSM_OPENED state */
|
||||
(fsm *);
|
||||
void (*down) /* Called when fsm leaves PPP_FSM_OPENED state */
|
||||
(fsm *);
|
||||
void (*starting) /* Called when we want the lower layer */
|
||||
(fsm *);
|
||||
void (*finished) /* Called when we don't want the lower layer */
|
||||
(fsm *);
|
||||
void (*protreject) /* Called when Protocol-Reject received */
|
||||
(int);
|
||||
void (*retransmit) /* Retransmission is necessary */
|
||||
(fsm *);
|
||||
int (*extcode) /* Called when unknown code received */
|
||||
(fsm *, int, int, u_char *, int);
|
||||
char *proto_name; /* String name for protocol (for messages) */
|
||||
} fsm_callbacks;
|
||||
|
||||
|
||||
/*
|
||||
* Link states.
|
||||
*/
|
||||
#define PPP_FSM_INITIAL 0 /* Down, hasn't been opened */
|
||||
#define PPP_FSM_STARTING 1 /* Down, been opened */
|
||||
#define PPP_FSM_CLOSED 2 /* Up, hasn't been opened */
|
||||
#define PPP_FSM_STOPPED 3 /* Open, waiting for down event */
|
||||
#define PPP_FSM_CLOSING 4 /* Terminating the connection, not open */
|
||||
#define PPP_FSM_STOPPING 5 /* Terminating, but open */
|
||||
#define PPP_FSM_REQSENT 6 /* We've sent a Config Request */
|
||||
#define PPP_FSM_ACKRCVD 7 /* We've received a Config Ack */
|
||||
#define PPP_FSM_ACKSENT 8 /* We've sent a Config Ack */
|
||||
#define PPP_FSM_OPENED 9 /* Connection available */
|
||||
|
||||
|
||||
/*
|
||||
* Flags - indicate options controlling FSM operation
|
||||
*/
|
||||
#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
|
||||
#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
|
||||
#define OPT_SILENT 4 /* Wait for peer to speak first */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#if 0 /* moved to opt.h */
|
||||
#define DEFTIMEOUT 3 /* Timeout time in seconds */
|
||||
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
|
||||
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
|
||||
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void fsm_init(fsm *f);
|
||||
void fsm_lowerup(fsm *f);
|
||||
void fsm_lowerdown(fsm *f);
|
||||
void fsm_open(fsm *f);
|
||||
void fsm_close(fsm *f, char *reason);
|
||||
void fsm_input(fsm *f, u_char *inpacket, int l);
|
||||
void fsm_protreject(fsm *f);
|
||||
void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen);
|
||||
|
||||
|
||||
#endif /* FSM_H */
|
||||
#endif /* PPP_SUPPORT */
|
||||
107
src/include/netif/ppp/ipcp.h
Normal file
107
src/include/netif/ppp/ipcp.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ipcp.h,v 1.14 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef IPCP_H
|
||||
#define IPCP_H
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_ADDRS 1 /* IP Addresses */
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
#define CI_ADDR 3
|
||||
|
||||
#define CI_MS_DNS1 129 /* Primary DNS value */
|
||||
#define CI_MS_WINS1 130 /* Primary WINS value */
|
||||
#define CI_MS_DNS2 131 /* Secondary DNS value */
|
||||
#define CI_MS_WINS2 132 /* Secondary WINS value */
|
||||
|
||||
#define MAX_STATES 16 /* from slcompress.h */
|
||||
|
||||
#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
|
||||
#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
|
||||
#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
|
||||
/* maxslot and slot number compression) */
|
||||
|
||||
#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/
|
||||
#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
|
||||
/* compression option*/
|
||||
|
||||
typedef struct ipcp_options {
|
||||
unsigned int neg_addr :1; /* Negotiate IP Address? */
|
||||
unsigned int old_addrs :1; /* Use old (IP-Addresses) option? */
|
||||
unsigned int req_addr :1; /* Ask peer to send IP address? */
|
||||
#if 0 /* UNUSED */
|
||||
unsigned int default_route :1; /* Assign default route through interface? */
|
||||
unsigned int replace_default_route :1; /* Replace default route through interface? */
|
||||
#endif /* UNUSED */
|
||||
unsigned int proxy_arp :1; /* Make proxy ARP entry for peer? */
|
||||
unsigned int neg_vj :1; /* Van Jacobson Compression? */
|
||||
unsigned int old_vj :1; /* use old (short) form of VJ option? */
|
||||
unsigned int accept_local :1; /* accept peer's value for ouraddr */
|
||||
unsigned int accept_remote :1; /* accept peer's value for hisaddr */
|
||||
unsigned int req_dns1 :1; /* Ask peer to send primary DNS address? */
|
||||
unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */
|
||||
unsigned int cflag :1;
|
||||
unsigned int :5; /* 3 bits of padding to round out to 16 bits */
|
||||
|
||||
u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
|
||||
u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
|
||||
u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
|
||||
|
||||
u16_t vj_protocol; /* protocol value to use in VJ option */
|
||||
u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */
|
||||
} ipcp_options;
|
||||
|
||||
#if 0 /* UNUSED, already defined by lwIP */
|
||||
char *ip_ntoa (u32_t);
|
||||
#endif /* UNUSED, already defined by lwIP */
|
||||
|
||||
extern const struct protent ipcp_protent;
|
||||
|
||||
#endif /* IPCP_H */
|
||||
#endif /* PPP_SUPPORT */
|
||||
179
src/include/netif/ppp/ipv6cp.h
Normal file
179
src/include/netif/ppp/ipv6cp.h
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* ipv6cp.h - PPP IPV6 Control Protocol.
|
||||
*
|
||||
* Copyright (c) 1999 Tommi Komulainen. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Tommi Komulainen
|
||||
* <Tommi.Komulainen@iki.fi>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Original version, based on RFC2023 :
|
||||
|
||||
Copyright (c) 1995, 1996, 1997 Francis.Dupont@inria.fr, INRIA Rocquencourt,
|
||||
Alain.Durand@imag.fr, IMAG,
|
||||
Jean-Luc.Richier@imag.fr, IMAG-LSR.
|
||||
|
||||
Copyright (c) 1998, 1999 Francis.Dupont@inria.fr, GIE DYADE,
|
||||
Alain.Durand@imag.fr, IMAG,
|
||||
Jean-Luc.Richier@imag.fr, IMAG-LSR.
|
||||
|
||||
Ce travail a été fait au sein du GIE DYADE (Groupement d'Intérêt
|
||||
Économique ayant pour membres BULL S.A. et l'INRIA).
|
||||
|
||||
Ce logiciel informatique est disponible aux conditions
|
||||
usuelles dans la recherche, c'est-à-dire qu'il peut
|
||||
être utilisé, copié, modifié, distribué à l'unique
|
||||
condition que ce texte soit conservé afin que
|
||||
l'origine de ce logiciel soit reconnue.
|
||||
|
||||
Le nom de l'Institut National de Recherche en Informatique
|
||||
et en Automatique (INRIA), de l'IMAG, ou d'une personne morale
|
||||
ou physique ayant participé à l'élaboration de ce logiciel ne peut
|
||||
être utilisé sans son accord préalable explicite.
|
||||
|
||||
Ce logiciel est fourni tel quel sans aucune garantie,
|
||||
support ou responsabilité d'aucune sorte.
|
||||
Ce logiciel est dérivé de sources d'origine
|
||||
"University of California at Berkeley" et
|
||||
"Digital Equipment Corporation" couvertes par des copyrights.
|
||||
|
||||
L'Institut d'Informatique et de Mathématiques Appliquées de Grenoble (IMAG)
|
||||
est une fédération d'unités mixtes de recherche du CNRS, de l'Institut National
|
||||
Polytechnique de Grenoble et de l'Université Joseph Fourier regroupant
|
||||
sept laboratoires dont le laboratoire Logiciels, Systèmes, Réseaux (LSR).
|
||||
|
||||
This work has been done in the context of GIE DYADE (joint R & D venture
|
||||
between BULL S.A. and INRIA).
|
||||
|
||||
This software is available with usual "research" terms
|
||||
with the aim of retain credits of the software.
|
||||
Permission to use, copy, modify and distribute this software for any
|
||||
purpose and without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies,
|
||||
and the name of INRIA, IMAG, or any contributor not be used in advertising
|
||||
or publicity pertaining to this material without the prior explicit
|
||||
permission. The software is provided "as is" without any
|
||||
warranties, support or liabilities of any kind.
|
||||
This software is derived from source code from
|
||||
"University of California at Berkeley" and
|
||||
"Digital Equipment Corporation" protected by copyrights.
|
||||
|
||||
Grenoble's Institute of Computer Science and Applied Mathematics (IMAG)
|
||||
is a federation of seven research units funded by the CNRS, National
|
||||
Polytechnic Institute of Grenoble and University Joseph Fourier.
|
||||
The research unit in Software, Systems, Networks (LSR) is member of IMAG.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Derived from :
|
||||
*
|
||||
*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ipv6cp.h,v 1.7 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef IPV6CP_H
|
||||
#define IPV6CP_H
|
||||
|
||||
#include "eui64.h"
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_IFACEID 1 /* Interface Identifier */
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
|
||||
/* No compression types yet defined.
|
||||
*#define IPV6CP_COMP 0x004f
|
||||
*/
|
||||
typedef struct ipv6cp_options {
|
||||
unsigned int neg_ifaceid :1; /* Negotiate interface identifier? */
|
||||
unsigned int req_ifaceid :1; /* Ask peer to send interface identifier? */
|
||||
unsigned int accept_local :1; /* accept peer's value for iface id? */
|
||||
unsigned int opt_local :1; /* ourtoken set by option */
|
||||
unsigned int opt_remote :1; /* histoken set by option */
|
||||
unsigned int use_ip :1; /* use IP as interface identifier */
|
||||
#if 0
|
||||
#if defined(SOL2) || defined(__linux__)
|
||||
unsigned int use_persistent :1; /* use uniquely persistent value for address */
|
||||
#endif /* defined(SOL2) */
|
||||
#endif
|
||||
unsigned int neg_vj :1; /* Van Jacobson Compression? */
|
||||
unsigned int :1; /* 1 bit of padding to round out to 8 bits */
|
||||
u_short vj_protocol; /* protocol value to use in VJ option */
|
||||
eui64_t ourid, hisid; /* Interface identifiers */
|
||||
} ipv6cp_options;
|
||||
|
||||
extern const struct protent ipv6cp_protent;
|
||||
|
||||
#endif /* IPV6CP_H */
|
||||
#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */
|
||||
176
src/include/netif/ppp/lcp.h
Normal file
176
src/include/netif/ppp/lcp.h
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* lcp.h - Link Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: lcp.h,v 1.20 2004/11/14 22:53:42 carlsonj Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef LCP_H
|
||||
#define LCP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_VENDOR 0 /* Vendor Specific */
|
||||
#define CI_MRU 1 /* Maximum Receive Unit */
|
||||
#define CI_ASYNCMAP 2 /* Async Control Character Map */
|
||||
#define CI_AUTHTYPE 3 /* Authentication Type */
|
||||
#define CI_QUALITY 4 /* Quality Protocol */
|
||||
#define CI_MAGICNUMBER 5 /* Magic Number */
|
||||
#define CI_PCOMPRESSION 7 /* Protocol Field Compression */
|
||||
#define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */
|
||||
#define CI_FCSALTERN 9 /* FCS-Alternatives */
|
||||
#define CI_SDP 10 /* Self-Describing-Pad */
|
||||
#define CI_NUMBERED 11 /* Numbered-Mode */
|
||||
#define CI_CALLBACK 13 /* callback */
|
||||
#define CI_MRRU 17 /* max reconstructed receive unit; multilink */
|
||||
#define CI_SSNHF 18 /* short sequence numbers for multilink */
|
||||
#define CI_EPDISC 19 /* endpoint discriminator */
|
||||
#define CI_MPPLUS 22 /* Multi-Link-Plus-Procedure */
|
||||
#define CI_LDISC 23 /* Link-Discriminator */
|
||||
#define CI_LCPAUTH 24 /* LCP Authentication */
|
||||
#define CI_COBS 25 /* Consistent Overhead Byte Stuffing */
|
||||
#define CI_PREFELIS 26 /* Prefix Elision */
|
||||
#define CI_MPHDRFMT 27 /* MP Header Format */
|
||||
#define CI_I18N 28 /* Internationalization */
|
||||
#define CI_SDL 29 /* Simple Data Link */
|
||||
|
||||
/*
|
||||
* LCP-specific packet types (code numbers).
|
||||
*/
|
||||
#define PROTREJ 8 /* Protocol Reject */
|
||||
#define ECHOREQ 9 /* Echo Request */
|
||||
#define ECHOREP 10 /* Echo Reply */
|
||||
#define DISCREQ 11 /* Discard Request */
|
||||
#define IDENTIF 12 /* Identification */
|
||||
#define TIMEREM 13 /* Time Remaining */
|
||||
|
||||
/* Value used as data for CI_CALLBACK option */
|
||||
#define CBCP_OPT 6 /* Use callback control protocol */
|
||||
|
||||
#define DEFMRU 1500 /* Try for this */
|
||||
#define MINMRU 128 /* No MRUs below this */
|
||||
#define MAXMRU 16384 /* Normally limit MRU to this */
|
||||
|
||||
/* An endpoint discriminator, used with multilink. */
|
||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||
struct epdisc {
|
||||
unsigned char class_; /* -- The word "class" is reserved in C++. */
|
||||
unsigned char length;
|
||||
unsigned char value[MAX_ENDP_LEN];
|
||||
};
|
||||
|
||||
/*
|
||||
* The state of options is described by an lcp_options structure.
|
||||
*/
|
||||
typedef struct lcp_options {
|
||||
unsigned int passive :1; /* Don't die if we don't get a response */
|
||||
unsigned int silent :1; /* Wait for the other end to start first */
|
||||
unsigned int restart :1; /* Restart vs. exit after close */
|
||||
unsigned int neg_mru :1; /* Negotiate the MRU? */
|
||||
unsigned int neg_asyncmap :1; /* Negotiate the async map? */
|
||||
#if PAP_SUPPORT
|
||||
unsigned int neg_upap :1; /* Ask for UPAP authentication? */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
unsigned int neg_chap :1; /* Ask for CHAP authentication? */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
unsigned int neg_eap :1; /* Ask for EAP authentication? */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* EAP_SUPPORT */
|
||||
unsigned int neg_magicnumber :1; /* Ask for magic number? */
|
||||
unsigned int neg_pcompression :1; /* HDLC Protocol Field Compression? */
|
||||
unsigned int neg_accompression :1; /* HDLC Address/Control Field Compression? */
|
||||
#if LQR_SUPPORT
|
||||
unsigned int neg_lqr :1; /* Negotiate use of Link Quality Reports */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* LQR_SUPPORT */
|
||||
unsigned int neg_cbcp :1; /* Negotiate use of CBCP */
|
||||
#ifdef HAVE_MULTILINK
|
||||
unsigned int neg_mrru :1; /* negotiate multilink MRRU */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* HAVE_MULTILINK */
|
||||
unsigned int neg_ssnhf :1; /* negotiate short sequence numbers */
|
||||
unsigned int neg_endpoint :1; /* negotiate endpoint discriminator */
|
||||
u16_t mru; /* Value of MRU */
|
||||
#ifdef HAVE_MULTILINK
|
||||
u16_t mrru; /* Value of MRRU, and multilink enable */
|
||||
#endif /* MULTILINK */
|
||||
#if CHAP_SUPPORT
|
||||
u8_t chap_mdtype; /* which MD types (hashing algorithm) */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
u32_t asyncmap; /* Value of async map */
|
||||
u32_t magicnumber;
|
||||
u8_t numloops; /* Number of loops during magic number neg. */
|
||||
#if LQR_SUPPORT
|
||||
u32_t lqr_period; /* Reporting period for LQR 1/100ths second */
|
||||
#endif /* LQR_SUPPORT */
|
||||
struct epdisc endpoint; /* endpoint discriminator */
|
||||
} lcp_options;
|
||||
|
||||
void lcp_open(ppp_pcb *pcb);
|
||||
void lcp_close(ppp_pcb *pcb, char *reason);
|
||||
void lcp_lowerup(ppp_pcb *pcb);
|
||||
void lcp_lowerdown(ppp_pcb *pcb);
|
||||
void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len); /* send protocol reject */
|
||||
|
||||
extern const struct protent lcp_protent;
|
||||
|
||||
#if 0 /* moved to opt.h */
|
||||
/* Default number of times we receive our magic number from the peer
|
||||
before deciding the link is looped-back. */
|
||||
#define DEFLOOPBACKFAIL 10
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
#endif /* LCP_H */
|
||||
#endif /* PPP_SUPPORT */
|
||||
119
src/include/netif/ppp/magic.h
Normal file
119
src/include/netif/ppp/magic.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* magic.h - PPP Magic Number definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $
|
||||
*/
|
||||
/*****************************************************************************
|
||||
* randm.h - Random number generator header file.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* Copyright (c) 1998 Global Election Systems Inc.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 98-05-29 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
|
||||
* Extracted from avos.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef MAGIC_H
|
||||
#define MAGIC_H
|
||||
|
||||
/***********************
|
||||
*** PUBLIC FUNCTIONS ***
|
||||
***********************/
|
||||
|
||||
/*
|
||||
* Initialize the random number generator.
|
||||
*/
|
||||
void magic_init(void);
|
||||
|
||||
/*
|
||||
* Randomize our random seed value. To be called for truely random events
|
||||
* such as user operations and network traffic.
|
||||
*/
|
||||
void magic_randomize(void);
|
||||
|
||||
/*
|
||||
* Return a new random number.
|
||||
*/
|
||||
u32_t magic(void); /* Returns the next magic number */
|
||||
|
||||
#if PPP_MD5_RANDM
|
||||
/*
|
||||
* Fill buffer with random bytes
|
||||
*
|
||||
* Use the random pool to generate random data. This degrades to pseudo
|
||||
* random when used faster than randomness is supplied using magic_churnrand().
|
||||
* Thus it's important to make sure that the results of this are not
|
||||
* published directly because one could predict the next result to at
|
||||
* least some degree. Also, it's important to get a good seed before
|
||||
* the first use.
|
||||
*/
|
||||
void random_bytes(unsigned char *buf, u32_t len);
|
||||
#endif /* PPP_MD5_RANDM */
|
||||
|
||||
#endif /* MAGIC_H */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
92
src/include/netif/ppp/polarssl/des.h
Normal file
92
src/include/netif/ppp/polarssl/des.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* \file des.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names of PolarSSL or XySSL nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_DES
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_DES_H
|
||||
#define LWIP_INCLUDED_POLARSSL_DES_H
|
||||
|
||||
#define DES_ENCRYPT 1
|
||||
#define DES_DECRYPT 0
|
||||
|
||||
/**
|
||||
* \brief DES context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int mode; /*!< encrypt/decrypt */
|
||||
unsigned long sk[32]; /*!< DES subkeys */
|
||||
}
|
||||
des_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief DES key schedule (56-bit, encryption)
|
||||
*
|
||||
* \param ctx DES context to be initialized
|
||||
* \param key 8-byte secret key
|
||||
*/
|
||||
void des_setkey_enc( des_context *ctx, unsigned char key[8] );
|
||||
|
||||
/**
|
||||
* \brief DES key schedule (56-bit, decryption)
|
||||
*
|
||||
* \param ctx DES context to be initialized
|
||||
* \param key 8-byte secret key
|
||||
*/
|
||||
void des_setkey_dec( des_context *ctx, unsigned char key[8] );
|
||||
|
||||
/**
|
||||
* \brief DES-ECB block encryption/decryption
|
||||
*
|
||||
* \param ctx DES context
|
||||
* \param input 64-bit input block
|
||||
* \param output 64-bit output block
|
||||
*/
|
||||
void des_crypt_ecb( des_context *ctx,
|
||||
unsigned char input[8],
|
||||
unsigned char output[8] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_DES_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_DES */
|
||||
97
src/include/netif/ppp/polarssl/md4.h
Normal file
97
src/include/netif/ppp/polarssl/md4.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* \file md4.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names of PolarSSL or XySSL nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_MD4
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_MD4_H
|
||||
#define LWIP_INCLUDED_POLARSSL_MD4_H
|
||||
|
||||
/**
|
||||
* \brief MD4 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned long total[2]; /*!< number of bytes processed */
|
||||
unsigned long state[4]; /*!< intermediate digest state */
|
||||
unsigned char buffer[64]; /*!< data block being processed */
|
||||
}
|
||||
md4_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief MD4 context setup
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*/
|
||||
void md4_starts( md4_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief MD4 process buffer
|
||||
*
|
||||
* \param ctx MD4 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*/
|
||||
void md4_update( md4_context *ctx, unsigned char *input, int ilen );
|
||||
|
||||
/**
|
||||
* \brief MD4 final digest
|
||||
*
|
||||
* \param ctx MD4 context
|
||||
* \param output MD4 checksum result
|
||||
*/
|
||||
void md4_finish( md4_context *ctx, unsigned char output[16] );
|
||||
|
||||
/**
|
||||
* \brief Output = MD4( input buffer )
|
||||
*
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
* \param output MD4 checksum result
|
||||
*/
|
||||
void md4( unsigned char *input, int ilen, unsigned char output[16] );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD4_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD4 */
|
||||
96
src/include/netif/ppp/polarssl/md5.h
Normal file
96
src/include/netif/ppp/polarssl/md5.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* \file md5.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names of PolarSSL or XySSL nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_MD5
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_MD5_H
|
||||
#define LWIP_INCLUDED_POLARSSL_MD5_H
|
||||
|
||||
/**
|
||||
* \brief MD5 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned long total[2]; /*!< number of bytes processed */
|
||||
unsigned long state[4]; /*!< intermediate digest state */
|
||||
unsigned char buffer[64]; /*!< data block being processed */
|
||||
}
|
||||
md5_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief MD5 context setup
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*/
|
||||
void md5_starts( md5_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief MD5 process buffer
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*/
|
||||
void md5_update( md5_context *ctx, unsigned char *input, int ilen );
|
||||
|
||||
/**
|
||||
* \brief MD5 final digest
|
||||
*
|
||||
* \param ctx MD5 context
|
||||
* \param output MD5 checksum result
|
||||
*/
|
||||
void md5_finish( md5_context *ctx, unsigned char output[16] );
|
||||
|
||||
/**
|
||||
* \brief Output = MD5( input buffer )
|
||||
*
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
* \param output MD5 checksum result
|
||||
*/
|
||||
void md5( unsigned char *input, int ilen, unsigned char output[16] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD5_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD5 */
|
||||
96
src/include/netif/ppp/polarssl/sha1.h
Normal file
96
src/include/netif/ppp/polarssl/sha1.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* \file sha1.h
|
||||
*
|
||||
* Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
|
||||
*
|
||||
* Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names of PolarSSL or XySSL nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if LWIP_INCLUDED_POLARSSL_SHA1
|
||||
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_SHA1_H
|
||||
#define LWIP_INCLUDED_POLARSSL_SHA1_H
|
||||
|
||||
/**
|
||||
* \brief SHA-1 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned long total[2]; /*!< number of bytes processed */
|
||||
unsigned long state[5]; /*!< intermediate digest state */
|
||||
unsigned char buffer[64]; /*!< data block being processed */
|
||||
}
|
||||
sha1_context;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief SHA-1 context setup
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*/
|
||||
void sha1_starts( sha1_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief SHA-1 process buffer
|
||||
*
|
||||
* \param ctx SHA-1 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*/
|
||||
void sha1_update( sha1_context *ctx, unsigned char *input, int ilen );
|
||||
|
||||
/**
|
||||
* \brief SHA-1 final digest
|
||||
*
|
||||
* \param ctx SHA-1 context
|
||||
* \param output SHA-1 checksum result
|
||||
*/
|
||||
void sha1_finish( sha1_context *ctx, unsigned char output[20] );
|
||||
|
||||
/**
|
||||
* \brief Output = SHA-1( input buffer )
|
||||
*
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
* \param output SHA-1 checksum result
|
||||
*/
|
||||
void sha1( unsigned char *input, int ilen, unsigned char output[20] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */
|
||||
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */
|
||||
608
src/include/netif/ppp/ppp.h
Normal file
608
src/include/netif/ppp/ppp.h
Normal file
@@ -0,0 +1,608 @@
|
||||
/*****************************************************************************
|
||||
* ppp.h - Network Point to Point Protocol header file.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* portions Copyright (c) 1997 Global Election Systems Inc.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
|
||||
* Original derived from BSD codes.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPP_H
|
||||
#define PPP_H
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/sio.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/timers.h"
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#include "lwip/ip6_addr.h"
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
|
||||
|
||||
|
||||
/*************************
|
||||
*** PUBLIC DEFINITIONS ***
|
||||
*************************/
|
||||
|
||||
/*
|
||||
* The basic PPP frame.
|
||||
*/
|
||||
#define PPP_HDRLEN 4 /* octets for standard ppp header */
|
||||
#define PPP_FCSLEN 2 /* octets for FCS */
|
||||
|
||||
/*
|
||||
* Values for phase.
|
||||
*/
|
||||
#define PPP_PHASE_DEAD 0
|
||||
#define PPP_PHASE_INITIALIZE 1
|
||||
#define PPP_PHASE_SERIALCONN 2
|
||||
#define PPP_PHASE_DORMANT 3
|
||||
#define PPP_PHASE_ESTABLISH 4
|
||||
#define PPP_PHASE_AUTHENTICATE 5
|
||||
#define PPP_PHASE_CALLBACK 6
|
||||
#define PPP_PHASE_NETWORK 7
|
||||
#define PPP_PHASE_RUNNING 8
|
||||
#define PPP_PHASE_TERMINATE 9
|
||||
#define PPP_PHASE_DISCONNECT 10
|
||||
#define PPP_PHASE_HOLDOFF 11
|
||||
#define PPP_PHASE_MASTER 12
|
||||
|
||||
/* Error codes. */
|
||||
#define PPPERR_NONE 0 /* No error. */
|
||||
#define PPPERR_PARAM 1 /* Invalid parameter. */
|
||||
#define PPPERR_OPEN 2 /* Unable to open PPP session. */
|
||||
#define PPPERR_DEVICE 3 /* Invalid I/O device for PPP. */
|
||||
#define PPPERR_ALLOC 4 /* Unable to allocate resources. */
|
||||
#define PPPERR_USER 5 /* User interrupt. */
|
||||
#define PPPERR_CONNECT 6 /* Connection lost. */
|
||||
#define PPPERR_AUTHFAIL 7 /* Failed authentication challenge. */
|
||||
#define PPPERR_PROTOCOL 8 /* Failed to meet protocol. */
|
||||
#define PPPERR_PEERDEAD 9 /* Connection timeout */
|
||||
#define PPPERR_IDLETIMEOUT 10 /* Idle Timeout */
|
||||
#define PPPERR_CONNECTTIME 11 /* Max connect time reached */
|
||||
#define PPPERR_LOOPBACK 12 /* Loopback detected */
|
||||
|
||||
/*
|
||||
* PPP IOCTL commands.
|
||||
*/
|
||||
/*
|
||||
* Get the up status - 0 for down, non-zero for up. The argument must
|
||||
* point to an int.
|
||||
*/
|
||||
#define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */
|
||||
#define PPPCTLS_ERRCODE 101 /* Set the error code */
|
||||
#define PPPCTLG_ERRCODE 102 /* Get the error code */
|
||||
#define PPPCTLG_FD 103 /* Get the fd associated with the ppp */
|
||||
|
||||
/************************
|
||||
*** PUBLIC DATA TYPES ***
|
||||
************************/
|
||||
|
||||
/*
|
||||
* 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 struct ppp_pcb_s ppp_pcb;
|
||||
|
||||
/* Type definitions for BSD code. */
|
||||
#ifndef __u_char_defined
|
||||
typedef unsigned long u_long;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned char u_char;
|
||||
#endif
|
||||
|
||||
#include "fsm.h"
|
||||
#include "lcp.h"
|
||||
#include "ipcp.h"
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#include "ipv6cp.h"
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
#if PAP_SUPPORT
|
||||
#include "upap.h"
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
#include "chap-new.h"
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
#include "eap.h"
|
||||
#endif /* EAP_SUPPORT */
|
||||
#if VJ_SUPPORT
|
||||
#include "vj.h"
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
#include "netif/ppp/pppoe.h"
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
#include "netif/ppp/pppol2tp.h"
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
|
||||
/*
|
||||
* PPP configuration.
|
||||
*/
|
||||
typedef struct ppp_settings_s {
|
||||
|
||||
#if PPP_SERVER
|
||||
unsigned int auth_required : 1; /* Peer is required to authenticate */
|
||||
unsigned int null_login : 1; /* Username of "" and a password of "" are acceptable */
|
||||
#else
|
||||
unsigned int :2; /* 2 bits of padding */
|
||||
#endif /* PPP_SERVER */
|
||||
#if PPP_REMOTENAME
|
||||
unsigned int explicit_remote : 1; /* remote_name specified with remotename opt */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* PPP_REMOTENAME */
|
||||
#if PAP_SUPPORT
|
||||
unsigned int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
unsigned int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if MSCHAP_SUPPORT
|
||||
unsigned int refuse_mschap : 1; /* Don't wanna auth. ourselves with MS-CHAP */
|
||||
unsigned int refuse_mschap_v2 : 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */
|
||||
#else
|
||||
unsigned int :2; /* 2 bits of padding */
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
unsigned int refuse_eap : 1; /* Don't wanna auth. ourselves with EAP */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* EAP_SUPPORT */
|
||||
unsigned int usepeerdns : 1; /* Ask peer for DNS adds */
|
||||
unsigned int persist : 1; /* Persist mode, always try to reopen the connection */
|
||||
#if PRINTPKT_SUPPORT
|
||||
unsigned int hide_password : 1; /* Hide password in dumped packets */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#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 */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif
|
||||
unsigned int :1; /* 1 bit of padding to round out to 16 bits */
|
||||
|
||||
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 */
|
||||
|
||||
/* auth data */
|
||||
char *user; /* Username for PAP */
|
||||
char *passwd; /* Password for PAP, secret for CHAP */
|
||||
#if PPP_SERVER
|
||||
char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */
|
||||
#endif /* PPP_SERVER */
|
||||
#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 */
|
||||
|
||||
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;
|
||||
|
||||
struct ppp_addrs {
|
||||
ip_addr_t our_ipaddr, his_ipaddr, netmask;
|
||||
ip_addr_t dns1, dns2;
|
||||
#if PPP_IPV6_SUPPORT
|
||||
ip6_addr_t our6_ipaddr, his6_ipaddr;
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
};
|
||||
|
||||
/* FIXME: find a way to move ppp_dev_states and ppp_pcb_rx_s to ppp_impl.h */
|
||||
#if PPPOS_SUPPORT
|
||||
/*
|
||||
* Extended asyncmap - allows any character to be escaped.
|
||||
*/
|
||||
typedef u_char ext_accm[32];
|
||||
|
||||
/* PPP packet parser states. Current state indicates operation yet to be
|
||||
* completed. */
|
||||
typedef enum {
|
||||
PDIDLE = 0, /* Idle state - waiting. */
|
||||
PDSTART, /* Process start flag. */
|
||||
PDADDRESS, /* Process address field. */
|
||||
PDCONTROL, /* Process control field. */
|
||||
PDPROTOCOL1, /* Process protocol field 1. */
|
||||
PDPROTOCOL2, /* Process protocol field 2. */
|
||||
PDDATA /* Process data byte. */
|
||||
} ppp_dev_states;
|
||||
|
||||
/*
|
||||
* PPP interface RX control block.
|
||||
*/
|
||||
typedef struct ppp_pcb_rx_s {
|
||||
/** ppp descriptor */
|
||||
ppp_pcb *pcb;
|
||||
/** the rx file descriptor */
|
||||
sio_fd_t fd;
|
||||
|
||||
/* The input packet. */
|
||||
struct pbuf *in_head, *in_tail;
|
||||
|
||||
u16_t in_protocol; /* The input protocol code. */
|
||||
u16_t in_fcs; /* Input Frame Check Sequence value. */
|
||||
ppp_dev_states in_state; /* The input process state. */
|
||||
char in_escaped; /* Escape next character. */
|
||||
ext_accm in_accm; /* Async-Ctl-Char-Map for input. */
|
||||
} ppp_pcb_rx;
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
/*
|
||||
* PPP interface control block.
|
||||
*/
|
||||
struct ppp_pcb_s {
|
||||
/* -- below are data that will NOT be cleared between two sessions */
|
||||
#if PPP_DEBUG
|
||||
u8_t num; /* Interface number - only useful for debugging */
|
||||
#endif /* PPP_DEBUG */
|
||||
ppp_settings settings;
|
||||
#if PPPOS_SUPPORT
|
||||
sio_fd_t fd; /* File device ID of port. */
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
#if PPPOE_SUPPORT
|
||||
struct pppoe_softc *pppoe_sc;
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
pppol2tp_pcb *l2tp_pcb;
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
void (*link_status_cb)(ppp_pcb *pcb, int err_code, void *ctx); /* Status change callback */
|
||||
#if PPP_NOTIFY_PHASE
|
||||
void (*notify_phase_cb)(ppp_pcb *pcb, u8_t phase, void *ctx); /* Notify phase callback */
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
void *ctx_cb; /* Callbacks optional pointer */
|
||||
struct netif netif; /* PPP interface */
|
||||
|
||||
/* -- below are data that will be cleared between two sessions */
|
||||
|
||||
/*
|
||||
* phase must be the first member of cleared members, because it is used to know
|
||||
* which part must not be cleared.
|
||||
*/
|
||||
u8_t phase; /* where the link is at */
|
||||
u8_t err_code; /* Code indicating why interface is down. */
|
||||
|
||||
/* flags */
|
||||
unsigned int if_up :1; /* True when the interface is up. */
|
||||
unsigned int pcomp :1; /* Does peer accept protocol compression? */
|
||||
unsigned int accomp :1; /* Does peer accept addr/ctl compression? */
|
||||
unsigned int proxy_arp_set :1; /* Have created proxy arp entry */
|
||||
unsigned int ipcp_is_open :1; /* haven't called np_finished() */
|
||||
unsigned int ipcp_is_up :1; /* have called ipcp_up() */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
unsigned int ipv6cp_is_up :1; /* have called ip6cp_up() */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
unsigned int ask_for_local :1; /* request our address from peer */
|
||||
unsigned int lcp_echo_timer_running :1; /* set if a timer is running */
|
||||
#if PPPOS_SUPPORT && VJ_SUPPORT
|
||||
unsigned int vj_enabled :1; /* Flag indicating VJ compression enabled. */
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* PPPOS_SUPPORT && VJ_SUPPORT */
|
||||
unsigned int :6; /* 5 bits of padding to round out to 16 bits */
|
||||
|
||||
#if PPPOS_SUPPORT
|
||||
/* FIXME: there is probably one superfluous */
|
||||
ext_accm out_accm; /* Async-Ctl-Char-Map for output. */
|
||||
ext_accm xmit_accm; /* extended transmit ACCM */
|
||||
ppp_pcb_rx rx;
|
||||
#if VJ_SUPPORT
|
||||
struct vjcompress vj_comp; /* Van Jacobson compression header. */
|
||||
#endif /* VJ_SUPPORT */
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
u32_t last_xmit; /* Time of last transmission. */
|
||||
|
||||
struct ppp_addrs addrs; /* PPP addresses */
|
||||
|
||||
/* auth data */
|
||||
#if PPP_SERVER
|
||||
char peer_authname[MAXNAMELEN + 1]; /* The name by which the peer authenticated itself to us. */
|
||||
#endif /* PPP_SERVER */
|
||||
u16_t auth_pending; /* Records which authentication operations haven't completed yet. */
|
||||
u16_t auth_done; /* Records which authentication operations have been completed. */
|
||||
u8_t num_np_open; /* Number of network protocols which we have opened. */
|
||||
u8_t num_np_up; /* Number of network protocols which have come up. */
|
||||
|
||||
#if PAP_SUPPORT
|
||||
upap_state upap; /* PAP data */
|
||||
#endif /* PAP_SUPPORT */
|
||||
|
||||
#if CHAP_SUPPORT
|
||||
chap_client_state chap_client; /* CHAP client data */
|
||||
#if PPP_SERVER
|
||||
chap_server_state chap_server; /* CHAP server data */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
#if EAP_SUPPORT
|
||||
eap_state eap; /* EAP data */
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
fsm lcp_fsm; /* LCP fsm structure */
|
||||
lcp_options lcp_wantoptions; /* Options that we want to request */
|
||||
lcp_options lcp_gotoptions; /* Options that peer ack'd */
|
||||
lcp_options lcp_allowoptions; /* Options we allow peer to request */
|
||||
lcp_options lcp_hisoptions; /* Options that we ack'd */
|
||||
u8_t lcp_echos_pending; /* Number of outstanding echo msgs */
|
||||
u8_t lcp_echo_number; /* ID number of next echo frame */
|
||||
u16_t peer_mru; /* currently negotiated peer MRU */
|
||||
|
||||
fsm ipcp_fsm; /* IPCP fsm structure */
|
||||
ipcp_options ipcp_wantoptions; /* Options that we want to request */
|
||||
ipcp_options ipcp_gotoptions; /* Options that peer ack'd */
|
||||
ipcp_options ipcp_allowoptions; /* Options we allow peer to request */
|
||||
ipcp_options ipcp_hisoptions; /* Options that we ack'd */
|
||||
|
||||
#if PPP_IPV6_SUPPORT
|
||||
fsm ipv6cp_fsm; /* IPV6CP fsm structure */
|
||||
ipv6cp_options ipv6cp_wantoptions; /* Options that we want to request */
|
||||
ipv6cp_options ipv6cp_gotoptions; /* Options that peer ack'd */
|
||||
ipv6cp_options ipv6cp_allowoptions; /* Options we allow peer to request */
|
||||
ipv6cp_options ipv6cp_hisoptions; /* Options that we ack'd */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
};
|
||||
|
||||
/************************
|
||||
*** PUBLIC FUNCTIONS ***
|
||||
************************/
|
||||
|
||||
/*
|
||||
* Initialize the PPP subsystem.
|
||||
*/
|
||||
int ppp_init(void);
|
||||
|
||||
/*
|
||||
* Create a new PPP session.
|
||||
*
|
||||
* This initializes the PPP control block but does not
|
||||
* attempt to negotiate the LCP session.
|
||||
*
|
||||
* Return a new PPP connection control block pointer
|
||||
* on success or a null pointer on failure.
|
||||
*/
|
||||
ppp_pcb *ppp_new(void);
|
||||
|
||||
/*
|
||||
* Set a PPP interface as the default network interface
|
||||
* (used to output all packets for which no specific route is found).
|
||||
*/
|
||||
void ppp_set_default(ppp_pcb *pcb);
|
||||
|
||||
/*
|
||||
* Set auth helper, optional, you can either fill ppp_pcb->settings.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#define PPPAUTHTYPE_NONE 0x00
|
||||
#define PPPAUTHTYPE_PAP 0x01
|
||||
#define PPPAUTHTYPE_CHAP 0x02
|
||||
#define PPPAUTHTYPE_MSCHAP 0x04
|
||||
#define PPPAUTHTYPE_EAP 0x08
|
||||
#define PPPAUTHTYPE_ANY 0xff
|
||||
|
||||
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd);
|
||||
|
||||
#if PPP_NOTIFY_PHASE
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx);
|
||||
void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
|
||||
/* Link status callback function prototype */
|
||||
typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx);
|
||||
|
||||
#if PPPOS_SUPPORT
|
||||
/*
|
||||
* Create a new PPP connection using the given serial I/O device.
|
||||
*
|
||||
* If this port connects to a modem, the modem connection must be
|
||||
* established before calling this.
|
||||
*
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
int ppp_over_serial_create(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
/*
|
||||
* Create a new PPP Over Ethernet (PPPoE) connection.
|
||||
*
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
int ppp_over_ethernet_create(ppp_pcb *pcb, struct netif *ethif, const char *service_name, const char *concentrator_name,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
#if PPPOL2TP_SUPPORT
|
||||
/*
|
||||
* Create a new PPP Over L2TP (PPPoL2TP) connection.
|
||||
*/
|
||||
int ppp_over_l2tp_create(ppp_pcb *pcb, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
|
||||
u8_t *secret, u8_t secret_len,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
|
||||
/*
|
||||
* Open 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.
|
||||
*/
|
||||
int ppp_open(ppp_pcb *pcb, u16_t holdoff);
|
||||
|
||||
/*
|
||||
* Initiate the end of a PPP connection.
|
||||
* Any outstanding packets in the queues are dropped.
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
int ppp_close(ppp_pcb *pcb);
|
||||
|
||||
/*
|
||||
* Indicate to the PPP stack that the line has disconnected.
|
||||
*/
|
||||
void ppp_sighup(ppp_pcb *pcb);
|
||||
|
||||
/*
|
||||
* Free the control block, clean everything except the PPP PCB itself
|
||||
* and the netif, it allows you to change the underlying PPP protocol
|
||||
* (eg. from PPPoE to PPPoS to switch from DSL to GPRS) without losing
|
||||
* your PPP and netif handlers.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
int 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.
|
||||
*/
|
||||
int ppp_delete(ppp_pcb *pcb);
|
||||
|
||||
/*
|
||||
* Get and set parameters for the given connection.
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
int ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg);
|
||||
|
||||
#if PPPOS_SUPPORT
|
||||
/*
|
||||
* PPP over Serial: this is the input function to be called for received data.
|
||||
*/
|
||||
void pppos_input(ppp_pcb *pcb, u_char* data, int len);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
/* Get the PPP netif interface */
|
||||
#define ppp_netif(ppp) (&(ppp)->netif)
|
||||
|
||||
/* Get the PPP addresses */
|
||||
#define ppp_addrs(ppp) (&(ppp)->addrs)
|
||||
|
||||
#if LWIP_NETIF_STATUS_CALLBACK
|
||||
/* Set an lwIP-style status-callback for the selected PPP device */
|
||||
void ppp_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback);
|
||||
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||
#if LWIP_NETIF_LINK_CALLBACK
|
||||
/* Set an lwIP-style link-callback for the selected PPP device */
|
||||
void ppp_set_netif_linkcallback(ppp_pcb *pcb, netif_status_callback_fn link_callback);
|
||||
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||
|
||||
#endif /* PPP_H */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
574
src/include/netif/ppp/ppp_impl.h
Normal file
574
src/include/netif/ppp/ppp_impl.h
Normal file
@@ -0,0 +1,574 @@
|
||||
/*****************************************************************************
|
||||
* ppp.h - Network Point to Point Protocol header file.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* portions Copyright (c) 1997 Global Election Systems Inc.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
|
||||
* Original derived from BSD codes.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPP_IMP_H_
|
||||
#define PPP_IMP_H_
|
||||
|
||||
#include <stdio.h> /* formats */
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h> /* strtol() */
|
||||
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/timers.h"
|
||||
#include "lwip/sio.h"
|
||||
|
||||
#include "ppp.h"
|
||||
#include "pppdebug.h"
|
||||
|
||||
/*
|
||||
* Memory used for control packets.
|
||||
*
|
||||
* PPP_CTRL_PBUF_MAX_SIZE is the amount of memory we allocate when we
|
||||
* cannot figure out how much we are going to use before filling the buffer.
|
||||
*/
|
||||
#if PPP_USE_PBUF_RAM
|
||||
#define PPP_CTRL_PBUF_TYPE PBUF_RAM
|
||||
#define PPP_CTRL_PBUF_MAX_SIZE 512
|
||||
#else /* PPP_USE_PBUF_RAM */
|
||||
#define PPP_CTRL_PBUF_TYPE PBUF_POOL
|
||||
#define PPP_CTRL_PBUF_MAX_SIZE PBUF_POOL_BUFSIZE
|
||||
#endif /* PPP_USE_PBUF_RAM */
|
||||
|
||||
/*
|
||||
* Limits.
|
||||
*/
|
||||
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
||||
#define MAXARGS 1 /* max # args to a command */
|
||||
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
||||
#define MAXSECRETLEN 256 /* max length of password or secret */
|
||||
|
||||
/*
|
||||
* The basic PPP frame.
|
||||
*/
|
||||
#define PPP_ADDRESS(p) (((u_char *)(p))[0])
|
||||
#define PPP_CONTROL(p) (((u_char *)(p))[1])
|
||||
#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
|
||||
|
||||
/*
|
||||
* Significant octet values.
|
||||
*/
|
||||
#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
|
||||
#define PPP_UI 0x03 /* Unnumbered Information */
|
||||
#define PPP_FLAG 0x7e /* Flag Sequence */
|
||||
#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
|
||||
#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
|
||||
|
||||
/*
|
||||
* Protocol field values.
|
||||
*/
|
||||
#define PPP_IP 0x21 /* Internet Protocol */
|
||||
#if 0 /* UNUSED */
|
||||
#define PPP_AT 0x29 /* AppleTalk Protocol */
|
||||
#define PPP_IPX 0x2b /* IPX protocol */
|
||||
#endif /* UNUSED */
|
||||
#if VJ_SUPPORT
|
||||
#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
|
||||
#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
|
||||
#endif /* VJ_SUPPORT */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
#if CCP_SUPPORT
|
||||
#define PPP_COMP 0xfd /* compressed packet */
|
||||
#endif /* CCP_SUPPORT */
|
||||
#define PPP_IPCP 0x8021 /* IP Control Protocol */
|
||||
#if 0 /* UNUSED */
|
||||
#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
|
||||
#define PPP_IPXCP 0x802b /* IPX Control Protocol */
|
||||
#endif /* UNUSED */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
#if CCP_SUPPORT
|
||||
#define PPP_CCP 0x80fd /* Compression Control Protocol */
|
||||
#endif /* CCP_SUPPORT */
|
||||
#if ECP_SUPPORT
|
||||
#define PPP_ECP 0x8053 /* Encryption Control Protocol */
|
||||
#endif /* ECP_SUPPORT */
|
||||
#define PPP_LCP 0xc021 /* Link Control Protocol */
|
||||
#if PAP_SUPPORT
|
||||
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if LQR_SUPPORT
|
||||
#define PPP_LQR 0xc025 /* Link Quality Report protocol */
|
||||
#endif /* LQR_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if CBCP_SUPPORT
|
||||
#define PPP_CBCP 0xc029 /* Callback Control Protocol */
|
||||
#endif /* CBCP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
/*
|
||||
* Values for FCS calculations.
|
||||
*/
|
||||
#define PPP_INITFCS 0xffff /* Initial FCS value */
|
||||
#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
|
||||
#if PPP_FCS_TABLE
|
||||
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
|
||||
#else
|
||||
u16_t ppp_get_fcs(u8_t byte);
|
||||
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ ppp_get_fcs(((fcs) ^ (c)) & 0xff))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* What to do with network protocol (NP) packets.
|
||||
*/
|
||||
enum NPmode {
|
||||
NPMODE_PASS, /* pass the packet through */
|
||||
NPMODE_DROP, /* silently drop the packet */
|
||||
NPMODE_ERROR, /* return an error */
|
||||
NPMODE_QUEUE /* save it up for later. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Statistics.
|
||||
*/
|
||||
#if PPP_STATS_SUPPORT
|
||||
struct pppstat {
|
||||
unsigned int ppp_ibytes; /* bytes received */
|
||||
unsigned int ppp_ipackets; /* packets received */
|
||||
unsigned int ppp_ierrors; /* receive errors */
|
||||
unsigned int ppp_obytes; /* bytes sent */
|
||||
unsigned int ppp_opackets; /* packets sent */
|
||||
unsigned int ppp_oerrors; /* transmit errors */
|
||||
};
|
||||
|
||||
#if VJ_SUPPORT
|
||||
struct vjstat {
|
||||
unsigned int vjs_packets; /* outbound packets */
|
||||
unsigned int vjs_compressed; /* outbound compressed packets */
|
||||
unsigned int vjs_searches; /* searches for connection state */
|
||||
unsigned int vjs_misses; /* times couldn't find conn. state */
|
||||
unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
|
||||
unsigned int vjs_compressedin; /* inbound compressed packets */
|
||||
unsigned int vjs_errorin; /* inbound unknown type packets */
|
||||
unsigned int vjs_tossed; /* inbound packets tossed because of error */
|
||||
};
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
struct ppp_stats {
|
||||
struct pppstat p; /* basic PPP statistics */
|
||||
#if VJ_SUPPORT
|
||||
struct vjstat vj; /* VJ header compression statistics */
|
||||
#endif /* VJ_SUPPORT */
|
||||
};
|
||||
|
||||
#if CCP_SUPPORT
|
||||
struct compstat {
|
||||
unsigned int unc_bytes; /* total uncompressed bytes */
|
||||
unsigned int unc_packets; /* total uncompressed packets */
|
||||
unsigned int comp_bytes; /* compressed bytes */
|
||||
unsigned int comp_packets; /* compressed packets */
|
||||
unsigned int inc_bytes; /* incompressible bytes */
|
||||
unsigned int inc_packets; /* incompressible packets */
|
||||
unsigned int ratio; /* recent compression ratio << 8 */
|
||||
};
|
||||
|
||||
struct ppp_comp_stats {
|
||||
struct compstat c; /* packet compression statistics */
|
||||
struct compstat d; /* packet decompression statistics */
|
||||
};
|
||||
#endif /* CCP_SUPPORT */
|
||||
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
#if PPP_IDLETIMELIMIT
|
||||
/*
|
||||
* The following structure records the time in seconds since
|
||||
* the last NP packet was sent or received.
|
||||
*/
|
||||
struct ppp_idle {
|
||||
time_t xmit_idle; /* time since last NP packet sent */
|
||||
time_t recv_idle; /* time since last NP packet received */
|
||||
};
|
||||
#endif /* PPP_IDLETIMELIMIT */
|
||||
|
||||
/* values for epdisc.class */
|
||||
#define EPD_NULL 0 /* null discriminator, no data */
|
||||
#define EPD_LOCAL 1
|
||||
#define EPD_IP 2
|
||||
#define EPD_MAC 3
|
||||
#define EPD_MAGIC 4
|
||||
#define EPD_PHONENUM 5
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
#ifdef HAVE_MULTILINK
|
||||
extern u8_t multilink; /* enable multilink operation */
|
||||
extern u8_t doing_multilink;
|
||||
extern u8_t multilink_master;
|
||||
extern u8_t bundle_eof;
|
||||
extern u8_t bundle_terminating;
|
||||
#endif
|
||||
|
||||
#ifdef MAXOCTETS
|
||||
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
|
||||
extern int maxoctets_dir; /* Direction :
|
||||
0 - in+out (default)
|
||||
1 - in
|
||||
2 - out
|
||||
3 - max(in,out) */
|
||||
extern int maxoctets_timeout; /* Timeout for check of octets limit */
|
||||
#define PPP_OCTETS_DIRECTION_SUM 0
|
||||
#define PPP_OCTETS_DIRECTION_IN 1
|
||||
#define PPP_OCTETS_DIRECTION_OUT 2
|
||||
#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
|
||||
/* same as previos, but little different on RADIUS side */
|
||||
#define PPP_OCTETS_DIRECTION_MAXSESSION 4
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following struct gives the addresses of procedures to call
|
||||
* for a particular protocol.
|
||||
*/
|
||||
struct protent {
|
||||
u_short protocol; /* PPP protocol number */
|
||||
/* Initialization procedure */
|
||||
void (*init) (ppp_pcb *pcb);
|
||||
/* Process a received packet */
|
||||
void (*input) (ppp_pcb *pcb, u_char *pkt, int len);
|
||||
/* Process a received protocol-reject */
|
||||
void (*protrej) (ppp_pcb *pcb);
|
||||
/* Lower layer has come up */
|
||||
void (*lowerup) (ppp_pcb *pcb);
|
||||
/* Lower layer has gone down */
|
||||
void (*lowerdown) (ppp_pcb *pcb);
|
||||
/* Open the protocol */
|
||||
void (*open) (ppp_pcb *pcb);
|
||||
/* Close the protocol */
|
||||
void (*close) (ppp_pcb *pcb, char *reason);
|
||||
#if PRINTPKT_SUPPORT
|
||||
/* Print a packet in readable form */
|
||||
int (*printpkt) (u_char *pkt, int len,
|
||||
void (*printer) (void *, char *, ...),
|
||||
void *arg);
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
/* FIXME: data input is only used by CCP, which is not supported at this time,
|
||||
* should we remove this entry and save some flash ?
|
||||
*/
|
||||
/* Process a received data packet */
|
||||
void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len);
|
||||
u8_t enabled_flag; /* 0 if protocol is disabled */
|
||||
#if PRINTPKT_SUPPORT
|
||||
char *name; /* Text name of protocol */
|
||||
char *data_name; /* Text name of corresponding data protocol */
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
#if PPP_OPTIONS
|
||||
option_t *options; /* List of command-line options */
|
||||
/* Check requested options, assign defaults */
|
||||
void (*check_options) (void);
|
||||
#endif /* PPP_OPTIONS */
|
||||
#if DEMAND_SUPPORT
|
||||
/* Configure interface for demand-dial */
|
||||
int (*demand_conf) (int unit);
|
||||
/* Say whether to bring up link for this pkt */
|
||||
int (*active_pkt) (u_char *pkt, int len);
|
||||
#endif /* DEMAND_SUPPORT */
|
||||
};
|
||||
|
||||
/* Table of pointers to supported protocols */
|
||||
extern const struct protent* const protocols[];
|
||||
|
||||
|
||||
/* Values for auth_pending, auth_done */
|
||||
#if PAP_SUPPORT
|
||||
#define PAP_WITHPEER 0x1
|
||||
#define PAP_PEER 0x2
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
#define CHAP_WITHPEER 0x4
|
||||
#define CHAP_PEER 0x8
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
#define EAP_WITHPEER 0x10
|
||||
#define EAP_PEER 0x20
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
/* Values for auth_done only */
|
||||
#if CHAP_SUPPORT
|
||||
#define CHAP_MD5_WITHPEER 0x40
|
||||
#define CHAP_MD5_PEER 0x80
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
|
||||
#define CHAP_MS_WITHPEER 0x100
|
||||
#define CHAP_MS_PEER 0x200
|
||||
#define CHAP_MS2_WITHPEER 0x400
|
||||
#define CHAP_MS2_PEER 0x800
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
/* Supported CHAP protocols */
|
||||
#if CHAP_SUPPORT
|
||||
#include "chap-new.h"
|
||||
#if MSCHAP_SUPPORT
|
||||
#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
|
||||
#else
|
||||
#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MD5)
|
||||
#endif
|
||||
#else
|
||||
#define CHAP_MDTYPE_SUPPORTED (MDTYPE_NONE)
|
||||
#endif
|
||||
|
||||
#if PPP_STATS_SUPPORT
|
||||
/*
|
||||
* PPP statistics structure
|
||||
*/
|
||||
struct pppd_stats {
|
||||
unsigned int bytes_in;
|
||||
unsigned int bytes_out;
|
||||
unsigned int pkts_in;
|
||||
unsigned int pkts_out;
|
||||
};
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
|
||||
/* PPP flow functions
|
||||
*/
|
||||
/* function called by pppoe.c */
|
||||
void ppp_input(ppp_pcb *pcb, struct pbuf *pb);
|
||||
|
||||
/* function called by all PPP subsystems to send packets */
|
||||
int ppp_write(ppp_pcb *pcb, struct pbuf *p);
|
||||
|
||||
/* functions called by auth.c link_terminated() */
|
||||
void ppp_link_down(ppp_pcb *pcb);
|
||||
void ppp_link_terminated(ppp_pcb *pcb);
|
||||
|
||||
/* merge a pbuf chain into one pbuf */
|
||||
struct pbuf * ppp_singlebuf(struct pbuf *p);
|
||||
|
||||
|
||||
/* Functions called by various PPP subsystems to configure
|
||||
* the PPP interface or change the PPP phase.
|
||||
*/
|
||||
void new_phase(ppp_pcb *pcb, int p);
|
||||
|
||||
#if PPPOS_SUPPORT
|
||||
void ppp_set_xaccm(ppp_pcb *pcb, ext_accm *accm);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp);
|
||||
int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp);
|
||||
|
||||
int sifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr, u32_t net_mask);
|
||||
int cifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr);
|
||||
|
||||
#if PPP_IPV6_SUPPORT
|
||||
int sif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
|
||||
int cif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
|
||||
int sdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2);
|
||||
int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2);
|
||||
|
||||
int sifup(ppp_pcb *pcb);
|
||||
int sifdown (ppp_pcb *pcb);
|
||||
|
||||
int sifnpmode(ppp_pcb *pcb, int proto, enum NPmode mode);
|
||||
|
||||
void netif_set_mtu(ppp_pcb *pcb, int mtu);
|
||||
int netif_get_mtu(ppp_pcb *pcb);
|
||||
|
||||
int sifproxyarp(ppp_pcb *pcb, u32_t his_adr);
|
||||
int cifproxyarp(ppp_pcb *pcb, u32_t his_adr);
|
||||
|
||||
int sifvjcomp(ppp_pcb *pcb, int vjcomp, int cidcomp, int maxcid);
|
||||
|
||||
#if PPP_IDLETIMELIMIT
|
||||
int get_idle_time(ppp_pcb *pcb, struct ppp_idle *ip);
|
||||
#endif /* PPP_IDLETIMELIMIT */
|
||||
|
||||
int get_loop_output(void);
|
||||
|
||||
u32_t get_mask (u32_t addr);
|
||||
|
||||
|
||||
/* Optional protocol names list, to make our messages a little more informative. */
|
||||
#if PPP_PROTOCOLNAME
|
||||
const char * protocol_name(int proto);
|
||||
#endif /* PPP_PROTOCOLNAME */
|
||||
|
||||
|
||||
/* Optional stats support, to get some statistics on the PPP interface */
|
||||
#if PPP_STATS_SUPPORT
|
||||
void print_link_stats(void); /* Print stats, if available */
|
||||
void reset_link_stats(int u); /* Reset (init) stats when link goes up */
|
||||
void update_link_stats(int u); /* Get stats at link termination */
|
||||
#endif /* PPP_STATS_SUPPORT */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Inline versions of get/put char/short/long.
|
||||
* Pointer is advanced; we assume that both arguments
|
||||
* are lvalues and will already be in registers.
|
||||
* cp MUST be u_char *.
|
||||
*/
|
||||
#define GETCHAR(c, cp) { \
|
||||
(c) = *(cp)++; \
|
||||
}
|
||||
#define PUTCHAR(c, cp) { \
|
||||
*(cp)++ = (u_char) (c); \
|
||||
}
|
||||
|
||||
|
||||
#define GETSHORT(s, cp) { \
|
||||
(s) = *(cp)++ << 8; \
|
||||
(s) |= *(cp)++; \
|
||||
}
|
||||
#define PUTSHORT(s, cp) { \
|
||||
*(cp)++ = (u_char) ((s) >> 8); \
|
||||
*(cp)++ = (u_char) (s); \
|
||||
}
|
||||
|
||||
#define GETLONG(l, cp) { \
|
||||
(l) = *(cp)++ << 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; \
|
||||
}
|
||||
#define PUTLONG(l, cp) { \
|
||||
*(cp)++ = (u_char) ((l) >> 24); \
|
||||
*(cp)++ = (u_char) ((l) >> 16); \
|
||||
*(cp)++ = (u_char) ((l) >> 8); \
|
||||
*(cp)++ = (u_char) (l); \
|
||||
}
|
||||
|
||||
#define INCPTR(n, cp) ((cp) += (n))
|
||||
#define DECPTR(n, cp) ((cp) -= (n))
|
||||
|
||||
/*
|
||||
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
||||
*/
|
||||
#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
|
||||
#define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0)
|
||||
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
|
||||
|
||||
#define BZERO(s, n) memset(s, 0, n)
|
||||
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
|
||||
|
||||
#define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); }
|
||||
|
||||
/*
|
||||
* MAKEHEADER - Add Header fields to a packet.
|
||||
*/
|
||||
#define MAKEHEADER(p, t) { \
|
||||
PUTCHAR(PPP_ALLSTATIONS, p); \
|
||||
PUTCHAR(PPP_UI, p); \
|
||||
PUTSHORT(t, p); }
|
||||
|
||||
/* Procedures exported from auth.c */
|
||||
void link_required(ppp_pcb *pcb); /* we are starting to use the link */
|
||||
void link_terminated(ppp_pcb *pcb); /* we are finished with the link */
|
||||
void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */
|
||||
void upper_layers_down(ppp_pcb *pcb); /* take all NCPs down */
|
||||
void link_established(ppp_pcb *pcb); /* the link is up; authenticate now */
|
||||
void start_networks(ppp_pcb *pcb); /* start all the network control protos */
|
||||
void continue_networks(ppp_pcb *pcb); /* start network [ip, etc] control protos */
|
||||
#if PPP_SERVER
|
||||
void auth_peer_fail(ppp_pcb *pcb, int protocol);
|
||||
/* peer failed to authenticate itself */
|
||||
void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, char *name, int namelen);
|
||||
/* peer successfully authenticated itself */
|
||||
#endif /* PPP_SERVER */
|
||||
void auth_withpeer_fail(ppp_pcb *pcb, int protocol);
|
||||
/* we failed to authenticate ourselves */
|
||||
void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor);
|
||||
/* we successfully authenticated ourselves */
|
||||
void np_up(ppp_pcb *pcb, int proto); /* a network protocol has come up */
|
||||
void np_down(ppp_pcb *pcb, int proto); /* a network protocol has gone down */
|
||||
void np_finished(ppp_pcb *pcb, int proto); /* a network protocol no longer needs link */
|
||||
void auth_reset(ppp_pcb *pcb); /* check what secrets we have */
|
||||
int get_secret(ppp_pcb *pcb, char *client, char *server, char *secret, int *secret_len, int am_server);
|
||||
/* get "secret" for chap */
|
||||
|
||||
/* Procedures exported from ipcp.c */
|
||||
/* int parse_dotted_ip (char *, u32_t *); */
|
||||
|
||||
/* Procedures exported from demand.c */
|
||||
#if DEMAND_SUPPORT
|
||||
void demand_conf (void); /* config interface(s) for demand-dial */
|
||||
void demand_block (void); /* set all NPs to queue up packets */
|
||||
void demand_unblock (void); /* set all NPs to pass packets */
|
||||
void demand_discard (void); /* set all NPs to discard packets */
|
||||
void demand_rexmit (int, u32_t); /* retransmit saved frames for an NP*/
|
||||
int loop_chars (unsigned char *, int); /* process chars from loopback */
|
||||
int loop_frame (unsigned char *, int); /* should we bring link up? */
|
||||
#endif /* DEMAND_SUPPORT */
|
||||
|
||||
/* Procedures exported from multilink.c */
|
||||
#ifdef HAVE_MULTILINK
|
||||
void mp_check_options (void); /* Check multilink-related options */
|
||||
int mp_join_bundle (void); /* join our link to an appropriate bundle */
|
||||
void mp_exit_bundle (void); /* have disconnected our link from bundle */
|
||||
void mp_bundle_terminated (void);
|
||||
char *epdisc_to_str (struct epdisc *); /* string from endpoint discrim. */
|
||||
int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */
|
||||
#else
|
||||
#define mp_bundle_terminated() /* nothing */
|
||||
#define mp_exit_bundle() /* nothing */
|
||||
#define doing_multilink 0
|
||||
#define multilink_master 0
|
||||
#endif
|
||||
|
||||
/* Procedures exported from utils.c. */
|
||||
void ppp_print_string(char *p, int len, void (*printer) (void *, char *, ...), void *arg); /* Format a string for output */
|
||||
int ppp_slprintf(char *buf, int buflen, char *fmt, ...); /* sprintf++ */
|
||||
int ppp_vslprintf(char *buf, int buflen, char *fmt, va_list args); /* vsprintf++ */
|
||||
size_t ppp_strlcpy(char *dest, const char *src, size_t len); /* safe strcpy */
|
||||
size_t ppp_strlcat(char *dest, const char *src, size_t len); /* safe strncpy */
|
||||
void ppp_dbglog(char *fmt, ...); /* log a debug message */
|
||||
void ppp_info(char *fmt, ...); /* log an informational message */
|
||||
void ppp_notice(char *fmt, ...); /* log a notice-level message */
|
||||
void ppp_warn(char *fmt, ...); /* log a warning message */
|
||||
void ppp_error(char *fmt, ...); /* log an error message */
|
||||
void ppp_fatal(char *fmt, ...); /* log an error message and die(1) */
|
||||
#if PRINTPKT_SUPPORT
|
||||
void ppp_dump_packet(const char *tag, unsigned char *p, int len);
|
||||
/* dump packet to debug log if interesting */
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
|
||||
|
||||
#endif /* PPP_IMP_H_ */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
43
src/include/netif/ppp/pppcrypt.h
Normal file
43
src/include/netif/ppp/pppcrypt.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1
|
||||
*
|
||||
* Extracted from chap_ms.c by James Carlson.
|
||||
*
|
||||
* Copyright (c) 1995 Eric Rosenquist. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPPCRYPT_H
|
||||
#define PPPCRYPT_H
|
||||
|
||||
void pppcrypt_56_to_64_bit_key(u_char *key, u_char *des_key);
|
||||
|
||||
#endif /* PPPCRYPT_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && MSCHAP_SUPPORT */
|
||||
80
src/include/netif/ppp/pppdebug.h
Normal file
80
src/include/netif/ppp/pppdebug.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************
|
||||
* pppdebug.h - System debugging utilities.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* portions Copyright (c) 1998 Global Election Systems Inc.
|
||||
* portions Copyright (c) 2001 by Cognizant Pty Ltd.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY (please don't use tabs!)
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 98-07-29 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc.
|
||||
* Original.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPPDEBUG_H
|
||||
#define PPPDEBUG_H
|
||||
|
||||
/* Trace levels. */
|
||||
#define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE)
|
||||
#define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE)
|
||||
#define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING)
|
||||
#define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING)
|
||||
#define LOG_INFO (PPP_DEBUG)
|
||||
#define LOG_DETAIL (PPP_DEBUG)
|
||||
#define LOG_DEBUG (PPP_DEBUG)
|
||||
|
||||
#if PPP_DEBUG
|
||||
|
||||
#define MAINDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define SYSDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define FSMDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define LCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define IPCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define IPV6CPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define UPAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define CHAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a)
|
||||
#define PPPDEBUG(a, b) LWIP_DEBUGF(a, b)
|
||||
|
||||
#else /* PPP_DEBUG */
|
||||
|
||||
#define MAINDEBUG(a)
|
||||
#define SYSDEBUG(a)
|
||||
#define FSMDEBUG(a)
|
||||
#define LCPDEBUG(a)
|
||||
#define IPCPDEBUG(a)
|
||||
#define IPV6CPDEBUG(a)
|
||||
#define UPAPDEBUG(a)
|
||||
#define CHAPDEBUG(a)
|
||||
#define PPPDEBUG(a, b)
|
||||
|
||||
#endif /* PPP_DEBUG */
|
||||
|
||||
#endif /* PPPDEBUG_H */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* ppp_oe.h - PPP Over Ethernet implementation for lwIP.
|
||||
* pppoe.h - PPP Over Ethernet implementation for lwIP.
|
||||
*
|
||||
* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
*
|
||||
@@ -67,13 +67,13 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPP_OE_H
|
||||
#define PPP_OE_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if PPPOE_SUPPORT > 0
|
||||
|
||||
#include "ppp.h"
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
@@ -109,10 +109,13 @@ PACK_STRUCT_END
|
||||
#define PPPOE_STATE_PADI_SENT 1
|
||||
#define PPPOE_STATE_PADR_SENT 2
|
||||
#define PPPOE_STATE_SESSION 3
|
||||
#define PPPOE_STATE_CLOSING 4
|
||||
/* passive */
|
||||
#define PPPOE_STATE_PADO_SENT 1
|
||||
|
||||
#define PPPOE_CB_STATE_UP 0 /* PPPoE link is UP */
|
||||
#define PPPOE_CB_STATE_DOWN 1 /* PPPoE link is DOWN - normal condition */
|
||||
#define PPPOE_CB_STATE_FAILED 2 /* Failed to setup PPPoE link */
|
||||
|
||||
#define PPPOE_HEADERLEN sizeof(struct pppoehdr)
|
||||
#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */
|
||||
|
||||
@@ -133,13 +136,6 @@ PACK_STRUCT_END
|
||||
#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */
|
||||
#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */
|
||||
|
||||
#ifndef ETHERMTU
|
||||
#define ETHERMTU 1500
|
||||
#endif
|
||||
|
||||
/* two byte PPP protocol discriminator, then IP data */
|
||||
#define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2)
|
||||
|
||||
#ifndef PPPOE_MAX_AC_COOKIE_LEN
|
||||
#define PPPOE_MAX_AC_COOKIE_LEN 64
|
||||
#endif
|
||||
@@ -147,32 +143,32 @@ PACK_STRUCT_END
|
||||
struct pppoe_softc {
|
||||
struct pppoe_softc *next;
|
||||
struct netif *sc_ethif; /* ethernet interface we are using */
|
||||
int sc_pd; /* ppp unit number */
|
||||
void (*sc_linkStatusCB)(int pd, int up);
|
||||
ppp_pcb *pcb; /* PPP PCB */
|
||||
void (*sc_link_status_cb)(ppp_pcb *pcb, int up);
|
||||
|
||||
int sc_state; /* discovery phase or session connected */
|
||||
struct eth_addr sc_dest; /* hardware address of concentrator */
|
||||
u16_t sc_session; /* PPPoE session id */
|
||||
u8_t sc_state; /* discovery phase or session connected */
|
||||
|
||||
#ifdef PPPOE_TODO
|
||||
char *sc_service_name; /* if != NULL: requested name of service */
|
||||
char *sc_concentrator_name; /* if != NULL: requested concentrator id */
|
||||
u8_t *sc_service_name; /* if != NULL: requested name of service */
|
||||
u8_t *sc_concentrator_name; /* if != NULL: requested concentrator id */
|
||||
#endif /* PPPOE_TODO */
|
||||
u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
|
||||
size_t sc_ac_cookie_len; /* length of cookie data */
|
||||
u8_t sc_ac_cookie_len; /* length of cookie data */
|
||||
#ifdef PPPOE_SERVER
|
||||
u8_t *sc_hunique; /* content of host unique we must echo back */
|
||||
size_t sc_hunique_len; /* length of host unique */
|
||||
u8_t sc_hunique_len; /* length of host unique */
|
||||
#endif
|
||||
int sc_padi_retried; /* number of PADI retries already done */
|
||||
int sc_padr_retried; /* number of PADR retries already done */
|
||||
u8_t sc_padi_retried; /* number of PADI retries already done */
|
||||
u8_t sc_padr_retried; /* number of PADR retries already done */
|
||||
};
|
||||
|
||||
|
||||
#define pppoe_init() /* compatibility define, no initialization needed */
|
||||
|
||||
err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
|
||||
err_t pppoe_destroy(struct netif *ifp);
|
||||
err_t pppoe_create(struct netif *ethif, ppp_pcb *pcb, void (*link_status_cb)(ppp_pcb *pcb, int up), struct pppoe_softc **scptr);
|
||||
err_t pppoe_destroy(struct pppoe_softc *sc);
|
||||
|
||||
int pppoe_connect(struct pppoe_softc *sc);
|
||||
void pppoe_disconnect(struct pppoe_softc *sc);
|
||||
@@ -182,9 +178,6 @@ void pppoe_data_input(struct netif *netif, struct pbuf *p);
|
||||
|
||||
err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb);
|
||||
|
||||
/** used in ppp.c */
|
||||
#define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN)
|
||||
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
#endif /* PPP_OE_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && PPPOE_SUPPORT */
|
||||
217
src/include/netif/ppp/pppol2tp.h
Normal file
217
src/include/netif/ppp/pppol2tp.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* @file
|
||||
* Network Point to Point Protocol over Layer 2 Tunneling Protocol header file.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PPPOL2TP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPPOL2TP_H_
|
||||
#define PPPOL2TP_H_
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/* Timeout */
|
||||
#define PPPOL2TP_CONTROL_TIMEOUT (5*1000) /* base for quick timeout calculation */
|
||||
#define PPPOL2TP_SLOW_RETRY (60*1000) /* persistent retry interval */
|
||||
|
||||
#define PPPOL2TP_MAXSCCRQ 4 /* retry SCCRQ four times (quickly) */
|
||||
#define PPPOL2TP_MAXICRQ 4 /* retry IRCQ four times */
|
||||
#define PPPOL2TP_MAXICCN 4 /* retry ICCN four times */
|
||||
|
||||
/* L2TP header flags */
|
||||
#define PPPOL2TP_HEADERFLAG_CONTROL 0x8000
|
||||
#define PPPOL2TP_HEADERFLAG_LENGTH 0x4000
|
||||
#define PPPOL2TP_HEADERFLAG_SEQUENCE 0x0800
|
||||
#define PPPOL2TP_HEADERFLAG_OFFSET 0x0200
|
||||
#define PPPOL2TP_HEADERFLAG_PRIORITY 0x0100
|
||||
#define PPPOL2TP_HEADERFLAG_VERSION 0x0002
|
||||
|
||||
/* Mandatory bits for control: Control, Length, Sequence, Version 2 */
|
||||
#define PPPOL2TP_HEADERFLAG_CONTROL_MANDATORY (PPPOL2TP_HEADERFLAG_CONTROL|PPPOL2TP_HEADERFLAG_LENGTH|PPPOL2TP_HEADERFLAG_SEQUENCE|PPPOL2TP_HEADERFLAG_VERSION)
|
||||
/* Forbidden bits for control: Offset, Priority */
|
||||
#define PPPOL2TP_HEADERFLAG_CONTROL_FORBIDDEN (PPPOL2TP_HEADERFLAG_OFFSET|PPPOL2TP_HEADERFLAG_PRIORITY)
|
||||
|
||||
/* Mandatory bits for data: Version 2 */
|
||||
#define PPPOL2TP_HEADERFLAG_DATA_MANDATORY (PPPOL2TP_HEADERFLAG_VERSION)
|
||||
|
||||
/* AVP (Attribute Value Pair) header */
|
||||
#define PPPOL2TP_AVPHEADERFLAG_MANDATORY 0x8000
|
||||
#define PPPOL2TP_AVPHEADERFLAG_HIDDEN 0x4000
|
||||
#define PPPOL2TP_AVPHEADERFLAG_LENGTHMASK 0x03ff
|
||||
|
||||
/* -- AVP - Message type */
|
||||
#define PPPOL2TP_AVPTYPE_MESSAGE 0 /* Message type */
|
||||
|
||||
/* Control Connection Management */
|
||||
#define PPPOL2TP_MESSAGETYPE_SCCRQ 1 /* Start Control Connection Request */
|
||||
#define PPPOL2TP_MESSAGETYPE_SCCRP 2 /* Start Control Connection Reply */
|
||||
#define PPPOL2TP_MESSAGETYPE_SCCCN 3 /* Start Control Connection Connected */
|
||||
#define PPPOL2TP_MESSAGETYPE_STOPCCN 4 /* Stop Control Connection Notification */
|
||||
#define PPPOL2TP_MESSAGETYPE_HELLO 6 /* Hello */
|
||||
/* Call Management */
|
||||
#define PPPOL2TP_MESSAGETYPE_OCRQ 7 /* Outgoing Call Request */
|
||||
#define PPPOL2TP_MESSAGETYPE_OCRP 8 /* Outgoing Call Reply */
|
||||
#define PPPOL2TP_MESSAGETYPE_OCCN 9 /* Outgoing Call Connected */
|
||||
#define PPPOL2TP_MESSAGETYPE_ICRQ 10 /* Incoming Call Request */
|
||||
#define PPPOL2TP_MESSAGETYPE_ICRP 11 /* Incoming Call Reply */
|
||||
#define PPPOL2TP_MESSAGETYPE_ICCN 12 /* Incoming Call Connected */
|
||||
#define PPPOL2TP_MESSAGETYPE_CDN 14 /* Call Disconnect Notify */
|
||||
/* Error reporting */
|
||||
#define PPPOL2TP_MESSAGETYPE_WEN 15 /* WAN Error Notify */
|
||||
/* PPP Session Control */
|
||||
#define PPPOL2TP_MESSAGETYPE_SLI 16 /* Set Link Info */
|
||||
|
||||
/* -- AVP - Result code */
|
||||
#define PPPOL2TP_AVPTYPE_RESULTCODE 1 /* Result code */
|
||||
#define PPPOL2TP_RESULTCODE 1 /* General request to clear control connection */
|
||||
|
||||
/* -- AVP - Protocol version (!= L2TP Header version) */
|
||||
#define PPPOL2TP_AVPTYPE_VERSION 2
|
||||
#define PPPOL2TP_VERSION 0x0100 /* L2TP Protocol version 1, revision 0 */
|
||||
|
||||
/* -- AVP - Framing capabilities */
|
||||
#define PPPOL2TP_AVPTYPE_FRAMINGCAPABILITIES 3 /* Bearer capabilities */
|
||||
#define PPPOL2TP_FRAMINGCAPABILITIES 0x00000003 /* Async + Sync framing */
|
||||
|
||||
/* -- AVP - Bearer capabilities */
|
||||
#define PPPOL2TP_AVPTYPE_BEARERCAPABILITIES 4 /* Bearer capabilities */
|
||||
#define PPPOL2TP_BEARERCAPABILITIES 0x00000003 /* Analog + Digital Access */
|
||||
|
||||
/* -- AVP - Tie breaker */
|
||||
#define PPPOL2TP_AVPTYPE_TIEBREAKER 5
|
||||
|
||||
/* -- AVP - Host name */
|
||||
#define PPPOL2TP_AVPTYPE_HOSTNAME 7 /* Host name */
|
||||
#define PPPOL2TP_HOSTNAME "lwIP" /* FIXME: make it configurable */
|
||||
|
||||
/* -- AVP - Vendor name */
|
||||
#define PPPOL2TP_AVPTYPE_VENDORNAME 8 /* Vendor name */
|
||||
#define PPPOL2TP_VENDORNAME "lwIP" /* FIXME: make it configurable */
|
||||
|
||||
/* -- AVP - Assign tunnel ID */
|
||||
#define PPPOL2TP_AVPTYPE_TUNNELID 9 /* Assign Tunnel ID */
|
||||
|
||||
/* -- AVP - Receive window size */
|
||||
#define PPPOL2TP_AVPTYPE_RECEIVEWINDOWSIZE 10 /* Receive window size */
|
||||
#define PPPOL2TP_RECEIVEWINDOWSIZE 8 /* FIXME: make it configurable */
|
||||
|
||||
/* -- AVP - Challenge */
|
||||
#define PPPOL2TP_AVPTYPE_CHALLENGE 11 /* Challenge */
|
||||
|
||||
/* -- AVP - Cause code */
|
||||
#define PPPOL2TP_AVPTYPE_CAUSECODE 12 /* Cause code*/
|
||||
|
||||
/* -- AVP - Challenge response */
|
||||
#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE 13 /* Challenge response */
|
||||
#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE_SIZE 16
|
||||
|
||||
/* -- AVP - Assign session ID */
|
||||
#define PPPOL2TP_AVPTYPE_SESSIONID 14 /* Assign Session ID */
|
||||
|
||||
/* -- AVP - Call serial number */
|
||||
#define PPPOL2TP_AVPTYPE_CALLSERIALNUMBER 15 /* Call Serial Number */
|
||||
|
||||
/* -- AVP - Framing type */
|
||||
#define PPPOL2TP_AVPTYPE_FRAMINGTYPE 19 /* Framing Type */
|
||||
#define PPPOL2TP_FRAMINGTYPE 0x00000001 /* Sync framing */
|
||||
|
||||
/* -- AVP - TX Connect Speed */
|
||||
#define PPPOL2TP_AVPTYPE_TXCONNECTSPEED 24 /* TX Connect Speed */
|
||||
#define PPPOL2TP_TXCONNECTSPEED 100000000 /* Connect speed: 100 Mbits/s */
|
||||
|
||||
/* L2TP Session state */
|
||||
#define PPPOL2TP_STATE_INITIAL 0
|
||||
#define PPPOL2TP_STATE_SCCRQ_SENT 1
|
||||
#define PPPOL2TP_STATE_ICRQ_SENT 2
|
||||
#define PPPOL2TP_STATE_ICCN_SENT 3
|
||||
#define PPPOL2TP_STATE_DATA 4
|
||||
|
||||
#define PPPOL2TP_CB_STATE_UP 0 /* PPPoL2TP link is UP */
|
||||
#define PPPOL2TP_CB_STATE_DOWN 1 /* PPPo2TP link is DOWN - normal condition */
|
||||
#define PPPOL2TP_CB_STATE_FAILED 2 /* Failed to setup PPPo2TP link */
|
||||
|
||||
#define PPPOL2TP_OUTPUT_DATA_HEADER_LEN 6 /* Our data header len */
|
||||
|
||||
/*
|
||||
* PPPoL2TP interface control block.
|
||||
*/
|
||||
typedef struct pppol2tp_pcb_s pppol2tp_pcb;
|
||||
struct pppol2tp_pcb_s {
|
||||
ppp_pcb *ppp; /* PPP PCB */
|
||||
u8_t phase; /* L2TP phase */
|
||||
void (*link_status_cb)(ppp_pcb *pcb, int status);
|
||||
struct udp_pcb *udp; /* UDP L2TP Socket */
|
||||
struct netif *netif; /* Output interface, used as a default route */
|
||||
ip_addr_t remote_ip; /* LNS IP Address */
|
||||
u16_t remote_port; /* LNS port */
|
||||
#if PPPOL2TP_AUTH_SUPPORT
|
||||
u8_t *secret; /* Secret string */
|
||||
u8_t secret_len; /* Secret string length */
|
||||
u8_t secret_rv[16]; /* Random vector */
|
||||
u8_t challenge_hash[16]; /* Challenge response */
|
||||
u8_t send_challenge; /* Boolean whether the next sent packet should contains a challenge response */
|
||||
#endif /* PPPOL2TP_AUTH_SUPPORT */
|
||||
|
||||
u16_t tunnel_port; /* Tunnel port */
|
||||
u16_t our_ns; /* NS to peer */
|
||||
u16_t peer_nr; /* NR from peer */
|
||||
u16_t peer_ns; /* NS from peer */
|
||||
u16_t source_tunnel_id; /* Tunnel ID assigned by peer */
|
||||
u16_t remote_tunnel_id; /* Tunnel ID assigned to peer */
|
||||
u16_t source_session_id; /* Session ID assigned by peer */
|
||||
u16_t remote_session_id; /* Session ID assigned to peer */
|
||||
|
||||
u8_t sccrq_retried; /* number of SCCRQ retries already done */
|
||||
u8_t icrq_retried; /* number of ICRQ retries already done */
|
||||
u8_t iccn_retried; /* number of ICCN retries already done */
|
||||
};
|
||||
|
||||
|
||||
/* Create a new L2TP session. */
|
||||
err_t pppol2tp_create(ppp_pcb *ppp, void (*link_status_cb)(ppp_pcb *pcb, int status), pppol2tp_pcb **l2tpptr,
|
||||
struct netif *netif, ip_addr_t *ipaddr, u16_t port,
|
||||
u8_t *secret, u8_t secret_len);
|
||||
|
||||
/* Destroy a L2TP control block */
|
||||
err_t pppol2tp_destroy(pppol2tp_pcb *l2tp);
|
||||
|
||||
/* Be a LAC, connect to a LNS. */
|
||||
err_t pppol2tp_connect(pppol2tp_pcb *l2tp);
|
||||
|
||||
/* Disconnect */
|
||||
void pppol2tp_disconnect(pppol2tp_pcb *l2tp);
|
||||
|
||||
/* Data packet from PPP to L2TP */
|
||||
err_t pppol2tp_xmit(pppol2tp_pcb *l2tp, struct pbuf *pb);
|
||||
|
||||
#endif /* PPPOL2TP_H_ */
|
||||
#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */
|
||||
123
src/include/netif/ppp/upap.h
Normal file
123
src/include/netif/ppp/upap.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* upap.h - User/Password Authentication Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: upap.h,v 1.8 2002/12/04 23:03:33 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef UPAP_H
|
||||
#define UPAP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define UPAP_HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* UPAP codes.
|
||||
*/
|
||||
#define UPAP_AUTHREQ 1 /* Authenticate-Request */
|
||||
#define UPAP_AUTHACK 2 /* Authenticate-Ack */
|
||||
#define UPAP_AUTHNAK 3 /* Authenticate-Nak */
|
||||
|
||||
|
||||
/*
|
||||
* Client states.
|
||||
*/
|
||||
#define UPAPCS_INITIAL 0 /* Connection down */
|
||||
#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */
|
||||
#define UPAPCS_PENDING 2 /* Connection down, have requested auth */
|
||||
#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */
|
||||
#define UPAPCS_OPEN 4 /* We've received an Ack */
|
||||
#define UPAPCS_BADAUTH 5 /* We've received a Nak */
|
||||
|
||||
/*
|
||||
* Server states.
|
||||
*/
|
||||
#define UPAPSS_INITIAL 0 /* Connection down */
|
||||
#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */
|
||||
#define UPAPSS_PENDING 2 /* Connection down, have requested auth */
|
||||
#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */
|
||||
#define UPAPSS_OPEN 4 /* We've sent an Ack */
|
||||
#define UPAPSS_BADAUTH 5 /* We've sent a Nak */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#if 0 /* moved to opt.h */
|
||||
#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */
|
||||
#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */
|
||||
#endif /* moved to opt.h */
|
||||
|
||||
/*
|
||||
* Each interface is described by upap structure.
|
||||
*/
|
||||
#if PAP_SUPPORT
|
||||
typedef struct upap_state {
|
||||
char *us_user; /* User */
|
||||
u8_t us_userlen; /* User length */
|
||||
char *us_passwd; /* Password */
|
||||
u8_t us_passwdlen; /* Password length */
|
||||
u8_t us_clientstate; /* Client state */
|
||||
#if PPP_SERVER
|
||||
u8_t us_serverstate; /* Server state */
|
||||
#endif /* PPP_SERVER */
|
||||
u8_t us_id; /* Current id */
|
||||
u8_t us_transmits; /* Number of auth-reqs sent */
|
||||
} upap_state;
|
||||
#endif /* PAP_SUPPORT */
|
||||
|
||||
|
||||
void upap_authwithpeer(ppp_pcb *pcb, char *user, char *password);
|
||||
#if PPP_SERVER
|
||||
void upap_authpeer(ppp_pcb *pcb);
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
extern const struct protent pap_protent;
|
||||
|
||||
#endif /* UPAP_H */
|
||||
#endif /* PPP_SUPPORT && PAP_SUPPORT */
|
||||
161
src/include/netif/ppp/vj.h
Normal file
161
src/include/netif/ppp/vj.h
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Definitions for tcp compression routines.
|
||||
*
|
||||
* $Id: vj.h,v 1.7 2010/02/22 17:52:09 goldsimon Exp $
|
||||
*
|
||||
* Copyright (c) 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT && VJ_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef VJ_H
|
||||
#define VJ_H
|
||||
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/tcp_impl.h"
|
||||
|
||||
#define MAX_SLOTS 16 /* must be > 2 and < 256 */
|
||||
#define MAX_HDR 128
|
||||
|
||||
/*
|
||||
* Compressed packet format:
|
||||
*
|
||||
* The first octet contains the packet type (top 3 bits), TCP
|
||||
* 'push' bit, and flags that indicate which of the 4 TCP sequence
|
||||
* numbers have changed (bottom 5 bits). The next octet is a
|
||||
* conversation number that associates a saved IP/TCP header with
|
||||
* the compressed packet. The next two octets are the TCP checksum
|
||||
* from the original datagram. The next 0 to 15 octets are
|
||||
* sequence number changes, one change per bit set in the header
|
||||
* (there may be no changes and there are two special cases where
|
||||
* the receiver implicitly knows what changed -- see below).
|
||||
*
|
||||
* There are 5 numbers which can change (they are always inserted
|
||||
* in the following order): TCP urgent pointer, window,
|
||||
* acknowlegement, sequence number and IP ID. (The urgent pointer
|
||||
* is different from the others in that its value is sent, not the
|
||||
* change in value.) Since typical use of SLIP links is biased
|
||||
* toward small packets (see comments on MTU/MSS below), changes
|
||||
* use a variable length coding with one octet for numbers in the
|
||||
* range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
|
||||
* range 256 - 65535 or 0. (If the change in sequence number or
|
||||
* ack is more than 65535, an uncompressed packet is sent.)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet types (must not conflict with IP protocol version)
|
||||
*
|
||||
* The top nibble of the first octet is the packet type. There are
|
||||
* three possible types: IP (not proto TCP or tcp with one of the
|
||||
* control flags set); uncompressed TCP (a normal IP/TCP packet but
|
||||
* with the 8-bit protocol field replaced by an 8-bit connection id --
|
||||
* this type of packet syncs the sender & receiver); and compressed
|
||||
* TCP (described above).
|
||||
*
|
||||
* LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
|
||||
* is logically part of the 4-bit "changes" field that follows. Top
|
||||
* three bits are actual packet type. For backward compatibility
|
||||
* and in the interest of conserving bits, numbers are chosen so the
|
||||
* IP protocol version number (4) which normally appears in this nibble
|
||||
* means "IP packet".
|
||||
*/
|
||||
|
||||
/* packet types */
|
||||
#define TYPE_IP 0x40
|
||||
#define TYPE_UNCOMPRESSED_TCP 0x70
|
||||
#define TYPE_COMPRESSED_TCP 0x80
|
||||
#define TYPE_ERROR 0x00
|
||||
|
||||
/* Bits in first octet of compressed packet */
|
||||
#define NEW_C 0x40 /* flag bits for what changed in a packet */
|
||||
#define NEW_I 0x20
|
||||
#define NEW_S 0x08
|
||||
#define NEW_A 0x04
|
||||
#define NEW_W 0x02
|
||||
#define NEW_U 0x01
|
||||
|
||||
/* reserved, special-case values of above */
|
||||
#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
|
||||
#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
|
||||
#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
|
||||
|
||||
#define TCP_PUSH_BIT 0x10
|
||||
|
||||
|
||||
/*
|
||||
* "state" data for each active tcp conversation on the wire. This is
|
||||
* basically a copy of the entire IP/TCP header from the last packet
|
||||
* we saw from the conversation together with a small identifier
|
||||
* the transmit & receive ends of the line use to locate saved header.
|
||||
*/
|
||||
struct cstate {
|
||||
struct cstate *cs_next; /* next most recently used state (xmit only) */
|
||||
u_short cs_hlen; /* size of hdr (receive only) */
|
||||
u_char cs_id; /* connection # associated with this state */
|
||||
u_char cs_filler;
|
||||
union {
|
||||
char csu_hdr[MAX_HDR];
|
||||
struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */
|
||||
} vjcs_u;
|
||||
};
|
||||
#define cs_ip vjcs_u.csu_ip
|
||||
#define cs_hdr vjcs_u.csu_hdr
|
||||
|
||||
|
||||
struct vjstat {
|
||||
unsigned long vjs_packets; /* outbound packets */
|
||||
unsigned long vjs_compressed; /* outbound compressed packets */
|
||||
unsigned long vjs_searches; /* searches for connection state */
|
||||
unsigned long vjs_misses; /* times couldn't find conn. state */
|
||||
unsigned long vjs_uncompressedin; /* inbound uncompressed packets */
|
||||
unsigned long vjs_compressedin; /* inbound compressed packets */
|
||||
unsigned long vjs_errorin; /* inbound unknown type packets */
|
||||
unsigned long vjs_tossed; /* inbound packets tossed because of error */
|
||||
};
|
||||
|
||||
/*
|
||||
* all the state data for one serial line (we need one of these per line).
|
||||
*/
|
||||
struct vjcompress {
|
||||
struct cstate *last_cs; /* most recently used tstate */
|
||||
u_char last_recv; /* last rcvd conn. id */
|
||||
u_char last_xmit; /* last sent conn. id */
|
||||
u_short flags;
|
||||
u_char maxSlotIndex;
|
||||
u_char compressSlot; /* Flag indicating OK to compress slot ID. */
|
||||
#if LINK_STATS
|
||||
struct vjstat stats;
|
||||
#endif
|
||||
struct cstate tstate[MAX_SLOTS]; /* xmit connection states */
|
||||
struct cstate rstate[MAX_SLOTS]; /* receive connection states */
|
||||
};
|
||||
|
||||
/* flag values */
|
||||
#define VJF_TOSS 1U /* tossing rcvd frames because of input err */
|
||||
|
||||
extern void vj_compress_init (struct vjcompress *comp);
|
||||
extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb);
|
||||
extern void vj_uncompress_err (struct vjcompress *comp);
|
||||
extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp);
|
||||
extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp);
|
||||
|
||||
#endif /* VJ_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && VJ_SUPPORT */
|
||||
Reference in New Issue
Block a user