8000 remove lwip-v1.4 specific code by d-a-v · Pull Request #7436 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

remove lwip-v1.4 specific code #7436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
remove lwip-v1.4 specific code
  • Loading branch information
d-a-v committed Jul 7, 2020
commit 16cb8b8c8b7f0889495a3f44cbd802e569605c1f
11 changes: 0 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@ jobs:
env:
- BUILD_PARITY=odd

- name: "Build lwIP-v1.4 (1)"
stage: build
script: $TRAVIS_BUILD_DIR/tests/build1.sh
env:
- BUILD_PARITY=even
- name: "Build lwIP-v1.4 (2)"
stage: build
script: $TRAVIS_BUILD_DIR/tests/build1.sh
env:
- BUILD_PARITY=odd

- name: "Mac OSX can build sketches"
os: osx
stage: build
Expand Down
238 changes: 0 additions & 238 deletions boards.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cores/esp8266/AddrList.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct netifWrapper
const char* ifmac () const { return (const char*)_netif->hwaddr; }
int ifnumber () const { return _netif->num; }
bool ifUp () const { return !!(_netif->flags & NETIF_FLAG_UP); }
CONST netif* interface () const { return _netif; }
const netif* interface () const { return _netif; }

const ip_addr_t* ipFromNetifNum () const
{
Expand Down
8000
2 changes: 0 additions & 2 deletions cores/esp8266/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ class Client: public Stream {
uint8_t* rawIPAddress(IPAddress& addr) {
return addr.raw_address();
}
#if LWIP_VERSION_MAJOR != 1
const uint8_t* rawIPAddress(const IPAddress& addr) {
return addr.raw_address();
}
#endif
};

#endif
3 changes: 0 additions & 3 deletions cores/esp8266/Esp-version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,18 @@
#include <Arduino.h>
#include <user_interface.h>
#include <core_version.h>
#include <lwip/init.h> // LWIP_VERSION_*
#include <lwipopts.h> // LWIP_HASH_STR (lwip2)
#include <bearssl/bearssl_git.h> // BEARSSL_GIT short hash

#define STRHELPER(x) #x
#define STR(x) STRHELPER(x) // stringifier

static const char arduino_esp8266_git_ver [] PROGMEM = "/Core:" STR(ARDUINO_ESP8266_GIT_DESC) "=";
#if LWIP_VERSION_MAJOR > 1
#if LWIP_IPV6
static const char lwip_version [] PROGMEM = "/lwIP:IPv6+" LWIP_HASH_STR;
#else
static const char lwip_version [] PROGMEM = "/lwIP:" LWIP_HASH_STR;
#endif
#endif
static const char bearssl_version [] PROGMEM = "/BearSSL:" STR(BEARSSL_GIT);

String EspClass::getFullVersion() {
Expand Down
2 changes: 1 addition & 1 deletion cores/esp8266/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ bool IPAddress::isValid(const char* arg) {
return IPAddress().fromString(arg);
}

CONST IPAddress INADDR_ANY; // generic "0.0.0.0" for IPv4 & IPv6
const IPAddress INADDR_ANY; // generic "0.0.0.0" for IPv4 & IPv6
const IPAddress INADDR_NONE(255,255,255,255);

/**************************************/
Expand Down
22 changes: 2 additions & 20 deletions cores/esp8266/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,9 @@
#include <lwip/init.h>
#include <lwip/ip_addr.h>

#if LWIP_VERSION_MAJOR == 1
// compatibility macros to make lwIP-v1 compiling lwIP-v2 API
#define LWIP_IPV6_NUM_ADDRESSES 0
#define ip_2_ip4(x) (x)
#define ipv4_addr ip_addr
#define ipv4_addr_t ip_addr_t
#define IP_IS_V4_VAL(x) (1)
#define IP_SET_TYPE_VAL(x,y) do { (void)0; } while (0)
#define IP_ANY_TYPE (&ip_addr_any)
#define IP4_ADDR_ANY IPADDR_ANY
#define IP4_ADDR_ANY4 IP_ADDR_ANY
#define IPADDR4_INIT(x) { x }
#define CONST /* nothing: lwIP-v1 does not use const */
#define ip4_addr_netcmp ip_addr_netcmp
#define netif_dhcp_data(netif) ((netif)->dhcp)
#else // lwIP-v2+
#define CONST const
#if !LWIP_IPV6
struct ip_addr: ipv4_addr { };
//struct ip_addr: ipv4_addr { };
#endif // !LWIP_IPV6
#endif // lwIP-v2+

// A class to make it easier to handle and pass around IP addresses
// IPv6 update:
Expand Down Expand Up @@ -220,7 +202,7 @@ class IPAddress: public Printable {

};

extern CONST IPAddress INADDR_ANY;
extern const IPAddress INADDR_ANY;
extern const IPAddress INADDR_NONE;

#endif
4 changes: 2 additions & 2 deletions cores/esp8266/Udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ class UDP: public Stream {
// Return the port of the host who sent the current incoming packet
virtual uint16_t remotePort() =0;
protected:

uint8_t* rawIPAddress(IPAddress& addr) {
return addr.raw_address();
}
#if LWIP_VERSION_MAJOR != 1

const uint8_t* rawIPAddress(const IPAddress& addr) {
return addr.raw_address();
}
#endif
};

#endif
40 changes: 0 additions & 40 deletions cores/esp8266/sntp-lwip2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,6 @@ void settimeofday_cb (const TrivialCB& cb)

extern "C" {

#if LWIP_VERSION_MAJOR == 1

#include <pgmspace.h>

static const char stod14[] PROGMEM = "settimeofday() can't set time!\n";
bool sntp_set_timezone(sint8 timezone);
bool sntp_set_timezone_in_seconds(int32_t timezone)
{
return sntp_set_timezone((sint8)(timezone/(60*60))); //TODO: move this to the same file as sntp_set_timezone() in lwip1.4, and implement correctly over there.
}

void sntp_set_daylight(int daylight);

int settimeofday(const struct timeval* tv, const struct timezone* tz)
{
if (tz) /*before*/
{
sntp_set_timezone_in_seconds(tz->tz_minuteswest * 60);
// apparently tz->tz_dsttime is a bitfield and should not be further used (cf man)
sntp_set_daylight(0);
}
if (tv) /* after*/
{
// can't call lwip1.4's static sntp_set_system_time()
os_printf(stod14);

// reset time subsystem
timeshift64_is_set = false;

return -1;
}
return 0;
}

#endif // lwip 1.4 only

#if LWIP_VERSION_MAJOR == 2

#include <lwip/apps/sntp.h>

uint32_t sntp_real_timestamp = 0;
Expand Down Expand Up @@ -128,6 +90,4 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz)
return 0;
}

#endif // lwip2 only

};
9 changes: 0 additions & 9 deletions cores/esp8266/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ int clock_gettime(clockid_t unused, struct timespec *tp)
return 0;
}

#if LWIP_VERSION_MAJOR == 1
// hack for espressif time management included in patched lwIP-1.4
#define sntp_real_timestamp sntp_get_current_timestamp()
#endif

#if LWIP_VERSION_MAJOR != 1

// backport Espressif api

bool sntp_set_timezone_in_seconds (int32_t timezone_sec)
Expand All @@ -103,8 +96,6 @@ uint32 sntp_get_current_timestamp()
return sntp_real_timestamp;
}

#endif

time_t time(time_t * t)
{
if (t)
Expand Down
9 changes: 2 additions & 7 deletions libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,16 @@ void ESP8266NetBIOS::end()
}
}

void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint16_t port)
void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t port)
{
(void)upcb;
(void)addr;
(void)port;
while(pb != NULL) {
uint8_t * data = (uint8_t*)((pb)->payload);
size_t len = pb->len;
#if LWIP_VERSION_MAJOR == 1
// check UdpContext.h
ip_addr_t* saddr = &current_iphdr_src;
#else
// check UdpContext.h
const ip_addr_t* saddr = &ip_data.current_iphdr_src;
#endif

if (len >= sizeof(struct NBNSQUESTION)) {
struct NBNSQUESTION * question = (struct NBNSQUESTION *)data;
Expand Down Expand Up @@ -267,7 +262,7 @@ void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint1
}
}

void ESP8266NetBIOS::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, CONST ip_addr_t *addr, uint16_t port)
void ESP8266NetBIOS::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, const ip_addr_t *addr, uint16_t port)
{
reinterpret_cast<ESP8266NetBIOS*>(arg)->_recv(upcb, p, addr, port);
}
Expand Down
5 changes: 2 additions & 3 deletions libraries/ESP8266NetBIOS/ESP8266NetBIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#define __ESPNBNS_h__

extern "C" {
#include "lwip/init.h" // LWIP_VERSION_
#include <lwip/ip_addr.h>
}
#include <ESP8266WiFi.h>
Expand All @@ -28,8 +27,8 @@ class ESP8266NetBIOS
void _getnbname(char *nbname, char *name, uint8_t maxlen);
void _makenbname(char *name, char *nbname, uint8_t outlen);

void _recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint16_t port);
static void _s_recv(void *arg, udp_pcb *upcb, pbuf *p, CONST ip_addr_t *addr, uint16_t port);
void _recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t port);
static void _s_recv(void *arg, udp_pcb *upcb, pbuf *p, const ip_addr_t *addr, uint16_t port);

public:
ESP8266NetBIOS();
Expand Down
16 changes: 0 additions & 16 deletions libraries/ESP8266WiFi/examples/StaticLease/StaticLease.ino
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -104,5 +90,3 @@ void setup() {
void loop() {
server.handleClient();
}

#endif // lwIP-v2
15 changes: 3 additions & 12 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down
15 changes: 1 addition & 14 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGratuitous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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;
Expand Down
Loading
0