2013-07-03 17:32:26 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013, Swedish Institute of Computer Science.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-02-15 18:02:07 +00:00
|
|
|
/**
|
2017-09-29 20:18:48 +00:00
|
|
|
* \addtogroup uip
|
2015-02-15 18:02:07 +00:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-07-03 17:32:26 +00:00
|
|
|
/**
|
|
|
|
* \file
|
2015-02-15 18:02:07 +00:00
|
|
|
* IPv6 Neighbor cache (link-layer/IPv6 address mapping)
|
2013-07-03 17:32:26 +00:00
|
|
|
* \author Mathilde Durvy <mdurvy@cisco.com>
|
|
|
|
* \author Julien Abeille <jabeille@cisco.com>
|
|
|
|
* \author Simon Duquennoy <simonduq@sics.se>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-11-24 15:57:08 +00:00
|
|
|
#ifndef UIP_DS6_NEIGHBOR_H_
|
|
|
|
#define UIP_DS6_NEIGHBOR_H_
|
2013-07-03 17:32:26 +00:00
|
|
|
|
2017-12-10 20:07:10 +00:00
|
|
|
#include "contiki.h"
|
2017-09-22 13:06:44 +00:00
|
|
|
#include "net/ipv6/uip.h"
|
2017-12-10 20:07:10 +00:00
|
|
|
#include "net/ipv6/uip-nd6.h"
|
2013-07-29 16:49:21 +00:00
|
|
|
#include "net/nbr-table.h"
|
|
|
|
#include "sys/stimer.h"
|
2013-07-03 17:32:26 +00:00
|
|
|
#if UIP_CONF_IPV6_QUEUE_PKT
|
2017-09-22 13:06:44 +00:00
|
|
|
#include "net/ipv6/uip-packetqueue.h"
|
2013-07-03 17:32:26 +00:00
|
|
|
#endif /*UIP_CONF_QUEUE_PKT */
|
|
|
|
|
2013-07-29 16:49:21 +00:00
|
|
|
/*--------------------------------------------------*/
|
|
|
|
/** \brief Possible states for the nbr cache entries */
|
|
|
|
#define NBR_INCOMPLETE 0
|
|
|
|
#define NBR_REACHABLE 1
|
|
|
|
#define NBR_STALE 2
|
|
|
|
#define NBR_DELAY 3
|
|
|
|
#define NBR_PROBE 4
|
|
|
|
|
|
|
|
NBR_TABLE_DECLARE(ds6_neighbors);
|
2013-07-03 17:32:26 +00:00
|
|
|
|
|
|
|
/** \brief An entry in the nbr cache */
|
|
|
|
typedef struct uip_ds6_nbr {
|
|
|
|
uip_ipaddr_t ipaddr;
|
|
|
|
uint8_t isrouter;
|
|
|
|
uint8_t state;
|
2017-01-16 12:44:15 +00:00
|
|
|
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA
|
2015-11-20 18:07:20 +00:00
|
|
|
struct stimer reachable;
|
|
|
|
struct stimer sendns;
|
|
|
|
uint8_t nscount;
|
2017-01-16 12:44:15 +00:00
|
|
|
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA */
|
2013-07-03 17:32:26 +00:00
|
|
|
#if UIP_CONF_IPV6_QUEUE_PKT
|
|
|
|
struct uip_packetqueue_handle packethandle;
|
|
|
|
#define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4
|
|
|
|
#endif /*UIP_CONF_QUEUE_PKT */
|
|
|
|
} uip_ds6_nbr_t;
|
|
|
|
|
|
|
|
void uip_ds6_neighbors_init(void);
|
|
|
|
|
|
|
|
/** \brief Neighbor Cache basic routines */
|
2015-09-20 19:02:30 +00:00
|
|
|
uip_ds6_nbr_t *uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr,
|
|
|
|
const uip_lladdr_t *lladdr,
|
|
|
|
uint8_t isrouter, uint8_t state,
|
|
|
|
nbr_table_reason_t reason, void *data);
|
2015-08-20 14:56:50 +00:00
|
|
|
int uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr);
|
2013-11-16 13:42:57 +00:00
|
|
|
const uip_lladdr_t *uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr);
|
2018-03-23 13:51:27 +00:00
|
|
|
int uip_ds6_nbr_update_ll(uip_ds6_nbr_t **nbr, const uip_lladdr_t *new_ll_addr);
|
2013-11-16 13:42:57 +00:00
|
|
|
const uip_ipaddr_t *uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr);
|
|
|
|
uip_ds6_nbr_t *uip_ds6_nbr_lookup(const uip_ipaddr_t *ipaddr);
|
|
|
|
uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(const uip_lladdr_t *lladdr);
|
|
|
|
uip_ipaddr_t *uip_ds6_nbr_ipaddr_from_lladdr(const uip_lladdr_t *lladdr);
|
|
|
|
const uip_lladdr_t *uip_ds6_nbr_lladdr_from_ipaddr(const uip_ipaddr_t *ipaddr);
|
2017-06-24 09:46:37 +00:00
|
|
|
void uip_ds6_link_callback(int status, int numtx);
|
2013-08-11 21:55:08 +00:00
|
|
|
void uip_ds6_neighbor_periodic(void);
|
|
|
|
int uip_ds6_nbr_num(void);
|
2017-07-15 10:35:59 +00:00
|
|
|
uip_ds6_nbr_t *uip_ds6_nbr_head(void);
|
|
|
|
uip_ds6_nbr_t *uip_ds6_nbr_next(uip_ds6_nbr_t *nbr);
|
2013-07-03 17:32:26 +00:00
|
|
|
|
2017-01-16 12:44:15 +00:00
|
|
|
#if UIP_ND6_SEND_NS
|
2015-11-26 00:07:58 +00:00
|
|
|
/**
|
|
|
|
* \brief Refresh the reachable state of a neighbor. This function
|
|
|
|
* may be called when a node receives an IPv6 message that confirms the
|
|
|
|
* reachability of a neighbor.
|
|
|
|
* \param ipaddr pointer to the IPv6 address whose neighbor reachability state
|
|
|
|
* should be refreshed.
|
|
|
|
*/
|
|
|
|
void uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr);
|
2017-01-16 12:44:15 +00:00
|
|
|
#endif /* UIP_ND6_SEND_NS */
|
2015-11-26 00:07:58 +00:00
|
|
|
|
2013-07-03 17:32:26 +00:00
|
|
|
/**
|
|
|
|
* \brief
|
2015-02-15 19:20:40 +00:00
|
|
|
* This searches inside the neighbor table for the neighbor that is about to
|
|
|
|
* expire the next.
|
2013-07-03 17:32:26 +00:00
|
|
|
*
|
|
|
|
* \return
|
2015-02-15 19:20:40 +00:00
|
|
|
* A reference to the neighbor about to expire the next or NULL if
|
|
|
|
* table is empty.
|
2013-07-03 17:32:26 +00:00
|
|
|
*/
|
|
|
|
uip_ds6_nbr_t *uip_ds6_get_least_lifetime_neighbor(void);
|
|
|
|
|
2013-11-24 15:57:08 +00:00
|
|
|
#endif /* UIP_DS6_NEIGHBOR_H_ */
|
2014-05-30 09:01:20 +00:00
|
|
|
/** @} */
|