Contiki 2.5
Files | Macros | Functions
MMEM-based temporary Storage

Files

file  storage_mmem.c
 

Macros

#define STORAGE_MMEM_FLAGS_LOCKED   0x1
 Flags for the storage.
 

Functions

void storage_mmem_prune ()
 "Internal" functions More...
 
void storage_mmem_reinit (void)
 Sets the storage to its initial state.
 
uint16_t storage_mmem_delete_bundle (uint32_t bundle_number, uint8_t reason)
 deletes a bundle from storage More...
 
void storage_mmem_update_statistics ()
 internal function to send statistics to statistics module
 
void storage_mmem_init (void)
 called by agent at startup
 
uint8_t storage_mmem_make_room (struct mmem *bundlemem)
 This function delete as many bundles from the storage as necessary to have at least one slot and the number of required of memory free. More...
 
uint8_t storage_mmem_save_bundle (struct mmem *bundlemem, uint32_t **bundle_number_ptr)
 saves a bundle in storage More...
 
struct mmem * storage_mmem_read_bundle (uint32_t bundle_num)
 reads a bundle from storage More...
 
uint16_t storage_mmem_get_free_space (struct mmem *bundlemem)
 checks if there is space for a bundle More...
 
uint16_t storage_mmem_get_bundle_numbers (void)
 Get the number of slots available in storage. More...
 
struct storage_entry_tstorage_mmem_get_bundles (void)
 Get the bundle list. More...
 
uint8_t storage_mmem_lock_bundle (uint32_t bundle_num)
 Mark a bundle as locked so that it will not be deleted even if we are running out of space. More...
 
void storage_mmem_unlock_bundle (uint32_t bundle_num)
 Mark a bundle as unlocked after being locked previously.
 

Detailed Description

Function Documentation

uint16_t storage_mmem_delete_bundle ( uint32_t  bundle_number,
uint8_t  reason 
)

deletes a bundle from storage

Parameters
bundle_numberbundle number to be deleted
reasonreason code
Returns
1 on success or 0 on error

Definition at line 388 of file storage_mmem.c.

References bundle_decrement(), entry, list_head(), list_item_next(), list_remove(), memb_free(), MMEM_PTR, NULL, STATUSREPORT, and storage_mmem_update_statistics().

Referenced by storage_mmem_make_room(), storage_mmem_prune(), and storage_mmem_reinit().

uint16_t storage_mmem_get_bundle_numbers ( void  )

Get the number of slots available in storage.

Returns
the number of free slots

Definition at line 506 of file storage_mmem.c.

struct storage_entry_t* storage_mmem_get_bundles ( void  )
read

Get the bundle list.

Returns
pointer to first bundle list entry

Definition at line 514 of file storage_mmem.c.

References list_head().

uint16_t storage_mmem_get_free_space ( struct mmem *  bundlemem)

checks if there is space for a bundle

Parameters
bundlemempointer to a bundle struct (not used here)
Returns
number of free slots

Definition at line 497 of file storage_mmem.c.

References BUNDLE_STORAGE_SIZE.

uint8_t storage_mmem_lock_bundle ( uint32_t  bundle_num)

Mark a bundle as locked so that it will not be deleted even if we are running out of space.

Parameters
bundle_numBundle number
Returns
1 on success or 0 on error

Definition at line 525 of file storage_mmem.c.

References entry, list_head(), list_item_next(), NULL, and STORAGE_MMEM_FLAGS_LOCKED.

uint8_t storage_mmem_make_room ( struct mmem *  bundlemem)

This function delete as many bundles from the storage as necessary to have at least one slot and the number of required of memory free.

Parameters
bundlememPointer to the MMEM struct containing the bundle
Returns
1 on success, 0 if no room could be made free

Definition at line 168 of file storage_mmem.c.

References BUNDLE_STORAGE_SIZE, entry, list_head(), list_item_next(), MMEM_PTR, NULL, storage_mmem_delete_bundle(), STORAGE_MMEM_FLAGS_LOCKED, and storage_mmem_prune().

Referenced by storage_mmem_save_bundle().

void storage_mmem_prune ( )

"Internal" functions

deletes expired bundles from storage

Definition at line 123 of file storage_mmem.c.

References ctimer_restart(), entry, list_head(), list_item_next(), MMEM_PTR, NULL, and storage_mmem_delete_bundle().

Referenced by storage_mmem_init(), and storage_mmem_make_room().

struct mmem* storage_mmem_read_bundle ( uint32_t  bundle_num)
read

reads a bundle from storage

Parameters
bundle_numbundle number to read
Returns
pointer to the MMEM struct, NULL on error

Definition at line 448 of file storage_mmem.c.

References bundle_increment(), entry, list_head(), list_item_next(), MMEM_PTR, and NULL.

uint8_t storage_mmem_save_bundle ( struct mmem *  bundlemem,
uint32_t **  bundle_number_ptr 
)

saves a bundle in storage

Parameters
bundlemempointer to the bundle
bundle_number_ptrpointer where the bundle number will be stored (on success)
Returns
0 on error, 1 on success

Definition at line 299 of file storage_mmem.c.

References bundle_decrement(), bundle_increment(), entry, list_add(), list_head(), list_item_next(), memb_alloc(), MMEM_PTR, NULL, storage_mmem_make_room(), and storage_mmem_update_statistics().