Skip to content
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

IP math #3637

Closed
wants to merge 4 commits into from
Closed

IP math #3637

Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
struct dhcps_lease dhcp_lease;

uint32_t net_addr = info.ip.addr & info.netmask.addr;
uint32_t bcast_addr = net_addr | !info.netmask.addr;
uint32_t bcast_addr = net_addr | ~info.netmask.addr;

// Assign user-supplied range, checking its validity
IPAddress ip = (static_cast<uint32_t>(dhcp_start) & !info.netmask.addr) | net_addr;
IPAddress ip = (static_cast<uint32_t>(dhcp_start) & ~info.netmask.addr) | net_addr;

dhcp_lease.start_ip.addr = ip;
if(ip != net_addr && ip != bcast_addr && ip != info.ip.addr && ip != info.gw.addr) {
Expand All @@ -220,7 +220,7 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
dhcp_lease.start_ip.addr=0;
}

ip = (static_cast<uint32_t>(dhcp_end) & !info.netmask.addr) | net_addr;
ip = (static_cast<uint32_t>(dhcp_end) & ~info.netmask.addr) | net_addr;
dhcp_lease.end_ip.addr = static_cast<uint32_t>(ip);
if(ip != net_addr && ip != bcast_addr && ip != info.ip.addr && ip != info.gw.addr) {
DEBUG_WIFI("[APConfig] DHCP IP end: %s\n", ip.toString().c_str());
Expand Down