Update IDF to 3.2-3276a13 and esptool.py to 2.5.0 (#1878)

* TX Flow Control and Code cleanup

* Use semaphore instead of delay

TX functionality is done.

* Use single buffer and empty queue on exit

* Fix compile issues because of LwIP code relocation

* Add temporary header to fix Azure not compiling

* Fix AsyncUDP early init

* AsyncUDP Multicast fixes

* Add source mac address and rework multicast

* Allow redefinition of default pins for Serials 1 and 2

* Update IDF to 3276a13

* Update esptool.py to 2.5.0

* Fix sketches

* Fix log level in BluetoothSetial
This commit is contained in:
Me No Dev
2018-09-21 08:39:36 +02:00
committed by GitHub
parent 4e96bffe0e
commit 96822d783f
447 changed files with 37993 additions and 10849 deletions

View File

@ -0,0 +1,33 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _DHCP_STATE_H_
#define _DHCP_STATE_H_
#ifdef __cplusplus
extern "C" {
#endif
bool dhcp_ip_addr_restore(void *netif);
void dhcp_ip_addr_store(void *netif);
void dhcp_ip_addr_erase(void *netif);
#ifdef __cplusplus
}
#endif
#endif /* _DHCP_STATE_H_ */

View File

@ -1,147 +1,3 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
* Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
* 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 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.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#ifndef LWIP_HDR_NETIF_ETHARP_H
#define LWIP_HDR_NETIF_ETHARP_H
#include "lwip/opt.h"
#if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */
#include "lwip/pbuf.h"
#include "lwip/ip4_addr.h"
#include "lwip/netif.h"
#include "lwip/ip4.h"
/* ARP has been moved to core/ipv4, provide this #include for compatibility only */
#include "lwip/etharp.h"
#include "netif/ethernet.h"
#ifdef __cplusplus
extern "C" {
#endif
#if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */
#ifndef ETHARP_HWADDR_LEN
#define ETHARP_HWADDR_LEN ETH_HWADDR_LEN
#endif
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
PACK_STRUCT_BEGIN
/** the ARP message, see RFC 826 ("Packet format") */
struct etharp_hdr {
PACK_STRUCT_FIELD(u16_t hwtype);
PACK_STRUCT_FIELD(u16_t proto);
PACK_STRUCT_FLD_8(u8_t hwlen);
PACK_STRUCT_FLD_8(u8_t protolen);
PACK_STRUCT_FIELD(u16_t opcode);
PACK_STRUCT_FLD_S(struct eth_addr shwaddr);
PACK_STRUCT_FLD_S(struct ip4_addr2 sipaddr);
PACK_STRUCT_FLD_S(struct eth_addr dhwaddr);
PACK_STRUCT_FLD_S(struct ip4_addr2 dipaddr);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h"
#endif
#define SIZEOF_ETHARP_HDR 28
#define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
#if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET)
#define SIZEOF_ETHARP_PACKET_TX (SIZEOF_ETHARP_PACKET + SIZEOF_VLAN_HDR)
#else /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */
#define SIZEOF_ETHARP_PACKET_TX SIZEOF_ETHARP_PACKET
#endif /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */
/** 1 seconds period */
#define ARP_TMR_INTERVAL 1000
/** ARP message types (opcodes) */
#define ARP_REQUEST 1
#define ARP_REPLY 2
#if ARP_QUEUEING
/** struct for queueing outgoing packets for unknown address
* defined here to be accessed by memp.h
*/
struct etharp_q_entry {
struct etharp_q_entry *next;
struct pbuf *p;
};
#endif /* ARP_QUEUEING */
#define etharp_init() /* Compatibility define, no init needed. */
void etharp_tmr(void);
s8_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
struct eth_addr **eth_ret, const ip4_addr_t **ip_ret);
u8_t etharp_get_entry(u8_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_addr **eth_ret);
err_t etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
err_t etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q);
err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr);
/** For Ethernet network interfaces, we might want to send "gratuitous ARP";
* this is an ARP packet sent by a node in order to spontaneously cause other
* nodes to update an entry in their ARP cache.
* From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
#define etharp_gratuitous(netif) etharp_request((netif), netif_ip4_addr(netif))
void etharp_cleanup_netif(struct netif *netif);
#if ETHARP_SUPPORT_STATIC_ENTRIES
err_t etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr);
err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr);
#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
#if LWIP_AUTOIP
err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
const struct eth_addr *ethdst_addr,
const struct eth_addr *hwsrc_addr, const ip4_addr_t *ipsrc_addr,
const struct eth_addr *hwdst_addr, const ip4_addr_t *ipdst_addr,
const u16_t opcode);
#endif /* LWIP_AUTOIP */
#endif /* LWIP_IPV4 && LWIP_ARP */
void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p);
#if ETHARP_TRUST_IP_MAC
void etharp_ip_input(struct netif *netif, struct pbuf *p);
#endif
#ifdef __cplusplus
}
#endif
#endif /* LWIP_ARP || LWIP_ETHERNET */
#endif /* LWIP_HDR_NETIF_ETHARP_H */

View File

@ -1,3 +1,9 @@
/**
* @file
* Ethernet input function - handles INCOMING ethernet level traffic
* To be used in most low-level netif implementations
*/
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
@ -39,111 +45,12 @@
#include "lwip/pbuf.h"
#include "lwip/netif.h"
#include "lwip/prot/ethernet.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ETH_HWADDR_LEN
#ifdef ETHARP_HWADDR_LEN
#define ETH_HWADDR_LEN ETHARP_HWADDR_LEN /* compatibility mode */
#else
#define ETH_HWADDR_LEN 6
#endif
#endif
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
PACK_STRUCT_BEGIN
struct eth_addr {
PACK_STRUCT_FLD_8(u8_t addr[ETH_HWADDR_LEN]);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h"
#endif
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
PACK_STRUCT_BEGIN
/** Ethernet header */
struct eth_hdr {
#if ETH_PAD_SIZE
PACK_STRUCT_FLD_8(u8_t padding[ETH_PAD_SIZE]);
#endif
PACK_STRUCT_FLD_S(struct eth_addr dest);
PACK_STRUCT_FLD_S(struct eth_addr src);
PACK_STRUCT_FIELD(u16_t type);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h"
#endif
#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE)
#if ETHARP_SUPPORT_VLAN
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
PACK_STRUCT_BEGIN
/** VLAN header inserted between ethernet header and payload
* if 'type' in ethernet header is ETHTYPE_VLAN.
* See IEEE802.Q */
struct eth_vlan_hdr {
PACK_STRUCT_FIELD(u16_t prio_vid);
PACK_STRUCT_FIELD(u16_t tpid);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h"
#endif
#define SIZEOF_VLAN_HDR 4
#define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF)
#endif /* ETHARP_SUPPORT_VLAN */
/* A list of often ethtypes (although lwIP does not use all of them): */
#define ETHTYPE_IP 0x0800U /* Internet protocol v4 */
#define ETHTYPE_ARP 0x0806U /* Address resolution protocol */
#define ETHTYPE_WOL 0x0842U /* Wake on lan */
#define ETHTYPE_VLAN 0x8100U /* Virtual local area network */
#define ETHTYPE_IPV6 0x86DDU /* Internet protocol v6 */
#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */
#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */
#define ETHTYPE_JUMBO 0x8870U /* Jumbo Frames */
#define ETHTYPE_PROFINET 0x8892U /* Process field network */
#define ETHTYPE_ETHERCAT 0x88A4U /* Ethernet for control automation technology */
#define ETHTYPE_LLDP 0x88CCU /* Link layer discovery protocol */
#define ETHTYPE_SERCOS 0x88CDU /* Serial real-time communication system */
#define ETHTYPE_PTP 0x88F7U /* Precision time protocol */
#define ETHTYPE_QINQ 0x9100U /* Q-in-Q, 802.1ad */
/** The 24-bit IANA IPv4-multicast OUI is 01-00-5e: */
#define LL_IP4_MULTICAST_ADDR_0 0x01
#define LL_IP4_MULTICAST_ADDR_1 0x00
#define LL_IP4_MULTICAST_ADDR_2 0x5e
/** IPv6 multicast uses this prefix */
#define LL_IP6_MULTICAST_ADDR_0 0x33
#define LL_IP6_MULTICAST_ADDR_1 0x33
/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables
* or known to be 32-bit aligned within the protocol header. */
#ifndef ETHADDR32_COPY
#define ETHADDR32_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN)
#endif
/** MEMCPY-like macro to copy to/from struct eth_addr's that are no local
* variables and known to be 16-bit aligned within the protocol header. */
#ifndef ETHADDR16_COPY
#define ETHADDR16_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN)
#endif
#if LWIP_ARP || LWIP_ETHERNET
/** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type)
@ -157,8 +64,7 @@ PACK_STRUCT_END
#endif
err_t ethernet_input(struct pbuf *p, struct netif *netif);
#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETH_HWADDR_LEN) == 0)
err_t ethernet_output(struct netif* netif, struct pbuf* p, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type);
extern const struct eth_addr ethbroadcast, ethzero;

View File

@ -73,7 +73,9 @@ err_t lowpan6_if_init(struct netif *netif);
/* pan_id in network byte order. */
err_t lowpan6_set_pan_id(u16_t pan_id);
#if !NO_SYS
err_t tcpip_6lowpan_input(struct pbuf *p, struct netif *inp);
#endif /* !NO_SYS */
#ifdef __cplusplus
}

View File

@ -1,3 +1,8 @@
/**
* @file
* 6LowPAN options list
*/
/*
* Copyright (c) 2015 Inico Technologies Ltd.
* All rights reserved.

View File

@ -30,7 +30,7 @@
* $Id: ccp.h,v 1.12 2004/11/04 10:02:26 paulus Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && CCP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef CCP_H

View File

@ -28,7 +28,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.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;

View File

@ -28,7 +28,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef CHAP_H

View File

@ -30,15 +30,15 @@
* $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef __CHAPMS_INCLUDE__
#ifndef CHAPMS_INCLUDE
#define CHAPMS_INCLUDE
extern const struct chap_digest_type chapms_digest;
extern const struct chap_digest_type chapms2_digest;
#define __CHAPMS_INCLUDE__
#endif /* __CHAPMS_INCLUDE__ */
#endif /* CHAPMS_INCLUDE */
#endif /* PPP_SUPPORT && MSCHAP_SUPPORT */

View File

@ -20,7 +20,7 @@
* $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef PPP_EAP_H
@ -148,12 +148,12 @@ typedef struct eap_state {
/*
* Timeouts.
*/
#if 0 /* moved to opt.h */
#if 0 /* moved to ppp_opts.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 */
#endif /* moved to ppp_opts.h */
void eap_authwithpeer(ppp_pcb *pcb, const char *localname);
void eap_authpeer(ppp_pcb *pcb, const char *localname);

View File

@ -31,7 +31,7 @@
* $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */
typedef struct ecp_options {

View File

@ -35,14 +35,14 @@
* $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef __EUI64_H__
#define __EUI64_H__
#ifndef EUI64_H
#define EUI64_H
/*
* TODO:
* @todo:
*
* Maybe this should be done by processing struct in6_addr directly...
*/
@ -84,11 +84,11 @@ typedef union
#define eui64_set32(e, l) do { \
(e).e32[0] = 0; \
(e).e32[1] = htonl(l); \
(e).e32[1] = lwip_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 /* EUI64_H */
#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */

View File

@ -42,7 +42,7 @@
* $Id: fsm.h,v 1.10 2004/11/13 02:28:15 paulus Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef FSM_H
@ -150,12 +150,12 @@ typedef struct fsm_callbacks {
/*
* Timeouts.
*/
#if 0 /* moved to opt.h */
#if 0 /* moved to ppp_opts.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 */
#endif /* moved to ppp_opts.h */
/*

View File

@ -42,7 +42,7 @@
* $Id: ipcp.h,v 1.14 2002/12/04 23:03:32 paulus Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && PPP_IPV4_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef IPCP_H

View File

@ -138,7 +138,7 @@
* $Id: ipv6cp.h,v 1.7 2002/12/04 23:03:32 paulus Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef IPV6CP_H

View File

@ -42,7 +42,7 @@
* $Id: lcp.h,v 1.20 2004/11/14 22:53:42 carlsonj Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef LCP_H
@ -90,11 +90,11 @@
/* Value used as data for CI_CALLBACK option */
#define CBCP_OPT 6 /* Use callback control protocol */
#if 0 /* moved to opt.h */
#if 0 /* moved to ppp_opts.h */
#define DEFMRU 1500 /* Try for this */
#define MINMRU 128 /* No MRUs below this */
#define MAXMRU 16384 /* Normally limit MRU to this */
#endif /* moved to opt.h */
#endif /* moved to ppp_opts.h */
/* An endpoint discriminator, used with multilink. */
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
@ -110,7 +110,9 @@ struct epdisc {
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 */
#if 0 /* UNUSED */
unsigned int restart :1; /* Restart vs. exit after close */
#endif /* UNUSED */
unsigned int neg_mru :1; /* Negotiate the MRU? */
unsigned int neg_asyncmap :1; /* Negotiate the async map? */
#if PAP_SUPPORT
@ -159,11 +161,11 @@ 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 */
#if 0 /* moved to ppp_opts.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 /* moved to ppp_opts.h */
#endif /* LCP_H */
#endif /* PPP_SUPPORT */

View File

@ -74,7 +74,7 @@
* Extracted from avos.
*****************************************************************************/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef MAGIC_H

View File

@ -33,17 +33,13 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && MPPE_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef MPPE_H
#define MPPE_H
#if LWIP_INCLUDED_POLARSSL_ARC4
#include "netif/ppp/polarssl/arc4.h"
#else
#include "polarssl/arc4.h"
#endif
#include "netif/ppp/pppcrypt.h"
#define MPPE_PAD 4 /* MPPE growth per frame */
#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */
@ -63,7 +59,7 @@
* This is not nice ... the alternative is a bitfield struct though.
* And unfortunately, we cannot share the same bits for the option
* names above since C and H are the same bit. We could do a u_int32
* but then we have to do a htonl() all the time and/or we still need
* but then we have to do a lwip_htonl() all the time and/or we still need
* to know which octet is which.
*/
#define MPPE_C_BIT 0x01 /* MPPC */
@ -152,7 +148,7 @@ static const u8_t mppe_sha1_pad2[SHA1_PAD_SIZE] = {
* State for an MPPE (de)compressor.
*/
typedef struct ppp_mppe_state {
arc4_context arc4;
lwip_arc4_context arc4;
u8_t master_key[MPPE_MAX_KEY_LEN];
u8_t session_key[MPPE_MAX_KEY_LEN];
u8_t keylen; /* key length in bytes */

View File

@ -33,7 +33,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if LWIP_INCLUDED_POLARSSL_ARC4
#ifndef LWIP_INCLUDED_POLARSSL_ARC4_H

View File

@ -33,7 +33,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if LWIP_INCLUDED_POLARSSL_DES
#ifndef LWIP_INCLUDED_POLARSSL_DES_H

View File

@ -33,7 +33,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if LWIP_INCLUDED_POLARSSL_MD4
#ifndef LWIP_INCLUDED_POLARSSL_MD4_H

View File

@ -33,7 +33,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if LWIP_INCLUDED_POLARSSL_MD5
#ifndef LWIP_INCLUDED_POLARSSL_MD5_H

View File

@ -33,7 +33,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if LWIP_INCLUDED_POLARSSL_SHA1
#ifndef LWIP_INCLUDED_POLARSSL_SHA1_H

View File

@ -31,7 +31,7 @@
* Original derived from BSD codes.
*****************************************************************************/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef PPP_H
@ -42,13 +42,12 @@
#include "lwip/mem.h"
#include "lwip/netif.h"
#include "lwip/sys.h"
#include "lwip/sio.h"
#include "lwip/timers.h"
#include "lwip/timeouts.h"
#if PPP_IPV6_SUPPORT
#include "lwip/ip6_addr.h"
#endif /* PPP_IPV6_SUPPORT */
/* Disable non-working or rarely used PPP feature, so rarely that we don't want to bloat opt.h with them */
/* Disable non-working or rarely used PPP feature, so rarely that we don't want to bloat ppp_opts.h with them */
#ifndef PPP_OPTIONS
#define PPP_OPTIONS 0
#endif
@ -111,18 +110,18 @@
* 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
#define PPP_PHASE_MASTER 1
#define PPP_PHASE_HOLDOFF 2
#define PPP_PHASE_INITIALIZE 3
#define PPP_PHASE_SERIALCONN 4
#define PPP_PHASE_DORMANT 5
#define PPP_PHASE_ESTABLISH 6
#define PPP_PHASE_AUTHENTICATE 7
#define PPP_PHASE_CALLBACK 8
#define PPP_PHASE_NETWORK 9
#define PPP_PHASE_RUNNING 10
#define PPP_PHASE_TERMINATE 11
#define PPP_PHASE_DISCONNECT 12
/* Error codes. */
#define PPPERR_NONE 0 /* No error. */
@ -311,7 +310,6 @@ struct ppp_addrs {
* PPP interface control block.
*/
struct ppp_pcb_s {
/* -- below are data that will NOT be cleared between two sessions */
ppp_settings settings;
const struct link_callbacks *link_cb;
void *link_ctx_cb;
@ -321,18 +319,12 @@ struct ppp_pcb_s {
#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 */
#if PPP_IPV4_SUPPORT
unsigned int ask_for_local :1; /* request our address from peer */
unsigned int ipcp_is_open :1; /* haven't called np_finished() */
unsigned int ipcp_is_up :1; /* have called ipcp_up() */
unsigned int if4_up :1; /* True when the IPv4 interface is up. */
@ -432,7 +424,13 @@ struct ppp_pcb_s {
************************/
/*
* Set auth helper, optional, you can either fill ppp_pcb->settings.
* WARNING: For multi-threads environment, all ppp_set_* functions most
* only be called while the PPP is in the dead phase (i.e. disconnected).
*/
#if PPP_AUTH_SUPPORT
/*
* Set PPP authentication.
*
* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
* RFC 1994 says:
@ -452,6 +450,7 @@ struct ppp_pcb_s {
* circumstances, then distinct user names SHOULD be employed, each of
* which identifies exactly one authentication method.
*
* Default is none auth type, unset (NULL) user and passwd.
*/
#define PPPAUTHTYPE_NONE 0x00
#define PPPAUTHTYPE_PAP 0x01
@ -462,6 +461,127 @@ struct ppp_pcb_s {
#define PPPAUTHTYPE_ANY 0xff
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);
/*
* If set, peer is required to authenticate. This is mostly necessary for PPP server support.
*
* Default is false.
*/
#define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval)
#endif /* PPP_AUTH_SUPPORT */
#if PPP_IPV4_SUPPORT
/*
* Set PPP interface "our" and "his" IPv4 addresses. This is mostly necessary for PPP server
* support but it can also be used on a PPP link where each side choose its own IP address.
*
* Default is unset (0.0.0.0).
*/
#define ppp_set_ipcp_ouraddr(ppp, addr) do { ppp->ipcp_wantoptions.ouraddr = ip4_addr_get_u32(addr); \
ppp->ask_for_local = ppp->ipcp_wantoptions.ouraddr != 0; } while(0)
#define ppp_set_ipcp_hisaddr(ppp, addr) (ppp->ipcp_wantoptions.hisaddr = ip4_addr_get_u32(addr))
#if LWIP_DNS
/*
* Set DNS server addresses that are sent if the peer asks for them. This is mostly necessary
* for PPP server support.
*
* Default is unset (0.0.0.0).
*/
#define ppp_set_ipcp_dnsaddr(ppp, index, addr) (ppp->ipcp_allowoptions.dnsaddr[index] = ip4_addr_get_u32(addr))
/*
* If set, we ask the peer for up to 2 DNS server addresses. Received DNS server addresses are
* registered using the dns_setserver() function.
*
* Default is false.
*/
#define ppp_set_usepeerdns(ppp, boolval) (ppp->settings.usepeerdns = boolval)
#endif /* LWIP_DNS */
#endif /* PPP_IPV4_SUPPORT */
#if MPPE_SUPPORT
/* Disable MPPE (Microsoft Point to Point Encryption). This parameter is exclusive. */
#define PPP_MPPE_DISABLE 0x00
/* Require the use of MPPE (Microsoft Point to Point Encryption). */
#define PPP_MPPE_ENABLE 0x01
/* Allow MPPE to use stateful mode. Stateless mode is still attempted first. */
#define PPP_MPPE_ALLOW_STATEFUL 0x02
/* Refuse the use of MPPE with 40-bit encryption. Conflict with PPP_MPPE_REFUSE_128. */
#define PPP_MPPE_REFUSE_40 0x04
/* Refuse the use of MPPE with 128-bit encryption. Conflict with PPP_MPPE_REFUSE_40. */
#define PPP_MPPE_REFUSE_128 0x08
/*
* Set MPPE configuration
*
* Default is disabled.
*/
void ppp_set_mppe(ppp_pcb *pcb, u8_t flags);
#endif /* MPPE_SUPPORT */
/*
* Wait for up to intval milliseconds for a valid PPP packet from the peer.
* At the end of this time, or when a valid PPP packet is received from the
* peer, we commence negotiation by sending our first LCP packet.
*
* Default is 0.
*/
#define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval)
/*
* If set, we will attempt to initiate a connection but if no reply is received from
* the peer, we will then just wait passively for a valid LCP packet from the peer.
*
* Default is false.
*/
#define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval)
/*
* If set, we will not transmit LCP packets to initiate a connection until a valid
* LCP packet is received from the peer. This is what we usually call the server mode.
*
* Default is false.
*/
#define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval)
/*
* If set, enable protocol field compression negotiation in both the receive and
* the transmit direction.
*
* Default is true.
*/
#define ppp_set_neg_pcomp(ppp, boolval) (ppp->lcp_wantoptions.neg_pcompression = \
ppp->lcp_allowoptions.neg_pcompression = boolval)
/*
* If set, enable Address/Control compression in both the receive and the transmit
* direction.
*
* Default is true.
*/
#define ppp_set_neg_accomp(ppp, boolval) (ppp->lcp_wantoptions.neg_accompression = \
ppp->lcp_allowoptions.neg_accompression = boolval)
/*
* If set, enable asyncmap negotiation. Otherwise forcing all control characters to
* be escaped for both the transmit and the receive direction.
*
* Default is true.
*/
#define ppp_set_neg_asyncmap(ppp, boolval) (ppp->lcp_wantoptions.neg_asyncmap = \
ppp->lcp_allowoptions.neg_asyncmap = boolval)
/*
* This option sets the Async-Control-Character-Map (ACCM) for this end of the link.
* The ACCM is a set of 32 bits, one for each of the ASCII control characters with
* values from 0 to 31, where a 1 bit indicates that the corresponding control
* character should not be used in PPP packets sent to this system. The map is
* an unsigned 32 bits integer where the least significant bit (00000001) represents
* character 0 and the most significant bit (80000000) represents character 31.
* We will then ask the peer to send these characters as a 2-byte escape sequence.
*
* Default is 0.
*/
#define ppp_set_asyncmap(ppp, intval) (ppp->lcp_wantoptions.asyncmap = intval)
/*
* Set a PPP interface as the default network interface
* (used to output all packets for which no specific route is found).
@ -498,13 +618,10 @@ err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff);
*
* This can only be called if PPP is in the dead phase.
*
* Local and remote interface IP addresses, as well as DNS are
* provided through a previously filled struct ppp_addrs.
*
* If this port connects to a modem, the modem connection must be
* established before calling this.
*/
err_t ppp_listen(ppp_pcb *pcb, struct ppp_addrs *addrs);
err_t ppp_listen(ppp_pcb *pcb);
#endif /* PPP_SERVER */
/*

View File

@ -33,7 +33,7 @@
#ifndef LWIP_HDR_PPP_IMPL_H
#define LWIP_HDR_PPP_IMPL_H
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
@ -48,7 +48,7 @@
#include "lwip/netif.h"
#include "lwip/def.h"
#include "lwip/timers.h"
#include "lwip/timeouts.h"
#include "ppp.h"
#include "pppdebug.h"
@ -138,10 +138,10 @@
*/
struct link_callbacks {
/* Start a connection (e.g. Initiate discovery phase) */
err_t (*connect) (ppp_pcb *pcb, void *ctx);
void (*connect) (ppp_pcb *pcb, void *ctx);
#if PPP_SERVER
/* Listen for an incoming connection (Passive mode) */
err_t (*listen) (ppp_pcb *pcb, void *ctx, struct ppp_addrs *addrs);
void (*listen) (ppp_pcb *pcb, void *ctx);
#endif /* PPP_SERVER */
/* End a connection (i.e. initiate disconnect phase) */
void (*disconnect) (ppp_pcb *pcb, void *ctx);
@ -378,6 +378,7 @@ struct pppd_stats {
* PPP private functions
*/
/*
* Functions called from lwIP core.
*/
@ -385,7 +386,6 @@ struct pppd_stats {
/* initialize the PPP subsystem */
int ppp_init(void);
/*
* Functions called from PPP link protocols.
*/
@ -394,9 +394,6 @@ int ppp_init(void);
ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, void *link_ctx_cb,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
/* Set a PPP PCB to its initial state */
void ppp_clear(ppp_pcb *pcb);
/* Initiate LCP open request */
void ppp_start(ppp_pcb *pcb);
@ -623,7 +620,7 @@ void ppp_warn(const char *fmt, ...); /* log a warning message */
void ppp_error(const char *fmt, ...); /* log an error message */
void ppp_fatal(const char *fmt, ...); /* log an error message and die(1) */
#if PRINTPKT_SUPPORT
void ppp_dump_packet(const char *tag, unsigned char *p, int len);
void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len);
/* dump packet to debug log if interesting */
#endif /* PRINTPKT_SUPPORT */

View File

@ -0,0 +1,593 @@
/*
* 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_PPP_OPTS_H
#define LWIP_PPP_OPTS_H
#include "lwip/opt.h"
/**
* PPP_SUPPORT==1: Enable PPP.
*/
#ifndef PPP_SUPPORT
#define PPP_SUPPORT 0
#endif
/**
* PPPOE_SUPPORT==1: Enable PPP Over Ethernet
*/
#ifndef PPPOE_SUPPORT
#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
*/
#ifndef PPPOS_SUPPORT
#define PPPOS_SUPPORT PPP_SUPPORT
#endif
/**
* LWIP_PPP_API==1: Enable PPP API (in pppapi.c)
*/
#ifndef LWIP_PPP_API
#define LWIP_PPP_API (PPP_SUPPORT && (NO_SYS == 0))
#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
#if PPP_SUPPORT
/**
* MEMP_NUM_PPPOS_INTERFACES: the number of concurrently active PPPoS
* interfaces (only used with PPPOS_SUPPORT==1)
*/
#ifndef MEMP_NUM_PPPOS_INTERFACES
#define MEMP_NUM_PPPOS_INTERFACES MEMP_NUM_PPP_PCB
#endif
/**
* MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
* interfaces (only used with PPPOE_SUPPORT==1)
*/
#ifndef MEMP_NUM_PPPOE_INTERFACES
#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
/**
* MEMP_NUM_PPP_API_MSG: Number of concurrent PPP API messages (in pppapi.c)
*/
#ifndef MEMP_NUM_PPP_API_MSG
#define MEMP_NUM_PPP_API_MSG 5
#endif
/**
* PPP_DEBUG: Enable debugging for PPP.
*/
#ifndef PPP_DEBUG
#define PPP_DEBUG LWIP_DBG_OFF
#endif
/**
* PPP_INPROC_IRQ_SAFE==1 call pppos_input() using tcpip_callback().
*
* Please read the "PPPoS input path" chapter in the PPP documentation about this option.
*/
#ifndef PPP_INPROC_IRQ_SAFE
#define PPP_INPROC_IRQ_SAFE 0
#endif
/**
* PRINTPKT_SUPPORT==1: Enable PPP print packet support
*
* Mandatory for debugging, it displays exchanged packet content in debug trace.
*/
#ifndef PRINTPKT_SUPPORT
#define PRINTPKT_SUPPORT 0
#endif
/**
* PPP_IPV4_SUPPORT==1: Enable PPP IPv4 support
*/
#ifndef PPP_IPV4_SUPPORT
#define PPP_IPV4_SUPPORT (LWIP_IPV4)
#endif
/**
* PPP_IPV6_SUPPORT==1: Enable PPP IPv6 support
*/
#ifndef PPP_IPV6_SUPPORT
#define PPP_IPV6_SUPPORT (LWIP_IPV6)
#endif
/**
* PPP_NOTIFY_PHASE==1: Support PPP notify phase support
*
* PPP notify phase support allows you to set a callback which is
* called on change of the internal PPP state machine.
*
* This can be used for example to set a LED pattern depending on the
* current phase of the PPP session.
*/
#ifndef PPP_NOTIFY_PHASE
#define PPP_NOTIFY_PHASE 0
#endif
/**
* pbuf_type PPP is using for LCP, PAP, CHAP, EAP, CCP, 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 for PPPoS
*/
#ifndef PPP_FCS_TABLE
#define PPP_FCS_TABLE 1
#endif
/**
* PAP_SUPPORT==1: Support PAP.
*/
#ifndef PAP_SUPPORT
#define PAP_SUPPORT 0
#endif
/**
* CHAP_SUPPORT==1: Support CHAP.
*/
#ifndef CHAP_SUPPORT
#define CHAP_SUPPORT 0
#endif
/**
* MSCHAP_SUPPORT==1: Support MSCHAP.
*/
#ifndef MSCHAP_SUPPORT
#define MSCHAP_SUPPORT 0
#endif
#if MSCHAP_SUPPORT
/* MSCHAP requires CHAP support */
#undef CHAP_SUPPORT
#define CHAP_SUPPORT 1
#endif /* MSCHAP_SUPPORT */
/**
* EAP_SUPPORT==1: Support EAP.
*/
#ifndef EAP_SUPPORT
#define EAP_SUPPORT 0
#endif
/**
* CCP_SUPPORT==1: Support CCP.
*/
#ifndef CCP_SUPPORT
#define CCP_SUPPORT 0
#endif
/**
* MPPE_SUPPORT==1: Support MPPE.
*/
#ifndef MPPE_SUPPORT
#define MPPE_SUPPORT 0
#endif
#if MPPE_SUPPORT
/* MPPE requires CCP support */
#undef CCP_SUPPORT
#define CCP_SUPPORT 1
/* MPPE requires MSCHAP support */
#undef MSCHAP_SUPPORT
#define MSCHAP_SUPPORT 1
/* MSCHAP requires CHAP support */
#undef CHAP_SUPPORT
#define CHAP_SUPPORT 1
#endif /* MPPE_SUPPORT */
/**
* CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
*/
#ifndef CBCP_SUPPORT
#define CBCP_SUPPORT 0
#endif
/**
* ECP_SUPPORT==1: Support ECP. CURRENTLY NOT SUPPORTED! DO NOT SET!
*/
#ifndef ECP_SUPPORT
#define ECP_SUPPORT 0
#endif
/**
* DEMAND_SUPPORT==1: Support dial on demand. CURRENTLY NOT SUPPORTED! DO NOT SET!
*/
#ifndef DEMAND_SUPPORT
#define DEMAND_SUPPORT 0
#endif
/**
* LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets.
*/
#ifndef LQR_SUPPORT
#define LQR_SUPPORT 0
#endif
/**
* PPP_SERVER==1: Enable PPP server support (waiting for incoming PPP session).
*
* Currently only supported for PPPoS.
*/
#ifndef PPP_SERVER
#define PPP_SERVER 0
#endif
#if PPP_SERVER
/*
* PPP_OUR_NAME: Our name for authentication purposes
*/
#ifndef PPP_OUR_NAME
#define PPP_OUR_NAME "lwIP"
#endif
#endif /* PPP_SERVER */
/**
* VJ_SUPPORT==1: Support VJ header compression.
*/
#ifndef VJ_SUPPORT
#define VJ_SUPPORT 1
#endif
/* VJ compression is only supported for TCP over IPv4 over PPPoS. */
#if !PPPOS_SUPPORT || !PPP_IPV4_SUPPORT || !LWIP_TCP
#undef VJ_SUPPORT
#define VJ_SUPPORT 0
#endif /* !PPPOS_SUPPORT */
/**
* PPP_MD5_RANDM==1: Use MD5 for better randomness.
* Enabled by default if CHAP, EAP, or L2TP AUTH support is enabled.
*/
#ifndef PPP_MD5_RANDM
#define PPP_MD5_RANDM (CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT)
#endif
/**
* PolarSSL embedded library
*
*
* lwIP contains some files fetched from the latest BSD release of
* the PolarSSL project (PolarSSL 0.10.1-bsd) 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.
*
* If you are not using the embedded copy you must include external
* libraries into your arch/cc.h port file.
*
* Beware of the stack requirements which can be a lot larger if you are not
* using our cleaned PolarSSL library.
*/
/**
* LWIP_USE_EXTERNAL_POLARSSL: Use external PolarSSL library
*/
#ifndef LWIP_USE_EXTERNAL_POLARSSL
#define LWIP_USE_EXTERNAL_POLARSSL 0
#endif
/**
* LWIP_USE_EXTERNAL_MBEDTLS: Use external mbed TLS library
*/
#ifndef LWIP_USE_EXTERNAL_MBEDTLS
#define LWIP_USE_EXTERNAL_MBEDTLS 0
#endif
/*
* PPP Timeouts
*/
/**
* FSM_DEFTIMEOUT: Timeout time in seconds
*/
#ifndef FSM_DEFTIMEOUT
#define FSM_DEFTIMEOUT 6
#endif
/**
* FSM_DEFMAXTERMREQS: Maximum Terminate-Request transmissions
*/
#ifndef FSM_DEFMAXTERMREQS
#define FSM_DEFMAXTERMREQS 2
#endif
/**
* FSM_DEFMAXCONFREQS: Maximum Configure-Request transmissions
*/
#ifndef FSM_DEFMAXCONFREQS
#define FSM_DEFMAXCONFREQS 10
#endif
/**
* FSM_DEFMAXNAKLOOPS: Maximum number of nak loops
*/
#ifndef FSM_DEFMAXNAKLOOPS
#define FSM_DEFMAXNAKLOOPS 5
#endif
/**
* UPAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req
*/
#ifndef UPAP_DEFTIMEOUT
#define UPAP_DEFTIMEOUT 6
#endif
/**
* UPAP_DEFTRANSMITS: Maximum number of auth-reqs to send
*/
#ifndef UPAP_DEFTRANSMITS
#define UPAP_DEFTRANSMITS 10
#endif
#if PPP_SERVER
/**
* UPAP_DEFREQTIME: Time to wait for auth-req from peer
*/
#ifndef UPAP_DEFREQTIME
#define UPAP_DEFREQTIME 30
#endif
#endif /* PPP_SERVER */
/**
* CHAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req
*/
#ifndef CHAP_DEFTIMEOUT
#define CHAP_DEFTIMEOUT 6
#endif
/**
* CHAP_DEFTRANSMITS: max # times to send challenge
*/
#ifndef CHAP_DEFTRANSMITS
#define CHAP_DEFTRANSMITS 10
#endif
#if PPP_SERVER
/**
* CHAP_DEFRECHALLENGETIME: If this option is > 0, rechallenge the peer every n seconds
*/
#ifndef CHAP_DEFRECHALLENGETIME
#define CHAP_DEFRECHALLENGETIME 0
#endif
#endif /* PPP_SERVER */
/**
* EAP_DEFREQTIME: Time to wait for peer request
*/
#ifndef EAP_DEFREQTIME
#define EAP_DEFREQTIME 6
#endif
/**
* EAP_DEFALLOWREQ: max # times to accept requests
*/
#ifndef EAP_DEFALLOWREQ
#define EAP_DEFALLOWREQ 10
#endif
#if PPP_SERVER
/**
* EAP_DEFTIMEOUT: Timeout (seconds) for rexmit
*/
#ifndef EAP_DEFTIMEOUT
#define EAP_DEFTIMEOUT 6
#endif
/**
* EAP_DEFTRANSMITS: max # times to transmit
*/
#ifndef EAP_DEFTRANSMITS
#define EAP_DEFTRANSMITS 10
#endif
#endif /* PPP_SERVER */
/**
* LCP_DEFLOOPBACKFAIL: 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
/**
* LCP_ECHOINTERVAL: Interval in seconds between keepalive echo requests, 0 to disable.
*/
#ifndef LCP_ECHOINTERVAL
#define LCP_ECHOINTERVAL 0
#endif
/**
* LCP_MAXECHOFAILS: Number of unanswered echo requests before failure.
*/
#ifndef LCP_MAXECHOFAILS
#define LCP_MAXECHOFAILS 3
#endif
/**
* PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char.
*/
#ifndef PPP_MAXIDLEFLAG
#define PPP_MAXIDLEFLAG 100
#endif
/**
* PPP Packet sizes
*/
/**
* PPP_MRU: Default MRU
*/
#ifndef PPP_MRU
#define PPP_MRU 1500
#endif
/**
* PPP_DEFMRU: Default MRU to try
*/
#ifndef PPP_DEFMRU
#define PPP_DEFMRU 1500
#endif
/**
* PPP_MAXMRU: Normally limit MRU to this (pppd default = 16384)
*/
#ifndef PPP_MAXMRU
#define PPP_MAXMRU 1500
#endif
/**
* PPP_MINMRU: No MRUs below this
*/
#ifndef PPP_MINMRU
#define PPP_MINMRU 128
#endif
/**
* PPPOL2TP_DEFMRU: Default MTU and MRU for L2TP
* Default = 1500 - PPPoE(6) - PPP Protocol(2) - IPv4 header(20) - UDP Header(8)
* - L2TP Header(6) - HDLC Header(2) - PPP Protocol(2) - MPPE Header(2) - PPP Protocol(2)
*/
#if PPPOL2TP_SUPPORT
#ifndef PPPOL2TP_DEFMRU
#define PPPOL2TP_DEFMRU 1450
#endif
#endif /* PPPOL2TP_SUPPORT */
/**
* MAXNAMELEN: max length of hostname or name for auth
*/
#ifndef MAXNAMELEN
#define MAXNAMELEN 256
#endif
/**
* MAXSECRETLEN: max length of password or secret
*/
#ifndef MAXSECRETLEN
#define MAXSECRETLEN 256
#endif
/* ------------------------------------------------------------------------- */
/*
* Build triggers for embedded PolarSSL
*/
#if !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS
/* CHAP, EAP, L2TP AUTH and MD5 Random require MD5 support */
#if CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM
#define LWIP_INCLUDED_POLARSSL_MD5 1
#endif /* CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM */
#if MSCHAP_SUPPORT
/* MSCHAP require MD4 support */
#define LWIP_INCLUDED_POLARSSL_MD4 1
/* MSCHAP require SHA1 support */
#define LWIP_INCLUDED_POLARSSL_SHA1 1
/* MSCHAP require DES support */
#define LWIP_INCLUDED_POLARSSL_DES 1
/* MS-CHAP support is required for MPPE */
#if MPPE_SUPPORT
/* MPPE require ARC4 support */
#define LWIP_INCLUDED_POLARSSL_ARC4 1
#endif /* MPPE_SUPPORT */
#endif /* MSCHAP_SUPPORT */
#endif /* !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS */
/* Default value if unset */
#ifndef LWIP_INCLUDED_POLARSSL_MD4
#define LWIP_INCLUDED_POLARSSL_MD4 0
#endif /* LWIP_INCLUDED_POLARSSL_MD4 */
#ifndef LWIP_INCLUDED_POLARSSL_MD5
#define LWIP_INCLUDED_POLARSSL_MD5 0
#endif /* LWIP_INCLUDED_POLARSSL_MD5 */
#ifndef LWIP_INCLUDED_POLARSSL_SHA1
#define LWIP_INCLUDED_POLARSSL_SHA1 0
#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */
#ifndef LWIP_INCLUDED_POLARSSL_DES
#define LWIP_INCLUDED_POLARSSL_DES 0
#endif /* LWIP_INCLUDED_POLARSSL_DES */
#ifndef LWIP_INCLUDED_POLARSSL_ARC4
#define LWIP_INCLUDED_POLARSSL_ARC4 0
#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */
#endif /* PPP_SUPPORT */
#endif /* LWIP_PPP_OPTS_H */

View File

@ -0,0 +1,147 @@
/*
* 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 "netif/ppp/ppp_opts.h"
#if LWIP_PPP_API /* don't build if not configured for use in lwipopts.h */
#include "lwip/sys.h"
#include "lwip/netif.h"
#include "lwip/priv/tcpip_priv.h"
#include "netif/ppp/ppp.h"
#if PPPOS_SUPPORT
#include "netif/ppp/pppos.h"
#endif /* PPPOS_SUPPORT */
#ifdef __cplusplus
extern "C" {
#endif
struct pppapi_msg_msg {
ppp_pcb *ppp;
union {
#if ESP_LWIP
struct {
u8_t authtype;
const char *user;
const char *passwd;
} setauth;
#endif
#if PPP_NOTIFY_PHASE
struct {
ppp_notify_phase_cb_fn notify_phase_cb;
} setnotifyphasecb;
#endif /* PPP_NOTIFY_PHASE */
#if PPPOS_SUPPORT
struct {
struct netif *pppif;
pppos_output_cb_fn output_cb;
ppp_link_status_cb_fn link_status_cb;
void *ctx_cb;
} serialcreate;
#endif /* PPPOS_SUPPORT */
#if PPPOE_SUPPORT
struct {
struct netif *pppif;
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 *pppif;
struct netif *netif;
API_MSG_M_DEF_C(ip_addr_t, ipaddr);
u16_t port;
#if PPPOL2TP_AUTH_SUPPORT
const 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;
} connect;
struct {
u8_t nocarrier;
} close;
struct {
u8_t cmd;
void *arg;
} ioctl;
} msg;
};
struct pppapi_msg {
struct tcpip_api_call_data call;
struct pppapi_msg_msg msg;
};
/* API for application */
err_t pppapi_set_default(ppp_pcb *pcb);
#if ESP_LWIP
void pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);
#endif
#if PPP_NOTIFY_PHASE
err_t pppapi_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
#endif /* PPP_NOTIFY_PHASE */
#if PPPOS_SUPPORT
ppp_pcb *pppapi_pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
#endif /* PPPOS_SUPPORT */
#if PPPOE_SUPPORT
ppp_pcb *pppapi_pppoe_create(struct netif *pppif, 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
ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
const u8_t *secret, u8_t secret_len,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
#endif /* PPPOL2TP_SUPPORT */
err_t pppapi_connect(ppp_pcb *pcb, u16_t holdoff);
#if PPP_SERVER
err_t pppapi_listen(ppp_pcb *pcb);
#endif /* PPP_SERVER */
err_t pppapi_close(ppp_pcb *pcb, u8_t nocarrier);
err_t pppapi_free(ppp_pcb *pcb);
err_t pppapi_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_PPP_API */
#endif /* LWIP_PPPAPI_H */

View File

@ -30,14 +30,107 @@
* 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 */
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
/* This header file is included in all PPP modules needing hashes and/or ciphers */
#ifndef PPPCRYPT_H
#define PPPCRYPT_H
/*
* If included PolarSSL copy is not used, user is expected to include
* external libraries in arch/cc.h (which is included by lwip/arch.h).
*/
#include "lwip/arch.h"
/*
* Map hashes and ciphers functions to PolarSSL
*/
#if !LWIP_USE_EXTERNAL_MBEDTLS
#include "netif/ppp/polarssl/md4.h"
#define lwip_md4_context md4_context
#define lwip_md4_init(context)
#define lwip_md4_starts md4_starts
#define lwip_md4_update md4_update
#define lwip_md4_finish md4_finish
#define lwip_md4_free(context)
#include "netif/ppp/polarssl/md5.h"
#define lwip_md5_context md5_context
#define lwip_md5_init(context)
#define lwip_md5_starts md5_starts
#define lwip_md5_update md5_update
#define lwip_md5_finish md5_finish
#define lwip_md5_free(context)
#include "netif/ppp/polarssl/sha1.h"
#define lwip_sha1_context sha1_context
#define lwip_sha1_init(context)
#define lwip_sha1_starts sha1_starts
#define lwip_sha1_update sha1_update
#define lwip_sha1_finish sha1_finish
#define lwip_sha1_free(context)
#include "netif/ppp/polarssl/des.h"
#define lwip_des_context des_context
#define lwip_des_init(context)
#define lwip_des_setkey_enc des_setkey_enc
#define lwip_des_crypt_ecb des_crypt_ecb
#define lwip_des_free(context)
#include "netif/ppp/polarssl/arc4.h"
#define lwip_arc4_context arc4_context
#define lwip_arc4_init(context)
#define lwip_arc4_setup arc4_setup
#define lwip_arc4_crypt arc4_crypt
#define lwip_arc4_free(context)
#endif /* !LWIP_USE_EXTERNAL_MBEDTLS */
/*
* Map hashes and ciphers functions to mbed TLS
*/
#if LWIP_USE_EXTERNAL_MBEDTLS
#define lwip_md4_context mbedtls_md4_context
#define lwip_md4_init mbedtls_md4_init
#define lwip_md4_starts mbedtls_md4_starts
#define lwip_md4_update mbedtls_md4_update
#define lwip_md4_finish mbedtls_md4_finish
#define lwip_md4_free mbedtls_md4_free
#define lwip_md5_context mbedtls_md5_context
#define lwip_md5_init mbedtls_md5_init
#define lwip_md5_starts mbedtls_md5_starts
#define lwip_md5_update mbedtls_md5_update
#define lwip_md5_finish mbedtls_md5_finish
#define lwip_md5_free mbedtls_md5_free
#define lwip_sha1_context mbedtls_sha1_context
#define lwip_sha1_init mbedtls_sha1_init
#define lwip_sha1_starts mbedtls_sha1_starts
#define lwip_sha1_update mbedtls_sha1_update
#define lwip_sha1_finish mbedtls_sha1_finish
#define lwip_sha1_free mbedtls_sha1_free
#define lwip_des_context mbedtls_des_context
#define lwip_des_init mbedtls_des_init
#define lwip_des_setkey_enc mbedtls_des_setkey_enc
#define lwip_des_crypt_ecb mbedtls_des_crypt_ecb
#define lwip_des_free mbedtls_des_free
#define lwip_arc4_context mbedtls_arc4_context
#define lwip_arc4_init mbedtls_arc4_init
#define lwip_arc4_setup mbedtls_arc4_setup
#define lwip_arc4_crypt(context, buffer, length) mbedtls_arc4_crypt(context, length, buffer, buffer)
#define lwip_arc4_free mbedtls_arc4_free
#endif /* LWIP_USE_EXTERNAL_MBEDTLS */
void pppcrypt_56_to_64_bit_key(u_char *key, u_char *des_key);
#endif /* PPPCRYPT_H */
#endif /* PPP_SUPPORT && MSCHAP_SUPPORT */
#endif /* PPP_SUPPORT */

View File

@ -34,7 +34,7 @@
*****************************************************************************
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef PPPDEBUG_H

View File

@ -67,14 +67,14 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.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 "ppp.h"
#include "netif/etharp.h"
#include "lwip/etharp.h"
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"

View File

@ -31,11 +31,11 @@
*
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && PPPOL2TP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef PPPOL2TP_H_
#define PPPOL2TP_H_
#ifndef PPPOL2TP_H
#define PPPOL2TP_H
#include "ppp.h"
@ -193,9 +193,9 @@ struct pppol2tp_pcb_s {
/* Create a new L2TP session. */
ppp_pcb *pppol2tp_create(struct netif *pppif,
struct netif *netif, ip_addr_t *ipaddr, u16_t port,
struct netif *netif, const ip_addr_t *ipaddr, u16_t port,
const u8_t *secret, u8_t secret_len,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
#endif /* PPPOL2TP_H_ */
#endif /* PPPOL2TP_H */
#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */

View File

@ -31,14 +31,13 @@
*
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && PPPOS_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef PPPOS_H
#define PPPOS_H
#include "lwip/sys.h"
#include "lwip/sio.h"
#include "ppp.h"
#include "vj.h"

View File

@ -42,7 +42,7 @@
* $Id: upap.h,v 1.8 2002/12/04 23:03:33 paulus Exp $
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef UPAP_H
@ -88,10 +88,10 @@
/*
* Timeouts.
*/
#if 0 /* moved to opt.h */
#if 0 /* moved to ppp_opts.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 */
#endif /* moved to ppp_opts.h */
/*
* Each interface is described by upap structure.

View File

@ -22,7 +22,7 @@
* - Initial distribution.
*/
#include "lwip/opt.h"
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && VJ_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef VJ_H

View File

@ -1,3 +1,9 @@
/**
* @file
*
* SLIP netif API
*/
/*
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.