1 // Copyright 2015-2019 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 #ifndef _ESP_NETIF_SUPPRESS_LEGACY_WARNING_ 15 #warning "This header is deprecated, please use new network related API in esp_netif.h" 16 #include "esp_netif.h" 17 #endif 18 19 #ifndef _TCPIP_ADAPTER_H_ 20 #define _TCPIP_ADAPTER_H_ 21 22 #include "esp_netif.h" 23 24 #include "tcpip_adapter_types.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /** 31 * @brief tcpip adapter legacy init. It is used only to set the compatibility mode of esp-netif, which 32 * will enable backward compatibility of esp-netif. 33 */ 34 void tcpip_adapter_init(void) __attribute__ ((deprecated)); 35 36 /** 37 * @brief Compatiblity mode: convert the esp-netif handle to tcpip_adapter legacy interface enum 38 * 39 * @param esp_netif 40 * 41 * @return corresponding interface if valid or known esp_netif provided, TCPIP_ADAPTER_IF_MAX otherwise 42 */ 43 tcpip_adapter_if_t tcpip_adapter_if_from_esp_netif(esp_netif_t *esp_netif); 44 45 /** 46 * @brief Translates to esp_netif_get_ip_info 47 * 48 * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif 49 * @param ip_info See esp_netif_get_ip_info 50 * @return See esp_netif_get_ip_info 51 */ 52 esp_err_t tcpip_adapter_get_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info); 53 54 #if CONFIG_LWIP_IPV6 55 /** 56 * @brief Translates to esp_netif_get_ip6_linklocal 57 * 58 * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif 59 * @param if_ip6 See esp_netif_get_ip6_linklocal 60 * @return See esp_netif_get_ip6_linklocal 61 */ 62 esp_err_t tcpip_adapter_get_ip6_linklocal(tcpip_adapter_if_t tcpip_if, ip6_addr_t *if_ip6); 63 64 /** 65 * @brief Translates to esp_netif_get_ip6_global 66 * 67 * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif 68 * @param if_ip6 See esp_netif_get_ip6_global 69 * @return See esp_netif_get_ip6_global 70 */ 71 esp_err_t tcpip_adapter_get_ip6_global(tcpip_adapter_if_t tcpip_if, ip6_addr_t *if_ip6); 72 #endif 73 74 /** 75 * @brief`Translates to esp_netif_dhcpc_get_status 76 * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif 77 * @param status 78 * @return See esp_netif_dhcpc_get_status 79 */ 80 esp_err_t tcpip_adapter_dhcpc_get_status(tcpip_adapter_if_t tcpip_if, tcpip_adapter_dhcp_status_t *status); 81 82 /** 83 * @brief Translates to esp_netif_is_netif_up 84 * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif 85 * @return see esp_netif_is_netif_up 86 */ 87 bool tcpip_adapter_is_netif_up(tcpip_adapter_if_t tcpip_if); 88 89 /** 90 * @brief Translates to esp_netif_get_netif 91 * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif 92 * @param netif 93 * @return see esp_netif_get_netif 94 */ 95 esp_err_t tcpip_adapter_get_netif(tcpip_adapter_if_t tcpip_if, void ** netif); 96 97 #if CONFIG_LWIP_IPV6 98 /** 99 * @brief Translates to esp_netif_create_ip6_linklocal 100 * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif 101 * @return see esp_netif_create_ip6_linklocal 102 */ 103 esp_err_t tcpip_adapter_create_ip6_linklocal(tcpip_adapter_if_t tcpip_if); 104 #endif 105 106 /** 107 * @brief Compatible version of setting ethernet default handlers 108 * @note Compatible version of wifi handlers are provided in a separate header, 109 * as this used to be called privately from wifi_init() 110 * @return ESP_OK on success 111 */ 112 esp_err_t tcpip_adapter_set_default_eth_handlers(void); 113 114 /** 115 * @brief Compatible version of network stack input function. Translates to esp_netif_receive() 116 */ 117 esp_err_t tcpip_adapter_eth_input(void *buffer, uint16_t len, void *eb); 118 119 /** 120 * @brief Compatible version of network stack input function. Translates to esp_netif_receive() 121 */ 122 esp_err_t tcpip_adapter_sta_input(void *buffer, uint16_t len, void *eb); 123 124 /** 125 * @brief Compatible version of network stack input function. Translates to esp_netif_receive() 126 */ 127 esp_err_t tcpip_adapter_ap_input(void *buffer, uint16_t len, void *eb); 128 129 /** 130 * @brief Compatible version of former tcpip_adapter API to clear default WIFI handlers 131 * @return ESP_OK on success 132 */ 133 esp_err_t tcpip_adapter_clear_default_wifi_handlers(void); 134 135 /** 136 * @brief Compatible version of former tcpip_adapter API to clear default ethernet handlers 137 * @return ESP_OK on success 138 */ 139 esp_err_t tcpip_adapter_clear_default_eth_handlers(void); 140 141 /** 142 * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcps_stop 143 */ 144 esp_err_t tcpip_adapter_dhcps_stop(tcpip_adapter_if_t tcpip_if); 145 146 /** 147 * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcpc_stop 148 */ 149 esp_err_t tcpip_adapter_dhcpc_stop(tcpip_adapter_if_t tcpip_if); 150 151 /** 152 * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcps_start 153 */ 154 esp_err_t tcpip_adapter_dhcps_start(tcpip_adapter_if_t tcpip_if); 155 156 /** 157 * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcpc_start 158 */ 159 esp_err_t tcpip_adapter_dhcpc_start(tcpip_adapter_if_t tcpip_if); 160 161 /** 162 * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcps_get_status 163 */ 164 esp_err_t tcpip_adapter_dhcps_get_status(tcpip_adapter_if_t tcpip_if, tcpip_adapter_dhcp_status_t *status); 165 166 /** 167 * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcps_option 168 */ 169 esp_err_t tcpip_adapter_dhcps_option(tcpip_adapter_dhcp_option_mode_t opt_op, tcpip_adapter_dhcp_option_id_t opt_id, void *opt_val, uint32_t opt_len); 170 171 /** 172 * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcpc_option 173 */ 174 esp_err_t tcpip_adapter_dhcpc_option(tcpip_adapter_dhcp_option_mode_t opt_op, tcpip_adapter_dhcp_option_id_t opt_id, void *opt_val, uint32_t opt_len); 175 176 /** 177 * @brief Compatible version of former tcpip_adapter API of esp_netif_set_ip_info 178 */ 179 esp_err_t tcpip_adapter_set_ip_info(tcpip_adapter_if_t tcpip_if, const tcpip_adapter_ip_info_t *ip_info); 180 181 /** 182 * @brief Compatible version of former tcpip_adapter API of esp_netif_get_dns_info 183 */ 184 esp_err_t tcpip_adapter_get_dns_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_dns_type_t type, tcpip_adapter_dns_info_t *dns); 185 186 /** 187 * @brief Compatible version of former tcpip_adapter API of esp_netif_set_dns_info 188 */ 189 esp_err_t tcpip_adapter_set_dns_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_dns_type_t type, tcpip_adapter_dns_info_t *dns); 190 191 /** 192 * @brief Compatible version of former tcpip_adapter API of esp_netif_get_netif_impl_index 193 */ 194 int tcpip_adapter_get_netif_index(tcpip_adapter_if_t tcpip_if); 195 196 /** 197 * @brief Compatible version of former tcpip_adapter API of esp_netif_get_sta_list 198 */ 199 esp_err_t tcpip_adapter_get_sta_list(const wifi_sta_list_t *wifi_sta_list, tcpip_adapter_sta_list_t *tcpip_sta_list); 200 201 /** 202 * @brief Compatible version of former tcpip_adapter API of esp_netif_action_start for default ethernet 203 */ 204 esp_err_t tcpip_adapter_eth_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info, void *args); 205 206 /** 207 * @brief Compatible version of former tcpip_adapter API of esp_netif_action_start for default station 208 */ 209 esp_err_t tcpip_adapter_sta_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); 210 211 /** 212 * @brief Compatible version of former tcpip_adapter API of esp_netif_action_start for default softAP 213 */ 214 esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); 215 216 /** 217 * @brief Compatible version of former tcpip_adapter API of esp_netif_action_stop 218 */ 219 esp_err_t tcpip_adapter_stop(tcpip_adapter_if_t tcpip_if); 220 221 /** 222 * @brief Compatible version of former tcpip_adapter API of esp_netif_up 223 */ 224 esp_err_t tcpip_adapter_up(tcpip_adapter_if_t tcpip_if); 225 226 /** 227 * @brief Compatible version of former tcpip_adapter API of esp_netif_down 228 */ 229 esp_err_t tcpip_adapter_down(tcpip_adapter_if_t tcpip_if); 230 231 /** 232 * @brief Compatible version of former tcpip_adapter API of esp_netif_get_old_ip_info 233 */ 234 esp_err_t tcpip_adapter_get_old_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info); 235 236 /** 237 * @brief Compatible version of former tcpip_adapter API of esp_netif_set_old_ip_info 238 */ 239 esp_err_t tcpip_adapter_set_old_ip_info(tcpip_adapter_if_t tcpip_if, const tcpip_adapter_ip_info_t *ip_info); 240 241 /** 242 * @brief Compatible version of former tcpip_adapter API of esp_netif_get_handle_from_netif_impl 243 */ 244 esp_interface_t tcpip_adapter_get_esp_if(void *dev); 245 246 /** 247 * @brief Compatible version of former tcpip_adapter API of esp_netif_set_hostname 248 */ 249 esp_err_t tcpip_adapter_set_hostname(tcpip_adapter_if_t tcpip_if, const char *hostname); 250 251 /** 252 * @brief Compatible version of former tcpip_adapter API of esp_netif_get_hostname 253 */ 254 esp_err_t tcpip_adapter_get_hostname(tcpip_adapter_if_t tcpip_if, const char **hostname); 255 256 /** 257 * @brief This function is called from wifi_init to assure backward compatibility mode 258 * of tcpip_adapter. In case of legacy use, default instances of ap and sta 259 * are created and handlers are registered 260 * 261 * @return ESP_OK on success 262 */ 263 esp_err_t tcpip_adapter_set_default_wifi_handlers(void); 264 265 #ifdef __cplusplus 266 } // extern "C" 267 #endif 268 269 #endif //_TCPIP_ADAPTER_H_ 270