esp_netif_net_stack.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _ESP_NETIF_NET_STACK_H_
  7. #define _ESP_NETIF_NET_STACK_H_
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. //
  12. // Network stack API: This ESP-NETIF API are supposed to be called only from internals of TCP/IP stack
  13. //
  14. /** @addtogroup ESP_NETIF_CONVERT
  15. * @{
  16. */
  17. /**
  18. * @brief Returns esp-netif handle
  19. *
  20. * @param[in] dev opaque ptr to network interface of specific TCP/IP stack
  21. *
  22. * @return handle to related esp-netif instance
  23. */
  24. esp_netif_t* esp_netif_get_handle_from_netif_impl(void *dev);
  25. /**
  26. * @brief Returns network stack specific implementation handle (if supported)
  27. *
  28. * Note that it is not supported to acquire PPP netif impl pointer and
  29. * this function will return NULL for esp_netif instances configured to PPP mode
  30. *
  31. * @param[in] esp_netif Handle to esp-netif instance
  32. *
  33. * @return handle to related network stack netif handle
  34. */
  35. void* esp_netif_get_netif_impl(esp_netif_t *esp_netif);
  36. /**
  37. * @}
  38. */
  39. /** @addtogroup ESP_NETIF_DATA_IO_API
  40. * @{
  41. */
  42. /**
  43. * @brief Outputs packets from the TCP/IP stack to the media to be transmitted
  44. *
  45. * This function gets called from network stack to output packets to IO driver.
  46. *
  47. * @param[in] esp_netif Handle to esp-netif instance
  48. * @param[in] data Data to be transmitted
  49. * @param[in] len Length of the data frame
  50. *
  51. * @return ESP_OK on success, an error passed from the I/O driver otherwise
  52. */
  53. esp_err_t esp_netif_transmit(esp_netif_t *esp_netif, void* data, size_t len);
  54. /**
  55. * @brief Outputs packets from the TCP/IP stack to the media to be transmitted
  56. *
  57. * This function gets called from network stack to output packets to IO driver.
  58. *
  59. * @param[in] esp_netif Handle to esp-netif instance
  60. * @param[in] data Data to be transmitted
  61. * @param[in] len Length of the data frame
  62. * @param[in] netstack_buf net stack buffer
  63. *
  64. * @return ESP_OK on success, an error passed from the I/O driver otherwise
  65. */
  66. esp_err_t esp_netif_transmit_wrap(esp_netif_t *esp_netif, void *data, size_t len, void *netstack_buf);
  67. /**
  68. * @brief Free the rx buffer allocated by the media driver
  69. *
  70. * This function gets called from network stack when the rx buffer to be freed in IO driver context,
  71. * i.e. to deallocate a buffer owned by io driver (when data packets were passed to higher levels
  72. * to avoid copying)
  73. *
  74. * @param[in] esp_netif Handle to esp-netif instance
  75. * @param[in] buffer Rx buffer pointer
  76. */
  77. void esp_netif_free_rx_buffer(void *esp_netif, void* buffer);
  78. /**
  79. * @}
  80. */
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif //_ESP_NETIF_NET_STACK_H_