diff --git a/components/esp_netif/include/esp_netif_ppp.h b/components/esp_netif/include/esp_netif_ppp.h index b6df9fdfd..413910c43 100644 --- a/components/esp_netif/include/esp_netif_ppp.h +++ b/components/esp_netif/include/esp_netif_ppp.h @@ -74,6 +74,7 @@ typedef enum { * */ typedef enum { + NETIF_PPP_AUTHTYPE_NONE = 0x00, NETIF_PPP_AUTHTYPE_PAP = 0x01, NETIF_PPP_AUTHTYPE_CHAP = 0x02, NETIF_PPP_AUTHTYPE_MSCHAP = 0x04, diff --git a/components/esp_netif/lwip/esp_netif_lwip_ppp.c b/components/esp_netif/lwip/esp_netif_lwip_ppp.c index 9a5cc9b01..f36538c54 100644 --- a/components/esp_netif/lwip/esp_netif_lwip_ppp.c +++ b/components/esp_netif/lwip/esp_netif_lwip_ppp.c @@ -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) { @@ -207,10 +209,8 @@ esp_err_t esp_netif_ppp_set_auth(esp_netif_t *netif, esp_netif_auth_type_t autht if (netif == NULL || !netif->is_ppp_netif) { return ESP_ERR_ESP_NETIF_INVALID_PARAMS; } +#if PPP_AUTH_SUPPORT struct lwip_ppp_ctx *obj = netif->lwip_ppp_ctx; -#if PAP_SUPPORT - pppapi_set_auth(obj->ppp, authtype, user, passwd); -#elif CHAP_SUPPORT pppapi_set_auth(obj->ppp, authtype, user, passwd); #else #error "Unsupported AUTH Negotiation" diff --git a/examples/protocols/pppos_client/main/pppos_client_main.c b/examples/protocols/pppos_client/main/pppos_client_main.c index a6eea822d..7637ba3ce 100644 --- a/examples/protocols/pppos_client/main/pppos_client_main.c +++ b/examples/protocols/pppos_client/main/pppos_client_main.c @@ -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);