Contiki 2.5
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  * $Id: collect-neighbor.h,v 1.6 2010/10/11 23:38:46 adamdunkels Exp $
43  */
44 
45 /**
46  * \file
47  * Header file for the Contiki radio neighborhood management
48  * \author
49  * Adam Dunkels <adam@sics.se>
50  */
51 
52 #ifndef __COLLECT_NEIGHBOR_H__
53 #define __COLLECT_NEIGHBOR_H__
54 
55 #include "net/rime/rimeaddr.h"
57 #include "lib/list.h"
58 
59 struct collect_neighbor_list {
60  LIST_STRUCT(list);
61  struct ctimer periodic;
62 };
63 
64 struct collect_neighbor {
65  struct collect_neighbor *next;
66  rimeaddr_t addr;
67  uint16_t rtmetric;
68  uint16_t age;
69  uint16_t le_age;
70  struct collect_link_estimate le;
71  struct timer congested_timer;
72 };
73 
74 void collect_neighbor_init(void);
75 
76 list_t collect_neighbor_list(struct collect_neighbor_list *neighbor_list);
77 
78 void collect_neighbor_list_new(struct collect_neighbor_list *neighbor_list);
79 
80 int collect_neighbor_list_add(struct collect_neighbor_list *neighbor_list,
81  const rimeaddr_t *addr, uint16_t rtmetric);
82 void collect_neighbor_list_remove(struct collect_neighbor_list *neighbor_list,
83  const rimeaddr_t *addr);
84 struct collect_neighbor *collect_neighbor_list_find(struct collect_neighbor_list *neighbor_list,
85  const rimeaddr_t *addr);
86 struct collect_neighbor *collect_neighbor_list_best(struct collect_neighbor_list *neighbor_list);
87 int collect_neighbor_list_num(struct collect_neighbor_list *neighbor_list);
88 struct collect_neighbor *collect_neighbor_list_get(struct collect_neighbor_list *neighbor_list, int num);
89 void collect_neighbor_list_purge(struct collect_neighbor_list *neighbor_list);
90 
91 void collect_neighbor_update_rtmetric(struct collect_neighbor *n,
92  uint16_t rtmetric);
93 void collect_neighbor_tx(struct collect_neighbor *n, uint16_t num_tx);
94 void collect_neighbor_rx(struct collect_neighbor *n);
95 void collect_neighbor_tx_fail(struct collect_neighbor *n, uint16_t num_tx);
96 void collect_neighbor_set_congested(struct collect_neighbor *n);
97 int collect_neighbor_is_congested(struct collect_neighbor *n);
98 
99 uint16_t collect_neighbor_link_estimate(struct collect_neighbor *n);
100 uint16_t collect_neighbor_rtmetric_link_estimate(struct collect_neighbor *n);
101 uint16_t collect_neighbor_rtmetric(struct collect_neighbor *n);
102 
103 
104 #endif /* __COLLECT_NEIGHBOR_H__ */
105 /** @} */
106 /** @} */