Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

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
no need to init
  • Loading branch information
mcspr committed Apr 20, 2022
commit cc5fc18da5fbbffbabcd380892b372666740d6b8
6 changes: 2 additions & 4 deletions cores/esp8266/LwipDhcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__;
#define LWIP_IS_OK(what, err) ((err) == ERR_OK)
#endif

const uint32 DhcpServer::magic_cookie = 0x63538263; // https://tools.ietf.org/html/rfc1497

////////////////////////////////////////////////////////////////////////////////////

DhcpServer::DhcpServer(netif* netif) : _netif(netif) { }
Expand Down Expand Up @@ -489,7 +487,7 @@ void DhcpServer::create_msg(struct dhcps_msg* m)
memset((char*)m->sname, 0, sizeof(m->sname));
memset((char*)m->file, 0, sizeof(m->file));
memset((char*)m->options, 0, sizeof(m->options));
memcpy((char*)m->options, &magic_cookie, sizeof(magic_cookie));
memcpy((char*)m->options, &MagicCookie, sizeof(MagicCookie));
}
///////////////////////////////////////////////////////////////////////////////////
/*
Expand Down Expand Up @@ -794,7 +792,7 @@ uint8_t DhcpServer::parse_options(uint8_t* optptr, sint16_t len)
///////////////////////////////////////////////////////////////////////////////////
sint16_t DhcpServer::parse_msg(struct dhcps_msg* m, u16_t len)
{
if (memcmp((char*)m->options, &magic_cookie, sizeof(magic_cookie)) == 0)
if (memcmp((char*)m->options, &MagicCookie, sizeof(MagicCookie)) == 0)
{
struct ipv4_addr ip;
memcpy(&ip.addr, m->ciaddr, sizeof(ip.addr));
Expand Down
10 changes: 2 additions & 8 deletions cores/esp8266/LwipDhcpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@
class DhcpServer
{
public:
static constexpr int DefaultLeaseTime = 120 /* seconds */;
static constexpr ip_info DefaultIpConfig = {
.ip { 0x0104a8c0 }, // 192.168.4.1
.netmask { 0x00ffffff }, // 255.255.255.0
.gw { 0 } // 0.0.0.0
};

static const uint32 magic_cookie;
static constexpr int DefaultLeaseTime = 120; // seconds
static constexpr uint32 MagicCookie = 0x63538263; // https://tools.ietf.org/html/rfc1497

DhcpServer(netif*);
~DhcpServer();
Expand Down
7 changes: 4 additions & 3 deletions libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* psk, int channel,
struct ip_info ip;
if(wifi_get_ip_info(SOFTAP_IF, &ip)) {
if(ip.ip.addr == 0x00000000) {
// Invalid config
DEBUG_WIFI("[AP] IP config Invalid resetting...\n");
//192.168.4.1 , 192.168.4.1 , 255.255.255.0
ret = softAPConfig(0x0104A8C0, 0x0104A8C0, 0x00FFFFFF);
ret = softAPConfig(
0x0104A8C0 /* 192.168.4.1 */,
0x0104A8C0 /* 192.168.4.1 */,
0x00FFFFFF /* 255.255.255.0 */);
if(!ret) {
DEBUG_WIFI("[AP] softAPConfig failed!\n");
ret = false;
Expand Down