mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
esp_netif/lwip: Implement basic support for vanilla-lwip (2.1.3-REL)
* Reference lwip-2.1.3-REL vanilla lwip version * Use inherent NETIF callbacks instead of dhcp/ipv6/autoip
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -21,8 +21,7 @@
|
||||
//
|
||||
// LWIP compatibility inet and address macros/functions
|
||||
//
|
||||
# define LWIP_COMPAT_SOCKET_INET 1
|
||||
# define LWIP_COMPAT_SOCKET_ADDR 1
|
||||
# include "esp_cpp_sockets.h"
|
||||
|
||||
//
|
||||
// Specific ASIO feature flags
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -40,6 +40,11 @@ static esp_err_t eth_input_to_netif(esp_eth_handle_t eth_handle, uint8_t *buffer
|
||||
return esp_netif_receive((esp_netif_t *)priv, buffer, length, NULL);
|
||||
}
|
||||
|
||||
static void eth_l2_free(void *h, void* buffer)
|
||||
{
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static esp_err_t esp_eth_post_attach(esp_netif_t *esp_netif, void *args)
|
||||
{
|
||||
uint8_t eth_mac[6];
|
||||
@@ -52,7 +57,7 @@ static esp_err_t esp_eth_post_attach(esp_netif_t *esp_netif, void *args)
|
||||
esp_netif_driver_ifconfig_t driver_ifconfig = {
|
||||
.handle = netif_glue->eth_driver,
|
||||
.transmit = esp_eth_transmit,
|
||||
.driver_free_rx_buffer = NULL
|
||||
.driver_free_rx_buffer = eth_l2_free
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_set_driver_config(esp_netif, &driver_ifconfig));
|
||||
|
@@ -13,6 +13,7 @@ set(srcs
|
||||
"vfs_l2tap/esp_vfs_l2tap.c"
|
||||
"lwip/esp_netif_lwip.c"
|
||||
"lwip/esp_netif_lwip_defaults.c"
|
||||
"lwip/esp_netif_lwip_orig.c"
|
||||
"lwip/esp_netif_sta_list.c")
|
||||
|
||||
set(include_dirs "include")
|
||||
|
@@ -28,6 +28,14 @@ menu "ESP NETIF Adapter"
|
||||
help
|
||||
Dummy implementation of esp-netif functionality which connects driver transmit
|
||||
to receive function. This option is for testing purpose only
|
||||
|
||||
config ESP_NETIF_TCPIP_LWIP_ORIG
|
||||
bool "LwIP-orig"
|
||||
depends on !LWIP_PPP_SUPPORT && !LWIP_IPV4_NAPT
|
||||
help
|
||||
This choice sets the original, vanilla-lwIP as the TCP/IP stack.
|
||||
Warning: Current implementation does not support PPP and NAPT features
|
||||
|
||||
endchoice
|
||||
|
||||
config ESP_NETIF_L2_TAP
|
||||
|
@@ -10,12 +10,13 @@
|
||||
|
||||
#include "esp_check.h"
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
#include "esp_netif_lwip_orig.h"
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_private.h"
|
||||
#include "esp_random.h"
|
||||
|
||||
#if CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP) || defined(CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG)
|
||||
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/dhcp.h"
|
||||
@@ -99,6 +100,7 @@ static bool tcpip_initialized = false;
|
||||
static esp_netif_t *s_last_default_esp_netif = NULL;
|
||||
static bool s_is_last_default_esp_netif_overridden = false;
|
||||
|
||||
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
static sys_sem_t api_sync_sem = NULL;
|
||||
static sys_sem_t api_lock_sem = NULL;
|
||||
@@ -490,7 +492,7 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config)
|
||||
// Create parent esp-netif object
|
||||
esp_netif_t *esp_netif = calloc(1, sizeof(struct esp_netif_obj));
|
||||
if (!esp_netif) {
|
||||
ESP_LOGE(TAG, "Failed to allocate %d bytes (fee heap size %d)", sizeof(struct esp_netif_obj),
|
||||
ESP_LOGE(TAG, "Failed to allocate %d bytes (free heap size %d)", sizeof(struct esp_netif_obj),
|
||||
esp_get_free_heap_size());
|
||||
return NULL;
|
||||
}
|
||||
@@ -498,7 +500,7 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config)
|
||||
// Create ip info
|
||||
esp_netif_ip_info_t *ip_info = calloc(1, sizeof(esp_netif_ip_info_t));
|
||||
if (!ip_info) {
|
||||
ESP_LOGE(TAG, "Failed to allocate %d bytes (fee heap size %d)", sizeof(esp_netif_ip_info_t),
|
||||
ESP_LOGE(TAG, "Failed to allocate %d bytes (free heap size %d)", sizeof(esp_netif_ip_info_t),
|
||||
esp_get_free_heap_size());
|
||||
free(esp_netif);
|
||||
return NULL;
|
||||
@@ -508,7 +510,7 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config)
|
||||
// creating another ip info (to store old ip)
|
||||
ip_info = calloc(1, sizeof(esp_netif_ip_info_t));
|
||||
if (!ip_info) {
|
||||
ESP_LOGE(TAG, "Failed to allocate %d bytes (fee heap size %d)", sizeof(esp_netif_ip_info_t),
|
||||
ESP_LOGE(TAG, "Failed to allocate %d bytes (free heap size %d)", sizeof(esp_netif_ip_info_t),
|
||||
esp_get_free_heap_size());
|
||||
free(esp_netif->ip_info);
|
||||
free(esp_netif);
|
||||
@@ -519,7 +521,7 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config)
|
||||
// Create underlying lwip netif
|
||||
struct netif * lwip_netif = calloc(1, sizeof(struct netif));
|
||||
if (!lwip_netif) {
|
||||
ESP_LOGE(TAG, "Failed to allocate %d bytes (fee heap size %d)", sizeof(struct netif),
|
||||
ESP_LOGE(TAG, "Failed to allocate %d bytes (free heap size %d)", sizeof(struct netif),
|
||||
esp_get_free_heap_size());
|
||||
free(esp_netif->ip_info_old);
|
||||
free(esp_netif->ip_info);
|
||||
@@ -552,6 +554,8 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
set_lwip_netif_callback();
|
||||
|
||||
return esp_netif;
|
||||
}
|
||||
|
||||
@@ -562,6 +566,15 @@ static void esp_netif_lwip_remove(esp_netif_t *esp_netif)
|
||||
netif_set_down(esp_netif->lwip_netif);
|
||||
}
|
||||
netif_remove(esp_netif->lwip_netif);
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
if (esp_netif->flags&ESP_NETIF_FLAG_GARP) {
|
||||
netif_unset_garp_flag(esp_netif->lwip_netif);
|
||||
}
|
||||
#endif
|
||||
if (esp_netif->flags & ESP_NETIF_DHCP_CLIENT) {
|
||||
dhcp_cleanup(esp_netif->lwip_netif);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,6 +624,9 @@ void esp_netif_destroy(esp_netif_t *esp_netif)
|
||||
{
|
||||
if (esp_netif) {
|
||||
esp_netif_remove_from_list(esp_netif);
|
||||
if (esp_netif_get_nr_of_ifs() == 0) {
|
||||
remove_lwip_netif_callback();
|
||||
}
|
||||
free(esp_netif->ip_info);
|
||||
free(esp_netif->ip_info_old);
|
||||
free(esp_netif->if_key);
|
||||
@@ -923,12 +939,12 @@ esp_err_t esp_netif_receive(esp_netif_t *esp_netif, void *buffer, size_t len, vo
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_netif_start_ip_lost_timer(esp_netif_t *esp_netif);
|
||||
|
||||
//
|
||||
// DHCP:
|
||||
//
|
||||
static esp_err_t esp_netif_start_ip_lost_timer(esp_netif_t *esp_netif);
|
||||
|
||||
static void esp_netif_dhcpc_cb(struct netif *netif)
|
||||
void esp_netif_internal_dhcpc_cb(struct netif *netif)
|
||||
{
|
||||
if (!netif) {
|
||||
ESP_LOGD(TAG, "null netif=%p", netif);
|
||||
@@ -941,7 +957,6 @@ static void esp_netif_dhcpc_cb(struct netif *netif)
|
||||
esp_netif_ip_info_t *ip_info = esp_netif->ip_info;
|
||||
esp_netif_ip_info_t *ip_info_old = esp_netif->ip_info_old;
|
||||
|
||||
|
||||
if ( !ip4_addr_cmp(ip_2_ip4(&netif->ip_addr), IP4_ADDR_ANY4) ) {
|
||||
|
||||
//check whether IP is changed
|
||||
@@ -1122,7 +1137,7 @@ static esp_err_t esp_netif_dhcpc_start_api(esp_netif_api_msg_t *msg)
|
||||
return ESP_ERR_ESP_NETIF_DHCPC_START_FAILED;
|
||||
}
|
||||
|
||||
dhcp_set_cb(p_netif, esp_netif_dhcpc_cb);
|
||||
dhcp_set_cb(p_netif, esp_netif_internal_dhcpc_cb);
|
||||
|
||||
esp_netif->dhcpc_status = ESP_NETIF_DHCP_STARTED;
|
||||
return ESP_OK;
|
||||
@@ -1624,11 +1639,11 @@ esp_ip6_addr_type_t esp_netif_ip6_get_addr_type(esp_ip6_addr_t* ip6_addr)
|
||||
|
||||
}
|
||||
|
||||
static void esp_netif_nd6_cb(struct netif *p_netif, uint8_t ip_index)
|
||||
void esp_netif_internal_nd6_cb(struct netif *p_netif, uint8_t ip_index)
|
||||
{
|
||||
ESP_LOGD(TAG, "%s lwip-netif:%p", __func__, p_netif);
|
||||
if (!p_netif) {
|
||||
ESP_LOGD(TAG, "esp_netif_nd6_cb called with null p_netif");
|
||||
ESP_LOGD(TAG, "esp_netif_internal_nd6_cb called with null p_netif");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1661,7 +1676,7 @@ static esp_err_t esp_netif_create_ip6_linklocal_api(esp_netif_api_msg_t *msg)
|
||||
struct netif *p_netif = esp_netif->lwip_netif;
|
||||
if (p_netif != NULL && netif_is_up(p_netif)) {
|
||||
netif_create_ip6_linklocal_address(p_netif, 1);
|
||||
nd6_set_cb(p_netif, esp_netif_nd6_cb);
|
||||
nd6_set_cb(p_netif, esp_netif_internal_nd6_cb);
|
||||
return ESP_OK;
|
||||
} else {
|
||||
return ESP_FAIL;
|
||||
@@ -2058,4 +2073,4 @@ esp_err_t esp_netif_remove_ip6_address(esp_netif_t *esp_netif, const esp_ip6_add
|
||||
|
||||
#endif // CONFIG_LWIP_IPV6
|
||||
|
||||
#endif /* CONFIG_ESP_NETIF_TCPIP_LWIP */
|
||||
#endif /* CONFIG_ESP_NETIF_TCPIP_LWIP || CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG */
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
#include "esp_netif_lwip_ppp.h"
|
||||
|
||||
#ifdef CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP) || defined(CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG)
|
||||
|
||||
#include "netif/wlanif.h"
|
||||
#include "netif/ethernetif.h"
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "lwip/netif.h"
|
||||
#include "dhcpserver/dhcpserver.h"
|
||||
|
||||
#ifdef CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP) || defined(CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG)
|
||||
|
||||
struct esp_netif_netstack_lwip_vanilla_config {
|
||||
err_t (*init_fn)(struct netif*);
|
||||
|
82
components/esp_netif/lwip/esp_netif_lwip_orig.c
Normal file
82
components/esp_netif/lwip/esp_netif_lwip_orig.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <lwip/dns.h>
|
||||
#include <lwip/timeouts.h>
|
||||
#include <lwip/etharp.h>
|
||||
|
||||
#include "esp_check.h"
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
#include "esp_netif_lwip_orig.h"
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_private.h"
|
||||
|
||||
#define DHCP_CB_CHANGE (LWIP_NSC_IPV4_SETTINGS_CHANGED | LWIP_NSC_IPV4_ADDRESS_CHANGED | LWIP_NSC_IPV4_GATEWAY_CHANGED | LWIP_NSC_IPV4_NETMASK_CHANGED)
|
||||
|
||||
static void netif_callback_fn(struct netif* netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args)
|
||||
{
|
||||
if (reason & DHCP_CB_CHANGE) {
|
||||
esp_netif_internal_dhcpc_cb(netif);
|
||||
}
|
||||
#if LWIP_IPV6
|
||||
if (reason & LWIP_NSC_IPV6_ADDR_STATE_CHANGED) {
|
||||
s8_t addr_idx = args->ipv6_addr_state_changed.addr_index;
|
||||
if (netif_ip6_addr_state(netif, addr_idx) & IP6_ADDR_VALID) {
|
||||
/* address is valid -> call the callback function */
|
||||
esp_netif_internal_nd6_cb(netif, addr_idx);
|
||||
}
|
||||
}
|
||||
#endif /* #if LWIP_IPV6 */
|
||||
}
|
||||
|
||||
static netif_ext_callback_t netif_callback = { .callback_fn = NULL, .next = NULL };
|
||||
|
||||
void set_lwip_netif_callback(void)
|
||||
{
|
||||
if (netif_callback.callback_fn == NULL ) {
|
||||
netif_add_ext_callback(&netif_callback, netif_callback_fn);
|
||||
}
|
||||
}
|
||||
|
||||
void remove_lwip_netif_callback(void)
|
||||
{
|
||||
netif_remove_ext_callback(&netif_callback);
|
||||
memset(&netif_callback, 0, sizeof(netif_callback));
|
||||
}
|
||||
|
||||
void dns_clear_servers(bool keep_fallback)
|
||||
{
|
||||
u8_t numdns = 0;
|
||||
|
||||
for (numdns = 0; numdns < DNS_MAX_SERVERS; numdns ++) {
|
||||
if (keep_fallback && numdns == DNS_FALLBACK_SERVER_INDEX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dns_setserver(numdns, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LWIP_GARP_TMR_INTERVAL
|
||||
void netif_send_garp(void *arg)
|
||||
{
|
||||
struct netif *netif = arg;
|
||||
etharp_gratuitous(netif);
|
||||
sys_timeout(CONFIG_LWIP_GARP_TMR_INTERVAL*1000, netif_send_garp, netif);
|
||||
}
|
||||
|
||||
void netif_set_garp_flag(struct netif *netif)
|
||||
{
|
||||
sys_timeout(CONFIG_LWIP_GARP_TMR_INTERVAL*1000, netif_send_garp, netif);
|
||||
}
|
||||
|
||||
void netif_unset_garp_flag(struct netif *netif)
|
||||
{
|
||||
sys_untimeout(netif_send_garp, netif);
|
||||
}
|
||||
#endif // CONFIG_LWIP_GARP_TMR_INTERVAL
|
47
components/esp_netif/lwip/esp_netif_lwip_orig.h
Normal file
47
components/esp_netif/lwip/esp_netif_lwip_orig.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
|
||||
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG) || defined(CONFIG_ESP_NETIF_TCPIP_LWIP)
|
||||
|
||||
/**
|
||||
* @brief Sets one extended lwip netif callbacks for all esp-netif
|
||||
*/
|
||||
void set_lwip_netif_callback(void);
|
||||
|
||||
void remove_lwip_netif_callback(void);
|
||||
|
||||
void esp_netif_internal_dhcpc_cb(struct netif *netif);
|
||||
|
||||
void esp_netif_internal_nd6_cb(struct netif *netif, uint8_t index);
|
||||
|
||||
static inline void dhcp_set_cb(struct netif *netif, void (*cb)(struct netif*)) { }
|
||||
|
||||
static inline void nd6_set_cb(struct netif *netif, void (*cb)(struct netif *netif, u8_t ip_index)) { }
|
||||
|
||||
void dns_clear_servers(bool keep_fallback);
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
|
||||
void netif_set_garp_flag(struct netif *netif);
|
||||
|
||||
void netif_unset_garp_flag(struct netif *netif);
|
||||
|
||||
#endif // ESP_GRATUITOUS_ARP
|
||||
|
||||
#else // !CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG and !CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
|
||||
static inline void set_lwip_netif_callback(void) { }
|
||||
|
||||
static inline void remove_lwip_netif_callback(void) { }
|
||||
|
||||
static inline void netif_unset_garp_flag(struct netif *netif) {}
|
||||
|
||||
#endif // CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG or CONFIG_ESP_NETIF_TCPIP_LWIP
|
@@ -1,22 +1,12 @@
|
||||
// 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-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_NETIF_LWIP_PPP_H_
|
||||
#define _ESP_NETIF_LWIP_PPP_H_
|
||||
|
||||
#if CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
|
||||
/**
|
||||
* @brief Creates new PPP related structure
|
||||
*
|
||||
@@ -77,7 +67,5 @@ esp_err_t esp_netif_stop_ppp(netif_related_data_t *netif_related);
|
||||
*/
|
||||
void esp_netif_ppp_set_default_netif(netif_related_data_t *netif_related);
|
||||
|
||||
#endif /* CONFIG_ESP_NETIF_TCPIP_LWIP */
|
||||
|
||||
|
||||
#endif // _ESP_NETIF_LWIP_PPP_H_
|
||||
|
@@ -85,6 +85,7 @@ set(srcs
|
||||
"port/esp32/hooks/lwip_default_hooks.c"
|
||||
"port/esp32/debug/lwip_debug.c"
|
||||
"port/esp32/freertos/sys_arch.c"
|
||||
"port/esp32/sockets_ext.c"
|
||||
"port/esp32/netif/wlanif.c")
|
||||
|
||||
if(CONFIG_LWIP_PPP_SUPPORT)
|
||||
@@ -159,15 +160,10 @@ idf_component_register(SRCS "${srcs}"
|
||||
# lots of LWIP source files evaluate macros that check address of stack variables
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-address)
|
||||
|
||||
set_source_files_properties(
|
||||
lwip/src/netif/ppp/ppp.c
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-uninitialized
|
||||
)
|
||||
set_source_files_properties(
|
||||
lwip/src/netif/ppp/pppos.c
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-implicit-fallthrough
|
||||
-Wno-type-limits
|
||||
)
|
||||
# "comparison is always false due to limited range of data type" warning
|
||||
# when setting CONFIG_LWIP_TCP_WND_DEFAULT to 65535
|
||||
|
@@ -46,7 +46,6 @@ entries:
|
||||
etharp:etharp_output_to_arp_index (noflash_text)
|
||||
etharp:etharp_output (noflash_text)
|
||||
ip4_addr:ip4_addr_isbroadcast_u32 (noflash_text)
|
||||
ip4:ip4_route_src_hook (noflash_text)
|
||||
ip4:ip4_route_src (noflash_text)
|
||||
ip4:ip4_route (noflash_text)
|
||||
ip4:ip4_input (noflash_text)
|
||||
|
Submodule components/lwip/lwip updated: 76303df238...6ca936f6b5
98
components/lwip/port/esp32/include/esp_cpp_sockets.h
Normal file
98
components/lwip/port/esp32/include/esp_cpp_sockets.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "sys/poll.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "netdb.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG) || defined(CONFIG_ESP_NETIF_TCPIP_LWIP)
|
||||
|
||||
// lwIP's socket API is mostly implemented as macros,
|
||||
// but ASIO uses the same symbols in different namespaces, where macros wouldn't work.
|
||||
// Here we have to undefined the symbols for ASIO build and declare as standard functions
|
||||
#undef getaddrinfo
|
||||
#undef gethostbyname_r
|
||||
#undef gethostbyname
|
||||
#undef freeaddrinfo
|
||||
#undef accept
|
||||
#undef bind
|
||||
#undef shutdown
|
||||
#undef getpeername
|
||||
#undef getsockname
|
||||
#undef setsockopt
|
||||
#undef setsockopt
|
||||
#undef getsockopt
|
||||
#undef closesocket
|
||||
#undef connect
|
||||
#undef listen
|
||||
#undef recvmsg
|
||||
#undef recv
|
||||
#undef recvfrom
|
||||
#undef sendmsg
|
||||
#undef send
|
||||
#undef sendto
|
||||
#undef socket
|
||||
#undef inet_ntop
|
||||
#undef inet_pton
|
||||
#undef poll
|
||||
#undef select
|
||||
|
||||
static inline int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
|
||||
{ return lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop); }
|
||||
static inline struct hostent *gethostbyname(const char *name)
|
||||
{ return lwip_gethostbyname(name); }
|
||||
static inline void freeaddrinfo(struct addrinfo *ai)
|
||||
{ lwip_freeaddrinfo(ai); }
|
||||
static inline int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
|
||||
{ return lwip_getaddrinfo(nodename, servname, hints, res); }
|
||||
static inline int accept(int s,struct sockaddr *addr,socklen_t *addrlen)
|
||||
{ return lwip_accept(s,addr,addrlen); }
|
||||
static inline int bind(int s,const struct sockaddr *name, socklen_t namelen)
|
||||
{ return lwip_bind(s,name,namelen); }
|
||||
static inline int shutdown(int s,int how)
|
||||
{ return lwip_shutdown(s,how); }
|
||||
static inline int getpeername(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getpeername(s,name,namelen); }
|
||||
static inline int getsockname(int s,struct sockaddr *name,socklen_t *namelen)
|
||||
{ return lwip_getsockname(s,name,namelen); }
|
||||
static inline int setsockopt(int s,int level,int optname,const void *opval,socklen_t optlen)
|
||||
{ return lwip_setsockopt(s,level,optname,opval,optlen); }
|
||||
static inline int getsockopt(int s,int level,int optname,void *opval,socklen_t *optlen)
|
||||
{ return lwip_getsockopt(s,level,optname,opval,optlen); }
|
||||
static inline int closesocket(int s)
|
||||
{ return lwip_close(s); }
|
||||
static inline int connect(int s,const struct sockaddr *name,socklen_t namelen)
|
||||
{ return lwip_connect(s,name,namelen); }
|
||||
static inline int listen(int s,int backlog)
|
||||
{ return lwip_listen(s,backlog); }
|
||||
static inline ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
|
||||
{ return lwip_recvmsg(sockfd, msg, flags); }
|
||||
static inline ssize_t recv(int s,void *mem,size_t len,int flags)
|
||||
{ return lwip_recv(s,mem,len,flags); }
|
||||
static inline ssize_t recvfrom(int s,void *mem,size_t len,int flags,struct sockaddr *from,socklen_t *fromlen)
|
||||
{ return lwip_recvfrom(s,mem,len,flags,from,fromlen); }
|
||||
static inline ssize_t send(int s,const void *dataptr,size_t size,int flags)
|
||||
{ return lwip_send(s,dataptr,size,flags); }
|
||||
static inline ssize_t sendmsg(int s,const struct msghdr *message,int flags)
|
||||
{ return lwip_sendmsg(s,message,flags); }
|
||||
static inline ssize_t sendto(int s,const void *dataptr,size_t size,int flags,const struct sockaddr *to,socklen_t tolen)
|
||||
{ return lwip_sendto(s,dataptr,size,flags,to,tolen); }
|
||||
static inline int socket(int domain,int type,int protocol)
|
||||
{ return lwip_socket(domain,type,protocol); }
|
||||
static inline const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
|
||||
{ return lwip_inet_ntop(af, src, dst, size); }
|
||||
static inline int inet_pton(int af, const char *src, void *dst)
|
||||
{ return lwip_inet_pton(af, src, dst); }
|
||||
#endif // CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG || CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -16,15 +16,17 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/select.h>
|
||||
#include "netif/dhcp_state.h"
|
||||
#include "sntp/sntp_get_set_time.h"
|
||||
#include <sys/poll.h>
|
||||
#ifdef __linux__
|
||||
#include "esp32_mock.h"
|
||||
#else
|
||||
#include "esp_task.h"
|
||||
#include "esp_random.h"
|
||||
#endif // __linux__
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "netif/dhcp_state.h"
|
||||
#include "sntp/sntp_get_set_time.h"
|
||||
#include "sockets_ext.h"
|
||||
|
||||
/*
|
||||
-----------------------------------------------
|
||||
@@ -589,6 +591,18 @@
|
||||
#define LWIP_NETIF_STATUS_CALLBACK 0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP_ORIG) || defined(CONFIG_ESP_NETIF_TCPIP_LWIP)
|
||||
/**
|
||||
* LWIP_NETIF_EXT_STATUS_CALLBACK==1: Support an extended callback function
|
||||
* for several netif related event that supports multiple subscribers.
|
||||
*
|
||||
* This ext-callback is used by ESP-NETIF with lwip-orig (upstream version)
|
||||
* to provide netif related events on IP4/IP6 address/status changes
|
||||
*/
|
||||
#define LWIP_NETIF_EXT_STATUS_CALLBACK 1
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP *tries* to put all data
|
||||
* to be sent into one single pbuf. This is for compatibility with DMA-enabled
|
||||
@@ -1111,6 +1125,11 @@
|
||||
#endif
|
||||
#define LWIP_HOOK_FILENAME "lwip_default_hooks.h"
|
||||
#define LWIP_HOOK_IP4_ROUTE_SRC ip4_route_src_hook
|
||||
#define LWIP_HOOK_SOCKETS_GETSOCKOPT(s, sock, level, optname, optval, optlen, err) \
|
||||
lwip_getsockopt_impl_ext(sock, level, optname, optval, optlen, err)?(done_socket(sock), true): false
|
||||
|
||||
#define LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, err) \
|
||||
lwip_setsockopt_impl_ext(sock, level, optname, optval, optlen, err)?(done_socket(sock), true): false
|
||||
|
||||
/*
|
||||
---------------------------------------
|
||||
|
@@ -30,6 +30,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "esp_cpp_sockets.h"
|
||||
#include "lwip/sockets.h"
|
||||
/*
|
||||
SOMAXCONN is expected to be found in this header too,
|
||||
|
@@ -1,16 +1,8 @@
|
||||
// Copyright 2017 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: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
@@ -475,7 +475,7 @@ components/esp_local_ctrl/src/esp_local_ctrl_transport_ble.c
|
||||
components/esp_netif/include/esp_netif_ppp.h
|
||||
components/esp_netif/include/esp_netif_slip.h
|
||||
components/esp_netif/loopback/esp_netif_loopback.c
|
||||
components/esp_netif/lwip/esp_netif_lwip_ppp.h
|
||||
components/esp_netif/lwip/esp_netif_lwip_ppp.c
|
||||
components/esp_netif/lwip/esp_netif_lwip_slip.c
|
||||
components/esp_netif/lwip/esp_netif_lwip_slip.h
|
||||
components/esp_netif/private_include/esp_netif_private.h
|
||||
@@ -984,7 +984,6 @@ components/lwip/port/esp32/netif/dhcp_state.c
|
||||
components/lwip/port/esp32/netif/ethernetif.c
|
||||
components/lwip/port/esp32/netif/wlanif.c
|
||||
components/lwip/port/esp32/no_vfs_syscalls.c
|
||||
components/lwip/port/esp32/vfs_lwip.c
|
||||
components/lwip/test_afl_host/dhcp_di.h
|
||||
components/lwip/test_afl_host/dhcpserver_di.h
|
||||
components/lwip/test_afl_host/dns_di.h
|
||||
|
Reference in New Issue
Block a user