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