NetTribute library with debug turned on in FShandler Donatien Garner -> Segundo Equipo -> this version

Committer:
hexley
Date:
Fri Nov 19 01:54:45 2010 +0000
Revision:
0:281d6ff68967

        

Who changed what in which revision?

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