Skip to content

Commit cc84a64

Browse files
mtongnzigrr
authored andcommitted
Set DHCP subnet correctly for softAP (#2648)
Removes hard coded subnet of 255.255.255.0 and fetches the correct subnet from wifi_get_ip_info()
1 parent ae13809 commit cc84a64

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

tools/sdk/lwip/src/app/dhcpserver.c

+9-18
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,16 @@ static uint8_t* ICACHE_FLASH_ATTR add_offer_options(uint8_t *optptr)
137137

138138
ipadd.addr = *( (uint32_t *) &server_address);
139139

140-
#ifdef USE_CLASS_B_NET
141-
*optptr++ = DHCP_OPTION_SUBNET_MASK;
142-
*optptr++ = 4; //length
143-
*optptr++ = 255;
144-
*optptr++ = 240;
145-
*optptr++ = 0;
146-
*optptr++ = 0;
147-
#else
140+
struct ip_info if_ip;
141+
os_bzero(&if_ip, sizeof(struct ip_info));
142+
wifi_get_ip_info(SOFTAP_IF, &if_ip);
143+
148144
*optptr++ = DHCP_OPTION_SUBNET_MASK;
149-
*optptr++ = 4;
150-
*optptr++ = 255;
151-
*optptr++ = 255;
152-
*optptr++ = 255;
153-
*optptr++ = 0;
154-
#endif
145+
*optptr++ = 4;
146+
*optptr++ = ip4_addr1( &if_ip.netmask);
147+
*optptr++ = ip4_addr2( &if_ip.netmask);
148+
*optptr++ = ip4_addr3( &if_ip.netmask);
149+
*optptr++ = ip4_addr4( &if_ip.netmask);
155150

156151
*optptr++ = DHCP_OPTION_LEASE_TIME;
157152
*optptr++ = 4;
@@ -168,10 +163,6 @@ static uint8_t* ICACHE_FLASH_ATTR add_offer_options(uint8_t *optptr)
168163
*optptr++ = ip4_addr4( &ipadd);
169164

170165
if (dhcps_router_enabled(offer)){
171-
struct ip_info if_ip;
172-
os_bzero(&if_ip, sizeof(struct ip_info));
173-
wifi_get_ip_info(SOFTAP_IF, &if_ip);
174-
175166
*optptr++ = DHCP_OPTION_ROUTER;
176167
*optptr++ = 4;
177168
*optptr++ = ip4_addr1( &if_ip.gw);

0 commit comments

Comments
 (0)