Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed

Dependencies:   mbed

Committer:
pehrhovey
Date:
Sun Mar 14 00:54:12 2010 +0000
Revision:
0:a548a085de55

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pehrhovey 0:a548a085de55 1 /*
pehrhovey 0:a548a085de55 2 * SETUP: Make sure we define everything we will need.
pehrhovey 0:a548a085de55 3 *
pehrhovey 0:a548a085de55 4 * We have create three types of pools:
pehrhovey 0:a548a085de55 5 * 1) MEMPOOL - standard pools
pehrhovey 0:a548a085de55 6 * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
pehrhovey 0:a548a085de55 7 * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
pehrhovey 0:a548a085de55 8 *
pehrhovey 0:a548a085de55 9 * If the include'r doesn't require any special treatment of each of the types
pehrhovey 0:a548a085de55 10 * above, then will declare #2 & #3 to be just standard mempools.
pehrhovey 0:a548a085de55 11 */
pehrhovey 0:a548a085de55 12 #ifndef LWIP_MALLOC_MEMPOOL
pehrhovey 0:a548a085de55 13 /* This treats "malloc pools" just like any other pool.
pehrhovey 0:a548a085de55 14 The pools are a little bigger to provide 'size' as the amount of user data. */
pehrhovey 0:a548a085de55 15 #define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size)
pehrhovey 0:a548a085de55 16 #define LWIP_MALLOC_MEMPOOL_START
pehrhovey 0:a548a085de55 17 #define LWIP_MALLOC_MEMPOOL_END
pehrhovey 0:a548a085de55 18 #endif /* LWIP_MALLOC_MEMPOOL */
pehrhovey 0:a548a085de55 19
pehrhovey 0:a548a085de55 20 #ifndef LWIP_PBUF_MEMPOOL
pehrhovey 0:a548a085de55 21 /* This treats "pbuf pools" just like any other pool.
pehrhovey 0:a548a085de55 22 * Allocates buffers for a pbuf struct AND a payload size */
pehrhovey 0:a548a085de55 23 #define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc)
pehrhovey 0:a548a085de55 24 #endif /* LWIP_PBUF_MEMPOOL */
pehrhovey 0:a548a085de55 25
pehrhovey 0:a548a085de55 26
pehrhovey 0:a548a085de55 27 /*
pehrhovey 0:a548a085de55 28 * A list of internal pools used by LWIP.
pehrhovey 0:a548a085de55 29 *
pehrhovey 0:a548a085de55 30 * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
pehrhovey 0:a548a085de55 31 * creates a pool name MEMP_pool_name. description is used in stats.c
pehrhovey 0:a548a085de55 32 */
pehrhovey 0:a548a085de55 33 #if LWIP_RAW
pehrhovey 0:a548a085de55 34 LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB")
pehrhovey 0:a548a085de55 35 #endif /* LWIP_RAW */
pehrhovey 0:a548a085de55 36
pehrhovey 0:a548a085de55 37 #if LWIP_UDP
pehrhovey 0:a548a085de55 38 LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB")
pehrhovey 0:a548a085de55 39 #endif /* LWIP_UDP */
pehrhovey 0:a548a085de55 40
pehrhovey 0:a548a085de55 41 #if LWIP_TCP
pehrhovey 0:a548a085de55 42 LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB")
pehrhovey 0:a548a085de55 43 LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN")
pehrhovey 0:a548a085de55 44 LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG")
pehrhovey 0:a548a085de55 45 #endif /* LWIP_TCP */
pehrhovey 0:a548a085de55 46
pehrhovey 0:a548a085de55 47 #if IP_REASSEMBLY
pehrhovey 0:a548a085de55 48 LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA")
pehrhovey 0:a548a085de55 49 #endif /* IP_REASSEMBLY */
pehrhovey 0:a548a085de55 50
pehrhovey 0:a548a085de55 51 #if LWIP_NETCONN
pehrhovey 0:a548a085de55 52 LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF")
pehrhovey 0:a548a085de55 53 LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN")
pehrhovey 0:a548a085de55 54 #endif /* LWIP_NETCONN */
pehrhovey 0:a548a085de55 55
pehrhovey 0:a548a085de55 56 #if NO_SYS==0
pehrhovey 0:a548a085de55 57 LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API")
pehrhovey 0:a548a085de55 58 LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT")
pehrhovey 0:a548a085de55 59 #endif /* NO_SYS==0 */
pehrhovey 0:a548a085de55 60
pehrhovey 0:a548a085de55 61 #if ARP_QUEUEING
pehrhovey 0:a548a085de55 62 LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE")
pehrhovey 0:a548a085de55 63 #endif /* ARP_QUEUEING */
pehrhovey 0:a548a085de55 64
pehrhovey 0:a548a085de55 65 #if LWIP_IGMP
pehrhovey 0:a548a085de55 66 LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP")
pehrhovey 0:a548a085de55 67 #endif /* LWIP_IGMP */
pehrhovey 0:a548a085de55 68
pehrhovey 0:a548a085de55 69 #if NO_SYS==0
pehrhovey 0:a548a085de55 70 LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT")
pehrhovey 0:a548a085de55 71 #endif /* NO_SYS==0 */
pehrhovey 0:a548a085de55 72
pehrhovey 0:a548a085de55 73
pehrhovey 0:a548a085de55 74 /*
pehrhovey 0:a548a085de55 75 * A list of pools of pbuf's used by LWIP.
pehrhovey 0:a548a085de55 76 *
pehrhovey 0:a548a085de55 77 * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
pehrhovey 0:a548a085de55 78 * creates a pool name MEMP_pool_name. description is used in stats.c
pehrhovey 0:a548a085de55 79 * This allocates enough space for the pbuf struct and a payload.
pehrhovey 0:a548a085de55 80 * (Example: pbuf_payload_size=0 allocates only size for the struct)
pehrhovey 0:a548a085de55 81 */
pehrhovey 0:a548a085de55 82 LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM")
pehrhovey 0:a548a085de55 83 LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, PBUF_POOL_BUFSIZE, "PBUF_POOL")
pehrhovey 0:a548a085de55 84
pehrhovey 0:a548a085de55 85
pehrhovey 0:a548a085de55 86 /*
pehrhovey 0:a548a085de55 87 * Allow for user-defined pools; this must be explicitly set in lwipopts.h
pehrhovey 0:a548a085de55 88 * since the default is to NOT look for lwippools.h
pehrhovey 0:a548a085de55 89 */
pehrhovey 0:a548a085de55 90 #if MEMP_USE_CUSTOM_POOLS
pehrhovey 0:a548a085de55 91 #include "lwippools.h"
pehrhovey 0:a548a085de55 92 #endif /* MEMP_USE_CUSTOM_POOLS */
pehrhovey 0:a548a085de55 93
pehrhovey 0:a548a085de55 94 /*
pehrhovey 0:a548a085de55 95 * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
pehrhovey 0:a548a085de55 96 * (#undef is ignored for something that is not defined)
pehrhovey 0:a548a085de55 97 */
pehrhovey 0:a548a085de55 98 #undef LWIP_MEMPOOL
pehrhovey 0:a548a085de55 99 #undef LWIP_MALLOC_MEMPOOL
pehrhovey 0:a548a085de55 100 #undef LWIP_MALLOC_MEMPOOL_START
pehrhovey 0:a548a085de55 101 #undef LWIP_MALLOC_MEMPOOL_END
pehrhovey 0:a548a085de55 102 #undef LWIP_PBUF_MEMPOOL