Contiki 3.x
collect-neighbor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006, 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 Contiki radio neighborhood management
36  * \author
37  * Adam Dunkels <adam@sics.se>
38  */
39 
40 /**
41  * \addtogroup rime
42  * @{
43  */
44 
45 /**
46  * \defgroup rimeneighbor Collect neighbor management
47  * @{
48  *
49  * The neighbor module manages the neighbor table that is used by the
50  * Collect module.
51  */
52 
53 #ifndef COLLECT_NEIGHBOR_H_
54 #define COLLECT_NEIGHBOR_H_
55 
56 #include "net/linkaddr.h"
58 #include "lib/list.h"
59 
60 struct collect_neighbor_list {
61  LIST_STRUCT(list);
62  struct ctimer periodic;
63 };
64 
65 struct collect_neighbor {
66  struct collect_neighbor *next;
67  linkaddr_t addr;
68  uint16_t rtmetric;
69  uint16_t age;
70  uint16_t le_age;
71  struct collect_link_estimate le;
72  struct timer congested_timer;
73 };
74 
75 void collect_neighbor_init(void);
76 
77 list_t collect_neighbor_list(struct collect_neighbor_list *neighbor_list);
78 
79 void collect_neighbor_list_new(struct collect_neighbor_list *neighbor_list);
80 
81 int collect_neighbor_list_add(struct collect_neighbor_list *neighbor_list,
82  const linkaddr_t *addr, uint16_t rtmetric);
83 void collect_neighbor_list_remove(struct collect_neighbor_list *neighbor_list,
84  const linkaddr_t *addr);
85 struct collect_neighbor *collect_neighbor_list_find(struct collect_neighbor_list *neighbor_list,
86  const linkaddr_t *addr);
87 struct collect_neighbor *collect_neighbor_list_best(struct collect_neighbor_list *neighbor_list);
88 int collect_neighbor_list_num(struct collect_neighbor_list *neighbor_list);
89 struct collect_neighbor *collect_neighbor_list_get(struct collect_neighbor_list *neighbor_list, int num);
90 void collect_neighbor_list_purge(struct collect_neighbor_list *neighbor_list);
91 
92 void collect_neighbor_update_rtmetric(struct collect_neighbor *n,
93  uint16_t rtmetric);
94 void collect_neighbor_tx(struct collect_neighbor *n, uint16_t num_tx);
95 void collect_neighbor_rx(struct collect_neighbor *n);
96 void collect_neighbor_tx_fail(struct collect_neighbor *n, uint16_t num_tx);
97 void collect_neighbor_set_congested(struct collect_neighbor *n);
98 int collect_neighbor_is_congested(struct collect_neighbor *n);
99 
100 uint16_t collect_neighbor_link_estimate(struct collect_neighbor *n);
101 uint16_t collect_neighbor_rtmetric_link_estimate(struct collect_neighbor *n);
102 uint16_t collect_neighbor_rtmetric(struct collect_neighbor *n);
103 
104 
105 #endif /* COLLECT_NEIGHBOR_H_ */
106 /** @} */
107 /** @} */
Linked list manipulation routines.
A timer.
Definition: timer.h:86
void ** list_t
The linked list type.
Definition: list.h:133
Header file for the Collect link estimate
#define LIST_STRUCT(name)
Declare a linked list inside a structure declaraction.
Definition: list.h:108
uint16_t collect_link_estimate(struct collect_link_estimate *le)
Compute the link estimate metric for a link estimate.
Header file for the Rime address representation