1 /* 2 * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include "esp_err.h" 10 11 #define L2TAP_VFS_DEFAULT_PATH "/dev/net/tap" 12 #define L2TAP_VFS_CONFIG_DEFAULT() \ 13 { \ 14 .base_path = L2TAP_VFS_DEFAULT_PATH, \ 15 } 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 typedef void *l2tap_iodriver_handle; 22 23 /** 24 * @brief L2Tap VFS config parameters 25 * 26 */ 27 typedef struct { 28 const char* base_path; /*!< vfs base path */ 29 } l2tap_vfs_config_t; 30 31 typedef enum { 32 L2TAP_S_RCV_FILTER, 33 L2TAP_G_RCV_FILTER, 34 L2TAP_S_INTF_DEVICE, 35 L2TAP_G_INTF_DEVICE, 36 L2TAP_S_DEVICE_DRV_HNDL, 37 L2TAP_G_DEVICE_DRV_HNDL 38 } l2tap_ioctl_opt_t; 39 40 /** 41 * @brief Add L2 TAP virtual filesystem driver 42 * 43 * This function must be called prior usage of ESP-NETIF L2 TAP Interface 44 * 45 * @param config L2 TAP virtual filesystem driver configuration. Default base path /dev/net/tap is used when this paramenter is NULL. 46 * @return esp_err_t 47 * - ESP_OK on success 48 */ 49 esp_err_t esp_vfs_l2tap_intf_register(l2tap_vfs_config_t *config); 50 51 /** 52 * @brief Removes L2 TAP virtual filesystem driver 53 * 54 * @param base_path Base path to the L2 TAP virtual filesystem driver. Default path /dev/net/tap is used when this paramenter is NULL. 55 * @return esp_err_t 56 * - ESP_OK on success 57 */ 58 esp_err_t esp_vfs_l2tap_intf_unregister(const char *base_path); 59 60 /** 61 * @brief Filters received Ethernet L2 frames into L2 TAP infrastructure. 62 * 63 * @param driver_handle handle of driver at which the frame was received 64 * @param buff received L2 frame 65 * @param size input length of the L2 frame which is set to 0 when frame is filtered into L2 TAP 66 * @return esp_err_t 67 * - ESP_OK is always returned 68 */ 69 esp_err_t esp_vfs_l2tap_eth_filter(l2tap_iodriver_handle driver_handle, void *buff, size_t *size); 70 71 #ifdef __cplusplus 72 } 73 #endif 74