Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
deployment.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018, RISE SICS.
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*
29
*/
30
31
/**
32
* \addtogroup lib
33
* @{
34
*
35
* \defgroup deployment A module to handle Node IDs and MAC addresses in deployments
36
* @{
37
*
38
* \file
39
* Per-deployment MAC <-> nodeid mapping
40
* \author Simon Duquennoy <simon.duquennoy@ri.se>
41
*/
42
43
#ifndef DEPLOYMENT_H_
44
#define DEPLOYMENT_H_
45
46
#include "contiki-conf.h"
47
#include "
net/ipv6/uip.h
"
48
#include "
net/linkaddr.h
"
49
50
/**
51
* \brief ID<->MAC address mapping structure
52
*/
53
struct
id_mac
{
54
uint16_t id;
55
linkaddr_t mac;
56
};
57
58
/**
59
* DEPLOYMENT_MAPPING:
60
* A table of struct id_mac that provides ID-MAC mapping for a deployment.
61
* Example with four nodes:
62
* In configuration file:
63
* \#define DEPLOYMENT_MAPPING custom_array
64
* In a .c file:
65
* const struct id_mac custom_array[] = {
66
{ 1, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb6,0x14}}},
67
{ 2, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb1,0xe7}}},
68
{ 3, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb4,0x35}}},
69
{ 4, {{0x00,0x12,0x4b,0x00,0x06,0x0d,0xb1,0xcf}}},
70
{ 0, {{0}}}
71
};
72
*/
73
74
/**
75
* Initialize the deployment module
76
*/
77
void
deployment_init
(
void
);
78
79
/**
80
* Get the number of nodes for the deployment (length of mapping table)
81
*
82
* \return The number of nodes in the deployment
83
*/
84
int
deployment_node_count
(
void
);
85
86
/**
87
* Get node ID from a link-layer address, from the deployment mapping table
88
*
89
* \param lladdr The link-layer address to look up for
90
* \return Node ID from a corresponding link-layer address
91
*/
92
uint16_t
deployment_id_from_lladdr
(
const
linkaddr_t *lladdr);
93
94
/**
95
* Get node link-layer address from a node ID, from the deployment mapping table
96
*
97
* \param lladdr A pointer where to write the link-layer address
98
* \param id The node ID to look up for
99
*/
100
void
deployment_lladdr_from_id
(linkaddr_t *lladdr, uint16_t
id
);
101
102
/**
103
* Get node ID from the IID of an IPv6 address
104
*
105
* \param ipaddr The IPv6 (global or link-local) address that contains the IID
106
* \return Node ID from a corresponding IID
107
*/
108
uint16_t
deployment_id_from_iid
(
const
uip_ipaddr_t *
ipaddr
);
109
110
/**
111
* Get IPv6 IID from node IDs
112
*
113
* \param ipaddr The IPv6 where to write the IID
114
* \param id The node ID
115
*/
116
void
deployment_iid_from_id
(uip_ipaddr_t *
ipaddr
, uint16_t
id
);
117
118
/**
119
* Get node ID from index in mapping table
120
*
121
* \param index The index in the deployment mapping table
122
* \return Node ID at the corresponding index
123
*/
124
uint16_t
deployment_id_from_index
(uint16_t index);
125
126
#endif
/* DEPLOYMENT_H_ */
127
/**
128
* @}
129
* @}
130
*/
deployment_id_from_index
uint16_t deployment_id_from_index(uint16_t index)
Get node ID from index in mapping table.
Definition
deployment.c:131
deployment_node_count
int deployment_node_count(void)
Get the number of nodes for the deployment (length of mapping table).
Definition
deployment.c:76
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.
Definition
deployment.c:115
deployment_init
void deployment_init(void)
DEPLOYMENT_MAPPING: A table of struct id_mac that provides ID-MAC mapping for a deployment.
Definition
deployment.c:62
deployment_iid_from_id
void deployment_iid_from_id(uip_ipaddr_t *ipaddr, uint16_t id)
Get IPv6 IID from node IDs.
Definition
deployment.c:123
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.
Definition
deployment.c:99
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.
Definition
deployment.c:82
linkaddr.h
Header file for the link-layer address representation.
id_mac
ID<->MAC address mapping structure.
Definition
deployment.h:53
ipaddr
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition
uip-nd6.c:116
uip.h
Header file for the uIP TCP/IP stack.
os
services
deployment
deployment.h
Generated on
for Contiki-NG by
1.17.0