mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_netif_lwip_ppp: fix posting ip-event data
Closes https://github.com/espressif/esp-idf/issues/4634
This commit is contained in:
parent
3f5d19016a
commit
7d45bfda21
@ -45,20 +45,23 @@ static void on_ppp_status_changed(ppp_pcb *pcb, int err_code, void *ctx)
|
||||
{
|
||||
struct netif *pppif = ppp_netif(pcb);
|
||||
const ip_addr_t *dest_ip = NULL;
|
||||
ip_event_ap_staipassigned_t evt = { 0 };
|
||||
esp_err_t err;
|
||||
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;
|
||||
esp_netif_ip_info_t ipinfo = { {0}, {0}, {0} };
|
||||
esp_ip4_addr_t ns1;
|
||||
esp_ip4_addr_t ns2;
|
||||
switch (err_code) {
|
||||
case PPPERR_NONE: /* Connected */
|
||||
ESP_LOGI(TAG, "Connected");
|
||||
|
||||
ipinfo.ip.addr = pppif->ip_addr.u_addr.ip4.addr;
|
||||
ipinfo.gw.addr = pppif->gw.u_addr.ip4.addr;
|
||||
ipinfo.netmask.addr = pppif->netmask.u_addr.ip4.addr;
|
||||
evt.ip_info.ip.addr = pppif->ip_addr.u_addr.ip4.addr;
|
||||
evt.ip_info.gw.addr = pppif->gw.u_addr.ip4.addr;
|
||||
evt.ip_info.netmask.addr = pppif->netmask.u_addr.ip4.addr;
|
||||
|
||||
dest_ip = dns_getserver(0);
|
||||
if(dest_ip != NULL){
|
||||
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 Server2: " IPSTR, IP2STR(&ns2));
|
||||
|
||||
evt.ip.addr = ipinfo.ip.addr;
|
||||
|
||||
err = esp_event_post(IP_EVENT, netif->get_ip_event, &evt, sizeof(evt), 0);
|
||||
if (ESP_OK != err) {
|
||||
|
@ -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,
|
||||
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) {
|
||||
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, "IP : " IPSTR, IP2STR(&event->ip_info.ip));
|
||||
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_LOGI(TAG, "Name Server1: " IPSTR, IP2STR(&dns_info.ip.u_addr.ip4));
|
||||
esp_netif_get_dns_info(netif, 1, &dns_info);
|
||||
|
Loading…
x
Reference in New Issue
Block a user