Contiki-Inga 3.x
collect-neighbor.h
Go to the documentation of this file.
1 /**
2  * \addtogroup rime
3  * @{
4  */
5 /**
6  * \defgroup rimeneighbor Collect neighbor management
7  * @{
8  *
9  * The neighbor module manages the neighbor table that is used by the
10  * Collect module.
11  */
12 /*
13  * Copyright (c) 2006, Swedish Institute of Computer Science.
14  * All rights reserved.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions
18  * are met:
19  * 1. Redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer.
21  * 2. Redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution.
24  * 3. Neither the name of the Institute nor the names of its contributors
25  * may be used to endorse or promote products derived from this software
26  * without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38  * SUCH DAMAGE.
39  *
40  * This file is part of the Contiki operating system.
41  *
42  */
43 
44 /**
45  * \file
46  * Header file for the Contiki radio neighborhood management
47  * \author
48  * Adam Dunkels <adam@sics.se>
49  */
50 
51 #ifndef COLLECT_NEIGHBOR_H_
52 #define COLLECT_NEIGHBOR_H_
53 
54 #include "net/linkaddr.h"
56 #include "lib/list.h"
57 
58 struct collect_neighbor_list {
59  LIST_STRUCT(list);
60  struct ctimer periodic;
61 };
62 
63 struct collect_neighbor {
64  struct collect_neighbor *next;
65  linkaddr_t addr;
66  uint16_t rtmetric;
67  uint16_t age;
68  uint16_t le_age;
69  struct collect_link_estimate le;
70  struct timer congested_timer;
71 };
72 
73 void collect_neighbor_init(void);
74 
75 list_t collect_neighbor_list(struct collect_neighbor_list *neighbor_list);
76 
77 void collect_neighbor_list_new(struct collect_neighbor_list *neighbor_list);
78 
79 int collect_neighbor_list_add(struct collect_neighbor_list *neighbor_list,
80  const linkaddr_t *addr, uint16_t rtmetric);
81 void collect_neighbor_list_remove(struct collect_neighbor_list *neighbor_list,
82  const linkaddr_t *addr);
83 struct collect_neighbor *collect_neighbor_list_find(struct collect_neighbor_list *neighbor_list,
84  const linkaddr_t *addr);
85 struct collect_neighbor *collect_neighbor_list_best(struct collect_neighbor_list *neighbor_list);
86 int collect_neighbor_list_num(struct collect_neighbor_list *neighbor_list);
87 struct collect_neighbor *collect_neighbor_list_get(struct collect_neighbor_list *neighbor_list, int num);
88 void collect_neighbor_list_purge(struct collect_neighbor_list *neighbor_list);
89 
90 void collect_neighbor_update_rtmetric(struct collect_neighbor *n,
91  uint16_t rtmetric);
92 void collect_neighbor_tx(struct collect_neighbor *n, uint16_t num_tx);
93 void collect_neighbor_rx(struct collect_neighbor *n);
94 void collect_neighbor_tx_fail(struct collect_neighbor *n, uint16_t num_tx);
95 void collect_neighbor_set_congested(struct collect_neighbor *n);
96 int collect_neighbor_is_congested(struct collect_neighbor *n);
97 
98 uint16_t collect_neighbor_link_estimate(struct collect_neighbor *n);
99 uint16_t collect_neighbor_rtmetric_link_estimate(struct collect_neighbor *n);
100 uint16_t collect_neighbor_rtmetric(struct collect_neighbor *n);
101 
102 
103 #endif /* COLLECT_NEIGHBOR_H_ */
104 /** @} */
105 /** @} */