I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

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