1 /* 2 * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef _ESP_NETIF_DEFAULTS_H 8 #define _ESP_NETIF_DEFAULTS_H 9 10 #ifndef __ZEPHYR__ 11 #include "esp_compiler.h" 12 #endif 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 // 19 // Macros to assemble master configs with partial configs from netif, stack and driver 20 // 21 22 #define ESP_NETIF_INHERENT_DEFAULT_WIFI_STA() \ 23 { \ 24 .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \ 25 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 26 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 27 .get_ip_event = IP_EVENT_STA_GOT_IP, \ 28 .lost_ip_event = IP_EVENT_STA_LOST_IP, \ 29 .if_key = "WIFI_STA_DEF", \ 30 .if_desc = "sta", \ 31 .route_prio = 100 \ 32 } \ 33 34 #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT 35 #define ESP_NETIF_INHERENT_DEFAULT_WIFI_AP() \ 36 { \ 37 .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP), \ 38 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 39 .ip_info = &_g_esp_netif_soft_ap_ip, \ 40 .get_ip_event = 0, \ 41 .lost_ip_event = 0, \ 42 .if_key = "WIFI_AP_DEF", \ 43 .if_desc = "ap", \ 44 .route_prio = 10 \ 45 }; 46 #endif 47 48 #define ESP_NETIF_INHERENT_DEFAULT_ETH() \ 49 { \ 50 .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \ 51 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 52 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 53 .get_ip_event = IP_EVENT_ETH_GOT_IP, \ 54 .lost_ip_event = IP_EVENT_ETH_LOST_IP, \ 55 .if_key = "ETH_DEF", \ 56 .if_desc = "eth", \ 57 .route_prio = 50 \ 58 }; 59 60 #define ESP_NETIF_INHERENT_DEFAULT_PPP() \ 61 { \ 62 .flags = ESP_NETIF_FLAG_IS_PPP, \ 63 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 64 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 65 .get_ip_event = IP_EVENT_PPP_GOT_IP, \ 66 .lost_ip_event = IP_EVENT_PPP_LOST_IP, \ 67 .if_key = "PPP_DEF", \ 68 .if_desc = "ppp", \ 69 .route_prio = 20 \ 70 }; 71 72 #define ESP_NETIF_INHERENT_DEFAULT_OPENTHREAD() \ 73 { \ 74 .flags = 0, \ 75 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 76 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 77 .get_ip_event = 0, \ 78 .lost_ip_event = 0, \ 79 .if_key = "OT_DEF", \ 80 .if_desc = "openthread", \ 81 .route_prio = 15 \ 82 }; 83 84 #define ESP_NETIF_INHERENT_DEFAULT_SLIP() \ 85 { \ 86 .flags = ESP_NETIF_FLAG_IS_SLIP, \ 87 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 88 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 89 .get_ip_event = 0, \ 90 .lost_ip_event = 0, \ 91 .if_key = "SLP_DEF", \ 92 .if_desc = "slip", \ 93 .route_prio = 16 \ 94 }; 95 96 97 /** 98 * @brief Default configuration reference of ethernet interface 99 */ 100 #define ESP_NETIF_DEFAULT_ETH() \ 101 { \ 102 .base = ESP_NETIF_BASE_DEFAULT_ETH, \ 103 .driver = NULL, \ 104 .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH, \ 105 } 106 107 #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT 108 /** 109 * @brief Default configuration reference of WIFI AP 110 */ 111 #define ESP_NETIF_DEFAULT_WIFI_AP() \ 112 { \ 113 .base = ESP_NETIF_BASE_DEFAULT_WIFI_AP, \ 114 .driver = NULL, \ 115 .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP, \ 116 } 117 #endif 118 119 /** 120 * @brief Default configuration reference of WIFI STA 121 */ 122 #define ESP_NETIF_DEFAULT_WIFI_STA() \ 123 { \ 124 .base = ESP_NETIF_BASE_DEFAULT_WIFI_STA, \ 125 .driver = NULL, \ 126 .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA, \ 127 } 128 129 /** 130 * @brief Default configuration reference of PPP client 131 */ 132 #define ESP_NETIF_DEFAULT_PPP() \ 133 { \ 134 .base = ESP_NETIF_BASE_DEFAULT_PPP, \ 135 .driver = NULL, \ 136 .stack = ESP_NETIF_NETSTACK_DEFAULT_PPP, \ 137 } 138 139 /** 140 * @brief Default configuration reference of SLIP client 141 */ 142 #define ESP_NETIF_DEFAULT_SLIP() \ 143 { \ 144 .base = ESP_NETIF_BASE_DEFAULT_SLIP, \ 145 .driver = NULL, \ 146 .stack = ESP_NETIF_NETSTACK_DEFAULT_SLIP, \ 147 } 148 149 150 /** 151 * @brief Default base config (esp-netif inherent) of WIFI STA 152 */ 153 #define ESP_NETIF_BASE_DEFAULT_WIFI_STA &_g_esp_netif_inherent_sta_config 154 155 #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT 156 /** 157 * @brief Default base config (esp-netif inherent) of WIFI AP 158 */ 159 #define ESP_NETIF_BASE_DEFAULT_WIFI_AP &_g_esp_netif_inherent_ap_config 160 #endif 161 162 /** 163 * @brief Default base config (esp-netif inherent) of ethernet interface 164 */ 165 #define ESP_NETIF_BASE_DEFAULT_ETH &_g_esp_netif_inherent_eth_config 166 167 /** 168 * @brief Default base config (esp-netif inherent) of ppp interface 169 */ 170 #define ESP_NETIF_BASE_DEFAULT_PPP &_g_esp_netif_inherent_ppp_config 171 172 /** 173 * @brief Default base config (esp-netif inherent) of slip interface 174 */ 175 #define ESP_NETIF_BASE_DEFAULT_SLIP &_g_esp_netif_inherent_slip_config 176 177 178 #define ESP_NETIF_NETSTACK_DEFAULT_ETH _g_esp_netif_netstack_default_eth 179 #define ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA _g_esp_netif_netstack_default_wifi_sta 180 #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT 181 #define ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP _g_esp_netif_netstack_default_wifi_ap 182 #endif 183 #define ESP_NETIF_NETSTACK_DEFAULT_PPP _g_esp_netif_netstack_default_ppp 184 #define ESP_NETIF_NETSTACK_DEFAULT_SLIP _g_esp_netif_netstack_default_slip 185 #define ESP_NETIF_NETSTACK_DEFAULT_OPENTHREAD _g_esp_netif_netstack_default_openthread 186 187 // 188 // Include default network stacks configs 189 // - Network stack configurations are provided in a specific network stack 190 // implementation that is invisible to user API 191 // - Here referenced only as opaque pointers 192 // 193 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth; 194 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta; 195 #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT 196 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap; 197 #endif 198 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp; 199 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_slip; 200 201 // 202 // Include default common configs inherent to esp-netif 203 // - These inherent configs are defined in esp_netif_defaults.c and describe 204 // common behavioural patterns for common interfaces such as STA, AP, ETH, PPP 205 // 206 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config; 207 #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT 208 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config; 209 #endif 210 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config; 211 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config; 212 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_slip_config; 213 214 #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT 215 extern const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip; 216 #endif 217 218 #if CONFIG_OPENTHREAD_ENABLED 219 /** 220 * @brief Default configuration reference of SLIP client 221 */ 222 #define ESP_NETIF_DEFAULT_OPENTHREAD() \ 223 { \ 224 .base = ESP_NETIF_BASE_DEFAULT_OPENTHREAD, \ 225 .driver = NULL, \ 226 .stack = ESP_NETIF_NETSTACK_DEFAULT_OPENTHREAD, \ 227 } 228 229 /** 230 * @brief Default base config (esp-netif inherent) of openthread interface 231 */ 232 #define ESP_NETIF_BASE_DEFAULT_OPENTHREAD &_g_esp_netif_inherent_openthread_config 233 234 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_openthread; 235 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_openthread_config; 236 237 #endif // CONFIG_OPENTHREAD_ENABLED 238 239 #ifdef __cplusplus 240 } 241 #endif 242 243 #endif //_ESP_NETIF_DEFAULTS_H 244