esp_netif_slip.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. //
  14. #ifndef _ESP_NETIF_SLIP_H_
  15. #define _ESP_NETIF_SLIP_H_
  16. #include "esp_netif.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /** @brief Configuration structure for SLIP network interface
  21. *
  22. */
  23. typedef struct esp_netif_slip_config {
  24. esp_ip6_addr_t ip6_addr; /* Local IP6 address */
  25. } esp_netif_slip_config_t;
  26. /** @brief Sets common parameters for the supplied esp-netif.
  27. *
  28. * @param[in] esp_netif handle to slip esp-netif instance
  29. * @param[in] config Pointer to SLIP netif configuration structure
  30. *
  31. * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not SLIP
  32. */
  33. esp_err_t esp_netif_slip_set_params(esp_netif_t *netif, const esp_netif_slip_config_t *config);
  34. #if CONFIG_LWIP_IPV6
  35. /** @brief Sets IPV6 address for the supplied esp-netif.
  36. *
  37. * @param[in] netif handle to slip esp-netif instance
  38. * @param[in] ipv6 IPv6 address of the SLIP interface
  39. *
  40. * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not SLIP
  41. */
  42. esp_err_t esp_netif_slip_set_ipv6(esp_netif_t *netif, const esp_ip6_addr_t *ipv6);
  43. #endif
  44. /**
  45. * @brief Data path API to write raw packet ous the SLIP interface
  46. *
  47. * This API is typically used when implementing user defined methods
  48. *
  49. * @param[in] esp_netif handle to slip esp-netif instance
  50. * @param[in] buffer pointer to the outgoing data
  51. * @param[in] len length of the data
  52. *
  53. * @return
  54. * - ESP_OK on success
  55. */
  56. void esp_netif_lwip_slip_raw_output(esp_netif_t *netif, void *buffer, size_t len);
  57. /**
  58. * @brief Fetch IP6 address attached to the SLIP interface
  59. *
  60. * @param[in] esp_netif handle to slip esp-netif instance
  61. * @param[in] address index (unused)
  62. *
  63. * @return
  64. * - pointer to the internal ip6 address object
  65. */
  66. const esp_ip6_addr_t *esp_slip_get_ip6(esp_netif_t *slip_netif);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif //_ESP_NETIF_SLIP_H_