Rewrote the uIP IPv6 route handling code. Instead of being nested deeply inside the uip-ds6.c file, the route management code is now in a separate file, uip-ds6-route.c. This file presents a lib/list.h API for the routes, which makes the route list much easier to use. Additionally, the uip-ds6-route.c file adds a callback API that invokes a callback when routes are added and removed.
This commit is contained in:
parent
b2063953ba
commit
afe13b22bc
6 changed files with 579 additions and 106 deletions
|
@ -46,6 +46,7 @@
|
|||
#include "sys/stimer.h"
|
||||
/* The size of uip_ds6_addr_t depends on UIP_ND6_DEF_MAXDADNS. Include uip-nd6.h to define it. */
|
||||
#include "net/uip-nd6.h"
|
||||
#include "net/uip-ds6-route.h"
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/** Configuration. For all tables (Neighbor cache, Prefix List, Routing Table,
|
||||
|
@ -82,15 +83,6 @@
|
|||
#endif
|
||||
#define UIP_DS6_PREFIX_NB UIP_DS6_PREFIX_NBS + UIP_DS6_PREFIX_NBU
|
||||
|
||||
/* Routing table */
|
||||
#define UIP_DS6_ROUTE_NBS 0
|
||||
#ifndef UIP_CONF_DS6_ROUTE_NBU
|
||||
#define UIP_DS6_ROUTE_NBU 4
|
||||
#else
|
||||
#define UIP_DS6_ROUTE_NBU UIP_CONF_DS6_ROUTE_NBU
|
||||
#endif
|
||||
#define UIP_DS6_ROUTE_NB UIP_DS6_ROUTE_NBS + UIP_DS6_ROUTE_NBU
|
||||
|
||||
/* Unicast address list*/
|
||||
#define UIP_DS6_ADDR_NBS 1
|
||||
#ifndef UIP_CONF_DS6_ADDR_NBU
|
||||
|
@ -158,9 +150,8 @@
|
|||
#define FOUND 0
|
||||
#define FREESPACE 1
|
||||
#define NOSPACE 2
|
||||
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
|
||||
#if UIP_CONF_IPV6_QUEUE_PKT
|
||||
#include "net/uip-packetqueue.h"
|
||||
#endif /*UIP_CONF_QUEUE_PKT */
|
||||
|
@ -181,14 +172,6 @@ typedef struct uip_ds6_nbr {
|
|||
#endif /*UIP_CONF_QUEUE_PKT */
|
||||
} uip_ds6_nbr_t;
|
||||
|
||||
/** \brief An entry in the default router list */
|
||||
typedef struct uip_ds6_defrt {
|
||||
uint8_t isused;
|
||||
uip_ipaddr_t ipaddr;
|
||||
struct stimer lifetime;
|
||||
uint8_t isinfinite;
|
||||
} uip_ds6_defrt_t;
|
||||
|
||||
/** \brief A prefix list entry */
|
||||
#if UIP_CONF_ROUTER
|
||||
typedef struct uip_ds6_prefix {
|
||||
|
@ -236,19 +219,6 @@ typedef struct uip_ds6_maddr {
|
|||
uip_ipaddr_t ipaddr;
|
||||
} uip_ds6_maddr_t;
|
||||
|
||||
/** \brief define some additional RPL related route state and
|
||||
* neighbor callback for RPL - if not a DS6_ROUTE_STATE is already set */
|
||||
#ifndef UIP_DS6_ROUTE_STATE_TYPE
|
||||
#define UIP_DS6_ROUTE_STATE_TYPE rpl_route_entry_t
|
||||
/* Needed for the extended route entry state when using ContikiRPL */
|
||||
typedef struct rpl_route_entry {
|
||||
uint32_t lifetime;
|
||||
uint32_t saved_lifetime;
|
||||
void *dag;
|
||||
uint8_t learned_from;
|
||||
} rpl_route_entry_t;
|
||||
#endif /* UIP_DS6_ROUTE_STATE_TYPE */
|
||||
|
||||
/* only define the callback if RPL is active */
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
#ifndef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
|
||||
|
@ -258,18 +228,6 @@ typedef struct rpl_route_entry {
|
|||
|
||||
|
||||
|
||||
/** \brief An entry in the routing table */
|
||||
typedef struct uip_ds6_route {
|
||||
uint8_t isused;
|
||||
uip_ipaddr_t ipaddr;
|
||||
uint8_t length;
|
||||
uint8_t metric;
|
||||
uip_ipaddr_t nexthop;
|
||||
#ifdef UIP_DS6_ROUTE_STATE_TYPE
|
||||
UIP_DS6_ROUTE_STATE_TYPE state;
|
||||
#endif
|
||||
} uip_ds6_route_t;
|
||||
|
||||
/** \brief Interface structure (contains all the interface variables) */
|
||||
typedef struct uip_ds6_netif {
|
||||
uint32_t link_mtu;
|
||||
|
@ -325,15 +283,6 @@ uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(uip_lladdr_t *lladdr);
|
|||
|
||||
/** @} */
|
||||
|
||||
/** \name Default router list basic routines */
|
||||
/** @{ */
|
||||
uip_ds6_defrt_t *uip_ds6_defrt_add(uip_ipaddr_t *ipaddr,
|
||||
unsigned long interval);
|
||||
void uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt);
|
||||
uip_ds6_defrt_t *uip_ds6_defrt_lookup(uip_ipaddr_t *ipaddr);
|
||||
uip_ipaddr_t *uip_ds6_defrt_choose(void);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** \name Prefix list basic routines */
|
||||
/** @{ */
|
||||
|
@ -381,16 +330,6 @@ uip_ds6_aaddr_t *uip_ds6_aaddr_lookup(uip_ipaddr_t *ipaddr);
|
|||
/** @} */
|
||||
|
||||
|
||||
/** \name Routing Table basic routines */
|
||||
/** @{ */
|
||||
uip_ds6_route_t *uip_ds6_route_lookup(uip_ipaddr_t *destipaddr);
|
||||
uip_ds6_route_t *uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
||||
uip_ipaddr_t *next_hop, uint8_t metric);
|
||||
void uip_ds6_route_rm(uip_ds6_route_t *route);
|
||||
void uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** \brief set the last 64 bits of an IP address based on the MAC address */
|
||||
void uip_ds6_set_addr_iid(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue