Stripped down version of Segundos NetService library (http://mbed.org/users/segundo/libraries/NetServices ). I have removed all NetServices, and all functions which had been disabled. Use this version when you need only pure TCP or UDP functions - this library compiles faster.

Dependencies:   lwip lwip-sys

Dependents:   christmasLights device_server pop3demo device_server_udp ... more

Committer:
hlipka
Date:
Mon Jan 10 21:03:11 2011 +0000
Revision:
0:8b387bed54c2
initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hlipka 0:8b387bed54c2 1 /*
hlipka 0:8b387bed54c2 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
hlipka 0:8b387bed54c2 3 * All rights reserved.
hlipka 0:8b387bed54c2 4 *
hlipka 0:8b387bed54c2 5 * Redistribution and use in source and binary forms, with or without modification,
hlipka 0:8b387bed54c2 6 * are permitted provided that the following conditions are met:
hlipka 0:8b387bed54c2 7 *
hlipka 0:8b387bed54c2 8 * 1. Redistributions of source code must retain the above copyright notice,
hlipka 0:8b387bed54c2 9 * this list of conditions and the following disclaimer.
hlipka 0:8b387bed54c2 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
hlipka 0:8b387bed54c2 11 * this list of conditions and the following disclaimer in the documentation
hlipka 0:8b387bed54c2 12 * and/or other materials provided with the distribution.
hlipka 0:8b387bed54c2 13 * 3. The name of the author may not be used to endorse or promote products
hlipka 0:8b387bed54c2 14 * derived from this software without specific prior written permission.
hlipka 0:8b387bed54c2 15 *
hlipka 0:8b387bed54c2 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
hlipka 0:8b387bed54c2 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
hlipka 0:8b387bed54c2 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
hlipka 0:8b387bed54c2 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
hlipka 0:8b387bed54c2 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
hlipka 0:8b387bed54c2 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
hlipka 0:8b387bed54c2 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
hlipka 0:8b387bed54c2 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
hlipka 0:8b387bed54c2 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
hlipka 0:8b387bed54c2 25 * OF SUCH DAMAGE.
hlipka 0:8b387bed54c2 26 *
hlipka 0:8b387bed54c2 27 * This file is part of the lwIP TCP/IP stack.
hlipka 0:8b387bed54c2 28 *
hlipka 0:8b387bed54c2 29 * Author: Adam Dunkels <adam@sics.se>
hlipka 0:8b387bed54c2 30 *
hlipka 0:8b387bed54c2 31 */
hlipka 0:8b387bed54c2 32 #ifndef __LWIP_DEF_H__
hlipka 0:8b387bed54c2 33 #define __LWIP_DEF_H__
hlipka 0:8b387bed54c2 34
hlipka 0:8b387bed54c2 35 /* arch.h might define NULL already */
hlipka 0:8b387bed54c2 36 #include "lwip/arch.h"
hlipka 0:8b387bed54c2 37 #include "lwip/opt.h"
hlipka 0:8b387bed54c2 38
hlipka 0:8b387bed54c2 39 #ifdef __cplusplus
hlipka 0:8b387bed54c2 40 extern "C" {
hlipka 0:8b387bed54c2 41 #endif
hlipka 0:8b387bed54c2 42
hlipka 0:8b387bed54c2 43 #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y))
hlipka 0:8b387bed54c2 44 #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y))
hlipka 0:8b387bed54c2 45
hlipka 0:8b387bed54c2 46 #ifndef NULL
hlipka 0:8b387bed54c2 47 #define NULL ((void *)0)
hlipka 0:8b387bed54c2 48 #endif
hlipka 0:8b387bed54c2 49
hlipka 0:8b387bed54c2 50 /** Get the absolute difference between 2 u32_t values (correcting overflows)
hlipka 0:8b387bed54c2 51 * 'a' is expected to be 'higher' (without overflow) than 'b'. */
hlipka 0:8b387bed54c2 52 #define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))
hlipka 0:8b387bed54c2 53
hlipka 0:8b387bed54c2 54 /* Endianess-optimized shifting of two u8_t to create one u16_t */
hlipka 0:8b387bed54c2 55 #if BYTE_ORDER == LITTLE_ENDIAN
hlipka 0:8b387bed54c2 56 #define LWIP_MAKE_U16(a, b) ((a << 8) | b)
hlipka 0:8b387bed54c2 57 #else
hlipka 0:8b387bed54c2 58 #define LWIP_MAKE_U16(a, b) ((b << 8) | a)
hlipka 0:8b387bed54c2 59 #endif
hlipka 0:8b387bed54c2 60
hlipka 0:8b387bed54c2 61 #ifndef LWIP_PLATFORM_BYTESWAP
hlipka 0:8b387bed54c2 62 #define LWIP_PLATFORM_BYTESWAP 0
hlipka 0:8b387bed54c2 63 #endif
hlipka 0:8b387bed54c2 64
hlipka 0:8b387bed54c2 65 #ifndef LWIP_PREFIX_BYTEORDER_FUNCS
hlipka 0:8b387bed54c2 66 /* workaround for naming collisions on some platforms */
hlipka 0:8b387bed54c2 67
hlipka 0:8b387bed54c2 68 #ifdef htons
hlipka 0:8b387bed54c2 69 #undef htons
hlipka 0:8b387bed54c2 70 #endif /* htons */
hlipka 0:8b387bed54c2 71 #ifdef htonl
hlipka 0:8b387bed54c2 72 #undef htonl
hlipka 0:8b387bed54c2 73 #endif /* htonl */
hlipka 0:8b387bed54c2 74 #ifdef ntohs
hlipka 0:8b387bed54c2 75 #undef ntohs
hlipka 0:8b387bed54c2 76 #endif /* ntohs */
hlipka 0:8b387bed54c2 77 #ifdef ntohl
hlipka 0:8b387bed54c2 78 #undef ntohl
hlipka 0:8b387bed54c2 79 #endif /* ntohl */
hlipka 0:8b387bed54c2 80
hlipka 0:8b387bed54c2 81 #define htons(x) lwip_htons(x)
hlipka 0:8b387bed54c2 82 #define ntohs(x) lwip_ntohs(x)
hlipka 0:8b387bed54c2 83 #define htonl(x) lwip_htonl(x)
hlipka 0:8b387bed54c2 84 #define ntohl(x) lwip_ntohl(x)
hlipka 0:8b387bed54c2 85 #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */
hlipka 0:8b387bed54c2 86
hlipka 0:8b387bed54c2 87 #if BYTE_ORDER == BIG_ENDIAN
hlipka 0:8b387bed54c2 88 #define lwip_htons(x) (x)
hlipka 0:8b387bed54c2 89 #define lwip_ntohs(x) (x)
hlipka 0:8b387bed54c2 90 #define lwip_htonl(x) (x)
hlipka 0:8b387bed54c2 91 #define lwip_ntohl(x) (x)
hlipka 0:8b387bed54c2 92 #define PP_HTONS(x) (x)
hlipka 0:8b387bed54c2 93 #define PP_NTOHS(x) (x)
hlipka 0:8b387bed54c2 94 #define PP_HTONL(x) (x)
hlipka 0:8b387bed54c2 95 #define PP_NTOHL(x) (x)
hlipka 0:8b387bed54c2 96 #else /* BYTE_ORDER != BIG_ENDIAN */
hlipka 0:8b387bed54c2 97 #if LWIP_PLATFORM_BYTESWAP
hlipka 0:8b387bed54c2 98 #define lwip_htons(x) LWIP_PLATFORM_HTONS(x)
hlipka 0:8b387bed54c2 99 #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x)
hlipka 0:8b387bed54c2 100 #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x)
hlipka 0:8b387bed54c2 101 #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x)
hlipka 0:8b387bed54c2 102 #else /* LWIP_PLATFORM_BYTESWAP */
hlipka 0:8b387bed54c2 103 u16_t lwip_htons(u16_t x);
hlipka 0:8b387bed54c2 104 u16_t lwip_ntohs(u16_t x);
hlipka 0:8b387bed54c2 105 u32_t lwip_htonl(u32_t x);
hlipka 0:8b387bed54c2 106 u32_t lwip_ntohl(u32_t x);
hlipka 0:8b387bed54c2 107 #endif /* LWIP_PLATFORM_BYTESWAP */
hlipka 0:8b387bed54c2 108
hlipka 0:8b387bed54c2 109 /* These macros should be calculated by the preprocessor and are used
hlipka 0:8b387bed54c2 110 with compile-time constants only (so that there is no little-endian
hlipka 0:8b387bed54c2 111 overhead at runtime). */
hlipka 0:8b387bed54c2 112 #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
hlipka 0:8b387bed54c2 113 #define PP_NTOHS(x) PP_HTONS(x)
hlipka 0:8b387bed54c2 114 #define PP_HTONL(x) ((((x) & 0xff) << 24) | \
hlipka 0:8b387bed54c2 115 (((x) & 0xff00) << 8) | \
hlipka 0:8b387bed54c2 116 (((x) & 0xff0000UL) >> 8) | \
hlipka 0:8b387bed54c2 117 (((x) & 0xff000000UL) >> 24))
hlipka 0:8b387bed54c2 118 #define PP_NTOHL(x) PP_HTONL(x)
hlipka 0:8b387bed54c2 119
hlipka 0:8b387bed54c2 120 #endif /* BYTE_ORDER == BIG_ENDIAN */
hlipka 0:8b387bed54c2 121
hlipka 0:8b387bed54c2 122 #ifdef __cplusplus
hlipka 0:8b387bed54c2 123 }
hlipka 0:8b387bed54c2 124 #endif
hlipka 0:8b387bed54c2 125
hlipka 0:8b387bed54c2 126 #endif /* __LWIP_DEF_H__ */
hlipka 0:8b387bed54c2 127