1 /* 2 * Copyright (c) 2016 Intel Corporation 3 * Copyright (c) 2023 Nordic Semiconductor ASA 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #include <stdbool.h> 9 10 #include <zephyr/device.h> 11 #include <zephyr/net/buf.h> 12 #include <zephyr/net/net_pkt.h> 13 #include <zephyr/net/net_if.h> 14 15 #if defined(CONFIG_SLIP_TAP) 16 #define _SLIP_MTU 1500 17 #else 18 #define _SLIP_MTU 576 19 #endif /* CONFIG_SLIP_TAP */ 20 21 struct slip_context { 22 bool init_done; 23 bool first; /* SLIP received it's byte or not after 24 * driver initialization or SLIP_END byte. 25 */ 26 uint8_t buf[1]; /* SLIP data is read into this buf */ 27 struct net_pkt *rx; /* and then placed into this net_pkt */ 28 struct net_buf *last; /* Pointer to last buffer in the list */ 29 uint8_t *ptr; /* Where in net_pkt to add data */ 30 struct net_if *iface; 31 uint8_t state; 32 33 uint8_t mac_addr[6]; 34 struct net_linkaddr ll_addr; 35 36 #if defined(CONFIG_SLIP_STATISTICS) 37 #define SLIP_STATS(statement) 38 #else 39 uint16_t garbage; 40 #define SLIP_STATS(statement) statement 41 #endif 42 }; 43 44 void slip_iface_init(struct net_if *iface); 45 int slip_init(const struct device *dev); 46 int slip_send(const struct device *dev, struct net_pkt *pkt); 47