mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feat/esp_netif_ppp_opts' into 'master'
feat(esp_netif): PPP netif extend config/use RAM pbufs Closes IDFGH-10017 See merge request espressif/esp-idf!26057
This commit is contained in:
commit
3b2a22f65a
@ -24,7 +24,7 @@ if(${target} STREQUAL "linux")
|
||||
endif()
|
||||
|
||||
if(CONFIG_PPP_SUPPORT)
|
||||
list(APPEND srcs_lwip lwip/esp_netif_lwip_ppp.c)
|
||||
list(APPEND srcs_lwip lwip/esp_netif_lwip_ppp.c lwip/netif/ppp.c)
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
//
|
||||
|
||||
#ifndef _ESP_NETIF_PPP_H_
|
||||
@ -29,6 +21,13 @@ ESP_EVENT_DECLARE_BASE(NETIF_PPP_STATUS);
|
||||
typedef struct esp_netif_ppp_config {
|
||||
bool ppp_phase_event_enabled; /**< Enables events coming from PPP PHASE change */
|
||||
bool ppp_error_event_enabled; /**< Enables events from main PPP state machine producing errors */
|
||||
#ifdef CONFIG_LWIP_ENABLE_LCP_ECHO
|
||||
bool ppp_lcp_echo_disabled; /**< Allows to temporarily disable LCP keepalive (runtime, if enabled compile time)
|
||||
* When LCP echo is enabled in menuconfig, this option can be used to override the setting,
|
||||
* if we have to relax LCP keepalive criteria during runtime operation, for example before OTA update.
|
||||
* The current session must be closed, settings will be applied upon connecting.
|
||||
* */
|
||||
#endif // CONFIG_LWIP_ENABLE_LCP_ECHO
|
||||
} esp_netif_ppp_config_t;
|
||||
|
||||
/** @brief event id offset for PHASE related events
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -17,6 +17,7 @@
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
#include <string.h>
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "netif/pppif.h"
|
||||
|
||||
ESP_EVENT_DEFINE_BASE(NETIF_PPP_STATUS);
|
||||
|
||||
@ -31,6 +32,9 @@ typedef struct lwip_peer2peer_ctx {
|
||||
// PPP specific fields follow
|
||||
bool ppp_phase_event_enabled;
|
||||
bool ppp_error_event_enabled;
|
||||
#ifdef CONFIG_LWIP_ENABLE_LCP_ECHO
|
||||
bool ppp_lcp_echo_disabled;
|
||||
#endif
|
||||
ppp_pcb *ppp;
|
||||
} lwip_peer2peer_ctx_t;
|
||||
|
||||
@ -257,6 +261,16 @@ esp_err_t esp_netif_start_ppp(esp_netif_t *esp_netif)
|
||||
lwip_peer2peer_ctx_t *ppp_ctx = (lwip_peer2peer_ctx_t *)netif_related;
|
||||
assert(ppp_ctx->base.netif_type == PPP_LWIP_NETIF);
|
||||
|
||||
#ifdef CONFIG_LWIP_ENABLE_LCP_ECHO
|
||||
if (ppp_ctx->ppp_lcp_echo_disabled) {
|
||||
ppp_ctx->ppp->settings.lcp_echo_interval = 0;
|
||||
ppp_ctx->ppp->settings.lcp_echo_fails = 0;
|
||||
} else {
|
||||
ppp_ctx->ppp->settings.lcp_echo_interval = LCP_ECHOINTERVAL;
|
||||
ppp_ctx->ppp->settings.lcp_echo_fails = LCP_MAXECHOFAILS;
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_LOGD(TAG, "%s: Starting PPP connection: %p", __func__, ppp_ctx->ppp);
|
||||
esp_err_t err = pppapi_connect(ppp_ctx->ppp, 0);
|
||||
if (err != ESP_OK) {
|
||||
@ -272,7 +286,7 @@ esp_err_t esp_netif_start_ppp(esp_netif_t *esp_netif)
|
||||
esp_netif_recv_ret_t esp_netif_lwip_ppp_input(void *ppp_ctx, void *buffer, size_t len, void *eb)
|
||||
{
|
||||
struct lwip_peer2peer_ctx * obj = ppp_ctx;
|
||||
err_t ret = pppos_input_tcpip(obj->ppp, buffer, len);
|
||||
err_t ret = pppos_input_tcpip_as_ram_pbuf(obj->ppp, buffer, len);
|
||||
if (ret != ERR_OK) {
|
||||
ESP_LOGE(TAG, "pppos_input_tcpip failed with %d", ret);
|
||||
return ESP_NETIF_OPTIONAL_RETURN_CODE(ESP_FAIL);
|
||||
@ -311,6 +325,9 @@ esp_err_t esp_netif_ppp_set_params(esp_netif_t *netif, const esp_netif_ppp_confi
|
||||
struct lwip_peer2peer_ctx *obj = (struct lwip_peer2peer_ctx *)netif->related_data;
|
||||
obj->ppp_phase_event_enabled = config->ppp_phase_event_enabled;
|
||||
obj->ppp_error_event_enabled = config->ppp_error_event_enabled;
|
||||
#ifdef CONFIG_LWIP_ENABLE_LCP_ECHO
|
||||
obj->ppp_lcp_echo_disabled = config->ppp_lcp_echo_disabled;
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@ -323,5 +340,8 @@ esp_err_t esp_netif_ppp_get_params(esp_netif_t *netif, esp_netif_ppp_config_t *c
|
||||
struct lwip_peer2peer_ctx *obj = (struct lwip_peer2peer_ctx *)netif->related_data;
|
||||
config->ppp_phase_event_enabled = obj->ppp_phase_event_enabled;
|
||||
config->ppp_error_event_enabled = obj->ppp_error_event_enabled;
|
||||
#ifdef CONFIG_LWIP_ENABLE_LCP_ECHO
|
||||
config->ppp_lcp_echo_disabled = obj->ppp_lcp_echo_disabled;
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
28
components/esp_netif/lwip/netif/ppp.c
Normal file
28
components/esp_netif/lwip/netif/ppp.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2001-2004 Swedish Institute of Computer Science
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* SPDX-FileContributor: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
#include "pppif.h"
|
||||
#include "lwip/tcpip.h"
|
||||
|
||||
/*
|
||||
* Similar to pppos_input_tcpip() from lwip's ppp netif, but instead
|
||||
* of PBUF_POOL, we use PBUF_RAM type of the pbuf we pass to the stack
|
||||
*/
|
||||
err_t pppos_input_tcpip_as_ram_pbuf(ppp_pcb *ppp, u8_t *s, int l)
|
||||
{
|
||||
struct pbuf *p = pbuf_alloc(PBUF_RAW, l, PBUF_RAM);
|
||||
if (!p) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
pbuf_take(p, s, l);
|
||||
|
||||
err_t err = tcpip_inpkt(p, ppp_netif(ppp), pppos_input_sys);
|
||||
if (err != ERR_OK) {
|
||||
pbuf_free(p);
|
||||
}
|
||||
return err;
|
||||
}
|
22
components/esp_netif/lwip/netif/pppif.h
Normal file
22
components/esp_netif/lwip/netif/pppif.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2001-2004 Swedish Institute of Computer Science
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* SPDX-FileContributor: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
#include "lwip/pbuf.h"
|
||||
#include "netif/ppp/pppos.h"
|
||||
|
||||
/** Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread.
|
||||
*
|
||||
* This function uses allocated packet buffers of exact size for input to TCP/IP stack
|
||||
* to consume less memory in download mode, compared to the pppos_input_tcpip() from lwIP.
|
||||
* (original implementation uses `PBUF_POOL`, which on ESP port uses standard malloc
|
||||
* to allocate a fixed size pbuf)
|
||||
*
|
||||
* @param ppp PPP descriptor index, returned by pppos_create()
|
||||
* @param s received data
|
||||
* @param l length of received data
|
||||
*/
|
||||
err_t pppos_input_tcpip_as_ram_pbuf(ppp_pcb *ppp, u8_t *s, int l);
|
@ -422,7 +422,6 @@ components/esp_hid/src/esp_hid_common.c
|
||||
components/esp_local_ctrl/src/esp_local_ctrl_handler.c
|
||||
components/esp_local_ctrl/src/esp_local_ctrl_priv.h
|
||||
components/esp_local_ctrl/src/esp_local_ctrl_transport_ble.c
|
||||
components/esp_netif/include/esp_netif_ppp.h
|
||||
components/esp_phy/test/test_phy_rtc.c
|
||||
components/esp_pm/include/esp_private/pm_trace.h
|
||||
components/esp_rom/esp32/ld/esp32.rom.api.ld
|
||||
|
Loading…
x
Reference in New Issue
Block a user