mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_netif/lwip: Fix deps cycles to "lwip -> esp_netif -> phy-drivers"
Fix dependency tree so that lwip doesn't depend on any specific network interface component. Network interface drivers shall depend on esp_netif. esp_netif shall depend on lwip (but not on any specific interface driver) -- it optionally depends on vfs and esp_eth (need ethernet header for L2/bridge mode)
This commit is contained in:
parent
84ae84e3fe
commit
5c383d7b73
@ -678,8 +678,8 @@ endif()
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
REQUIRES esp_timer
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy mbedtls driver
|
||||
REQUIRES esp_timer esp_wifi
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy mbedtls driver vfs
|
||||
LDFRAGMENTS "linker.lf")
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRC_DIRS . param_test touch_sensor_test dac_dma_test
|
||||
PRIV_INCLUDE_DIRS include param_test/include touch_sensor_test/include
|
||||
PRIV_REQUIRES cmock test_utils driver nvs_flash esp_serial_slave_link
|
||||
esp_timer esp_adc)
|
||||
esp_timer esp_adc esp_event esp_wifi)
|
||||
|
@ -16,7 +16,6 @@ if(CONFIG_ETH_ENABLED)
|
||||
# esp_netif related
|
||||
if(esp_netif IN_LIST components_to_build)
|
||||
list(APPEND srcs "src/esp_eth_netif_glue.c")
|
||||
list(APPEND priv_requires esp_netif esp_pm)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -54,6 +53,9 @@ idf_component_register(SRCS "${srcs}"
|
||||
REQUIRES esp_event # For using "ESP_EVENT_DECLARE_BASE" in header file
|
||||
PRIV_REQUIRES ${priv_requires})
|
||||
|
||||
if(CONFIG_ETH_USE_SPI_ETHERNET)
|
||||
idf_component_optional_requires(PUBLIC driver)
|
||||
if(CONFIG_ETH_ENABLED)
|
||||
if(CONFIG_ETH_USE_SPI_ETHERNET)
|
||||
idf_component_optional_requires(PUBLIC driver)
|
||||
endif()
|
||||
idf_component_optional_requires(PRIVATE esp_netif esp_pm)
|
||||
endif()
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "esp_netif.h"
|
||||
#include "esp_eth_driver.h"
|
||||
#include "esp_eth_netif_glue.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
@ -77,7 +78,10 @@ static void eth_action_start(void *handler_args, esp_event_base_t base, int32_t
|
||||
esp_eth_netif_glue_t *netif_glue = handler_args;
|
||||
ESP_LOGD(TAG, "eth_action_start: %p, %p, %d, %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data);
|
||||
if (netif_glue->eth_driver == eth_handle) {
|
||||
eth_speed_t speed;
|
||||
esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &speed);
|
||||
esp_netif_action_start(netif_glue->base.netif, base, event_id, event_data);
|
||||
esp_netif_set_link_speed(netif_glue->base.netif, speed == ETH_SPEED_100M ? 100000000 : 10000000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRC_DIRS .
|
||||
PRIV_INCLUDE_DIRS .
|
||||
PRIV_REQUIRES cmock test_utils esp_eth esp_http_client
|
||||
PRIV_REQUIRES cmock test_utils esp_eth esp_http_client esp_netif
|
||||
EMBED_TXTFILES dl_espressif_com_root_cert.pem)
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRCS "esp_eth_test.c"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity esp_eth)
|
||||
PRIV_REQUIRES unity esp_eth esp_netif)
|
||||
|
@ -11,12 +11,7 @@ if(${target} STREQUAL "linux")
|
||||
# Temporary fix until esp_system is available for linux, too
|
||||
list(APPEND priv_include_dirs "$ENV{IDF_PATH}/tools/mocks/esp_system/include")
|
||||
else()
|
||||
list(APPEND requires "esp_netif")
|
||||
if(${target} STREQUAL "esp32")
|
||||
list(APPEND priv_requires esp_eth esp_timer)
|
||||
else()
|
||||
list(APPEND priv_requires esp_timer)
|
||||
endif()
|
||||
list(APPEND priv_requires esp_timer)
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
|
@ -5,5 +5,5 @@ idf_component_register(SRCS "esp_http_client.c"
|
||||
INCLUDE_DIRS "include"
|
||||
PRIV_INCLUDE_DIRS "lib/include"
|
||||
# lwip is a public requirement because esp_http_client.h includes sys/socket.h
|
||||
REQUIRES http_parser lwip
|
||||
PRIV_REQUIRES tcp_transport)
|
||||
REQUIRES lwip
|
||||
PRIV_REQUIRES tcp_transport http_parser)
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
|
||||
#include "http_parser.h"
|
||||
#include "http_header.h"
|
||||
#include "esp_transport.h"
|
||||
#include "esp_transport_tcp.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define _ESP_HTTP_CLIENT_H
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "http_parser.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include <sys/socket.h>
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "esp_rom_md5.h"
|
||||
#include "esp_tls_crypto.h"
|
||||
|
@ -12,7 +12,9 @@ set(srcs
|
||||
"esp_netif_defaults.c"
|
||||
"lwip/esp_netif_lwip.c"
|
||||
"lwip/esp_netif_lwip_defaults.c"
|
||||
"lwip/esp_netif_sta_list.c")
|
||||
"lwip/netif/wlanif.c"
|
||||
"lwip/netif/ethernetif.c"
|
||||
"lwip/netif/esp_pbuf_ref.c" )
|
||||
|
||||
set(include_dirs "include")
|
||||
set(priv_include_dirs "lwip" "private_include")
|
||||
@ -45,9 +47,10 @@ endif()
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
REQUIRES lwip)
|
||||
|
||||
REQUIRES esp_event
|
||||
PRIV_REQUIRES lwip
|
||||
LDFRAGMENTS linker.lf)
|
||||
|
||||
if(CONFIG_ESP_NETIF_L2_TAP OR CONFIG_ESP_NETIF_BRIDGE_EN)
|
||||
idf_component_optional_requires(PRIVATE esp_eth)
|
||||
idf_component_optional_requires(PRIVATE esp_eth vfs)
|
||||
endif()
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_wifi_default.h"
|
||||
#include "lwip/esp_netif_net_stack.h"
|
||||
|
||||
//
|
||||
// Purpose of this module is to provide
|
||||
@ -14,13 +14,18 @@
|
||||
//
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Default configuration of common interfaces, such as STA, AP, ETH
|
||||
//
|
||||
const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config = ESP_NETIF_INHERENT_DEFAULT_WIFI_STA();
|
||||
|
||||
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
||||
const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip = {
|
||||
.ip = { .addr = ESP_IP4TOADDR( 192, 168, 4, 1) },
|
||||
.gw = { .addr = ESP_IP4TOADDR( 192, 168, 4, 1) },
|
||||
.netmask = { .addr = ESP_IP4TOADDR( 255, 255, 255, 0) },
|
||||
};
|
||||
|
||||
const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config = ESP_NETIF_INHERENT_DEFAULT_WIFI_AP();
|
||||
#endif
|
||||
|
||||
@ -29,11 +34,3 @@ const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config = ESP_NETIF_I
|
||||
const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config = ESP_NETIF_INHERENT_DEFAULT_PPP();
|
||||
|
||||
const esp_netif_inherent_config_t _g_esp_netif_inherent_slip_config = ESP_NETIF_INHERENT_DEFAULT_SLIP();
|
||||
|
||||
const esp_netif_inherent_config_t _g_esp_netif_inherent_openthread_config = ESP_NETIF_INHERENT_DEFAULT_OPENTHREAD();
|
||||
|
||||
const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip = {
|
||||
.ip = { .addr = ESP_IP4TOADDR( 192, 168, 4, 1) },
|
||||
.gw = { .addr = ESP_IP4TOADDR( 192, 168, 4, 1) },
|
||||
.netmask = { .addr = ESP_IP4TOADDR( 255, 255, 255, 0) },
|
||||
};
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "esp_netif_ip_addr.h"
|
||||
#include "esp_netif_types.h"
|
||||
#include "esp_netif_defaults.h"
|
||||
@ -616,6 +615,19 @@ esp_err_t esp_netif_dhcps_start(esp_netif_t *esp_netif);
|
||||
*/
|
||||
esp_err_t esp_netif_dhcps_stop(esp_netif_t *esp_netif);
|
||||
|
||||
/**
|
||||
* @brief Populate IP addresses of clients connected to DHCP server listed by their MAC addresses
|
||||
*
|
||||
* @param[in] esp_netif Handle to esp-netif instance
|
||||
* @param[in] num Number of clients with specified MAC addresses in the array of pairs
|
||||
* @param[in,out] mac_ip_pair Array of pairs of MAC and IP addresses (MAC are inputs, IP outputs)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_ESP_NETIF_INVALID_PARAMS on invalid params
|
||||
* - ESP_ERR_NOT_SUPPORTED if DHCP server not enabled
|
||||
*/
|
||||
esp_err_t esp_netif_dhcps_get_clients_by_mac(esp_netif_t *esp_netif, int num, esp_netif_pair_mac_ip_t *mac_ip_pair);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -71,18 +71,6 @@ extern "C" {
|
||||
.bridge_info = NULL \
|
||||
};
|
||||
|
||||
#define ESP_NETIF_INHERENT_DEFAULT_OPENTHREAD() \
|
||||
{ \
|
||||
.flags = 0, \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
|
||||
.get_ip_event = 0, \
|
||||
.lost_ip_event = 0, \
|
||||
.if_key = "OT_DEF", \
|
||||
.if_desc = "openthread", \
|
||||
.route_prio = 15, \
|
||||
.bridge_info = NULL \
|
||||
};
|
||||
|
||||
#define ESP_NETIF_INHERENT_DEFAULT_SLIP() \
|
||||
{ \
|
||||
@ -199,7 +187,6 @@ extern "C" {
|
||||
#endif
|
||||
#define ESP_NETIF_NETSTACK_DEFAULT_PPP _g_esp_netif_netstack_default_ppp
|
||||
#define ESP_NETIF_NETSTACK_DEFAULT_SLIP _g_esp_netif_netstack_default_slip
|
||||
#define ESP_NETIF_NETSTACK_DEFAULT_OPENTHREAD _g_esp_netif_netstack_default_openthread
|
||||
|
||||
//
|
||||
// Include default network stacks configs
|
||||
@ -233,27 +220,6 @@ extern const esp_netif_inherent_config_t _g_esp_netif_inherent_slip_config;
|
||||
extern const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_OPENTHREAD_ENABLED
|
||||
/**
|
||||
* @brief Default configuration reference of SLIP client
|
||||
*/
|
||||
#define ESP_NETIF_DEFAULT_OPENTHREAD() \
|
||||
{ \
|
||||
.base = ESP_NETIF_BASE_DEFAULT_OPENTHREAD, \
|
||||
.driver = NULL, \
|
||||
.stack = ESP_NETIF_NETSTACK_DEFAULT_OPENTHREAD, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default base config (esp-netif inherent) of openthread interface
|
||||
*/
|
||||
#define ESP_NETIF_BASE_DEFAULT_OPENTHREAD &_g_esp_netif_inherent_openthread_config
|
||||
|
||||
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_openthread;
|
||||
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_openthread_config;
|
||||
|
||||
#endif // CONFIG_OPENTHREAD_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -40,6 +40,14 @@ esp_netif_t* esp_netif_get_handle_from_netif_impl(void *dev);
|
||||
*/
|
||||
void* esp_netif_get_netif_impl(esp_netif_t *esp_netif);
|
||||
|
||||
/**
|
||||
* @brief Set link-speed for the specified network interface
|
||||
* @param[in] esp_netif Handle to esp-netif instance
|
||||
* @param[in] speed Link speed in bit/s
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_netif_set_link_speed(esp_netif_t *esp_netif, uint32_t speed);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -245,6 +245,14 @@ struct esp_netif_config {
|
||||
const esp_netif_netstack_config_t *stack; /*!< stack config */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief DHCP client's addr info (pair of MAC and IP address)
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t mac[6]; /**< Clients MAC address */
|
||||
esp_ip4_addr_t ip; /**< Clients IP address */
|
||||
} esp_netif_pair_mac_ip_t;
|
||||
|
||||
/**
|
||||
* @brief ESP-NETIF Receive function type
|
||||
*/
|
||||
|
79
components/esp_netif/include/lwip/esp_netif_net_stack.h
Normal file
79
components/esp_netif/include/lwip/esp_netif_net_stack.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "esp_netif_ppp.h"
|
||||
#include "esp_netif_slip.h"
|
||||
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP)
|
||||
|
||||
struct esp_netif_netstack_lwip_vanilla_config {
|
||||
err_t (*init_fn)(struct netif*);
|
||||
void (*input_fn)(void *netif, void *buffer, size_t len, void *eb);
|
||||
};
|
||||
|
||||
struct esp_netif_netstack_lwip_ppp_config {
|
||||
void (*input_fn)(void *netif, void *buffer, size_t len, void *eb);
|
||||
esp_netif_ppp_config_t ppp_events;
|
||||
};
|
||||
|
||||
struct esp_netif_netstack_lwip_slip_config {
|
||||
err_t (*init_fn)(struct netif*);
|
||||
void (*input_fn)(void *netif, void *buffer, size_t len, void *eb);
|
||||
esp_netif_slip_config_t slip_config;
|
||||
};
|
||||
|
||||
// LWIP netif specific network stack configuration
|
||||
struct esp_netif_netstack_config {
|
||||
union {
|
||||
struct esp_netif_netstack_lwip_vanilla_config lwip;
|
||||
struct esp_netif_netstack_lwip_ppp_config lwip_ppp;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief LWIP's network stack init function for Ethernet
|
||||
* @param netif LWIP's network interface handle
|
||||
* @return ERR_OK on success
|
||||
*/
|
||||
err_t ethernetif_init(struct netif *netif);
|
||||
|
||||
/**
|
||||
* @brief LWIP's network stack input packet function for Ethernet
|
||||
* @param h LWIP's network interface handle
|
||||
* @param buffer Input buffer pointer
|
||||
* @param len Input buffer size
|
||||
* @param l2_buff External buffer pointer (to be passed to custom input-buffer free)
|
||||
*/
|
||||
void ethernetif_input(void *h, void *buffer, size_t len, void *l2_buff);
|
||||
|
||||
/**
|
||||
* @brief LWIP's network stack init function for WiFi (AP)
|
||||
* @param netif LWIP's network interface handle
|
||||
* @return ERR_OK on success
|
||||
*/
|
||||
err_t wlanif_init_ap(struct netif *netif);
|
||||
|
||||
/**
|
||||
* @brief LWIP's network stack init function for WiFi (Station)
|
||||
* @param netif LWIP's network interface handle
|
||||
* @return ERR_OK on success
|
||||
*/
|
||||
err_t wlanif_init_sta(struct netif *netif);
|
||||
|
||||
/**
|
||||
* @brief LWIP's network stack input packet function for WiFi (both STA/AP)
|
||||
* @param h LWIP's network interface handle
|
||||
* @param buffer Input buffer pointer
|
||||
* @param len Input buffer size
|
||||
* @param l2_buff External buffer pointer (to be passed to custom input-buffer free)
|
||||
*/
|
||||
void wlanif_input(void *h, void *buffer, size_t len, void* l2_buff);
|
||||
|
||||
#endif // CONFIG_ESP_NETIF_TCPIP_LWIP
|
@ -7,8 +7,7 @@
|
||||
* @file esp_pbuf reference interface file
|
||||
*/
|
||||
|
||||
#ifndef __LWIP_ESP_PBUF_REF_H__
|
||||
#define __LWIP_ESP_PBUF_REF_H__
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include "lwip/pbuf.h"
|
||||
@ -28,5 +27,3 @@ struct pbuf* esp_pbuf_allocate(esp_netif_t *esp_netif, void *buffer, size_t len,
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__LWIP_ESP_PBUF_REF_H__
|
13
components/esp_netif/linker.lf
Normal file
13
components/esp_netif/linker.lf
Normal file
@ -0,0 +1,13 @@
|
||||
[mapping:esp_netif]
|
||||
archive: libesp_netif.a
|
||||
entries:
|
||||
if LWIP_IRAM_OPTIMIZATION = y:
|
||||
ethernetif:ethernet_low_level_output (noflash_text)
|
||||
ethernetif:ethernetif_input (noflash_text)
|
||||
wlanif:low_level_output (noflash_text)
|
||||
wlanif:wlanif_input (noflash_text)
|
||||
esp_netif_lwip:esp_netif_transmit_wrap (noflash_text)
|
||||
esp_netif_lwip:esp_netif_free_rx_buffer (noflash_text)
|
||||
esp_netif_lwip:esp_netif_receive (noflash_text)
|
||||
esp_pbuf_ref:esp_pbuf_allocate (noflash_text)
|
||||
esp_pbuf_ref:esp_pbuf_free (noflash_text)
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2015-2016 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: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -18,7 +10,6 @@
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_private.h"
|
||||
#include "esp_netif_sta_list.h"
|
||||
|
||||
#if CONFIG_ESP_NETIF_LOOPBACK
|
||||
|
||||
@ -398,11 +389,6 @@ esp_err_t esp_netif_get_dns_info(esp_netif_t *esp_netif, esp_netif_dns_type_t ty
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t esp_netif_get_sta_list(const wifi_sta_list_t *wifi_sta_list, esp_netif_sta_list_t *netif_sta_list)
|
||||
{
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t esp_netif_create_ip6_linklocal(esp_netif_t *esp_netif)
|
||||
{
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "esp_check.h"
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
#include "lwip/esp_netif_net_stack.h"
|
||||
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_private.h"
|
||||
@ -23,6 +25,7 @@
|
||||
#include "lwip/ip6_addr.h"
|
||||
#include "lwip/mld6.h"
|
||||
#include "lwip/nd6.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/priv/tcpip_priv.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/etharp.h"
|
||||
@ -1666,6 +1669,36 @@ static esp_err_t esp_netif_set_ip_info_api(esp_netif_api_msg_t *msg)
|
||||
|
||||
esp_err_t esp_netif_set_ip_info(esp_netif_t *esp_netif, const esp_netif_ip_info_t *ip_info) _RUN_IN_LWIP_TASK_IF_SUPPORTED(esp_netif_set_ip_info_api, esp_netif, ip_info)
|
||||
|
||||
struct array_mac_ip_t {
|
||||
int num;
|
||||
esp_netif_pair_mac_ip_t *mac_ip_pair;
|
||||
};
|
||||
|
||||
#if CONFIG_LWIP_DHCPS
|
||||
static esp_err_t esp_netif_dhcps_get_clients_by_mac_api(esp_netif_api_msg_t *msg)
|
||||
{
|
||||
esp_netif_t *netif = msg->esp_netif;
|
||||
struct array_mac_ip_t *params = msg->data;
|
||||
for (int i = 0; i < params->num; i++) {
|
||||
dhcp_search_ip_on_mac(netif->dhcps, params->mac_ip_pair[i].mac, (ip4_addr_t*)¶ms->mac_ip_pair[i].ip);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif // CONFIG_LWIP_DHCPS
|
||||
|
||||
esp_err_t esp_netif_dhcps_get_clients_by_mac(esp_netif_t *esp_netif, int num, esp_netif_pair_mac_ip_t *mac_ip_pair)
|
||||
{
|
||||
#if CONFIG_LWIP_DHCPS
|
||||
if (esp_netif == NULL || esp_netif->dhcps == NULL || num < 0 || mac_ip_pair == NULL) {
|
||||
return ESP_ERR_ESP_NETIF_INVALID_PARAMS;
|
||||
}
|
||||
struct array_mac_ip_t array_mac_ip = { num, mac_ip_pair };
|
||||
return esp_netif_lwip_ipc_call(esp_netif_dhcps_get_clients_by_mac_api, esp_netif, (void *)&array_mac_ip);
|
||||
#else
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif // CONFIG_LWIP_DHCPS
|
||||
}
|
||||
|
||||
static esp_err_t esp_netif_set_dns_info_api(esp_netif_api_msg_t *msg)
|
||||
{
|
||||
esp_netif_t *esp_netif = msg->esp_netif;
|
||||
@ -2145,6 +2178,19 @@ esp_err_t esp_netif_get_netif_impl_name(esp_netif_t *esp_netif, char* name)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_netif_set_link_speed_api(esp_netif_api_msg_t *msg)
|
||||
{
|
||||
uint32_t speed = *((uint32_t*)msg->data);
|
||||
esp_err_t error = ESP_OK;
|
||||
ESP_LOGD(TAG, "%s esp_netif:%p", __func__, msg->esp_netif);
|
||||
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, speed);
|
||||
LWIP_UNUSED_ARG(speed); // Maybe unused if SNMP disabled
|
||||
return error;
|
||||
}
|
||||
|
||||
esp_err_t esp_netif_set_link_speed(esp_netif_t *esp_netif, uint32_t speed)
|
||||
_RUN_IN_LWIP_TASK(esp_netif_set_link_speed_api, esp_netif, &speed)
|
||||
|
||||
#if CONFIG_LWIP_IPV6
|
||||
|
||||
static esp_err_t esp_netif_join_ip6_multicast_group_api(esp_netif_api_msg_t *msg)
|
||||
|
@ -6,16 +6,22 @@
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
#include "lwip/esp_netif_net_stack.h"
|
||||
#include "esp_netif_lwip_ppp.h"
|
||||
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP)
|
||||
|
||||
#include "netif/wlanif.h"
|
||||
#include "netif/ethernetif.h"
|
||||
#if CONFIG_ESP_NETIF_BRIDGE_EN
|
||||
#include "netif/bridgeif.h"
|
||||
#if CONFIG_OPENTHREAD_ENABLED
|
||||
#include "netif/openthreadif.h"
|
||||
#endif
|
||||
|
||||
static const struct esp_netif_netstack_config s_br_netif_config = {
|
||||
.lwip = {
|
||||
.init_fn = bridgeif_init,
|
||||
.input_fn = NULL
|
||||
}
|
||||
};
|
||||
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_br = &s_br_netif_config;
|
||||
#endif // CONFIG_ESP_NETIF_BRIDGE_EN
|
||||
|
||||
//
|
||||
// Purpose of this object is to define default network stack configuration
|
||||
@ -28,12 +34,6 @@ static const struct esp_netif_netstack_config s_eth_netif_config = {
|
||||
.input_fn = ethernetif_input
|
||||
}
|
||||
};
|
||||
static const struct esp_netif_netstack_config s_br_netif_config = {
|
||||
.lwip = {
|
||||
.init_fn = bridgeif_init,
|
||||
.input_fn = NULL
|
||||
}
|
||||
};
|
||||
static const struct esp_netif_netstack_config s_wifi_netif_config_ap = {
|
||||
.lwip = {
|
||||
.init_fn = wlanif_init_ap,
|
||||
@ -59,19 +59,8 @@ static const struct esp_netif_netstack_config s_netif_config_ppp = {
|
||||
};
|
||||
|
||||
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth = &s_eth_netif_config;
|
||||
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_br = &s_br_netif_config;
|
||||
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta = &s_wifi_netif_config_sta;
|
||||
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap = &s_wifi_netif_config_ap;
|
||||
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp = &s_netif_config_ppp;
|
||||
|
||||
#if CONFIG_OPENTHREAD_ENABLED
|
||||
static const struct esp_netif_netstack_config s_netif_config_openthread = {
|
||||
.lwip = {
|
||||
.init_fn = openthread_netif_init,
|
||||
.input_fn = openthread_netif_input,
|
||||
}
|
||||
};
|
||||
const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_openthread = &s_netif_config_openthread;
|
||||
#endif // CONFIG_OPENTHREAD_ENABLED
|
||||
|
||||
#endif /*CONFIG_ESP_NETIF_TCPIP_LWIP*/
|
||||
|
@ -14,30 +14,6 @@
|
||||
|
||||
#if defined(CONFIG_ESP_NETIF_TCPIP_LWIP)
|
||||
|
||||
struct esp_netif_netstack_lwip_vanilla_config {
|
||||
err_t (*init_fn)(struct netif*);
|
||||
void (*input_fn)(void *netif, void *buffer, size_t len, void *eb);
|
||||
};
|
||||
|
||||
struct esp_netif_netstack_lwip_ppp_config {
|
||||
void (*input_fn)(void *netif, void *buffer, size_t len, void *eb);
|
||||
esp_netif_ppp_config_t ppp_events;
|
||||
};
|
||||
|
||||
struct esp_netif_netstack_lwip_slip_config {
|
||||
err_t (*init_fn)(struct netif*);
|
||||
void (*input_fn)(void *netif, void *buffer, size_t len, void *eb);
|
||||
esp_netif_slip_config_t slip_config;
|
||||
};
|
||||
|
||||
// LWIP netif specific network stack configuration
|
||||
struct esp_netif_netstack_config {
|
||||
union {
|
||||
struct esp_netif_netstack_lwip_vanilla_config lwip;
|
||||
struct esp_netif_netstack_lwip_ppp_config lwip_ppp;
|
||||
};
|
||||
};
|
||||
|
||||
struct esp_netif_api_msg_s;
|
||||
|
||||
typedef int (*esp_netif_api_fn)(struct esp_netif_api_msg_s *msg);
|
||||
|
@ -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-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -19,6 +11,7 @@
|
||||
#include "esp_netif_slip.h"
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "lwip/esp_netif_net_stack.h"
|
||||
|
||||
#ifdef CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "esp_netif_lwip_internal.h"
|
||||
#include "esp_netif_sta_list.h"
|
||||
#include "dhcpserver/dhcpserver.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#if CONFIG_ESP_NETIF_TCPIP_LWIP
|
||||
|
||||
static const char *TAG = "esp_netif_sta_list";
|
||||
|
||||
esp_err_t esp_netif_get_sta_list(const wifi_sta_list_t *wifi_sta_list, esp_netif_sta_list_t *netif_sta_list)
|
||||
{
|
||||
ESP_LOGD(TAG, "%s entered", __func__);
|
||||
|
||||
if ((wifi_sta_list == NULL) || (netif_sta_list == NULL)) {
|
||||
return ESP_ERR_ESP_NETIF_INVALID_PARAMS;
|
||||
}
|
||||
esp_netif_t *ap = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
if (ap == NULL) {
|
||||
return ESP_ERR_ESP_NETIF_IF_NOT_READY;
|
||||
}
|
||||
memset(netif_sta_list, 0, sizeof(esp_netif_sta_list_t));
|
||||
netif_sta_list->num = wifi_sta_list->num;
|
||||
for (int i = 0; i < wifi_sta_list->num; i++) {
|
||||
memcpy(netif_sta_list->sta[i].mac, wifi_sta_list->sta[i].mac, 6);
|
||||
#if CONFIG_LWIP_DHCPS
|
||||
dhcp_search_ip_on_mac(ap->dhcps, netif_sta_list->sta[i].mac, (ip4_addr_t*)&netif_sta_list->sta[i].ip);
|
||||
#endif
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif // CONFIG_ESP_NETIF_TCPIP_LWIP
|
@ -9,9 +9,9 @@
|
||||
* and the L2 free function esp_netif_free_rx_buffer()
|
||||
*/
|
||||
|
||||
#include "netif/esp_pbuf_ref.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/esp_pbuf_ref.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
|
||||
/**
|
||||
* @brief Specific pbuf structure for pbufs allocated by ESP netif
|
||||
@ -37,7 +37,14 @@ static void esp_pbuf_free(struct pbuf *pbuf)
|
||||
mem_free(pbuf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate custom pbuf for supplied sp_netif
|
||||
* @param esp_netif esp-netif handle
|
||||
* @param buffer Buffer to allocate
|
||||
* @param len Size of the buffer
|
||||
* @param l2_buff External l2 buffe
|
||||
* @return Custom pbuf pointer on success; NULL if no free heap
|
||||
*/
|
||||
struct pbuf* esp_pbuf_allocate(esp_netif_t *esp_netif, void *buffer, size_t len, void *l2_buff)
|
||||
{
|
||||
struct pbuf *p;
|
@ -1,58 +1,27 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2001-2004 Swedish Institute of Computer Science
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* SPDX-FileContributor: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* Ethernet Interface Skeleton
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/ethip6.h"
|
||||
#include "netif/etharp.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/ethip6.h"
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#include "esp_eth_driver.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "netif/esp_pbuf_ref.h"
|
||||
#include "lwip/esp_pbuf_ref.h"
|
||||
|
||||
/* Define those to better describe your network interface. */
|
||||
#define IFNAME0 'e'
|
||||
@ -127,7 +96,8 @@ static err_t ethernet_low_level_output(struct netif *netif, struct pbuf *p)
|
||||
/* Check error */
|
||||
if (likely(ret == ESP_OK)) {
|
||||
return ERR_OK;
|
||||
} else if (ret == ESP_ERR_NO_MEM) {
|
||||
}
|
||||
if (ret == ESP_ERR_NO_MEM) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
return ERR_IF;
|
||||
@ -186,7 +156,7 @@ err_t ethernetif_init(struct netif *netif)
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
/* Have to get the esp-netif handle from netif first and then driver==ethernet handle from there */
|
||||
esp_netif_t *esp_netif = esp_netif_get_handle_from_netif_impl(netif);
|
||||
esp_eth_handle_t eth_handle = esp_netif_get_io_driver(esp_netif);
|
||||
|
||||
/* Initialize interface hostname */
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
#if ESP_LWIP
|
||||
@ -199,16 +169,6 @@ err_t ethernetif_init(struct netif *netif)
|
||||
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
/* Initialize the snmp variables and counters inside the struct netif. */
|
||||
eth_speed_t speed;
|
||||
|
||||
esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &speed);
|
||||
if (speed == ETH_SPEED_100M) {
|
||||
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 100000000);
|
||||
} else {
|
||||
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 10000000);
|
||||
}
|
||||
|
||||
netif->name[0] = IFNAME0;
|
||||
netif->name[1] = IFNAME1;
|
||||
netif->output = etharp_output;
|
230
components/esp_netif/lwip/netif/wlanif.c
Normal file
230
components/esp_netif/lwip/netif/wlanif.c
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2001-2004 Swedish Institute of Computer Science
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* SPDX-FileContributor: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* Ethernet Interface Skeleton used for WiFi
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/ethip6.h"
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "lwip/esp_netif_net_stack.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "lwip/esp_pbuf_ref.h"
|
||||
|
||||
/**
|
||||
* In this function, the hardware should be initialized.
|
||||
* Called from wlanif_input().
|
||||
*
|
||||
* @param netif the already initialized lwip network interface structure
|
||||
* for this wlanif
|
||||
*/
|
||||
static void
|
||||
low_level_init(struct netif *netif)
|
||||
{
|
||||
/* set MAC hardware address length */
|
||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
||||
|
||||
/* set MAC hardware address */
|
||||
|
||||
/* maximum transfer unit */
|
||||
netif->mtu = 1500;
|
||||
|
||||
/* device capabilities */
|
||||
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
|
||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
||||
|
||||
#if ESP_LWIP
|
||||
#if LWIP_IGMP
|
||||
netif->flags |= NETIF_FLAG_IGMP;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ESP_IPV6
|
||||
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
||||
netif->flags |= NETIF_FLAG_MLD6;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function should do the actual transmission of the packet. The packet is
|
||||
* contained in the pbuf that is passed to the function. This pbuf
|
||||
* might be chained.
|
||||
*
|
||||
* @param netif the lwip network interface structure for this wlanif
|
||||
* @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
|
||||
* @return ERR_OK if the packet could be sent
|
||||
* an err_t value if the packet couldn't be sent
|
||||
*
|
||||
* @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
|
||||
* strange results. You might consider waiting for space in the DMA queue
|
||||
* to become available since the stack doesn't retry to send a packet
|
||||
* dropped because of memory failure (except for the TCP timers).
|
||||
*/
|
||||
static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
esp_netif_t *esp_netif = netif->state;
|
||||
if (esp_netif == NULL) {
|
||||
return ERR_IF;
|
||||
}
|
||||
|
||||
struct pbuf *q = p;
|
||||
esp_err_t ret;
|
||||
|
||||
if(q->next == NULL) {
|
||||
ret = esp_netif_transmit_wrap(esp_netif, q->payload, q->len, q);
|
||||
|
||||
} else {
|
||||
LWIP_DEBUGF(PBUF_DEBUG, ("low_level_output: pbuf is a list, application may has bug"));
|
||||
q = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM);
|
||||
if (q != NULL) {
|
||||
pbuf_copy(q, p);
|
||||
} else {
|
||||
return ERR_MEM;
|
||||
}
|
||||
ret = esp_netif_transmit_wrap(esp_netif, q->payload, q->len, q);
|
||||
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
return ERR_OK;
|
||||
}
|
||||
if (ret == ESP_ERR_NO_MEM) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
if (ret == ESP_ERR_INVALID_ARG) {
|
||||
return ERR_ARG;
|
||||
}
|
||||
return ERR_IF;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function should be called when a packet is ready to be read
|
||||
* from the interface. It uses the function low_level_input() that
|
||||
* should handle the actual reception of bytes from the network
|
||||
* interface. Then the type of the received packet is determined and
|
||||
* the appropriate input function is called.
|
||||
*
|
||||
* @param h lwip network interface structure (struct netif) for this ethernetif
|
||||
* @param buffer wlan buffer
|
||||
* @param len length of buffer
|
||||
* @param l2_buff wlan's L2 buffer pointer
|
||||
*/
|
||||
void wlanif_input(void *h, void *buffer, size_t len, void* l2_buff)
|
||||
{
|
||||
struct netif * netif = h;
|
||||
esp_netif_t *esp_netif = netif->state;
|
||||
struct pbuf *p;
|
||||
|
||||
if(unlikely(!buffer || !netif_is_up(netif))) {
|
||||
if (l2_buff) {
|
||||
esp_netif_free_rx_buffer(esp_netif, l2_buff);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LWIP_L2_TO_L3_COPY
|
||||
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
|
||||
if (p == NULL) {
|
||||
esp_netif_free_rx_buffer(esp_netif, l2_buff);
|
||||
return;
|
||||
}
|
||||
memcpy(p->payload, buffer, len);
|
||||
esp_netif_free_rx_buffer(esp_netif, l2_buff);
|
||||
#else
|
||||
p = esp_pbuf_allocate(esp_netif, buffer, len, l2_buff);
|
||||
if (p == NULL) {
|
||||
esp_netif_free_rx_buffer(esp_netif, l2_buff);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* full packet send to tcpip_thread to process */
|
||||
if (unlikely(netif->input(p, netif) != ERR_OK)) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("wlanif_input: IP input error\n"));
|
||||
pbuf_free(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called at the beginning of the program to set up the
|
||||
* network interface. It calls the function low_level_init() to do the
|
||||
* actual setup of the hardware.
|
||||
*
|
||||
* This function should be passed as a parameter to netif_add().
|
||||
*
|
||||
* @param netif the lwip network interface structure for this wlanif
|
||||
* @return ERR_OK if the loopif is initialized
|
||||
* ERR_MEM if private data couldn't be allocated
|
||||
* any other err_t on error
|
||||
*/
|
||||
err_t
|
||||
wlanif_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
/* Initialize interface hostname */
|
||||
|
||||
#if ESP_LWIP
|
||||
if (esp_netif_get_hostname(esp_netif_get_handle_from_netif_impl(netif), &netif->hostname) != ESP_OK) {
|
||||
netif->hostname = CONFIG_LWIP_LOCAL_HOSTNAME;
|
||||
}
|
||||
#else
|
||||
netif->hostname = "lwip";
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
/*
|
||||
* Initialize the snmp variables and counters inside the struct netif.
|
||||
* The last argument should be replaced with your link speed, in units
|
||||
* of bits per second.
|
||||
*/
|
||||
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 100);
|
||||
|
||||
/* We directly use etharp_output() here to save a function call.
|
||||
* You can instead declare your own function an call etharp_output()
|
||||
* from it if you have to do some checks before sending (e.g. if link
|
||||
* is available...) */
|
||||
netif->output = etharp_output;
|
||||
#if LWIP_IPV6
|
||||
netif->output_ip6 = ethip6_output;
|
||||
#endif /* LWIP_IPV6 */
|
||||
netif->linkoutput = low_level_output;
|
||||
|
||||
/* initialize the hardware */
|
||||
low_level_init(netif);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
err_t wlanif_init_sta(struct netif *netif) {
|
||||
netif->name[0] = 's';
|
||||
netif->name[1] = 't';
|
||||
return wlanif_init(netif);
|
||||
}
|
||||
|
||||
err_t wlanif_init_ap(struct netif *netif) {
|
||||
netif->name[0] = 'a';
|
||||
netif->name[1] = 'p';
|
||||
return wlanif_init(netif);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "../private_include" "."
|
||||
PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver esp_eth)
|
||||
PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver esp_eth esp_wifi)
|
||||
|
@ -2,4 +2,4 @@ idf_component_register(SRCS "esp_netif_test.c"
|
||||
REQUIRES test_utils
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "$ENV{IDF_PATH}/components/esp_netif/private_include" "."
|
||||
PRIV_REQUIRES unity esp_netif nvs_flash)
|
||||
PRIV_REQUIRES unity esp_netif nvs_flash esp_wifi)
|
||||
|
@ -31,7 +31,7 @@ endif()
|
||||
# [refactor-todo]: requires "driver" component for periph_ctrl header file
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "include" "${idf_target}/include"
|
||||
PRIV_REQUIRES nvs_flash driver efuse esp_timer esp_adc
|
||||
PRIV_REQUIRES nvs_flash driver efuse esp_timer esp_adc esp_wifi
|
||||
LDFRAGMENTS "${ldfragments}"
|
||||
EMBED_FILES ${embed_files}
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRC_DIRS .
|
||||
PRIV_INCLUDE_DIRS . ${CMAKE_CURRENT_BINARY_DIR}
|
||||
PRIV_REQUIRES cmock test_utils nvs_flash ulp esp_common esp_phy
|
||||
PRIV_REQUIRES cmock test_utils nvs_flash ulp esp_common esp_phy esp_wifi
|
||||
)
|
||||
|
@ -24,13 +24,14 @@ if(CONFIG_ESP32_WIFI_ENABLED)
|
||||
"src/wifi_init.c"
|
||||
"src/wifi_default.c"
|
||||
"src/wifi_netif.c"
|
||||
"src/wifi_default_ap.c"
|
||||
"${idf_target}/esp_adapter.c")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES esp_event esp_phy
|
||||
PRIV_REQUIRES driver esptool_py esp_netif esp_pm esp_timer nvs_flash esp_adc
|
||||
REQUIRES esp_event esp_phy esp_netif
|
||||
PRIV_REQUIRES driver esptool_py esp_pm esp_timer nvs_flash esp_adc
|
||||
wpa_supplicant hal lwip ${extra_priv_requires}
|
||||
LDFRAGMENTS "${ldfragments}")
|
||||
|
||||
|
@ -4,40 +4,22 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_NETIF_STA_LIST_H_
|
||||
#define _ESP_NETIF_STA_LIST_H_
|
||||
#pragma once
|
||||
|
||||
#include "esp_netif_types.h"
|
||||
#include "esp_wifi_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief station list info element
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t mac[6]; /**< Station MAC address */
|
||||
esp_ip4_addr_t ip; /**< Station assigned IP address */
|
||||
} esp_netif_sta_info_t;
|
||||
|
||||
/**
|
||||
* @brief station list structure
|
||||
*/
|
||||
typedef struct {
|
||||
esp_netif_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< Connected stations */
|
||||
int num; /**< Number of connected stations */
|
||||
} esp_netif_sta_list_t;
|
||||
|
||||
/**
|
||||
* @defgroup ESP_NETIF_STA_LIST ESP-NETIF STA list api
|
||||
* @brief List of stations for Wi-Fi AP interface
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup ESP_NETIF_STA_LIST
|
||||
* @{
|
||||
*/
|
||||
int num; /**< Number of connected stations */
|
||||
esp_netif_pair_mac_ip_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< Connected stations */
|
||||
} wifi_sta_mac_ip_list_t;
|
||||
|
||||
/**
|
||||
* @brief Get IP information for stations connected to the Wi-Fi AP interface
|
||||
@ -54,7 +36,7 @@ typedef struct {
|
||||
* - ESP_ERR_ESP_NETIF_NO_MEM
|
||||
* - ESP_ERR_ESP_NETIF_INVALID_PARAMS
|
||||
*/
|
||||
esp_err_t esp_netif_get_sta_list(const wifi_sta_list_t *wifi_sta_list, esp_netif_sta_list_t *netif_sta_list);
|
||||
esp_err_t esp_wifi_ap_get_sta_list_with_ip(const wifi_sta_list_t *wifi_sta_list, wifi_sta_mac_ip_list_t *wifi_sta_ip_mac_list);
|
||||
|
||||
/**
|
||||
* @}
|
||||
@ -63,5 +45,3 @@ esp_err_t esp_netif_get_sta_list(const wifi_sta_list_t *wifi_sta_list, esp_netif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_ESP_NETIF_STA_LIST_H_
|
@ -1,19 +1,10 @@
|
||||
// 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
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef _ESP_WIFI_NETIF_H
|
||||
#define _ESP_WIFI_NETIF_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -67,8 +58,8 @@ esp_err_t esp_wifi_get_if_mac(wifi_netif_driver_t ifx, uint8_t mac[6]);
|
||||
* @param[in] ifx pointer to wifi interface handle
|
||||
*
|
||||
* @return
|
||||
* - true if ready after intertace started (typically Access Point type)
|
||||
* - false if ready once intertace connected (typically for Station type)
|
||||
* - true if ready after interface started (typically Access Point type)
|
||||
* - false if ready once interface connected (typically for Station type)
|
||||
*/
|
||||
bool esp_wifi_is_if_ready_when_started(wifi_netif_driver_t ifx);
|
||||
|
||||
@ -76,7 +67,7 @@ bool esp_wifi_is_if_ready_when_started(wifi_netif_driver_t ifx);
|
||||
* @brief Register interface receive callback function with argument
|
||||
*
|
||||
* @param[in] ifx pointer to wifi interface handle
|
||||
* @param[in] fn funtion to be registered (typically esp_netif_receive)
|
||||
* @param[in] fn function to be registered (typically esp_netif_receive)
|
||||
* @param[in] arg argument to be supplied to registered function (typically esp_netif ptr)
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
@ -87,5 +78,3 @@ esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_ESP_WIFI_NETIF_H
|
||||
|
@ -134,7 +134,7 @@ static void wifi_default_action_sta_got_ip(void *arg, esp_event_base_t base, int
|
||||
/**
|
||||
* @brief Clear default handlers
|
||||
*/
|
||||
esp_err_t _esp_wifi_clear_default_wifi_handlers(void)
|
||||
static esp_err_t clear_default_wifi_handlers(void)
|
||||
{
|
||||
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_START, wifi_default_action_sta_start);
|
||||
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_STOP, wifi_default_action_sta_stop);
|
||||
@ -153,7 +153,7 @@ esp_err_t _esp_wifi_clear_default_wifi_handlers(void)
|
||||
/**
|
||||
* @brief Set default handlers
|
||||
*/
|
||||
esp_err_t _esp_wifi_set_default_wifi_handlers(void)
|
||||
static esp_err_t set_default_wifi_handlers(void)
|
||||
{
|
||||
if (wifi_default_handlers_set) {
|
||||
return ESP_OK;
|
||||
@ -205,7 +205,7 @@ esp_err_t _esp_wifi_set_default_wifi_handlers(void)
|
||||
return ESP_OK;
|
||||
|
||||
fail:
|
||||
_esp_wifi_clear_default_wifi_handlers();
|
||||
clear_default_wifi_handlers();
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ fail:
|
||||
*/
|
||||
esp_err_t esp_wifi_set_default_wifi_sta_handlers(void)
|
||||
{
|
||||
return _esp_wifi_set_default_wifi_handlers();
|
||||
return set_default_wifi_handlers();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -222,7 +222,7 @@ esp_err_t esp_wifi_set_default_wifi_sta_handlers(void)
|
||||
*/
|
||||
esp_err_t esp_wifi_set_default_wifi_ap_handlers(void)
|
||||
{
|
||||
return _esp_wifi_set_default_wifi_handlers();
|
||||
return set_default_wifi_handlers();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -246,7 +246,7 @@ esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif)
|
||||
|
||||
if (i == MAX_WIFI_IFS) { // if all wifi default netifs are null
|
||||
ESP_LOGD(TAG, "Clearing wifi default handlers");
|
||||
_esp_wifi_clear_default_wifi_handlers();
|
||||
clear_default_wifi_handlers();
|
||||
}
|
||||
return disconnect_and_destroy(esp_netif);
|
||||
}
|
||||
|
29
components/esp_wifi/src/wifi_default_ap.c
Normal file
29
components/esp_wifi/src/wifi_default_ap.c
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "esp_log.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_wifi_ap_get_sta_list.h"
|
||||
|
||||
|
||||
esp_err_t esp_wifi_ap_get_sta_list_with_ip(const wifi_sta_list_t *wifi_sta_list, wifi_sta_mac_ip_list_t *wifi_sta_ip_mac_list)
|
||||
{
|
||||
if ((wifi_sta_list == NULL) || (wifi_sta_ip_mac_list == NULL)) {
|
||||
return ESP_ERR_ESP_NETIF_INVALID_PARAMS;
|
||||
}
|
||||
esp_netif_t *ap = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
|
||||
if (ap == NULL) {
|
||||
return ESP_ERR_ESP_NETIF_IF_NOT_READY;
|
||||
}
|
||||
int num = wifi_sta_list->num;
|
||||
wifi_sta_ip_mac_list->num = num;
|
||||
for (int i = 0; i < num; i++) {
|
||||
memcpy(wifi_sta_ip_mac_list->sta[i].mac, wifi_sta_list->sta[i].mac, 6);
|
||||
memset(&wifi_sta_ip_mac_list->sta[i].ip, 0, sizeof(esp_ip4_addr_t));
|
||||
}
|
||||
return esp_netif_dhcps_get_clients_by_mac(ap, num, wifi_sta_ip_mac_list->sta);
|
||||
}
|
@ -5,8 +5,6 @@
|
||||
*/
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "netif/wlanif.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_private/wifi.h"
|
||||
#include "esp_wifi_netif.h"
|
||||
@ -19,13 +17,35 @@
|
||||
/**
|
||||
* @brief WiFi netif driver structure
|
||||
*/
|
||||
typedef struct wifi_netif_driver {
|
||||
struct wifi_netif_driver {
|
||||
esp_netif_driver_base_t base;
|
||||
wifi_interface_t wifi_if;
|
||||
}* wifi_netif_driver_t;
|
||||
};
|
||||
|
||||
static const char* TAG = "wifi_netif";
|
||||
|
||||
/**
|
||||
* @brief Local storage for netif handles and callbacks for specific wifi interfaces
|
||||
*/
|
||||
static esp_netif_receive_t s_wifi_rxcbs[MAX_WIFI_IFS] = { NULL };
|
||||
static esp_netif_t *s_wifi_netifs[MAX_WIFI_IFS] = { NULL };
|
||||
|
||||
/**
|
||||
* @brief WiFi netif driver IO functions, a thin glue layer
|
||||
* to the original wifi interface API
|
||||
*/
|
||||
static esp_err_t wifi_sta_receive(void *buffer, uint16_t len, void *eb)
|
||||
{
|
||||
return s_wifi_rxcbs[WIFI_IF_STA](s_wifi_netifs[WIFI_IF_STA], buffer, len, eb);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
||||
static esp_err_t wifi_ap_receive(void *buffer, uint16_t len, void *eb)
|
||||
{
|
||||
return s_wifi_rxcbs[WIFI_IF_AP](s_wifi_netifs[WIFI_IF_AP], buffer, len, eb);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void wifi_free(void *h, void* buffer)
|
||||
{
|
||||
if (buffer) {
|
||||
@ -68,6 +88,7 @@ void esp_wifi_destroy_if_driver(wifi_netif_driver_t h)
|
||||
if (h) {
|
||||
esp_wifi_internal_reg_rxcb(h->wifi_if, NULL); // ignore the potential error
|
||||
// as the wifi might have been already uninitialized
|
||||
s_wifi_netifs[h->wifi_if] = NULL;
|
||||
}
|
||||
free(h);
|
||||
}
|
||||
@ -108,6 +129,7 @@ esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
wifi_interface_t wifi_interface = ifx->wifi_if;
|
||||
s_wifi_rxcbs[wifi_interface] = fn;
|
||||
wifi_rxcb_t rxcb = NULL;
|
||||
esp_err_t ret;
|
||||
|
||||
@ -115,12 +137,12 @@ esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t
|
||||
{
|
||||
|
||||
case WIFI_IF_STA:
|
||||
rxcb = wifi_rxcb_sta;
|
||||
rxcb = wifi_sta_receive;
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
||||
case WIFI_IF_AP:
|
||||
rxcb = wifi_rxcb_ap;
|
||||
rxcb = wifi_ap_receive;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -134,12 +156,10 @@ esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t
|
||||
}
|
||||
|
||||
/* Interface must be set before registering Wi-Fi RX callback */
|
||||
set_wifi_netif(wifi_interface, esp_netif_get_netif_impl(arg));
|
||||
|
||||
s_wifi_netifs[wifi_interface] = ifx->base.netif;
|
||||
if ((ret = esp_wifi_internal_reg_rxcb(wifi_interface, rxcb)) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_wifi_internal_reg_rxcb for if=%d failed with %d", wifi_interface, ret);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRC_DIRS .
|
||||
PRIV_INCLUDE_DIRS . ${CMAKE_CURRENT_BINARY_DIR}
|
||||
PRIV_REQUIRES cmock test_utils nvs_flash ulp esp_common
|
||||
PRIV_REQUIRES cmock test_utils nvs_flash ulp esp_common esp_wifi esp_event
|
||||
)
|
||||
|
@ -11,5 +11,6 @@ set(srcs "diskio/diskio.c"
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS diskio vfs src
|
||||
REQUIRES wear_levelling sdmmc vfs
|
||||
REQUIRES wear_levelling sdmmc
|
||||
PRIV_REQUIRES vfs
|
||||
)
|
||||
|
@ -89,9 +89,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"
|
||||
"port/esp32/netif/esp_pbuf_ref.c")
|
||||
"port/esp32/sockets_ext.c")
|
||||
|
||||
if(CONFIG_LWIP_PPP_SUPPORT)
|
||||
list(APPEND srcs
|
||||
@ -127,20 +125,12 @@ if(CONFIG_LWIP_PPP_SUPPORT)
|
||||
"lwip/src/netif/ppp/polarssl/sha1.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_ETH_ENABLED)
|
||||
list(APPEND srcs "port/esp32/netif/ethernetif.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_VFS_SUPPORT_IO)
|
||||
list(APPEND srcs "port/esp32/vfs_lwip.c")
|
||||
else()
|
||||
list(APPEND srcs "port/esp32/no_vfs_syscalls.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_OPENTHREAD_ENABLED)
|
||||
list(APPEND srcs "port/esp32/netif/openthreadif.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_LWIP_ICMP)
|
||||
list(APPEND srcs
|
||||
"apps/ping/esp_ping.c"
|
||||
@ -159,8 +149,7 @@ endif()
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
LDFRAGMENTS linker.lf
|
||||
REQUIRES vfs esp_wifi
|
||||
PRIV_REQUIRES esp_netif)
|
||||
PRIV_REQUIRES vfs)
|
||||
|
||||
# lots of LWIP source files evaluate macros that check address of stack variables
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-address)
|
||||
|
@ -78,13 +78,6 @@ entries:
|
||||
sys_arch:sys_mbox_post (noflash_text)
|
||||
sys_arch:sys_mbox_trypost (noflash_text)
|
||||
sys_arch:sys_arch_mbox_fetch (noflash_text)
|
||||
ethernetif:ethernet_low_level_output (noflash_text)
|
||||
ethernetif:ethernetif_input (noflash_text)
|
||||
wlanif:sta_output (noflash_text)
|
||||
wlanif:ap_output (noflash_text)
|
||||
wlanif:wifi_rxcb_sta (noflash_text)
|
||||
wlanif:wifi_rxcb_ap (noflash_text)
|
||||
wlanif:wifi_pbuf_free (noflash_text)
|
||||
lwip_default_hooks:ip4_route_src_hook (noflash_text)
|
||||
|
||||
if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
|
||||
|
@ -1,35 +0,0 @@
|
||||
// Copyright 2015-2016 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.
|
||||
|
||||
|
||||
#ifndef _ETH_LWIP_IF_H_
|
||||
#define _ETH_LWIP_IF_H_
|
||||
|
||||
#include "lwip/err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
err_t ethernetif_init(struct netif *netif);
|
||||
|
||||
void ethernetif_input(void *netif, void *buffer, size_t len, void *eb);
|
||||
|
||||
void netif_reg_addr_change_cb(void* cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ETH_LWIP_IF_H_ */
|
@ -1,52 +0,0 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) CO 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
|
||||
|
||||
#ifndef _OPENTHREAD_LWIP_IF_H_
|
||||
#define _OPENTHREAD_LWIP_IF_H_
|
||||
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/ip6.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This function initializes the OpenThread lwIP network interface.
|
||||
*
|
||||
* @param[in] netif The lwIP interface to initialize
|
||||
*
|
||||
* @return
|
||||
* - ERR_OK
|
||||
*
|
||||
*/
|
||||
err_t openthread_netif_init(struct netif *netif);
|
||||
|
||||
/**
|
||||
* @brief This function sends the buffer to the lwIP network interface
|
||||
*
|
||||
* @param[in] netif The lwIP interface to send to.
|
||||
* @param[in] buffer The packet to send.
|
||||
* @param[in] len The length of the buffer.
|
||||
* @param[in] eb Unused.
|
||||
*
|
||||
*/
|
||||
void openthread_netif_input(void *netif, void *buffer, size_t len, void *eb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _OPENTHREAD_LWIP_IF_H_ */
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _WLAN_LWIP_IF_H_
|
||||
#define _WLAN_LWIP_IF_H_
|
||||
|
||||
#include "esp_wifi.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
err_t wlanif_init_ap(struct netif *netif);
|
||||
err_t wlanif_init_sta(struct netif *netif);
|
||||
err_t set_wifi_netif(int wifi_inx, void* netif);
|
||||
esp_err_t wifi_rxcb_sta(void *buffer, uint16_t len, void *l2_buff);
|
||||
esp_err_t wifi_rxcb_ap(void *buffer, uint16_t len, void *l2_buff);
|
||||
|
||||
|
||||
void wlanif_input(void *netif, void *buffer, size_t len, void* eb);
|
||||
err_t wlanif_init(struct netif *netif);
|
||||
|
||||
wifi_interface_t wifi_get_interface(void *dev);
|
||||
|
||||
void netif_reg_addr_change_cb(void* cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _WLAN_LWIP_IF_H_ */
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "netif/openthreadif.h"
|
||||
#include "esp_openthread.h"
|
||||
#include "esp_openthread_lock.h"
|
||||
#include "openthread/error.h"
|
||||
#include "openthread/ip6.h"
|
||||
#include "openthread/link.h"
|
||||
#include "openthread/message.h"
|
||||
|
||||
#define OPENTHREAD_IP6_MTU 1280
|
||||
|
||||
static err_t openthread_output_ip6(struct netif *netif, struct pbuf *p, const struct ip6_addr *peer_addr)
|
||||
{
|
||||
struct pbuf *q = p;
|
||||
esp_netif_t *esp_netif = esp_netif_get_handle_from_netif_impl(netif);
|
||||
esp_err_t ret = ESP_FAIL;
|
||||
if (!esp_netif) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("corresponding esp-netif is NULL: netif=%p pbuf=%p len=%d\n", netif, p, p->len));
|
||||
return ERR_IF;
|
||||
}
|
||||
|
||||
if (q->next == NULL) {
|
||||
ret = esp_netif_transmit(esp_netif, q->payload, q->len);
|
||||
} else {
|
||||
LWIP_DEBUGF(PBUF_DEBUG, ("low_level_output: pbuf is a list, application may has bug"));
|
||||
q = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM);
|
||||
if (q != NULL) {
|
||||
pbuf_copy(q, p);
|
||||
} else {
|
||||
return ERR_MEM;
|
||||
}
|
||||
ret = esp_netif_transmit(esp_netif, q->payload, q->len);
|
||||
/* content in payload has been copied to OpenThread queue, it's safe to free pbuf now */
|
||||
pbuf_free(q);
|
||||
}
|
||||
/* Check error */
|
||||
switch (ret) {
|
||||
case ESP_ERR_NO_MEM:
|
||||
return ERR_MEM;
|
||||
|
||||
case ESP_OK:
|
||||
return ERR_OK;
|
||||
|
||||
default:
|
||||
return ERR_ABRT;
|
||||
}
|
||||
}
|
||||
|
||||
void openthread_netif_input(void *h, void *buffer, size_t len, void *eb)
|
||||
{
|
||||
struct netif *netif = h;
|
||||
struct pbuf *p;
|
||||
otMessage *message = (otMessage *)buffer;
|
||||
|
||||
if (unlikely(buffer == NULL || !netif_is_up(netif))) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Allocate LINK buffer in case it's forwarded to WiFi/ETH */
|
||||
p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
|
||||
if (p == NULL) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("Failed to allocate input pbuf for OpenThread netif\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (unlikely(otMessageRead(message, 0, p->payload, len) != OT_ERROR_NONE)) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("Failed to read OpenThread message\n"));
|
||||
}
|
||||
|
||||
/* full packet send to tcpip_thread to process */
|
||||
if (unlikely(netif->input(p, netif) != ERR_OK)) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("openthread_netif_input: IP input error\n"));
|
||||
pbuf_free(p);
|
||||
}
|
||||
/* the pbuf will be free in upper layer, eg: tcpip_input */
|
||||
}
|
||||
|
||||
static err_t openthread_netif_multicast_handler(struct netif *netif,
|
||||
const ip6_addr_t *group, enum netif_mac_filter_action action)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otIp6Address multicast_addr;
|
||||
|
||||
memcpy(multicast_addr.mFields.m8, group->addr, sizeof(group->addr));
|
||||
esp_openthread_lock_acquire(portMAX_DELAY);
|
||||
if (action == NETIF_ADD_MAC_FILTER) {
|
||||
error = otIp6SubscribeMulticastAddress(esp_openthread_get_instance(), &multicast_addr);
|
||||
} else {
|
||||
error = otIp6UnsubscribeMulticastAddress(esp_openthread_get_instance(), &multicast_addr);
|
||||
}
|
||||
esp_openthread_lock_release();
|
||||
switch (error) {
|
||||
case OT_ERROR_NONE:
|
||||
case OT_ERROR_ALREADY:
|
||||
return ERR_OK;
|
||||
case OT_ERROR_NO_BUFS:
|
||||
return ERR_MEM;
|
||||
case OT_ERROR_INVALID_ARGS:
|
||||
return ERR_ARG;
|
||||
default:
|
||||
return ERR_IF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
err_t openthread_netif_init(struct netif *netif)
|
||||
{
|
||||
netif->name[0] = 'o';
|
||||
netif->name[1] = 't';
|
||||
netif->hwaddr_len = sizeof(otExtAddress);
|
||||
memset(netif->hwaddr, 0, sizeof(netif->hwaddr));
|
||||
netif->mtu = OPENTHREAD_IP6_MTU;
|
||||
netif->flags = NETIF_FLAG_BROADCAST;
|
||||
netif->output = NULL;
|
||||
netif->output_ip6 = openthread_output_ip6;
|
||||
netif->mld_mac_filter = openthread_netif_multicast_handler;
|
||||
netif_set_link_up(netif);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
@ -1,362 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2001-2004 Swedish Institute of Computer Science
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* SPDX-FileContributor: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* Ethernet Interface Skeleton used for WiFi
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/ethip6.h"
|
||||
#include "netif/etharp.h"
|
||||
#include "netif/wlanif.h"
|
||||
#include "esp_private/wifi.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "netif/esp_pbuf_ref.h"
|
||||
|
||||
|
||||
typedef struct wifi_custom_pbuf
|
||||
{
|
||||
struct pbuf_custom p;
|
||||
void* l2_buf;
|
||||
} wifi_custom_pbuf_t;
|
||||
|
||||
static struct netif *s_wifi_netifs[2] = { NULL };
|
||||
|
||||
|
||||
/**
|
||||
* In this function, the hardware should be initialized.
|
||||
* Called from wlanif_input().
|
||||
*
|
||||
* @param netif the already initialized lwip network interface structure
|
||||
* for this wlanif
|
||||
*/
|
||||
static void
|
||||
low_level_init(struct netif *netif)
|
||||
{
|
||||
/* set MAC hardware address length */
|
||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
||||
|
||||
/* set MAC hardware address */
|
||||
|
||||
/* maximum transfer unit */
|
||||
netif->mtu = 1500;
|
||||
|
||||
/* device capabilities */
|
||||
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
|
||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
||||
|
||||
#if ESP_LWIP
|
||||
#if LWIP_IGMP
|
||||
netif->flags |= NETIF_FLAG_IGMP;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ESP_IPV6
|
||||
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
||||
netif->flags |= NETIF_FLAG_MLD6;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
err_t set_wifi_netif(int wifi_inx, void* netif)
|
||||
{
|
||||
if (wifi_inx < 2) {
|
||||
s_wifi_netifs[wifi_inx] = netif;
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_ARG;
|
||||
}
|
||||
|
||||
|
||||
static void wifi_pbuf_free(struct pbuf *p)
|
||||
{
|
||||
wifi_custom_pbuf_t* wifi_pbuf = (wifi_custom_pbuf_t*)p;
|
||||
if (wifi_pbuf) {
|
||||
esp_wifi_internal_free_rx_buffer(wifi_pbuf->l2_buf);
|
||||
}
|
||||
mem_free(wifi_pbuf);
|
||||
}
|
||||
|
||||
static inline struct pbuf* wifi_pbuf_allocate(struct netif *netif, void *buffer, size_t len, void *l2_buff)
|
||||
{
|
||||
struct pbuf *p;
|
||||
|
||||
wifi_custom_pbuf_t* esp_pbuf = mem_malloc(sizeof(wifi_custom_pbuf_t));
|
||||
|
||||
if (esp_pbuf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
esp_pbuf->p.custom_free_function = wifi_pbuf_free;
|
||||
esp_pbuf->l2_buf = l2_buff;
|
||||
p = pbuf_alloced_custom(PBUF_RAW, len, PBUF_REF, &esp_pbuf->p, buffer, len);
|
||||
if (p == NULL) {
|
||||
mem_free(esp_pbuf);
|
||||
return NULL;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
esp_err_t wifi_rxcb_sta(void *buffer, uint16_t len, void *l2_buff)
|
||||
{
|
||||
struct netif * netif = s_wifi_netifs[0];
|
||||
struct pbuf *p;
|
||||
|
||||
if(unlikely(!buffer || !netif_is_up(netif))) {
|
||||
if (l2_buff) {
|
||||
esp_wifi_internal_free_rx_buffer(l2_buff);
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
p = wifi_pbuf_allocate(netif, buffer, len, l2_buff);
|
||||
if (p == NULL) {
|
||||
esp_wifi_internal_free_rx_buffer(l2_buff);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* full packet send to tcpip_thread to process */
|
||||
if (unlikely(netif->input(p, netif) != ERR_OK)) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("wlanif_input: IP input error\n"));
|
||||
pbuf_free(p);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t wifi_rxcb_ap(void *buffer, uint16_t len, void *l2_buff)
|
||||
{
|
||||
struct netif * netif = s_wifi_netifs[1];
|
||||
struct pbuf *p;
|
||||
|
||||
if(unlikely(!buffer || !netif_is_up(netif))) {
|
||||
if (l2_buff) {
|
||||
esp_wifi_internal_free_rx_buffer(l2_buff);
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
p = wifi_pbuf_allocate(netif, buffer, len, l2_buff);
|
||||
if (p == NULL) {
|
||||
esp_wifi_internal_free_rx_buffer(l2_buff);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* full packet send to tcpip_thread to process */
|
||||
if (unlikely(netif->input(p, netif) != ERR_OK)) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("wlanif_input: IP input error\n"));
|
||||
pbuf_free(p);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
/**
|
||||
* This function should be called when a packet is ready to be read
|
||||
* from the interface. It uses the function low_level_input() that
|
||||
* should handle the actual reception of bytes from the network
|
||||
* interface. Then the type of the received packet is determined and
|
||||
* the appropriate input function is called.
|
||||
*
|
||||
* @param h lwip network interface structure (struct netif) for this ethernetif
|
||||
* @param buffer wlan buffer
|
||||
* @param len length of buffer
|
||||
* @param l2_buff wlan's L2 buffer pointer
|
||||
*/
|
||||
void
|
||||
wlanif_input(void *h, void *buffer, size_t len, void* l2_buff)
|
||||
{
|
||||
struct netif * netif = h;
|
||||
esp_netif_t *esp_netif = esp_netif_get_handle_from_netif_impl(netif);
|
||||
struct pbuf *p;
|
||||
|
||||
if(unlikely(!buffer || !netif_is_up(netif))) {
|
||||
if (l2_buff) {
|
||||
esp_netif_free_rx_buffer(esp_netif, l2_buff);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LWIP_L2_TO_L3_COPY
|
||||
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
|
||||
if (p == NULL) {
|
||||
esp_netif_free_rx_buffer(esp_netif, l2_buff);
|
||||
return;
|
||||
}
|
||||
memcpy(p->payload, buffer, len);
|
||||
esp_netif_free_rx_buffer(esp_netif, l2_buff);
|
||||
#else
|
||||
p = esp_pbuf_allocate(esp_netif, buffer, len, l2_buff);
|
||||
if (p == NULL) {
|
||||
esp_netif_free_rx_buffer(esp_netif, l2_buff);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* full packet send to tcpip_thread to process */
|
||||
if (unlikely(netif->input(p, netif) != ERR_OK)) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("wlanif_input: IP input error\n"));
|
||||
pbuf_free(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function should do the actual transmission of the packet. The packet is
|
||||
* contained in the pbuf that is passed to the function. This pbuf
|
||||
* might be chained.
|
||||
*
|
||||
* @param netif the lwip network interface structure for this wlanif
|
||||
* @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
|
||||
* @return ERR_OK if the packet could be sent
|
||||
* an err_t value if the packet couldn't be sent
|
||||
*
|
||||
* @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
|
||||
* strange results. You might consider waiting for space in the DMA queue
|
||||
* to become available since the stack doesn't retry to send a packet
|
||||
* dropped because of memory failure (except for the TCP timers).
|
||||
*/
|
||||
static err_t
|
||||
sta_output(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
struct pbuf *q = p;
|
||||
esp_err_t ret;
|
||||
|
||||
if(q->next == NULL) {
|
||||
ret = esp_wifi_internal_tx(WIFI_IF_STA, q->payload, q->len);
|
||||
|
||||
} else {
|
||||
LWIP_DEBUGF(PBUF_DEBUG, ("low_level_output: pbuf is a list, application may has bug"));
|
||||
q = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM);
|
||||
if (q != NULL) {
|
||||
pbuf_copy(q, p);
|
||||
} else {
|
||||
return ERR_MEM;
|
||||
}
|
||||
ret = esp_wifi_internal_tx(WIFI_IF_STA, q->payload, q->len);
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
return ERR_OK;
|
||||
} else if (ret == ESP_ERR_NO_MEM) {
|
||||
return ERR_MEM;
|
||||
} else if (ret == ESP_ERR_INVALID_ARG) {
|
||||
return ERR_ARG;
|
||||
} else {
|
||||
return ERR_IF;
|
||||
}
|
||||
}
|
||||
|
||||
static err_t
|
||||
ap_output(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
struct pbuf *q = p;
|
||||
esp_err_t ret;
|
||||
|
||||
if(q->next == NULL) {
|
||||
ret = esp_wifi_internal_tx(WIFI_IF_AP, q->payload, q->len);
|
||||
|
||||
} else {
|
||||
LWIP_DEBUGF(PBUF_DEBUG, ("low_level_output: pbuf is a list, application may has bug"));
|
||||
q = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM);
|
||||
if (q != NULL) {
|
||||
pbuf_copy(q, p);
|
||||
} else {
|
||||
return ERR_MEM;
|
||||
}
|
||||
ret = esp_wifi_internal_tx(WIFI_IF_AP, q->payload, q->len);
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
return ERR_OK;
|
||||
} else if (ret == ESP_ERR_NO_MEM) {
|
||||
return ERR_MEM;
|
||||
} else if (ret == ESP_ERR_INVALID_ARG) {
|
||||
return ERR_ARG;
|
||||
} else {
|
||||
return ERR_IF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called at the beginning of the program to set up the
|
||||
* network interface. It calls the function low_level_init() to do the
|
||||
* actual setup of the hardware.
|
||||
*
|
||||
* This function should be passed as a parameter to netif_add().
|
||||
*
|
||||
* @param netif the lwip network interface structure for this wlanif
|
||||
* @return ERR_OK if the loopif is initialized
|
||||
* ERR_MEM if private data couldn't be allocated
|
||||
* any other err_t on error
|
||||
*/
|
||||
err_t
|
||||
wlanif_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
/* Initialize interface hostname */
|
||||
|
||||
#if ESP_LWIP
|
||||
if (esp_netif_get_hostname(esp_netif_get_handle_from_netif_impl(netif), &netif->hostname) != ESP_OK) {
|
||||
netif->hostname = CONFIG_LWIP_LOCAL_HOSTNAME;
|
||||
}
|
||||
#else
|
||||
netif->hostname = "lwip";
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
/*
|
||||
* Initialize the snmp variables and counters inside the struct netif.
|
||||
* The last argument should be replaced with your link speed, in units
|
||||
* of bits per second.
|
||||
*/
|
||||
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 100);
|
||||
|
||||
/* We directly use etharp_output() here to save a function call.
|
||||
* You can instead declare your own function an call etharp_output()
|
||||
* from it if you have to do some checks before sending (e.g. if link
|
||||
* is available...) */
|
||||
netif->output = etharp_output;
|
||||
#if LWIP_IPV6
|
||||
netif->output_ip6 = ethip6_output;
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
/* initialize the hardware */
|
||||
low_level_init(netif);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
err_t wlanif_init_sta(struct netif *netif) {
|
||||
netif->name[0] = 's';
|
||||
netif->name[1] = 't';
|
||||
netif->linkoutput = sta_output;
|
||||
return wlanif_init(netif);
|
||||
}
|
||||
|
||||
err_t wlanif_init_ap(struct netif *netif) {
|
||||
netif->name[0] = 'a';
|
||||
netif->name[1] = 'p';
|
||||
netif->linkoutput = ap_output;
|
||||
return wlanif_init(netif);
|
||||
}
|
@ -119,9 +119,6 @@ idf_component_get_property(mbedtls_dir mbedtls COMPONENT_DIR)
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC mocks)
|
||||
|
||||
else()
|
||||
idf_component_get_property(http_parser_lib http_parser COMPONENT_LIB)
|
||||
idf_component_get_property(tcp_transport_lib tcp_transport COMPONENT_LIB)
|
||||
idf_component_get_property(lwip_lib lwip COMPONENT_LIB)
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC ${http_parser_lib} ${tcp_transport_lib})
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE ${lwip_lib})
|
||||
idf_component_optional_requires(PUBLIC esp_event tcp_transport)
|
||||
idf_component_optional_requires(PRIVATE http_parser)
|
||||
endif()
|
||||
|
@ -1,2 +1,2 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth)
|
||||
PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth esp_netif)
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) CO 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: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -23,6 +15,31 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default configuration reference of OT esp-netif
|
||||
*/
|
||||
#define ESP_NETIF_INHERENT_DEFAULT_OPENTHREAD() \
|
||||
{ \
|
||||
.flags = 0, \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
||||
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
|
||||
.get_ip_event = 0, \
|
||||
.lost_ip_event = 0, \
|
||||
.if_key = "OT_DEF", \
|
||||
.if_desc = "openthread", \
|
||||
.route_prio = 15 \
|
||||
};
|
||||
|
||||
#define ESP_NETIF_DEFAULT_OPENTHREAD() \
|
||||
{ \
|
||||
.base = &g_esp_netif_inherent_openthread_config, \
|
||||
.driver = NULL, \
|
||||
.stack = &g_esp_netif_netstack_default_openthread, \
|
||||
}
|
||||
|
||||
extern const esp_netif_netstack_config_t g_esp_netif_netstack_default_openthread;
|
||||
extern const esp_netif_inherent_config_t g_esp_netif_inherent_openthread_config;
|
||||
|
||||
/**
|
||||
* @brief This function initializes the OpenThread network interface glue.
|
||||
*
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a63a3ae3f371955064c28db2995fac59e7cffb7e
|
||||
Subproject commit fc81212ff83f263b64c95c9e9fb70fd41ac1dc7d
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES cmock test_utils spiffs)
|
||||
PRIV_REQUIRES cmock test_utils spiffs vfs)
|
||||
|
@ -22,4 +22,4 @@ idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS include
|
||||
PRIV_INCLUDE_DIRS src proto-c ../protocomm/proto-c
|
||||
REQUIRES lwip protocomm
|
||||
PRIV_REQUIRES protobuf-c bt json esp_timer)
|
||||
PRIV_REQUIRES protobuf-c bt json esp_timer esp_wifi)
|
||||
|
@ -196,7 +196,7 @@ idf_component_register(SRCS "${srcs}" "${esp_srcs}" "${tls_src}" "${roaming_src}
|
||||
"${crypto_src}" "${mbo_src}" "${dpp_src}" "${wps_registrar_src}"
|
||||
INCLUDE_DIRS include port/include esp_supplicant/include
|
||||
PRIV_INCLUDE_DIRS src src/utils esp_supplicant/src src/crypto
|
||||
PRIV_REQUIRES mbedtls esp_timer)
|
||||
PRIV_REQUIRES mbedtls esp_timer esp_wifi)
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-strict-aliasing -Wno-write-strings -Werror)
|
||||
target_compile_definitions(${COMPONENT_LIB} PRIVATE
|
||||
|
@ -1,7 +1,7 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "." "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
PRIV_INCLUDE_DIRS "../src" "../esp_supplicant/src"
|
||||
PRIV_REQUIRES cmock esp_common test_utils wpa_supplicant mbedtls)
|
||||
PRIV_REQUIRES cmock esp_common test_utils wpa_supplicant mbedtls esp_wifi esp_event)
|
||||
|
||||
idf_component_get_property(esp_supplicant_dir wpa_supplicant COMPONENT_DIR)
|
||||
|
||||
|
@ -14,7 +14,7 @@ endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "include"
|
||||
PRIV_REQUIRES esp_netif driver)
|
||||
PRIV_REQUIRES esp_netif driver esp_wifi vfs)
|
||||
|
||||
if(CONFIG_EXAMPLE_PROVIDE_WIFI_CONSOLE_CMD)
|
||||
idf_component_optional_requires(PRIVATE console)
|
||||
|
@ -6,4 +6,4 @@ set(sources src/msc_scsi_bot.c
|
||||
idf_component_register( SRCS ${sources}
|
||||
INCLUDE_DIRS include
|
||||
PRIV_INCLUDE_DIRS private_include
|
||||
REQUIRES usb fatfs )
|
||||
REQUIRES usb fatfs vfs )
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS "msc_example_main.c"
|
||||
INCLUDE_DIRS ""
|
||||
REQUIRES usb msc fatfs)
|
||||
REQUIRES usb msc fatfs vfs)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <sys/param.h>
|
||||
#include "esp_netif.h"
|
||||
#include "esp_eth.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "protocol_examples_common.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include <esp_https_server.h>
|
||||
|
@ -62,6 +62,7 @@ examples_and_unit_tests:
|
||||
lwip_component:
|
||||
include:
|
||||
- 'components/lwip/**'
|
||||
- 'components/esp_netif/lwip/**'
|
||||
allowed_licenses:
|
||||
- Apache-2.0
|
||||
- BSD-3-Clause
|
||||
|
@ -461,8 +461,6 @@ 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_netif/include/esp_netif_slip.h
|
||||
components/esp_netif/loopback/esp_netif_loopback.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
|
||||
components/esp_netif/test/test_esp_netif.c
|
||||
@ -683,7 +681,6 @@ components/esp_wifi/include/esp_mesh_internal.h
|
||||
components/esp_wifi/include/esp_private/esp_wifi_types_private.h
|
||||
components/esp_wifi/include/esp_private/wifi_types.h
|
||||
components/esp_wifi/include/esp_smartconfig.h
|
||||
components/esp_wifi/include/esp_wifi_netif.h
|
||||
components/esp_wifi/include/smartconfig_ack.h
|
||||
components/esp_wifi/src/lib_printf.c
|
||||
components/esp_wifi/src/mesh_event.c
|
||||
@ -882,7 +879,6 @@ components/lwip/port/esp32/include/netinet/in.h
|
||||
components/lwip/port/esp32/include/netinet/tcp.h
|
||||
components/lwip/port/esp32/include/sntp/sntp_get_set_time.h
|
||||
components/lwip/port/esp32/include/sys/socket.h
|
||||
components/lwip/port/esp32/netif/ethernetif.c
|
||||
components/lwip/port/esp32/no_vfs_syscalls.c
|
||||
components/lwip/test_afl_host/dhcp_di.h
|
||||
components/lwip/test_afl_host/dhcpserver_di.h
|
||||
@ -966,7 +962,6 @@ components/nvs_flash/test_nvs_host/test_nvs_partition.cpp
|
||||
components/nvs_flash/test_nvs_host/test_nvs_storage.cpp
|
||||
components/openthread/include/esp_openthread.h
|
||||
components/openthread/include/esp_openthread_lock.h
|
||||
components/openthread/include/esp_openthread_netif_glue.h
|
||||
components/protocomm/include/transports/protocomm_console.h
|
||||
components/protocomm/include/transports/protocomm_httpd.h
|
||||
components/protocomm/proto-c/constants.pb-c.c
|
||||
|
Loading…
Reference in New Issue
Block a user