modify the behavior for dhcpserver and tcpip_adapter:

1. dhcp_server: suppress send_offer debug output
2. tcpip_adapter: zero-initialize system_event_t structures
3. tcpip_adapter: pass client IP address along with SYSTEM_EVENT_AP_STAIPASSIGNED

Closes https://github.com/espressif/esp-idf/issues/2924
Closes https://github.com/espressif/esp-idf/issues/2949
This commit is contained in:
zhangyanjiao 2019-03-11 11:03:48 +08:00
parent f42ae05d1e
commit 27cc0d1f91
3 changed files with 17 additions and 0 deletions

View File

@ -120,6 +120,10 @@ typedef struct {
uint8_t mac[6]; /**< MAC address of the station which send probe request */
} system_event_ap_probe_req_rx_t;
typedef struct {
ip4_addr_t ip;
} system_event_ap_staipassigned_t;
typedef union {
system_event_sta_connected_t connected; /**< ESP32 station connected to AP */
system_event_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */
@ -131,6 +135,7 @@ typedef union {
system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */
system_event_ap_stadisconnected_t sta_disconnected; /**< a station disconnected to ESP32 soft-AP */
system_event_ap_probe_req_rx_t ap_probereqrecved; /**< ESP32 soft-AP receive probe request packet */
system_event_ap_staipassigned_t ap_staipassigned; /**< ESP32 soft-AP assign an IP to the station*/
system_event_got_ip6_t got_ip6; /**< ESP32 station or ap or ethernet ipv6 addr state change to preferred */
} system_event_info_t;

View File

@ -475,7 +475,9 @@ static void send_offer(struct dhcps_msg *m, u16_t len)
u8_t *data;
u16_t cnt = 0;
u16_t i;
#if DHCPS_DEBUG
err_t SendOffer_err_t;
#endif
create_msg(m);
end = add_msg_type(&m->options[4], DHCPOFFER);
@ -523,8 +525,12 @@ static void send_offer(struct dhcps_msg *m, u16_t len)
ip_addr_t ip_temp = IPADDR4_INIT(0x0);
ip4_addr_set(ip_2_ip4(&ip_temp), &broadcast_dhcps);
#if DHCPS_DEBUG
SendOffer_err_t = udp_sendto(pcb_dhcps, p, &ip_temp, DHCPS_CLIENT_PORT);
DHCPS_LOG("dhcps: send_offer>>udp_sendto result %x\n", SendOffer_err_t);
#else
udp_sendto(pcb_dhcps, p, &ip_temp, DHCPS_CLIENT_PORT);
#endif
if (p->ref != 0) {
#if DHCPS_DEBUG

View File

@ -91,7 +91,9 @@ static void tcpip_adapter_dhcps_cb(u8_t client_ip[4])
ESP_LOGI(TAG,"softAP assign IP to station,IP is: %d.%d.%d.%d",
client_ip[0],client_ip[1],client_ip[2],client_ip[3]);
system_event_t evt;
memset(&evt, 0, sizeof(system_event_t));
evt.event_id = SYSTEM_EVENT_AP_STAIPASSIGNED;
memcpy((char *)&evt.event_info.ap_staipassigned.ip.addr, (char *)client_ip, sizeof(evt.event_info.ap_staipassigned.ip.addr));
esp_event_send(&evt);
}
@ -429,6 +431,7 @@ esp_err_t tcpip_adapter_set_ip_info(tcpip_adapter_if_t tcpip_if, const tcpip_ada
if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) {
if (!(ip4_addr_isany_val(ip_info->ip) || ip4_addr_isany_val(ip_info->netmask) || ip4_addr_isany_val(ip_info->gw))) {
system_event_t evt;
memset(&evt, 0, sizeof(system_event_t));
if (tcpip_if == TCPIP_ADAPTER_IF_STA) {
evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
} else if (tcpip_if == TCPIP_ADAPTER_IF_ETH) {
@ -461,6 +464,7 @@ static void tcpip_adapter_nd6_cb(struct netif *p_netif, uint8_t ip_idex)
tcpip_adapter_ip6_info_t *ip6_info;
system_event_t evt;
memset(&evt, 0, sizeof(system_event_t));
//notify event
evt.event_id = SYSTEM_EVENT_GOT_IP6;
@ -896,6 +900,7 @@ static void tcpip_adapter_dhcpc_cb(struct netif *netif)
!ip4_addr_cmp(ip_2_ip4(&netif->netmask), (&ip_info->netmask)) ||
!ip4_addr_cmp(ip_2_ip4(&netif->gw), (&ip_info->gw)) ) {
system_event_t evt;
memset(&evt, 0, sizeof(system_event_t));
ip4_addr_set(&ip_info->ip, ip_2_ip4(&netif->ip_addr));
ip4_addr_set(&ip_info->netmask, ip_2_ip4(&netif->netmask));
@ -971,6 +976,7 @@ static void tcpip_adapter_ip_lost_timer(void *arg)
if ( (!netif) || (netif && ip4_addr_cmp(ip_2_ip4(&netif->ip_addr), IP4_ADDR_ANY4))){
system_event_t evt;
memset(&evt, 0, sizeof(system_event_t));
ESP_LOGD(TAG, "if%d ip lost tmr: raise ip lost event", tcpip_if);
memset(&esp_ip_old[tcpip_if], 0, sizeof(tcpip_adapter_ip_info_t));