Merge branch 'develop' into contrib/update-cooja
This commit is contained in:
commit
abf1c76133
@ -67,9 +67,11 @@ typedef uint16_t u16_t;
|
||||
typedef uint32_t u32_t;
|
||||
typedef int32_t s32_t;
|
||||
|
||||
typedef unsigned short uip_stats_t;
|
||||
typedef unsigned int uip_stats_t;
|
||||
|
||||
#ifndef UIP_CONF_BYTE_ORDER
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
||||
|
@ -70,12 +70,44 @@
|
||||
#define LOG_MODULE "Native"
|
||||
#define LOG_LEVEL LOG_LEVEL_MAIN
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name Native Platform Configuration
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Defines the maximum number of file descriptors monitored by the platform
|
||||
* main loop.
|
||||
*/
|
||||
#ifdef SELECT_CONF_MAX
|
||||
#define SELECT_MAX SELECT_CONF_MAX
|
||||
#else
|
||||
#define SELECT_MAX 8
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines the timeout (in msec) of the select operation if no monitored file
|
||||
* descriptors becomes ready.
|
||||
*/
|
||||
#ifdef SELECT_CONF_TIMEOUT
|
||||
#define SELECT_TIMEOUT SELECT_CONF_TIMEOUT
|
||||
#else
|
||||
#define SELECT_TIMEOUT 1000
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Adds the STDIN file descriptor to the list of monitored file descriptors.
|
||||
*/
|
||||
#ifdef SELECT_CONF_STDIN
|
||||
#define SELECT_STDIN SELECT_CONF_STDIN
|
||||
#else
|
||||
#define SELECT_STDIN 1
|
||||
#endif
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static const struct select_callback *select_callback[SELECT_MAX];
|
||||
static int select_max = 0;
|
||||
|
||||
@ -116,6 +148,7 @@ select_set_callback(int fd, const struct select_callback *callback)
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if SELECT_STDIN
|
||||
static int
|
||||
stdin_set_fd(fd_set *rset, fd_set *wset)
|
||||
{
|
||||
@ -135,6 +168,7 @@ stdin_handle_fd(fd_set *rset, fd_set *wset)
|
||||
const static struct select_callback stdin_fd = {
|
||||
stdin_set_fd, stdin_handle_fd
|
||||
};
|
||||
#endif /* SELECT_STDIN */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
set_lladdr(void)
|
||||
@ -240,7 +274,9 @@ platform_init_stage_three()
|
||||
void
|
||||
platform_main_loop()
|
||||
{
|
||||
#if SELECT_STDIN
|
||||
select_set_callback(STDIN_FILENO, &stdin_fd);
|
||||
#endif /* SELECT_STDIN */
|
||||
while(1) {
|
||||
fd_set fdr;
|
||||
fd_set fdw;
|
||||
@ -252,7 +288,7 @@ platform_main_loop()
|
||||
retval = process_run();
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = retval ? 1 : 1000;
|
||||
tv.tv_usec = retval ? 1 : SELECT_TIMEOUT;
|
||||
|
||||
FD_ZERO(&fdr);
|
||||
FD_ZERO(&fdw);
|
||||
|
@ -115,7 +115,7 @@ static uip_ds6_nbr_t *nbr; /** Pointer to a nbr cache entry*/
|
||||
static uip_ds6_addr_t *addr; /** Pointer to an interface address */
|
||||
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
|
||||
|
||||
#if UIP_ND6_SEND_NS || !UIP_CONF_ROUTER
|
||||
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
|
||||
static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */
|
||||
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
|
||||
|
||||
@ -973,7 +973,7 @@ ra_input(void)
|
||||
default:
|
||||
LOG_DBG("Updating timer of prefix ");
|
||||
LOG_DBG_6ADDR(&prefix->ipaddr);
|
||||
LOG_DBG_(" new value %lu\n", uip_ntohl(nd6_opt_prefix_info->validlt));
|
||||
LOG_DBG_(" new value %lu\n", (unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt));
|
||||
stimer_set(&prefix->vlifetime,
|
||||
uip_ntohl(nd6_opt_prefix_info->validlt));
|
||||
prefix->isinfinite = 0;
|
||||
@ -999,7 +999,7 @@ ra_input(void)
|
||||
LOG_DBG("Updating timer of address ");
|
||||
LOG_DBG_6ADDR(&addr->ipaddr);
|
||||
LOG_DBG_(" new value %lu\n",
|
||||
uip_ntohl(nd6_opt_prefix_info->validlt));
|
||||
(unsigned long)uip_ntohl(nd6_opt_prefix_info->validlt));
|
||||
stimer_set(&addr->vlifetime,
|
||||
uip_ntohl(nd6_opt_prefix_info->validlt));
|
||||
} else {
|
||||
@ -1027,18 +1027,16 @@ ra_input(void)
|
||||
break;
|
||||
#if UIP_ND6_RA_RDNSS
|
||||
case UIP_ND6_OPT_RDNSS:
|
||||
if(UIP_ND6_RA_BUF->flags_reserved & (UIP_ND6_O_FLAG << 6)) {
|
||||
LOG_DBG("Processing RDNSS option\n");
|
||||
uint8_t naddr = (UIP_ND6_OPT_RDNSS_BUF->len - 1) / 2;
|
||||
uip_ipaddr_t *ip = (uip_ipaddr_t *)(&UIP_ND6_OPT_RDNSS_BUF->ip);
|
||||
LOG_DBG("got %d nameservers\n", naddr);
|
||||
while(naddr-- > 0) {
|
||||
LOG_DBG("nameserver: ");
|
||||
LOG_DBG_6ADDR(ip);
|
||||
LOG_DBG_(" lifetime: %lx\n", uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime));
|
||||
uip_nameserver_update(ip, uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime));
|
||||
ip++;
|
||||
}
|
||||
LOG_DBG("Processing RDNSS option\n");
|
||||
uint8_t naddr = (UIP_ND6_OPT_RDNSS_BUF->len - 1) / 2;
|
||||
uip_ipaddr_t *ip = (uip_ipaddr_t *)(&UIP_ND6_OPT_RDNSS_BUF->ip);
|
||||
LOG_DBG("got %d nameservers\n", naddr);
|
||||
while(naddr-- > 0) {
|
||||
LOG_DBG("nameserver: ");
|
||||
LOG_DBG_6ADDR(ip);
|
||||
LOG_DBG_(" lifetime: %lx\n", (unsigned long)uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime));
|
||||
uip_nameserver_update(ip, uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime));
|
||||
ip++;
|
||||
}
|
||||
break;
|
||||
#endif /* UIP_ND6_RA_RDNSS */
|
||||
|
@ -118,7 +118,7 @@ be added regardless of their reachability and liveness. */
|
||||
#define UIP_ND6_MIN_RA_INTERVAL UIP_CONF_ND6_MIN_RA_INTERVAL
|
||||
#endif
|
||||
#define UIP_ND6_M_FLAG 0
|
||||
#define UIP_ND6_O_FLAG (UIP_ND6_RA_RDNSS || UIP_ND6_RA_DNSSL)
|
||||
#define UIP_ND6_O_FLAG 0
|
||||
#ifndef UIP_CONF_ROUTER_LIFETIME
|
||||
#define UIP_ND6_ROUTER_LIFETIME 3 * UIP_ND6_MAX_RA_INTERVAL
|
||||
#else
|
||||
|
@ -141,15 +141,23 @@ get_global_addr(uip_ipaddr_t *addr)
|
||||
{
|
||||
int i;
|
||||
int state;
|
||||
uip_ipaddr_t *prefix = NULL;
|
||||
uint8_t prefix_length = 0;
|
||||
rpl_dag_t *dag = rpl_get_any_dag();
|
||||
|
||||
if(dag != NULL && dag->prefix_info.length != 0) {
|
||||
prefix = &dag->prefix_info.prefix;
|
||||
prefix_length = dag->prefix_info.length;
|
||||
}
|
||||
|
||||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
||||
state = uip_ds6_if.addr_list[i].state;
|
||||
if(uip_ds6_if.addr_list[i].isused &&
|
||||
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
|
||||
if(!uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) {
|
||||
memcpy(addr, &uip_ds6_if.addr_list[i].ipaddr, sizeof(uip_ipaddr_t));
|
||||
return 1;
|
||||
}
|
||||
state == ADDR_PREFERRED &&
|
||||
!uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr) &&
|
||||
(prefix == NULL || uip_ipaddr_prefixcmp(prefix, &uip_ds6_if.addr_list[i].ipaddr, prefix_length))) {
|
||||
memcpy(addr, &uip_ds6_if.addr_list[i].ipaddr, sizeof(uip_ipaddr_t));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -71,12 +71,20 @@ rpl_get_global_address(void)
|
||||
int i;
|
||||
uint8_t state;
|
||||
uip_ipaddr_t *ipaddr = NULL;
|
||||
uip_ipaddr_t *prefix = NULL;
|
||||
uint8_t prefix_length = 0;
|
||||
|
||||
if(curr_instance.used && curr_instance.dag.prefix_info.length != 0) {
|
||||
prefix = &curr_instance.dag.prefix_info.prefix;
|
||||
prefix_length = curr_instance.dag.prefix_info.length;
|
||||
}
|
||||
|
||||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
||||
state = uip_ds6_if.addr_list[i].state;
|
||||
if(uip_ds6_if.addr_list[i].isused &&
|
||||
state == ADDR_PREFERRED &&
|
||||
!uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) {
|
||||
!uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr) &&
|
||||
(prefix == NULL || uip_ipaddr_prefixcmp(prefix, &uip_ds6_if.addr_list[i].ipaddr, prefix_length))) {
|
||||
ipaddr = &uip_ds6_if.addr_list[i].ipaddr;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user