Skip to content

Commit 3512ad3

Browse files
committed
Fixes INADDR_NONE in all networking Arduino Libs
1 parent be49659 commit 3512ad3

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Diff for: cores/esp32/IPAddress.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,6 @@ bool IPAddress::fromString(const char *address)
120120
_address.bytes[3] = acc;
121121
return true;
122122
}
123+
124+
// declared one time - as external in IPAddress.h
125+
IPAddress INADDR_NONE(0, 0, 0, 0);

Diff for: cores/esp32/IPAddress.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ class IPAddress: public Printable
9191
friend class DNSClient;
9292
};
9393

94-
// avoids some conflict in some AWS, Microsoft Azure and MATTER projects
95-
#ifndef INADDR_NONE
96-
const IPAddress INADDR_NONE(0, 0, 0, 0);
97-
#endif
98-
99-
#endif
94+
// changed to extern because const declaration creates copies in BSS of INADDR_NONE for each CPP unit that includes it
95+
extern IPAddress INADDR_NONE;
96+
#endif

Diff for: libraries/AsyncUDP/src/AsyncUDP.h

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "Stream.h"
88
#include <functional>
99
extern "C" {
10-
#include "lwip/ip_addr.h"
1110
#include "esp_netif.h"
1211
#include "freertos/queue.h"
1312
#include "freertos/semphr.h"

Diff for: libraries/WiFi/src/WiFiServer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "Arduino.h"
2323
#include "Server.h"
2424
#include "WiFiClient.h"
25-
#include "arpa/inet.h"
2625
#include "IPAddress.h"
2726

2827
class WiFiServer : public Server {
@@ -38,7 +37,8 @@ class WiFiServer : public Server {
3837
public:
3938
void listenOnLocalhost(){}
4039

41-
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) {
40+
// _addr(INADDR_ANY) is the same as _addr() ==> 0.0.0.0
41+
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) {
4242
log_v("WiFiServer::WiFiServer(port=%d, ...)", port);
4343
}
4444
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) {

0 commit comments

Comments
 (0)