-
Notifications
You must be signed in to change notification settings - Fork 0
/
sn-utils.c
37 lines (33 loc) · 923 Bytes
/
sn-utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* \file
* Sleepy node utility functions.
*
* \authors
* Francesco Paolo Culcasi <[email protected]> <br>
* Alessandro Martinelli <[email protected]> <br>
* Nicola Messina <[email protected]> <br>
*/
#include "sn-utils.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
/**
* Sets the global address of the sleepy-node using a fixed prefix
* and a EUI-64 based interface ID.
*/
void set_global_address(void){
uip_ipaddr_t ipaddr;
int i;
uint8_t state;
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
PRINTF("IPv6 addresses: ");
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)) {
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
PRINTF("\n");
}
}
}