Contiki 3.x
linkaddr.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007, Swedish Institute of Computer Science.
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  * This file is part of the Contiki operating system.
30  *
31  */
32 
33 /**
34  * \file
35  * Header file for the Rime address representation
36  * \author
37  * Adam Dunkels <adam@sics.se>
38  */
39 
40 /**
41  * \addtogroup rime
42  * @{
43  */
44 
45 /**
46  * \defgroup linkaddr Rime addresses
47  * @{
48  *
49  * The linkaddr module is an abstract representation of addresses in
50  * Rime.
51  *
52  */
53 
54 #ifndef LINKADDR_H_
55 #define LINKADDR_H_
56 
57 #include "contiki-conf.h"
58 
59 #ifdef LINKADDR_CONF_SIZE
60 #define LINKADDR_SIZE LINKADDR_CONF_SIZE
61 #else /* LINKADDR_SIZE */
62 #define LINKADDR_SIZE 2
63 #endif /* LINKADDR_SIZE */
64 
65 typedef union {
66  unsigned char u8[LINKADDR_SIZE];
67 #if LINKADDR_SIZE == 2
68  uint16_t u16;
69 #endif /* LINKADDR_SIZE == 2 */
70 } linkaddr_t;
71 
72 typedef union {
73  uint8_t u8[8];
74  uint16_t u16[4];
75 } linkaddr_extended_t;
76 
77 /**
78  * \brief Copy a Rime address
79  * \param dest The destination
80  * \param from The source
81  *
82  * This function copies a Rime address from one location
83  * to another.
84  *
85  */
86 void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *from);
87 
88 /**
89  * \brief Compare two Rime addresses
90  * \param addr1 The first address
91  * \param addr2 The second address
92  * \return Non-zero if the addresses are the same, zero if they are different
93  *
94  * This function compares two Rime addresses and returns
95  * the result of the comparison. The function acts like
96  * the '==' operator and returns non-zero if the addresses
97  * are the same, and zero if the addresses are different.
98  *
99  */
100 int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2);
101 
102 
103 /**
104  * \brief Set the address of the current node
105  * \param addr The address
106  *
107  * This function sets the Rime address of the node.
108  *
109  */
110 void linkaddr_set_node_addr(linkaddr_t *addr);
111 
112 /**
113  * \brief The Rime address of the node
114  *
115  * This variable contains the Rime address of the
116  * node. This variable should not be changed directly;
117  * rather, the linkaddr_set_node_addr() function should be
118  * used.
119  *
120  */
121 extern linkaddr_t linkaddr_node_addr;
122 
123 /**
124  * \brief The null Rime address
125  *
126  * This variable contains the null Rime address. The null
127  * address is used in route tables to indicate that the
128  * table entry is unused. Nodes with no configured address
129  * has the null address. Nodes with their node address set
130  * to the null address will have problems communicating
131  * with other nodes.
132  *
133  */
134 extern const linkaddr_t linkaddr_null;
135 
136 #endif /* LINKADDR_H_ */
137 /** @} */
138 /** @} */
linkaddr_t linkaddr_node_addr
The Rime address of the node.
Definition: linkaddr.c:48
const linkaddr_t linkaddr_null
The null Rime address.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
Definition: linkaddr.c:60
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two Rime addresses.
Definition: linkaddr.c:66
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
Definition: linkaddr.c:72