58 #define SLIP_DONTBLOCK 0
62 #define SLIP_ESC_END 0334
63 #define SLIP_ESC_ESC 0335
65 #define SLIP_MAX_SIZE 1500
67 enum slipif_recv_state {
76 enum slipif_recv_state state;
93 struct slipif_priv *priv;
109 for (q = p; q !=
NULL; q = q->
next) {
110 for (i = 0; i < q->
len; i++) {
163 slipif_input(
struct netif *netif,
u8_t block)
165 struct slipif_priv *priv;
174 while (slip_sio_read(priv->sd, &c, 1, block) > 0) {
175 switch (priv->state) {
176 case SLIP_RECV_NORMAL:
179 if (priv->recved > 0) {
188 priv->p = priv->q =
NULL;
189 priv->i = priv->recved = 0;
194 priv->state = SLIP_RECV_ESCAPE;
198 case SLIP_RECV_ESCAPE:
207 priv->state = SLIP_RECV_NORMAL;
212 if (priv->p ==
NULL) {
217 if (priv->p ==
NULL) {
224 if (priv->q !=
NULL) {
234 if ((priv->p !=
NULL) && (priv->recved <= SLIP_MAX_SIZE)) {
235 ((
u8_t *)priv->p->payload)[priv->i] = c;
238 if (priv->i >= priv->p->len) {
241 if (priv->p->next !=
NULL && priv->p->next->len > 0) {
243 priv->p = priv->p->next;
265 slipif_loop_thread(
void *nf)
268 struct netif *netif = (
struct netif *)nf;
271 p = slipif_input(netif, SLIP_BLOCK);
299 struct slipif_priv *priv;
304 priv =
mem_malloc(
sizeof(
struct slipif_priv));
309 netif->
name[0] =
's';
310 netif->
name[1] =
'l';
311 netif->
output = slipif_output;
312 netif->
mtu = SLIP_MAX_SIZE;
326 priv->state = SLIP_RECV_NORMAL;
353 struct slipif_priv *priv;
360 while ((p = slipif_input(netif, SLIP_DONTBLOCK)) !=
NULL) {