Contiki 2.6

neighbor-discovery.h

Go to the documentation of this file.
00001 /**
00002  * \addtogroup rime
00003  * @{
00004  */
00005 
00006 /**
00007  * \defgroup rimeneighbordiscovery Neighbor discovery
00008  * @{
00009  *
00010  * The neighbor-discovery module implements a periodic neighbor
00011  * discovery mechanism. A callback is invoked for every incoming
00012  * neighbor discovery message.
00013  *
00014  * \section channels Channels
00015  *
00016  * The neighbor-discovery module uses 1 channel.
00017  *
00018  */
00019 
00020 /*
00021  * Copyright (c) 2006, Swedish Institute of Computer Science.
00022  * All rights reserved.
00023  *
00024  * Redistribution and use in source and binary forms, with or without
00025  * modification, are permitted provided that the following conditions
00026  * are met:
00027  * 1. Redistributions of source code must retain the above copyright
00028  *    notice, this list of conditions and the following disclaimer.
00029  * 2. Redistributions in binary form must reproduce the above copyright
00030  *    notice, this list of conditions and the following disclaimer in the
00031  *    documentation and/or other materials provided with the distribution.
00032  * 3. Neither the name of the Institute nor the names of its contributors
00033  *    may be used to endorse or promote products derived from this software
00034  *    without specific prior written permission.
00035  *
00036  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00037  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00038  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00039  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00040  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00041  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00042  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00043  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00044  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00045  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00046  * SUCH DAMAGE.
00047  *
00048  * This file is part of the Contiki operating system.
00049  *
00050  * $Id: neighbor-discovery.h,v 1.12 2010/06/18 08:28:56 nifi Exp $
00051  */
00052 
00053 /**
00054  * \file
00055  *         Neighbor discovery header file
00056  * \author
00057  *         Adam Dunkels <adam@sics.se>
00058  */
00059 
00060 #ifndef __NEIGHBOR_DISCOVERY_H__
00061 #define __NEIGHBOR_DISCOVERY_H__
00062 
00063 #include "net/rime/broadcast.h"
00064 #include "sys/ctimer.h"
00065 
00066 struct neighbor_discovery_conn;
00067 
00068 struct neighbor_discovery_callbacks {
00069   void (* recv)(struct neighbor_discovery_conn *c,
00070                 const rimeaddr_t *from, uint16_t val);
00071   void (* sent)(struct neighbor_discovery_conn *c);
00072 };
00073 
00074 struct neighbor_discovery_conn {
00075   struct broadcast_conn c;
00076   const struct neighbor_discovery_callbacks *u;
00077   struct ctimer send_timer, interval_timer;
00078   clock_time_t initial_interval, min_interval, max_interval;
00079   clock_time_t current_interval;
00080   uint16_t val;
00081 };
00082 
00083 void neighbor_discovery_open(struct neighbor_discovery_conn *c,
00084                              uint16_t channel,
00085                              clock_time_t initial,
00086                              clock_time_t min,
00087                              clock_time_t max,
00088                              const struct neighbor_discovery_callbacks *u);
00089 void neighbor_discovery_close(struct neighbor_discovery_conn *c);
00090 void neighbor_discovery_set_val(struct neighbor_discovery_conn *c, uint16_t val);
00091 
00092 void neighbor_discovery_start(struct neighbor_discovery_conn *c, uint16_t val);
00093 
00094 #endif /* __NEIGHBOR_DISCOVERY_H__ */
00095 /** @} */
00096 /** @} */