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 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef _ESP_NETIF_NET_STACK_H_ 16 #define _ESP_NETIF_NET_STACK_H_ 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 // 23 // Network stack API: This ESP-NETIF API are supposed to be called only from internals of TCP/IP stack 24 // 25 26 /** @addtogroup ESP_NETIF_CONVERT 27 * @{ 28 */ 29 30 /** 31 * @brief Returns esp-netif handle 32 * 33 * @param[in] dev opaque ptr to network interface of specific TCP/IP stack 34 * 35 * @return handle to related esp-netif instance 36 */ 37 esp_netif_t* esp_netif_get_handle_from_netif_impl(void *dev); 38 39 /** 40 * @brief Returns network stack specific implementation handle (if supported) 41 * 42 * Note that it is not supported to acquire PPP netif impl pointer and 43 * this function will return NULL for esp_netif instances configured to PPP mode 44 * 45 * @param[in] esp_netif Handle to esp-netif instance 46 * 47 * @return handle to related network stack netif handle 48 */ 49 void* esp_netif_get_netif_impl(esp_netif_t *esp_netif); 50 51 /** 52 * @} 53 */ 54 55 /** @addtogroup ESP_NETIF_DATA_IO_API 56 * @{ 57 */ 58 59 /** 60 * @brief Outputs packets from the TCP/IP stack to the media to be transmitted 61 * 62 * This function gets called from network stack to output packets to IO driver. 63 * 64 * @param[in] esp_netif Handle to esp-netif instance 65 * @param[in] data Data to be transmitted 66 * @param[in] len Length of the data frame 67 * 68 * @return ESP_OK on success, an error passed from the I/O driver otherwise 69 */ 70 esp_err_t esp_netif_transmit(esp_netif_t *esp_netif, void* data, size_t len); 71 72 /** 73 * @brief Outputs packets from the TCP/IP stack to the media to be transmitted 74 * 75 * This function gets called from network stack to output packets to IO driver. 76 * 77 * @param[in] esp_netif Handle to esp-netif instance 78 * @param[in] data Data to be transmitted 79 * @param[in] len Length of the data frame 80 * @param[in] netstack_buf net stack buffer 81 * 82 * @return ESP_OK on success, an error passed from the I/O driver otherwise 83 */ 84 esp_err_t esp_netif_transmit_wrap(esp_netif_t *esp_netif, void *data, size_t len, void *netstack_buf); 85 86 /** 87 * @brief Free the rx buffer allocated by the media driver 88 * 89 * This function gets called from network stack when the rx buffer to be freed in IO driver context, 90 * i.e. to deallocate a buffer owned by io driver (when data packets were passed to higher levels 91 * to avoid copying) 92 * 93 * @param[in] esp_netif Handle to esp-netif instance 94 * @param[in] buffer Rx buffer pointer 95 */ 96 void esp_netif_free_rx_buffer(void *esp_netif, void* buffer); 97 98 /** 99 * @} 100 */ 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif //_ESP_NETIF_NET_STACK_H_ 107