Contiki-Inga 3.x
linkaddr.h
Go to the documentation of this file.
1 /**
2  * \addtogroup rime
3  * @{
4  */
5 
6 /**
7  * \defgroup linkaddr Rime addresses
8  * @{
9  *
10  * The linkaddr module is an abstract representation of addresses in
11  * Rime.
12  *
13  */
14 
15 /*
16  * Copyright (c) 2007, Swedish Institute of Computer Science.
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions
21  * are met:
22  * 1. Redistributions of source code must retain the above copyright
23  * notice, this list of conditions and the following disclaimer.
24  * 2. Redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in the
26  * documentation and/or other materials provided with the distribution.
27  * 3. Neither the name of the Institute nor the names of its contributors
28  * may be used to endorse or promote products derived from this software
29  * without specific prior written permission.
30  *
31  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
32  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
35  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41  * SUCH DAMAGE.
42  *
43  * This file is part of the Contiki operating system.
44  *
45  */
46 
47 /**
48  * \file
49  * Header file for the Rime address representation
50  * \author
51  * Adam Dunkels <adam@sics.se>
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 } linkaddr_t;
68 
69 
70 /**
71  * \brief Copy a Rime address
72  * \param dest The destination
73  * \param from The source
74  *
75  * This function copies a Rime address from one location
76  * to another.
77  *
78  */
79 void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *from);
80 
81 /**
82  * \brief Compare two Rime addresses
83  * \param addr1 The first address
84  * \param addr2 The second address
85  * \return Non-zero if the addresses are the same, zero if they are different
86  *
87  * This function compares two Rime addresses and returns
88  * the result of the comparison. The function acts like
89  * the '==' operator and returns non-zero if the addresses
90  * are the same, and zero if the addresses are different.
91  *
92  */
93 int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2);
94 
95 
96 /**
97  * \brief Set the address of the current node
98  * \param addr The address
99  *
100  * This function sets the Rime address of the node.
101  *
102  */
103 void linkaddr_set_node_addr(linkaddr_t *addr);
104 
105 /**
106  * \brief The Rime address of the node
107  *
108  * This variable contains the Rime address of the
109  * node. This variable should not be changed directly;
110  * rather, the linkaddr_set_node_addr() function should be
111  * used.
112  *
113  */
114 extern linkaddr_t linkaddr_node_addr;
115 
116 /**
117  * \brief The null Rime address
118  *
119  * This variable contains the null Rime address. The null
120  * address is used in route tables to indicate that the
121  * table entry is unused. Nodes with no configured address
122  * has the null address. Nodes with their node address set
123  * to the null address will have problems communicating
124  * with other nodes.
125  *
126  */
127 extern const linkaddr_t linkaddr_null;
128 
129 #endif /* LINKADDR_H_ */
130 /** @} */
131 /** @} */