未验证 提交 807ed51d 编写于 作者: D david gauchard 提交者: GitHub

AP & dhcp-server: fix uninitialized variables (#7905)

上级 e3fe7a57
...@@ -1140,16 +1140,9 @@ bool DhcpServer::set_dhcps_lease(struct dhcps_lease *please) ...@@ -1140,16 +1140,9 @@ bool DhcpServer::set_dhcps_lease(struct dhcps_lease *please)
// logic below is subject for improvement // logic below is subject for improvement
// - is wrong // - is wrong
// - limited to /24 address plans // - limited to /24 address plans
#if 1 softap_ip = htonl(ip_2_ip4(&_netif->ip_addr)->addr);
softap_ip = ip_2_ip4(&_netif->ip_addr)->addr;
#else
struct ip_info info;
bzero(&info, sizeof(struct ip_info));
wifi_get_ip_info(SOFTAP_IF, &info);
softap_ip = htonl(info.ip.addr);
start_ip = htonl(please->start_ip.addr); start_ip = htonl(please->start_ip.addr);
end_ip = htonl(please->end_ip.addr); end_ip = htonl(please->end_ip.addr);
#endif
/*config ip information can't contain local ip*/ /*config ip information can't contain local ip*/
if ((start_ip <= softap_ip) && (softap_ip <= end_ip)) if ((start_ip <= softap_ip) && (softap_ip <= end_ip))
{ {
......
...@@ -224,6 +224,7 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA ...@@ -224,6 +224,7 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
} }
struct dhcps_lease dhcp_lease; struct dhcps_lease dhcp_lease;
dhcp_lease.enable = true;
IPAddress ip = local_ip; IPAddress ip = local_ip;
ip[3] += 99; ip[3] += 99;
dhcp_lease.start_ip.addr = ip.v4(); dhcp_lease.start_ip.addr = ip.v4();
...@@ -264,8 +265,7 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA ...@@ -264,8 +265,7 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
DEBUG_WIFI("[APConfig] IP config Invalid?!\n"); DEBUG_WIFI("[APConfig] IP config Invalid?!\n");
ret = false; ret = false;
} else if(local_ip.v4() != info.ip.addr) { } else if(local_ip.v4() != info.ip.addr) {
ip = info.ip.addr; DEBUG_WIFI("[APConfig] IP config not set correct?! new IP: %s\n", IPAddress(info.ip.addr).toString().c_str());
DEBUG_WIFI("[APConfig] IP config not set correct?! new IP: %s\n", ip.toString().c_str());
ret = false; ret = false;
} }
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册