Contiki 2.5
Files | Data Structures | Functions
Bundle Memory Representation

Files

file  bundle.c
 this file implements the bundle memory representation
 
file  bundle.h
 this file defines the bundle memory representation
 

Data Structures

struct  bundle_t
 this struct defines the bundle for internal processing More...
 

Functions

struct mmem * bundle_create_bundle ()
 Get a new bundle structure allocated. More...
 
int bundle_add_block (struct mmem *bundlemem, uint8_t type, uint8_t flags, uint8_t *data, uint8_t d_len)
 Add a block to a bundle. More...
 
struct bundle_block_t * bundle_get_block (struct mmem *bundlemem, uint8_t i)
 Returns a pointer a bundle block. More...
 
struct bundle_block_t * bundle_get_block_by_type (struct mmem *bundlemem, uint8_t type)
 Returns pointer to first bundle block of specific type. More...
 
struct bundle_block_t * bundle_get_payload_block (struct mmem *bundlemem)
 Returns pointer to bundle payload block. More...
 
uint8_t bundle_set_attr (struct mmem *bundlemem, uint8_t attr, uint32_t *val)
 sets an attribute of a bundle More...
 
uint8_t bundle_get_attr (struct mmem *bundlemem, uint8_t attr, uint32_t *val)
 Gets an attribute of a bundle. More...
 
struct mmem * bundle_recover_bundle (uint8_t *buffer, int size)
 generates the bundle struct from raw data More...
 
int bundle_encode_bundle (struct mmem *bundlemem, uint8_t *buffer, int max_len)
 Encodes the bundle to raw data. More...
 
int bundle_increment (struct mmem *bundlemem)
 Increments the reference counter for a MMEM struct containing a bundle. More...
 
int bundle_decrement (struct mmem *bundlemem)
 Decrements the reference counter for a MMEM struct containing a bundle Frees the struct when reference counter is down to 0. More...
 
uint16_t bundle_delete_bundle (struct mmem *bundlemem)
 free a given MMEM allocation of a bundle struct More...
 
rimeaddr_t convert_eid_to_rime (uint32_t eid)
 converts IPN EIDs (uint32_t) into the RIME address
 
uint32_t convert_rime_to_eid (rimeaddr_t *dest)
 converts a RIME address into an IPN EID
 

Detailed Description

Function Documentation

int bundle_add_block ( struct mmem *  bundlemem,
uint8_t  type,
uint8_t  flags,
uint8_t *  data,
uint8_t  d_len 
)

Add a block to a bundle.

Parameters
bundlemempointer to the MMEM allocation of the bundle
typetype of the block
flagsprocessing flags of the block
datapointer to the block payload
d_lenlength of the block payload
Returns
1 on success or 0 on error

Definition at line 67 of file bundle.c.

References flags, MMEM_PTR, and mmem_realloc().

Referenced by statusreport_basic_send().

struct mmem * bundle_create_bundle ( )
read

Get a new bundle structure allocated.

Returns
MMEM allocation of the bundle, NULL in case of an error

Definition at line 38 of file bundle.c.

References mmem_alloc(), MMEM_PTR, NULL, and PROCESS_CURRENT.

Referenced by bundle_recover_bundle(), statusreport_basic_send(), and storage_coffee_read_bundle().

int bundle_decrement ( struct mmem *  bundlemem)
uint16_t bundle_delete_bundle ( struct mmem *  bundlemem)

free a given MMEM allocation of a bundle struct

Parameters
bundlememthe MMEM allocation to free

A bit of magic is involved here because we want to also free the bundleslot that this bundle belongs to.

Definition at line 572 of file bundle.c.

References MMEM_PTR.

Referenced by bundle_recover_bundle().

int bundle_encode_bundle ( struct mmem *  bundlemem,
uint8_t *  buffer,
int  max_len 
)

Encodes the bundle to raw data.

Parameters
bundlemempointer to the MMEM struct containing the bundle
bufferpointer to a buffer
max_lenSize of the buffer
Returns
The number of bytes that were written to buf

Definition at line 394 of file bundle.c.

References MMEM_PTR, sdnv_encode(), and sdnv_encoding_len().

uint8_t bundle_get_attr ( struct mmem *  bundlemem,
uint8_t  attr,
uint32_t *  val 
)

Gets an attribute of a bundle.

Parameters
bundlemempointer to the MMEM struct containing the bundle
attrattribute to get
valpointer to the variable where the value will be written
Returns
1 on success or 0 on error

Definition at line 196 of file bundle.c.

References MMEM_PTR.

Referenced by routing_epidemic_new_bundle(), routing_flooding_new_bundle(), and statusreport_basic_send().

struct bundle_block_t * bundle_get_block ( struct mmem *  bundlemem,
uint8_t  i 
)
read

Returns a pointer a bundle block.

Parameters
bundlememMMEM allocation of the bundle
iindex of the block. Starts at 0
Returns
the block or NULL on error

Definition at line 102 of file bundle.c.

References MMEM_PTR, and NULL.

struct bundle_block_t * bundle_get_block_by_type ( struct mmem *  bundlemem,
uint8_t  type 
)
read

Returns pointer to first bundle block of specific type.

Parameters
bundlememMMEM allocation of the bundle
typetype of the block (see bundle.h)
Returns
the block of NULL on error

Definition at line 117 of file bundle.c.

References MMEM_PTR, and NULL.

Referenced by bundle_get_payload_block().

struct bundle_block_t * bundle_get_payload_block ( struct mmem *  bundlemem)
read

Returns pointer to bundle payload block.

Parameters
bundlememMMEM allocation of the bundle
Returns
the block of NULL on error

Definition at line 134 of file bundle.c.

References bundle_get_block_by_type().

Referenced by dispatching_check_report().

int bundle_increment ( struct mmem *  bundlemem)

Increments the reference counter for a MMEM struct containing a bundle.

Returns
Returns the number of references on the bundle or -1 on error

Definition at line 552 of file bundle.c.

References MMEM_PTR.

Referenced by storage_mmem_read_bundle(), and storage_mmem_save_bundle().

struct mmem * bundle_recover_bundle ( uint8_t *  buffer,
int  size 
)
read

generates the bundle struct from raw data

Parameters
bufferpointer to the buffer with raw data
sizesize of raw data
Returns
Pointer to the MMEM struct containing the bundle

Definition at line 252 of file bundle.c.

References bundle_create_bundle(), bundle_delete_bundle(), MMEM_PTR, NULL, and sdnv_decode().

uint8_t bundle_set_attr ( struct mmem *  bundlemem,
uint8_t  attr,
uint32_t *  val 
)

sets an attribute of a bundle

Parameters
bundlemempointer to the MMEM struct containing bundle
attrattribute to be set
valpointer to the value to be set
Returns
length of the set value on success or 0 on error

Definition at line 138 of file bundle.c.

References MMEM_PTR.

Referenced by statusreport_basic_send().