Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C027_Support IBMIoTClientCellularExample MQTT mbed
Fork of MQTT-GSM-GPS-CAN-SMS by
EthernetInterface/lwip/include/ipv4/lwip/inet_chksum.h@6:37b6d0d56190, 2014-08-20 (annotated)
- Committer:
 - samdanbury
 - Date:
 - Wed Aug 20 12:45:14 2014 +0000
 - Revision:
 - 6:37b6d0d56190
 
Code completely changed to improve the structure, flow and memory usage of the application
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| samdanbury | 6:37b6d0d56190 | 1 | /* | 
| samdanbury | 6:37b6d0d56190 | 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. | 
| samdanbury | 6:37b6d0d56190 | 3 | * All rights reserved. | 
| samdanbury | 6:37b6d0d56190 | 4 | * | 
| samdanbury | 6:37b6d0d56190 | 5 | * Redistribution and use in source and binary forms, with or without modification, | 
| samdanbury | 6:37b6d0d56190 | 6 | * are permitted provided that the following conditions are met: | 
| samdanbury | 6:37b6d0d56190 | 7 | * | 
| samdanbury | 6:37b6d0d56190 | 8 | * 1. Redistributions of source code must retain the above copyright notice, | 
| samdanbury | 6:37b6d0d56190 | 9 | * this list of conditions and the following disclaimer. | 
| samdanbury | 6:37b6d0d56190 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, | 
| samdanbury | 6:37b6d0d56190 | 11 | * this list of conditions and the following disclaimer in the documentation | 
| samdanbury | 6:37b6d0d56190 | 12 | * and/or other materials provided with the distribution. | 
| samdanbury | 6:37b6d0d56190 | 13 | * 3. The name of the author may not be used to endorse or promote products | 
| samdanbury | 6:37b6d0d56190 | 14 | * derived from this software without specific prior written permission. | 
| samdanbury | 6:37b6d0d56190 | 15 | * | 
| samdanbury | 6:37b6d0d56190 | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 
| samdanbury | 6:37b6d0d56190 | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 
| samdanbury | 6:37b6d0d56190 | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | 
| samdanbury | 6:37b6d0d56190 | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 
| samdanbury | 6:37b6d0d56190 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | 
| samdanbury | 6:37b6d0d56190 | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
| samdanbury | 6:37b6d0d56190 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
| samdanbury | 6:37b6d0d56190 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 
| samdanbury | 6:37b6d0d56190 | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | 
| samdanbury | 6:37b6d0d56190 | 25 | * OF SUCH DAMAGE. | 
| samdanbury | 6:37b6d0d56190 | 26 | * | 
| samdanbury | 6:37b6d0d56190 | 27 | * This file is part of the lwIP TCP/IP stack. | 
| samdanbury | 6:37b6d0d56190 | 28 | * | 
| samdanbury | 6:37b6d0d56190 | 29 | * Author: Adam Dunkels <adam@sics.se> | 
| samdanbury | 6:37b6d0d56190 | 30 | * | 
| samdanbury | 6:37b6d0d56190 | 31 | */ | 
| samdanbury | 6:37b6d0d56190 | 32 | #ifndef __LWIP_INET_CHKSUM_H__ | 
| samdanbury | 6:37b6d0d56190 | 33 | #define __LWIP_INET_CHKSUM_H__ | 
| samdanbury | 6:37b6d0d56190 | 34 | |
| samdanbury | 6:37b6d0d56190 | 35 | #include "lwip/opt.h" | 
| samdanbury | 6:37b6d0d56190 | 36 | |
| samdanbury | 6:37b6d0d56190 | 37 | #include "lwip/pbuf.h" | 
| samdanbury | 6:37b6d0d56190 | 38 | #include "lwip/ip_addr.h" | 
| samdanbury | 6:37b6d0d56190 | 39 | |
| samdanbury | 6:37b6d0d56190 | 40 | /** Swap the bytes in an u16_t: much like htons() for little-endian */ | 
| samdanbury | 6:37b6d0d56190 | 41 | #ifndef SWAP_BYTES_IN_WORD | 
| samdanbury | 6:37b6d0d56190 | 42 | #if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) | 
| samdanbury | 6:37b6d0d56190 | 43 | /* little endian and PLATFORM_BYTESWAP defined */ | 
| samdanbury | 6:37b6d0d56190 | 44 | #define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) | 
| samdanbury | 6:37b6d0d56190 | 45 | #else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ | 
| samdanbury | 6:37b6d0d56190 | 46 | /* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ | 
| samdanbury | 6:37b6d0d56190 | 47 | #define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) | 
| samdanbury | 6:37b6d0d56190 | 48 | #endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ | 
| samdanbury | 6:37b6d0d56190 | 49 | #endif /* SWAP_BYTES_IN_WORD */ | 
| samdanbury | 6:37b6d0d56190 | 50 | |
| samdanbury | 6:37b6d0d56190 | 51 | /** Split an u32_t in two u16_ts and add them up */ | 
| samdanbury | 6:37b6d0d56190 | 52 | #ifndef FOLD_U32T | 
| samdanbury | 6:37b6d0d56190 | 53 | #define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) | 
| samdanbury | 6:37b6d0d56190 | 54 | #endif | 
| samdanbury | 6:37b6d0d56190 | 55 | |
| samdanbury | 6:37b6d0d56190 | 56 | #if LWIP_CHECKSUM_ON_COPY | 
| samdanbury | 6:37b6d0d56190 | 57 | /** Function-like macro: same as MEMCPY but returns the checksum of copied data | 
| samdanbury | 6:37b6d0d56190 | 58 | as u16_t */ | 
| samdanbury | 6:37b6d0d56190 | 59 | #ifndef LWIP_CHKSUM_COPY | 
| samdanbury | 6:37b6d0d56190 | 60 | #define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) | 
| samdanbury | 6:37b6d0d56190 | 61 | #ifndef LWIP_CHKSUM_COPY_ALGORITHM | 
| samdanbury | 6:37b6d0d56190 | 62 | #define LWIP_CHKSUM_COPY_ALGORITHM 1 | 
| samdanbury | 6:37b6d0d56190 | 63 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ | 
| samdanbury | 6:37b6d0d56190 | 64 | #endif /* LWIP_CHKSUM_COPY */ | 
| samdanbury | 6:37b6d0d56190 | 65 | #else /* LWIP_CHECKSUM_ON_COPY */ | 
| samdanbury | 6:37b6d0d56190 | 66 | #define LWIP_CHKSUM_COPY_ALGORITHM 0 | 
| samdanbury | 6:37b6d0d56190 | 67 | #endif /* LWIP_CHECKSUM_ON_COPY */ | 
| samdanbury | 6:37b6d0d56190 | 68 | |
| samdanbury | 6:37b6d0d56190 | 69 | #ifdef __cplusplus | 
| samdanbury | 6:37b6d0d56190 | 70 | extern "C" { | 
| samdanbury | 6:37b6d0d56190 | 71 | #endif | 
| samdanbury | 6:37b6d0d56190 | 72 | |
| samdanbury | 6:37b6d0d56190 | 73 | u16_t inet_chksum(void *dataptr, u16_t len); | 
| samdanbury | 6:37b6d0d56190 | 74 | u16_t inet_chksum_pbuf(struct pbuf *p); | 
| samdanbury | 6:37b6d0d56190 | 75 | u16_t inet_chksum_pseudo(struct pbuf *p, | 
| samdanbury | 6:37b6d0d56190 | 76 | ip_addr_t *src, ip_addr_t *dest, | 
| samdanbury | 6:37b6d0d56190 | 77 | u8_t proto, u16_t proto_len); | 
| samdanbury | 6:37b6d0d56190 | 78 | u16_t inet_chksum_pseudo_partial(struct pbuf *p, | 
| samdanbury | 6:37b6d0d56190 | 79 | ip_addr_t *src, ip_addr_t *dest, | 
| samdanbury | 6:37b6d0d56190 | 80 | u8_t proto, u16_t proto_len, u16_t chksum_len); | 
| samdanbury | 6:37b6d0d56190 | 81 | #if LWIP_CHKSUM_COPY_ALGORITHM | 
| samdanbury | 6:37b6d0d56190 | 82 | u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); | 
| samdanbury | 6:37b6d0d56190 | 83 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ | 
| samdanbury | 6:37b6d0d56190 | 84 | |
| samdanbury | 6:37b6d0d56190 | 85 | #ifdef __cplusplus | 
| samdanbury | 6:37b6d0d56190 | 86 | } | 
| samdanbury | 6:37b6d0d56190 | 87 | #endif | 
| samdanbury | 6:37b6d0d56190 | 88 | |
| samdanbury | 6:37b6d0d56190 | 89 | #endif /* __LWIP_INET_H__ */ | 
| samdanbury | 6:37b6d0d56190 | 90 | 
