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
hlipka 0:8b387bed54c2 33 #ifndef __LWIP_MEMP_H__
hlipka 0:8b387bed54c2 34 #define __LWIP_MEMP_H__
hlipka 0:8b387bed54c2 35
hlipka 0:8b387bed54c2 36 #include "lwip/opt.h"
hlipka 0:8b387bed54c2 37
hlipka 0:8b387bed54c2 38 #ifdef __cplusplus
hlipka 0:8b387bed54c2 39 extern "C" {
hlipka 0:8b387bed54c2 40 #endif
hlipka 0:8b387bed54c2 41
hlipka 0:8b387bed54c2 42 /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
hlipka 0:8b387bed54c2 43 typedef enum {
hlipka 0:8b387bed54c2 44 #define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
hlipka 0:8b387bed54c2 45 #include "lwip/memp_std.h"
hlipka 0:8b387bed54c2 46 MEMP_MAX
hlipka 0:8b387bed54c2 47 } memp_t;
hlipka 0:8b387bed54c2 48
hlipka 0:8b387bed54c2 49 #if MEM_USE_POOLS
hlipka 0:8b387bed54c2 50 /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */
hlipka 0:8b387bed54c2 51 typedef enum {
hlipka 0:8b387bed54c2 52 /* Get the first (via:
hlipka 0:8b387bed54c2 53 MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/
hlipka 0:8b387bed54c2 54 MEMP_POOL_HELPER_FIRST = ((u8_t)
hlipka 0:8b387bed54c2 55 #define LWIP_MEMPOOL(name,num,size,desc)
hlipka 0:8b387bed54c2 56 #define LWIP_MALLOC_MEMPOOL_START 1
hlipka 0:8b387bed54c2 57 #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0
hlipka 0:8b387bed54c2 58 #define LWIP_MALLOC_MEMPOOL_END
hlipka 0:8b387bed54c2 59 #include "lwip/memp_std.h"
hlipka 0:8b387bed54c2 60 ) ,
hlipka 0:8b387bed54c2 61 /* Get the last (via:
hlipka 0:8b387bed54c2 62 MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */
hlipka 0:8b387bed54c2 63 MEMP_POOL_HELPER_LAST = ((u8_t)
hlipka 0:8b387bed54c2 64 #define LWIP_MEMPOOL(name,num,size,desc)
hlipka 0:8b387bed54c2 65 #define LWIP_MALLOC_MEMPOOL_START
hlipka 0:8b387bed54c2 66 #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size *
hlipka 0:8b387bed54c2 67 #define LWIP_MALLOC_MEMPOOL_END 1
hlipka 0:8b387bed54c2 68 #include "lwip/memp_std.h"
hlipka 0:8b387bed54c2 69 )
hlipka 0:8b387bed54c2 70 } memp_pool_helper_t;
hlipka 0:8b387bed54c2 71
hlipka 0:8b387bed54c2 72 /* The actual start and stop values are here (cast them over)
hlipka 0:8b387bed54c2 73 We use this helper type and these defines so we can avoid using const memp_t values */
hlipka 0:8b387bed54c2 74 #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
hlipka 0:8b387bed54c2 75 #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
hlipka 0:8b387bed54c2 76 #endif /* MEM_USE_POOLS */
hlipka 0:8b387bed54c2 77
hlipka 0:8b387bed54c2 78 #if MEMP_MEM_MALLOC || MEM_USE_POOLS
hlipka 0:8b387bed54c2 79 extern const u16_t memp_sizes[MEMP_MAX];
hlipka 0:8b387bed54c2 80 #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
hlipka 0:8b387bed54c2 81
hlipka 0:8b387bed54c2 82 #if MEMP_MEM_MALLOC
hlipka 0:8b387bed54c2 83
hlipka 0:8b387bed54c2 84 #include "mem.h"
hlipka 0:8b387bed54c2 85
hlipka 0:8b387bed54c2 86 #define memp_init()
hlipka 0:8b387bed54c2 87 #define memp_malloc(type) mem_malloc(memp_sizes[type])
hlipka 0:8b387bed54c2 88 #define memp_free(type, mem) mem_free(mem)
hlipka 0:8b387bed54c2 89
hlipka 0:8b387bed54c2 90 #else /* MEMP_MEM_MALLOC */
hlipka 0:8b387bed54c2 91
hlipka 0:8b387bed54c2 92 #if MEM_USE_POOLS
hlipka 0:8b387bed54c2 93 /** This structure is used to save the pool one element came from. */
hlipka 0:8b387bed54c2 94 struct memp_malloc_helper
hlipka 0:8b387bed54c2 95 {
hlipka 0:8b387bed54c2 96 memp_t poolnr;
hlipka 0:8b387bed54c2 97 };
hlipka 0:8b387bed54c2 98 #endif /* MEM_USE_POOLS */
hlipka 0:8b387bed54c2 99
hlipka 0:8b387bed54c2 100 void memp_init(void);
hlipka 0:8b387bed54c2 101
hlipka 0:8b387bed54c2 102 #if MEMP_OVERFLOW_CHECK
hlipka 0:8b387bed54c2 103 void *memp_malloc_fn(memp_t type, const char* file, const int line);
hlipka 0:8b387bed54c2 104 #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
hlipka 0:8b387bed54c2 105 #else
hlipka 0:8b387bed54c2 106 void *memp_malloc(memp_t type);
hlipka 0:8b387bed54c2 107 #endif
hlipka 0:8b387bed54c2 108 void memp_free(memp_t type, void *mem);
hlipka 0:8b387bed54c2 109
hlipka 0:8b387bed54c2 110 #endif /* MEMP_MEM_MALLOC */
hlipka 0:8b387bed54c2 111
hlipka 0:8b387bed54c2 112 #ifdef __cplusplus
hlipka 0:8b387bed54c2 113 }
hlipka 0:8b387bed54c2 114 #endif
hlipka 0:8b387bed54c2 115
hlipka 0:8b387bed54c2 116 #endif /* __LWIP_MEMP_H__ */