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_INET_CHKSUM_H__
simon 0:350011bf8be7 33 #define __LWIP_INET_CHKSUM_H__
simon 0:350011bf8be7 34
simon 0:350011bf8be7 35 #include "lwip/opt.h"
simon 0:350011bf8be7 36
simon 0:350011bf8be7 37 #include "lwip/pbuf.h"
simon 0:350011bf8be7 38 #include "lwip/ip_addr.h"
simon 0:350011bf8be7 39
simon 0:350011bf8be7 40 /** Swap the bytes in an u16_t: much like htons() for little-endian */
simon 0:350011bf8be7 41 #ifndef SWAP_BYTES_IN_WORD
simon 0:350011bf8be7 42 #if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)
simon 0:350011bf8be7 43 /* little endian and PLATFORM_BYTESWAP defined */
simon 0:350011bf8be7 44 #define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w)
simon 0:350011bf8be7 45 #else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */
simon 0:350011bf8be7 46 /* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */
simon 0:350011bf8be7 47 #define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8)
simon 0:350011bf8be7 48 #endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/
simon 0:350011bf8be7 49 #endif /* SWAP_BYTES_IN_WORD */
simon 0:350011bf8be7 50
simon 0:350011bf8be7 51 /** Split an u32_t in two u16_ts and add them up */
simon 0:350011bf8be7 52 #ifndef FOLD_U32T
simon 0:350011bf8be7 53 #define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL))
simon 0:350011bf8be7 54 #endif
simon 0:350011bf8be7 55
simon 0:350011bf8be7 56 #if LWIP_CHECKSUM_ON_COPY
simon 0:350011bf8be7 57 /** Function-like macro: same as MEMCPY but returns the checksum of copied data
simon 0:350011bf8be7 58 as u16_t */
simon 0:350011bf8be7 59 #ifndef LWIP_CHKSUM_COPY
simon 0:350011bf8be7 60 #define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len)
simon 0:350011bf8be7 61 #ifndef LWIP_CHKSUM_COPY_ALGORITHM
simon 0:350011bf8be7 62 #define LWIP_CHKSUM_COPY_ALGORITHM 1
simon 0:350011bf8be7 63 #endif /* LWIP_CHKSUM_COPY_ALGORITHM */
simon 0:350011bf8be7 64 #endif /* LWIP_CHKSUM_COPY */
simon 0:350011bf8be7 65 #else /* LWIP_CHECKSUM_ON_COPY */
simon 0:350011bf8be7 66 #define LWIP_CHKSUM_COPY_ALGORITHM 0
simon 0:350011bf8be7 67 #endif /* LWIP_CHECKSUM_ON_COPY */
simon 0:350011bf8be7 68
simon 0:350011bf8be7 69 #ifdef __cplusplus
simon 0:350011bf8be7 70 extern "C" {
simon 0:350011bf8be7 71 #endif
simon 0:350011bf8be7 72
simon 0:350011bf8be7 73 u16_t inet_chksum(void *dataptr, u16_t len);
simon 0:350011bf8be7 74 u16_t inet_chksum_pbuf(struct pbuf *p);
simon 0:350011bf8be7 75 u16_t inet_chksum_pseudo(struct pbuf *p,
simon 0:350011bf8be7 76 ip_addr_t *src, ip_addr_t *dest,
simon 0:350011bf8be7 77 u8_t proto, u16_t proto_len);
simon 0:350011bf8be7 78 u16_t inet_chksum_pseudo_partial(struct pbuf *p,
simon 0:350011bf8be7 79 ip_addr_t *src, ip_addr_t *dest,
simon 0:350011bf8be7 80 u8_t proto, u16_t proto_len, u16_t chksum_len);
simon 0:350011bf8be7 81 #if LWIP_CHKSUM_COPY_ALGORITHM
simon 0:350011bf8be7 82 u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len);
simon 0:350011bf8be7 83 #endif /* LWIP_CHKSUM_COPY_ALGORITHM */
simon 0:350011bf8be7 84
simon 0:350011bf8be7 85 #ifdef __cplusplus
simon 0:350011bf8be7 86 }
simon 0:350011bf8be7 87 #endif
simon 0:350011bf8be7 88
simon 0:350011bf8be7 89 #endif /* __LWIP_INET_H__ */
simon 0:350011bf8be7 90