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_STATS_H__
donatien 0:8e01dca41002 33 #define __LWIP_STATS_H__
donatien 0:8e01dca41002 34
donatien 0:8e01dca41002 35 #include "lwip/opt.h"
donatien 0:8e01dca41002 36
donatien 0:8e01dca41002 37 #include "lwip/mem.h"
donatien 0:8e01dca41002 38 #include "lwip/memp.h"
donatien 0:8e01dca41002 39
donatien 0:8e01dca41002 40 #ifdef __cplusplus
donatien 0:8e01dca41002 41 extern "C" {
donatien 0:8e01dca41002 42 #endif
donatien 0:8e01dca41002 43
donatien 0:8e01dca41002 44 #if LWIP_STATS
donatien 0:8e01dca41002 45
donatien 0:8e01dca41002 46 #ifndef LWIP_STATS_LARGE
donatien 0:8e01dca41002 47 #define LWIP_STATS_LARGE 0
donatien 0:8e01dca41002 48 #endif
donatien 0:8e01dca41002 49
donatien 0:8e01dca41002 50 #if LWIP_STATS_LARGE
donatien 0:8e01dca41002 51 #define STAT_COUNTER u32_t
donatien 0:8e01dca41002 52 #define STAT_COUNTER_F U32_F
donatien 0:8e01dca41002 53 #else
donatien 0:8e01dca41002 54 #define STAT_COUNTER u16_t
donatien 0:8e01dca41002 55 #define STAT_COUNTER_F U16_F
donatien 0:8e01dca41002 56 #endif
donatien 0:8e01dca41002 57
donatien 0:8e01dca41002 58 struct stats_proto {
donatien 0:8e01dca41002 59 STAT_COUNTER xmit; /* Transmitted packets. */
donatien 0:8e01dca41002 60 STAT_COUNTER recv; /* Received packets. */
donatien 0:8e01dca41002 61 STAT_COUNTER fw; /* Forwarded packets. */
donatien 0:8e01dca41002 62 STAT_COUNTER drop; /* Dropped packets. */
donatien 0:8e01dca41002 63 STAT_COUNTER chkerr; /* Checksum error. */
donatien 0:8e01dca41002 64 STAT_COUNTER lenerr; /* Invalid length error. */
donatien 0:8e01dca41002 65 STAT_COUNTER memerr; /* Out of memory error. */
donatien 0:8e01dca41002 66 STAT_COUNTER rterr; /* Routing error. */
donatien 0:8e01dca41002 67 STAT_COUNTER proterr; /* Protocol error. */
donatien 0:8e01dca41002 68 STAT_COUNTER opterr; /* Error in options. */
donatien 0:8e01dca41002 69 STAT_COUNTER err; /* Misc error. */
donatien 0:8e01dca41002 70 STAT_COUNTER cachehit;
donatien 0:8e01dca41002 71 };
donatien 0:8e01dca41002 72
donatien 0:8e01dca41002 73 struct stats_igmp {
donatien 0:8e01dca41002 74 STAT_COUNTER xmit; /* Transmitted packets. */
donatien 0:8e01dca41002 75 STAT_COUNTER recv; /* Received packets. */
donatien 0:8e01dca41002 76 STAT_COUNTER drop; /* Dropped packets. */
donatien 0:8e01dca41002 77 STAT_COUNTER chkerr; /* Checksum error. */
donatien 0:8e01dca41002 78 STAT_COUNTER lenerr; /* Invalid length error. */
donatien 0:8e01dca41002 79 STAT_COUNTER memerr; /* Out of memory error. */
donatien 0:8e01dca41002 80 STAT_COUNTER proterr; /* Protocol error. */
donatien 0:8e01dca41002 81 STAT_COUNTER rx_v1; /* Received v1 frames. */
donatien 0:8e01dca41002 82 STAT_COUNTER rx_group; /* Received group-specific queries. */
donatien 0:8e01dca41002 83 STAT_COUNTER rx_general; /* Received general queries. */
donatien 0:8e01dca41002 84 STAT_COUNTER rx_report; /* Received reports. */
donatien 0:8e01dca41002 85 STAT_COUNTER tx_join; /* Sent joins. */
donatien 0:8e01dca41002 86 STAT_COUNTER tx_leave; /* Sent leaves. */
donatien 0:8e01dca41002 87 STAT_COUNTER tx_report; /* Sent reports. */
donatien 0:8e01dca41002 88 };
donatien 0:8e01dca41002 89
donatien 0:8e01dca41002 90 struct stats_mem {
donatien 0:8e01dca41002 91 #ifdef LWIP_DEBUG
donatien 0:8e01dca41002 92 const char *name;
donatien 0:8e01dca41002 93 #endif /* LWIP_DEBUG */
donatien 0:8e01dca41002 94 mem_size_t avail;
donatien 0:8e01dca41002 95 mem_size_t used;
donatien 0:8e01dca41002 96 mem_size_t max;
donatien 0:8e01dca41002 97 STAT_COUNTER err;
donatien 0:8e01dca41002 98 STAT_COUNTER illegal;
donatien 0:8e01dca41002 99 };
donatien 0:8e01dca41002 100
donatien 0:8e01dca41002 101 struct stats_syselem {
donatien 0:8e01dca41002 102 STAT_COUNTER used;
donatien 0:8e01dca41002 103 STAT_COUNTER max;
donatien 0:8e01dca41002 104 STAT_COUNTER err;
donatien 0:8e01dca41002 105 };
donatien 0:8e01dca41002 106
donatien 0:8e01dca41002 107 struct stats_sys {
donatien 0:8e01dca41002 108 struct stats_syselem sem;
donatien 0:8e01dca41002 109 struct stats_syselem mutex;
donatien 0:8e01dca41002 110 struct stats_syselem mbox;
donatien 0:8e01dca41002 111 };
donatien 0:8e01dca41002 112
donatien 0:8e01dca41002 113 struct stats_ {
donatien 0:8e01dca41002 114 #if LINK_STATS
donatien 0:8e01dca41002 115 struct stats_proto link;
donatien 0:8e01dca41002 116 #endif
donatien 0:8e01dca41002 117 #if ETHARP_STATS
donatien 0:8e01dca41002 118 struct stats_proto etharp;
donatien 0:8e01dca41002 119 #endif
donatien 0:8e01dca41002 120 #if IPFRAG_STATS
donatien 0:8e01dca41002 121 struct stats_proto ip_frag;
donatien 0:8e01dca41002 122 #endif
donatien 0:8e01dca41002 123 #if IP_STATS
donatien 0:8e01dca41002 124 struct stats_proto ip;
donatien 0:8e01dca41002 125 #endif
donatien 0:8e01dca41002 126 #if ICMP_STATS
donatien 0:8e01dca41002 127 struct stats_proto icmp;
donatien 0:8e01dca41002 128 #endif
donatien 0:8e01dca41002 129 #if IGMP_STATS
donatien 0:8e01dca41002 130 struct stats_igmp igmp;
donatien 0:8e01dca41002 131 #endif
donatien 0:8e01dca41002 132 #if UDP_STATS
donatien 0:8e01dca41002 133 struct stats_proto udp;
donatien 0:8e01dca41002 134 #endif
donatien 0:8e01dca41002 135 #if TCP_STATS
donatien 0:8e01dca41002 136 struct stats_proto tcp;
donatien 0:8e01dca41002 137 #endif
donatien 0:8e01dca41002 138 #if MEM_STATS
donatien 0:8e01dca41002 139 struct stats_mem mem;
donatien 0:8e01dca41002 140 #endif
donatien 0:8e01dca41002 141 #if MEMP_STATS
donatien 0:8e01dca41002 142 struct stats_mem memp[MEMP_MAX];
donatien 0:8e01dca41002 143 #endif
donatien 0:8e01dca41002 144 #if SYS_STATS
donatien 0:8e01dca41002 145 struct stats_sys sys;
donatien 0:8e01dca41002 146 #endif
donatien 0:8e01dca41002 147 };
donatien 0:8e01dca41002 148
donatien 0:8e01dca41002 149 extern struct stats_ lwip_stats;
donatien 0:8e01dca41002 150
donatien 0:8e01dca41002 151 void stats_init(void);
donatien 0:8e01dca41002 152
donatien 0:8e01dca41002 153 #define STATS_INC(x) ++lwip_stats.x
donatien 0:8e01dca41002 154 #define STATS_DEC(x) --lwip_stats.x
donatien 0:8e01dca41002 155 #define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \
donatien 0:8e01dca41002 156 if (lwip_stats.x.max < lwip_stats.x.used) { \
donatien 0:8e01dca41002 157 lwip_stats.x.max = lwip_stats.x.used; \
donatien 0:8e01dca41002 158 } \
donatien 0:8e01dca41002 159 } while(0)
donatien 0:8e01dca41002 160 #else /* LWIP_STATS */
donatien 0:8e01dca41002 161 #define stats_init()
donatien 0:8e01dca41002 162 #define STATS_INC(x)
donatien 0:8e01dca41002 163 #define STATS_DEC(x)
donatien 0:8e01dca41002 164 #define STATS_INC_USED(x)
donatien 0:8e01dca41002 165 #endif /* LWIP_STATS */
donatien 0:8e01dca41002 166
donatien 0:8e01dca41002 167 #if TCP_STATS
donatien 0:8e01dca41002 168 #define TCP_STATS_INC(x) STATS_INC(x)
donatien 0:8e01dca41002 169 #define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP")
donatien 0:8e01dca41002 170 #else
donatien 0:8e01dca41002 171 #define TCP_STATS_INC(x)
donatien 0:8e01dca41002 172 #define TCP_STATS_DISPLAY()
donatien 0:8e01dca41002 173 #endif
donatien 0:8e01dca41002 174
donatien 0:8e01dca41002 175 #if UDP_STATS
donatien 0:8e01dca41002 176 #define UDP_STATS_INC(x) STATS_INC(x)
donatien 0:8e01dca41002 177 #define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP")
donatien 0:8e01dca41002 178 #else
donatien 0:8e01dca41002 179 #define UDP_STATS_INC(x)
donatien 0:8e01dca41002 180 #define UDP_STATS_DISPLAY()
donatien 0:8e01dca41002 181 #endif
donatien 0:8e01dca41002 182
donatien 0:8e01dca41002 183 #if ICMP_STATS
donatien 0:8e01dca41002 184 #define ICMP_STATS_INC(x) STATS_INC(x)
donatien 0:8e01dca41002 185 #define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP")
donatien 0:8e01dca41002 186 #else
donatien 0:8e01dca41002 187 #define ICMP_STATS_INC(x)
donatien 0:8e01dca41002 188 #define ICMP_STATS_DISPLAY()
donatien 0:8e01dca41002 189 #endif
donatien 0:8e01dca41002 190
donatien 0:8e01dca41002 191 #if IGMP_STATS
donatien 0:8e01dca41002 192 #define IGMP_STATS_INC(x) STATS_INC(x)
donatien 0:8e01dca41002 193 #define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp)
donatien 0:8e01dca41002 194 #else
donatien 0:8e01dca41002 195 #define IGMP_STATS_INC(x)
donatien 0:8e01dca41002 196 #define IGMP_STATS_DISPLAY()
donatien 0:8e01dca41002 197 #endif
donatien 0:8e01dca41002 198
donatien 0:8e01dca41002 199 #if IP_STATS
donatien 0:8e01dca41002 200 #define IP_STATS_INC(x) STATS_INC(x)
donatien 0:8e01dca41002 201 #define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP")
donatien 0:8e01dca41002 202 #else
donatien 0:8e01dca41002 203 #define IP_STATS_INC(x)
donatien 0:8e01dca41002 204 #define IP_STATS_DISPLAY()
donatien 0:8e01dca41002 205 #endif
donatien 0:8e01dca41002 206
donatien 0:8e01dca41002 207 #if IPFRAG_STATS
donatien 0:8e01dca41002 208 #define IPFRAG_STATS_INC(x) STATS_INC(x)
donatien 0:8e01dca41002 209 #define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG")
donatien 0:8e01dca41002 210 #else
donatien 0:8e01dca41002 211 #define IPFRAG_STATS_INC(x)
donatien 0:8e01dca41002 212 #define IPFRAG_STATS_DISPLAY()
donatien 0:8e01dca41002 213 #endif
donatien 0:8e01dca41002 214
donatien 0:8e01dca41002 215 #if ETHARP_STATS
donatien 0:8e01dca41002 216 #define ETHARP_STATS_INC(x) STATS_INC(x)
donatien 0:8e01dca41002 217 #define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP")
donatien 0:8e01dca41002 218 #else
donatien 0:8e01dca41002 219 #define ETHARP_STATS_INC(x)
donatien 0:8e01dca41002 220 #define ETHARP_STATS_DISPLAY()
donatien 0:8e01dca41002 221 #endif
donatien 0:8e01dca41002 222
donatien 0:8e01dca41002 223 #if LINK_STATS
donatien 0:8e01dca41002 224 #define LINK_STATS_INC(x) STATS_INC(x)
donatien 0:8e01dca41002 225 #define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK")
donatien 0:8e01dca41002 226 #else
donatien 0:8e01dca41002 227 #define LINK_STATS_INC(x)
donatien 0:8e01dca41002 228 #define LINK_STATS_DISPLAY()
donatien 0:8e01dca41002 229 #endif
donatien 0:8e01dca41002 230
donatien 0:8e01dca41002 231 #if MEM_STATS
donatien 0:8e01dca41002 232 #define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
donatien 0:8e01dca41002 233 #define MEM_STATS_INC(x) STATS_INC(mem.x)
donatien 0:8e01dca41002 234 #define MEM_STATS_INC_USED(x, y) STATS_INC_USED(mem, y)
donatien 0:8e01dca41002 235 #define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y
donatien 0:8e01dca41002 236 #define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
donatien 0:8e01dca41002 237 #else
donatien 0:8e01dca41002 238 #define MEM_STATS_AVAIL(x, y)
donatien 0:8e01dca41002 239 #define MEM_STATS_INC(x)
donatien 0:8e01dca41002 240 #define MEM_STATS_INC_USED(x, y)
donatien 0:8e01dca41002 241 #define MEM_STATS_DEC_USED(x, y)
donatien 0:8e01dca41002 242 #define MEM_STATS_DISPLAY()
donatien 0:8e01dca41002 243 #endif
donatien 0:8e01dca41002 244
donatien 0:8e01dca41002 245 #if MEMP_STATS
donatien 0:8e01dca41002 246 #define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y
donatien 0:8e01dca41002 247 #define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x)
donatien 0:8e01dca41002 248 #define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x)
donatien 0:8e01dca41002 249 #define MEMP_STATS_INC_USED(x, i) STATS_INC_USED(memp[i], 1)
donatien 0:8e01dca41002 250 #define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i)
donatien 0:8e01dca41002 251 #else
donatien 0:8e01dca41002 252 #define MEMP_STATS_AVAIL(x, i, y)
donatien 0:8e01dca41002 253 #define MEMP_STATS_INC(x, i)
donatien 0:8e01dca41002 254 #define MEMP_STATS_DEC(x, i)
donatien 0:8e01dca41002 255 #define MEMP_STATS_INC_USED(x, i)
donatien 0:8e01dca41002 256 #define MEMP_STATS_DISPLAY(i)
donatien 0:8e01dca41002 257 #endif
donatien 0:8e01dca41002 258
donatien 0:8e01dca41002 259 #if SYS_STATS
donatien 0:8e01dca41002 260 #define SYS_STATS_INC(x) STATS_INC(sys.x)
donatien 0:8e01dca41002 261 #define SYS_STATS_DEC(x) STATS_DEC(sys.x)
donatien 0:8e01dca41002 262 #define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1)
donatien 0:8e01dca41002 263 #define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys)
donatien 0:8e01dca41002 264 #else
donatien 0:8e01dca41002 265 #define SYS_STATS_INC(x)
donatien 0:8e01dca41002 266 #define SYS_STATS_DEC(x)
donatien 0:8e01dca41002 267 #define SYS_STATS_INC_USED(x)
donatien 0:8e01dca41002 268 #define SYS_STATS_DISPLAY()
donatien 0:8e01dca41002 269 #endif
donatien 0:8e01dca41002 270
donatien 0:8e01dca41002 271 /* Display of statistics */
donatien 0:8e01dca41002 272 #if LWIP_STATS_DISPLAY
donatien 0:8e01dca41002 273 void stats_display(void);
donatien 0:8e01dca41002 274 void stats_display_proto(struct stats_proto *proto, char *name);
donatien 0:8e01dca41002 275 void stats_display_igmp(struct stats_igmp *igmp);
donatien 0:8e01dca41002 276 void stats_display_mem(struct stats_mem *mem, char *name);
donatien 0:8e01dca41002 277 void stats_display_memp(struct stats_mem *mem, int index);
donatien 0:8e01dca41002 278 void stats_display_sys(struct stats_sys *sys);
donatien 0:8e01dca41002 279 #else /* LWIP_STATS_DISPLAY */
donatien 0:8e01dca41002 280 #define stats_display()
donatien 0:8e01dca41002 281 #define stats_display_proto(proto, name)
donatien 0:8e01dca41002 282 #define stats_display_igmp(igmp)
donatien 0:8e01dca41002 283 #define stats_display_mem(mem, name)
donatien 0:8e01dca41002 284 #define stats_display_memp(mem, index)
donatien 0:8e01dca41002 285 #define stats_display_sys(sys)
donatien 0:8e01dca41002 286 #endif /* LWIP_STATS_DISPLAY */
donatien 0:8e01dca41002 287
donatien 0:8e01dca41002 288 #ifdef __cplusplus
donatien 0:8e01dca41002 289 }
donatien 0:8e01dca41002 290 #endif
donatien 0:8e01dca41002 291
donatien 0:8e01dca41002 292 #endif /* __LWIP_STATS_H__ */