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 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 16 #ifndef _ESP_NETIF_SLIP_H_ 17 #define _ESP_NETIF_SLIP_H_ 18 19 #include "esp_netif.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /** @brief Configuration structure for SLIP network interface 26 * 27 */ 28 typedef struct esp_netif_slip_config { 29 esp_ip6_addr_t ip6_addr; /* Local IP6 address */ 30 31 } esp_netif_slip_config_t; 32 33 34 /** @brief Sets common parameters for the supplied esp-netif. 35 * 36 * @param[in] esp_netif handle to slip esp-netif instance 37 * @param[in] config Pointer to SLIP netif configuration structure 38 * 39 * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not SLIP 40 */ 41 esp_err_t esp_netif_slip_set_params(esp_netif_t *netif, const esp_netif_slip_config_t *config); 42 43 #if CONFIG_LWIP_IPV6 44 /** @brief Sets IPV6 address for the supplied esp-netif. 45 * 46 * @param[in] netif handle to slip esp-netif instance 47 * @param[in] ipv6 IPv6 address of the SLIP interface 48 * 49 * @return ESP_OK on success, ESP_ERR_ESP_NETIF_INVALID_PARAMS if netif null or not SLIP 50 */ 51 esp_err_t esp_netif_slip_set_ipv6(esp_netif_t *netif, const esp_ip6_addr_t *ipv6); 52 #endif 53 54 /** 55 * @brief Data path API to write raw packet ous the SLIP interface 56 * 57 * This API is typically used when implementing user defined methods 58 * 59 * @param[in] esp_netif handle to slip esp-netif instance 60 * @param[in] buffer pointer to the outgoing data 61 * @param[in] len length of the data 62 * 63 * @return 64 * - ESP_OK on success 65 */ 66 void esp_netif_lwip_slip_raw_output(esp_netif_t *netif, void *buffer, size_t len); 67 68 /** 69 * @brief Fetch IP6 address attached to the SLIP interface 70 * 71 * @param[in] esp_netif handle to slip esp-netif instance 72 * @param[in] address index (unused) 73 * 74 * @return 75 * - pointer to the internal ip6 address object 76 */ 77 const esp_ip6_addr_t *esp_slip_get_ip6(esp_netif_t *slip_netif); 78 79 #ifdef __cplusplus 80 } 81 #endif 82 #endif //_ESP_NETIF_SLIP_H_ 83