mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-01 15:35:46 +03:00
the old implementation stuffed the pdu struct in front of the transport-level pbuf, and preserved it on the stack while the packages were sent. this had two advantages: * saving ram * preserving the other implementation's structure of pdu->hdr == pdu+1 (ie. starting right after the pdu struct) but two disadvantages: * bad readability and pointer juggling in the send routine * relying on the send function to block until the package is out (which works for simple implementations of lwip drivers but not dma etc) if something really assumes the contiguous memory structure, it will show (unfortunately by corrupting other pdu structs), and chances are people use ->hdr anyway.
52 lines
1.7 KiB
C
52 lines
1.7 KiB
C
/** Memory pool definitions for the libcoap when used with lwIP (which has its
|
|
* own mechanism for quickly allocating chunks of data with known sizes). Has
|
|
* to be findable by lwIP (ie. an #include <lwippools.h> must either directly
|
|
* include this or include something more generic which includes this), and
|
|
* MEMP_USE_CUSTOM_POOLS has to be set in lwipopts.h. */
|
|
|
|
#include <net.h>
|
|
#include <subscribe.h>
|
|
#include <resource.h>
|
|
|
|
#ifndef MEMP_NUM_COAPCONTEXT
|
|
#define MEMP_NUM_COAPCONTEXT 1
|
|
#endif
|
|
|
|
#ifndef MEMP_NUM_COAPENDPOINT
|
|
#define MEMP_NUM_COAPENDPOINT 1
|
|
#endif
|
|
|
|
/* 1 is sufficient as this is very short-lived */
|
|
#ifndef MEMP_NUM_COAPPACKET
|
|
#define MEMP_NUM_COAPPACKET 1
|
|
#endif
|
|
|
|
#ifndef MEMP_NUM_COAPNODE
|
|
#define MEMP_NUM_COAPNODE 4
|
|
#endif
|
|
|
|
#ifndef MEMP_NUM_COAPPDU
|
|
#define MEMP_NUM_COAPPDU MEMP_NUM_COAPNODE
|
|
#endif
|
|
|
|
#ifndef MEMP_NUM_COAP_SUBSCRIPTION
|
|
#define MEMP_NUM_COAP_SUBSCRIPTION 4
|
|
#endif
|
|
|
|
#ifndef MEMP_NUM_COAPRESOURCE
|
|
#define MEMP_NUM_COAPRESOURCE 10
|
|
#endif
|
|
|
|
#ifndef MEMP_NUM_COAPRESOURCEATTR
|
|
#define MEMP_NUM_COAPRESOURCEATTR 20
|
|
#endif
|
|
|
|
LWIP_MEMPOOL(COAP_CONTEXT, MEMP_NUM_COAPCONTEXT, sizeof(coap_context_t), "COAP_CONTEXT")
|
|
LWIP_MEMPOOL(COAP_ENDPOINT, MEMP_NUM_COAPENDPOINT, sizeof(coap_endpoint_t), "COAP_ENDPOINT")
|
|
LWIP_MEMPOOL(COAP_PACKET, MEMP_NUM_COAPPACKET, sizeof(coap_packet_t), "COAP_PACKET")
|
|
LWIP_MEMPOOL(COAP_NODE, MEMP_NUM_COAPNODE, sizeof(coap_queue_t), "COAP_NODE")
|
|
LWIP_MEMPOOL(COAP_PDU, MEMP_NUM_COAPPDU, sizeof(coap_pdu_t), "COAP_PDU")
|
|
LWIP_MEMPOOL(COAP_subscription, MEMP_NUM_COAP_SUBSCRIPTION, sizeof(coap_subscription_t), "COAP_subscription")
|
|
LWIP_MEMPOOL(COAP_RESOURCE, MEMP_NUM_COAPRESOURCE, sizeof(coap_resource_t), "COAP_RESOURCE")
|
|
LWIP_MEMPOOL(COAP_RESOURCEATTR, MEMP_NUM_COAPRESOURCEATTR, sizeof(coap_attr_t), "COAP_RESOURCEATTR")
|