Contiki-NG
Loading...
Searching...
No Matches
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
64typedef 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 */
82void 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 True if the addresses are the same, false if they are different
89 */
90bool linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2);
91
92
93/**
94 * \brief The link-layer address of the node
95 *
96 * This variable contains the link-layer address of the
97 * node. This variable should not be changed directly;
98 * rather, the linkaddr_set_node_addr() function should be
99 * used.
100 *
101 */
102extern linkaddr_t linkaddr_node_addr;
103
104/**
105 * \brief The null link-layer address
106 *
107 * This variable contains the null link-layer address. The null
108 * address is used in route tables to indicate that the
109 * table entry is unused. Nodes with no configured address
110 * has the null address. Nodes with their node address set
111 * to the null address will have problems communicating
112 * with other nodes.
113 *
114 */
115extern const linkaddr_t linkaddr_null;
116
117/**
118 * \brief Set the address of the current node
119 * \param addr The address
120 *
121 * This function sets the link-layer address of the node.
122 *
123 */
124static inline void linkaddr_set_node_addr(linkaddr_t *addr)
125{
127}
128
129#endif /* LINKADDR_H_ */
130/** @} */
131/** @} */
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
bool linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
Definition linkaddr.c:69
const linkaddr_t linkaddr_null
The null link-layer address.
static void linkaddr_set_node_addr(linkaddr_t *addr)
Set the address of the current node.
Definition linkaddr.h:124
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition uip-nd6.c:107