LwIP with PPP & Ethernet integration

Dependents:   NetworkingCoreLib

This is the mbed port of the LwIP stack: http://savannah.nongnu.org/projects/lwip/

It includes contributed content from NXP's port for LPCxxxx devices: http://www.lpcware.com/content/project/lightweight-ip-lwip-networking-stack

Licence

LwIP is licenced under the BSD licence:

Copyright (c) 2001-2004 Swedish Institute of Computer Science. 
All rights reserved. 
Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met: 
1. Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer. 
2. Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution. 
3. The name of the author may not be used to endorse or promote products 
derived from this software without specific prior written permission. 
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.
Committer:
donatien
Date:
Fri May 25 08:56:35 2012 +0000
Revision:
2:1a87f74b8e3b
Parent:
0:8e01dca41002
Removed compilation of EMAC driver when using PPP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:8e01dca41002 1 /*
donatien 0:8e01dca41002 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
donatien 0:8e01dca41002 3 * All rights reserved.
donatien 0:8e01dca41002 4 *
donatien 0:8e01dca41002 5 * Redistribution and use in source and binary forms, with or without modification,
donatien 0:8e01dca41002 6 * are permitted provided that the following conditions are met:
donatien 0:8e01dca41002 7 *
donatien 0:8e01dca41002 8 * 1. Redistributions of source code must retain the above copyright notice,
donatien 0:8e01dca41002 9 * this list of conditions and the following disclaimer.
donatien 0:8e01dca41002 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
donatien 0:8e01dca41002 11 * this list of conditions and the following disclaimer in the documentation
donatien 0:8e01dca41002 12 * and/or other materials provided with the distribution.
donatien 0:8e01dca41002 13 * 3. The name of the author may not be used to endorse or promote products
donatien 0:8e01dca41002 14 * derived from this software without specific prior written permission.
donatien 0:8e01dca41002 15 *
donatien 0:8e01dca41002 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
donatien 0:8e01dca41002 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
donatien 0:8e01dca41002 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
donatien 0:8e01dca41002 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
donatien 0:8e01dca41002 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
donatien 0:8e01dca41002 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
donatien 0:8e01dca41002 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
donatien 0:8e01dca41002 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
donatien 0:8e01dca41002 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
donatien 0:8e01dca41002 25 * OF SUCH DAMAGE.
donatien 0:8e01dca41002 26 *
donatien 0:8e01dca41002 27 * This file is part of the lwIP TCP/IP stack.
donatien 0:8e01dca41002 28 *
donatien 0:8e01dca41002 29 * Author: Adam Dunkels <adam@sics.se>
donatien 0:8e01dca41002 30 *
donatien 0:8e01dca41002 31 */
donatien 0:8e01dca41002 32 #ifndef __LWIP_TCPIP_H__
donatien 0:8e01dca41002 33 #define __LWIP_TCPIP_H__
donatien 0:8e01dca41002 34
donatien 0:8e01dca41002 35 #include "lwip/opt.h"
donatien 0:8e01dca41002 36
donatien 0:8e01dca41002 37 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
donatien 0:8e01dca41002 38
donatien 0:8e01dca41002 39 #include "lwip/api_msg.h"
donatien 0:8e01dca41002 40 #include "lwip/netifapi.h"
donatien 0:8e01dca41002 41 #include "lwip/pbuf.h"
donatien 0:8e01dca41002 42 #include "lwip/api.h"
donatien 0:8e01dca41002 43 #include "lwip/sys.h"
donatien 0:8e01dca41002 44 #include "lwip/timers.h"
donatien 0:8e01dca41002 45 #include "lwip/netif.h"
donatien 0:8e01dca41002 46
donatien 0:8e01dca41002 47 #ifdef __cplusplus
donatien 0:8e01dca41002 48 extern "C" {
donatien 0:8e01dca41002 49 #endif
donatien 0:8e01dca41002 50
donatien 0:8e01dca41002 51 /** Define this to something that triggers a watchdog. This is called from
donatien 0:8e01dca41002 52 * tcpip_thread after processing a message. */
donatien 0:8e01dca41002 53 #ifndef LWIP_TCPIP_THREAD_ALIVE
donatien 0:8e01dca41002 54 #define LWIP_TCPIP_THREAD_ALIVE()
donatien 0:8e01dca41002 55 #endif
donatien 0:8e01dca41002 56
donatien 0:8e01dca41002 57 #if LWIP_TCPIP_CORE_LOCKING
donatien 0:8e01dca41002 58 /** The global semaphore to lock the stack. */
donatien 0:8e01dca41002 59 extern sys_mutex_t lock_tcpip_core;
donatien 0:8e01dca41002 60 #define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
donatien 0:8e01dca41002 61 #define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
donatien 0:8e01dca41002 62 #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
donatien 0:8e01dca41002 63 #define TCPIP_APIMSG_ACK(m)
donatien 0:8e01dca41002 64 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
donatien 0:8e01dca41002 65 #define TCPIP_NETIFAPI_ACK(m)
donatien 0:8e01dca41002 66 #else /* LWIP_TCPIP_CORE_LOCKING */
donatien 0:8e01dca41002 67 #define LOCK_TCPIP_CORE()
donatien 0:8e01dca41002 68 #define UNLOCK_TCPIP_CORE()
donatien 0:8e01dca41002 69 #define TCPIP_APIMSG(m) tcpip_apimsg(m)
donatien 0:8e01dca41002 70 #define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
donatien 0:8e01dca41002 71 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
donatien 0:8e01dca41002 72 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
donatien 0:8e01dca41002 73 #endif /* LWIP_TCPIP_CORE_LOCKING */
donatien 0:8e01dca41002 74
donatien 0:8e01dca41002 75 /** Function prototype for the init_done function passed to tcpip_init */
donatien 0:8e01dca41002 76 typedef void (*tcpip_init_done_fn)(void *arg);
donatien 0:8e01dca41002 77 /** Function prototype for functions passed to tcpip_callback() */
donatien 0:8e01dca41002 78 typedef void (*tcpip_callback_fn)(void *ctx);
donatien 0:8e01dca41002 79
donatien 0:8e01dca41002 80 void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
donatien 0:8e01dca41002 81
donatien 0:8e01dca41002 82 #if LWIP_NETCONN
donatien 0:8e01dca41002 83 err_t tcpip_apimsg(struct api_msg *apimsg);
donatien 0:8e01dca41002 84 #if LWIP_TCPIP_CORE_LOCKING
donatien 0:8e01dca41002 85 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
donatien 0:8e01dca41002 86 #endif /* LWIP_TCPIP_CORE_LOCKING */
donatien 0:8e01dca41002 87 #endif /* LWIP_NETCONN */
donatien 0:8e01dca41002 88
donatien 0:8e01dca41002 89 err_t tcpip_input(struct pbuf *p, struct netif *inp);
donatien 0:8e01dca41002 90
donatien 0:8e01dca41002 91 #if LWIP_NETIF_API
donatien 0:8e01dca41002 92 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
donatien 0:8e01dca41002 93 #if LWIP_TCPIP_CORE_LOCKING
donatien 0:8e01dca41002 94 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
donatien 0:8e01dca41002 95 #endif /* LWIP_TCPIP_CORE_LOCKING */
donatien 0:8e01dca41002 96 #endif /* LWIP_NETIF_API */
donatien 0:8e01dca41002 97
donatien 0:8e01dca41002 98 err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
donatien 0:8e01dca41002 99 #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
donatien 0:8e01dca41002 100
donatien 0:8e01dca41002 101 /* free pbufs or heap memory from another context without blocking */
donatien 0:8e01dca41002 102 err_t pbuf_free_callback(struct pbuf *p);
donatien 0:8e01dca41002 103 err_t mem_free_callback(void *m);
donatien 0:8e01dca41002 104
donatien 0:8e01dca41002 105 #if LWIP_TCPIP_TIMEOUT
donatien 0:8e01dca41002 106 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
donatien 0:8e01dca41002 107 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
donatien 0:8e01dca41002 108 #endif /* LWIP_TCPIP_TIMEOUT */
donatien 0:8e01dca41002 109
donatien 0:8e01dca41002 110 enum tcpip_msg_type {
donatien 0:8e01dca41002 111 #if LWIP_NETCONN
donatien 0:8e01dca41002 112 TCPIP_MSG_API,
donatien 0:8e01dca41002 113 #endif /* LWIP_NETCONN */
donatien 0:8e01dca41002 114 TCPIP_MSG_INPKT,
donatien 0:8e01dca41002 115 #if LWIP_NETIF_API
donatien 0:8e01dca41002 116 TCPIP_MSG_NETIFAPI,
donatien 0:8e01dca41002 117 #endif /* LWIP_NETIF_API */
donatien 0:8e01dca41002 118 #if LWIP_TCPIP_TIMEOUT
donatien 0:8e01dca41002 119 TCPIP_MSG_TIMEOUT,
donatien 0:8e01dca41002 120 TCPIP_MSG_UNTIMEOUT,
donatien 0:8e01dca41002 121 #endif /* LWIP_TCPIP_TIMEOUT */
donatien 0:8e01dca41002 122 TCPIP_MSG_CALLBACK
donatien 0:8e01dca41002 123 };
donatien 0:8e01dca41002 124
donatien 0:8e01dca41002 125 struct tcpip_msg {
donatien 0:8e01dca41002 126 enum tcpip_msg_type type;
donatien 0:8e01dca41002 127 sys_sem_t *sem;
donatien 0:8e01dca41002 128 union {
donatien 0:8e01dca41002 129 #if LWIP_NETCONN
donatien 0:8e01dca41002 130 struct api_msg *apimsg;
donatien 0:8e01dca41002 131 #endif /* LWIP_NETCONN */
donatien 0:8e01dca41002 132 #if LWIP_NETIF_API
donatien 0:8e01dca41002 133 struct netifapi_msg *netifapimsg;
donatien 0:8e01dca41002 134 #endif /* LWIP_NETIF_API */
donatien 0:8e01dca41002 135 struct {
donatien 0:8e01dca41002 136 struct pbuf *p;
donatien 0:8e01dca41002 137 struct netif *netif;
donatien 0:8e01dca41002 138 } inp;
donatien 0:8e01dca41002 139 struct {
donatien 0:8e01dca41002 140 tcpip_callback_fn function;
donatien 0:8e01dca41002 141 void *ctx;
donatien 0:8e01dca41002 142 } cb;
donatien 0:8e01dca41002 143 #if LWIP_TCPIP_TIMEOUT
donatien 0:8e01dca41002 144 struct {
donatien 0:8e01dca41002 145 u32_t msecs;
donatien 0:8e01dca41002 146 sys_timeout_handler h;
donatien 0:8e01dca41002 147 void *arg;
donatien 0:8e01dca41002 148 } tmo;
donatien 0:8e01dca41002 149 #endif /* LWIP_TCPIP_TIMEOUT */
donatien 0:8e01dca41002 150 } msg;
donatien 0:8e01dca41002 151 };
donatien 0:8e01dca41002 152
donatien 0:8e01dca41002 153 #ifdef __cplusplus
donatien 0:8e01dca41002 154 }
donatien 0:8e01dca41002 155 #endif
donatien 0:8e01dca41002 156
donatien 0:8e01dca41002 157 #endif /* !NO_SYS */
donatien 0:8e01dca41002 158
donatien 0:8e01dca41002 159 #endif /* __LWIP_TCPIP_H__ */