1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef _ESP_NETIF_DEFAULTS_H 16 #define _ESP_NETIF_DEFAULTS_H 17 18 #include "esp_compiler.h" 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 // 25 // Macros to assemble master configs with partial configs from netif, stack and driver 26 // 27 28 #define ESP_NETIF_INHERENT_DEFAULT_WIFI_STA() \ 29 { \ 30 .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \ 31 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 32 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 33 .get_ip_event = IP_EVENT_STA_GOT_IP, \ 34 .lost_ip_event = IP_EVENT_STA_LOST_IP, \ 35 .if_key = "WIFI_STA_DEF", \ 36 .if_desc = "sta", \ 37 .route_prio = 100 \ 38 } \ 39 40 #define ESP_NETIF_INHERENT_DEFAULT_WIFI_AP() \ 41 { \ 42 .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP), \ 43 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 44 .ip_info = &_g_esp_netif_soft_ap_ip, \ 45 .get_ip_event = 0, \ 46 .lost_ip_event = 0, \ 47 .if_key = "WIFI_AP_DEF", \ 48 .if_desc = "ap", \ 49 .route_prio = 10 \ 50 }; 51 52 #define ESP_NETIF_INHERENT_DEFAULT_ETH() \ 53 { \ 54 .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \ 55 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 56 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 57 .get_ip_event = IP_EVENT_ETH_GOT_IP, \ 58 .lost_ip_event = 0, \ 59 .if_key = "ETH_DEF", \ 60 .if_desc = "eth", \ 61 .route_prio = 50 \ 62 }; 63 64 #define ESP_NETIF_INHERENT_DEFAULT_PPP() \ 65 { \ 66 .flags = ESP_NETIF_FLAG_IS_PPP, \ 67 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 68 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 69 .get_ip_event = IP_EVENT_PPP_GOT_IP, \ 70 .lost_ip_event = IP_EVENT_PPP_LOST_IP, \ 71 .if_key = "PPP_DEF", \ 72 .if_desc = "ppp", \ 73 .route_prio = 20 \ 74 }; 75 76 #define ESP_NETIF_INHERENT_DEFAULT_SLIP() \ 77 { \ 78 .flags = ESP_NETIF_FLAG_IS_SLIP, \ 79 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \ 80 ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \ 81 .get_ip_event = 0, \ 82 .lost_ip_event = 0, \ 83 .if_key = "SLP_DEF", \ 84 .if_desc = "slip", \ 85 .route_prio = 16 \ 86 }; 87 88 /** 89 * @brief Default configuration reference of ethernet interface 90 */ 91 #define ESP_NETIF_DEFAULT_ETH() \ 92 { \ 93 .base = ESP_NETIF_BASE_DEFAULT_ETH, \ 94 .driver = NULL, \ 95 .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH, \ 96 } 97 98 /** 99 * @brief Default configuration reference of WIFI AP 100 */ 101 #define ESP_NETIF_DEFAULT_WIFI_AP() \ 102 { \ 103 .base = ESP_NETIF_BASE_DEFAULT_WIFI_AP, \ 104 .driver = NULL, \ 105 .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP, \ 106 } 107 108 /** 109 * @brief Default configuration reference of WIFI STA 110 */ 111 #define ESP_NETIF_DEFAULT_WIFI_STA() \ 112 { \ 113 .base = ESP_NETIF_BASE_DEFAULT_WIFI_STA, \ 114 .driver = NULL, \ 115 .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA, \ 116 } 117 118 /** 119 * @brief Default configuration reference of PPP client 120 */ 121 #define ESP_NETIF_DEFAULT_PPP() \ 122 { \ 123 .base = ESP_NETIF_BASE_DEFAULT_PPP, \ 124 .driver = NULL, \ 125 .stack = ESP_NETIF_NETSTACK_DEFAULT_PPP, \ 126 } 127 128 /** 129 * @brief Default configuration reference of SLIP client 130 */ 131 #define ESP_NETIF_DEFAULT_SLIP() \ 132 { \ 133 .base = ESP_NETIF_BASE_DEFAULT_SLIP, \ 134 .driver = NULL, \ 135 .stack = ESP_NETIF_NETSTACK_DEFAULT_SLIP, \ 136 } 137 138 139 /** 140 * @brief Default base config (esp-netif inherent) of WIFI STA 141 */ 142 #define ESP_NETIF_BASE_DEFAULT_WIFI_STA &_g_esp_netif_inherent_sta_config 143 144 /** 145 * @brief Default base config (esp-netif inherent) of WIFI AP 146 */ 147 #define ESP_NETIF_BASE_DEFAULT_WIFI_AP &_g_esp_netif_inherent_ap_config 148 149 /** 150 * @brief Default base config (esp-netif inherent) of ethernet interface 151 */ 152 #define ESP_NETIF_BASE_DEFAULT_ETH &_g_esp_netif_inherent_eth_config 153 154 /** 155 * @brief Default base config (esp-netif inherent) of ppp interface 156 */ 157 #define ESP_NETIF_BASE_DEFAULT_PPP &_g_esp_netif_inherent_ppp_config 158 159 /** 160 * @brief Default base config (esp-netif inherent) of slip interface 161 */ 162 #define ESP_NETIF_BASE_DEFAULT_SLIP &_g_esp_netif_inherent_slip_config 163 164 165 166 #define ESP_NETIF_NETSTACK_DEFAULT_ETH _g_esp_netif_netstack_default_eth 167 #define ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA _g_esp_netif_netstack_default_wifi_sta 168 #define ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP _g_esp_netif_netstack_default_wifi_ap 169 #define ESP_NETIF_NETSTACK_DEFAULT_PPP _g_esp_netif_netstack_default_ppp 170 #define ESP_NETIF_NETSTACK_DEFAULT_SLIP _g_esp_netif_netstack_default_slip 171 172 // 173 // Include default network stacks configs 174 // - Network stack configurations are provided in a specific network stack 175 // implementation that is invisible to user API 176 // - Here referenced only as opaque pointers 177 // 178 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth; 179 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta; 180 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap; 181 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp; 182 extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_slip; 183 184 // 185 // Include default common configs inherent to esp-netif 186 // - These inherent configs are defined in esp_netif_defaults.c and describe 187 // common behavioural patterns for common interfaces such as STA, AP, ETH, PPP 188 // 189 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config; 190 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config; 191 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config; 192 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config; 193 extern const esp_netif_inherent_config_t _g_esp_netif_inherent_slip_config; 194 195 extern const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip; 196 197 #ifdef __cplusplus 198 } 199 #endif 200 201 #endif //_ESP_NETIF_DEFAULTS_H 202