esp_netif_net_stack.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "esp_netif.h"
  8. #include "lwip/netif.h"
  9. #include "esp_netif_ppp.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #ifdef CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS
  14. typedef esp_err_t esp_netif_recv_ret_t;
  15. #define ESP_NETIF_OPTIONAL_RETURN_CODE(expr) expr
  16. #else
  17. typedef void esp_netif_recv_ret_t;
  18. #define ESP_NETIF_OPTIONAL_RETURN_CODE(expr)
  19. #endif // CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS
  20. typedef err_t (*init_fn_t)(struct netif*);
  21. typedef esp_netif_recv_ret_t (*input_fn_t)(void *netif, void *buffer, size_t len, void *eb);
  22. struct esp_netif_netstack_lwip_vanilla_config {
  23. init_fn_t init_fn;
  24. input_fn_t input_fn;
  25. };
  26. struct esp_netif_netstack_lwip_ppp_config {
  27. input_fn_t input_fn;
  28. esp_netif_ppp_config_t ppp_events;
  29. };
  30. // LWIP netif specific network stack configuration
  31. struct esp_netif_netstack_config {
  32. union {
  33. struct esp_netif_netstack_lwip_vanilla_config lwip;
  34. struct esp_netif_netstack_lwip_ppp_config lwip_ppp;
  35. };
  36. };
  37. /**
  38. * @brief LWIP's network stack init function for Ethernet
  39. * @param netif LWIP's network interface handle
  40. * @return ERR_OK on success
  41. */
  42. err_t ethernetif_init(struct netif *netif);
  43. /**
  44. * @brief LWIP's network stack input packet function for Ethernet
  45. * @param h LWIP's network interface handle
  46. * @param buffer Input buffer pointer
  47. * @param len Input buffer size
  48. * @param l2_buff External buffer pointer (to be passed to custom input-buffer free)
  49. */
  50. esp_netif_recv_ret_t ethernetif_input(void *h, void *buffer, size_t len, void *l2_buff);
  51. /**
  52. * @brief LWIP's network stack init function for WiFi (AP)
  53. * @param netif LWIP's network interface handle
  54. * @return ERR_OK on success
  55. */
  56. err_t wlanif_init_ap(struct netif *netif);
  57. /**
  58. * @brief LWIP's network stack init function for WiFi (Station)
  59. * @param netif LWIP's network interface handle
  60. * @return ERR_OK on success
  61. */
  62. err_t wlanif_init_sta(struct netif *netif);
  63. /**
  64. * @brief LWIP's network stack init function for WiFi Aware interface (NAN)
  65. * @param netif LWIP's network interface handle
  66. * @return ERR_OK on success
  67. */
  68. err_t wlanif_init_nan(struct netif *netif);
  69. /**
  70. * @brief LWIP's network stack input packet function for WiFi (both STA/AP)
  71. * @param h LWIP's network interface handle
  72. * @param buffer Input buffer pointer
  73. * @param len Input buffer size
  74. * @param l2_buff External buffer pointer (to be passed to custom input-buffer free)
  75. */
  76. esp_netif_recv_ret_t wlanif_input(void *h, void *buffer, size_t len, void* l2_buff);
  77. #ifdef __cplusplus
  78. }
  79. #endif