esp_netif_lwip_ppp: fix posting ip-event data

Closes https://github.com/espressif/esp-idf/issues/4634
pull/2405/merge
David Cermak 2020-01-31 15:18:19 +01:00
rodzic 3f5d19016a
commit 7d45bfda21
2 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -45,20 +45,23 @@ static void on_ppp_status_changed(ppp_pcb *pcb, int err_code, void *ctx)
{ {
struct netif *pppif = ppp_netif(pcb); struct netif *pppif = ppp_netif(pcb);
const ip_addr_t *dest_ip = NULL; const ip_addr_t *dest_ip = NULL;
ip_event_ap_staipassigned_t evt = { 0 };
esp_err_t err;
esp_netif_t *netif = ctx; esp_netif_t *netif = ctx;
ip_event_got_ip_t evt = {
.esp_netif = netif,
.if_index = -1,
};
esp_err_t err;
struct lwip_ppp_ctx *obj = netif->lwip_ppp_ctx; struct lwip_ppp_ctx *obj = netif->lwip_ppp_ctx;
esp_netif_ip_info_t ipinfo = { {0}, {0}, {0} };
esp_ip4_addr_t ns1; esp_ip4_addr_t ns1;
esp_ip4_addr_t ns2; esp_ip4_addr_t ns2;
switch (err_code) { switch (err_code) {
case PPPERR_NONE: /* Connected */ case PPPERR_NONE: /* Connected */
ESP_LOGI(TAG, "Connected"); ESP_LOGI(TAG, "Connected");
ipinfo.ip.addr = pppif->ip_addr.u_addr.ip4.addr; evt.ip_info.ip.addr = pppif->ip_addr.u_addr.ip4.addr;
ipinfo.gw.addr = pppif->gw.u_addr.ip4.addr; evt.ip_info.gw.addr = pppif->gw.u_addr.ip4.addr;
ipinfo.netmask.addr = pppif->netmask.u_addr.ip4.addr; evt.ip_info.netmask.addr = pppif->netmask.u_addr.ip4.addr;
dest_ip = dns_getserver(0); dest_ip = dns_getserver(0);
if(dest_ip != NULL){ if(dest_ip != NULL){
ns1.addr = (*dest_ip).u_addr.ip4.addr; ns1.addr = (*dest_ip).u_addr.ip4.addr;
@ -70,7 +73,6 @@ static void on_ppp_status_changed(ppp_pcb *pcb, int err_code, void *ctx)
ESP_LOGI(TAG, "Name Server1: " IPSTR, IP2STR(&ns1)); ESP_LOGI(TAG, "Name Server1: " IPSTR, IP2STR(&ns1));
ESP_LOGI(TAG, "Name Server2: " IPSTR, IP2STR(&ns2)); ESP_LOGI(TAG, "Name Server2: " IPSTR, IP2STR(&ns2));
evt.ip.addr = ipinfo.ip.addr;
err = esp_event_post(IP_EVENT, netif->get_ip_event, &evt, sizeof(evt), 0); err = esp_event_post(IP_EVENT, netif->get_ip_event, &evt, sizeof(evt), 0);
if (ESP_OK != err) { if (ESP_OK != err) {

Wyświetl plik

@ -181,7 +181,7 @@ static void on_ppp_changed(void *arg, esp_event_base_t event_base,
static void on_ip_event(void *arg, esp_event_base_t event_base, static void on_ip_event(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data) int32_t event_id, void *event_data)
{ {
ESP_LOGI(TAG, "IP event! %d", event_id); ESP_LOGD(TAG, "IP event! %d", event_id);
if (event_id == IP_EVENT_PPP_GOT_IP) { if (event_id == IP_EVENT_PPP_GOT_IP) {
esp_netif_dns_info_t dns_info; esp_netif_dns_info_t dns_info;
@ -192,7 +192,7 @@ static void on_ip_event(void *arg, esp_event_base_t event_base,
ESP_LOGI(TAG, "~~~~~~~~~~~~~~"); ESP_LOGI(TAG, "~~~~~~~~~~~~~~");
ESP_LOGI(TAG, "IP : " IPSTR, IP2STR(&event->ip_info.ip)); ESP_LOGI(TAG, "IP : " IPSTR, IP2STR(&event->ip_info.ip));
ESP_LOGI(TAG, "Netmask : " IPSTR, IP2STR(&event->ip_info.netmask)); ESP_LOGI(TAG, "Netmask : " IPSTR, IP2STR(&event->ip_info.netmask));
ESP_LOGI(TAG, "Gateway : " IPSTR, IP2STR(&event->ip_info.ip)); ESP_LOGI(TAG, "Gateway : " IPSTR, IP2STR(&event->ip_info.gw));
esp_netif_get_dns_info(netif, 0, &dns_info); esp_netif_get_dns_info(netif, 0, &dns_info);
ESP_LOGI(TAG, "Name Server1: " IPSTR, IP2STR(&dns_info.ip.u_addr.ip4)); ESP_LOGI(TAG, "Name Server1: " IPSTR, IP2STR(&dns_info.ip.u_addr.ip4));
esp_netif_get_dns_info(netif, 1, &dns_info); esp_netif_get_dns_info(netif, 1, &dns_info);