Contiki-NG
Files | Data Structures | Functions | Variables
A module to handle Node IDs and MAC addresses in deployments

Files

file  deployment.c
 
    Code managing id<->mac address<->IPv6 address mapping, and doing this
    for different deployment scenarios: Cooja, Nodes, Indriya or Twist testbeds

 
file  deployment.h
 Per-deployment MAC <-> nodeid mapping.
 

Data Structures

struct  id_mac
 ID<->MAC address mapping structure. More...
 

Functions

void deployment_init (void)
 DEPLOYMENT_MAPPING: A table of struct id_mac that provides ID-MAC mapping for a deployment. More...
 
int deployment_node_count (void)
 Get the number of nodes for the deployment (length of mapping table) More...
 
uint16_t deployment_id_from_lladdr (const linkaddr_t *lladdr)
 Get node ID from a link-layer address, from the deployment mapping table. More...
 
void deployment_lladdr_from_id (linkaddr_t *lladdr, uint16_t id)
 Get node link-layer address from a node ID, from the deployment mapping table. More...
 
uint16_t deployment_id_from_iid (const uip_ipaddr_t *ipaddr)
 Get node ID from the IID of an IPv6 address. More...
 
void deployment_iid_from_id (uip_ipaddr_t *ipaddr, uint16_t id)
 Get IPv6 IID from node IDs. More...
 
uint16_t deployment_id_from_index (uint16_t index)
 Get node ID from index in mapping table. More...
 

Variables

const struct id_mac DEPLOYMENT_MAPPING []
 List of ID<->MAC mapping used for different deployments.
 
static int node_count = 0
 The number of nodes in the deployment.
 

Detailed Description

Function Documentation

◆ deployment_id_from_iid()

uint16_t deployment_id_from_iid ( const uip_ipaddr_t *  ipaddr)

Get node ID from the IID of an IPv6 address.

Parameters
ipaddrThe IPv6 (global or link-local) address that contains the IID
Returns
Node ID from a corresponding IID

Definition at line 115 of file deployment.c.

References deployment_id_from_lladdr(), and uip_ds6_set_lladdr_from_iid().

◆ deployment_id_from_index()

uint16_t deployment_id_from_index ( uint16_t  index)

Get node ID from index in mapping table.

Parameters
indexThe index in the deployment mapping table
Returns
Node ID at the corresponding index

Definition at line 131 of file deployment.c.

References DEPLOYMENT_MAPPING, and deployment_node_count().

◆ deployment_id_from_lladdr()

uint16_t deployment_id_from_lladdr ( const linkaddr_t *  lladdr)

Get node ID from a link-layer address, from the deployment mapping table.

Parameters
lladdrThe link-layer address to look up for
Returns
Node ID from a corresponding link-layer address

Definition at line 82 of file deployment.c.

References DEPLOYMENT_MAPPING.

Referenced by deployment_id_from_iid().

◆ deployment_iid_from_id()

void deployment_iid_from_id ( uip_ipaddr_t *  ipaddr,
uint16_t  id 
)

Get IPv6 IID from node IDs.

Parameters
ipaddrThe IPv6 where to write the IID
idThe node ID

Definition at line 123 of file deployment.c.

References deployment_lladdr_from_id(), and uip_ds6_set_addr_iid().

◆ deployment_init()

void deployment_init ( void  )

DEPLOYMENT_MAPPING: A table of struct id_mac that provides ID-MAC mapping for a deployment.

Example with four nodes: In configuration file: #define DEPLOYMENT_MAPPING custom_array In a .c file: const struct id_mac custom_array[] = { { 1, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb6,0x14}}}, { 2, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb1,0xe7}}}, { 3, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb4,0x35}}}, { 4, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb1,0xcf}}}, { 0, {{0}}} }; Initialize the deployment module

Definition at line 62 of file deployment.c.

References DEPLOYMENT_MAPPING.

Referenced by node_id_init().

◆ deployment_lladdr_from_id()

void deployment_lladdr_from_id ( linkaddr_t *  lladdr,
uint16_t  id 
)

Get node link-layer address from a node ID, from the deployment mapping table.

Parameters
lladdrA pointer where to write the link-layer address
idThe node ID to look up for

Definition at line 99 of file deployment.c.

References DEPLOYMENT_MAPPING.

Referenced by deployment_iid_from_id().

◆ deployment_node_count()

int deployment_node_count ( void  )

Get the number of nodes for the deployment (length of mapping table)

Returns
The number of nodes in the deployment

Definition at line 76 of file deployment.c.

References node_count.

Referenced by deployment_id_from_index().