• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * This file is part of the CoAP library libcoap. Please see README for terms
5  * of use.
6  */
7 
8 /* Memory pool definitions for the libcoap when used with lwIP (which has its
9  * own mechanism for quickly allocating chunks of data with known sizes). Has
10  * to be findable by lwIP (ie. an #include <lwippools.h> must either directly
11  * include this or include something more generic which includes this), and
12  * MEMP_USE_CUSTOM_POOLS has to be set in lwipopts.h. */
13 
14 #include "coap_internal.h"
15 #include "net.h"
16 #include "resource.h"
17 #include "subscribe.h"
18 
19 #ifndef MEMP_NUM_COAPCONTEXT
20 #define MEMP_NUM_COAPCONTEXT 1
21 #endif
22 
23 #ifndef MEMP_NUM_COAPENDPOINT
24 #define MEMP_NUM_COAPENDPOINT 1
25 #endif
26 
27 /* 1 is sufficient as this is very short-lived */
28 #ifndef MEMP_NUM_COAPPACKET
29 #define MEMP_NUM_COAPPACKET 1
30 #endif
31 
32 #ifndef MEMP_NUM_COAPNODE
33 #define MEMP_NUM_COAPNODE 4
34 #endif
35 
36 #ifndef MEMP_NUM_COAPPDU
37 #define MEMP_NUM_COAPPDU MEMP_NUM_COAPNODE
38 #endif
39 
40 #ifndef MEMP_NUM_COAPSESSION
41 #define MEMP_NUM_COAPSESSION 2
42 #endif
43 
44 #ifndef MEMP_NUM_COAP_SUBSCRIPTION
45 #define MEMP_NUM_COAP_SUBSCRIPTION 4
46 #endif
47 
48 #ifndef MEMP_NUM_COAPRESOURCE
49 #define MEMP_NUM_COAPRESOURCE 10
50 #endif
51 
52 #ifndef MEMP_NUM_COAPRESOURCEATTR
53 #define MEMP_NUM_COAPRESOURCEATTR 20
54 #endif
55 
56 #ifndef MEMP_NUM_COAPOPTLIST
57 #define MEMP_NUM_COAPOPTLIST 1
58 #endif
59 
60 #ifndef MEMP_LEN_COAPOPTLIST
61 #define MEMP_LEN_COAPOPTLIST 12
62 #endif
63 
64 #ifndef MEMP_NUM_COAPSTRING
65 #define MEMP_NUM_COAPSTRING 10
66 #endif
67 
68 #ifndef MEMP_LEN_COAPSTRING
69 #define MEMP_LEN_COAPSTRING 32
70 #endif
71 
72 #ifndef MEMP_NUM_COAPCACHE_KEYS
73 #define MEMP_NUM_COAPCACHE_KEYS        (2U)
74 #endif /* MEMP_NUM_COAPCACHE_KEYS */
75 
76 #ifndef MEMP_NUM_COAPCACHE_ENTRIES
77 #define MEMP_NUM_COAPCACHE_ENTRIES        (2U)
78 #endif /* MEMP_NUM_COAPCACHE_ENTRIES */
79 
80 #ifndef MEMP_NUM_COAPPDUBUF
81 #define MEMP_NUM_COAPPDUBUF 2
82 #endif
83 
84 #ifndef MEMP_LEN_COAPPDUBUF
85 #define MEMP_LEN_COAPPDUBUF 32
86 #endif
87 
88 #ifndef MEMP_NUM_COAPLGXMIT
89 #define MEMP_NUM_COAPLGXMIT 2
90 #endif
91 
92 #ifndef MEMP_NUM_COAPLGCRCV
93 #define MEMP_NUM_COAPLGCRCV 2
94 #endif
95 
96 #ifndef MEMP_NUM_COAPLGSRCV
97 #define MEMP_NUM_COAPLGSRCV 2
98 #endif
99 
100 LWIP_MEMPOOL(COAP_CONTEXT, MEMP_NUM_COAPCONTEXT, sizeof(coap_context_t), "COAP_CONTEXT")
101 LWIP_MEMPOOL(COAP_ENDPOINT, MEMP_NUM_COAPENDPOINT, sizeof(coap_endpoint_t), "COAP_ENDPOINT")
102 LWIP_MEMPOOL(COAP_PACKET, MEMP_NUM_COAPPACKET, sizeof(coap_packet_t), "COAP_PACKET")
103 LWIP_MEMPOOL(COAP_NODE, MEMP_NUM_COAPNODE, sizeof(coap_queue_t), "COAP_NODE")
104 LWIP_MEMPOOL(COAP_PDU, MEMP_NUM_COAPPDU, sizeof(coap_pdu_t), "COAP_PDU")
105 LWIP_MEMPOOL(COAP_SESSION, MEMP_NUM_COAPSESSION, sizeof(coap_session_t), "COAP_SESSION")
106 LWIP_MEMPOOL(COAP_subscription, MEMP_NUM_COAP_SUBSCRIPTION, sizeof(coap_subscription_t), "COAP_subscription")
107 LWIP_MEMPOOL(COAP_RESOURCE, MEMP_NUM_COAPRESOURCE, sizeof(coap_resource_t), "COAP_RESOURCE")
108 LWIP_MEMPOOL(COAP_RESOURCEATTR, MEMP_NUM_COAPRESOURCEATTR, sizeof(coap_attr_t), "COAP_RESOURCEATTR")
109 LWIP_MEMPOOL(COAP_OPTLIST, MEMP_NUM_COAPOPTLIST, sizeof(coap_optlist_t)+MEMP_LEN_COAPOPTLIST, "COAP_OPTLIST")
110 LWIP_MEMPOOL(COAP_STRING, MEMP_NUM_COAPSTRING, sizeof(coap_string_t)+MEMP_LEN_COAPSTRING, "COAP_STRING")
111 LWIP_MEMPOOL(COAP_CACHE_KEY, MEMP_NUM_COAPCACHE_KEYS, sizeof(coap_cache_key_t), "COAP_CACHE_KEY")
112 LWIP_MEMPOOL(COAP_CACHE_ENTRY, MEMP_NUM_COAPCACHE_ENTRIES, sizeof(coap_cache_entry_t), "COAP_CACHE_ENTRY")
113 LWIP_MEMPOOL(COAP_PDU_BUF, MEMP_NUM_COAPPDUBUF, MEMP_LEN_COAPPDUBUF, "COAP_PDU_BUF")
114 LWIP_MEMPOOL(COAP_LG_XMIT, MEMP_NUM_COAPLGXMIT, sizeof(coap_lg_xmit_t), "COAP_LG_XMIT")
115 LWIP_MEMPOOL(COAP_LG_CRCV, MEMP_NUM_COAPLGCRCV, sizeof(coap_lg_crcv_t), "COAP_LG_CRCV")
116 LWIP_MEMPOOL(COAP_LG_SRCV, MEMP_NUM_COAPLGSRCV, sizeof(coap_lg_srcv_t), "COAP_LG_SRCV")
117 
118