EthernetNetIf Compatibility.

Dependents:   XBeeWiFi_SPI_example

Fork of NetServicesSource by Donatien Garnier

Committer:
donatien
Date:
Tue Jul 27 15:59:42 2010 +0000
Revision:
5:dd63a1e02b1b
Parent:
0:632c9925f013

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:632c9925f013 1 /**
donatien 0:632c9925f013 2 * @file
donatien 0:632c9925f013 3 * Implementation of raw protocol PCBs for low-level handling of
donatien 0:632c9925f013 4 * different types of protocols besides (or overriding) those
donatien 0:632c9925f013 5 * already available in lwIP.
donatien 0:632c9925f013 6 *
donatien 0:632c9925f013 7 */
donatien 0:632c9925f013 8
donatien 0:632c9925f013 9 /*
donatien 0:632c9925f013 10 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
donatien 0:632c9925f013 11 * All rights reserved.
donatien 0:632c9925f013 12 *
donatien 0:632c9925f013 13 * Redistribution and use in source and binary forms, with or without modification,
donatien 0:632c9925f013 14 * are permitted provided that the following conditions are met:
donatien 0:632c9925f013 15 *
donatien 0:632c9925f013 16 * 1. Redistributions of source code must retain the above copyright notice,
donatien 0:632c9925f013 17 * this list of conditions and the following disclaimer.
donatien 0:632c9925f013 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
donatien 0:632c9925f013 19 * this list of conditions and the following disclaimer in the documentation
donatien 0:632c9925f013 20 * and/or other materials provided with the distribution.
donatien 0:632c9925f013 21 * 3. The name of the author may not be used to endorse or promote products
donatien 0:632c9925f013 22 * derived from this software without specific prior written permission.
donatien 0:632c9925f013 23 *
donatien 0:632c9925f013 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
donatien 0:632c9925f013 25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
donatien 0:632c9925f013 26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
donatien 0:632c9925f013 27 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
donatien 0:632c9925f013 28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
donatien 0:632c9925f013 29 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
donatien 0:632c9925f013 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
donatien 0:632c9925f013 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
donatien 0:632c9925f013 32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
donatien 0:632c9925f013 33 * OF SUCH DAMAGE.
donatien 0:632c9925f013 34 *
donatien 0:632c9925f013 35 * This file is part of the lwIP TCP/IP stack.
donatien 0:632c9925f013 36 *
donatien 0:632c9925f013 37 * Author: Adam Dunkels <adam@sics.se>
donatien 0:632c9925f013 38 *
donatien 0:632c9925f013 39 */
donatien 0:632c9925f013 40
donatien 0:632c9925f013 41 #include "lwip/opt.h"
donatien 0:632c9925f013 42
donatien 0:632c9925f013 43 #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
donatien 0:632c9925f013 44
donatien 0:632c9925f013 45 #include "lwip/def.h"
donatien 0:632c9925f013 46 #include "lwip/memp.h"
donatien 0:632c9925f013 47 #include "lwip/ip_addr.h"
donatien 0:632c9925f013 48 #include "lwip/netif.h"
donatien 0:632c9925f013 49 #include "lwip/raw.h"
donatien 0:632c9925f013 50 #include "lwip/stats.h"
donatien 0:632c9925f013 51 #include "arch/perf.h"
donatien 0:632c9925f013 52
donatien 0:632c9925f013 53 #include <string.h>
donatien 0:632c9925f013 54
donatien 0:632c9925f013 55 /** The list of RAW PCBs */
donatien 0:632c9925f013 56 static struct raw_pcb *raw_pcbs;
donatien 0:632c9925f013 57
donatien 0:632c9925f013 58 /**
donatien 0:632c9925f013 59 * Determine if in incoming IP packet is covered by a RAW PCB
donatien 0:632c9925f013 60 * and if so, pass it to a user-provided receive callback function.
donatien 0:632c9925f013 61 *
donatien 0:632c9925f013 62 * Given an incoming IP datagram (as a chain of pbufs) this function
donatien 0:632c9925f013 63 * finds a corresponding RAW PCB and calls the corresponding receive
donatien 0:632c9925f013 64 * callback function.
donatien 0:632c9925f013 65 *
donatien 0:632c9925f013 66 * @param p pbuf to be demultiplexed to a RAW PCB.
donatien 0:632c9925f013 67 * @param inp network interface on which the datagram was received.
donatien 0:632c9925f013 68 * @return - 1 if the packet has been eaten by a RAW PCB receive
donatien 0:632c9925f013 69 * callback function. The caller MAY NOT not reference the
donatien 0:632c9925f013 70 * packet any longer, and MAY NOT call pbuf_free().
donatien 0:632c9925f013 71 * @return - 0 if packet is not eaten (pbuf is still referenced by the
donatien 0:632c9925f013 72 * caller).
donatien 0:632c9925f013 73 *
donatien 0:632c9925f013 74 */
donatien 0:632c9925f013 75 u8_t
donatien 0:632c9925f013 76 raw_input(struct pbuf *p, struct netif *inp)
donatien 0:632c9925f013 77 {
donatien 0:632c9925f013 78 struct raw_pcb *pcb, *prev;
donatien 0:632c9925f013 79 struct ip_hdr *iphdr;
donatien 0:632c9925f013 80 s16_t proto;
donatien 0:632c9925f013 81 u8_t eaten = 0;
donatien 0:632c9925f013 82
donatien 0:632c9925f013 83 LWIP_UNUSED_ARG(inp);
donatien 0:632c9925f013 84
donatien 0:632c9925f013 85 iphdr = (struct ip_hdr *)p->payload;
donatien 0:632c9925f013 86 proto = IPH_PROTO(iphdr);
donatien 0:632c9925f013 87
donatien 0:632c9925f013 88 prev = NULL;
donatien 0:632c9925f013 89 pcb = raw_pcbs;
donatien 0:632c9925f013 90 /* loop through all raw pcbs until the packet is eaten by one */
donatien 0:632c9925f013 91 /* this allows multiple pcbs to match against the packet by design */
donatien 0:632c9925f013 92 while ((eaten == 0) && (pcb != NULL)) {
donatien 0:632c9925f013 93 if ((pcb->protocol == proto) &&
donatien 0:632c9925f013 94 (ip_addr_isany(&pcb->local_ip) ||
donatien 5:dd63a1e02b1b 95 ip_addr_cmp(&(pcb->local_ip), &current_iphdr_dest))) {
donatien 0:632c9925f013 96 #if IP_SOF_BROADCAST_RECV
donatien 0:632c9925f013 97 /* broadcast filter? */
donatien 5:dd63a1e02b1b 98 if ((pcb->so_options & SOF_BROADCAST) || !ip_addr_isbroadcast(&current_iphdr_dest, inp))
donatien 0:632c9925f013 99 #endif /* IP_SOF_BROADCAST_RECV */
donatien 0:632c9925f013 100 {
donatien 0:632c9925f013 101 /* receive callback function available? */
donatien 0:632c9925f013 102 if (pcb->recv != NULL) {
donatien 0:632c9925f013 103 /* the receive callback function did not eat the packet? */
donatien 5:dd63a1e02b1b 104 if (pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr()) != 0) {
donatien 0:632c9925f013 105 /* receive function ate the packet */
donatien 0:632c9925f013 106 p = NULL;
donatien 0:632c9925f013 107 eaten = 1;
donatien 0:632c9925f013 108 if (prev != NULL) {
donatien 0:632c9925f013 109 /* move the pcb to the front of raw_pcbs so that is
donatien 0:632c9925f013 110 found faster next time */
donatien 0:632c9925f013 111 prev->next = pcb->next;
donatien 0:632c9925f013 112 pcb->next = raw_pcbs;
donatien 0:632c9925f013 113 raw_pcbs = pcb;
donatien 0:632c9925f013 114 }
donatien 0:632c9925f013 115 }
donatien 0:632c9925f013 116 }
donatien 0:632c9925f013 117 /* no receive callback function was set for this raw PCB */
donatien 0:632c9925f013 118 }
donatien 0:632c9925f013 119 /* drop the packet */
donatien 0:632c9925f013 120 }
donatien 0:632c9925f013 121 prev = pcb;
donatien 0:632c9925f013 122 pcb = pcb->next;
donatien 0:632c9925f013 123 }
donatien 0:632c9925f013 124 return eaten;
donatien 0:632c9925f013 125 }
donatien 0:632c9925f013 126
donatien 0:632c9925f013 127 /**
donatien 0:632c9925f013 128 * Bind a RAW PCB.
donatien 0:632c9925f013 129 *
donatien 0:632c9925f013 130 * @param pcb RAW PCB to be bound with a local address ipaddr.
donatien 0:632c9925f013 131 * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to
donatien 0:632c9925f013 132 * bind to all local interfaces.
donatien 0:632c9925f013 133 *
donatien 0:632c9925f013 134 * @return lwIP error code.
donatien 0:632c9925f013 135 * - ERR_OK. Successful. No error occured.
donatien 0:632c9925f013 136 * - ERR_USE. The specified IP address is already bound to by
donatien 0:632c9925f013 137 * another RAW PCB.
donatien 0:632c9925f013 138 *
donatien 0:632c9925f013 139 * @see raw_disconnect()
donatien 0:632c9925f013 140 */
donatien 0:632c9925f013 141 err_t
donatien 0:632c9925f013 142 raw_bind(struct raw_pcb *pcb, ip_addr_t *ipaddr)
donatien 0:632c9925f013 143 {
donatien 0:632c9925f013 144 ip_addr_set(&pcb->local_ip, ipaddr);
donatien 0:632c9925f013 145 return ERR_OK;
donatien 0:632c9925f013 146 }
donatien 0:632c9925f013 147
donatien 0:632c9925f013 148 /**
donatien 0:632c9925f013 149 * Connect an RAW PCB. This function is required by upper layers
donatien 0:632c9925f013 150 * of lwip. Using the raw api you could use raw_sendto() instead
donatien 0:632c9925f013 151 *
donatien 0:632c9925f013 152 * This will associate the RAW PCB with the remote address.
donatien 0:632c9925f013 153 *
donatien 0:632c9925f013 154 * @param pcb RAW PCB to be connected with remote address ipaddr and port.
donatien 0:632c9925f013 155 * @param ipaddr remote IP address to connect with.
donatien 0:632c9925f013 156 *
donatien 0:632c9925f013 157 * @return lwIP error code
donatien 0:632c9925f013 158 *
donatien 0:632c9925f013 159 * @see raw_disconnect() and raw_sendto()
donatien 0:632c9925f013 160 */
donatien 0:632c9925f013 161 err_t
donatien 0:632c9925f013 162 raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr)
donatien 0:632c9925f013 163 {
donatien 0:632c9925f013 164 ip_addr_set(&pcb->remote_ip, ipaddr);
donatien 0:632c9925f013 165 return ERR_OK;
donatien 0:632c9925f013 166 }
donatien 0:632c9925f013 167
donatien 0:632c9925f013 168
donatien 0:632c9925f013 169 /**
donatien 0:632c9925f013 170 * Set the callback function for received packets that match the
donatien 0:632c9925f013 171 * raw PCB's protocol and binding.
donatien 0:632c9925f013 172 *
donatien 0:632c9925f013 173 * The callback function MUST either
donatien 0:632c9925f013 174 * - eat the packet by calling pbuf_free() and returning non-zero. The
donatien 0:632c9925f013 175 * packet will not be passed to other raw PCBs or other protocol layers.
donatien 0:632c9925f013 176 * - not free the packet, and return zero. The packet will be matched
donatien 0:632c9925f013 177 * against further PCBs and/or forwarded to another protocol layers.
donatien 0:632c9925f013 178 *
donatien 0:632c9925f013 179 * @return non-zero if the packet was free()d, zero if the packet remains
donatien 0:632c9925f013 180 * available for others.
donatien 0:632c9925f013 181 */
donatien 0:632c9925f013 182 void
donatien 0:632c9925f013 183 raw_recv(struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg)
donatien 0:632c9925f013 184 {
donatien 0:632c9925f013 185 /* remember recv() callback and user data */
donatien 0:632c9925f013 186 pcb->recv = recv;
donatien 0:632c9925f013 187 pcb->recv_arg = recv_arg;
donatien 0:632c9925f013 188 }
donatien 0:632c9925f013 189
donatien 0:632c9925f013 190 /**
donatien 0:632c9925f013 191 * Send the raw IP packet to the given address. Note that actually you cannot
donatien 0:632c9925f013 192 * modify the IP headers (this is inconsistent with the receive callback where
donatien 0:632c9925f013 193 * you actually get the IP headers), you can only specify the IP payload here.
donatien 0:632c9925f013 194 * It requires some more changes in lwIP. (there will be a raw_send() function
donatien 0:632c9925f013 195 * then.)
donatien 0:632c9925f013 196 *
donatien 0:632c9925f013 197 * @param pcb the raw pcb which to send
donatien 0:632c9925f013 198 * @param p the IP payload to send
donatien 0:632c9925f013 199 * @param ipaddr the destination address of the IP packet
donatien 0:632c9925f013 200 *
donatien 0:632c9925f013 201 */
donatien 0:632c9925f013 202 err_t
donatien 0:632c9925f013 203 raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)
donatien 0:632c9925f013 204 {
donatien 0:632c9925f013 205 err_t err;
donatien 0:632c9925f013 206 struct netif *netif;
donatien 0:632c9925f013 207 ip_addr_t *src_ip;
donatien 0:632c9925f013 208 struct pbuf *q; /* q will be sent down the stack */
donatien 0:632c9925f013 209
donatien 0:632c9925f013 210 LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\n"));
donatien 0:632c9925f013 211
donatien 0:632c9925f013 212 /* not enough space to add an IP header to first pbuf in given p chain? */
donatien 0:632c9925f013 213 if (pbuf_header(p, IP_HLEN)) {
donatien 0:632c9925f013 214 /* allocate header in new pbuf */
donatien 0:632c9925f013 215 q = pbuf_alloc(PBUF_IP, 0, PBUF_RAM);
donatien 0:632c9925f013 216 /* new header pbuf could not be allocated? */
donatien 0:632c9925f013 217 if (q == NULL) {
donatien 0:632c9925f013 218 LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("raw_sendto: could not allocate header\n"));
donatien 0:632c9925f013 219 return ERR_MEM;
donatien 0:632c9925f013 220 }
donatien 0:632c9925f013 221 /* chain header q in front of given pbuf p */
donatien 0:632c9925f013 222 pbuf_chain(q, p);
donatien 0:632c9925f013 223 /* { first pbuf q points to header pbuf } */
donatien 0:632c9925f013 224 LWIP_DEBUGF(RAW_DEBUG, ("raw_sendto: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p));
donatien 0:632c9925f013 225 } else {
donatien 0:632c9925f013 226 /* first pbuf q equals given pbuf */
donatien 0:632c9925f013 227 q = p;
donatien 0:632c9925f013 228 if(pbuf_header(q, -IP_HLEN)) {
donatien 0:632c9925f013 229 LWIP_ASSERT("Can't restore header we just removed!", 0);
donatien 0:632c9925f013 230 return ERR_MEM;
donatien 0:632c9925f013 231 }
donatien 0:632c9925f013 232 }
donatien 0:632c9925f013 233
donatien 0:632c9925f013 234 if ((netif = ip_route(ipaddr)) == NULL) {
donatien 0:632c9925f013 235 LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
donatien 0:632c9925f013 236 ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr)));
donatien 0:632c9925f013 237 /* free any temporary header pbuf allocated by pbuf_header() */
donatien 0:632c9925f013 238 if (q != p) {
donatien 0:632c9925f013 239 pbuf_free(q);
donatien 0:632c9925f013 240 }
donatien 0:632c9925f013 241 return ERR_RTE;
donatien 0:632c9925f013 242 }
donatien 0:632c9925f013 243
donatien 0:632c9925f013 244 #if IP_SOF_BROADCAST
donatien 0:632c9925f013 245 /* broadcast filter? */
donatien 0:632c9925f013 246 if (((pcb->so_options & SOF_BROADCAST) == 0) && ip_addr_isbroadcast(ipaddr, netif)) {
donatien 0:632c9925f013 247 LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb));
donatien 0:632c9925f013 248 /* free any temporary header pbuf allocated by pbuf_header() */
donatien 0:632c9925f013 249 if (q != p) {
donatien 0:632c9925f013 250 pbuf_free(q);
donatien 0:632c9925f013 251 }
donatien 0:632c9925f013 252 return ERR_VAL;
donatien 0:632c9925f013 253 }
donatien 0:632c9925f013 254 #endif /* IP_SOF_BROADCAST */
donatien 0:632c9925f013 255
donatien 0:632c9925f013 256 if (ip_addr_isany(&pcb->local_ip)) {
donatien 0:632c9925f013 257 /* use outgoing network interface IP address as source address */
donatien 0:632c9925f013 258 src_ip = &(netif->ip_addr);
donatien 0:632c9925f013 259 } else {
donatien 0:632c9925f013 260 /* use RAW PCB local IP address as source address */
donatien 0:632c9925f013 261 src_ip = &(pcb->local_ip);
donatien 0:632c9925f013 262 }
donatien 0:632c9925f013 263
donatien 0:632c9925f013 264 #if LWIP_NETIF_HWADDRHINT
donatien 0:632c9925f013 265 netif->addr_hint = &(pcb->addr_hint);
donatien 0:632c9925f013 266 #endif /* LWIP_NETIF_HWADDRHINT*/
donatien 0:632c9925f013 267 err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif);
donatien 0:632c9925f013 268 #if LWIP_NETIF_HWADDRHINT
donatien 0:632c9925f013 269 netif->addr_hint = NULL;
donatien 0:632c9925f013 270 #endif /* LWIP_NETIF_HWADDRHINT*/
donatien 0:632c9925f013 271
donatien 0:632c9925f013 272 /* did we chain a header earlier? */
donatien 0:632c9925f013 273 if (q != p) {
donatien 0:632c9925f013 274 /* free the header */
donatien 0:632c9925f013 275 pbuf_free(q);
donatien 0:632c9925f013 276 }
donatien 0:632c9925f013 277 return err;
donatien 0:632c9925f013 278 }
donatien 0:632c9925f013 279
donatien 0:632c9925f013 280 /**
donatien 0:632c9925f013 281 * Send the raw IP packet to the address given by raw_connect()
donatien 0:632c9925f013 282 *
donatien 0:632c9925f013 283 * @param pcb the raw pcb which to send
donatien 0:632c9925f013 284 * @param p the IP payload to send
donatien 0:632c9925f013 285 *
donatien 0:632c9925f013 286 */
donatien 0:632c9925f013 287 err_t
donatien 0:632c9925f013 288 raw_send(struct raw_pcb *pcb, struct pbuf *p)
donatien 0:632c9925f013 289 {
donatien 0:632c9925f013 290 return raw_sendto(pcb, p, &pcb->remote_ip);
donatien 0:632c9925f013 291 }
donatien 0:632c9925f013 292
donatien 0:632c9925f013 293 /**
donatien 0:632c9925f013 294 * Remove an RAW PCB.
donatien 0:632c9925f013 295 *
donatien 0:632c9925f013 296 * @param pcb RAW PCB to be removed. The PCB is removed from the list of
donatien 0:632c9925f013 297 * RAW PCB's and the data structure is freed from memory.
donatien 0:632c9925f013 298 *
donatien 0:632c9925f013 299 * @see raw_new()
donatien 0:632c9925f013 300 */
donatien 0:632c9925f013 301 void
donatien 0:632c9925f013 302 raw_remove(struct raw_pcb *pcb)
donatien 0:632c9925f013 303 {
donatien 0:632c9925f013 304 struct raw_pcb *pcb2;
donatien 0:632c9925f013 305 /* pcb to be removed is first in list? */
donatien 0:632c9925f013 306 if (raw_pcbs == pcb) {
donatien 0:632c9925f013 307 /* make list start at 2nd pcb */
donatien 0:632c9925f013 308 raw_pcbs = raw_pcbs->next;
donatien 0:632c9925f013 309 /* pcb not 1st in list */
donatien 0:632c9925f013 310 } else {
donatien 0:632c9925f013 311 for(pcb2 = raw_pcbs; pcb2 != NULL; pcb2 = pcb2->next) {
donatien 0:632c9925f013 312 /* find pcb in raw_pcbs list */
donatien 0:632c9925f013 313 if (pcb2->next != NULL && pcb2->next == pcb) {
donatien 0:632c9925f013 314 /* remove pcb from list */
donatien 0:632c9925f013 315 pcb2->next = pcb->next;
donatien 0:632c9925f013 316 }
donatien 0:632c9925f013 317 }
donatien 0:632c9925f013 318 }
donatien 0:632c9925f013 319 memp_free(MEMP_RAW_PCB, pcb);
donatien 0:632c9925f013 320 }
donatien 0:632c9925f013 321
donatien 0:632c9925f013 322 /**
donatien 0:632c9925f013 323 * Create a RAW PCB.
donatien 0:632c9925f013 324 *
donatien 0:632c9925f013 325 * @return The RAW PCB which was created. NULL if the PCB data structure
donatien 0:632c9925f013 326 * could not be allocated.
donatien 0:632c9925f013 327 *
donatien 0:632c9925f013 328 * @param proto the protocol number of the IPs payload (e.g. IP_PROTO_ICMP)
donatien 0:632c9925f013 329 *
donatien 0:632c9925f013 330 * @see raw_remove()
donatien 0:632c9925f013 331 */
donatien 0:632c9925f013 332 struct raw_pcb *
donatien 0:632c9925f013 333 raw_new(u8_t proto)
donatien 0:632c9925f013 334 {
donatien 0:632c9925f013 335 struct raw_pcb *pcb;
donatien 0:632c9925f013 336
donatien 0:632c9925f013 337 LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_new\n"));
donatien 0:632c9925f013 338
donatien 0:632c9925f013 339 pcb = (struct raw_pcb *)memp_malloc(MEMP_RAW_PCB);
donatien 0:632c9925f013 340 /* could allocate RAW PCB? */
donatien 0:632c9925f013 341 if (pcb != NULL) {
donatien 0:632c9925f013 342 /* initialize PCB to all zeroes */
donatien 0:632c9925f013 343 memset(pcb, 0, sizeof(struct raw_pcb));
donatien 0:632c9925f013 344 pcb->protocol = proto;
donatien 0:632c9925f013 345 pcb->ttl = RAW_TTL;
donatien 0:632c9925f013 346 pcb->next = raw_pcbs;
donatien 0:632c9925f013 347 raw_pcbs = pcb;
donatien 0:632c9925f013 348 }
donatien 0:632c9925f013 349 return pcb;
donatien 0:632c9925f013 350 }
donatien 0:632c9925f013 351
donatien 0:632c9925f013 352 #endif /* LWIP_RAW */