NetTribute library with debug turned on in FShandler Donatien Garner -> Segundo Equipo -> this version

Committer:
hexley
Date:
Fri Nov 19 01:54:45 2010 +0000
Revision:
0:281d6ff68967

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hexley 0:281d6ff68967 1 /**
hexley 0:281d6ff68967 2 * @file
hexley 0:281d6ff68967 3 * SLIP Interface
hexley 0:281d6ff68967 4 *
hexley 0:281d6ff68967 5 */
hexley 0:281d6ff68967 6
hexley 0:281d6ff68967 7 /*
hexley 0:281d6ff68967 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
hexley 0:281d6ff68967 9 * All rights reserved.
hexley 0:281d6ff68967 10 *
hexley 0:281d6ff68967 11 * Redistribution and use in source and binary forms, with or without
hexley 0:281d6ff68967 12 * modification, are permitted provided that the following conditions
hexley 0:281d6ff68967 13 * are met:
hexley 0:281d6ff68967 14 * 1. Redistributions of source code must retain the above copyright
hexley 0:281d6ff68967 15 * notice, this list of conditions and the following disclaimer.
hexley 0:281d6ff68967 16 * 2. Redistributions in binary form must reproduce the above copyright
hexley 0:281d6ff68967 17 * notice, this list of conditions and the following disclaimer in the
hexley 0:281d6ff68967 18 * documentation and/or other materials provided with the distribution.
hexley 0:281d6ff68967 19 * 3. Neither the name of the Institute nor the names of its contributors
hexley 0:281d6ff68967 20 * may be used to endorse or promote products derived from this software
hexley 0:281d6ff68967 21 * without specific prior written permission.
hexley 0:281d6ff68967 22 *
hexley 0:281d6ff68967 23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
hexley 0:281d6ff68967 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
hexley 0:281d6ff68967 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
hexley 0:281d6ff68967 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
hexley 0:281d6ff68967 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
hexley 0:281d6ff68967 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
hexley 0:281d6ff68967 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
hexley 0:281d6ff68967 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
hexley 0:281d6ff68967 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
hexley 0:281d6ff68967 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
hexley 0:281d6ff68967 33 * SUCH DAMAGE.
hexley 0:281d6ff68967 34 *
hexley 0:281d6ff68967 35 * This file is built upon the file: src/arch/rtxc/netif/sioslip.c
hexley 0:281d6ff68967 36 *
hexley 0:281d6ff68967 37 * Author: Magnus Ivarsson <magnus.ivarsson(at)volvo.com>
hexley 0:281d6ff68967 38 */
hexley 0:281d6ff68967 39
hexley 0:281d6ff68967 40 /*
hexley 0:281d6ff68967 41 * This is an arch independent SLIP netif. The specific serial hooks must be
hexley 0:281d6ff68967 42 * provided by another file. They are sio_open, sio_read/sio_tryread and sio_send
hexley 0:281d6ff68967 43 */
hexley 0:281d6ff68967 44
hexley 0:281d6ff68967 45 #include "netif/slipif.h"
hexley 0:281d6ff68967 46 #include "lwip/opt.h"
hexley 0:281d6ff68967 47
hexley 0:281d6ff68967 48 #if LWIP_HAVE_SLIPIF
hexley 0:281d6ff68967 49
hexley 0:281d6ff68967 50 #include "lwip/def.h"
hexley 0:281d6ff68967 51 #include "lwip/pbuf.h"
hexley 0:281d6ff68967 52 #include "lwip/sys.h"
hexley 0:281d6ff68967 53 #include "lwip/stats.h"
hexley 0:281d6ff68967 54 #include "lwip/snmp.h"
hexley 0:281d6ff68967 55 #include "lwip/sio.h"
hexley 0:281d6ff68967 56
hexley 0:281d6ff68967 57 #define SLIP_BLOCK 1
hexley 0:281d6ff68967 58 #define SLIP_DONTBLOCK 0
hexley 0:281d6ff68967 59
hexley 0:281d6ff68967 60 #define SLIP_END 0300 /* 0xC0 */
hexley 0:281d6ff68967 61 #define SLIP_ESC 0333 /* 0xDB */
hexley 0:281d6ff68967 62 #define SLIP_ESC_END 0334 /* 0xDC */
hexley 0:281d6ff68967 63 #define SLIP_ESC_ESC 0335 /* 0xDD */
hexley 0:281d6ff68967 64
hexley 0:281d6ff68967 65 #define SLIP_MAX_SIZE 1500
hexley 0:281d6ff68967 66
hexley 0:281d6ff68967 67 enum slipif_recv_state {
hexley 0:281d6ff68967 68 SLIP_RECV_NORMAL,
hexley 0:281d6ff68967 69 SLIP_RECV_ESCAPE,
hexley 0:281d6ff68967 70 };
hexley 0:281d6ff68967 71
hexley 0:281d6ff68967 72 struct slipif_priv {
hexley 0:281d6ff68967 73 sio_fd_t sd;
hexley 0:281d6ff68967 74 /* q is the whole pbuf chain for a packet, p is the current pbuf in the chain */
hexley 0:281d6ff68967 75 struct pbuf *p, *q;
hexley 0:281d6ff68967 76 enum slipif_recv_state state;
hexley 0:281d6ff68967 77 u16_t i, recved;
hexley 0:281d6ff68967 78 };
hexley 0:281d6ff68967 79
hexley 0:281d6ff68967 80 /**
hexley 0:281d6ff68967 81 * Send a pbuf doing the necessary SLIP encapsulation
hexley 0:281d6ff68967 82 *
hexley 0:281d6ff68967 83 * Uses the serial layer's sio_send()
hexley 0:281d6ff68967 84 *
hexley 0:281d6ff68967 85 * @param netif the lwip network interface structure for this slipif
hexley 0:281d6ff68967 86 * @param p the pbuf chaing packet to send
hexley 0:281d6ff68967 87 * @param ipaddr the ip address to send the packet to (not used for slipif)
hexley 0:281d6ff68967 88 * @return always returns ERR_OK since the serial layer does not provide return values
hexley 0:281d6ff68967 89 */
hexley 0:281d6ff68967 90 err_t
hexley 0:281d6ff68967 91 slipif_output(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr)
hexley 0:281d6ff68967 92 {
hexley 0:281d6ff68967 93 struct slipif_priv *priv;
hexley 0:281d6ff68967 94 struct pbuf *q;
hexley 0:281d6ff68967 95 u16_t i;
hexley 0:281d6ff68967 96 u8_t c;
hexley 0:281d6ff68967 97
hexley 0:281d6ff68967 98 LWIP_ASSERT("netif != NULL", (netif != NULL));
hexley 0:281d6ff68967 99 LWIP_ASSERT("netif->state != NULL", (netif->state != NULL));
hexley 0:281d6ff68967 100 LWIP_ASSERT("p != NULL", (p != NULL));
hexley 0:281d6ff68967 101
hexley 0:281d6ff68967 102 LWIP_UNUSED_ARG(ipaddr);
hexley 0:281d6ff68967 103
hexley 0:281d6ff68967 104 priv = netif->state;
hexley 0:281d6ff68967 105
hexley 0:281d6ff68967 106 /* Send pbuf out on the serial I/O device. */
hexley 0:281d6ff68967 107 sio_send(SLIP_END, priv->sd);
hexley 0:281d6ff68967 108
hexley 0:281d6ff68967 109 for (q = p; q != NULL; q = q->next) {
hexley 0:281d6ff68967 110 for (i = 0; i < q->len; i++) {
hexley 0:281d6ff68967 111 c = ((u8_t *)q->payload)[i];
hexley 0:281d6ff68967 112 switch (c) {
hexley 0:281d6ff68967 113 case SLIP_END:
hexley 0:281d6ff68967 114 sio_send(SLIP_ESC, priv->sd);
hexley 0:281d6ff68967 115 sio_send(SLIP_ESC_END, priv->sd);
hexley 0:281d6ff68967 116 break;
hexley 0:281d6ff68967 117 case SLIP_ESC:
hexley 0:281d6ff68967 118 sio_send(SLIP_ESC, priv->sd);
hexley 0:281d6ff68967 119 sio_send(SLIP_ESC_ESC, priv->sd);
hexley 0:281d6ff68967 120 break;
hexley 0:281d6ff68967 121 default:
hexley 0:281d6ff68967 122 sio_send(c, priv->sd);
hexley 0:281d6ff68967 123 break;
hexley 0:281d6ff68967 124 }
hexley 0:281d6ff68967 125 }
hexley 0:281d6ff68967 126 }
hexley 0:281d6ff68967 127 sio_send(SLIP_END, priv->sd);
hexley 0:281d6ff68967 128 return ERR_OK;
hexley 0:281d6ff68967 129 }
hexley 0:281d6ff68967 130
hexley 0:281d6ff68967 131 /**
hexley 0:281d6ff68967 132 * Static function for easy use of blockig or non-blocking
hexley 0:281d6ff68967 133 * sio_read
hexley 0:281d6ff68967 134 *
hexley 0:281d6ff68967 135 * @param fd serial device handle
hexley 0:281d6ff68967 136 * @param data pointer to data buffer for receiving
hexley 0:281d6ff68967 137 * @param len maximum length (in bytes) of data to receive
hexley 0:281d6ff68967 138 * @param block if 1, call sio_read; if 0, call sio_tryread
hexley 0:281d6ff68967 139 * @return return value of sio_read of sio_tryread
hexley 0:281d6ff68967 140 */
hexley 0:281d6ff68967 141 static u32_t
hexley 0:281d6ff68967 142 slip_sio_read(sio_fd_t fd, u8_t* data, u32_t len, u8_t block)
hexley 0:281d6ff68967 143 {
hexley 0:281d6ff68967 144 if (block) {
hexley 0:281d6ff68967 145 return sio_read(fd, data, len);
hexley 0:281d6ff68967 146 } else {
hexley 0:281d6ff68967 147 return sio_tryread(fd, data, len);
hexley 0:281d6ff68967 148 }
hexley 0:281d6ff68967 149 }
hexley 0:281d6ff68967 150
hexley 0:281d6ff68967 151 /**
hexley 0:281d6ff68967 152 * Handle the incoming SLIP stream character by character
hexley 0:281d6ff68967 153 *
hexley 0:281d6ff68967 154 * Poll the serial layer by calling sio_read() or sio_tryread().
hexley 0:281d6ff68967 155 *
hexley 0:281d6ff68967 156 * @param netif the lwip network interface structure for this slipif
hexley 0:281d6ff68967 157 * @param block if 1, block until data is received; if 0, return when all data
hexley 0:281d6ff68967 158 * from the buffer is received (multiple calls to this function will
hexley 0:281d6ff68967 159 * return a complete packet, NULL is returned before - used for polling)
hexley 0:281d6ff68967 160 * @return The IP packet when SLIP_END is received
hexley 0:281d6ff68967 161 */
hexley 0:281d6ff68967 162 static struct pbuf *
hexley 0:281d6ff68967 163 slipif_input(struct netif *netif, u8_t block)
hexley 0:281d6ff68967 164 {
hexley 0:281d6ff68967 165 struct slipif_priv *priv;
hexley 0:281d6ff68967 166 u8_t c;
hexley 0:281d6ff68967 167 struct pbuf *t;
hexley 0:281d6ff68967 168
hexley 0:281d6ff68967 169 LWIP_ASSERT("netif != NULL", (netif != NULL));
hexley 0:281d6ff68967 170 LWIP_ASSERT("netif->state != NULL", (netif->state != NULL));
hexley 0:281d6ff68967 171
hexley 0:281d6ff68967 172 priv = netif->state;
hexley 0:281d6ff68967 173
hexley 0:281d6ff68967 174 while (slip_sio_read(priv->sd, &c, 1, block) > 0) {
hexley 0:281d6ff68967 175 switch (priv->state) {
hexley 0:281d6ff68967 176 case SLIP_RECV_NORMAL:
hexley 0:281d6ff68967 177 switch (c) {
hexley 0:281d6ff68967 178 case SLIP_END:
hexley 0:281d6ff68967 179 if (priv->recved > 0) {
hexley 0:281d6ff68967 180 /* Received whole packet. */
hexley 0:281d6ff68967 181 /* Trim the pbuf to the size of the received packet. */
hexley 0:281d6ff68967 182 pbuf_realloc(priv->q, priv->recved);
hexley 0:281d6ff68967 183
hexley 0:281d6ff68967 184 LINK_STATS_INC(link.recv);
hexley 0:281d6ff68967 185
hexley 0:281d6ff68967 186 LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n"));
hexley 0:281d6ff68967 187 t = priv->q;
hexley 0:281d6ff68967 188 priv->p = priv->q = NULL;
hexley 0:281d6ff68967 189 priv->i = priv->recved = 0;
hexley 0:281d6ff68967 190 return t;
hexley 0:281d6ff68967 191 }
hexley 0:281d6ff68967 192 continue;
hexley 0:281d6ff68967 193 case SLIP_ESC:
hexley 0:281d6ff68967 194 priv->state = SLIP_RECV_ESCAPE;
hexley 0:281d6ff68967 195 continue;
hexley 0:281d6ff68967 196 }
hexley 0:281d6ff68967 197 break;
hexley 0:281d6ff68967 198 case SLIP_RECV_ESCAPE:
hexley 0:281d6ff68967 199 switch (c) {
hexley 0:281d6ff68967 200 case SLIP_ESC_END:
hexley 0:281d6ff68967 201 c = SLIP_END;
hexley 0:281d6ff68967 202 break;
hexley 0:281d6ff68967 203 case SLIP_ESC_ESC:
hexley 0:281d6ff68967 204 c = SLIP_ESC;
hexley 0:281d6ff68967 205 break;
hexley 0:281d6ff68967 206 }
hexley 0:281d6ff68967 207 priv->state = SLIP_RECV_NORMAL;
hexley 0:281d6ff68967 208 /* FALLTHROUGH */
hexley 0:281d6ff68967 209 }
hexley 0:281d6ff68967 210
hexley 0:281d6ff68967 211 /* byte received, packet not yet completely received */
hexley 0:281d6ff68967 212 if (priv->p == NULL) {
hexley 0:281d6ff68967 213 /* allocate a new pbuf */
hexley 0:281d6ff68967 214 LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n"));
hexley 0:281d6ff68967 215 priv->p = pbuf_alloc(PBUF_LINK, (PBUF_POOL_BUFSIZE - PBUF_LINK_HLEN), PBUF_POOL);
hexley 0:281d6ff68967 216
hexley 0:281d6ff68967 217 if (priv->p == NULL) {
hexley 0:281d6ff68967 218 LINK_STATS_INC(link.drop);
hexley 0:281d6ff68967 219 LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n"));
hexley 0:281d6ff68967 220 /* don't process any further since we got no pbuf to receive to */
hexley 0:281d6ff68967 221 break;
hexley 0:281d6ff68967 222 }
hexley 0:281d6ff68967 223
hexley 0:281d6ff68967 224 if (priv->q != NULL) {
hexley 0:281d6ff68967 225 /* 'chain' the pbuf to the existing chain */
hexley 0:281d6ff68967 226 pbuf_cat(priv->q, priv->p);
hexley 0:281d6ff68967 227 } else {
hexley 0:281d6ff68967 228 /* p is the first pbuf in the chain */
hexley 0:281d6ff68967 229 priv->q = priv->p;
hexley 0:281d6ff68967 230 }
hexley 0:281d6ff68967 231 }
hexley 0:281d6ff68967 232
hexley 0:281d6ff68967 233 /* this automatically drops bytes if > SLIP_MAX_SIZE */
hexley 0:281d6ff68967 234 if ((priv->p != NULL) && (priv->recved <= SLIP_MAX_SIZE)) {
hexley 0:281d6ff68967 235 ((u8_t *)priv->p->payload)[priv->i] = c;
hexley 0:281d6ff68967 236 priv->recved++;
hexley 0:281d6ff68967 237 priv->i++;
hexley 0:281d6ff68967 238 if (priv->i >= priv->p->len) {
hexley 0:281d6ff68967 239 /* on to the next pbuf */
hexley 0:281d6ff68967 240 priv->i = 0;
hexley 0:281d6ff68967 241 if (priv->p->next != NULL && priv->p->next->len > 0) {
hexley 0:281d6ff68967 242 /* p is a chain, on to the next in the chain */
hexley 0:281d6ff68967 243 priv->p = priv->p->next;
hexley 0:281d6ff68967 244 } else {
hexley 0:281d6ff68967 245 /* p is a single pbuf, set it to NULL so next time a new
hexley 0:281d6ff68967 246 * pbuf is allocated */
hexley 0:281d6ff68967 247 priv->p = NULL;
hexley 0:281d6ff68967 248 }
hexley 0:281d6ff68967 249 }
hexley 0:281d6ff68967 250 }
hexley 0:281d6ff68967 251 }
hexley 0:281d6ff68967 252
hexley 0:281d6ff68967 253 return NULL;
hexley 0:281d6ff68967 254 }
hexley 0:281d6ff68967 255
hexley 0:281d6ff68967 256 #if !NO_SYS
hexley 0:281d6ff68967 257 /**
hexley 0:281d6ff68967 258 * The SLIP input thread.
hexley 0:281d6ff68967 259 *
hexley 0:281d6ff68967 260 * Feed the IP layer with incoming packets
hexley 0:281d6ff68967 261 *
hexley 0:281d6ff68967 262 * @param nf the lwip network interface structure for this slipif
hexley 0:281d6ff68967 263 */
hexley 0:281d6ff68967 264 static void
hexley 0:281d6ff68967 265 slipif_loop_thread(void *nf)
hexley 0:281d6ff68967 266 {
hexley 0:281d6ff68967 267 struct pbuf *p;
hexley 0:281d6ff68967 268 struct netif *netif = (struct netif *)nf;
hexley 0:281d6ff68967 269
hexley 0:281d6ff68967 270 while (1) {
hexley 0:281d6ff68967 271 p = slipif_input(netif, SLIP_BLOCK);
hexley 0:281d6ff68967 272 if (p != NULL) {
hexley 0:281d6ff68967 273 if (netif->input(p, netif) != ERR_OK) {
hexley 0:281d6ff68967 274 pbuf_free(p);
hexley 0:281d6ff68967 275 p = NULL;
hexley 0:281d6ff68967 276 }
hexley 0:281d6ff68967 277 }
hexley 0:281d6ff68967 278 }
hexley 0:281d6ff68967 279 }
hexley 0:281d6ff68967 280 #endif /* !NO_SYS */
hexley 0:281d6ff68967 281
hexley 0:281d6ff68967 282 /**
hexley 0:281d6ff68967 283 * SLIP netif initialization
hexley 0:281d6ff68967 284 *
hexley 0:281d6ff68967 285 * Call the arch specific sio_open and remember
hexley 0:281d6ff68967 286 * the opened device in the state field of the netif.
hexley 0:281d6ff68967 287 *
hexley 0:281d6ff68967 288 * @param netif the lwip network interface structure for this slipif
hexley 0:281d6ff68967 289 * @return ERR_OK if serial line could be opened,
hexley 0:281d6ff68967 290 * ERR_MEM if no memory could be allocated,
hexley 0:281d6ff68967 291 * ERR_IF is serial line couldn't be opened
hexley 0:281d6ff68967 292 *
hexley 0:281d6ff68967 293 * @note netif->num must contain the number of the serial port to open
hexley 0:281d6ff68967 294 * (0 by default)
hexley 0:281d6ff68967 295 */
hexley 0:281d6ff68967 296 err_t
hexley 0:281d6ff68967 297 slipif_init(struct netif *netif)
hexley 0:281d6ff68967 298 {
hexley 0:281d6ff68967 299 struct slipif_priv *priv;
hexley 0:281d6ff68967 300
hexley 0:281d6ff68967 301 LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%"U16_F"\n", (u16_t)netif->num));
hexley 0:281d6ff68967 302
hexley 0:281d6ff68967 303 /* Allocate private data */
hexley 0:281d6ff68967 304 priv = mem_malloc(sizeof(struct slipif_priv));
hexley 0:281d6ff68967 305 if (!priv) {
hexley 0:281d6ff68967 306 return ERR_MEM;
hexley 0:281d6ff68967 307 }
hexley 0:281d6ff68967 308
hexley 0:281d6ff68967 309 netif->name[0] = 's';
hexley 0:281d6ff68967 310 netif->name[1] = 'l';
hexley 0:281d6ff68967 311 netif->output = slipif_output;
hexley 0:281d6ff68967 312 netif->mtu = SLIP_MAX_SIZE;
hexley 0:281d6ff68967 313 netif->flags |= NETIF_FLAG_POINTTOPOINT;
hexley 0:281d6ff68967 314
hexley 0:281d6ff68967 315 /* Try to open the serial port (netif->num contains the port number). */
hexley 0:281d6ff68967 316 priv->sd = sio_open(netif->num);
hexley 0:281d6ff68967 317 if (!priv->sd) {
hexley 0:281d6ff68967 318 /* Opening the serial port failed. */
hexley 0:281d6ff68967 319 mem_free(priv);
hexley 0:281d6ff68967 320 return ERR_IF;
hexley 0:281d6ff68967 321 }
hexley 0:281d6ff68967 322
hexley 0:281d6ff68967 323 /* Initialize private data */
hexley 0:281d6ff68967 324 priv->p = NULL;
hexley 0:281d6ff68967 325 priv->q = NULL;
hexley 0:281d6ff68967 326 priv->state = SLIP_RECV_NORMAL;
hexley 0:281d6ff68967 327 priv->i = 0;
hexley 0:281d6ff68967 328 priv->recved = 0;
hexley 0:281d6ff68967 329
hexley 0:281d6ff68967 330 netif->state = priv;
hexley 0:281d6ff68967 331
hexley 0:281d6ff68967 332 /* initialize the snmp variables and counters inside the struct netif
hexley 0:281d6ff68967 333 * ifSpeed: no assumption can be made without knowing more about the
hexley 0:281d6ff68967 334 * serial line!
hexley 0:281d6ff68967 335 */
hexley 0:281d6ff68967 336 NETIF_INIT_SNMP(netif, snmp_ifType_slip, 0);
hexley 0:281d6ff68967 337
hexley 0:281d6ff68967 338 /* Create a thread to poll the serial line. */
hexley 0:281d6ff68967 339 sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop_thread, netif,
hexley 0:281d6ff68967 340 SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO);
hexley 0:281d6ff68967 341 return ERR_OK;
hexley 0:281d6ff68967 342 }
hexley 0:281d6ff68967 343
hexley 0:281d6ff68967 344 /**
hexley 0:281d6ff68967 345 * Polls the serial device and feeds the IP layer with incoming packets.
hexley 0:281d6ff68967 346 *
hexley 0:281d6ff68967 347 * @param netif The lwip network interface structure for this slipif
hexley 0:281d6ff68967 348 */
hexley 0:281d6ff68967 349 void
hexley 0:281d6ff68967 350 slipif_poll(struct netif *netif)
hexley 0:281d6ff68967 351 {
hexley 0:281d6ff68967 352 struct pbuf *p;
hexley 0:281d6ff68967 353 struct slipif_priv *priv;
hexley 0:281d6ff68967 354
hexley 0:281d6ff68967 355 LWIP_ASSERT("netif != NULL", (netif != NULL));
hexley 0:281d6ff68967 356 LWIP_ASSERT("netif->state != NULL", (netif->state != NULL));
hexley 0:281d6ff68967 357
hexley 0:281d6ff68967 358 priv = netif->state;
hexley 0:281d6ff68967 359
hexley 0:281d6ff68967 360 while ((p = slipif_input(netif, SLIP_DONTBLOCK)) != NULL) {
hexley 0:281d6ff68967 361 if (netif->input(p, netif) != ERR_OK) {
hexley 0:281d6ff68967 362 pbuf_free(p);
hexley 0:281d6ff68967 363 }
hexley 0:281d6ff68967 364 }
hexley 0:281d6ff68967 365 }
hexley 0:281d6ff68967 366
hexley 0:281d6ff68967 367 #endif /* LWIP_HAVE_SLIPIF */