Преглед изворни кода

Fix the bug that if one device is in station+softap mode, other device can not
get IP address after connecting to the softap.

Now the default netif is station in station+softap mode. The UDP pcb of
DHCP server is binded to IP 0.0.0.0. When other device connects to softap, the
DHCP offer will be sent by softap.But because the destination IP of DHCP offer
is broadcast IP and the source IP of it is 0.0.0.0, it will be sent from default
netif, that is station interface. Other device can not receive the DHCP offer
sent from station interface. As a result, other device can not get IP address.
The resolution is that bind UDP pcb to the IP address of softap. So, the source
IP of DHCP offer is that of softap. DHCP offer can be sent from softap interface
by source IP route method.

XiaXiaotian пре 8 година
родитељ
комит
20064978ba
2 измењених фајлова са 3 додато и 1 уклоњено
  1. 1 1
      components/lwip/apps/dhcpserver.c
  2. 2 0
      components/tcpip_adapter/tcpip_adapter_lwip.c

+ 1 - 1
components/lwip/apps/dhcpserver.c

@@ -1074,7 +1074,7 @@ void dhcps_start(struct netif *netif, ip4_addr_t ip)
 
     client_address_plus.addr = dhcps_poll.start_ip.addr;
 
-    udp_bind(pcb_dhcps, IP_ADDR_ANY, DHCPS_SERVER_PORT);
+    udp_bind(pcb_dhcps, &netif->ip_addr, DHCPS_SERVER_PORT);
     udp_recv(pcb_dhcps, handle_dhcp, NULL);
 #if DHCPS_DEBUG
     DHCPS_LOG("dhcps:dhcps_start->udp_recv function Set a receive callback handle_dhcp for UDP_PCB pcb_dhcps\n");

+ 2 - 0
components/tcpip_adapter/tcpip_adapter_lwip.c

@@ -309,6 +309,8 @@ esp_err_t tcpip_adapter_down(tcpip_adapter_if_t tcpip_if)
         tcpip_adapter_start_ip_lost_timer(tcpip_if);
     }
 
+    tcpip_adapter_update_default_netif();
+
     return ESP_OK;
 }