未验证 提交 ce2cd111 编写于 作者: R Rodrigo Garcia 提交者: GitHub

Fixes INADDR_NONE (#6659)

Description of Change

Fixes IPAddress INADDR_NONE declaration when using Arduino WiFi or ETH.
This symbol was defined as 0xffffffff by lwip /inet.h, making it impossible to use INADDR_NONE correctly.

This PR only works when <wifi-provisioning/wifi_config.h> has a modification to include <lwip/ip4_addr.h> instead of <lwip/inet.h>. This will be done directly to the sdk folder in the github structure and it has been fixed in IDF by a separated Merge Request. This will be reflected in the future, for good.

Tests scenarios

This PR was tested with all Arduino WiFi examples, including AsyncUDP. Also with ETH examples.
It was also tested for #6610 test cases.
Testing done for ESP32, ESP32-S2, ESP32-C3 and ESP32-S3.

Related links

fixes #6610
fixes #6247
fixes #4732
上级 5f6d093d
...@@ -120,3 +120,6 @@ bool IPAddress::fromString(const char *address) ...@@ -120,3 +120,6 @@ bool IPAddress::fromString(const char *address)
_address.bytes[3] = acc; _address.bytes[3] = acc;
return true; return true;
} }
// declared one time - as external in IPAddress.h
IPAddress INADDR_NONE(0, 0, 0, 0);
...@@ -91,6 +91,6 @@ public: ...@@ -91,6 +91,6 @@ public:
friend class DNSClient; friend class DNSClient;
}; };
const IPAddress INADDR_NONE(0, 0, 0, 0); // changed to extern because const declaration creates copies in BSS of INADDR_NONE for each CPP unit that includes it
extern IPAddress INADDR_NONE;
#endif #endif
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "Stream.h" #include "Stream.h"
#include <functional> #include <functional>
extern "C" { extern "C" {
#include "lwip/ip_addr.h"
#include "esp_netif.h" #include "esp_netif.h"
#include "freertos/queue.h" #include "freertos/queue.h"
#include "freertos/semphr.h" #include "freertos/semphr.h"
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "Arduino.h" #include "Arduino.h"
#include "Server.h" #include "Server.h"
#include "WiFiClient.h" #include "WiFiClient.h"
#include "arpa/inet.h"
#include "IPAddress.h" #include "IPAddress.h"
class WiFiServer : public Server { class WiFiServer : public Server {
...@@ -38,7 +37,8 @@ class WiFiServer : public Server { ...@@ -38,7 +37,8 @@ class WiFiServer : public Server {
public: public:
void listenOnLocalhost(){} void listenOnLocalhost(){}
WiFiServer(uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(INADDR_ANY),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) { // _addr(INADDR_ANY) is the same as _addr() ==> 0.0.0.0
WiFiServer(uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) {
log_v("WiFiServer::WiFiServer(port=%d, ...)", port); log_v("WiFiServer::WiFiServer(port=%d, ...)", port);
} }
WiFiServer(const IPAddress& addr, uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(addr),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) { WiFiServer(const IPAddress& addr, uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(addr),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#ifndef _WIFI_PROV_CONFIG_H_ #ifndef _WIFI_PROV_CONFIG_H_
#define _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_
#include <lwip/inet.h> #include <lwip/ip4_addr.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#ifndef _WIFI_PROV_CONFIG_H_ #ifndef _WIFI_PROV_CONFIG_H_
#define _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_
#include <lwip/inet.h> #include <lwip/ip4_addr.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#ifndef _WIFI_PROV_CONFIG_H_ #ifndef _WIFI_PROV_CONFIG_H_
#define _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_
#include <lwip/inet.h> #include <lwip/ip4_addr.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#ifndef _WIFI_PROV_CONFIG_H_ #ifndef _WIFI_PROV_CONFIG_H_
#define _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_
#include <lwip/inet.h> #include <lwip/ip4_addr.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册