Routing API: added neighbor_state_changed
This commit is contained in:
parent
c6f2364bd8
commit
c9861b0726
|
@ -53,19 +53,13 @@
|
||||||
#include "net/ipv6/uip-ds6.h"
|
#include "net/ipv6/uip-ds6.h"
|
||||||
#include "net/ipv6/uip-ds6-nbr.h"
|
#include "net/ipv6/uip-ds6-nbr.h"
|
||||||
#include "net/ipv6/uip-nd6.h"
|
#include "net/ipv6/uip-nd6.h"
|
||||||
|
#include "net/routing/routing.h"
|
||||||
|
|
||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "IPv6 Nbr"
|
#define LOG_MODULE "IPv6 Nbr"
|
||||||
#define LOG_LEVEL LOG_LEVEL_IPV6
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
#ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
|
|
||||||
#define NEIGHBOR_STATE_CHANGED(n) UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED(n)
|
|
||||||
void NEIGHBOR_STATE_CHANGED(uip_ds6_nbr_t *n);
|
|
||||||
#else
|
|
||||||
#define NEIGHBOR_STATE_CHANGED(n)
|
|
||||||
#endif /* UIP_DS6_CONF_NEIGHBOR_STATE_CHANGED */
|
|
||||||
|
|
||||||
NBR_TABLE_GLOBAL(uip_ds6_nbr_t, ds6_neighbors);
|
NBR_TABLE_GLOBAL(uip_ds6_nbr_t, ds6_neighbors);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -107,7 +101,7 @@ uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr,
|
||||||
LOG_INFO_(" link addr ");
|
LOG_INFO_(" link addr ");
|
||||||
LOG_INFO_LLADDR((linkaddr_t*)lladdr);
|
LOG_INFO_LLADDR((linkaddr_t*)lladdr);
|
||||||
LOG_INFO_(" state %u\n", state);
|
LOG_INFO_(" state %u\n", state);
|
||||||
NEIGHBOR_STATE_CHANGED(nbr);
|
NETSTACK_ROUTING.neighbor_state_changed(nbr);
|
||||||
return nbr;
|
return nbr;
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("Add drop ip addr ");
|
LOG_INFO("Add drop ip addr ");
|
||||||
|
@ -127,7 +121,7 @@ uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr)
|
||||||
#if UIP_CONF_IPV6_QUEUE_PKT
|
#if UIP_CONF_IPV6_QUEUE_PKT
|
||||||
uip_packetqueue_free(&nbr->packethandle);
|
uip_packetqueue_free(&nbr->packethandle);
|
||||||
#endif /* UIP_CONF_IPV6_QUEUE_PKT */
|
#endif /* UIP_CONF_IPV6_QUEUE_PKT */
|
||||||
NEIGHBOR_STATE_CHANGED(nbr);
|
NETSTACK_ROUTING.neighbor_state_changed(nbr);
|
||||||
return nbr_table_remove(ds6_neighbors, nbr);
|
return nbr_table_remove(ds6_neighbors, nbr);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -226,13 +226,6 @@ typedef struct uip_ds6_maddr {
|
||||||
uip_ipaddr_t ipaddr;
|
uip_ipaddr_t ipaddr;
|
||||||
} uip_ds6_maddr_t;
|
} uip_ds6_maddr_t;
|
||||||
|
|
||||||
/* only define the callback if RPL is active */
|
|
||||||
#if UIP_CONF_IPV6_RPL && (UIP_CONF_IPV6_RPL_LITE == 0)
|
|
||||||
#ifndef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
|
|
||||||
#define UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED rpl_ipv6_neighbor_callback
|
|
||||||
#endif /* UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED */
|
|
||||||
#endif /* UIP_CONF_IPV6_RPL */
|
|
||||||
|
|
||||||
/** \brief Interface structure (contains all the interface variables) */
|
/** \brief Interface structure (contains all the interface variables) */
|
||||||
typedef struct uip_ds6_netif {
|
typedef struct uip_ds6_netif {
|
||||||
uint32_t link_mtu;
|
uint32_t link_mtu;
|
||||||
|
|
|
@ -104,6 +104,11 @@ link_callback(const linkaddr_t *addr, int status, int numtx)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
|
neighbor_state_changed(uip_ds6_nbr_t *nbr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
drop_route(uip_ds6_route_t *route)
|
drop_route(uip_ds6_route_t *route)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -121,6 +126,7 @@ const struct routing_driver nullrouting_driver = {
|
||||||
ext_header_srh_update,
|
ext_header_srh_update,
|
||||||
ext_header_srh_get_next_hop,
|
ext_header_srh_get_next_hop,
|
||||||
link_callback,
|
link_callback,
|
||||||
|
neighbor_state_changed,
|
||||||
drop_route,
|
drop_route,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "net/ipv6/uip.h"
|
#include "net/ipv6/uip.h"
|
||||||
|
#include "net/ipv6/uip-ds6-nbr.h"
|
||||||
#include "net/ipv6/uip-ds6-route.h"
|
#include "net/ipv6/uip-ds6-route.h"
|
||||||
#include "net/linkaddr.h"
|
#include "net/linkaddr.h"
|
||||||
|
|
||||||
|
@ -118,6 +119,14 @@ struct routing_driver {
|
||||||
* \param numtx The total number of transmission attempts
|
* \param numtx The total number of transmission attempts
|
||||||
*/
|
*/
|
||||||
void (* link_callback)(const linkaddr_t *addr, int status, int numtx);
|
void (* link_callback)(const linkaddr_t *addr, int status, int numtx);
|
||||||
|
/**
|
||||||
|
* Called by uIP to notify addition/removal of IPv6 neighbor entries
|
||||||
|
*
|
||||||
|
* \param addr The link-layer addrress of the packet destination
|
||||||
|
* \param status The transmission status (see os/net/mac/mac.h)
|
||||||
|
* \param numtx The total number of transmission attempts
|
||||||
|
*/
|
||||||
|
void (* neighbor_state_changed)(uip_ds6_nbr_t *nbr);
|
||||||
/**
|
/**
|
||||||
* Called by uIP if it has decided to drop a route because
|
* Called by uIP if it has decided to drop a route because
|
||||||
*
|
*
|
||||||
|
|
|
@ -396,6 +396,7 @@ const struct routing_driver rpl_classic_driver = {
|
||||||
rpl_ext_header_srh_update,
|
rpl_ext_header_srh_update,
|
||||||
rpl_ext_header_srh_get_next_hop,
|
rpl_ext_header_srh_get_next_hop,
|
||||||
rpl_link_callback,
|
rpl_link_callback,
|
||||||
|
rpl_ipv6_neighbor_callback,
|
||||||
drop_route,
|
drop_route,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -194,6 +194,12 @@ init(void)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
|
neighbor_state_changed(uip_ds6_nbr_t *nbr)
|
||||||
|
{
|
||||||
|
/* Nothing needs be done in non-storing mode */
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
drop_route(uip_ds6_route_t *route)
|
drop_route(uip_ds6_route_t *route)
|
||||||
{
|
{
|
||||||
/* Do nothing. RPL-lite only supports non-storing mode, i.e. no routes */
|
/* Do nothing. RPL-lite only supports non-storing mode, i.e. no routes */
|
||||||
|
@ -212,6 +218,7 @@ const struct routing_driver rpl_lite_driver = {
|
||||||
rpl_ext_header_srh_update,
|
rpl_ext_header_srh_update,
|
||||||
rpl_ext_header_srh_get_next_hop,
|
rpl_ext_header_srh_get_next_hop,
|
||||||
rpl_link_callback,
|
rpl_link_callback,
|
||||||
|
neighbor_state_changed,
|
||||||
drop_route,
|
drop_route,
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
Loading…
Reference in New Issue