本文整理汇总了C++中rpl_set_prefix函数的典型用法代码示例。如果您正苦于以下问题:C++ rpl_set_prefix函数的具体用法?C++ rpl_set_prefix怎么用?C++ rpl_set_prefix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rpl_set_prefix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cetic_6lbr_set_prefix
/*---------------------------------------------------------------------------*/
void
cetic_6lbr_set_prefix(uip_ipaddr_t * prefix, unsigned len,
uip_ipaddr_t * ipaddr)
{
#if CETIC_6LBR_SMARTBRIDGE
int new_prefix = !uip_ipaddr_prefixcmp(&wsn_net_prefix, prefix, len);
int new_dag_prefix = cetic_dag == NULL || !uip_ipaddr_prefixcmp(&cetic_dag->prefix_info.prefix, prefix, len);
if((nvm_data.mode & CETIC_MODE_WAIT_RA_MASK) == 0) {
LOG6LBR_DEBUG("Ignoring RA\n");
return;
}
if(new_prefix) {
LOG6LBR_6ADDR(INFO, prefix, "Setting prefix : ");
uip_ipaddr_copy(&wsn_ip_addr, ipaddr);
uip_ipaddr_copy(&wsn_net_prefix, prefix);
wsn_net_prefix_len = len;
LOG6LBR_6ADDR(INFO, &wsn_ip_addr, "Tentative global IPv6 address : ");
#if CONTIKI_TARGET_NATIVE
cetic_6lbr_save_ip();
#endif
}
if(new_dag_prefix) {
if((nvm_data.rpl_config & CETIC_6LBR_MODE_GLOBAL_DODAG) != 0) {
cetic_dag = rpl_set_root(nvm_data.rpl_instance_id, &wsn_ip_addr);
rpl_set_prefix(cetic_dag, prefix, len);
LOG6LBR_6ADDR(INFO, &cetic_dag->dag_id, "Configured as DODAG Root ");
} else {
rpl_set_prefix(cetic_dag, prefix, len);
LOG6LBR_6ADDR(INFO, prefix, "Setting DAG prefix : ");
rpl_repair_root(RPL_DEFAULT_INSTANCE);
}
}
#endif
}
示例2: set_own_addresses
/*---------------------------------------------------------------------------*/
static void
set_own_addresses(void)
{
int i;
uint8_t state;
rpl_dag_t *dag;
uip_ipaddr_t ipaddr;
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("Our IPv6 addresses:\n");
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)) {
PRINTF(" ");
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
PRINTF("\n");
if(state == ADDR_TENTATIVE) {
uip_ds6_if.addr_list[i].state = ADDR_PREFERRED;
}
}
}
/* Become root of a new DODAG with ID our global v6 address */
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &ipaddr);
if(dag != NULL) {
rpl_set_prefix(dag, &ipaddr, 64);
PRINTF("Created a new RPL dag with ID: ");
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
}
}
示例3: cetic_6lbr_set_prefix
void
cetic_6lbr_set_prefix(uip_ipaddr_t * prefix, unsigned len,
uip_ipaddr_t * ipaddr)
{
#if CETIC_6LBR_SMARTBRIDGE
int new_prefix = cetic_dag != NULL && !uip_ipaddr_prefixcmp(&cetic_dag->prefix_info.prefix, prefix, len);
if((nvm_data.mode & CETIC_MODE_WAIT_RA_MASK) == 0) {
LOG6LBR_DEBUG("Ignoring RA\n");
return;
}
LOG6LBR_INFO("CETIC_BRIDGE : set_prefix\n");
uip_ipaddr_copy(&wsn_ip_addr, ipaddr);
if(cetic_dag != NULL) {
rpl_set_prefix(cetic_dag, prefix, len);
uip_ipaddr_copy(&wsn_net_prefix, prefix);
wsn_net_prefix_len = len;
if(new_prefix) {
LOG6LBR_6ADDR(INFO, prefix, "Setting DAG prefix : ");
rpl_repair_root(RPL_DEFAULT_INSTANCE);
}
}
#if CONTIKI_TARGET_NATIVE
cetic_6lbr_save_ip();
#endif
#endif
}
示例4: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
static struct etimer et;
rpl_dag_t *dag;
PROCESS_BEGIN();
prefix_set = 0;
PROCESS_PAUSE();
PRINTF("RPL-Border router started\n");
slip_config_handle_arguments(contiki_argc, contiki_argv);
/* tun init is also responsible for setting up the SLIP connection */
tun_init();
while(!mac_set) {
etimer_set(&et, CLOCK_SECOND);
request_mac();
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
if(slip_config_ipaddr != NULL) {
uip_ipaddr_t prefix;
if(uiplib_ipaddrconv((const char *)slip_config_ipaddr, &prefix)) {
PRINTF("Setting prefix ");
PRINT6ADDR(&prefix);
PRINTF("\n");
set_prefix_64(&prefix);
} else {
PRINTF("Parse error: %s\n", slip_config_ipaddr);
exit(0);
}
}
dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
#if DEBUG
print_local_addresses();
#endif
/* The border router runs with a 100% duty cycle in order to ensure high
packet reception rates. */
NETSTACK_MAC.off(1);
while(1) {
etimer_set(&et, CLOCK_SECOND * 2);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
/* do anything here??? */
}
PROCESS_END();
}
示例5: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
#ifdef PREFIX_DISC
static struct etimer et;
#endif
rpl_dag_t *dag;
PROCESS_BEGIN();
prefix_set = 0;
PROCESS_PAUSE();
SENSORS_ACTIVATE(button_sensor);
PRINTF("RPL-Border router started\n");
/* The border router runs with a 100% duty cycle in order to ensure high
packet reception rates.
Note if the MAC RDC is not turned off now, aggressive power management of the
cpu will interfere with establishing the SLIP connection */
NETSTACK_MAC.off(1);
#ifndef PREFIX_DISC
if (!uiplib_ipaddrconv("aaaa::", &prefix))
goto err;
#else
/* Request prefix until it has been received */
while(!prefix_set) {
etimer_set(&et, CLOCK_SECOND);
request_prefix();
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
#endif
dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
#if DEBUG || 1
print_local_addresses();
#endif
while(1) {
PROCESS_YIELD();
if (ev == sensors_event && data == &button_sensor) {
PRINTF("Initiating global repair\n");
rpl_repair_root(RPL_DEFAULT_INSTANCE);
}
}
err:
PRINTF("Shutting down\n");
PROCESS_END();
}
示例6: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{
uip_ipaddr_t ipaddr;
struct uip_ds6_addr *root_if;
PROCESS_BEGIN();
PROCESS_PAUSE();
SENSORS_ACTIVATE(button_sensor);
PRINTF("UDP server started\n");
#if UIP_CONF_ROUTER
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1);
/* uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); */
uip_ds6_addr_add(&ipaddr, 0, ADDR_MANUAL);
root_if = uip_ds6_addr_lookup(&ipaddr);
if(root_if != NULL) {
rpl_dag_t *dag;
rpl_set_root((uip_ip6addr_t *)&ipaddr);
dag = rpl_get_dag(RPL_ANY_INSTANCE);
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
rpl_set_prefix(dag, &ipaddr, 64);
PRINTF("created a new RPL dag\n");
} else {
PRINTF("failed to create a new RPL DAG\n");
}
#endif /* UIP_CONF_ROUTER */
print_local_addresses();
/* The data sink runs with a 100% duty cycle in order to ensure high
packet reception rates. */
NETSTACK_RDC.off(1);
server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL);
udp_bind(server_conn, UIP_HTONS(UDP_SERVER_PORT));
PRINTF("Created a server connection with remote address ");
PRINT6ADDR(&server_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n", UIP_HTONS(server_conn->lport),
UIP_HTONS(server_conn->rport));
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event) {
tcpip_handler();
} else if (ev == sensors_event && data == &button_sensor) {
PRINTF("Initiaing global repair\n");
rpl_repair_dag(rpl_get_dag(RPL_ANY_INSTANCE));
}
}
PROCESS_END();
}
示例7: cetic_6lbr_start_dodag_root
void
cetic_6lbr_start_dodag_root(void)
{
#if CETIC_6LBR_DODAG_ROOT
if((nvm_data.rpl_config & CETIC_6LBR_MODE_MANUAL_DODAG) != 0) {
//Manual DODAG ID
cetic_dag = rpl_set_root(nvm_data.rpl_instance_id, (uip_ipaddr_t*)&nvm_data.rpl_dodag_id);
} else {
//Automatic DODAG ID
if((nvm_data.rpl_config & CETIC_6LBR_MODE_GLOBAL_DODAG) != 0) {
#if CETIC_6LBR_SMARTBRIDGE
if((nvm_data.mode & CETIC_MODE_WAIT_RA_MASK) == 0) {
#endif
//DODAGID = global address used !
cetic_dag = rpl_set_root(nvm_data.rpl_instance_id, &wsn_ip_addr);
#if CETIC_6LBR_SMARTBRIDGE
} else {
//Not global IP yet configured
cetic_dag = NULL;
}
#endif
} else {
//DODAGID = link-local address used !
cetic_dag = rpl_set_root(nvm_data.rpl_instance_id, &wsn_ip_local_addr);
}
}
#if CETIC_6LBR_SMARTBRIDGE
if((nvm_data.mode & CETIC_MODE_WAIT_RA_MASK) == 0) {
rpl_set_prefix(cetic_dag, &wsn_net_prefix, nvm_data.wsn_net_prefix_len);
}
#else
rpl_set_prefix(cetic_dag, &wsn_net_prefix, nvm_data.wsn_net_prefix_len);
#endif
if(cetic_dag) {
LOG6LBR_6ADDR(INFO, &cetic_dag->dag_id, "Configured as DODAG Root ");
}
if(!uip_is_addr_unspecified(&wsn_ip_addr)) {
uip_ds6_addr_add(&wsn_ip_addr, 0, ((nvm_data.mode & CETIC_MODE_WSN_AUTOCONF) != 0) ? ADDR_AUTOCONF : ADDR_MANUAL);
}
#endif /* CETIC_6LBR_DODAG_ROOT */
}
示例8: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
static struct etimer et;
rpl_dag_t *dag;
PROCESS_BEGIN();
prefix_set = 0;
PROCESS_PAUSE();
#if WEBSERVER
process_start(&webserver_nogui_process, NULL);
#endif
//SENSORS_ACTIVATE(button_sensor);
PRINTF("RPL-Border router started\n");
/* Request prefix until it has been received */
while(!prefix_set) {
etimer_set(&et, CLOCK_SECOND);
request_prefix();
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
dag = rpl_set_root((uip_ip6addr_t *)dag_id);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
#if DEBUG || 1
print_local_addresses();
#endif
/* The border router runs with a 100% duty cycle in order to ensure high
packet reception rates. */
NETSTACK_MAC.off(1);
static struct etimer t;
etimer_set(&t, 10*CLOCK_SECOND);
while(1) {
PROCESS_YIELD();
//if (ev == sensors_event && data == &button_sensor) {
if (etimer_expired(&t)) {
PRINTF("Initiating global repair\n");
rpl_repair_dag(rpl_get_dag(RPL_ANY_INSTANCE));
etimer_reset(&t);
}
}
PROCESS_END();
}
示例9: rpl_dag_root_init_dag_immediately
/*---------------------------------------------------------------------------*/
int
rpl_dag_root_init_dag_immediately(void)
{
struct uip_ds6_addr *root_if;
int i;
uint8_t state;
uip_ipaddr_t *ipaddr = NULL;
rpl_dag_root_init();
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)) {
ipaddr = &uip_ds6_if.addr_list[i].ipaddr;
}
}
if(ipaddr != NULL) {
root_if = uip_ds6_addr_lookup(ipaddr);
if(root_if != NULL) {
rpl_dag_t *dag;
uip_ipaddr_t prefix;
rpl_set_root(RPL_DEFAULT_INSTANCE, ipaddr);
dag = rpl_get_any_dag();
/* If there are routes in this dag, we remove them all as we are
from now on the new dag root and the old routes are wrong */
if(RPL_IS_STORING(dag->instance)) {
rpl_remove_routes(dag);
}
if(dag->instance != NULL &&
dag->instance->def_route != NULL) {
uip_ds6_defrt_rm(dag->instance->def_route);
dag->instance->def_route = NULL;
}
uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
rpl_set_prefix(dag, &prefix, 64);
PRINTF("RPL: rpl_dag_root_init_dag: created a new RPL dag\n");
return 0;
} else {
PRINTF("RPL: rpl_dag_root_init_dag: failed to create a new RPL DAG\n");
return -1;
}
} else {
PRINTF("RPL: rpl_dag_root_init_dag: failed to create a new RPL DAG, no preferred IP address found\n");
return -2;
}
}
示例10: simple_rpl_init_dag_immediately
/*---------------------------------------------------------------------------*/
int
simple_rpl_init_dag_immediately(void)
{
struct uip_ds6_addr *root_if;
int i;
uint8_t state;
uip_ipaddr_t *ipaddr = NULL;
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_link_local(&uip_ds6_if.addr_list[i].ipaddr)) {
ipaddr = &uip_ds6_if.addr_list[i].ipaddr;
}
}
if(ipaddr != NULL) {
root_if = uip_ds6_addr_lookup(ipaddr);
if(root_if != NULL) {
rpl_dag_t *dag;
uip_ipaddr_t prefix;
rpl_set_root(RPL_DEFAULT_INSTANCE, ipaddr);
dag = rpl_get_any_dag();
/* If there are routes in this dag, we remove them all as we are
from now on the new dag root and the old routes are wrong */
rpl_remove_routes(dag);
if(dag->instance != NULL &&
dag->instance->def_route != NULL) {
uip_ds6_defrt_rm(dag->instance->def_route);
dag->instance->def_route = NULL;
}
#if CONTIKI_TARGET_TRXEB1120 || CONTIKI_TARGET_ETH1120 || CONTIKI_TARGET_TRXEB2520 || CONTIKI_TARGET_TRXEB1101 || CONTIKI_TARGET_ETH1101 || CONTIKI_TARGET_ETH2520
uip_ip6addr(&prefix, 0xfc00, 0, 0xabba, 0xabba, 0, 0, 0, 0);
#else /* CONTIKI_TARGET_TRXEB1120 */
uip_ip6addr(&prefix, 0xfc00, 0, 0, 0, 0, 0, 0, 0);
#endif /* CONTIKI_TARGET_TRXEB1120 */
rpl_set_prefix(dag, &prefix, 64);
printf("\r\nsimple_rpl_init_dag: created a new RPL dag\n");
return 0;
} else {
printf("\r\nsimple_rpl_init_dag: failed to create a new RPL DAG\n");
return -1;
}
} else {
printf("\r\nsimple_rpl_init_dag: failed to create a new RPL DAG, no preferred IP address found\n");
return -2;
}
}
示例11: PROCESS_THREAD
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(unicast_sender_process, ev, data)
{
static struct etimer periodic_timer;
static struct etimer send_timer;
uip_ipaddr_t global_ipaddr;
PROCESS_BEGIN();
printf("App: %u starting\n", node_id);
uip_ip6addr(&root_ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1);
if(node_id == ROOT_ID) {
memcpy(&global_ipaddr, &root_ipaddr, 16);
uip_ds6_addr_add(&global_ipaddr, 0, ADDR_MANUAL);
rpl_dag_t *dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &global_ipaddr);
rpl_set_prefix(dag, &global_ipaddr, 64);
} else {
uip_ip6addr(&global_ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&global_ipaddr, &uip_lladdr);
uip_ds6_addr_add(&global_ipaddr, 0, ADDR_AUTOCONF);
}
orpl_init(&global_ipaddr, node_id == ROOT_ID, 1);
simple_udp_register(&unicast_connection, UDP_PORT,
NULL, UDP_PORT, receiver);
if(node_id == ROOT_ID) {
NETSTACK_RDC.off(1);
} else {
etimer_set(&periodic_timer, SEND_INTERVAL);
while(1) {
etimer_set(&send_timer, random_rand() % (SEND_INTERVAL));
PROCESS_WAIT_UNTIL(etimer_expired(&send_timer));
if(orpl_current_edc() != 0xffff) {
app_send_to(ROOT_ID);
} else {
printf("App: not in DODAG\n");
}
PROCESS_WAIT_UNTIL(etimer_expired(&periodic_timer));
etimer_reset(&periodic_timer);
}
}
PROCESS_END();
}
示例12: set_prefix_64
/*---------------------------------------------------------------------------*/
void
set_prefix_64(uip_ipaddr_t *prefix_64)
{
rpl_dag_t *dag;
uip_ipaddr_t ipaddr;
memcpy(&prefix, prefix_64, 16);
memcpy(&ipaddr, prefix_64, 16);
prefix_set = 1;
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &ipaddr);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
}
示例13: net_init
/*---------------------------------------------------------------------------*/
static void
net_init(uip_ipaddr_t *br_prefix)
{
uip_ipaddr_t global_ipaddr;
if(br_prefix) { /* We are RPL root. Will be set automatically
as TSCH pan coordinator via the tsch-rpl module */
memcpy(&global_ipaddr, br_prefix, 16);
uip_ds6_set_addr_iid(&global_ipaddr, &uip_lladdr);
uip_ds6_addr_add(&global_ipaddr, 0, ADDR_AUTOCONF);
rpl_set_root(RPL_DEFAULT_INSTANCE, &global_ipaddr);
rpl_set_prefix(rpl_get_any_dag(), br_prefix, 64);
rpl_repair_root(RPL_DEFAULT_INSTANCE);
}
NETSTACK_MAC.on();
}
示例14: PROCESS_THREAD
PROCESS_THREAD(border_router_process, ev, data)
{
PROCESS_BEGIN();
PROCESS_PAUSE();
{ rpl_dag_t *dag;
char buf[sizeof(dag_id)];
memcpy_P(buf,dag_id,sizeof(dag_id));
dag = rpl_set_root((uip_ip6addr_t *)buf);
/* Assign separate addresses to the jackdaw uip stack and the host network interface, but with the same prefix */
/* E.g. bbbb::200 to the jackdaw and bbbb::1 to the host network interface with $ip -6 address add bbbb::1/64 dev usb0 */
/* Otherwise the host will trap packets intended for the jackdaw, just as the jackdaw will trap RF packets intended for the host */
/* $ifconfig usb0 -arp on Ubuntu to skip the neighbor solicitations. Add explicit neighbors on other OSs */
if(dag != NULL) {
PRINTD("created a new RPL dag\n");
#if UIP_CONF_ROUTER_RECEIVE_RA
//Contiki stack will shut down until assigned an address from the interface RA
//Currently this requires changes in the core rpl-icmp6.c to pass the link-local RA broadcast
#else
uip_ip6addr_t ipaddr;
uip_ip6addr(&ipaddr, 0xbbbb, 0, 0, 0, 0, 0, 0, 0x200);
uip_ds6_addr_add(&ipaddr, 0, ADDR_MANUAL);
rpl_set_prefix(dag, &ipaddr, 64);
#endif
}
}
/* The border router runs with a 100% duty cycle in order to ensure high
packet reception rates. */
// NETSTACK_MAC.off(1);
while(1) {
PROCESS_YIELD();
/* Local and global dag repair can be done from the jackdaw menu */
// rpl_set_prefix(rpl_get_dag(RPL_ANY_INSTANCE), &ipaddr, 64);
// rpl_repair_dag(rpl_get_dag(RPL_ANY_INSTANCE));
}
PROCESS_END();
}
示例15: set_prefix_64
/* Set our prefix when we receive one over SLIP */
void
set_prefix_64(uip_ipaddr_t *prefix_64) {
rpl_dag_t *dag;
uip_ipaddr_t ipaddr;
memcpy(&ipaddr, prefix_64, 16);
prefix_set = 1;
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
/* Become root of a new DODAG with ID our global v6 address */
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &ipaddr);
if(dag != NULL) {
rpl_set_prefix(dag, &ipaddr, 64);
PRINTF("Created a new RPL dag with ID: ");
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
}
}