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