Contiki 2.6

collect-neighbor.h

Go to the documentation of this file.
00001 /**
00002  * \addtogroup rime
00003  * @{
00004  */
00005 /**
00006  * \defgroup rimeneighbor Collect neighbor management
00007  * @{
00008  *
00009  * The neighbor module manages the neighbor table that is used by the
00010  * Collect module.
00011  */
00012 /*
00013  * Copyright (c) 2006, Swedish Institute of Computer Science.
00014  * All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions
00018  * are met:
00019  * 1. Redistributions of source code must retain the above copyright
00020  *    notice, this list of conditions and the following disclaimer.
00021  * 2. Redistributions in binary form must reproduce the above copyright
00022  *    notice, this list of conditions and the following disclaimer in the
00023  *    documentation and/or other materials provided with the distribution.
00024  * 3. Neither the name of the Institute nor the names of its contributors
00025  *    may be used to endorse or promote products derived from this software
00026  *    without specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00029  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00032  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00034  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00035  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00036  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00037  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00038  * SUCH DAMAGE.
00039  *
00040  * This file is part of the Contiki operating system.
00041  *
00042  * $Id: collect-neighbor.h,v 1.6 2010/10/11 23:38:46 adamdunkels Exp $
00043  */
00044 
00045 /**
00046  * \file
00047  *         Header file for the Contiki radio neighborhood management
00048  * \author
00049  *         Adam Dunkels <adam@sics.se>
00050  */
00051 
00052 #ifndef __COLLECT_NEIGHBOR_H__
00053 #define __COLLECT_NEIGHBOR_H__
00054 
00055 #include "net/rime/rimeaddr.h"
00056 #include "net/rime/collect-link-estimate.h"
00057 #include "lib/list.h"
00058 
00059 struct collect_neighbor_list {
00060   LIST_STRUCT(list);
00061   struct ctimer periodic;
00062 };
00063 
00064 struct collect_neighbor {
00065   struct collect_neighbor *next;
00066   rimeaddr_t addr;
00067   uint16_t rtmetric;
00068   uint16_t age;
00069   uint16_t le_age;
00070   struct collect_link_estimate le;
00071   struct timer congested_timer;
00072 };
00073 
00074 void collect_neighbor_init(void);
00075 
00076 list_t collect_neighbor_list(struct collect_neighbor_list *neighbor_list);
00077 
00078 void collect_neighbor_list_new(struct collect_neighbor_list *neighbor_list);
00079 
00080 int collect_neighbor_list_add(struct collect_neighbor_list *neighbor_list,
00081                               const rimeaddr_t *addr, uint16_t rtmetric);
00082 void collect_neighbor_list_remove(struct collect_neighbor_list *neighbor_list,
00083                                   const rimeaddr_t *addr);
00084 struct collect_neighbor *collect_neighbor_list_find(struct collect_neighbor_list *neighbor_list,
00085                                                const rimeaddr_t *addr);
00086 struct collect_neighbor *collect_neighbor_list_best(struct collect_neighbor_list *neighbor_list);
00087 int collect_neighbor_list_num(struct collect_neighbor_list *neighbor_list);
00088 struct collect_neighbor *collect_neighbor_list_get(struct collect_neighbor_list *neighbor_list, int num);
00089 void collect_neighbor_list_purge(struct collect_neighbor_list *neighbor_list);
00090 
00091 void collect_neighbor_update_rtmetric(struct collect_neighbor *n,
00092                                       uint16_t rtmetric);
00093 void collect_neighbor_tx(struct collect_neighbor *n, uint16_t num_tx);
00094 void collect_neighbor_rx(struct collect_neighbor *n);
00095 void collect_neighbor_tx_fail(struct collect_neighbor *n, uint16_t num_tx);
00096 void collect_neighbor_set_congested(struct collect_neighbor *n);
00097 int collect_neighbor_is_congested(struct collect_neighbor *n);
00098 
00099 uint16_t collect_neighbor_link_estimate(struct collect_neighbor *n);
00100 uint16_t collect_neighbor_rtmetric_link_estimate(struct collect_neighbor *n);
00101 uint16_t collect_neighbor_rtmetric(struct collect_neighbor *n);
00102 
00103 
00104 #endif /* __COLLECT_NEIGHBOR_H__ */
00105 /** @} */
00106 /** @} */