Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:350011bf8be7 1 /*
simon 0:350011bf8be7 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
simon 0:350011bf8be7 3 * All rights reserved.
simon 0:350011bf8be7 4 *
simon 0:350011bf8be7 5 * Redistribution and use in source and binary forms, with or without modification,
simon 0:350011bf8be7 6 * are permitted provided that the following conditions are met:
simon 0:350011bf8be7 7 *
simon 0:350011bf8be7 8 * 1. Redistributions of source code must retain the above copyright notice,
simon 0:350011bf8be7 9 * this list of conditions and the following disclaimer.
simon 0:350011bf8be7 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
simon 0:350011bf8be7 11 * this list of conditions and the following disclaimer in the documentation
simon 0:350011bf8be7 12 * and/or other materials provided with the distribution.
simon 0:350011bf8be7 13 * 3. The name of the author may not be used to endorse or promote products
simon 0:350011bf8be7 14 * derived from this software without specific prior written permission.
simon 0:350011bf8be7 15 *
simon 0:350011bf8be7 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
simon 0:350011bf8be7 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
simon 0:350011bf8be7 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
simon 0:350011bf8be7 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
simon 0:350011bf8be7 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
simon 0:350011bf8be7 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
simon 0:350011bf8be7 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
simon 0:350011bf8be7 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
simon 0:350011bf8be7 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
simon 0:350011bf8be7 25 * OF SUCH DAMAGE.
simon 0:350011bf8be7 26 *
simon 0:350011bf8be7 27 * This file is part of the lwIP TCP/IP stack.
simon 0:350011bf8be7 28 *
simon 0:350011bf8be7 29 * Author: Adam Dunkels <adam@sics.se>
simon 0:350011bf8be7 30 *
simon 0:350011bf8be7 31 */
simon 0:350011bf8be7 32 #ifndef __LWIP_DEF_H__
simon 0:350011bf8be7 33 #define __LWIP_DEF_H__
simon 0:350011bf8be7 34
simon 0:350011bf8be7 35 /* arch.h might define NULL already */
simon 0:350011bf8be7 36 #include "lwip/arch.h"
simon 0:350011bf8be7 37 #include "lwip/opt.h"
simon 0:350011bf8be7 38
simon 0:350011bf8be7 39 #ifdef __cplusplus
simon 0:350011bf8be7 40 extern "C" {
simon 0:350011bf8be7 41 #endif
simon 0:350011bf8be7 42
simon 0:350011bf8be7 43 #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y))
simon 0:350011bf8be7 44 #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y))
simon 0:350011bf8be7 45
simon 0:350011bf8be7 46 #ifndef NULL
simon 0:350011bf8be7 47 #define NULL ((void *)0)
simon 0:350011bf8be7 48 #endif
simon 0:350011bf8be7 49
simon 0:350011bf8be7 50 /** Get the absolute difference between 2 u32_t values (correcting overflows)
simon 0:350011bf8be7 51 * 'a' is expected to be 'higher' (without overflow) than 'b'. */
simon 0:350011bf8be7 52 #define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))
simon 0:350011bf8be7 53
simon 0:350011bf8be7 54 /* Endianess-optimized shifting of two u8_t to create one u16_t */
simon 0:350011bf8be7 55 #if BYTE_ORDER == LITTLE_ENDIAN
simon 0:350011bf8be7 56 #define LWIP_MAKE_U16(a, b) ((a << 8) | b)
simon 0:350011bf8be7 57 #else
simon 0:350011bf8be7 58 #define LWIP_MAKE_U16(a, b) ((b << 8) | a)
simon 0:350011bf8be7 59 #endif
simon 0:350011bf8be7 60
simon 0:350011bf8be7 61 #ifndef LWIP_PLATFORM_BYTESWAP
simon 0:350011bf8be7 62 #define LWIP_PLATFORM_BYTESWAP 0
simon 0:350011bf8be7 63 #endif
simon 0:350011bf8be7 64
simon 0:350011bf8be7 65 #ifndef LWIP_PREFIX_BYTEORDER_FUNCS
simon 0:350011bf8be7 66 /* workaround for naming collisions on some platforms */
simon 0:350011bf8be7 67
simon 0:350011bf8be7 68 #ifdef htons
simon 0:350011bf8be7 69 #undef htons
simon 0:350011bf8be7 70 #endif /* htons */
simon 0:350011bf8be7 71 #ifdef htonl
simon 0:350011bf8be7 72 #undef htonl
simon 0:350011bf8be7 73 #endif /* htonl */
simon 0:350011bf8be7 74 #ifdef ntohs
simon 0:350011bf8be7 75 #undef ntohs
simon 0:350011bf8be7 76 #endif /* ntohs */
simon 0:350011bf8be7 77 #ifdef ntohl
simon 0:350011bf8be7 78 #undef ntohl
simon 0:350011bf8be7 79 #endif /* ntohl */
simon 0:350011bf8be7 80
simon 0:350011bf8be7 81 #define htons(x) lwip_htons(x)
simon 0:350011bf8be7 82 #define ntohs(x) lwip_ntohs(x)
simon 0:350011bf8be7 83 #define htonl(x) lwip_htonl(x)
simon 0:350011bf8be7 84 #define ntohl(x) lwip_ntohl(x)
simon 0:350011bf8be7 85 #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */
simon 0:350011bf8be7 86
simon 0:350011bf8be7 87 #if BYTE_ORDER == BIG_ENDIAN
simon 0:350011bf8be7 88 #define lwip_htons(x) (x)
simon 0:350011bf8be7 89 #define lwip_ntohs(x) (x)
simon 0:350011bf8be7 90 #define lwip_htonl(x) (x)
simon 0:350011bf8be7 91 #define lwip_ntohl(x) (x)
simon 0:350011bf8be7 92 #define PP_HTONS(x) (x)
simon 0:350011bf8be7 93 #define PP_NTOHS(x) (x)
simon 0:350011bf8be7 94 #define PP_HTONL(x) (x)
simon 0:350011bf8be7 95 #define PP_NTOHL(x) (x)
simon 0:350011bf8be7 96 #else /* BYTE_ORDER != BIG_ENDIAN */
simon 0:350011bf8be7 97 #if LWIP_PLATFORM_BYTESWAP
simon 0:350011bf8be7 98 #define lwip_htons(x) LWIP_PLATFORM_HTONS(x)
simon 0:350011bf8be7 99 #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x)
simon 0:350011bf8be7 100 #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x)
simon 0:350011bf8be7 101 #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x)
simon 0:350011bf8be7 102 #else /* LWIP_PLATFORM_BYTESWAP */
simon 0:350011bf8be7 103 u16_t lwip_htons(u16_t x);
simon 0:350011bf8be7 104 u16_t lwip_ntohs(u16_t x);
simon 0:350011bf8be7 105 u32_t lwip_htonl(u32_t x);
simon 0:350011bf8be7 106 u32_t lwip_ntohl(u32_t x);
simon 0:350011bf8be7 107 #endif /* LWIP_PLATFORM_BYTESWAP */
simon 0:350011bf8be7 108
simon 0:350011bf8be7 109 /* These macros should be calculated by the preprocessor and are used
simon 0:350011bf8be7 110 with compile-time constants only (so that there is no little-endian
simon 0:350011bf8be7 111 overhead at runtime). */
simon 0:350011bf8be7 112 #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
simon 0:350011bf8be7 113 #define PP_NTOHS(x) PP_HTONS(x)
simon 0:350011bf8be7 114 #define PP_HTONL(x) ((((x) & 0xff) << 24) | \
simon 0:350011bf8be7 115 (((x) & 0xff00) << 8) | \
simon 0:350011bf8be7 116 (((x) & 0xff0000UL) >> 8) | \
simon 0:350011bf8be7 117 (((x) & 0xff000000UL) >> 24))
simon 0:350011bf8be7 118 #define PP_NTOHL(x) PP_HTONL(x)
simon 0:350011bf8be7 119
simon 0:350011bf8be7 120 #endif /* BYTE_ORDER == BIG_ENDIAN */
simon 0:350011bf8be7 121
simon 0:350011bf8be7 122 #ifdef __cplusplus
simon 0:350011bf8be7 123 }
simon 0:350011bf8be7 124 #endif
simon 0:350011bf8be7 125
simon 0:350011bf8be7 126 #endif /* __LWIP_DEF_H__ */
simon 0:350011bf8be7 127