esp_vfs_l2tap.h 1.9 KB

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