1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

IPv6 on esp8266-nonos-sdk and arduino (#5136)

This commit is contained in:
david gauchard
2018-11-27 23:07:47 +01:00
committed by GitHub
parent a501d3ca3b
commit 5c4db3acf4
59 changed files with 1270 additions and 809 deletions

View File

@ -38,6 +38,9 @@ extern "C" {
#include "lwip/err.h"
#include "lwip/dns.h"
#include "lwip/init.h" // LWIP_VERSION_
#if LWIP_IPV6
#include "lwip/netif.h" // struct netif
#endif
}
#include "debug.h"
@ -117,7 +120,7 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
struct station_config conf;
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
conf.threshold.authmode = AUTH_OPEN;
if(passphrase) {
@ -244,15 +247,20 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a
dns1 = arg1;
}
// check whether all is IPv4 (or gateway not set)
if (!(local_ip.isV4() && subnet.isV4() && (!gateway.isSet() || gateway.isV4()))) {
return false;
}
//ip and gateway must be in the same subnet
if((local_ip & subnet) != (gateway & subnet)) {
if((local_ip.v4() & subnet.v4()) != (gateway.v4() & subnet.v4())) {
return false;
}
struct ip_info info;
info.ip.addr = static_cast<uint32_t>(local_ip);
info.gw.addr = static_cast<uint32_t>(gateway);
info.netmask.addr = static_cast<uint32_t>(subnet);
info.ip.addr = local_ip.v4();
info.gw.addr = gateway.v4();
info.netmask.addr = subnet.v4();
wifi_station_dhcpc_stop();
if(wifi_set_ip_info(STATION_IF, &info)) {
@ -260,18 +268,15 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a
} else {
return false;
}
ip_addr_t d;
if(dns1 != (uint32_t)0x00000000) {
if(dns1.isSet()) {
// Set DNS1-Server
d.addr = static_cast<uint32_t>(dns1);
dns_setserver(0, &d);
dns_setserver(0, dns1);
}
if(dns2 != (uint32_t)0x00000000) {
if(dns2.isSet()) {
// Set DNS2-Server
d.addr = static_cast<uint32_t>(dns2);
dns_setserver(1, &d);
dns_setserver(1, dns2);
}
return true;
@ -392,7 +397,6 @@ IPAddress ESP8266WiFiSTAClass::localIP() {
return IPAddress(ip.ip.addr);
}
/**
* Get the station interface MAC address.
* @param mac pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
@ -446,8 +450,7 @@ IPAddress ESP8266WiFiSTAClass::dnsIP(uint8_t dns_no) {
ip_addr_t dns_ip = dns_getserver(dns_no);
return IPAddress(dns_ip.addr);
#else
const ip_addr_t* dns_ip = dns_getserver(dns_no);
return IPAddress(dns_ip->addr);
return IPAddress(dns_getserver(dns_no));
#endif
}