/* SETUP: Make sure we define everything we will need.
 * We assume that if LWIP_MALLOC_MEMPOOL is undefined, then 
 * we are supposed to treat the "malloc mempools" as
 * any other mempool.
 */
#ifndef LWIP_MALLOC_MEMPOOL
// This treats "malloc pools" just like any other pool
#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, size, "MALLOC_"#size)
#define LWIP_MALLOC_MEMPOOL_START
#define LWIP_MALLOC_MEMPOOL_END
#endif

/* A list of internal pools used by LWIP.
 *
 * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
 *     creates a pool name MEMP_pool_name. description is used in stats.c
 */
LWIP_MEMPOOL(PBUF,           16, sizeof(struct pbuf), "PBUF_REF/ROM")
LWIP_MEMPOOL(RAW_PCB,        4,  sizeof(struct raw_pcb), "RAW_PCB")
LWIP_MEMPOOL(UDP_PCB,        4,  sizeof(struct udp_pcb), "UDP_PCB")
LWIP_MEMPOOL(TCP_PCB,        5,  sizeof(struct tcp_pcb), "TCP_PCB")
LWIP_MEMPOOL(TCP_PCB_LISTEN, 8,  sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN")
LWIP_MEMPOOL(TCP_SEG,        16, sizeof(struct tcp_seg), "TCP_SEG")
LWIP_MEMPOOL(NETBUF,         2,  sizeof(struct netbuf), "NETBUF")
LWIP_MEMPOOL(NETCONN,        4,  sizeof(struct netconn), "NETCONN")
LWIP_MEMPOOL(TCPIP_MSG,      8,  sizeof(struct tcpip_msg), "TCPIP_MSG")

#if ARP_QUEUEING
LWIP_MEMPOOL(ARP_QUEUE,      30, sizeof(struct etharp_q_entry), "ARP_QUEUE")
#endif

LWIP_MEMPOOL(PBUF_POOL,      16, (sizeof(struct pbuf) + MEMP_ALIGN_SIZE(PBUF_POOL_BUFSIZE)), "PBUF_POOL")
LWIP_MEMPOOL(SYS_TIMEOUT,    3,  sizeof(struct sys_timeo), "SYS_TIMEOUT")

/* OPTIONAL: Pools to replace heap allocation
 * Optional: Pools can be used instead of the heap for mem_malloc. If so, these
 * should be defined here, in increasing order according to the pool element size.
 *
 * LWIP_MALLOC_MEMPOOL(number_elements, element_size)
 */
#if MEM_USE_POOLS
LWIP_MALLOC_MEMPOOL_START
LWIP_MALLOC_MEMPOOL(20, 256)
LWIP_MALLOC_MEMPOOL(10, 512)
LWIP_MALLOC_MEMPOOL(5, 1024)
LWIP_MALLOC_MEMPOOL_END
#endif /* MEM_USE_POOLS */

/* Optional: Your custom pools can go here if you would like to use lwIP's
 * memory pools for anything else.
 */
#if 0
LWIP_MEMPOOL(SYS_SEM, 10, my_sizeof(struct sys_mbox_struct), "SYS_SEM")
LWIP_MEMPOOL(SYS_MBOX, 10, my_sizeof(struct sys_sem_struct), "SYS_MBOX")
#endif

/* REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
 * (#undef is ignored for something that is not defined)
 */
#undef LWIP_MEMPOOL
#undef LWIP_MALLOC_MEMPOOL
#undef LWIP_MALLOC_MEMPOOL_START
#undef LWIP_MALLOC_MEMPOOL_END
