mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-13 13:01:55 +03:00
remove lwip-v1.4 specific code (#7436)
* remove lwip-v1.4 specific code * ditto * ditto * fix ip4_addr definition * CI: change debug builds to use IPv6, remove regular IPv6 builds * ditto * split pio CI in four (because they last twice the time of the other builds) * remove option from pio * remove lwIP-1.4 from doc * restore pio CI splitting * fix CI debug6 script * ditto
This commit is contained in:
@ -1,18 +1,4 @@
|
||||
|
||||
#include <lwip/init.h>
|
||||
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("wifi_softap_add_dhcps_lease() is not implemented with lwIP-v1");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Create a WiFi access point and provide static lease */
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
@ -104,5 +90,3 @@ void setup() {
|
||||
void loop() {
|
||||
server.handleClient();
|
||||
}
|
||||
|
||||
#endif // lwIP-v2
|
||||
|
@ -41,12 +41,7 @@ extern "C" {
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/init.h" // LWIP_VERSION_
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
#include "lwip/sntp.h"
|
||||
#else
|
||||
#include "lwip/apps/sntp.h"
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "WiFiClient.h"
|
||||
@ -588,7 +583,7 @@ bool ESP8266WiFiGenericClass::isSleepLevelMax () {
|
||||
// ------------------------------------------------ Generic Network function ---------------------------------------------
|
||||
// -----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void wifi_dns_found_callback(const char *name, CONST ip_addr_t *ipaddr, void *callback_arg);
|
||||
void wifi_dns_found_callback(const char *name, const ip_addr_t *ipaddr, void *callback_arg);
|
||||
|
||||
static bool _dns_lookup_pending = false;
|
||||
|
||||
@ -701,7 +696,7 @@ int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResul
|
||||
* @param ipaddr
|
||||
* @param callback_arg
|
||||
*/
|
||||
void wifi_dns_found_callback(const char *name, CONST ip_addr_t *ipaddr, void *callback_arg)
|
||||
void wifi_dns_found_callback(const char *name, const ip_addr_t *ipaddr, void *callback_arg)
|
||||
{
|
||||
(void) name;
|
||||
if (!_dns_lookup_pending) {
|
||||
@ -770,11 +765,7 @@ bool ESP8266WiFiGenericClass::shutdown (uint32 sleepUs, WiFiState* state)
|
||||
uint8_t i = 0;
|
||||
for (auto& ntp: state->state.ntp)
|
||||
{
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
ntp = sntp_getserver(i++);
|
||||
#else
|
||||
ntp = *sntp_getserver(i++);
|
||||
#endif
|
||||
}
|
||||
i = 0;
|
||||
for (auto& dns: state->state.dns)
|
||||
@ -814,7 +805,7 @@ bool ESP8266WiFiGenericClass::resumeFromShutdown (WiFiState* state)
|
||||
DEBUG_WIFI("core: resume: static address '%s'\n", local.toString().c_str());
|
||||
WiFi.config(state->state.ip.ip, state->state.ip.gw, state->state.ip.netmask, state->state.dns[0], state->state.dns[1]);
|
||||
uint8_t i = 0;
|
||||
for (CONST auto& ntp: state->state.ntp)
|
||||
for (const auto& ntp: state->state.ntp)
|
||||
{
|
||||
IPAddress ip(ntp);
|
||||
if (ip.isSet())
|
||||
|
@ -19,14 +19,7 @@
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "lwip/init.h" // LWIP_VERSION_*
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
#include "netif/wlan_lwip_if.h" // eagle_lwip_getif()
|
||||
#include "netif/etharp.h" // gratuitous arp
|
||||
#include "user_interface.h"
|
||||
#else
|
||||
#include "lwip/etharp.h" // gratuitous arp
|
||||
#endif
|
||||
} // extern "C"
|
||||
|
||||
#include <Schedule.h>
|
||||
@ -44,14 +37,8 @@ void ESP8266WiFiGratuitous::stationKeepAliveNow ()
|
||||
if (
|
||||
(interface->flags & NETIF_FLAG_LINK_UP)
|
||||
&& (interface->flags & NETIF_FLAG_UP)
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
&& interface == eagle_lwip_getif(STATION_IF) /* lwip1 does not set if->num properly */
|
||||
&& (!ip_addr_isany(&interface->ip_addr))
|
||||
#else
|
||||
&& interface->num == STATION_IF
|
||||
&& (!ip4_addr_isany_val(*netif_ip4_addr(interface)))
|
||||
#endif
|
||||
)
|
||||
&& (!ip4_addr_isany_val(*netif_ip4_addr(interface))))
|
||||
{
|
||||
etharp_gratuitous(interface);
|
||||
break;
|
||||
|
@ -39,10 +39,6 @@ extern "C" {
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/init.h" // LWIP_VERSION_
|
||||
#if LWIP_IPV6
|
||||
#include "lwip/netif.h" // struct netif
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "debug.h"
|
||||
@ -249,7 +245,6 @@ wl_status_t ESP8266WiFiSTAClass::begin() {
|
||||
* @param dns2 Static DNS server 2
|
||||
*/
|
||||
|
||||
#if LWIP_VERSION_MAJOR != 1
|
||||
/*
|
||||
About the following call in the end of ESP8266WiFiSTAClass::config():
|
||||
netif_set_addr(eagle_lwip_getif(STATION_IF), &info.ip, &info.netmask, &info.gw);
|
||||
@ -267,7 +262,6 @@ wl_status_t ESP8266WiFiSTAClass::begin() {
|
||||
#undef netif_set_addr // need to call lwIP-v1.4 netif_set_addr()
|
||||
extern "C" struct netif* eagle_lwip_getif (int netif_index);
|
||||
extern "C" void netif_set_addr (struct netif* netif, ip4_addr_t* ip, ip4_addr_t* netmask, ip4_addr_t* gw);
|
||||
#endif
|
||||
|
||||
bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress arg2, IPAddress arg3, IPAddress dns2) {
|
||||
|
||||
@ -310,7 +304,7 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a
|
||||
return false;
|
||||
}
|
||||
|
||||
#if LWIP_VERSION_MAJOR != 1 && !CORE_MOCK
|
||||
#if !CORE_MOCK
|
||||
// get current->previous IP address
|
||||
// (check below)
|
||||
struct ip_info previp;
|
||||
@ -339,7 +333,7 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a
|
||||
dns_setserver(1, dns2);
|
||||
}
|
||||
|
||||
#if LWIP_VERSION_MAJOR != 1 && !CORE_MOCK
|
||||
#if !CORE_MOCK
|
||||
// trigger address change by calling lwIP-v1.4 api
|
||||
// (see explanation above)
|
||||
// only when ip is already set by other mean (generally dhcp)
|
||||
@ -525,12 +519,7 @@ IPAddress ESP8266WiFiSTAClass::gatewayIP() {
|
||||
* @return IPAddress DNS Server IP
|
||||
*/
|
||||
IPAddress ESP8266WiFiSTAClass::dnsIP(uint8_t dns_no) {
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
ip_addr_t dns_ip = dns_getserver(dns_no);
|
||||
return IPAddress(dns_ip.addr);
|
||||
#else
|
||||
return IPAddress(dns_getserver(dns_no));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -605,11 +594,7 @@ bool ESP8266WiFiSTAClass::hostname(const char* aHostname) {
|
||||
for (netif* intf = netif_list; intf; intf = intf->next) {
|
||||
|
||||
// unconditionally update all known interfaces
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
intf->hostname = (char*)wifi_station_get_hostname();
|
||||
#else
|
||||
intf->hostname = wifi_station_get_hostname();
|
||||
#endif
|
||||
|
||||
if (netif_dhcp_data(intf) != nullptr) {
|
||||
// renew already started DHCP leases
|
||||
|
@ -145,17 +145,6 @@ int WiFiClient::connect(IPAddress ip, uint16_t port)
|
||||
_client = nullptr;
|
||||
}
|
||||
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
// if the default interface is down, tcp_connect exits early without
|
||||
// ever calling tcp_err
|
||||
// http://lists.gnu.org/archive/html/lwip-devel/2010-05/msg00001.html
|
||||
netif* interface = ip_route(ip);
|
||||
if (!interface) {
|
||||
DEBUGV("no route to host\r\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
tcp_pcb* pcb = tcp_new();
|
||||
if (!pcb)
|
||||
return 0;
|
||||
|
@ -35,7 +35,6 @@ extern "C" {
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/init.h" // LWIP_VERSION_
|
||||
#include <include/ClientContext.h>
|
||||
|
||||
#ifndef MAX_PENDING_CLIENTS_PER_PORT
|
||||
@ -85,11 +84,7 @@ void WiFiServer::begin(uint16_t port, uint8_t backlog) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
tcp_pcb* listen_pcb = tcp_listen(pcb);
|
||||
#else
|
||||
tcp_pcb* listen_pcb = tcp_listen_with_backlog(pcb, backlog);
|
||||
#endif
|
||||
|
||||
if (!listen_pcb) {
|
||||
tcp_close(pcb);
|
||||
@ -124,12 +119,12 @@ WiFiClient WiFiServer::available(byte* status) {
|
||||
(void) status;
|
||||
if (_unclaimed) {
|
||||
WiFiClient result(_unclaimed);
|
||||
#if LWIP_VERSION_MAJOR != 1
|
||||
|
||||
// pcb can be null when peer has already closed the connection
|
||||
if (_unclaimed->getPCB())
|
||||
// give permission to lwIP to accept one more peer
|
||||
tcp_backlog_accepted(_unclaimed->getPCB());
|
||||
#endif
|
||||
|
||||
_unclaimed = _unclaimed->next();
|
||||
result.setNoDelay(getNoDelay());
|
||||
DEBUGV("WS:av status=%d WCav=%d\r\n", result.status(), result.available());
|
||||
@ -193,12 +188,6 @@ long WiFiServer::_accept(tcp_pcb* apcb, long err) {
|
||||
// user calls ::available()
|
||||
ClientContext* client = new ClientContext(apcb, &WiFiServer::_s_discard, this);
|
||||
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
|
||||
tcp_accepted(_listen_pcb);
|
||||
|
||||
#else
|
||||
|
||||
// backlog doc:
|
||||
// http://lwip.100.n7.nabble.com/Problem-re-opening-listening-pbc-tt32484.html#a32494
|
||||
// https://www.nongnu.org/lwip/2_1_x/group__tcp__raw.html#gaeff14f321d1eecd0431611f382fcd338
|
||||
@ -206,8 +195,6 @@ long WiFiServer::_accept(tcp_pcb* apcb, long err) {
|
||||
// increase lwIP's backlog
|
||||
tcp_backlog_delayed(apcb);
|
||||
|
||||
#endif
|
||||
|
||||
_unclaimed = slist_append_tail(_unclaimed, client);
|
||||
|
||||
return ERR_OK;
|
||||
|
@ -26,7 +26,6 @@ class UdpContext;
|
||||
extern "C" {
|
||||
void esp_yield();
|
||||
void esp_schedule();
|
||||
#include "lwip/init.h" // LWIP_VERSION_
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
@ -92,24 +91,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
|
||||
bool connect(IPAddress addr, uint16_t port)
|
||||
{
|
||||
_pcb->remote_ip = addr;
|
||||
_pcb->remote_port = port;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool listen(IPAddress addr, uint16_t port)
|
||||
{
|
||||
udp_recv(_pcb, &_s_recv, (void *) this);
|
||||
err_t err = udp_bind(_pcb, addr, port);
|
||||
return err == ERR_OK;
|
||||
}
|
||||
|
||||
#else // lwIP-v2
|
||||
|
||||
bool connect(const IPAddress& addr, uint16_t port)
|
||||
{
|
||||
_pcb->remote_ip = addr;
|
||||
@ -130,8 +111,6 @@ public:
|
||||
return err == ERR_OK;
|
||||
}
|
||||
|
||||
#endif // lwIP-v2
|
||||
|
||||
void disconnect()
|
||||
{
|
||||
udp_disconnect(_pcb);
|
||||
@ -166,11 +145,7 @@ public:
|
||||
|
||||
void setMulticastInterface(const IPAddress& addr)
|
||||
{
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
udp_set_multicast_netif_addr(_pcb, (ip_addr_t)addr);
|
||||
#else
|
||||
udp_set_multicast_netif_addr(_pcb, ip_2_ip4((const ip_addr_t*)addr));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // !LWIP_IPV6
|
||||
@ -180,11 +155,7 @@ public:
|
||||
*/
|
||||
void setMulticastInterface(netif* p_pNetIf)
|
||||
{
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
udp_set_multicast_netif_addr(_pcb, (p_pNetIf ? p_pNetIf->ip_addr : ip_addr_any));
|
||||
#else
|
||||
udp_set_multicast_netif_index(_pcb, (p_pNetIf ? netif_get_index(p_pNetIf) : NETIF_NO_INDEX));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -262,7 +233,7 @@ public:
|
||||
return _currentAddr.input_netif;
|
||||
}
|
||||
|
||||
CONST IPAddress& getRemoteAddress() CONST
|
||||
const IPAddress& getRemoteAddress() const
|
||||
{
|
||||
return _currentAddr.srcaddr;
|
||||
}
|
||||
@ -419,7 +390,7 @@ public:
|
||||
return size;
|
||||
}
|
||||
|
||||
bool send(CONST ip_addr_t* addr = 0, uint16_t port = 0)
|
||||
bool send(const ip_addr_t* addr = 0, uint16_t port = 0)
|
||||
{
|
||||
size_t data_size = _tx_buf_offset;
|
||||
pbuf* tx_copy = pbuf_alloc(PBUF_TRANSPORT, data_size, PBUF_RAM);
|
||||
@ -537,14 +508,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
#define TEMPDSTADDR (¤t_iphdr_dest)
|
||||
#define TEMPINPUTNETIF (current_netif)
|
||||
#else
|
||||
#define TEMPDSTADDR (ip_current_dest_addr())
|
||||
#define TEMPINPUTNETIF (ip_current_input_netif())
|
||||
#endif
|
||||
|
||||
// chain this helper pbuf first
|
||||
if (_rx_buf)
|
||||
{
|
||||
@ -570,7 +533,7 @@ private:
|
||||
return;
|
||||
}
|
||||
// construct in place
|
||||
new(PBUF_ALIGNER(pb_helper->payload)) AddrHelper(srcaddr, TEMPDSTADDR, srcport, TEMPINPUTNETIF);
|
||||
new(PBUF_ALIGNER(pb_helper->payload)) AddrHelper(srcaddr, ip_current_dest_addr(), srcport, ip_current_input_netif());
|
||||
pb_helper->flags = PBUF_HELPER_FLAG; // mark helper pbuf
|
||||
// chain it
|
||||
pbuf_cat(_rx_buf, pb_helper);
|
||||
@ -582,9 +545,9 @@ private:
|
||||
else
|
||||
{
|
||||
_currentAddr.srcaddr = srcaddr;
|
||||
_currentAddr.dstaddr = TEMPDSTADDR;
|
||||
_currentAddr.dstaddr = ip_current_dest_addr();
|
||||
_currentAddr.srcport = srcport;
|
||||
_currentAddr.input_netif = TEMPINPUTNETIF;
|
||||
_currentAddr.input_netif = ip_current_input_netif();
|
||||
|
||||
DEBUGV(":urn %d\r\n", pb->tot_len);
|
||||
_first_buf_taken = false;
|
||||
@ -597,102 +560,15 @@ private:
|
||||
_on_rx();
|
||||
}
|
||||
|
||||
#undef TEMPDSTADDR
|
||||
#undef TEMPINPUTNETIF
|
||||
|
||||
}
|
||||
|
||||
static void _s_recv(void *arg,
|
||||
udp_pcb *upcb, pbuf *p,
|
||||
CONST ip_addr_t *srcaddr, u16_t srcport)
|
||||
const ip_addr_t *srcaddr, u16_t srcport)
|
||||
{
|
||||
reinterpret_cast<UdpContext*>(arg)->_recv(upcb, p, srcaddr, srcport);
|
||||
}
|
||||
|
||||
#if LWIP_VERSION_MAJOR == 1
|
||||
/*
|
||||
* Code in this conditional block is copied/backported verbatim from
|
||||
* LwIP 2.1.2 to provide pbuf_get_contiguous.
|
||||
*/
|
||||
|
||||
static const struct pbuf *
|
||||
pbuf_skip_const(const struct pbuf *in, u16_t in_offset, u16_t *out_offset)
|
||||
{
|
||||
u16_t offset_left = in_offset;
|
||||
const struct pbuf *pbuf_it = in;
|
||||
|
||||
/* get the correct pbuf */
|
||||
while ((pbuf_it != NULL) && (pbuf_it->len <= offset_left)) {
|
||||
offset_left = (u16_t)(offset_left - pbuf_it->len);
|
||||
pbuf_it = pbuf_it->next;
|
||||
}
|
||||
if (out_offset != NULL) {
|
||||
*out_offset = offset_left;
|
||||
}
|
||||
return pbuf_it;
|
||||
}
|
||||
|
||||
u16_t
|
||||
pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
|
||||
{
|
||||
const struct pbuf *p;
|
||||
u16_t left = 0;
|
||||
u16_t buf_copy_len;
|
||||
u16_t copied_total = 0;
|
||||
|
||||
LWIP_ERROR("pbuf_copy_partial: invalid buf", (buf != NULL), return 0;);
|
||||
LWIP_ERROR("pbuf_copy_partial: invalid dataptr", (dataptr != NULL), return 0;);
|
||||
|
||||
/* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */
|
||||
for (p = buf; len != 0 && p != NULL; p = p->next) {
|
||||
if ((offset != 0) && (offset >= p->len)) {
|
||||
/* don't copy from this buffer -> on to the next */
|
||||
offset = (u16_t)(offset - p->len);
|
||||
} else {
|
||||
/* copy from this buffer. maybe only partially. */
|
||||
buf_copy_len = (u16_t)(p->len - offset);
|
||||
if (buf_copy_len > len) {
|
||||
buf_copy_len = len;
|
||||
}
|
||||
/* copy the necessary parts of the buffer */
|
||||
MEMCPY(&((char *)dataptr)[left], &((char *)p->payload)[offset], buf_copy_len);
|
||||
copied_total = (u16_t)(copied_total + buf_copy_len);
|
||||
left = (u16_t)(left + buf_copy_len);
|
||||
len = (u16_t)(len - buf_copy_len);
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
return copied_total;
|
||||
}
|
||||
|
||||
void *
|
||||
pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset)
|
||||
{
|
||||
const struct pbuf *q;
|
||||
u16_t out_offset;
|
||||
|
||||
LWIP_ERROR("pbuf_get_contiguous: invalid buf", (p != NULL), return NULL;);
|
||||
LWIP_ERROR("pbuf_get_contiguous: invalid dataptr", (buffer != NULL), return NULL;);
|
||||
LWIP_ERROR("pbuf_get_contiguous: invalid dataptr", (bufsize >= len), return NULL;);
|
||||
|
||||
q = pbuf_skip_const(p, offset, &out_offset);
|
||||
if (q != NULL) {
|
||||
if (q->len >= (out_offset + len)) {
|
||||
/* all data in this pbuf, return zero-copy */
|
||||
return (u8_t *)q->payload + out_offset;
|
||||
}
|
||||
/* need to copy */
|
||||
if (pbuf_copy_partial(q, buffer, len, out_offset) != len) {
|
||||
/* copying failed: pbuf is too short */
|
||||
return NULL;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
/* pbuf is too short (offset does not fit in) */
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
udp_pcb* _pcb;
|
||||
pbuf* _rx_buf;
|
||||
|
Reference in New Issue
Block a user