![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
JNP3 16/17
cantcoap/inet.h@68:e88f3fd2e9cf, 2017-01-23 (annotated)
- Committer:
- pannaanna
- Date:
- Mon Jan 23 14:18:23 2017 +0100
- Revision:
- 68:e88f3fd2e9cf
- Parent:
- 31:413ba83b8c0b
port changed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bartosz Stebel |
31:413ba83b8c0b | 1 | // |
Bartosz Stebel |
31:413ba83b8c0b | 2 | // inet.h |
Bartosz Stebel |
31:413ba83b8c0b | 3 | // |
Bartosz Stebel |
31:413ba83b8c0b | 4 | // Functions common to all TCP/IP modules, such as the Internet checksum and the |
Bartosz Stebel |
31:413ba83b8c0b | 5 | // byte order functions. |
Bartosz Stebel |
31:413ba83b8c0b | 6 | // |
Bartosz Stebel |
31:413ba83b8c0b | 7 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. |
Bartosz Stebel |
31:413ba83b8c0b | 8 | // Portions Copyright (C) 2001, Swedish Institute of Computer Science. |
Bartosz Stebel |
31:413ba83b8c0b | 9 | // |
Bartosz Stebel |
31:413ba83b8c0b | 10 | // Redistribution and use in source and binary forms, with or without |
Bartosz Stebel |
31:413ba83b8c0b | 11 | // modification, are permitted provided that the following conditions |
Bartosz Stebel |
31:413ba83b8c0b | 12 | // are met: |
Bartosz Stebel |
31:413ba83b8c0b | 13 | // |
Bartosz Stebel |
31:413ba83b8c0b | 14 | // 1. Redistributions of source code must retain the above copyright |
Bartosz Stebel |
31:413ba83b8c0b | 15 | // notice, this list of conditions and the following disclaimer. |
Bartosz Stebel |
31:413ba83b8c0b | 16 | // 2. Redistributions in binary form must reproduce the above copyright |
Bartosz Stebel |
31:413ba83b8c0b | 17 | // notice, this list of conditions and the following disclaimer in the |
Bartosz Stebel |
31:413ba83b8c0b | 18 | // documentation and/or other materials provided with the distribution. |
Bartosz Stebel |
31:413ba83b8c0b | 19 | // 3. Neither the name of the project nor the names of its contributors |
Bartosz Stebel |
31:413ba83b8c0b | 20 | // may be used to endorse or promote products derived from this software |
Bartosz Stebel |
31:413ba83b8c0b | 21 | // without specific prior written permission. |
Bartosz Stebel |
31:413ba83b8c0b | 22 | // |
Bartosz Stebel |
31:413ba83b8c0b | 23 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Bartosz Stebel |
31:413ba83b8c0b | 24 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Bartosz Stebel |
31:413ba83b8c0b | 25 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
Bartosz Stebel |
31:413ba83b8c0b | 26 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
Bartosz Stebel |
31:413ba83b8c0b | 27 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Bartosz Stebel |
31:413ba83b8c0b | 28 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
Bartosz Stebel |
31:413ba83b8c0b | 29 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
Bartosz Stebel |
31:413ba83b8c0b | 30 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
Bartosz Stebel |
31:413ba83b8c0b | 31 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
Bartosz Stebel |
31:413ba83b8c0b | 32 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
Bartosz Stebel |
31:413ba83b8c0b | 33 | // SUCH DAMAGE. |
Bartosz Stebel |
31:413ba83b8c0b | 34 | // |
Bartosz Stebel |
31:413ba83b8c0b | 35 | |
Bartosz Stebel |
31:413ba83b8c0b | 36 | #ifndef INET_H |
Bartosz Stebel |
31:413ba83b8c0b | 37 | #define INET_H |
Bartosz Stebel |
31:413ba83b8c0b | 38 | |
Bartosz Stebel |
31:413ba83b8c0b | 39 | unsigned short inet_chksum(void *data, int len); |
Bartosz Stebel |
31:413ba83b8c0b | 40 | unsigned short inet_chksum_pbuf(struct pbuf *p); |
Bartosz Stebel |
31:413ba83b8c0b | 41 | unsigned short inet_chksum_pseudo(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, unsigned char proto, unsigned short proto_len); |
Bartosz Stebel |
31:413ba83b8c0b | 42 | |
Bartosz Stebel |
31:413ba83b8c0b | 43 | #if BYTE_ORDER == BIG_ENDIAN |
Bartosz Stebel |
31:413ba83b8c0b | 44 | |
Bartosz Stebel |
31:413ba83b8c0b | 45 | #define HTONS(n) (n) |
Bartosz Stebel |
31:413ba83b8c0b | 46 | #define NTOHS(n) (n) |
Bartosz Stebel |
31:413ba83b8c0b | 47 | #define HTONL(n) (n) |
Bartosz Stebel |
31:413ba83b8c0b | 48 | #define NTOHL(n) (n) |
Bartosz Stebel |
31:413ba83b8c0b | 49 | |
Bartosz Stebel |
31:413ba83b8c0b | 50 | #else |
Bartosz Stebel |
31:413ba83b8c0b | 51 | |
Bartosz Stebel |
31:413ba83b8c0b | 52 | #define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) |
Bartosz Stebel |
31:413ba83b8c0b | 53 | #define NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) |
Bartosz Stebel |
31:413ba83b8c0b | 54 | |
Bartosz Stebel |
31:413ba83b8c0b | 55 | #define HTONL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \ |
Bartosz Stebel |
31:413ba83b8c0b | 56 | ((((unsigned long)(n) & 0xFF00)) << 8) | \ |
Bartosz Stebel |
31:413ba83b8c0b | 57 | ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ |
Bartosz Stebel |
31:413ba83b8c0b | 58 | ((((unsigned long)(n) & 0xFF000000)) >> 24)) |
Bartosz Stebel |
31:413ba83b8c0b | 59 | |
Bartosz Stebel |
31:413ba83b8c0b | 60 | #define NTOHL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \ |
Bartosz Stebel |
31:413ba83b8c0b | 61 | ((((unsigned long)(n) & 0xFF00)) << 8) | \ |
Bartosz Stebel |
31:413ba83b8c0b | 62 | ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ |
Bartosz Stebel |
31:413ba83b8c0b | 63 | ((((unsigned long)(n) & 0xFF000000)) >> 24)) |
Bartosz Stebel |
31:413ba83b8c0b | 64 | #endif |
Bartosz Stebel |
31:413ba83b8c0b | 65 | |
Bartosz Stebel |
31:413ba83b8c0b | 66 | #if 1 |
Bartosz Stebel |
31:413ba83b8c0b | 67 | |
Bartosz Stebel |
31:413ba83b8c0b | 68 | unsigned short htons(unsigned short n); |
Bartosz Stebel |
31:413ba83b8c0b | 69 | unsigned short ntohs(unsigned short n); |
Bartosz Stebel |
31:413ba83b8c0b | 70 | unsigned long htonl(unsigned long n); |
Bartosz Stebel |
31:413ba83b8c0b | 71 | unsigned long ntohl(unsigned long n); |
Bartosz Stebel |
31:413ba83b8c0b | 72 | |
Bartosz Stebel |
31:413ba83b8c0b | 73 | #define htons(n) HTONS(n) |
Bartosz Stebel |
31:413ba83b8c0b | 74 | #define ntohs(n) NTOHS(n) |
Bartosz Stebel |
31:413ba83b8c0b | 75 | |
Bartosz Stebel |
31:413ba83b8c0b | 76 | #define htonl(n) HTONL(n) |
Bartosz Stebel |
31:413ba83b8c0b | 77 | #define ntohl(n) NTOHL(n) |
Bartosz Stebel |
31:413ba83b8c0b | 78 | |
Bartosz Stebel |
31:413ba83b8c0b | 79 | #endif |
Bartosz Stebel |
31:413ba83b8c0b | 80 | |
Bartosz Stebel |
31:413ba83b8c0b | 81 | #endif |