18#ifndef NET_STACK_MEMORY_MANAGER_H
19#define NET_STACK_MEMORY_MANAGER_H
50typedef void net_stack_mem_buf_t;
75 virtual net_stack_mem_buf_t *
alloc_heap(uint32_t size, uint32_t align) = 0;
88 virtual net_stack_mem_buf_t *
alloc_pool(uint32_t size, uint32_t align) = 0;
114 virtual void free(net_stack_mem_buf_t *buf) = 0;
135 virtual void copy(net_stack_mem_buf_t *to_buf,
const net_stack_mem_buf_t *from_buf) = 0;
148 virtual void copy_to_buf(net_stack_mem_buf_t *to_buf,
const void *ptr, uint32_t len);
160 virtual uint32_t
copy_from_buf(
void *ptr, uint32_t len,
const net_stack_mem_buf_t *from_buf)
const;
172 virtual void cat(net_stack_mem_buf_t *to_buf, net_stack_mem_buf_t *cat_buf) = 0;
182 virtual net_stack_mem_buf_t *
get_next(
const net_stack_mem_buf_t *buf)
const = 0;
193 while (buf !=
nullptr) {
206 virtual void *
get_ptr(
const net_stack_mem_buf_t *buf)
const = 0;
214 virtual uint32_t
get_len(
const net_stack_mem_buf_t *buf)
const = 0;
233 virtual void set_len(net_stack_mem_buf_t *buf, uint32_t len) = 0;
virtual uint32_t get_pool_alloc_unit(uint32_t align) const =0
Get memory buffer pool allocation unit.
virtual void copy_to_buf(net_stack_mem_buf_t *to_buf, const void *ptr, uint32_t len)
Copy to a memory buffer chain.
virtual net_stack_mem_buf_t * alloc_pool(uint32_t size, uint32_t align)=0
Allocates memory buffer chain from a pool.
virtual void cat(net_stack_mem_buf_t *to_buf, net_stack_mem_buf_t *cat_buf)=0
Concatenate two memory buffer chains.
virtual uint32_t copy_from_buf(void *ptr, uint32_t len, const net_stack_mem_buf_t *from_buf) const
Copy from a memory buffer chain.
virtual net_stack_mem_buf_t * alloc_heap(uint32_t size, uint32_t align)=0
Allocates memory buffer from the heap.
virtual void * get_ptr(const net_stack_mem_buf_t *buf) const =0
Return pointer to the payload of the buffer.
virtual uint32_t get_len(const net_stack_mem_buf_t *buf) const =0
Return payload size of this individual buffer (NOT including any chained buffers)
virtual uint32_t get_pool_size() const =0
Get memory buffer pool size.
virtual void free(net_stack_mem_buf_t *buf)=0
Free memory buffer chain.
@ HEAP_ALLOCATED
Allocated from the memory manager's heap.
@ VOLATILE
Buffer points to data from the application that will not live past the current network stack call.
@ CONSTANT
Buffer points to constant data (e.g. in ROM) that will live forever.
@ POOL_ALLOCATED
Allocated from the memory manager's pool.
virtual net_stack_mem_buf_t * get_next(const net_stack_mem_buf_t *buf) const =0
Returns the next buffer.
virtual Lifetime get_lifetime(net_stack_mem_buf_t const *buf) const =0
Gets the lifetime of the buffer.
virtual void copy(net_stack_mem_buf_t *to_buf, const net_stack_mem_buf_t *from_buf)=0
Copy a memory buffer chain.
mbed::Callback< void()> onPoolSpaceAvailCallback
Callback which shall be called (if set) by the implementation after one or more buffer spaces become ...
size_t count_buffers(const net_stack_mem_buf_t *buf)
Count the number of buffers in a buffer chain.
void set_on_pool_space_avail_cb(mbed::Callback< void()> cb)
Set callback which will be called when pool space becomes available.
virtual void set_len(net_stack_mem_buf_t *buf, uint32_t len)=0
Sets the payload size of the buffer.
virtual uint32_t get_total_len(const net_stack_mem_buf_t *buf) const =0
Return total length of a memory buffer chain.
Callback class based on template specialization.