esp_netif_defaults.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. // 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_DEFAULTS_H
  14. #define _ESP_NETIF_DEFAULTS_H
  15. #include "esp_compiler.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. //
  20. // Macros to assemble master configs with partial configs from netif, stack and driver
  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. #define ESP_NETIF_INHERENT_DEFAULT_WIFI_AP() \
  34. { \
  35. .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP), \
  36. ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
  37. .ip_info = &_g_esp_netif_soft_ap_ip, \
  38. .get_ip_event = 0, \
  39. .lost_ip_event = 0, \
  40. .if_key = "WIFI_AP_DEF", \
  41. .if_desc = "ap", \
  42. .route_prio = 10 \
  43. };
  44. #define ESP_NETIF_INHERENT_DEFAULT_ETH() \
  45. { \
  46. .flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_CLIENT | ESP_NETIF_FLAG_GARP | ESP_NETIF_FLAG_EVENT_IP_MODIFIED), \
  47. ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
  48. ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
  49. .get_ip_event = IP_EVENT_ETH_GOT_IP, \
  50. .lost_ip_event = 0, \
  51. .if_key = "ETH_DEF", \
  52. .if_desc = "eth", \
  53. .route_prio = 50 \
  54. };
  55. #define ESP_NETIF_INHERENT_DEFAULT_PPP() \
  56. { \
  57. .flags = ESP_NETIF_FLAG_IS_PPP, \
  58. ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac) \
  59. ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(ip_info) \
  60. .get_ip_event = IP_EVENT_PPP_GOT_IP, \
  61. .lost_ip_event = IP_EVENT_PPP_LOST_IP, \
  62. .if_key = "PPP_DEF", \
  63. .if_desc = "ppp", \
  64. .route_prio = 128 \
  65. };
  66. /**
  67. * @brief Default configuration reference of ethernet interface
  68. */
  69. #define ESP_NETIF_DEFAULT_ETH() \
  70. { \
  71. .base = ESP_NETIF_BASE_DEFAULT_ETH, \
  72. .driver = NULL, \
  73. .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH, \
  74. }
  75. /**
  76. * @brief Default configuration reference of WIFI AP
  77. */
  78. #define ESP_NETIF_DEFAULT_WIFI_AP() \
  79. { \
  80. .base = ESP_NETIF_BASE_DEFAULT_WIFI_AP, \
  81. .driver = NULL, \
  82. .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP, \
  83. }
  84. /**
  85. * @brief Default configuration reference of WIFI STA
  86. */
  87. #define ESP_NETIF_DEFAULT_WIFI_STA() \
  88. { \
  89. .base = ESP_NETIF_BASE_DEFAULT_WIFI_STA, \
  90. .driver = NULL, \
  91. .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA, \
  92. }
  93. /**
  94. * @brief Default configuration reference of PPP client
  95. */
  96. #define ESP_NETIF_DEFAULT_PPP() \
  97. { \
  98. .base = ESP_NETIF_BASE_DEFAULT_PPP, \
  99. .driver = NULL, \
  100. .stack = ESP_NETIF_NETSTACK_DEFAULT_PPP, \
  101. }
  102. /**
  103. * @brief Default base config (esp-netif inherent) of WIFI STA
  104. */
  105. #define ESP_NETIF_BASE_DEFAULT_WIFI_STA &_g_esp_netif_inherent_sta_config
  106. /**
  107. * @brief Default base config (esp-netif inherent) of WIFI AP
  108. */
  109. #define ESP_NETIF_BASE_DEFAULT_WIFI_AP &_g_esp_netif_inherent_ap_config
  110. /**
  111. * @brief Default base config (esp-netif inherent) of ethernet interface
  112. */
  113. #define ESP_NETIF_BASE_DEFAULT_ETH &_g_esp_netif_inherent_eth_config
  114. /**
  115. * @brief Default base config (esp-netif inherent) of ppp interface
  116. */
  117. #define ESP_NETIF_BASE_DEFAULT_PPP &_g_esp_netif_inherent_ppp_config
  118. #define ESP_NETIF_NETSTACK_DEFAULT_ETH _g_esp_netif_netstack_default_eth
  119. #define ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA _g_esp_netif_netstack_default_wifi_sta
  120. #define ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP _g_esp_netif_netstack_default_wifi_ap
  121. #define ESP_NETIF_NETSTACK_DEFAULT_PPP _g_esp_netif_netstack_default_ppp
  122. //
  123. // Include default network stacks configs
  124. // - Network stack configurations are provided in a specific network stack
  125. // implementation that is invisible to user API
  126. // - Here referenced only as opaque pointers
  127. //
  128. extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth;
  129. extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta;
  130. extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap;
  131. extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp;
  132. //
  133. // Include default common configs inherent to esp-netif
  134. // - These inherent configs are defined in esp_netif_defaults.c and describe
  135. // common behavioural patterns for common interfaces such as STA, AP, ETH, PPP
  136. //
  137. extern const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config;
  138. extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config;
  139. extern const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config;
  140. extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config;
  141. extern const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip;
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif //_ESP_NETIF_DEFAULTS_H