Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed
Core/lwIP/include/lwip/mem.h@0:a548a085de55, 2010-03-14 (annotated)
- Committer:
- pehrhovey
- Date:
- Sun Mar 14 00:54:12 2010 +0000
- Revision:
- 0:a548a085de55
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pehrhovey | 0:a548a085de55 | 1 | /* |
pehrhovey | 0:a548a085de55 | 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
pehrhovey | 0:a548a085de55 | 3 | * All rights reserved. |
pehrhovey | 0:a548a085de55 | 4 | * |
pehrhovey | 0:a548a085de55 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
pehrhovey | 0:a548a085de55 | 6 | * are permitted provided that the following conditions are met: |
pehrhovey | 0:a548a085de55 | 7 | * |
pehrhovey | 0:a548a085de55 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
pehrhovey | 0:a548a085de55 | 9 | * this list of conditions and the following disclaimer. |
pehrhovey | 0:a548a085de55 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
pehrhovey | 0:a548a085de55 | 11 | * this list of conditions and the following disclaimer in the documentation |
pehrhovey | 0:a548a085de55 | 12 | * and/or other materials provided with the distribution. |
pehrhovey | 0:a548a085de55 | 13 | * 3. The name of the author may not be used to endorse or promote products |
pehrhovey | 0:a548a085de55 | 14 | * derived from this software without specific prior written permission. |
pehrhovey | 0:a548a085de55 | 15 | * |
pehrhovey | 0:a548a085de55 | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
pehrhovey | 0:a548a085de55 | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
pehrhovey | 0:a548a085de55 | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
pehrhovey | 0:a548a085de55 | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
pehrhovey | 0:a548a085de55 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
pehrhovey | 0:a548a085de55 | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
pehrhovey | 0:a548a085de55 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
pehrhovey | 0:a548a085de55 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
pehrhovey | 0:a548a085de55 | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
pehrhovey | 0:a548a085de55 | 25 | * OF SUCH DAMAGE. |
pehrhovey | 0:a548a085de55 | 26 | * |
pehrhovey | 0:a548a085de55 | 27 | * This file is part of the lwIP TCP/IP stack. |
pehrhovey | 0:a548a085de55 | 28 | * |
pehrhovey | 0:a548a085de55 | 29 | * Author: Adam Dunkels <adam@sics.se> |
pehrhovey | 0:a548a085de55 | 30 | * |
pehrhovey | 0:a548a085de55 | 31 | */ |
pehrhovey | 0:a548a085de55 | 32 | #ifndef __LWIP_MEM_H__ |
pehrhovey | 0:a548a085de55 | 33 | #define __LWIP_MEM_H__ |
pehrhovey | 0:a548a085de55 | 34 | |
pehrhovey | 0:a548a085de55 | 35 | #include "lwip/opt.h" |
pehrhovey | 0:a548a085de55 | 36 | |
pehrhovey | 0:a548a085de55 | 37 | #ifdef __cplusplus |
pehrhovey | 0:a548a085de55 | 38 | extern "C" { |
pehrhovey | 0:a548a085de55 | 39 | #endif |
pehrhovey | 0:a548a085de55 | 40 | |
pehrhovey | 0:a548a085de55 | 41 | #if MEM_LIBC_MALLOC |
pehrhovey | 0:a548a085de55 | 42 | |
pehrhovey | 0:a548a085de55 | 43 | #include <stddef.h> /* for size_t */ |
pehrhovey | 0:a548a085de55 | 44 | |
pehrhovey | 0:a548a085de55 | 45 | typedef size_t mem_size_t; |
pehrhovey | 0:a548a085de55 | 46 | |
pehrhovey | 0:a548a085de55 | 47 | /* aliases for C library malloc() */ |
pehrhovey | 0:a548a085de55 | 48 | #define mem_init() |
pehrhovey | 0:a548a085de55 | 49 | /* in case C library malloc() needs extra protection, |
pehrhovey | 0:a548a085de55 | 50 | * allow these defines to be overridden. |
pehrhovey | 0:a548a085de55 | 51 | */ |
pehrhovey | 0:a548a085de55 | 52 | #ifndef mem_free |
pehrhovey | 0:a548a085de55 | 53 | #define mem_free free |
pehrhovey | 0:a548a085de55 | 54 | #endif |
pehrhovey | 0:a548a085de55 | 55 | #ifndef mem_malloc |
pehrhovey | 0:a548a085de55 | 56 | #define mem_malloc malloc |
pehrhovey | 0:a548a085de55 | 57 | #endif |
pehrhovey | 0:a548a085de55 | 58 | #ifndef mem_calloc |
pehrhovey | 0:a548a085de55 | 59 | #define mem_calloc calloc |
pehrhovey | 0:a548a085de55 | 60 | #endif |
pehrhovey | 0:a548a085de55 | 61 | #ifndef mem_realloc |
pehrhovey | 0:a548a085de55 | 62 | static void *mem_realloc(void *mem, mem_size_t size) |
pehrhovey | 0:a548a085de55 | 63 | { |
pehrhovey | 0:a548a085de55 | 64 | LWIP_UNUSED_ARG(size); |
pehrhovey | 0:a548a085de55 | 65 | return mem; |
pehrhovey | 0:a548a085de55 | 66 | } |
pehrhovey | 0:a548a085de55 | 67 | #endif |
pehrhovey | 0:a548a085de55 | 68 | #else /* MEM_LIBC_MALLOC */ |
pehrhovey | 0:a548a085de55 | 69 | |
pehrhovey | 0:a548a085de55 | 70 | /* MEM_SIZE would have to be aligned, but using 64000 here instead of |
pehrhovey | 0:a548a085de55 | 71 | * 65535 leaves some room for alignment... |
pehrhovey | 0:a548a085de55 | 72 | */ |
pehrhovey | 0:a548a085de55 | 73 | #if MEM_SIZE > 64000l |
pehrhovey | 0:a548a085de55 | 74 | typedef u32_t mem_size_t; |
pehrhovey | 0:a548a085de55 | 75 | #else |
pehrhovey | 0:a548a085de55 | 76 | typedef u16_t mem_size_t; |
pehrhovey | 0:a548a085de55 | 77 | #endif /* MEM_SIZE > 64000 */ |
pehrhovey | 0:a548a085de55 | 78 | |
pehrhovey | 0:a548a085de55 | 79 | #if MEM_USE_POOLS |
pehrhovey | 0:a548a085de55 | 80 | /** mem_init is not used when using pools instead of a heap */ |
pehrhovey | 0:a548a085de55 | 81 | #define mem_init() |
pehrhovey | 0:a548a085de55 | 82 | /** mem_realloc is not used when using pools instead of a heap: |
pehrhovey | 0:a548a085de55 | 83 | we can't free part of a pool element and don't want to copy the rest */ |
pehrhovey | 0:a548a085de55 | 84 | #define mem_realloc(mem, size) (mem) |
pehrhovey | 0:a548a085de55 | 85 | #else /* MEM_USE_POOLS */ |
pehrhovey | 0:a548a085de55 | 86 | /* lwIP alternative malloc */ |
pehrhovey | 0:a548a085de55 | 87 | void mem_init(void); |
pehrhovey | 0:a548a085de55 | 88 | void *mem_realloc(void *mem, mem_size_t size); |
pehrhovey | 0:a548a085de55 | 89 | #endif /* MEM_USE_POOLS */ |
pehrhovey | 0:a548a085de55 | 90 | void *mem_malloc(mem_size_t size); |
pehrhovey | 0:a548a085de55 | 91 | void *mem_calloc(mem_size_t count, mem_size_t size); |
pehrhovey | 0:a548a085de55 | 92 | void mem_free(void *mem); |
pehrhovey | 0:a548a085de55 | 93 | #endif /* MEM_LIBC_MALLOC */ |
pehrhovey | 0:a548a085de55 | 94 | |
pehrhovey | 0:a548a085de55 | 95 | #ifndef LWIP_MEM_ALIGN_SIZE |
pehrhovey | 0:a548a085de55 | 96 | #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) |
pehrhovey | 0:a548a085de55 | 97 | #endif |
pehrhovey | 0:a548a085de55 | 98 | |
pehrhovey | 0:a548a085de55 | 99 | #ifndef LWIP_MEM_ALIGN |
pehrhovey | 0:a548a085de55 | 100 | #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) |
pehrhovey | 0:a548a085de55 | 101 | #endif |
pehrhovey | 0:a548a085de55 | 102 | |
pehrhovey | 0:a548a085de55 | 103 | #ifdef __cplusplus |
pehrhovey | 0:a548a085de55 | 104 | } |
pehrhovey | 0:a548a085de55 | 105 | #endif |
pehrhovey | 0:a548a085de55 | 106 | |
pehrhovey | 0:a548a085de55 | 107 | #endif /* __LWIP_MEM_H__ */ |