Generic Data Structures
[Framework]

Collaboration diagram for Generic Data Structures:


Data Structures

struct  fip_ds6_searchStatus_t
 Structure used to indicate the status of a search function. More...

Files

file  fip_ds6.c
 Generic Data Structure Access.
file  fip_ds6.h
 Generic Data Structure Access Header.

Typedefs

typedef unsigned char fip_ds6_index_t
 Index that points to a data structure entry.

Functions

fip_ds6_searchStatus_t fip_ds6_searchList (const unsigned char *ds, unsigned char entrySize, fip_ds6_index_t numberEntries, unsigned char offsetToItem, const unsigned char *searchTerm, unsigned char searchTermLength)
 Generic function to search various tables such as neighbour cache, routing table, etc.

Typedef Documentation

typedef unsigned char fip_ds6_index_t

Index that points to a data structure entry.


Function Documentation

fip_ds6_searchStatus_t fip_ds6_searchList ( const unsigned char *  ds,
unsigned char  entrySize,
fip_ds6_index_t  numberEntries,
unsigned char  offsetToItem,
const unsigned char *  searchTerm,
unsigned char  searchTermLength 
)

Generic function to search various tables such as neighbour cache, routing table, etc.

For this function to work the data structure must be an array of elements. Each element should be a structure, the first item in each element should be an enumerated type. This function will only consider the element as "used" if that enumerated type is non-zero. Thus as an example you could have the following definitions to define your data array:

  typedef enum { UNUSED = 0, VALID, WAITING } state_t;
  typedef struct {
     state_t        state
     unsigned char  address1[8];
     unsigned char  numberSends;
   } entry_t;

   entry_t  array[10];

You could then call this function with:

  fip_ds6_searchList( (unsigned char *)array, sizeof(entry_t), 10, offsetof(entry_t, address1), someCompare, 8);

This will search the list until the following is true: (array[i].state != UNUSED) && ((memcmp(array[i].address1, someCompare, 8) == 0) . Note: it is highly recommended to use both sizeof() and offsetof() to ensure you get the correct values, as your compiler may pad the structs to get better alignment! You will need to do this to get that macro:

 #include <stddef.h>

Parameters:
ds Pointer to start of data structure
entrySize Size of each entry in the array
numberEntries Number of entries in the array
offsetToItem Offset from the start of the entry to the item we are searching for
searchTerm Pointer to search term
searchTermLength Length of the search term, must be the same as length of item searched for
Returns:
Indicates status of found or not, and if found the index

References fip_ds6_searchStatus_t::index, and fip_ds6_searchStatus_t::itemFound.

Referenced by fip_nd6_neighbourCache_lookupByIp(), and fip_route6_findRouteByNextHop().


Generated on Wed Dec 8 13:00:30 2010 for FIP by  doxygen 1.5.7.1