ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
yueee_yt
Date:
Wed Mar 12 04:39:15 2014 +0000
Revision:
2:14b689a85306
Parent:
0:7766f6712673
bug fix

Who changed what in which revision?

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