Philippe Bazot / Mbed 2 deprecated DU4SmartCities

Dependencies:   C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by IBM Watson IoT

Committer:
icraggs
Date:
Wed Oct 01 13:27:35 2014 +0000
Revision:
8:80d49dd91542
Parent:
6:37b6d0d56190
Remove conditional compilation for IBM IoT settings

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samdanbury 6:37b6d0d56190 1 /**
samdanbury 6:37b6d0d56190 2 * @file
samdanbury 6:37b6d0d56190 3 * Common functions used throughout the stack.
samdanbury 6:37b6d0d56190 4 *
samdanbury 6:37b6d0d56190 5 */
samdanbury 6:37b6d0d56190 6
samdanbury 6:37b6d0d56190 7 /*
samdanbury 6:37b6d0d56190 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
samdanbury 6:37b6d0d56190 9 * All rights reserved.
samdanbury 6:37b6d0d56190 10 *
samdanbury 6:37b6d0d56190 11 * Redistribution and use in source and binary forms, with or without modification,
samdanbury 6:37b6d0d56190 12 * are permitted provided that the following conditions are met:
samdanbury 6:37b6d0d56190 13 *
samdanbury 6:37b6d0d56190 14 * 1. Redistributions of source code must retain the above copyright notice,
samdanbury 6:37b6d0d56190 15 * this list of conditions and the following disclaimer.
samdanbury 6:37b6d0d56190 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
samdanbury 6:37b6d0d56190 17 * this list of conditions and the following disclaimer in the documentation
samdanbury 6:37b6d0d56190 18 * and/or other materials provided with the distribution.
samdanbury 6:37b6d0d56190 19 * 3. The name of the author may not be used to endorse or promote products
samdanbury 6:37b6d0d56190 20 * derived from this software without specific prior written permission.
samdanbury 6:37b6d0d56190 21 *
samdanbury 6:37b6d0d56190 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
samdanbury 6:37b6d0d56190 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
samdanbury 6:37b6d0d56190 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
samdanbury 6:37b6d0d56190 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
samdanbury 6:37b6d0d56190 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
samdanbury 6:37b6d0d56190 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
samdanbury 6:37b6d0d56190 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
samdanbury 6:37b6d0d56190 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
samdanbury 6:37b6d0d56190 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
samdanbury 6:37b6d0d56190 31 * OF SUCH DAMAGE.
samdanbury 6:37b6d0d56190 32 *
samdanbury 6:37b6d0d56190 33 * This file is part of the lwIP TCP/IP stack.
samdanbury 6:37b6d0d56190 34 *
samdanbury 6:37b6d0d56190 35 * Author: Simon Goldschmidt
samdanbury 6:37b6d0d56190 36 *
samdanbury 6:37b6d0d56190 37 */
samdanbury 6:37b6d0d56190 38
samdanbury 6:37b6d0d56190 39 #include "lwip/opt.h"
samdanbury 6:37b6d0d56190 40 #include "lwip/def.h"
samdanbury 6:37b6d0d56190 41
samdanbury 6:37b6d0d56190 42 /**
samdanbury 6:37b6d0d56190 43 * These are reference implementations of the byte swapping functions.
samdanbury 6:37b6d0d56190 44 * Again with the aim of being simple, correct and fully portable.
samdanbury 6:37b6d0d56190 45 * Byte swapping is the second thing you would want to optimize. You will
samdanbury 6:37b6d0d56190 46 * need to port it to your architecture and in your cc.h:
samdanbury 6:37b6d0d56190 47 *
samdanbury 6:37b6d0d56190 48 * #define LWIP_PLATFORM_BYTESWAP 1
samdanbury 6:37b6d0d56190 49 * #define LWIP_PLATFORM_HTONS(x) <your_htons>
samdanbury 6:37b6d0d56190 50 * #define LWIP_PLATFORM_HTONL(x) <your_htonl>
samdanbury 6:37b6d0d56190 51 *
samdanbury 6:37b6d0d56190 52 * Note ntohs() and ntohl() are merely references to the htonx counterparts.
samdanbury 6:37b6d0d56190 53 */
samdanbury 6:37b6d0d56190 54
samdanbury 6:37b6d0d56190 55 #if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN)
samdanbury 6:37b6d0d56190 56
samdanbury 6:37b6d0d56190 57 /**
samdanbury 6:37b6d0d56190 58 * Convert an u16_t from host- to network byte order.
samdanbury 6:37b6d0d56190 59 *
samdanbury 6:37b6d0d56190 60 * @param n u16_t in host byte order
samdanbury 6:37b6d0d56190 61 * @return n in network byte order
samdanbury 6:37b6d0d56190 62 */
samdanbury 6:37b6d0d56190 63 u16_t
samdanbury 6:37b6d0d56190 64 lwip_htons(u16_t n)
samdanbury 6:37b6d0d56190 65 {
samdanbury 6:37b6d0d56190 66 return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
samdanbury 6:37b6d0d56190 67 }
samdanbury 6:37b6d0d56190 68
samdanbury 6:37b6d0d56190 69 /**
samdanbury 6:37b6d0d56190 70 * Convert an u16_t from network- to host byte order.
samdanbury 6:37b6d0d56190 71 *
samdanbury 6:37b6d0d56190 72 * @param n u16_t in network byte order
samdanbury 6:37b6d0d56190 73 * @return n in host byte order
samdanbury 6:37b6d0d56190 74 */
samdanbury 6:37b6d0d56190 75 u16_t
samdanbury 6:37b6d0d56190 76 lwip_ntohs(u16_t n)
samdanbury 6:37b6d0d56190 77 {
samdanbury 6:37b6d0d56190 78 return lwip_htons(n);
samdanbury 6:37b6d0d56190 79 }
samdanbury 6:37b6d0d56190 80
samdanbury 6:37b6d0d56190 81 /**
samdanbury 6:37b6d0d56190 82 * Convert an u32_t from host- to network byte order.
samdanbury 6:37b6d0d56190 83 *
samdanbury 6:37b6d0d56190 84 * @param n u32_t in host byte order
samdanbury 6:37b6d0d56190 85 * @return n in network byte order
samdanbury 6:37b6d0d56190 86 */
samdanbury 6:37b6d0d56190 87 u32_t
samdanbury 6:37b6d0d56190 88 lwip_htonl(u32_t n)
samdanbury 6:37b6d0d56190 89 {
samdanbury 6:37b6d0d56190 90 return ((n & 0xff) << 24) |
samdanbury 6:37b6d0d56190 91 ((n & 0xff00) << 8) |
samdanbury 6:37b6d0d56190 92 ((n & 0xff0000UL) >> 8) |
samdanbury 6:37b6d0d56190 93 ((n & 0xff000000UL) >> 24);
samdanbury 6:37b6d0d56190 94 }
samdanbury 6:37b6d0d56190 95
samdanbury 6:37b6d0d56190 96 /**
samdanbury 6:37b6d0d56190 97 * Convert an u32_t from network- to host byte order.
samdanbury 6:37b6d0d56190 98 *
samdanbury 6:37b6d0d56190 99 * @param n u32_t in network byte order
samdanbury 6:37b6d0d56190 100 * @return n in host byte order
samdanbury 6:37b6d0d56190 101 */
samdanbury 6:37b6d0d56190 102 u32_t
samdanbury 6:37b6d0d56190 103 lwip_ntohl(u32_t n)
samdanbury 6:37b6d0d56190 104 {
samdanbury 6:37b6d0d56190 105 return lwip_htonl(n);
samdanbury 6:37b6d0d56190 106 }
samdanbury 6:37b6d0d56190 107
samdanbury 6:37b6d0d56190 108 #endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */