LwIP with PPP & Ethernet integration
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.
src/include/lwip/def.h@2:1a87f74b8e3b, 2012-05-25 (annotated)
- 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?
User | Revision | Line number | New 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_DEF_H__ |
donatien | 0:8e01dca41002 | 33 | #define __LWIP_DEF_H__ |
donatien | 0:8e01dca41002 | 34 | |
donatien | 0:8e01dca41002 | 35 | /* arch.h might define NULL already */ |
donatien | 0:8e01dca41002 | 36 | #include "lwip/arch.h" |
donatien | 0:8e01dca41002 | 37 | #include "lwip/opt.h" |
donatien | 0:8e01dca41002 | 38 | |
donatien | 0:8e01dca41002 | 39 | #ifdef __cplusplus |
donatien | 0:8e01dca41002 | 40 | extern "C" { |
donatien | 0:8e01dca41002 | 41 | #endif |
donatien | 0:8e01dca41002 | 42 | |
donatien | 0:8e01dca41002 | 43 | #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) |
donatien | 0:8e01dca41002 | 44 | #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) |
donatien | 0:8e01dca41002 | 45 | |
donatien | 0:8e01dca41002 | 46 | #ifndef NULL |
donatien | 0:8e01dca41002 | 47 | #define NULL ((void *)0) |
donatien | 0:8e01dca41002 | 48 | #endif |
donatien | 0:8e01dca41002 | 49 | |
donatien | 0:8e01dca41002 | 50 | /** Get the absolute difference between 2 u32_t values (correcting overflows) |
donatien | 0:8e01dca41002 | 51 | * 'a' is expected to be 'higher' (without overflow) than 'b'. */ |
donatien | 0:8e01dca41002 | 52 | #define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1))) |
donatien | 0:8e01dca41002 | 53 | |
donatien | 0:8e01dca41002 | 54 | /* Endianess-optimized shifting of two u8_t to create one u16_t */ |
donatien | 0:8e01dca41002 | 55 | #if BYTE_ORDER == LITTLE_ENDIAN |
donatien | 0:8e01dca41002 | 56 | #define LWIP_MAKE_U16(a, b) ((a << 8) | b) |
donatien | 0:8e01dca41002 | 57 | #else |
donatien | 0:8e01dca41002 | 58 | #define LWIP_MAKE_U16(a, b) ((b << 8) | a) |
donatien | 0:8e01dca41002 | 59 | #endif |
donatien | 0:8e01dca41002 | 60 | |
donatien | 0:8e01dca41002 | 61 | #ifndef LWIP_PLATFORM_BYTESWAP |
donatien | 0:8e01dca41002 | 62 | #define LWIP_PLATFORM_BYTESWAP 0 |
donatien | 0:8e01dca41002 | 63 | #endif |
donatien | 0:8e01dca41002 | 64 | |
donatien | 0:8e01dca41002 | 65 | #ifndef LWIP_PREFIX_BYTEORDER_FUNCS |
donatien | 0:8e01dca41002 | 66 | /* workaround for naming collisions on some platforms */ |
donatien | 0:8e01dca41002 | 67 | |
donatien | 0:8e01dca41002 | 68 | #ifdef htons |
donatien | 0:8e01dca41002 | 69 | #undef htons |
donatien | 0:8e01dca41002 | 70 | #endif /* htons */ |
donatien | 0:8e01dca41002 | 71 | #ifdef htonl |
donatien | 0:8e01dca41002 | 72 | #undef htonl |
donatien | 0:8e01dca41002 | 73 | #endif /* htonl */ |
donatien | 0:8e01dca41002 | 74 | #ifdef ntohs |
donatien | 0:8e01dca41002 | 75 | #undef ntohs |
donatien | 0:8e01dca41002 | 76 | #endif /* ntohs */ |
donatien | 0:8e01dca41002 | 77 | #ifdef ntohl |
donatien | 0:8e01dca41002 | 78 | #undef ntohl |
donatien | 0:8e01dca41002 | 79 | #endif /* ntohl */ |
donatien | 0:8e01dca41002 | 80 | |
donatien | 0:8e01dca41002 | 81 | #define htons(x) lwip_htons(x) |
donatien | 0:8e01dca41002 | 82 | #define ntohs(x) lwip_ntohs(x) |
donatien | 0:8e01dca41002 | 83 | #define htonl(x) lwip_htonl(x) |
donatien | 0:8e01dca41002 | 84 | #define ntohl(x) lwip_ntohl(x) |
donatien | 0:8e01dca41002 | 85 | #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ |
donatien | 0:8e01dca41002 | 86 | |
donatien | 0:8e01dca41002 | 87 | #if BYTE_ORDER == BIG_ENDIAN |
donatien | 0:8e01dca41002 | 88 | #define lwip_htons(x) (x) |
donatien | 0:8e01dca41002 | 89 | #define lwip_ntohs(x) (x) |
donatien | 0:8e01dca41002 | 90 | #define lwip_htonl(x) (x) |
donatien | 0:8e01dca41002 | 91 | #define lwip_ntohl(x) (x) |
donatien | 0:8e01dca41002 | 92 | #define PP_HTONS(x) (x) |
donatien | 0:8e01dca41002 | 93 | #define PP_NTOHS(x) (x) |
donatien | 0:8e01dca41002 | 94 | #define PP_HTONL(x) (x) |
donatien | 0:8e01dca41002 | 95 | #define PP_NTOHL(x) (x) |
donatien | 0:8e01dca41002 | 96 | #else /* BYTE_ORDER != BIG_ENDIAN */ |
donatien | 0:8e01dca41002 | 97 | #if LWIP_PLATFORM_BYTESWAP |
donatien | 0:8e01dca41002 | 98 | #define lwip_htons(x) LWIP_PLATFORM_HTONS(x) |
donatien | 0:8e01dca41002 | 99 | #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) |
donatien | 0:8e01dca41002 | 100 | #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) |
donatien | 0:8e01dca41002 | 101 | #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) |
donatien | 0:8e01dca41002 | 102 | #else /* LWIP_PLATFORM_BYTESWAP */ |
donatien | 0:8e01dca41002 | 103 | u16_t lwip_htons(u16_t x); |
donatien | 0:8e01dca41002 | 104 | u16_t lwip_ntohs(u16_t x); |
donatien | 0:8e01dca41002 | 105 | u32_t lwip_htonl(u32_t x); |
donatien | 0:8e01dca41002 | 106 | u32_t lwip_ntohl(u32_t x); |
donatien | 0:8e01dca41002 | 107 | #endif /* LWIP_PLATFORM_BYTESWAP */ |
donatien | 0:8e01dca41002 | 108 | |
donatien | 0:8e01dca41002 | 109 | /* These macros should be calculated by the preprocessor and are used |
donatien | 0:8e01dca41002 | 110 | with compile-time constants only (so that there is no little-endian |
donatien | 0:8e01dca41002 | 111 | overhead at runtime). */ |
donatien | 0:8e01dca41002 | 112 | #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) |
donatien | 0:8e01dca41002 | 113 | #define PP_NTOHS(x) PP_HTONS(x) |
donatien | 0:8e01dca41002 | 114 | #define PP_HTONL(x) ((((x) & 0xff) << 24) | \ |
donatien | 0:8e01dca41002 | 115 | (((x) & 0xff00) << 8) | \ |
donatien | 0:8e01dca41002 | 116 | (((x) & 0xff0000UL) >> 8) | \ |
donatien | 0:8e01dca41002 | 117 | (((x) & 0xff000000UL) >> 24)) |
donatien | 0:8e01dca41002 | 118 | #define PP_NTOHL(x) PP_HTONL(x) |
donatien | 0:8e01dca41002 | 119 | |
donatien | 0:8e01dca41002 | 120 | #endif /* BYTE_ORDER == BIG_ENDIAN */ |
donatien | 0:8e01dca41002 | 121 | |
donatien | 0:8e01dca41002 | 122 | #ifdef __cplusplus |
donatien | 0:8e01dca41002 | 123 | } |
donatien | 0:8e01dca41002 | 124 | #endif |
donatien | 0:8e01dca41002 | 125 | |
donatien | 0:8e01dca41002 | 126 | #endif /* __LWIP_DEF_H__ */ |
donatien | 0:8e01dca41002 | 127 |