10000 IPv6 on esp8266-nonos-sdk and arduino by d-a-v · Pull Request #5136 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

IPv6 on esp8266-nonos-sdk and arduino #5136

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 127 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ipv6: now compiles and links
  • Loading branch information
d-a-v committed Sep 13, 2018
commit b26701a08fe32f67385cb74ceb0987c9402330ac
30 changes: 15 additions & 15 deletions cores/esp8266/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
#include <Print.h>

IPAddress::IPAddress() {
_address.dword = 0;
ipv4() = 0;
}

IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) {
_address.bytes[0] = first_octet;
_address.bytes[1] = second_octet;
_address.bytes[2] = third_octet;
_address.bytes[3] = fourth_octet;
(*this)[0] = first_octet;
(*this)[1] = second_octet;
(*this)[2] = third_octet;
(*this)[3] = fourth_octet;
}

IPAddress::IPAddress(uint32_t address) {
_address.dword = address;
ipv4() = address;
}

IPAddress::IPAddress(const uint8_t *address) {
memcpy(_address.bytes, address, sizeof(_address.bytes));
ipv4() = *reinterpret_cast<const uint32_t*>(address);
}

bool IPAddress::fromString(const char *address) {
Expand All @@ -63,7 +63,7 @@ bool IPAddress::fromString(const char *address) {
// Too much dots (there must be 3 dots)
return false;
}
_address.bytes[dots++] = acc;
(*this)[dots++] = acc;
acc = 0;
}
else
Expand All @@ -77,38 +77,38 @@ bool IPAddress::fromString(const char *address) {
// Too few dots (there must be 3 dots)
return false;
}
_address.bytes[3] = acc;
(*this)[3] = acc;
return true;
}

IPAddress& IPAddress::operator=(const uint8_t *address) {
memcpy(_address.bytes, address, sizeof(_address.bytes));
ipv4() = *reinterpret_cast<const uint32_t*>(address);
return *this;
}

IPAddress& IPAddress::operator=(uint32_t address) {
_address.dword = address;
ipv4() = address;
return *this;
}

bool IPAddress::operator==(const uint8_t* addr) const {
return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0;
return ipv4() == *reinterpret_cast<const uint32_t*>(addr);
}

size_t IPAddress::printTo(Print& p) const {
size_t n = 0;
for(int i = 0; i < 3; i++) {
n += p.print(_address.bytes[i], DEC);
n += p.print((*this)[i], DEC);
n += p.print('.');
}
n += p.print(_address.bytes[3], DEC);
n += p.print((*this)[3], DEC);
return n;
}

String IPAddress::toString() const
{
char szRet[16];
sprintf(szRet,"%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]);
sprintf(szRet,"%u.%u.%u.%u", (*this)[0], (*this)[1], (*this)[2], (*this)[3]);
return String(szRet);
}

Expand Down
28 changes: 16 additions & 12 deletions cores/esp8266/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,27 @@
#include <WString.h>
#include <Printable.h>

#include <lwip/init.h>
#include <lwip/ip_addr.h>

// A class to make it easier to handle and pass around IP addresses

class IPAddress: public Printable {
private:
union {
uint8_t bytes[4]; // IPv4 address
uint32_t dword;
} _address;

ip_addr_t _ip;

//uint32_t& ipv4() { return ip_2_ip4(&_ip)->addr; } __attribute__((always_inline));

u32_t& ipv4() { return ip_2_ip4(&_ip)->addr; } __attribute__((always_inline));
u32_t ipv4() const { return ip_2_ip4(&_ip)->addr; } __attribute__((always_inline));

// Access the raw byte array containing the address. Because this returns a pointer
// to the internal structure rather than a copy of the address this function should only
// be used when you know that the usage of the returned uint8_t* will be transient and not
// stored.
uint8_t* raw_address() {
return _address.bytes;
return reinterpret_cast<uint8_t*>(ipv4());
}

public:
Expand All @@ -49,30 +53,29 @@ class IPAddress: public Printable {
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
IPAddress(uint32_t address);
IPAddress(const uint8_t *address);
IPAddress(const ip_addr_t* lwip_addr);

bool fromString(const char *address);
bool fromString(const String &address) { return fromString(address.c_str()); }

// Overloaded cast operator to allow IPAddress objects to be used where a pointer
// to a four-byte uint8_t array is expected
operator uint32_t() const {
return _address.dword;
return ipv4();
}
bool operator==(const IPAddress& addr) const {
return _address.dword == addr._address.dword;
return ipv4() == addr.ipv4();
}
bool operator==(uint32_t addr) const {
return _address.dword == addr;
return ipv4() == addr;
}
bool operator==(const uint8_t* addr) const;

// Overloaded index operator to allow getting and setting individual octets of the address
uint8_t operator[](int index) co 341A nst {
return _address.bytes[index];
return (ipv4() >> (index << 3)) & 0xff;
}
uint8_t& operator[](int index) {
return _address.bytes[index];
return *(raw_address() + index);
}

// Overloaded copy operators to allow initialisation of IPAddress objects from other types
Expand Down Expand Up @@ -100,7 +103,8 @@ class IPAddress: public Printable {
/*
lwIP address compatibility
*/
const ip_addr_t* getLwipAddr() const;
IPAddress(const ip_addr_t* lwip_addr) { _ip = *lwip_addr; }
const ip_addr_t* getLwipAddr() const { return &_ip; }
};

extern const IPAddress INADDR_NONE;
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ int ESP8266WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResul
DEBUG_WIFI_GENERIC("[hostByName] request IP for: %s\n", aHostname);
err_t err = dns_gethostbyname(aHostname, &addr, &wifi_dns_found_callback, &aResult);
if(err == ERR_OK) {
aResult = addr.addr;
aResult = IPAddress(&addr);
} else if(err == ERR_INPROGRESS) {
_dns_lookup_pending = true;
delay(timeout_ms);
Expand Down Expand Up @@ -503,7 +503,7 @@ void wifi_dns_found_callback(const char *name, const ip_addr_t *ipaddr, void *ca
return;
}
if(ipaddr) {
(*reinterpret_cast<IPAddress*>(callback_arg)) = ipaddr->addr;
(*reinterpret_cast<IPAddress*>(callback_arg)) = IPAddress(ipaddr);
}
esp_schedule(); // resume the hostByName function
}
Expand Down
11 changes: 3 additions & 8 deletions libraries/ESP8266WiFi/src/WiFiUdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ uint8_t WiFiUDP::beginMulticast(const IPAddress& interfaceAddr, const IPAddress&
_ctx = 0;
}

if (igmp_joingroup(interfaceAddr.getLwipAddr(), multicast.getLwipAddr())!= ERR_OK) {
if (igmp_joingroup(ip_2_ip4(interfaceAddr.getLwipAddr()), ip_2_ip4(multicast.getLwipAddr()))!= ERR_OK) {
return 0;
}

Expand Down Expand Up @@ -158,19 +158,14 @@ int WiFiUDP::beginPacket(const IPAddress& ip, uint16_t port)
int WiFiUDP::beginPacketMulticast(const IPAddress& multicastAddress, uint16_t port,
const IPAddress& interfaceAddress, int ttl)
{
ipv4_addr_t mcastAddr;
mcastAddr.addr = multicastAddress;
ipv4_addr_t ifaceAddr;
ifaceAddr.addr = interfaceAddress;

if (!_ctx) {
_ctx = new UdpContext;
_ctx->ref();
}
if (!_ctx->connect(mcastAddr, port)) {
if (!_ctx->connect(multicastAddress.getLwipAddr(), port)) {
return 0;
}
_ctx->setMulticastInterface(ifaceAddr);
_ctx->setMulticastInterface(interfaceAddress.getLwipAddr());
_ctx->setMulticastTTL(ttl);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiUdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class WiFiUDP : public UDP, public SList<WiFiUDP> {

// Start building up a packet to send to the remote host specific in ip and port
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
virtual int beginPacket(IPAddress ip, uint16_t port);
virtual int beginPacket(const IPAddress& ip, uint16_t port);
// Start building up a packet to send to the remote host specific in host and port
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
virtual int beginPacket(const char *host, uint16_t port);
Expand Down
13 changes: 9 additions & 4 deletions libraries/ESP8266WiFi/src/include/UdpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,17 @@ class UdpContext
return (pos <= _rx_buf->len);
}

#pragma message "FIXME"
static ip_addr_t blark;

const ip_addr_t* getRemoteAddress()
{
if (!_rx_buf)
return 0;

ip_hdr* iphdr = GET_IP_HDR(_rx_buf);
return iphdr->src;
//ip_hdr* iphdr = GET_IP_HDRs(_rx_buf);
//return iphdr->src;
return &blark;
}

uint16_t getRemotePort()
Expand All @@ -182,8 +186,9 @@ class UdpContext
if (!_rx_buf)
return 0;

ip_hdr* iphdr = GET_IP_HDR(_rx_buf);
return iphdr->dest;
//ip_hdr* iphdr = GET_IP_HDR(_rx_buf);
//return iphdr->dest;
return &blark;
}

uint16_t getLocalPort()
Expand Down
0