esp_netif_net_stack.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * @brief Set link-speed for the specified network interface
  38. * @param[in] esp_netif Handle to esp-netif instance
  39. * @param[in] speed Link speed in bit/s
  40. * @return ESP_OK on success
  41. */
  42. esp_err_t esp_netif_set_link_speed(esp_netif_t *esp_netif, uint32_t speed);
  43. /**
  44. * @}
  45. */
  46. /** @addtogroup ESP_NETIF_DATA_IO_API
  47. * @{
  48. */
  49. /**
  50. * @brief Outputs packets from the TCP/IP stack to the media to be transmitted
  51. *
  52. * This function gets called from network stack to output packets to IO driver.
  53. *
  54. * @param[in] esp_netif Handle to esp-netif instance
  55. * @param[in] data Data to be transmitted
  56. * @param[in] len Length of the data frame
  57. *
  58. * @return ESP_OK on success, an error passed from the I/O driver otherwise
  59. */
  60. esp_err_t esp_netif_transmit(esp_netif_t *esp_netif, void* data, size_t len);
  61. /**
  62. * @brief Outputs packets from the TCP/IP stack to the media to be transmitted
  63. *
  64. * This function gets called from network stack to output packets to IO driver.
  65. *
  66. * @param[in] esp_netif Handle to esp-netif instance
  67. * @param[in] data Data to be transmitted
  68. * @param[in] len Length of the data frame
  69. * @param[in] netstack_buf net stack buffer
  70. *
  71. * @return ESP_OK on success, an error passed from the I/O driver otherwise
  72. */
  73. esp_err_t esp_netif_transmit_wrap(esp_netif_t *esp_netif, void *data, size_t len, void *netstack_buf);
  74. /**
  75. * @brief Free the rx buffer allocated by the media driver
  76. *
  77. * This function gets called from network stack when the rx buffer to be freed in IO driver context,
  78. * i.e. to deallocate a buffer owned by io driver (when data packets were passed to higher levels
  79. * to avoid copying)
  80. *
  81. * @param[in] esp_netif Handle to esp-netif instance
  82. * @param[in] buffer Rx buffer pointer
  83. */
  84. void esp_netif_free_rx_buffer(void *esp_netif, void* buffer);
  85. /**
  86. * @}
  87. */
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif //_ESP_NETIF_NET_STACK_H_