Skip to content
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

IPv6 on esp8266-nonos-sdk and arduino #5136

Merged
merged 127 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
6c64759
wip
d-a-v Aug 22, 2018
746ec81
cc wip
d-a-v Aug 22, 2018
53c9222
cc wip
d-a-v Aug 22, 2018
6de50d4
cc comments
d-a-v Aug 22, 2018
2dd152d
wip cc
d-a-v Aug 24, 2018
f87602a
+sync, get/set default nodelay, sync
d-a-v Aug 27, 2018
6be4b6f
default nodelay=1
d-a-v Aug 28, 2018
8f7fb1e
update flush()
d-a-v Aug 28, 2018
c0bea2b
fix return value
d-a-v Aug 28, 2018
d00ac35
ClientContext: put things together
d-a-v Aug 28, 2018
53a19a8
Merge branch 'master' into ClientContext
devyte Sep 5, 2018
a662bfc
use ip4_addr instead of ip_addr
d-a-v May 23, 2018
b751983
ip4* -> ipv4*
d-a-v Aug 30, 2018
fc1719e
ipv6 wip
d-a-v Aug 30, 2018
68c207c
wip ipv6
d-a-v Sep 5, 2018
e18c276
wip ipv6
d-a-v Sep 5, 2018
090c5d5
ipv6: now compiles and links
d-a-v Sep 6, 2018
2fcd96c
wip ipv6: simplification of IPAddress + fix nasty reinterpret_cast bug
d-a-v Sep 6, 2018
eb666fb
wip ipv6
d-a-v Sep 6, 2018
ad02962
wip ipv6
d-a-v Sep 7, 2018
6718fe6
wip ipv6 lwIP-2.1rc0, menus
d-a-v Sep 10, 2018
95e8afe
wip ipv6
d-a-v Sep 10, 2018
de36650
wip ipv6
d-a-v Sep 11, 2018
d21916d
use ip4_addr instead of ip_addr
d-a-v May 23, 2018
0b11b17
ip4* -> ipv4*
d-a-v Aug 30, 2018
537b4da
ipv6 wip
d-a-v Aug 30, 2018
8f2ad74
wip ipv6
d-a-v Sep 5, 2018
c398663
wip ipv6
d-a-v Sep 5, 2018
b26701a
ipv6: now compiles and links
d-a-v Sep 6, 2018
9903be1
wip ipv6: simplification of IPAddress + fix nasty reinterpret_cast bug
d-a-v Sep 6, 2018
20bbdb3
wip ipv6
d-a-v Sep 6, 2018
b05dd81
wip ipv6
d-a-v Sep 7, 2018
b96c1c0
Merge branch 'ipv6' of github.com:d-a-v/Arduino into ipv6
d-a-v Sep 13, 2018
643036f
wip ipv6: now tcp server is working too :)
d-a-v Sep 14, 2018
86ba377
Merge branch 'ClientContext' into ipv6-test
d-a-v Sep 14, 2018
347130e
Merge branch 'master' into ipv6-test
devyte Sep 14, 2018
3c6ecb7
ipv6 fixes from lwip2 (dhcp6 working, beware: your esp is now accessi…
d-a-v Sep 15, 2018
5799d7e
parse and show standard ipv6 + WiFi.localIP6Link()/localIP6Global()
d-a-v Sep 16, 2018
d93ff6f
IPv6 initial example sketch
d-a-v Sep 17, 2018
54a50e2
liblwip2.a -> liblwip2_536.a
d-a-v Sep 17, 2018
43c5c9f
getFullVersion: lwIP version was displayed twice
d-a-v Sep 17, 2018
a777aa3
udp with IPV6 fixes
d-a-v Sep 17, 2018
1f48ad7
fix generic ip type management
d-a-v Sep 17, 2018
e3da355
lwip2: disable debug
d-a-v Sep 17, 2018
22f5701
lwip2: disable debug
d-a-v Sep 17, 2018
389bf07
lwip2: disable debug
d-a-v Sep 17, 2018
402c35e
update example with UDP showing remote v4 or v6 address
d-a-v Sep 17, 2018
53931c5
wip
d-a-v Aug 22, 2018
81ec0f4
cc wip
d-a-v Aug 22, 2018
fbf1dd1
cc wip
d-a-v Aug 22, 2018
b4a918f
cc comments
d-a-v Aug 22, 2018
c14eeef
wip cc
d-a-v Aug 24, 2018
238610e
+sync, get/set default nodelay, sync
d-a-v Aug 27, 2018
d0036a1
default nodelay=1
d-a-v Aug 28, 2018
e4c187b
update flush()
d-a-v Aug 28, 2018
d31d6f2
fix return value
d-a-v Aug 28, 2018
5cf60b6
ClientContext: put things together
d-a-v Aug 28, 2018
a058506
Move SSLContext to its own header (#5121)
earlephilhower Sep 17, 2018
a7a5959
Fix connection options and update github pubkey (#5120)
earlephilhower Sep 17, 2018
d06cac2
ClientContext: fix debugging messages
d-a-v Sep 18, 2018
976b749
Merge branch 'ClientContext' into ipv6-test
d-a-v Sep 18, 2018
ad61dfc
Esp.getFullVersion: show when IPv6 is enabled
d-a-v Sep 18, 2018
ede6e44
fixes lwip-v2 compatibilities with lwip-1.4 (check IPAddress.h's begi…
d-a-v Sep 18, 2018
2693714
enable nagle by default
d-a-v Sep 18, 2018
1bc5bc8
minor update to IPv6 example
d-a-v Sep 18, 2018
e67b6f0
astyled example
d-a-v Sep 18, 2018
c7859ba
LLMNR: restore a removed test
d-a-v Sep 18, 2018
636aa28
mDNSlib porting (multicast api changes like for MMNR SSDP)
d-a-v Sep 18, 2018
17ba0f6
fix: IPAddress is now rich, and cast to uint32_t is sometimes ambiguo…
d-a-v Sep 18, 2018
afa747d
port OTA
d-a-v Sep 18, 2018
0bbd791
IPAddress cosmetic
d-a-v Sep 18, 2018
4708451
add const to Ethernet and friends
d-a-v Sep 18, 2018
e8c659e
Merge branch 'master' into ClientContext
earlephilhower Sep 18, 2018
63e1da7
fix DNS
d-a-v Sep 18, 2018
b9f79f5
Merge branch 'master' into ipv6-test
d-a-v Sep 18, 2018
f271b2a
WiFiClient: move static members out of the class, add comments
d-a-v Sep 18, 2018
7f57694
Merge branch 'ClientContext' of github.com:d-a-v/Arduino into ClientC…
d-a-v Sep 18, 2018
888bdb8
remove circular dependency
d-a-v Sep 19, 2018
9d31c78
Merge branch 'ClientContext' into ipv6-test
d-a-v Sep 19, 2018
15e7dfe
IPAddress needs to be copied
d-a-v Sep 19, 2018
c8a81e5
IPAddress needs to be copied
d-a-v Sep 19, 2018
254c252
IPaddress: fix nullptr
d-a-v Sep 19, 2018
c2b0b96
add missing files (due to update to lwIP-2.1rc1)
d-a-v Sep 19, 2018
8f53b52
ipv6 example: use ipv6.google.com, shows status in udp:23, show versions
d-a-v Sep 19, 2018
0b7456b
Merge branch 'master' into ipv6-test
devyte Sep 21, 2018
64802a0
interface list for c++
d-a-v Sep 22, 2018
b7cd735
Merge branch 'master' into ipv6-test
d-a-v Sep 22, 2018
ba4a4d0
Merge branch 'master' into ipv6-test
d-a-v Sep 24, 2018
0393171
Merge branch 'master' into ipv6-test
d-a-v Sep 25, 2018
f63d2c7
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Sep 25, 2018
0cde770
+ IfList: interface iterator
d-a-v Sep 26, 2018
e855977
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Sep 26, 2018
4f97603
rename ifList to addrList, more accessors, updated example
d-a-v Sep 26, 2018
a6faa9d
Merge branch 'master' into ipv6-test
d-a-v Sep 27, 2018
b1e9cb5
Merge branch 'master' into ipv6-test
d-a-v Sep 28, 2018
10638ba
Merge branch 'master' into ipv6-test
d-a-v Sep 29, 2018
5948b93
Merge branch 'master' into ipv6-test
d-a-v Oct 1, 2018
bd85431
update example & comments and AddrList API
d-a-v Oct 1, 2018
0de3365
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Oct 1, 2018
f986cfe
astyle
d-a-v Oct 1, 2018
190c016
Merge branch 'master' into ipv6-test
d-a-v Oct 2, 2018
94eef5f
Merge branch 'master' into ipv6-test2
d-a-v Oct 9, 2018
f4cb3a6
cleaning
d-a-v Oct 9, 2018
bc654a3
Merge branch 'master' into ipv6-test
d-a-v Nov 26, 2018
849f87a
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Nov 26, 2018
29618dc
use CONST in place of constv2
d-a-v Nov 26, 2018
38efc64
Merge branch 'master' into ipv6-test
d-a-v Nov 26, 2018
1d78618
+ IPAddress::fromString4()
d-a-v Nov 26, 2018
bcd8fcd
use StringStream:: for ::toString()
d-a-v Nov 26, 2018
53b099b
use periodic timeout
d-a-v Nov 26, 2018
366d3a7
minor updates on interface iterator
d-a-v Nov 26, 2018
2dcf863
check for IPv4 addresses for softAP intialization
d-a-v Nov 26, 2018
82eecf3
comment
d-a-v Nov 27, 2018
0d7cd7d
document preprocessing #error directive
d-a-v Nov 27, 2018
523aa05
remove lowpan*
d-a-v Nov 27, 2018
97d2032
fix example
d-a-v Nov 27, 2018
ece7393
pio build
d-a-v Nov 27, 2018
b526eef
remove ifList from ESP8266WiFi.cpp
d-a-v Nov 27, 2018
d377bad
fix boards.txt
d-a-v Nov 27, 2018
271e94f
cast return type
d-a-v Nov 27, 2018
326f705
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Nov 27, 2018
d2bad35
rename IfList -> AddrList
d-a-v Nov 27, 2018
9ea8f0e
rename IfList to AddrList
d-a-v Nov 27, 2018
f530d84
fix example
d-a-v Nov 27, 2018
c16a111
check WiFi.config args for v4()
d-a-v Nov 27, 2018
72a64f0
remove tools/sdk/include/mesh.h
d-a-v Nov 27, 2018
fdcca1f
update lwIP to 2.1.2 stable, glue tagged 1.0 stable
d-a-v Nov 27, 2018
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
464 changes: 348 additions & 116 deletions boards.txt

Large diffs are not rendered by default.

168 changes: 168 additions & 0 deletions cores/esp8266/AddrList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*
AddrList.h - cycle through lwIP netif's ip addresses like a c++ list
Copyright (c) 2018 david gauchard. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/*
This class allows to explore all configured IP addresses
in lwIP netifs, with that kind of c++ loop:

for (auto a: ifList)
out.printf("IF='%s' index=%d legacy=%d IPv4=%d local=%d hostname='%s' addr= %s\n",
a->iface().c_str(),
a->number(),
a->addr().isLegacy(),
a->addr().isV4(),
a->addr().isLocal(),
a->hostname().c_str(),
a->addr().toString().c_str());

This loop:

while (WiFi.status() != WL_CONNECTED()) {
Serial.print('.');
delay(500);
}

can be replaced by:

for (bool configured = false; !configured; ) {
for (auto iface: ifList)
if ((configured = !iface->addr().isLocal())
break;
Serial.print('.');
delay(500);
}

waiting for an IPv6 global address:

for (bool configured = false; !configured; ) {
for (auto iface: ifList)
if ((configured = ( !iface->addr()->isV4()
&& !iface->addr().isLocal())))
break;
Serial.print('.');
delay(500);
}

waiting for an IPv6 global address, on a specific interface:

for (bool configured = false; !configured; ) {
for (auto iface: ifList)
if ((configured = ( !iface->addr()->isV4()
&& !iface->addr().isLocal()
&& iface->number() == STATION_IF)))
break;
Serial.print('.');
delay(500);
}
*/

#ifndef __ADDRLIST_H
#define __ADDRLIST_H

#include <IPAddress.h>
#include <lwip/netif.h>

#if LWIP_IPV6
#define IF_NUM_ADDRESSES (1 + LWIP_IPV6_NUM_ADDRESSES)
#else
#define IF_NUM_ADDRESSES (1)
#endif


class AddrListClass {

// no member in this class
// lwIP's global 'struct netif* netif_list' is used
// designed to be used with 'for (auto x: ifList)'

public:

class const_iterator {

public:

// iterator operations:

const_iterator (bool begin = true): _netif(begin? netif_list: nullptr), _num(-1) { ++*this; }
const_iterator (const const_iterator& o): _netif(o._netif), _num(o._num) { }
const_iterator& operator= (const const_iterator& o) { _netif = o._netif; _num = o._num; return *this; }

bool operator!= (const const_iterator& o) { return !equal(o); }
bool operator== (const const_iterator& o) { return equal(o); }

const_iterator operator++(int) {
const_iterator ret = *this;
++(*this);
return ret;
}

const_iterator& operator++() {
while (_netif) {
if (++_num == IF_NUM_ADDRESSES) {
_num = -1;
_netif = _netif->next;
continue;
}
if (!ip_addr_isany(_ip_from_netif_num()))
break;
}
return *this;
}

// (*iterator) emulation:

const const_iterator& operator* () const { return *this; }
const const_iterator* operator-> () const { return this; }

bool isLegacy() const { return _num == 0; }
bool isLocal() const { return addr().isLocal(); }
IPAddress addr () const { return _ip_from_netif_num(); }
IPAddress netmask () const { return _netif->netmask; }
IPAddress gw () const { return _netif->gw; }
String iface () const { return String(_netif->name[0]) + _netif->name[1]; }
const char* hostname () const { return _netif->hostname?: emptyString.c_str(); }
const char* mac () const { return (const char*)_netif->hwaddr; }
int number () const { return _netif->num; }

protected:

bool equal (const const_iterator& o) {
return _netif == o._netif
&& (!_netif || _num == o._num);
}

const ip_addr_t* _ip_from_netif_num () const {
#if LWIP_IPV6
return _num? &_netif->ip6_addr[_num - 1]: &_netif->ip_addr;
#else
return &_netif->ip_addr;
#endif
}

netif* _netif;
int _num; // address index (0 is legacy, _num-1 is ip6_addr[]'s index)
};

const const_iterator begin () const { return const_iterator(true); }
const const_iterator end () const { return const_iterator(false); }
};

extern AddrListClass addrList;

#endif // __ADDRLIST_H
4 changes: 2 additions & 2 deletions cores/esp8266/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class Client: public Stream {

public:
virtual int connect(IPAddress ip, uint16_t port) =0;
virtual int connect(CONST IPAddress& ip, uint16_t port) =0;
virtual int connect(const char *host, uint16_t port) =0;
virtual size_t write(uint8_t) =0;
virtual size_t write(const uint8_t *buf, size_t size) =0;
Expand All @@ -39,7 +39,7 @@ class Client: public Stream {
virtual uint8_t connected() = 0;
virtual operator bool() = 0;
protected:
uint8_t* rawIPAddress(IPAddress& addr) {
CONST uint8_t* rawIPAddress(CONST IPAddress& addr) {
return addr.raw_address();
}
;
Expand Down
14 changes: 6 additions & 8 deletions cores/esp8266/Esp-version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
#define STR(x) STRHELPER(x) // stringifier

static const char arduino_esp8266_git_ver [] PROGMEM = STR(ARDUINO_ESP8266_GIT_DESC);
#if LWIP_VERSION_MAJOR != 1
static const char lwip2_version [] PROGMEM = "/lwIP:" STR(LWIP_VERSION_MAJOR) "." STR(LWIP_VERSION_MINOR) "." STR(LWIP_VERSION_REVISION);
#endif
static const char bearssl_version [] PROGMEM = "/BearSSL:" STR(BEARSSL_GIT);

String EspClass::getFullVersion()
Expand All @@ -40,17 +37,18 @@ String EspClass::getFullVersion()
+ F("/Core:") + FPSTR(arduino_esp8266_git_ver)
#if LWIP_VERSION_MAJOR == 1
+ F("/lwIP:") + String(LWIP_VERSION_MAJOR) + "." + String(LWIP_VERSION_MINOR) + "." + String(LWIP_VERSION_REVISION)
#else
+ FPSTR(lwip2_version)
#endif
#if LWIP_VERSION_IS_DEVELOPMENT
+ F("-dev")
#endif
#if LWIP_VERSION_IS_RC
+ F("rc") + String(LWIP_VERSION_RC)
#endif
#ifdef LWIP_HASH_STR
+ "(" + F(LWIP_HASH_STR) + ")"
#else // LWIP_VERSION_MAJOR != 1
+ F("/lwIP:")
#if LWIP_IPV6
+ F("IPv6+")
#endif
+ F(LWIP_HASH_STR)
#endif
+ FPSTR(bearssl_version)
;
Expand Down
Loading