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

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

51自学网 2021-06-03 09:08:04
  C++
这篇教程C++ uip_ds6_addr_lookup函数代码示例写得很实用,希望能帮到您。

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

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

示例1: rpl_set_prefix

intrpl_set_prefix(rpl_dag_t *dag, uip_ipaddr_t *prefix, int len){  uip_ipaddr_t ipaddr;  if(len <= 128) {    memset(&dag->prefix_info.prefix, 0, 16);    memcpy(&dag->prefix_info.prefix, prefix, (len + 7) / 8);    dag->prefix_info.length = len;    dag->prefix_info.flags = 0x40;    PRINTF("RPL: Prefix set - will announce this in DIOs/n");    /* Autoconfigure an address if this node does not already have an address       with this prefix. */    /* assume that the prefix ends with zeros! */    memcpy(&ipaddr, &dag->prefix_info.prefix, 16);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);    if(uip_ds6_addr_lookup(&ipaddr) == NULL) {      PRINTF("RPL: adding global IP address ");      PRINT6ADDR(&ipaddr);      PRINTF("/n");      uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);    }    return 1;  }  return 0;}
开发者ID:Feandil,项目名称:RPL_Gateway,代码行数:27,


示例2: uip_ds6_set_lladdr

/*---------------------------------------------------------------------------*/void uip_ds6_set_lladdr(uip_lladdr_t *lladdr){  /* First remove the current address from system as this function   * can be called many times.   */  uip_ds6_addr_rm(uip_ds6_addr_lookup(&loc_fipaddr));  /* Create link local address, prefix, multicast addresses,   * anycast addresses   */  uip_create_linklocal_prefix(&loc_fipaddr);#if UIP_CONF_ROUTER  uip_ds6_prefix_add(&loc_fipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);#else /* UIP_CONF_ROUTER */  uip_ds6_prefix_add(&loc_fipaddr, UIP_DEFAULT_PREFIX_LEN, 0);#endif /* UIP_CONF_ROUTER */  memcpy(&uip_lladdr, lladdr, sizeof(uip_lladdr));  uip_ds6_set_addr_iid(&loc_fipaddr, &uip_lladdr);  uip_ds6_addr_add(&loc_fipaddr, 0, ADDR_AUTOCONF);  uip_create_linklocal_allnodes_mcast(&loc_fipaddr);  uip_ds6_maddr_add(&loc_fipaddr);#if UIP_CONF_ROUTER  uip_create_linklocal_allrouters_mcast(&loc_fipaddr);  uip_ds6_maddr_add(&loc_fipaddr);#endif /* UIP_CONF_ROUTER */}
开发者ID:CurieBSP,项目名称:zephyr,代码行数:31,


示例3: 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,


示例4: 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,


示例5: 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,


示例6: 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,


示例7: 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,


示例8: 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,


示例9: na_input

/** * Neighbor Advertisement Processing * * we might have to send a pkt that had been buffered while address * resolution was performed (if we support buffering, see UIP_CONF_QUEUE_PKT) * * As per RFC 4861, on link layer that have addresses, TLLAO options MUST be * included when responding to multicast solicitations, SHOULD be included in * response to unicast (here we assume it is for now) * * NA can be received after sending NS for DAD, Address resolution or NUD. Can * be unsolicited as well. * It can trigger update of the state of the neighbor in the neighbor cache, * router in the router list. * If the NS was for DAD, it means DAD failed * */static voidna_input(void){#if CETIC_6LBR_SMARTBRIDGE    uip_ds6_route_t * route;#endif    uint8_t is_llchange;    uint8_t is_router;    uint8_t is_solicited;    uint8_t is_override;    PRINTF("Received NA from");    PRINT6ADDR(&UIP_IP_BUF->srcipaddr);    PRINTF("to");    PRINT6ADDR(&UIP_IP_BUF->destipaddr);    PRINTF("with target address");    PRINT6ADDR((uip_ipaddr_t *) (&UIP_ND6_NA_BUF->tgtipaddr));    PRINTF("/n");    UIP_STAT(++uip_stat.nd6.recv);    /*     * booleans. the three last one are not 0 or 1 but 0 or 0x80, 0x40, 0x20     * but it works. Be careful though, do not use tests such as is_router == 1     */    is_llchange = 0;    is_router = ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_ROUTER));    is_solicited =        ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_SOLICITED));    is_override =        ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_OVERRIDE));#if UIP_CONF_IPV6_CHECKS    if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||            (UIP_ICMP_BUF->icode != 0) ||            (uip_is_addr_mcast(&UIP_ND6_NA_BUF->tgtipaddr)) ||            (is_solicited && uip_is_addr_mcast(&UIP_IP_BUF->destipaddr))) {        PRINTF("NA received is bad/n");        goto discard;    }#endif /*UIP_CONF_IPV6_CHECKS */    /* Options processing: we handle TLLAO, and must ignore others */    nd6_opt_offset = UIP_ND6_NA_LEN;    nd6_opt_llao = NULL;    while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {#if UIP_CONF_IPV6_CHECKS        if(UIP_ND6_OPT_HDR_BUF->len == 0) {            PRINTF("NA received is bad/n");            goto discard;        }#endif /*UIP_CONF_IPV6_CHECKS */        switch (UIP_ND6_OPT_HDR_BUF->type) {        case UIP_ND6_OPT_TLLAO:            nd6_opt_llao = (uint8_t *)UIP_ND6_OPT_HDR_BUF;            break;        default:            PRINTF("ND option not supported in NA/n");            break;        }        nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);    }#if CETIC_6LBR_SMARTBRIDGE    /* Address Advertisement */    if ( (nvm_data.mode & CETIC_MODE_SMART_MULTI_BR) != 0 ) {        if (uip_is_addr_mcast(&UIP_IP_BUF->destipaddr) && uip_is_mcast_group_id_all_nodes(&UIP_IP_BUF->destipaddr)) {            LOG6LBR_6ADDR(INFO, &UIP_ND6_NA_BUF->tgtipaddr, "Received purge NA for ");#if CETIC_NODE_INFO            node_info_rm_by_addr(&UIP_ND6_NA_BUF->tgtipaddr);#endif            route = uip_ds6_route_lookup(&UIP_ND6_NA_BUF->tgtipaddr);            if (route != NULL ) {                uip_ds6_route_rm(route);            }            goto discard;        }    }#endif    addr = uip_ds6_addr_lookup(&UIP_ND6_NA_BUF->tgtipaddr);    /* Message processing, including TLLAO if any */    if(addr != NULL) {#if UIP_ND6_DEF_MAXDADNS > 0        if(addr->state == ADDR_TENTATIVE) {            uip_ds6_dad_failed(addr);//.........这里部分代码省略.........
开发者ID:drandreas,项目名称:6lbr,代码行数:101,


示例10: ns_input

static voidns_input(void){    uint8_t flags;#if CETIC_6LBR_SMARTBRIDGE    uip_ds6_route_t * route;#endif    uip_ipaddr_t tgtipaddr;    PRINTF("Received NS from ");    PRINT6ADDR(&UIP_IP_BUF->srcipaddr);    PRINTF(" to ");    PRINT6ADDR(&UIP_IP_BUF->destipaddr);    PRINTF(" with target address");    PRINT6ADDR((uip_ipaddr_t *) (&UIP_ND6_NS_BUF->tgtipaddr));    PRINTF("/n");    UIP_STAT(++uip_stat.nd6.recv);#if UIP_CONF_IPV6_CHECKS    if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||            (uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||            (UIP_ICMP_BUF->icode != 0)) {        PRINTF("NS received is bad/n");        goto discard;    }#endif /* UIP_CONF_IPV6_CHECKS */    /* Options processing */    nd6_opt_llao = NULL;    nd6_opt_offset = UIP_ND6_NS_LEN;    while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {#if UIP_CONF_IPV6_CHECKS        if(UIP_ND6_OPT_HDR_BUF->len == 0) {            PRINTF("NS received is bad/n");            goto discard;        }#endif /* UIP_CONF_IPV6_CHECKS */        switch (UIP_ND6_OPT_HDR_BUF->type) {        case UIP_ND6_OPT_SLLAO:            nd6_opt_llao = &uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset];#if UIP_CONF_IPV6_CHECKS            /* There must be NO option in a DAD NS */            if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {                PRINTF("NS received is bad/n");                goto discard;            } else {#endif /*UIP_CONF_IPV6_CHECKS */                nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);                if(nbr == NULL) {                    /* Copy link address to a uip_lladdr_t first                     * to ensure the second argument to uip_ds6_nbr_add is word-aligned */                    uip_lladdr_t lladdr;                    memcpy(&lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], UIP_LLADDR_LEN);                    uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr, 0, NBR_STALE);                } else {                    uip_lladdr_t *lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr);                    if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],                              lladdr, UIP_LLADDR_LEN) != 0) {                        memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], UIP_LLADDR_LEN);                        nbr->state = NBR_STALE;                    } else {                        if(nbr->state == NBR_INCOMPLETE) {                            nbr->state = NBR_STALE;                        }                    }                }#if UIP_CONF_IPV6_CHECKS            }#endif /*UIP_CONF_IPV6_CHECKS */            break;        default:            PRINTF("ND option not supported in NS");            break;        }        nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);    }    memcpy(&tgtipaddr, &UIP_ND6_NS_BUF->tgtipaddr, sizeof(tgtipaddr));    addr = uip_ds6_addr_lookup(&tgtipaddr);#if CETIC_6LBR_SMARTBRIDGE    //ND Proxy implementation    if ( addr == NULL ) {        if ( (route = uip_ds6_route_lookup(&tgtipaddr)) != NULL ) {            if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {                /* DAD CASE */                uip_create_linklocal_allnodes_mcast(&tgtipaddr);                uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &tgtipaddr);                flags = UIP_ND6_NA_FLAG_OVERRIDE;                goto create_na;            } else {                uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &UIP_IP_BUF->srcipaddr);                uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &tgtipaddr);                flags = UIP_ND6_NA_FLAG_SOLICITED | UIP_ND6_NA_FLAG_OVERRIDE;                goto create_na;            }        }    }#endif    if(addr != NULL) {#if UIP_ND6_DEF_MAXDADNS > 0//.........这里部分代码省略.........
开发者ID:drandreas,项目名称:6lbr,代码行数:101,


示例11: join_dag

static voidjoin_dag(uip_ipaddr_t *from, rpl_dio_t *dio){  rpl_dag_t *dag;  rpl_parent_t *p;  rpl_of_t *of;  dag = rpl_alloc_dag(dio->instance_id);  if(dag == NULL) {    PRINTF("RPL: Failed to allocate a DAG object!/n");    return;  }  p = rpl_add_parent(dag, dio, from);  PRINTF("RPL: Adding ");  PRINT6ADDR(from);  PRINTF(" as a parent: ");  if(p == NULL) {    PRINTF("failed/n");    return;  }  PRINTF("succeeded/n");  /* Determine the objective function by using the     objective code point of the DIO. */  of = rpl_find_of(dio->ocp);  if(of == NULL) {    PRINTF("RPL: DIO for DAG instance %u does not specify a supported OF/n",        dio->instance_id);    return;  }  /* Autoconfigure an address if this node does not already have an address     with this prefix. */  if((dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) {    uip_ipaddr_t ipaddr;    /* assume that the prefix ends with zeros! */    memcpy(&ipaddr, &dio->prefix_info.prefix, 16);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);    if(uip_ds6_addr_lookup(&ipaddr) == NULL) {      PRINTF("RPL: adding global IP address ");      PRINT6ADDR(&ipaddr);      PRINTF("/n");      uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);    }  }  dag->joined = 1;  dag->used = 1;  dag->of = of;  dag->grounded = dio->grounded;  dag->mop = dio->mop;  dag->preference = dio->preference;  dag->instance_id = dio->instance_id;  dag->max_rankinc = dio->dag_max_rankinc;  dag->min_hoprankinc = dio->dag_min_hoprankinc;  dag->version = dio->version;  dag->preferred_parent = p;  dag->of->update_metric_container(dag);  dag->dio_intdoubl = dio->dag_intdoubl;  dag->dio_intmin = dio->dag_intmin;  dag->dio_redundancy = dio->dag_redund;  memcpy(&dag->dag_id, &dio->dag_id, sizeof(dio->dag_id));  /* copy prefix information into the dag */  memcpy(&dag->prefix_info, &dio->prefix_info, sizeof(rpl_prefix_t));  dag->rank = dag->of->calculate_rank(p, dio->rank);  dag->min_rank = dag->rank; /* So far this is the lowest rank we know of. */  PRINTF("RPL: Joined DAG with instance ID %u, rank %hu, DAG ID ",         dio->instance_id, dag->rank);  PRINT6ADDR(&dag->dag_id);  PRINTF("/n");  ANNOTATE("#A join=%u/n",dag->dag_id.u8[sizeof(dag->dag_id) - 1]);  dag->default_lifetime = dio->default_lifetime;  dag->lifetime_unit = dio->lifetime_unit;  rpl_reset_dio_timer(dag, 1);  rpl_set_default_route(dag, from);  if(should_send_dao(dag, dio, p)) {    rpl_schedule_dao(dag);  } else {    PRINTF("RPL: The DIO does not meet the prerequisites for sending a DAO/n");  }}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:94,


示例12: ra_input

//.........这里部分代码省略.........                                                  validlt));              } else {                prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix,                                            nd6_opt_prefix_info->preflen, 0);              }            }          } else {            switch (nd6_opt_prefix_info->validlt) {            case 0:              uip_ds6_prefix_rm(prefix);              break;            case UIP_ND6_INFINITE_LIFETIME:              prefix->isinfinite = 1;              break;            default:              PRINTF("Updating timer of prefix");              PRINT6ADDR(&prefix->ipaddr);              PRINTF("new value %lu/n", uip_ntohl(nd6_opt_prefix_info->validlt));              stimer_set(&prefix->vlifetime,                         uip_ntohl(nd6_opt_prefix_info->validlt));              prefix->isinfinite = 0;              break;            }          }        }        /* End of on-link flag related processing */        /* autonomous flag related processing */        if((nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_AUTONOMOUS)           && (nd6_opt_prefix_info->validlt != 0)           && (nd6_opt_prefix_info->preflen == UIP_DEFAULT_PREFIX_LEN)) {	            uip_ipaddr_copy(&ipaddr, &nd6_opt_prefix_info->prefix);          uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);          addr = uip_ds6_addr_lookup(&ipaddr);          if((addr != NULL) && (addr->type == ADDR_AUTOCONF)) {            if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) {              /* The processing below is defined in RFC4862 section 5.5.3 e */              if((uip_ntohl(nd6_opt_prefix_info->validlt) > 2 * 60 * 60) ||                 (uip_ntohl(nd6_opt_prefix_info->validlt) >                  stimer_remaining(&addr->vlifetime))) {                PRINTF("Updating timer of address");                PRINT6ADDR(&addr->ipaddr);                PRINTF("new value %lu/n",                       uip_ntohl(nd6_opt_prefix_info->validlt));                stimer_set(&addr->vlifetime,                           uip_ntohl(nd6_opt_prefix_info->validlt));              } else {                stimer_set(&addr->vlifetime, 2 * 60 * 60);                PRINTF("Updating timer of address ");                PRINT6ADDR(&addr->ipaddr);                PRINTF("new value %lu/n", (unsigned long)(2 * 60 * 60));              }              addr->isinfinite = 0;            } else {              addr->isinfinite = 1;            }          } else {            if(uip_ntohl(nd6_opt_prefix_info->validlt) ==               UIP_ND6_INFINITE_LIFETIME) {              uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);            } else {              uip_ds6_addr_add(&ipaddr, uip_ntohl(nd6_opt_prefix_info->validlt),                               ADDR_AUTOCONF);            }          }        }
开发者ID:naguirre,项目名称:contiki,代码行数:67,


示例13: 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,


示例14: uip_nd6_ns_input

voiduip_nd6_ns_input(void){  u8_t flags;  PRINTF("Received NS from");  PRINT6ADDR(&UIP_IP_BUF->srcipaddr);  PRINTF("to");  PRINT6ADDR(&UIP_IP_BUF->destipaddr);  PRINTF("with target address");  PRINT6ADDR((uip_ipaddr_t *) (&UIP_ND6_NS_BUF->tgtipaddr));  PRINTF("/n");  UIP_STAT(++uip_stat.nd6.recv);#if UIP_CONF_IPV6_CHECKS  if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||     (uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||     (UIP_ICMP_BUF->icode != 0)) {    PRINTF("NS received is bad/n");    goto discard;  }#endif /* UIP_CONF_IPV6_CHECKS */  /* Options processing */  nd6_opt_llao = NULL;  nd6_opt_offset = UIP_ND6_NS_LEN;  while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {#if UIP_CONF_IPV6_CHECKS    if(UIP_ND6_OPT_HDR_BUF->len == 0) {      PRINTF("NS received is bad/n");      goto discard;    }#endif /* UIP_CONF_IPV6_CHECKS */    switch (UIP_ND6_OPT_HDR_BUF->type) {    case UIP_ND6_OPT_SLLAO:      nd6_opt_llao = &uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset];#if UIP_CONF_IPV6_CHECKS      /* There must be NO option in a DAD NS */      if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {        PRINTF("NS received is bad/n");        goto discard;      } else {#endif /*UIP_CONF_IPV6_CHECKS */        nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);        if(nbr == NULL) {          uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr,			  (uip_lladdr_t *)&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],			  0, NBR_STALE);        } else {          if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],		    &nbr->lladdr, UIP_LLADDR_LEN) != 0) {            memcpy(&nbr->lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],		   UIP_LLADDR_LEN);            nbr->state = NBR_STALE;          } else {            if(nbr->state == NBR_INCOMPLETE) {              nbr->state = NBR_STALE;            }          }        }#if UIP_CONF_IPV6_CHECKS      }#endif /*UIP_CONF_IPV6_CHECKS */      break;    default:      PRINTF("ND option not supported in NS");      break;    }    nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);  }  addr = uip_ds6_addr_lookup(&UIP_ND6_NS_BUF->tgtipaddr);  if(addr != NULL) {    if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {      /* DAD CASE */#if UIP_CONF_IPV6_CHECKS      if(!uip_is_addr_solicited_node(&UIP_IP_BUF->destipaddr)) {        PRINTF("NS received is bad/n");        goto discard;      }#endif /* UIP_CONF_IPV6_CHECKS */      if(addr->state != ADDR_TENTATIVE) {        uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);        uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);        flags = UIP_ND6_NA_FLAG_OVERRIDE;        goto create_na;      } else {          /** /todo if I sent a NS before him, I win */        uip_ds6_dad_failed(addr);        goto discard;      }    }#if UIP_CONF_IPV6_CHECKS    if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr)) {        /**         * /NOTE do we do something here? we both are using the same address.         * If we are doing dad, we could cancel it, though we should receive a         * NA in response of DAD NS we sent, hence DAD will fail anyway. If we         * were not doing DAD, it means there is a duplicate in the network!         */      PRINTF("NS received is bad/n");//.........这里部分代码省略.........
开发者ID:EmuxEvans,项目名称:ContikiCC2530Port,代码行数:101,


示例15: na_input

/** * Neighbor Advertisement Processing * * we might have to send a pkt that had been buffered while address * resolution was performed (if we support buffering, see UIP_CONF_QUEUE_PKT) * * As per RFC 4861, on link layer that have addresses, TLLAO options MUST be * included when responding to multicast solicitations, SHOULD be included in * response to unicast (here we assume it is for now) * * NA can be received after sending NS for DAD, Address resolution or NUD. Can * be unsolicited as well. * It can trigger update of the state of the neighbor in the neighbor cache, * router in the router list. * If the NS was for DAD, it means DAD failed * */static voidna_input(void){  uint8_t is_llchange;  uint8_t is_router;  uint8_t is_solicited;  uint8_t is_override;  uip_lladdr_t lladdr_aligned;  PRINTF("Received NA from ");  PRINT6ADDR(&UIP_IP_BUF->srcipaddr);  PRINTF(" to ");  PRINT6ADDR(&UIP_IP_BUF->destipaddr);  PRINTF(" with target address ");  PRINT6ADDR((uip_ipaddr_t *) (&UIP_ND6_NA_BUF->tgtipaddr));  PRINTF("/n");  UIP_STAT(++uip_stat.nd6.recv);  /*   * booleans. the three last one are not 0 or 1 but 0 or 0x80, 0x40, 0x20   * but it works. Be careful though, do not use tests such as is_router == 1   */  is_llchange = 0;  is_router = ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_ROUTER));  is_solicited =    ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_SOLICITED));  is_override =    ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_OVERRIDE));#if UIP_CONF_IPV6_CHECKS  if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||     (UIP_ICMP_BUF->icode != 0) ||     (uip_is_addr_mcast(&UIP_ND6_NA_BUF->tgtipaddr)) ||     (is_solicited && uip_is_addr_mcast(&UIP_IP_BUF->destipaddr))) {    PRINTF("NA received is bad/n");    goto discard;  }#endif /*UIP_CONF_IPV6_CHECKS */  /* Options processing: we handle TLLAO, and must ignore others */  nd6_opt_offset = UIP_ND6_NA_LEN;  nd6_opt_llao = NULL;  while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {#if UIP_CONF_IPV6_CHECKS    if(UIP_ND6_OPT_HDR_BUF->len == 0) {      PRINTF("NA received is bad/n");      goto discard;    }#endif /*UIP_CONF_IPV6_CHECKS */    switch (UIP_ND6_OPT_HDR_BUF->type) {    case UIP_ND6_OPT_TLLAO:      nd6_opt_llao = (uint8_t *)UIP_ND6_OPT_HDR_BUF;      break;    default:      PRINTF("ND option not supported in NA/n");      break;    }    nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);  }  addr = uip_ds6_addr_lookup(&UIP_ND6_NA_BUF->tgtipaddr);  /* Message processing, including TLLAO if any */  if(addr != NULL) {#if UIP_ND6_DEF_MAXDADNS > 0    if(addr->state == ADDR_TENTATIVE) {      uip_ds6_dad_failed(addr);    }#endif /*UIP_ND6_DEF_MAXDADNS > 0 */    PRINTF("NA received is bad/n");    goto discard;  } else {    const uip_lladdr_t *lladdr;    nbr = uip_ds6_nbr_lookup(&UIP_ND6_NA_BUF->tgtipaddr);    if(nbr == NULL) {      goto discard;    }    lladdr = uip_ds6_nbr_get_ll(nbr);    if(lladdr == NULL) {      goto discard;    }    if(nd6_opt_llao != NULL) {      is_llchange =        memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], lladdr,               UIP_LLADDR_LEN);//.........这里部分代码省略.........
开发者ID:Conrad2210,项目名称:DEWI-Nimbus-Contiki,代码行数:101,


示例16: 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,



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


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