2021-04-07 03:04:51 -04:00
|
|
|
/*
|
2020-07-28 21:20:30 -04:00
|
|
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
2021-04-07 03:04:51 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-06-28 10:47:34 -04:00
|
|
|
|
|
|
|
#ifndef _ESP_NETIF_DEFAULTS_H
|
|
|
|
#define _ESP_NETIF_DEFAULTS_H
|
|
|
|
|
2020-02-06 06:28:56 -05:00
|
|
|
#include "esp_compiler.h"
|
2019-11-22 03:40:54 -05:00
|
|
|
|
2020-01-30 06:50:52 -05:00
|
|
|
#ifdef __cplusplus
|
2020-02-06 06:28:56 -05:00
|
|
|
extern "C" {
|
2020-01-30 06:50:52 -05:00
|
|
|
#endif
|
|
|
|
|
2019-06-28 10:47:34 -04:00
|
|
|
//
|
|
|
|
// Macros to assemble master configs with partial configs from netif, stack and driver
|
|
|
|
//
|
|
|
|
|
2022-09-22 08:43:57 -04:00
|
|
|
// If GARP enabled in menuconfig (default), make it also a default config for common netifs
|
2022-09-26 07:22:20 -04:00
|
|
|
#ifdef CONFIG_LWIP_ESP_GRATUITOUS_ARP
|
2022-09-22 08:43:57 -04:00
|
|
|
#define ESP_NETIF_DEFAULT_ARP_FLAGS (ESP_NETIF_FLAG_GARP)
|
|
|
|
#else
|
|
|
|
#define ESP_NETIF_DEFAULT_ARP_FLAGS (0)
|
|
|
|
#endif
|
|
|
|
|
2022-10-03 11:28:01 -04:00
|
|
|
#ifdef CONFIG_LWIP_IPV4
|
|
|
|
#define ESP_NETIF_IPV4_ONLY_FLAGS(flags) (flags)
|
|
|
|
#else
|
|
|
|
#define ESP_NETIF_IPV4_ONLY_FLAGS(flags) (0)
|
|
|
|
#endif
|
|
|
|
|
2020-01-30 06:50:52 -05:00
|
|
|
#define ESP_NETIF_INHERENT_DEFAULT_WIFI_STA() \
|
|
|
|
{ \
|
2022-10-03 11:28:01 -04:00
|
|
|
.flags = (esp_netif_flags_t)(ESP_NETIF_IPV4_ONLY_FLAGS(ESP_NETIF_DHCP_CLIENT) | ESP_NETIF_DEFAULT_ARP_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
|
2020-02-06 06:28:56 -05:00
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
|
2020-01-30 06:50:52 -05:00
|
|
|
.get_ip_event = IP_EVENT_STA_GOT_IP, \
|
|
|
|
.lost_ip_event = IP_EVENT_STA_LOST_IP, \
|
|
|
|
.if_key = "WIFI_STA_DEF", \
|
|
|
|
.if_desc = "sta", \
|
2022-05-06 10:09:24 -04:00
|
|
|
.route_prio = 100, \
|
|
|
|
.bridge_info = NULL \
|
2020-01-30 06:50:52 -05:00
|
|
|
} \
|
|
|
|
|
2021-04-07 03:04:51 -04:00
|
|
|
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
2020-01-30 06:50:52 -05:00
|
|
|
#define ESP_NETIF_INHERENT_DEFAULT_WIFI_AP() \
|
|
|
|
{ \
|
2022-10-03 11:28:01 -04:00
|
|
|
.flags = (esp_netif_flags_t)(ESP_NETIF_IPV4_ONLY_FLAGS(ESP_NETIF_DHCP_SERVER) | ESP_NETIF_FLAG_AUTOUP), \
|
2020-02-06 06:28:56 -05:00
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
2020-01-30 06:50:52 -05:00
|
|
|
.ip_info = &_g_esp_netif_soft_ap_ip, \
|
|
|
|
.get_ip_event = 0, \
|
|
|
|
.lost_ip_event = 0, \
|
|
|
|
.if_key = "WIFI_AP_DEF", \
|
|
|
|
.if_desc = "ap", \
|
2022-05-06 10:09:24 -04:00
|
|
|
.route_prio = 10, \
|
|
|
|
.bridge_info = NULL \
|
2022-10-28 19:57:45 -04:00
|
|
|
}
|
2021-04-07 03:04:51 -04:00
|
|
|
#endif
|
2020-01-30 06:50:52 -05:00
|
|
|
|
|
|
|
#define ESP_NETIF_INHERENT_DEFAULT_ETH() \
|
|
|
|
{ \
|
2022-10-03 11:28:01 -04:00
|
|
|
.flags = (esp_netif_flags_t)(ESP_NETIF_IPV4_ONLY_FLAGS(ESP_NETIF_DHCP_CLIENT) | ESP_NETIF_DEFAULT_ARP_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
|
2020-02-06 06:28:56 -05:00
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
|
2020-01-30 06:50:52 -05:00
|
|
|
.get_ip_event = IP_EVENT_ETH_GOT_IP, \
|
2021-05-06 23:36:13 -04:00
|
|
|
.lost_ip_event = IP_EVENT_ETH_LOST_IP, \
|
2020-01-30 06:50:52 -05:00
|
|
|
.if_key = "ETH_DEF", \
|
|
|
|
.if_desc = "eth", \
|
2022-05-06 10:09:24 -04:00
|
|
|
.route_prio = 50, \
|
|
|
|
.bridge_info = NULL \
|
2022-10-28 19:57:45 -04:00
|
|
|
}
|
2020-01-30 06:50:52 -05:00
|
|
|
|
2022-09-26 07:22:20 -04:00
|
|
|
#ifdef CONFIG_PPP_SUPPORT
|
2020-01-30 06:50:52 -05:00
|
|
|
#define ESP_NETIF_INHERENT_DEFAULT_PPP() \
|
|
|
|
{ \
|
|
|
|
.flags = ESP_NETIF_FLAG_IS_PPP, \
|
2020-02-06 06:28:56 -05:00
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
|
2020-01-30 06:50:52 -05:00
|
|
|
.get_ip_event = IP_EVENT_PPP_GOT_IP, \
|
|
|
|
.lost_ip_event = IP_EVENT_PPP_LOST_IP, \
|
|
|
|
.if_key = "PPP_DEF", \
|
|
|
|
.if_desc = "ppp", \
|
2022-05-06 10:09:24 -04:00
|
|
|
.route_prio = 20, \
|
|
|
|
.bridge_info = NULL \
|
2022-10-28 19:57:45 -04:00
|
|
|
}
|
2022-09-26 07:22:20 -04:00
|
|
|
#endif /* CONFIG_PPP_SUPPORT */
|
2020-05-21 01:55:56 -04:00
|
|
|
|
2021-05-18 23:52:51 -04:00
|
|
|
|
2022-07-22 11:37:47 -04:00
|
|
|
|
2020-01-30 06:50:52 -05:00
|
|
|
|
2022-05-06 10:09:24 -04:00
|
|
|
#define ESP_NETIF_INHERENT_DEFAULT_BR() \
|
|
|
|
{ \
|
2022-09-22 08:43:57 -04:00
|
|
|
.flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_CLIENT | ESP_NETIF_DEFAULT_ARP_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED | ESP_NETIF_FLAG_IS_BRIDGE), \
|
2022-05-06 10:09:24 -04:00
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
|
|
|
|
ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
|
|
|
|
.get_ip_event = IP_EVENT_ETH_GOT_IP, \
|
|
|
|
.lost_ip_event = IP_EVENT_ETH_LOST_IP, \
|
|
|
|
.if_key = "BR", \
|
|
|
|
.if_desc = "br", \
|
|
|
|
.route_prio = 70, \
|
|
|
|
.bridge_info = NULL \
|
2022-10-28 19:57:45 -04:00
|
|
|
}
|
2021-05-18 23:52:51 -04:00
|
|
|
|
2019-06-28 10:47:34 -04:00
|
|
|
/**
|
|
|
|
* @brief Default configuration reference of ethernet interface
|
|
|
|
*/
|
|
|
|
#define ESP_NETIF_DEFAULT_ETH() \
|
|
|
|
{ \
|
|
|
|
.base = ESP_NETIF_BASE_DEFAULT_ETH, \
|
2019-12-18 02:26:44 -05:00
|
|
|
.driver = NULL, \
|
2019-06-28 10:47:34 -04:00
|
|
|
.stack = ESP_NETIF_NETSTACK_DEFAULT_ETH, \
|
|
|
|
}
|
|
|
|
|
2021-04-07 03:04:51 -04:00
|
|
|
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
2019-06-28 10:47:34 -04:00
|
|
|
/**
|
|
|
|
* @brief Default configuration reference of WIFI AP
|
|
|
|
*/
|
|
|
|
#define ESP_NETIF_DEFAULT_WIFI_AP() \
|
2020-01-30 06:50:52 -05:00
|
|
|
{ \
|
2019-06-28 10:47:34 -04:00
|
|
|
.base = ESP_NETIF_BASE_DEFAULT_WIFI_AP, \
|
2019-12-18 02:26:44 -05:00
|
|
|
.driver = NULL, \
|
2019-06-28 10:47:34 -04:00
|
|
|
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP, \
|
|
|
|
}
|
2021-04-07 03:04:51 -04:00
|
|
|
#endif
|
2019-06-28 10:47:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Default configuration reference of WIFI STA
|
|
|
|
*/
|
|
|
|
#define ESP_NETIF_DEFAULT_WIFI_STA() \
|
|
|
|
{ \
|
|
|
|
.base = ESP_NETIF_BASE_DEFAULT_WIFI_STA, \
|
2019-12-18 02:26:44 -05:00
|
|
|
.driver = NULL, \
|
2019-06-28 10:47:34 -04:00
|
|
|
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA, \
|
|
|
|
}
|
2019-11-21 07:23:58 -05:00
|
|
|
|
2022-09-26 07:22:20 -04:00
|
|
|
#ifdef CONFIG_PPP_SUPPORT
|
2019-11-21 07:23:58 -05:00
|
|
|
/**
|
|
|
|
* @brief Default configuration reference of PPP client
|
|
|
|
*/
|
|
|
|
#define ESP_NETIF_DEFAULT_PPP() \
|
|
|
|
{ \
|
|
|
|
.base = ESP_NETIF_BASE_DEFAULT_PPP, \
|
2019-12-18 02:26:44 -05:00
|
|
|
.driver = NULL, \
|
2019-11-21 07:23:58 -05:00
|
|
|
.stack = ESP_NETIF_NETSTACK_DEFAULT_PPP, \
|
|
|
|
}
|
2022-09-26 07:22:20 -04:00
|
|
|
#endif /* CONFIG_PPP_SUPPORT */
|
2020-05-21 01:55:56 -04:00
|
|
|
|
2019-06-28 10:47:34 -04:00
|
|
|
/**
|
|
|
|
* @brief Default base config (esp-netif inherent) of WIFI STA
|
|
|
|
*/
|
|
|
|
#define ESP_NETIF_BASE_DEFAULT_WIFI_STA &_g_esp_netif_inherent_sta_config
|
|
|
|
|
2021-04-07 03:04:51 -04:00
|
|
|
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
2019-06-28 10:47:34 -04:00
|
|
|
/**
|
|
|
|
* @brief Default base config (esp-netif inherent) of WIFI AP
|
|
|
|
*/
|
|
|
|
#define ESP_NETIF_BASE_DEFAULT_WIFI_AP &_g_esp_netif_inherent_ap_config
|
2021-04-07 03:04:51 -04:00
|
|
|
#endif
|
2019-06-28 10:47:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Default base config (esp-netif inherent) of ethernet interface
|
|
|
|
*/
|
|
|
|
#define ESP_NETIF_BASE_DEFAULT_ETH &_g_esp_netif_inherent_eth_config
|
|
|
|
|
2022-09-26 07:22:20 -04:00
|
|
|
#ifdef CONFIG_PPP_SUPPORT
|
2019-11-21 07:23:58 -05:00
|
|
|
/**
|
|
|
|
* @brief Default base config (esp-netif inherent) of ppp interface
|
|
|
|
*/
|
|
|
|
#define ESP_NETIF_BASE_DEFAULT_PPP &_g_esp_netif_inherent_ppp_config
|
2022-09-26 07:22:20 -04:00
|
|
|
#endif
|
2019-11-21 07:23:58 -05:00
|
|
|
|
2020-05-21 01:55:56 -04:00
|
|
|
|
2019-06-28 10:47:34 -04:00
|
|
|
#define ESP_NETIF_NETSTACK_DEFAULT_ETH _g_esp_netif_netstack_default_eth
|
2022-05-06 10:09:24 -04:00
|
|
|
#define ESP_NETIF_NETSTACK_DEFAULT_BR _g_esp_netif_netstack_default_br
|
2019-06-28 10:47:34 -04:00
|
|
|
#define ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA _g_esp_netif_netstack_default_wifi_sta
|
2021-04-07 03:04:51 -04:00
|
|
|
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
2019-06-28 10:47:34 -04:00
|
|
|
#define ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP _g_esp_netif_netstack_default_wifi_ap
|
2021-04-07 03:04:51 -04:00
|
|
|
#endif
|
2022-09-26 07:22:20 -04:00
|
|
|
#ifdef CONFIG_PPP_SUPPORT
|
2019-11-21 07:23:58 -05:00
|
|
|
#define ESP_NETIF_NETSTACK_DEFAULT_PPP _g_esp_netif_netstack_default_ppp
|
2022-09-26 07:22:20 -04:00
|
|
|
#endif
|
2019-11-21 07:23:58 -05:00
|
|
|
|
2019-06-28 10:47:34 -04:00
|
|
|
//
|
|
|
|
// Include default network stacks configs
|
|
|
|
// - Network stack configurations are provided in a specific network stack
|
|
|
|
// implementation that is invisible to user API
|
|
|
|
// - Here referenced only as opaque pointers
|
|
|
|
//
|
|
|
|
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth;
|
2022-05-06 10:09:24 -04:00
|
|
|
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_br;
|
2019-06-28 10:47:34 -04:00
|
|
|
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta;
|
2021-04-07 03:04:51 -04:00
|
|
|
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
2019-06-28 10:47:34 -04:00
|
|
|
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap;
|
2021-04-07 03:04:51 -04:00
|
|
|
#endif
|
2022-09-26 07:22:20 -04:00
|
|
|
#ifdef CONFIG_PPP_SUPPORT
|
2019-11-21 07:23:58 -05:00
|
|
|
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp;
|
2022-09-26 07:22:20 -04:00
|
|
|
#endif
|
2019-06-28 10:47:34 -04:00
|
|
|
//
|
|
|
|
// Include default common configs inherent to esp-netif
|
|
|
|
// - These inherent configs are defined in esp_netif_defaults.c and describe
|
2020-02-06 06:28:56 -05:00
|
|
|
// common behavioural patterns for common interfaces such as STA, AP, ETH, PPP
|
2019-06-28 10:47:34 -04:00
|
|
|
//
|
|
|
|
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config;
|
2021-04-07 03:04:51 -04:00
|
|
|
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
2019-06-28 10:47:34 -04:00
|
|
|
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config;
|
2021-04-07 03:04:51 -04:00
|
|
|
#endif
|
2019-06-28 10:47:34 -04:00
|
|
|
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config;
|
2022-09-26 07:22:20 -04:00
|
|
|
#ifdef CONFIG_PPP_SUPPORT
|
2019-11-21 07:23:58 -05:00
|
|
|
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config;
|
2022-09-26 07:22:20 -04:00
|
|
|
#endif
|
2021-04-07 03:04:51 -04:00
|
|
|
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|
2020-01-30 06:50:52 -05:00
|
|
|
extern const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip;
|
2021-04-07 03:04:51 -04:00
|
|
|
#endif
|
2020-01-30 06:50:52 -05:00
|
|
|
|
2019-11-22 03:40:54 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-06-28 10:47:34 -04:00
|
|
|
#endif //_ESP_NETIF_DEFAULTS_H
|