您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ rpl_set_prefix函数代码示例

51自学网 2021-06-02 11:56:17
  C++
这篇教程C++ rpl_set_prefix函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中rpl_set_prefix函数的典型用法代码示例。如果您正苦于以下问题:C++ rpl_set_prefix函数的具体用法?C++ rpl_set_prefix怎么用?C++ rpl_set_prefix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了rpl_set_prefix函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: cetic_6lbr_set_prefix

/*---------------------------------------------------------------------------*/voidcetic_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}
开发者ID:kamejoko80,项目名称:6lbr,代码行数:36,


示例2: set_own_addresses

/*---------------------------------------------------------------------------*/static voidset_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");  }}
开发者ID:200018171,项目名称:contiki,代码行数:36,


示例3: cetic_6lbr_set_prefix

voidcetic_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}
开发者ID:Devesh24,项目名称:6lbr,代码行数:28,


示例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();}
开发者ID:AlexandreRio,项目名称:contiki,代码行数:60,


示例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();}
开发者ID:chanhemow,项目名称:contiki-fork,代码行数:58,


示例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();}
开发者ID:uoaerg,项目名称:wise,代码行数:57,


示例7: cetic_6lbr_start_dodag_root

voidcetic_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 */}
开发者ID:kamejoko80,项目名称:6lbr,代码行数:41,


示例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();}
开发者ID:bulajicm,项目名称:contiki-iris-examples,代码行数:54,


示例9: rpl_dag_root_init_dag_immediately

/*---------------------------------------------------------------------------*/intrpl_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;  }}
开发者ID:1847123212,项目名称:contiki,代码行数:53,


示例10: simple_rpl_init_dag_immediately

/*---------------------------------------------------------------------------*/intsimple_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;    }}
开发者ID:exziled,项目名称:WeatherSystem,代码行数:53,


示例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();}
开发者ID:Johnyren,项目名称:orpl,代码行数:49,


示例12: set_prefix_64

/*---------------------------------------------------------------------------*/voidset_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");  }}
开发者ID:jamella,项目名称:MyRepository,代码行数:18,


示例13: net_init

/*---------------------------------------------------------------------------*/static voidnet_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();}
开发者ID:matzTada,项目名称:contiki,代码行数:18,


示例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();}
开发者ID:C3MA,项目名称:hexabus,代码行数:45,


示例15: set_prefix_64

/* Set our prefix when we receive one over SLIP */voidset_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");  }}
开发者ID:GDanii,项目名称:contiki-mirror-MICAz-IPv6,代码行数:19,


示例16: cetic_6lbr_set_prefix

voidcetic_6lbr_set_prefix(uip_ipaddr_t * prefix, unsigned len,                      uip_ipaddr_t * ipaddr){  PRINTF("CETIC_BRIDGE : set_prefix/n");  if((nvm_data.mode & CETIC_MODE_WAIT_RA_MASK) == 0) {    PRINTF("Ignoring RA/n");    return;  }  if(cetic_dag != NULL) {    PRINTF("Setting DAG prefix : ");    PRINT6ADDR(&prefix->u8);    PRINTF("/n");    rpl_set_prefix(cetic_dag, prefix, len);    uip_ipaddr_copy(&wsn_net_prefix, prefix);  }}
开发者ID:denghongcai,项目名称:6lbr,代码行数:18,


示例17: create_rpl_dag

/*---------------------------------------------------------------------------*/static voidcreate_rpl_dag(uip_ipaddr_t *ipaddr){  struct uip_ds6_addr *root_if;  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();    uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);    rpl_set_prefix(dag, &prefix, 64);    printf("created a new RPL dag/n");  } else {    printf("failed to create a new RPL DAG/n");  }}
开发者ID:Blade87,项目名称:contiki-stm32f10x-iar,代码行数:19,


示例18: create_dag

voidcreate_dag(){  rpl_dag_t *dag;  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);  print_local_addresses();  dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &uip_ds6_get_global(ADDR_PREFERRED)->ipaddr);  if(dag != NULL) {    uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);    rpl_set_prefix(dag, &ipaddr, 64);    PRINTF("Created a new RPL dag with ID: ");    PRINT6ADDR(&dag->dag_id);    PRINTF("/n");  }}
开发者ID:Ammar-85,项目名称:contiki-arduino,代码行数:20,


示例19: create_dag

static voidcreate_dag(void){    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) {        static rpl_dag_t *dag;        dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)&ipaddr);        uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);        rpl_set_prefix(dag, &ipaddr, 64);        PRINTF("created a new RPL dag with ID:");        PRINT6ADDR(&dag->dag_id);        printf("/n");    } else {        PRINTF("failed to create a new RPL DAG/n");    }}
开发者ID:alirezapourbahram,项目名称:IoT-Wormhole-IDS,代码行数:21,


示例20: create_dag

void create_dag(){    uip_ipaddr_t ipaddr;    rpl_dag_t* dag;    // Create dag    dag = rpl_set_root(RPL_DEFAULT_INSTANCE,        &uip_ds6_get_global(ADDR_PREFERRED)->ipaddr);    if(dag == NULL) {      printf("E03/n");      return;    }    // Set the network prefix    uip_ip6addr(&ipaddr, 0xAAAA, 0, 0, 0, 0, 0, 0, 0);    rpl_set_prefix(dag, &ipaddr, 64);    PRINTF("# Created a new RPL dag with ID: ");    PRINT6ADDR(&dag->dag_id);    PRINTF("/n");}
开发者ID:RauPerez25,项目名称:Wall-E,代码行数:22,


示例21: PROCESS_THREAD

//.........这里部分代码省略........./*   #ifdef PARAMS_CHANNEL   PRINTF("PARAMs channel: %u/n", PARAMS_CHANNEL);   #endif */#ifdef RF_CHANNEL  PRINTF("RF channel: %u/n", RF_CHANNEL);#endif#ifdef IEEE802154_PANID  PRINTF("PAN ID: 0x%04X/n", IEEE802154_PANID);#endif  PRINTF("uIP buffer: %u/n", UIP_BUFSIZE);  PRINTF("LL header: %u/n", UIP_LLH_LEN);  PRINTF("IP+UDP header: %u/n", UIP_IPUDPH_LEN);  PRINTF("REST max chunk: %u/n", REST_MAX_CHUNK_SIZE);  /* Initialize the REST engine. */  rest_init_engine();  /*   * Bind the resources to their Uri-Path.   * WARNING: Activating twice only means alternate path, not two instances!   * All static variables are the same for each URI path.   *//*  rest_activate_resource(&res_hello, "test/hello"); *//*  rest_activate_resource(&res_mirror, "debug/mirror"); *//*  rest_activate_resource(&res_chunks, "test/chunks"); *//*  rest_activate_resource(&res_separate, "test/separate"); *//*  rest_activate_resource(&res_push, "test/push"); *//*  rest_activate_resource(&res_event, "sensors/button"); *//*  rest_activate_resource(&res_sub, "test/sub"); *//*  rest_activate_resource(&res_b1_sep_b2, "test/b1sepb2"); */#ifdef CO2  rest_activate_resource(&res_dc_co2, "dcdc/co2");#endif  rest_activate_resource(&res_dc_status_obs, "dcdc/status");/*  rest_activate_resource(&res_dc_status, "dcdc/status"); */  rest_activate_resource(&res_dc_vdc, "dcdc/vdc");  rest_activate_resource(&res_dc_hwcfg, "dcdc/hwcfg");/* #if PLATFORM_HAS_LEDS *//* / *  rest_activate_resource(&res_leds, "actuators/leds"); * / *//*  rest_activate_resource(&res_toggle, "actuators/toggle"); *//* #endif *//* #if PLATFORM_HAS_LIGHT *//*  rest_activate_resource(&res_light, "sensors/light"); *//*  SENSORS_ACTIVATE(light_sensor); *//* #endif *//**************************************************************************/  PRINTF("CoAP server started/n");#if UIP_CONF_ROUTER/* The choice of server address determines its 6LoPAN header compression. * Obviously the choice made here must also be selected in udp-client.c. * * For correct Wireshark decoding using a sniffer, add the /64 prefix to the 6LowPAN protocol preferences, * e.g. set Context 0 to aaaa::.  At present Wireshark copies Context/128 and then overwrites it. * (Setting Context 0 to aaaa::1111:2222:3333:4444 will report a 16 bit compressed address of aaaa::1111:22ff:fe33:xxxx) * Note Wireshark's IPCMV6 checksum verification depends on the correct uncompressed addresses. */#if 0/* Mode 1 - 64 bits inline */  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1);#elif 1/* Mode 2 - 16 bits inline */  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0x00ff, 0xfe00, 1);#else/* Mode 3 - derived from link local (MAC) address */  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);  uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);#endif  uip_ds6_addr_add(&ipaddr, 0, ADDR_MANUAL);  root_if = uip_ds6_addr_lookup(&ipaddr);  if(root_if != NULL) {    rpl_dag_t *dag;    dag = rpl_set_root(RPL_DEFAULT_INSTANCE, (uip_ip6addr_t *)&ipaddr);    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_MAC.off(1);  while(1) {    PROCESS_WAIT_EVENT();  }  PROCESS_END();}
开发者ID:13416795,项目名称:contiki,代码行数:101,


示例22: 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);    leds_init();    PRINTF("UDP server started/n");#if UIP_CONF_ROUTER    /* The choice of server address determines its 6LoWPAN header compression.     * Obviously the choice made here must also be selected in udp-client.c.     *     * For correct Wireshark decoding using a sniffer, add the /64 prefix to the     * 6LowPAN protocol preferences,     * e.g. set Context 0 to aaaa::.  At present Wireshark copies Context/128 and     * then overwrites it.     * (Setting Context 0 to aaaa::1111:2222:3333:4444 will report a 16 bit     * compressed address of aaaa::1111:22ff:fe33:xxxx)     * Note Wireshark's IPCMV6 checksum verification depends on the correct     * uncompressed addresses.     */#if 0    /* Mode 1 - 64 bits inline */    uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1);#elif 1    /* Mode 2 - 16 bits inline */    uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0x00ff, 0xfe00, 1);#else    /* Mode 3 - derived from link local (MAC) address */    uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);#endif    uip_ds6_addr_add(&ipaddr, 0, ADDR_MANUAL);    root_if = uip_ds6_addr_lookup(&ipaddr);    if(root_if != NULL) {        rpl_dag_t *dag;        dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)&ipaddr);        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_MAC.off(1);    server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL);    if(server_conn == NULL) {        PRINTF("No UDP connection available, exiting the process!/n");        PROCESS_EXIT();    }    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_root(RPL_DEFAULT_INSTANCE);        }    }    PROCESS_END();}
开发者ID:Jakl555,项目名称:contiki,代码行数:85,


示例23: rpl_process_dio

/*---------------------------------------------------------------------------*/voidrpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio){  rpl_instance_t *instance;  rpl_dag_t *dag, *previous_dag;  rpl_parent_t *p;  if(dio->mop != RPL_MOP_DEFAULT) {    PRINTF("RPL: Ignoring a DIO with an unsupported MOP: %d/n", dio->mop);    return;  }  dag = get_dag(dio->instance_id, &dio->dag_id);  instance = rpl_get_instance(dio->instance_id);  if(dag != NULL && instance != NULL) {    if(lollipop_greater_than(dio->version, dag->version)) {      if(dag->rank == ROOT_RANK(instance)) {	PRINTF("RPL: Root received inconsistent DIO version number/n");	dag->version = dio->version;	RPL_LOLLIPOP_INCREMENT(dag->version);	rpl_reset_dio_timer(instance);      } else {        PRINTF("RPL: Global Repair/n");        if(dio->prefix_info.length != 0) {          if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {            PRINTF("RPL : Prefix announced in DIO/n");            rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);          }        }	global_repair(from, dag, dio);      }      return;    }    if(lollipop_greater_than(dag->version, dio->version)) {      /* The DIO sender is on an older version of the DAG. */      PRINTF("RPL: old version received => inconsistency detected/n");      if(dag->joined) {        rpl_reset_dio_timer(instance);        return;      }    }  }  if(instance == NULL) {    PRINTF("RPL: New instance detected: Joining.../n");    rpl_join_instance(from, dio);    return;  }  if(dag == NULL) {    PRINTF("RPL: Adding new DAG to known instance./n");    rpl_add_dag(from, dio);    return;  }  if(dio->rank < ROOT_RANK(instance)) {    PRINTF("RPL: Ignoring DIO with too low rank: %u/n",           (unsigned)dio->rank);    return;  } else if(dio->rank == INFINITE_RANK && dag->joined) {    rpl_reset_dio_timer(instance);  }    /* Prefix Information Option treated to add new prefix */  if(dio->prefix_info.length != 0) {    if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {      PRINTF("RPL : Prefix announced in DIO/n");      rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);    }  }  if(dag->rank == ROOT_RANK(instance)) {    if(dio->rank != INFINITE_RANK) {      instance->dio_counter++;    }#if !WITH_ORPL    return; /* With ORPL we want to have neighbors in the "rpl_parents"    table as we need their rank and ackcount for routing set. */#endif  }  /*   * At this point, we know that this DIO pertains to a DAG that   * we are already part of. We consider the sender of the DIO to be   * a candidate parent, and let rpl_process_parent_event decide   * whether to keep it in the set.   */  p = rpl_find_parent(dag, from);  if(p == NULL) {    previous_dag = find_parent_dag(instance, from);    if(previous_dag == NULL) {      /* Add the DIO sender as a candidate parent. */      p = rpl_add_parent(dag, dio, from);      if(p == NULL) {        PRINTF("RPL: Failed to add a new parent (");//.........这里部分代码省略.........
开发者ID:Johnyren,项目名称:orpl,代码行数:101,


示例24: cetic_6lbr_init

voidcetic_6lbr_init(void){#if !CETIC_6LBR_TRANSPARENTBRIDGE  uip_ipaddr_t loc_fipaddr;  //DODAGID = link-local address used !  uip_create_linklocal_prefix(&loc_fipaddr);  uip_ds6_set_addr_iid(&loc_fipaddr, &uip_lladdr);  cetic_dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &loc_fipaddr);#endif  uip_ds6_addr_t *local = uip_ds6_get_link_local(-1);  uip_ipaddr_copy(&wsn_ip_local_addr, &local->ipaddr);  PRINTF("Tentative local IPv6 address ");  PRINT6ADDR(&wsn_ip_local_addr);  PRINTF("/n");#if CETIC_6LBR_SMARTBRIDGE || CETIC_6LBR_TRANSPARENTBRIDGE  if((nvm_data.mode & CETIC_MODE_WAIT_RA_MASK) == 0)    //Manual configuration  {    memcpy(wsn_net_prefix.u8, &nvm_data.wsn_net_prefix,           sizeof(nvm_data.wsn_net_prefix));    if((nvm_data.mode & CETIC_MODE_WSN_AUTOCONF) != 0)  //Address auto configuration    {      uip_ipaddr_copy(&wsn_ip_addr, &wsn_net_prefix);      uip_ds6_set_addr_iid(&wsn_ip_addr, &uip_lladdr);      uip_ds6_addr_add(&wsn_ip_addr, 0, ADDR_AUTOCONF);    } else {      memcpy(wsn_ip_addr.u8, &nvm_data.wsn_ip_addr,             sizeof(nvm_data.wsn_ip_addr));      uip_ds6_addr_add(&wsn_ip_addr, 0, ADDR_MANUAL);    }    PRINTF("Tentative global IPv6 address ");    PRINT6ADDR(&wsn_ip_addr.u8);    PRINTF("/n");    memcpy(eth_dft_router.u8, &nvm_data.eth_dft_router,           sizeof(nvm_data.eth_dft_router));    uip_ds6_defrt_add(&eth_dft_router, 0);#if CETIC_6LBR_SMARTBRIDGE    rpl_set_prefix(cetic_dag, &wsn_net_prefix, 64);#endif  }                             //End manual configuration#if CETIC_6LBR_TRANSPARENTBRIDGE  printf("Starting as Transparent-BRIDGE/n");#else  printf("Starting as Smart-BRIDGE/n");#endif#else /* ROUTER */  //WSN network configuration  memcpy(wsn_net_prefix.u8, &nvm_data.wsn_net_prefix,         sizeof(nvm_data.wsn_net_prefix));  if((nvm_data.mode & CETIC_MODE_WSN_AUTOCONF) != 0)    //Address auto configuration  {    uip_ipaddr_copy(&wsn_ip_addr, &wsn_net_prefix);    uip_ds6_set_addr_iid(&wsn_ip_addr, &uip_lladdr);    uip_ds6_addr_add(&wsn_ip_addr, 0, ADDR_AUTOCONF);  } else {    memcpy(wsn_ip_addr.u8, &nvm_data.wsn_ip_addr,           sizeof(nvm_data.wsn_ip_addr));    uip_ds6_addr_add(&wsn_ip_addr, 0, ADDR_MANUAL);  }  PRINTF("Tentative global IPv6 address (WSN) ");  PRINT6ADDR(&wsn_ip_addr.u8);  PRINTF("/n");  //Ethernet network configuration  memcpy(eth_net_prefix.u8, &nvm_data.eth_net_prefix,         sizeof(nvm_data.eth_net_prefix));  if((nvm_data.mode & CETIC_MODE_ROUTER_SEND_CONFIG) != 0) {    PRINTF("RA with autoconfig/n");    uip_ds6_prefix_add(&eth_net_prefix, 64, 1,                       UIP_ND6_RA_FLAG_ONLINK | UIP_ND6_RA_FLAG_AUTONOMOUS,                       30000, 30000);  } else {    PRINTF("RA without autoconfig/n");    uip_ds6_prefix_add(&eth_net_prefix, 64, 0, 0, 0, 0);  }  memcpy(eth_dft_router.u8, &nvm_data.eth_dft_router,         sizeof(nvm_data.eth_dft_router));  uip_ds6_defrt_add(&eth_dft_router, 0);  eth_mac64_addr.addr[0] = eth_mac_addr[0];  eth_mac64_addr.addr[1] = eth_mac_addr[1];  eth_mac64_addr.addr[2] = eth_mac_addr[2];  eth_mac64_addr.addr[3] = CETIC_6LBR_ETH_EXT_A;  eth_mac64_addr.addr[4] = CETIC_6LBR_ETH_EXT_B;  eth_mac64_addr.addr[5] = eth_mac_addr[3];  eth_mac64_addr.addr[6] = eth_mac_addr[4];  eth_mac64_addr.addr[7] = eth_mac_addr[5];  if((nvm_data.mode & CETIC_MODE_ETH_AUTOCONF) != 0)    //Address auto configuration  {    uip_ipaddr_copy(&eth_ip_addr, &eth_net_prefix);    uip_ds6_set_addr_iid(&eth_ip_addr, &eth_mac64_addr);//.........这里部分代码省略.........
开发者ID:denghongcai,项目名称:6lbr,代码行数:101,


示例25: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(border_router_process, ev, data){  rpl_dag_t *dag;  PROCESS_BEGIN();/* While waiting for the prefix to be sent through the SLIP connection, the future * border router can join an existing DAG as a parent or child, or acquire a default * router that will later take precedence over the SLIP fallback interface. * Prevent that by turning the radio off until we are initialized as a DAG root. */  prefix_set = 0;  NETSTACK_MAC.off(0);  PROCESS_PAUSE();  //SENSORS_ACTIVATE(button_sensor);  PRINTF("RPL-Border router started/n");#if 0   /* 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);#endif  /* Request prefix until it has been received */#define REQUEST_PREFIX  1#if REQUEST_PREFIX  static struct etimer et;  while(!prefix_set) {    etimer_set(&et, 1000);    request_prefix();    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));  }  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");   }#else  {      char buf[sizeof(dag_id)];      memcpy(buf,dag_id,sizeof(dag_id));      dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)buf);      /* Assign separate addresses to the uip stack and the host network          interface, but with the same prefix E.g. bbbb::ff:fe00:200 to          the stack and bbbb::1 to the host *fallback* network interface          Otherwise the host will trap packets intended for the stack,          just as the stack will trap packets intended for the host          $ifconfig usb0 -arp on Ubuntu to skip the neighbor          solicitations. Add explicit neighbors on other OSs */      if(dag != NULL)      {    	  PRINTF("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        {			int i;			uip_ip6addr_t ipaddr;		  #ifdef HARD_CODED_ADDRESS			uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr);		  #else			uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0x1);		  #endif			uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);			uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);			rpl_set_prefix(dag, &ipaddr, 64);			for(i = 0; i < UIP_DS6_ADDR_NB; i++) {			  if(uip_ds6_if.addr_list[i].isused) {				PRINTF("IPV6 Address: ");				sprint_ip6(uip_ds6_if.addr_list[i].ipaddr);				PRINTF("/n");			  }			}        }  #endif      }    }#endif  /* Now turn the radio on, but disable radio duty cycling.   * Since we are the DAG root, reception delays would constrain mesh throughbut.   */  NETSTACK_MAC.off(1);//.........这里部分代码省略.........
开发者ID:brtos,项目名称:brtos-contiki,代码行数:101,


示例26: cetic_6lbr_init

//.........这里部分代码省略.........         sizeof(nvm_data.eth_dft_router));  if ( !uip_is_addr_unspecified(&eth_dft_router) ) {    uip_ds6_defrt_add(&eth_dft_router, 0);  }  eth_mac64_addr.addr[0] = eth_mac_addr[0];  eth_mac64_addr.addr[1] = eth_mac_addr[1];  eth_mac64_addr.addr[2] = eth_mac_addr[2];  eth_mac64_addr.addr[3] = CETIC_6LBR_ETH_EXT_A;  eth_mac64_addr.addr[4] = CETIC_6LBR_ETH_EXT_B;  eth_mac64_addr.addr[5] = eth_mac_addr[3];  eth_mac64_addr.addr[6] = eth_mac_addr[4];  eth_mac64_addr.addr[7] = eth_mac_addr[5];  if((nvm_data.mode & CETIC_MODE_ETH_AUTOCONF) != 0)    //Address auto configuration  {    uip_ipaddr_copy(&eth_ip_addr, &eth_net_prefix);    uip_ds6_set_addr_iid(&eth_ip_addr, &eth_mac64_addr);    uip_ds6_addr_add(&eth_ip_addr, 0, ADDR_AUTOCONF);  } else {    memcpy(eth_ip_addr.u8, &nvm_data.eth_ip_addr,           sizeof(nvm_data.eth_ip_addr));    uip_ds6_addr_add(&eth_ip_addr, 0, ADDR_MANUAL);  }  LOG6LBR_6ADDR(INFO, &eth_ip_addr, "Tentative global IPv6 address (ETH) ");  //Ugly hack : in order to set WSN local address as the default address  //We must add it afterwards as uip_ds6_addr_add allocates addr from the end of the list  uip_ds6_addr_rm(local);  uip_create_linklocal_prefix(&eth_ip_local_addr);  uip_ds6_set_addr_iid(&eth_ip_local_addr, &eth_mac64_addr);  uip_ds6_addr_add(&eth_ip_local_addr, 0, ADDR_AUTOCONF);  uip_ds6_addr_add(&wsn_ip_local_addr, 0, ADDR_AUTOCONF);  //Prefix and RA configuration#if UIP_CONF_IPV6_RPL  uint8_t publish = (nvm_data.ra_prefix_flags & CETIC_6LBR_MODE_SEND_PIO) != 0;  uip_ds6_prefix_add(&eth_net_prefix, nvm_data.eth_net_prefix_len, publish,                     nvm_data.ra_prefix_flags,                     nvm_data.ra_prefix_vtime, nvm_data.ra_prefix_ptime);#else  uip_ds6_prefix_add(&eth_net_prefix, nvm_data.eth_net_prefix_len, 0, 0, 0, 0);  uint8_t publish = (nvm_data.ra_prefix_flags & CETIC_6LBR_MODE_SEND_PIO) != 0;  uip_ds6_prefix_add(&wsn_net_prefix, nvm_data.wsn_net_prefix_len, publish,		             nvm_data.ra_prefix_flags,		             nvm_data.ra_prefix_vtime, nvm_data.ra_prefix_ptime);#endif#if UIP_CONF_IPV6_RPL  if ((nvm_data.ra_rio_flags & CETIC_6LBR_MODE_SEND_RIO) != 0 ) {    uip_ds6_route_info_add(&wsn_net_prefix, nvm_data.wsn_net_prefix_len, nvm_data.ra_rio_flags, nvm_data.ra_rio_lifetime);  }#endif#endif#if UIP_CONF_IPV6_RPL && CETIC_6LBR_DODAG_ROOT  //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  LOG6LBR_INFO("Configured as DODAG Root/n");#endif#if CETIC_6LBR_TRANSPARENTBRIDGE#if CETIC_6LBR_LEARN_RPL_MAC  LOG6LBR_INFO("Starting as RPL Relay/n");#else  LOG6LBR_INFO("Starting as Full TRANSPARENT-BRIDGE/n");#endif#elif CETIC_6LBR_SMARTBRIDGE  LOG6LBR_INFO("Starting as SMART-BRIDGE/n");#elif CETIC_6LBR_ROUTER#if UIP_CONF_IPV6_RPL  LOG6LBR_INFO("Starting as RPL ROUTER/n");#else  LOG6LBR_INFO("Starting as NDP ROUTER/n");#endif#elif CETIC_6LBR_6LR  LOG6LBR_INFO("Starting as 6LR/n");#else  LOG6LBR_INFO("Starting in UNKNOWN mode/n");#endif#if CONTIKI_TARGET_NATIVE  if (ip_config_file_name) {    char str[INET6_ADDRSTRLEN];    inet_ntop(AF_INET6, (struct sockaddr_in6 *)&eth_ip_addr, str, INET6_ADDRSTRLEN);    FILE *ip_config_file = fopen(ip_config_file_name, "w");    fprintf(ip_config_file, "%s/n", str);    fclose(ip_config_file);  }#endif}
开发者ID:Mastnest,项目名称:6lbr,代码行数:101,


示例27: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_server_process, ev, data){  struct sensors_sensor *sensor;  uip_ipaddr_t ipaddr;  struct uip_ds6_addr *root_if;  static struct etimer timer;//  char buf[MAX_PAYLOAD_LEN];  PROCESS_BEGIN();  collect_common_net_init();    PROCESS_PAUSE();  SENSORS_ACTIVATE(button_sensor);  PRINTF("UDP server started/r/n");  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1);  uip_ip6addr(&clientipaddr,0xaaaa,0,0,0,0x0212,0x4B00,0x051d,0x0d30);    /* uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); */  uip_ds6_addr_add(&ipaddr, 0, ADDR_MANUAL); //MANUAL 手动模式;说明书;  root_if = uip_ds6_addr_lookup(&ipaddr);//look up 查找;  if(root_if != NULL) {    rpl_dag_t *dag;    dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)&ipaddr);    uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);    rpl_set_prefix(dag, &ipaddr, 64); //prefix 前缀;    PRINTF("created a new RPL dag./r/n");  } else {    PRINTF("failed to create a new RPL DAG./r/n");  }  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("/r/n");  PRINTF(" local/remote port %u/%u/r/n", UIP_HTONS(server_conn->lport),         UIP_HTONS(server_conn->rport));  initlcm();  set_wenzi();  while(1) {    PROCESS_YIELD();        if(ev == sensors_event){	sensor = (struct sensors_sensor *)data;	if(sensor == &button_sensor){            func_index=table[func_index].up;	}                if(sensor == &button_2_sensor){            func_index=table[func_index].down;	}        if(sensor == &button_3_sensor){            func_index=table[func_index].enter;	}                current_operation_index=table[func_index].current_operation;        (*current_operation_index)();//执行当前操作函数        }    if(ev == tcpip_event) {      tcpip_handler();    } else if (ev == blink_event) {      etimer_set(&timer, CLOCK_CONF_SECOND);    }    if(ev == PROCESS_EVENT_TIMER && sta == 1) {      if(data == &timer){        leds_toggle(LEDS_GREEN | LEDS_RED);      }       etimer_reset(&timer);    }    if(ev == serial_line_event_message) {      char *line;      line = (char *)data;      if(strncmp(line, "GET", 3) == 0) {        PRINTF("GET");    uip_ipaddr_copy(&server_conn->ripaddr, &clientipaddr);    uip_udp_packet_send(server_conn, "GET", sizeof("GET"));    uip_create_unspecified(&server_conn->ripaddr);      }else {        printf("unhandled command: %s/n", line);      }          /* Store rv temporarily in dec so we can use it for the battery */    }       }  PROCESS_END();}
开发者ID:ChenZJgor,项目名称:contiki,代码行数:98,



注:本文中的rpl_set_prefix函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ rpmExpand函数代码示例
C++ rpl_set_default_route函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。