From 1db40ed29542ff85c8d1d1b58707122436b39cf4 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 21 Jun 2023 15:09:26 +1000 Subject: [PATCH] esp32/ppp_set_auth: Add pppapi_set_auth from ESP-IDF. This function was made private/static in IDF commit c67f4c2b4c2bb4b7740f988fc0f8a3e911e56afe, so it add back here. Signed-off-by: Damien George --- LICENSE | 2 ++ ports/esp32/main/CMakeLists.txt | 1 + ports/esp32/ppp_set_auth.c | 35 +++++++++++++++++++++++++++++++++ ports/esp32/ppp_set_auth.h | 22 +++++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 ports/esp32/ppp_set_auth.c create mode 100644 ports/esp32/ppp_set_auth.h diff --git a/LICENSE b/LICENSE index 31eb9813f2..07c88b0a03 100644 --- a/LICENSE +++ b/LICENSE @@ -67,6 +67,8 @@ used during the build process and is not part of the compiled source code. /hal (BSD-3-clause) /simplelink (BSD-3-clause) /FreeRTOS (GPL-2.0 with FreeRTOS exception) + /esp32 + /ppp_set_auth.* (Apache-2.0) /stm32 /usbd*.c (MCD-ST Liberty SW License Agreement V2) /stm32_it.* (MIT + BSD-3-clause) diff --git a/ports/esp32/main/CMakeLists.txt b/ports/esp32/main/CMakeLists.txt index 425d70fdf0..4311af801c 100644 --- a/ports/esp32/main/CMakeLists.txt +++ b/ports/esp32/main/CMakeLists.txt @@ -53,6 +53,7 @@ set(MICROPY_SOURCE_DRIVERS set(MICROPY_SOURCE_PORT main.c + ppp_set_auth.c uart.c usb.c usb_serial_jtag.c diff --git a/ports/esp32/ppp_set_auth.c b/ports/esp32/ppp_set_auth.c new file mode 100644 index 0000000000..88ab668d48 --- /dev/null +++ b/ports/esp32/ppp_set_auth.c @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// The pppapi_set_auth function was made static in the ESP-IDF, so it's re-added here. +// See ESP-IDF commit c67f4c2b4c2bb4b7740f988fc0f8a3e911e56afe + +#include "ppp_set_auth.h" + +#ifdef CONFIG_ESP_NETIF_TCPIP_LWIP + +#include "netif/ppp/pppapi.h" + +typedef struct { + struct tcpip_api_call_data call; + ppp_pcb *ppp; + u8_t authtype; + const char *user; + const char *passwd; +} set_auth_msg_t; + +static err_t pppapi_do_ppp_set_auth(struct tcpip_api_call_data *m) { + set_auth_msg_t *msg = (set_auth_msg_t *)m; + ppp_set_auth(msg->ppp, msg->authtype, msg->user, msg->passwd); + return ERR_OK; +} + +void pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) { + set_auth_msg_t msg = { .ppp = pcb, .authtype = authtype, .user = user, .passwd = passwd}; + tcpip_api_call(pppapi_do_ppp_set_auth, &msg.call); +} + +#endif diff --git a/ports/esp32/ppp_set_auth.h b/ports/esp32/ppp_set_auth.h new file mode 100644 index 0000000000..67676ef4d6 --- /dev/null +++ b/ports/esp32/ppp_set_auth.h @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// The pppapi_set_auth function was made static in the ESP-IDF, so it's re-added here. +// See ESP-IDF commit c67f4c2b4c2bb4b7740f988fc0f8a3e911e56afe + +#pragma once + +#include "esp_netif.h" + +#ifdef CONFIG_ESP_NETIF_TCPIP_LWIP + +#include "lwip/netif.h" + +typedef struct ppp_pcb_s ppp_pcb; + +void pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd); + +#endif