tcpip_adapter.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _ESP_NETIF_SUPPRESS_LEGACY_WARNING_
  14. #warning "This header is deprecated, please use new network related API in esp_netif.h"
  15. #include "esp_netif.h"
  16. #endif
  17. #ifndef _TCPIP_ADAPTER_H_
  18. #define _TCPIP_ADAPTER_H_
  19. #include "esp_netif.h"
  20. #include "tcpip_adapter_types.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /**
  25. * @brief tcpip adapter legacy init. It is used only to set the compatibility mode of esp-netif, which
  26. * will enable backward compatibility of esp-netif.
  27. */
  28. void tcpip_adapter_init(void) __attribute__ ((deprecated));
  29. /**
  30. * @brief Compatiblity mode: convert the esp-netif handle to tcpip_adapter legacy interface enum
  31. *
  32. * @param esp_netif
  33. *
  34. * @return corresponding interface if valid or known esp_netif provided, TCPIP_ADAPTER_IF_MAX otherwise
  35. */
  36. tcpip_adapter_if_t tcpip_adapter_if_from_esp_netif(esp_netif_t *esp_netif);
  37. /**
  38. * @brief Translates to esp_netif_get_ip_info
  39. *
  40. * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif
  41. * @param ip_info See esp_netif_get_ip_info
  42. * @return See esp_netif_get_ip_info
  43. */
  44. esp_err_t tcpip_adapter_get_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info);
  45. /**
  46. * @brief Translates to esp_netif_get_ip6_linklocal
  47. *
  48. * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif
  49. * @param if_ip6 See esp_netif_get_ip6_linklocal
  50. * @return See esp_netif_get_ip6_linklocal
  51. */
  52. esp_err_t tcpip_adapter_get_ip6_linklocal(tcpip_adapter_if_t tcpip_if, ip6_addr_t *if_ip6);
  53. /**
  54. * @brief Translates to esp_netif_get_ip6_global
  55. *
  56. * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif
  57. * @param if_ip6 See esp_netif_get_ip6_global
  58. * @return See esp_netif_get_ip6_global
  59. */
  60. esp_err_t tcpip_adapter_get_ip6_global(tcpip_adapter_if_t tcpip_if, ip6_addr_t *if_ip6);
  61. /**
  62. * @brief`Translates to esp_netif_dhcpc_get_status
  63. * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif
  64. * @param status
  65. * @return See esp_netif_dhcpc_get_status
  66. */
  67. esp_err_t tcpip_adapter_dhcpc_get_status(tcpip_adapter_if_t tcpip_if, tcpip_adapter_dhcp_status_t *status);
  68. /**
  69. * @brief Translates to esp_netif_is_netif_up
  70. * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif
  71. * @return see esp_netif_is_netif_up
  72. */
  73. bool tcpip_adapter_is_netif_up(tcpip_adapter_if_t tcpip_if);
  74. /**
  75. * @brief Translates to esp_netif_get_netif
  76. * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif
  77. * @param netif
  78. * @return see esp_netif_get_netif
  79. */
  80. esp_err_t tcpip_adapter_get_netif(tcpip_adapter_if_t tcpip_if, void ** netif);
  81. /**
  82. * @brief Translates to esp_netif_create_ip6_linklocal
  83. * @param tcpip_if Interface type corresponding to appropriate instance of esp-netif
  84. * @return see esp_netif_create_ip6_linklocal
  85. */
  86. esp_err_t tcpip_adapter_create_ip6_linklocal(tcpip_adapter_if_t tcpip_if);
  87. /**
  88. * @brief Compatible version of setting ethernet default handlers
  89. * @note Compatible version of wifi handlers are provided in a separate header,
  90. * as this used to be called privately from wifi_init()
  91. * @return ESP_OK on success
  92. */
  93. esp_err_t tcpip_adapter_set_default_eth_handlers(void);
  94. /**
  95. * @brief Compatible version of network stack input function. Translates to esp_netif_receive()
  96. */
  97. esp_err_t tcpip_adapter_eth_input(void *buffer, uint16_t len, void *eb);
  98. /**
  99. * @brief Compatible version of network stack input function. Translates to esp_netif_receive()
  100. */
  101. esp_err_t tcpip_adapter_sta_input(void *buffer, uint16_t len, void *eb);
  102. /**
  103. * @brief Compatible version of network stack input function. Translates to esp_netif_receive()
  104. */
  105. esp_err_t tcpip_adapter_ap_input(void *buffer, uint16_t len, void *eb);
  106. /**
  107. * @brief Compatible version of former tcpip_adapter API to clear default WIFI handlers
  108. * @return ESP_OK on success
  109. */
  110. esp_err_t tcpip_adapter_clear_default_wifi_handlers(void);
  111. /**
  112. * @brief Compatible version of former tcpip_adapter API to clear default ethernet handlers
  113. * @return ESP_OK on success
  114. */
  115. esp_err_t tcpip_adapter_clear_default_eth_handlers(void);
  116. /**
  117. * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcps_stop
  118. */
  119. esp_err_t tcpip_adapter_dhcps_stop(tcpip_adapter_if_t tcpip_if);
  120. /**
  121. * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcpc_stop
  122. */
  123. esp_err_t tcpip_adapter_dhcpc_stop(tcpip_adapter_if_t tcpip_if);
  124. /**
  125. * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcps_start
  126. */
  127. esp_err_t tcpip_adapter_dhcps_start(tcpip_adapter_if_t tcpip_if);
  128. /**
  129. * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcpc_start
  130. */
  131. esp_err_t tcpip_adapter_dhcpc_start(tcpip_adapter_if_t tcpip_if);
  132. /**
  133. * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcps_get_status
  134. */
  135. esp_err_t tcpip_adapter_dhcps_get_status(tcpip_adapter_if_t tcpip_if, tcpip_adapter_dhcp_status_t *status);
  136. /**
  137. * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcps_option
  138. */
  139. 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);
  140. /**
  141. * @brief Compatible version of former tcpip_adapter API of esp_netif_dhcpc_option
  142. */
  143. 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);
  144. /**
  145. * @brief Compatible version of former tcpip_adapter API of esp_netif_set_ip_info
  146. */
  147. esp_err_t tcpip_adapter_set_ip_info(tcpip_adapter_if_t tcpip_if, const tcpip_adapter_ip_info_t *ip_info);
  148. /**
  149. * @brief Compatible version of former tcpip_adapter API of esp_netif_get_dns_info
  150. */
  151. 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);
  152. /**
  153. * @brief Compatible version of former tcpip_adapter API of esp_netif_set_dns_info
  154. */
  155. 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);
  156. /**
  157. * @brief Compatible version of former tcpip_adapter API of esp_netif_get_netif_impl_index
  158. */
  159. int tcpip_adapter_get_netif_index(tcpip_adapter_if_t tcpip_if);
  160. /**
  161. * @brief Compatible version of former tcpip_adapter API of esp_netif_get_sta_list
  162. */
  163. esp_err_t tcpip_adapter_get_sta_list(const wifi_sta_list_t *wifi_sta_list, tcpip_adapter_sta_list_t *tcpip_sta_list);
  164. /**
  165. * @brief Compatible version of former tcpip_adapter API of esp_netif_action_start for default ethernet
  166. */
  167. esp_err_t tcpip_adapter_eth_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info, void *args);
  168. /**
  169. * @brief Compatible version of former tcpip_adapter API of esp_netif_action_start for default station
  170. */
  171. esp_err_t tcpip_adapter_sta_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info);
  172. /**
  173. * @brief Compatible version of former tcpip_adapter API of esp_netif_action_start for default softAP
  174. */
  175. esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info);
  176. /**
  177. * @brief Compatible version of former tcpip_adapter API of esp_netif_action_stop
  178. */
  179. esp_err_t tcpip_adapter_stop(tcpip_adapter_if_t tcpip_if);
  180. /**
  181. * @brief Compatible version of former tcpip_adapter API of esp_netif_up
  182. */
  183. esp_err_t tcpip_adapter_up(tcpip_adapter_if_t tcpip_if);
  184. /**
  185. * @brief Compatible version of former tcpip_adapter API of esp_netif_down
  186. */
  187. esp_err_t tcpip_adapter_down(tcpip_adapter_if_t tcpip_if);
  188. /**
  189. * @brief Compatible version of former tcpip_adapter API of esp_netif_get_old_ip_info
  190. */
  191. esp_err_t tcpip_adapter_get_old_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info);
  192. /**
  193. * @brief Compatible version of former tcpip_adapter API of esp_netif_set_old_ip_info
  194. */
  195. esp_err_t tcpip_adapter_set_old_ip_info(tcpip_adapter_if_t tcpip_if, const tcpip_adapter_ip_info_t *ip_info);
  196. /**
  197. * @brief Compatible version of former tcpip_adapter API of esp_netif_get_handle_from_netif_impl
  198. */
  199. esp_interface_t tcpip_adapter_get_esp_if(void *dev);
  200. /**
  201. * @brief Compatible version of former tcpip_adapter API of esp_netif_set_hostname
  202. */
  203. esp_err_t tcpip_adapter_set_hostname(tcpip_adapter_if_t tcpip_if, const char *hostname);
  204. /**
  205. * @brief Compatible version of former tcpip_adapter API of esp_netif_get_hostname
  206. */
  207. esp_err_t tcpip_adapter_get_hostname(tcpip_adapter_if_t tcpip_if, const char **hostname);
  208. /**
  209. * @brief This function is called from wifi_init to assure backward compatibility mode
  210. * of tcpip_adapter. In case of legacy use, default instances of ap and sta
  211. * are created and handlers are registered
  212. *
  213. * @return ESP_OK on success
  214. */
  215. esp_err_t tcpip_adapter_set_default_wifi_handlers(void);
  216. #ifdef __cplusplus
  217. } // extern "C"
  218. #endif
  219. #endif //_TCPIP_ADAPTER_H_