integration of new uip6 code from Mathilde and Julien - adds routing and improved interface handling
This commit is contained in:
parent
7d5e3fbfde
commit
fd3d6c44d0
15 changed files with 1558 additions and 2448 deletions
|
@ -38,7 +38,7 @@
|
|||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __UIP_DS6_H__
|
||||
#define __UIP_DS6_H__
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
|||
|
||||
/*--------------------------------------------------*/
|
||||
/** Configuration. For all tables (Neighbor cache, Prefix List, Routing Table,
|
||||
* Default Router List, Unicast address list, multicast address list, anycast address list),
|
||||
* Default Router List, Unicast address list, multicast address list, anycast address list),
|
||||
* we define:
|
||||
* - the number of elements requested by the user in contiki configuration (name suffixed by _NBU)
|
||||
* - the number of elements assigned by the system (name suffixed by _NBS)
|
||||
|
@ -56,59 +56,59 @@
|
|||
/* Neighbor cache */
|
||||
#define UIP_DS6_NBR_NBS 0
|
||||
#ifndef UIP_CONF_DS6_NBR_NBU
|
||||
#define UIP_DS6_NBR_NBU 4
|
||||
#else
|
||||
#define UIP_DS6_NBR_NBU 4
|
||||
#else
|
||||
#define UIP_DS6_NBR_NBU UIP_CONF_DS6_NBR_NBU
|
||||
#endif
|
||||
#endif
|
||||
#define UIP_DS6_NBR_NB UIP_DS6_NBR_NBS + UIP_DS6_NBR_NBU
|
||||
|
||||
/* Default router list */
|
||||
#define UIP_DS6_DEFRT_NBS 0
|
||||
#ifndef UIP_CONF_DS6_DEFRT_NBU
|
||||
#define UIP_DS6_DEFRT_NBU 2
|
||||
#else
|
||||
#else
|
||||
#define UIP_DS6_DEFRT_NBU UIP_CONF_DS6_DEFRT_NBU
|
||||
#endif
|
||||
#endif
|
||||
#define UIP_DS6_DEFRT_NB UIP_DS6_DEFRT_NBS + UIP_DS6_DEFRT_NBU
|
||||
|
||||
/* Prefix list */
|
||||
#define UIP_DS6_PREFIX_NBS 1
|
||||
#define UIP_DS6_PREFIX_NBS 1
|
||||
#ifndef UIP_CONF_DS6_PREFIX_NBU
|
||||
#define UIP_DS6_PREFIX_NBU 2
|
||||
#else
|
||||
#else
|
||||
#define UIP_DS6_PREFIX_NBU UIP_CONF_DS6_PREFIX_NBU
|
||||
#endif
|
||||
#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
|
||||
#ifndef UIP_CONF_DS6_ROUTE_NBU
|
||||
#define UIP_DS6_ROUTE_NBU 4
|
||||
#else
|
||||
#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
|
||||
#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
|
||||
#define UIP_DS6_ADDR_NBU 2
|
||||
#else
|
||||
#else
|
||||
#define UIP_DS6_ADDR_NBU UIP_CONF_DS6_ADDR_NBU
|
||||
#endif
|
||||
#endif
|
||||
#define UIP_DS6_ADDR_NB UIP_DS6_ADDR_NBS + UIP_DS6_ADDR_NBU
|
||||
|
||||
/* Multicast address list */
|
||||
#if UIP_CONF_ROUTER
|
||||
#define UIP_DS6_MADDR_NBS 2 + UIP_DS6_ADDR_NB /* all routers + all nodes + one solicited per unicast */
|
||||
#define UIP_DS6_MADDR_NBS 2 + UIP_DS6_ADDR_NB /* all routers + all nodes + one solicited per unicast */
|
||||
#else
|
||||
#define UIP_DS6_MADDR_NBS 1 + UIP_DS6_ADDR_NB /* all nodes + one solicited per unicast */
|
||||
#define UIP_DS6_MADDR_NBS 1 + UIP_DS6_ADDR_NB /* all nodes + one solicited per unicast */
|
||||
#endif
|
||||
#ifndef UIP_CONF_DS6_MADDR_NBU
|
||||
#define UIP_DS6_MADDR_NBU 0
|
||||
#else
|
||||
#else
|
||||
#define UIP_DS6_MADDR_NBU UIP_CONF_DS6_MADDR_NBU
|
||||
#endif
|
||||
#endif
|
||||
#define UIP_DS6_MADDR_NB UIP_DS6_MADDR_NBS + UIP_DS6_MADDR_NBU
|
||||
|
||||
/* Anycast address list */
|
||||
|
@ -136,7 +136,7 @@
|
|||
/** \brief Possible states for the an address (RFC 4862) */
|
||||
#define ADDR_TENTATIVE 0
|
||||
#define ADDR_PREFERRED 1
|
||||
#define ADDR_DEPRECATED 2
|
||||
#define ADDR_DEPRECATED 2
|
||||
|
||||
/** \brief How the address was acquired: Autoconf, DHCP or manually */
|
||||
#define ADDR_ANYTYPE 0
|
||||
|
@ -160,32 +160,32 @@ typedef struct uip_ds6_nbr {
|
|||
uint8_t isrouter;
|
||||
uint8_t state;
|
||||
struct stimer reachable;
|
||||
struct stimer sendns;
|
||||
struct stimer sendns;
|
||||
uint8_t nscount;
|
||||
#if UIP_CONF_IPV6_QUEUE_PKT
|
||||
uint8_t queue_buf[UIP_BUFSIZE - UIP_LLH_LEN];
|
||||
uint8_t queue_buf_len;
|
||||
#endif /*UIP_CONF_QUEUE_PKT*/
|
||||
} 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;
|
||||
} uip_ds6_defrt;
|
||||
} uip_ds6_defrt_t;
|
||||
|
||||
/** \brief A prefix list entry */
|
||||
#if UIP_CONF_ROUTER
|
||||
typedef struct uip_ds6_prefix {
|
||||
uint8_t isused;
|
||||
uint8_t isused;
|
||||
uip_ipaddr_t ipaddr;
|
||||
uint8_t length;
|
||||
uint8_t advertise;
|
||||
u32_t vlifetime;
|
||||
u32_t plifetime;
|
||||
uint8_t l_a_reserved; /**< on-link and autonomous flags + 6 reserved bits */
|
||||
} uip_ds6_prefix ;
|
||||
} uip_ds6_prefix_t;
|
||||
#else /* UIP_CONF_ROUTER */
|
||||
typedef struct uip_ds6_prefix {
|
||||
uint8_t isused;
|
||||
|
@ -193,8 +193,8 @@ typedef struct uip_ds6_prefix {
|
|||
uint8_t length;
|
||||
struct stimer vlifetime;
|
||||
uint8_t isinfinite;
|
||||
} uip_ds6_prefix;
|
||||
#endif /*UIP_CONF_ROUTER*/
|
||||
} uip_ds6_prefix_t;
|
||||
#endif /*UIP_CONF_ROUTER */
|
||||
|
||||
/** * \brief Unicast address structure */
|
||||
typedef struct uip_ds6_addr {
|
||||
|
@ -206,19 +206,19 @@ typedef struct uip_ds6_addr {
|
|||
struct stimer vlifetime;
|
||||
struct timer dadtimer;
|
||||
uint8_t dadnscount;
|
||||
} uip_ds6_addr;
|
||||
} uip_ds6_addr_t;
|
||||
|
||||
/** \brief Anycast address */
|
||||
typedef struct uip_ds6_aaddr {
|
||||
uint8_t isused;
|
||||
uip_ipaddr_t ipaddr;
|
||||
} uip_ds6_aaddr;
|
||||
} uip_ds6_aaddr_t;
|
||||
|
||||
/** \brief A multicast address */
|
||||
typedef struct uip_ds6_maddr {
|
||||
uint8_t isused;
|
||||
uip_ipaddr_t ipaddr;
|
||||
} uip_ds6_maddr;
|
||||
} uip_ds6_maddr_t;
|
||||
|
||||
/** \brief An entry in the routing table */
|
||||
typedef struct uip_ds6_route {
|
||||
|
@ -227,33 +227,34 @@ typedef struct uip_ds6_route {
|
|||
uint8_t length;
|
||||
uip_ipaddr_t nexthop;
|
||||
uint8_t metric;
|
||||
} uip_ds6_route;
|
||||
} uip_ds6_route_t;
|
||||
|
||||
/** \brief Interface structure (contains all the interface variables) */
|
||||
typedef struct uip_ds6_netif {
|
||||
uint32_t link_mtu;
|
||||
uint8_t cur_hop_limit;
|
||||
uint8_t cur_hop_limit;
|
||||
uint32_t base_reachable_time; /* in msec */
|
||||
uint32_t reachable_time; /* in msec */
|
||||
uint32_t retrans_timer; /* in msec */
|
||||
uint32_t reachable_time; /* in msec */
|
||||
uint32_t retrans_timer; /* in msec */
|
||||
uint8_t maxdadns;
|
||||
uip_ds6_addr addr_list[UIP_DS6_ADDR_NB];
|
||||
uip_ds6_aaddr aaddr_list[UIP_DS6_AADDR_NB];
|
||||
uip_ds6_maddr maddr_list[UIP_DS6_MADDR_NB];
|
||||
} uip_ds6_netif;
|
||||
uip_ds6_addr_t addr_list[UIP_DS6_ADDR_NB];
|
||||
uip_ds6_aaddr_t aaddr_list[UIP_DS6_AADDR_NB];
|
||||
uip_ds6_maddr_t maddr_list[UIP_DS6_MADDR_NB];
|
||||
} uip_ds6_netif_t;
|
||||
|
||||
/** \brief Generic type for a DS6, to use a common loop though all DS */
|
||||
typedef struct uip_ds6_element {
|
||||
uint8_t isused;
|
||||
uip_ipaddr_t ipaddr;
|
||||
} uip_ds6_element ;
|
||||
} uip_ds6_element_t;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern uip_ds6_netif uip_ds6_if;
|
||||
extern uip_ds6_netif_t uip_ds6_if;
|
||||
extern struct etimer uip_ds6_timer_periodic;
|
||||
|
||||
#if UIP_CONF_ROUTER
|
||||
extern uip_ds6_prefix uip_ds6_prefix_list[UIP_DS6_PREFIX_NB];
|
||||
extern uip_ds6_prefix_t uip_ds6_prefix_list[UIP_DS6_PREFIX_NB];
|
||||
#else /* UIP_CONF_ROUTER */
|
||||
extern struct etimer uip_ds6_timer_rs;
|
||||
#endif /* UIP_CONF_ROUTER */
|
||||
|
@ -266,80 +267,99 @@ void uip_ds6_init(void);
|
|||
/** \brief Periodic processing of data structures */
|
||||
void uip_ds6_periodic(void);
|
||||
|
||||
/** \brief Generic loop routine on an abstract data structure, which generalizes
|
||||
/** \brief Generic loop routine on an abstract data structure, which generalizes
|
||||
* all data structures used in DS6 */
|
||||
uint8_t uip_ds6_list_loop(uip_ds6_element* list, uint8_t size, uint16_t elementsize, uip_ipaddr_t* ipaddr, uint8_t ipaddrlen, uip_ds6_element** out_element);
|
||||
uint8_t uip_ds6_list_loop(uip_ds6_element_t * list, uint8_t size,
|
||||
uint16_t elementsize, uip_ipaddr_t * ipaddr,
|
||||
uint8_t ipaddrlen,
|
||||
uip_ds6_element_t ** out_element);
|
||||
|
||||
/** \name Neighbor Cache basic routines */
|
||||
/** @{ */
|
||||
uip_ds6_nbr* uip_ds6_nbr_add(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr, uint8_t isrouter, uint8_t state);
|
||||
void uip_ds6_nbr_rm(uip_ds6_nbr* nbr);
|
||||
uip_ds6_nbr* uip_ds6_nbr_lookup(uip_ipaddr_t *ipaddr);
|
||||
uip_ds6_nbr_t *uip_ds6_nbr_add(uip_ipaddr_t * ipaddr, uip_lladdr_t * lladdr,
|
||||
uint8_t isrouter, uint8_t state);
|
||||
void uip_ds6_nbr_rm(uip_ds6_nbr_t * nbr);
|
||||
uip_ds6_nbr_t *uip_ds6_nbr_lookup(uip_ipaddr_t * ipaddr);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** \name Default router list basic routines */
|
||||
/** @{ */
|
||||
uip_ds6_defrt* uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval);
|
||||
void uip_ds6_defrt_rm(uip_ds6_defrt* defrt);
|
||||
uip_ds6_defrt* uip_ds6_defrt_lookup(uip_ipaddr_t *ipaddr);
|
||||
uip_ipaddr_t* uip_ds6_defrt_choose(void);
|
||||
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 */
|
||||
/** @{ */
|
||||
#if UIP_CONF_ROUTER
|
||||
uip_ds6_prefix* uip_ds6_prefix_add(uip_ipaddr_t *ipaddr, uint8_t length, uint8_t advertise, uint8_t flags, unsigned long vtime, unsigned long ptime);
|
||||
uip_ds6_prefix_t *uip_ds6_prefix_add(uip_ipaddr_t * ipaddr, uint8_t length,
|
||||
uint8_t advertise, uint8_t flags,
|
||||
unsigned long vtime,
|
||||
unsigned long ptime);
|
||||
#else /* UIP_CONF_ROUTER */
|
||||
uip_ds6_prefix* uip_ds6_prefix_add(uip_ipaddr_t *ipaddr, uint8_t length, unsigned long interval);
|
||||
uip_ds6_prefix_t *uip_ds6_prefix_add(uip_ipaddr_t * ipaddr, uint8_t length,
|
||||
unsigned long interval);
|
||||
#endif /* UIP_CONF_ROUTER */
|
||||
void uip_ds6_prefix_rm(uip_ds6_prefix* prefix);
|
||||
uip_ds6_prefix* uip_ds6_prefix_lookup(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen);
|
||||
uint8_t uip_ds6_is_addr_onlink(uip_ipaddr_t *ipaddr);
|
||||
void uip_ds6_prefix_rm(uip_ds6_prefix_t * prefix);
|
||||
uip_ds6_prefix_t *uip_ds6_prefix_lookup(uip_ipaddr_t * ipaddr,
|
||||
uint8_t ipaddrlen);
|
||||
uint8_t uip_ds6_is_addr_onlink(uip_ipaddr_t * ipaddr);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** \name Unicast address list basic routines */
|
||||
/** @{ */
|
||||
uip_ds6_addr* uip_ds6_addr_add(uip_ipaddr_t *ipaddr, unsigned long vlifetime, uint8_t type);
|
||||
void uip_ds6_addr_rm(uip_ds6_addr *addr);
|
||||
uip_ds6_addr* uip_ds6_addr_lookup(uip_ipaddr_t* ipaddr);
|
||||
uip_ds6_addr_t *uip_ds6_addr_add(uip_ipaddr_t * ipaddr,
|
||||
unsigned long vlifetime, uint8_t type);
|
||||
void uip_ds6_addr_rm(uip_ds6_addr_t * addr);
|
||||
uip_ds6_addr_t *uip_ds6_addr_lookup(uip_ipaddr_t * ipaddr);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** \name Multicast address list basic routines */
|
||||
/** @{ */
|
||||
uip_ds6_maddr* uip_ds6_maddr_add(uip_ipaddr_t *ipaddr);
|
||||
void uip_ds6_maddr_rm(uip_ds6_maddr *maddr);
|
||||
uip_ds6_maddr* uip_ds6_maddr_lookup(uip_ipaddr_t* ipaddr);
|
||||
uip_ds6_maddr_t *uip_ds6_maddr_add(uip_ipaddr_t * ipaddr);
|
||||
void uip_ds6_maddr_rm(uip_ds6_maddr_t * maddr);
|
||||
uip_ds6_maddr_t *uip_ds6_maddr_lookup(uip_ipaddr_t * ipaddr);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** \name Anycast address list basic routines */
|
||||
/** @{ */
|
||||
uip_ds6_aaddr* uip_ds6_aaddr_add(uip_ipaddr_t *ipaddr);
|
||||
void uip_ds6_aaddr_rm(uip_ds6_aaddr *aaddr);
|
||||
uip_ds6_aaddr* uip_ds6_aaddr_lookup(uip_ipaddr_t* ipaddr);
|
||||
uip_ds6_aaddr_t *uip_ds6_aaddr_add(uip_ipaddr_t * ipaddr);
|
||||
void uip_ds6_aaddr_rm(uip_ds6_aaddr_t * aaddr);
|
||||
uip_ds6_aaddr_t *uip_ds6_aaddr_lookup(uip_ipaddr_t * ipaddr);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
/** \name Routing Table basic routines */
|
||||
/** @{ */
|
||||
uip_ipaddr_t* uip_ds6_route_lookup(uip_ipaddr_t *destipaddr);
|
||||
uip_ds6_route* uip_ds6_route_add(uip_ipaddr_t *ipaddr, u8_t length, uip_ipaddr_t *next_hop, u8_t metric);
|
||||
void uip_ds6_route_rm(uip_ds6_route* route);
|
||||
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, u8_t metric);
|
||||
void uip_ds6_route_rm(uip_ds6_route_t * route);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** \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);
|
||||
void uip_ds6_set_addr_iid(uip_ipaddr_t * ipaddr, uip_lladdr_t * lladdr);
|
||||
|
||||
/** \brief Get the number of matching bits of two addresses */
|
||||
uint8_t get_match_length(uip_ipaddr_t *src, uip_ipaddr_t *dst);
|
||||
uint8_t get_match_length(uip_ipaddr_t * src, uip_ipaddr_t * dst);
|
||||
|
||||
/** \brief Perform Duplicate Address Selection on one address */
|
||||
void uip_ds6_dad(uip_ds6_addr* ifaddr);
|
||||
void uip_ds6_dad(uip_ds6_addr_t * ifaddr);
|
||||
|
||||
/** \brief Callback when DAD failed */
|
||||
void uip_ds6_dad_failed(uip_ds6_addr* ifaddr);
|
||||
int uip_ds6_dad_failed(uip_ds6_addr_t * ifaddr);
|
||||
|
||||
/** \brief Source address selection, see RFC 3484 */
|
||||
void uip_ds6_select_src(uip_ipaddr_t *src, uip_ipaddr_t *dst);
|
||||
void uip_ds6_select_src(uip_ipaddr_t * src, uip_ipaddr_t * dst);
|
||||
|
||||
#if UIP_CONF_ROUTER
|
||||
#if UIP_ND6_SEND_RA
|
||||
|
@ -351,7 +371,7 @@ void uip_ds6_send_ra_periodic(void);
|
|||
#endif /* UIP_ND6_SEND_RA */
|
||||
#else /* UIP_CONF_ROUTER */
|
||||
/** \brief Send periodic RS to find router */
|
||||
void uip_ds6_send_rs(void);
|
||||
void uip_ds6_send_rs(void);
|
||||
#endif /* UIP_CONF_ROUTER */
|
||||
|
||||
/** \brief Compute the reachable time based on base reachable time, see RFC 4861*/
|
||||
|
@ -366,4 +386,3 @@ uint32_t uip_ds6_compute_reachable_time(void); /** \brief compute random reachab
|
|||
/** @} */
|
||||
|
||||
#endif /* __UIP_DS6_H__ */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue