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

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

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

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

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

示例1: ule6loGI_getIp6addr

ule6lo_status_t	ule6loGI_getIp6addr(ule6lo_ipType_t ipType, ule6lo_ip6addr_t*	ipAddr, ule6lo_ipMode_t mode) {	ule6lo_status_t status = STATUS_NO_DATA;	uip_ds6_addr_t *uip_addr = NULL;	uint8_t index=0;	switch(ipType) {	case IP_ADDRESS_LINK_LOCAL:		uip_addr = uip_ds6_get_link_local((int8_t)mode);		break;	case IP_ADDRESS_GLOBAL:		uip_addr = uip_ds6_get_global((int8_t)mode);		break;	default:		break;	}	if(uip_addr !=NULL) {		for(index=0;index<16;index++) {			ipAddr->u8[index]=uip_addr->ipaddr.u8[index];		}		status = STATUS_SUCCESS;	}	return status;}
开发者ID:ULE-Alliance,项目名称:ULE_6LowPan,代码行数:25,


示例2: print_addresses

/*---------------------------------------------------------------------------*/void print_addresses(void){  uip_ds6_addr_t *lladdr;  printf("link-local IPv6 address: ");    lladdr = uip_ds6_get_link_local(-1);  if(lladdr != NULL){    print_address(lladdr);      printf("/r/n");  }  else    printf("None/r/n");    printf("global IPv6 address: ");    lladdr = uip_ds6_get_global(-1);  if(lladdr != NULL){    print_address(lladdr);      printf("/r/n");  }  else    printf("None/r/n");}
开发者ID:chanhemow,项目名称:contiki-fork,代码行数:27,


示例3: net_set_mac

int net_set_mac(uint8_t *mac, uint8_t len){	if ((len > UIP_LLADDR_LEN) || (len != 6 && len != 8)) {		NET_ERR("Wrong ll addr len, len %d, max %d/n",			len, UIP_LLADDR_LEN);		return -EINVAL;	}	linkaddr_set_node_addr((linkaddr_t *)mac);#ifdef CONFIG_NETWORKING_WITH_IPV6	{		uip_ds6_addr_t *lladdr;		uip_ds6_set_lladdr((uip_lladdr_t *)mac);		lladdr = uip_ds6_get_link_local(-1);		NET_DBG("Tentative link-local IPv6 address ");		PRINT6ADDR(&lladdr->ipaddr);		PRINTF("/n");		lladdr->state = ADDR_AUTOCONF;	}#endif	return 0;}
开发者ID:pafcndg,项目名称:ndgIqSoftwareKit,代码行数:27,


示例4: start_network

/** * /brief Start the network stack */static voidstart_network(void){#if NETSTACK_CONF_WITH_IPV6#ifndef CONTIKI_WAIT_FOR_MAC  memcpy(&uip_lladdr.addr, serial_id, sizeof(uip_lladdr.addr));#endif  process_start(&tcpip_process,NULL);#ifdef __CYGWIN__  process_start(&wpcap_process, NULL);#endif  printf("Tentative link-local IPv6 address ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    /* make it hardcoded... */    lladdr->state = ADDR_AUTOCONF;    printf("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }#elif NETSTACK_CONF_WITH_IPV4  process_start(&tcpip_process, NULL);#endif  autostart_start(autostart_processes);}
开发者ID:johangas,项目名称:thesis,代码行数:34,


示例5: handle_dao_timer

/*---------------------------------------------------------------------------*/static voidhandle_dao_timer(void *ptr){    rpl_instance_t *instance;    instance = (rpl_instance_t *)ptr;    if(!dio_send_ok && uip_ds6_get_link_local(ADDR_PREFERRED) == NULL) {        PRINTF("RPL: Postpone DAO transmission/n");        ctimer_set(&instance->dao_timer, CLOCK_SECOND, handle_dao_timer, instance);        return;    }    /* Send the DAO to the DAO parent set -- the preferred parent in our case. */    if(instance->current_dag->preferred_parent != NULL) {        PRINTF("RPL: handle_dao_timer - sending DAO/n");        /* Set the route lifetime to the default value. */        dao_output(instance->current_dag->preferred_parent, instance->default_lifetime);    } else {        PRINTF("RPL: No suitable DAO parent/n");    }    ctimer_stop(&instance->dao_timer);    if(etimer_expired(&instance->dao_lifetime_timer.etimer)) {        set_dao_lifetime_timer(instance);    }}
开发者ID:bobib22,项目名称:contiki-dinas-iotlab,代码行数:29,


示例6: uip_ds6_select_src

/*---------------------------------------------------------------------------*/voiduip_ds6_select_src(uip_ipaddr_t *src, uip_ipaddr_t *dst){  uint8_t best = 0;             /* number of bit in common with best match */  uint8_t n = 0;  uip_ds6_addr_t *matchaddr = NULL;  if(!uip_is_addr_link_local(dst) &&		  (!uip_is_addr_mcast(dst) || uip_is_addr_routable_mcast(dst))) {    /* find longest match */    for(locaddr = uip_ds6_if.addr_list;        locaddr < uip_ds6_if.addr_list + UIP_DS6_ADDR_NB; locaddr++) {      /* Only preferred global (not link-local) addresses */      if(locaddr->isused && locaddr->state == ADDR_PREFERRED &&         !uip_is_addr_link_local(&locaddr->ipaddr)) {        n = get_match_length(dst, &locaddr->ipaddr);        if(n >= best) {          best = n;          matchaddr = locaddr;        }      }    }  } else {    matchaddr = uip_ds6_get_link_local(ADDR_PREFERRED);  }  /* use the :: (unspecified address) as source if no match found */  if(matchaddr == NULL) {    uip_create_unspecified(src);  } else {    uip_ipaddr_copy(src, &matchaddr->ipaddr);  }}
开发者ID:ChristianKniep,项目名称:hexabus,代码行数:34,


示例7: handle_dao_timer

/*---------------------------------------------------------------------------*/static voidhandle_dao_timer(struct net_buf *not_used, void *ptr){  rpl_instance_t *instance;#if RPL_CONF_MULTICAST  uip_mcast6_route_t *mcast_route;  uint8_t i;#endif  instance = (rpl_instance_t *)ptr;  if(!dio_send_ok && uip_ds6_get_link_local(ADDR_PREFERRED) == NULL) {    PRINTF("RPL: Postpone DAO transmission/n");    ctimer_set(NULL, &instance->dao_timer, CLOCK_SECOND, handle_dao_timer, instance);    return;  }  /* Send the DAO to the DAO parent set -- the preferred parent in our case. */  if(instance->current_dag->preferred_parent != NULL) {    PRINTF("RPL: handle_dao_timer - sending DAO/n");    /* Set the route lifetime to the default value. */    dao_output(instance->current_dag->preferred_parent,	       instance->default_lifetime);#if RPL_CONF_MULTICAST    /* Send DAOs for multicast prefixes only if the instance is in MOP 3 */    if(instance->mop == RPL_MOP_STORING_MULTICAST) {      /* Send a DAO for own multicast addresses */      for(i = 0; i < UIP_DS6_MADDR_NB; i++) {        if(uip_ds6_if.maddr_list[i].isused            && uip_is_addr_mcast_global(&uip_ds6_if.maddr_list[i].ipaddr)) {          dao_output_target(instance->current_dag->preferred_parent,			    &uip_ds6_if.maddr_list[i].ipaddr,			    RPL_MCAST_LIFETIME);        }      }      /* Iterate over multicast routes and send DAOs */      mcast_route = uip_mcast6_route_list_head();      while(mcast_route != NULL) {        /* Don't send if it's also our own address, done that already */        if(uip_ds6_maddr_lookup(&mcast_route->group) == NULL) {          dao_output_target(instance->current_dag->preferred_parent,			    &mcast_route->group, RPL_MCAST_LIFETIME);        }        mcast_route = list_item_next(mcast_route);      }    }#endif  } else {    PRINTF("RPL: No suitable DAO parent/n");  }  ctimer_stop(&instance->dao_timer);  if(etimer_expired(&instance->dao_lifetime_timer.etimer)) {    set_dao_lifetime_timer(instance);  }}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:60,


示例8: handle_dio_timer

/*---------------------------------------------------------------------------*/static voidhandle_dio_timer(struct net_buf *not_used, void *ptr){  rpl_instance_t *instance;  instance = (rpl_instance_t *)ptr;  PRINTF("RPL: DIO Timer triggered/n");  if(!dio_send_ok) {    if(uip_ds6_get_link_local(ADDR_PREFERRED) != NULL) {      dio_send_ok = 1;    } else {      PRINTF("RPL: Postponing DIO transmission since link local address is not ok/n");      ctimer_set(NULL, &instance->dio_timer, CLOCK_SECOND, &handle_dio_timer,		 instance);      return;    }  }  if(instance->dio_send) {    /* send DIO if counter is less than desired redundancy */    if(instance->dio_redundancy != 0 && instance->dio_counter < instance->dio_redundancy) {#if RPL_CONF_STATS      instance->dio_totsend++;#endif /* RPL_CONF_STATS */      dio_output(instance, NULL);    } else {      PRINTF("RPL: Supressing DIO transmission (%d >= %d)/n",             instance->dio_counter, instance->dio_redundancy);    }    instance->dio_send = 0;    PRINTF("RPL: Scheduling DIO timer %lu ticks in future (sent)/n",           instance->dio_next_delay);    ctimer_set(NULL, &instance->dio_timer, instance->dio_next_delay,	       handle_dio_timer, instance);  } else {    /* check if we need to double interval */    if(instance->dio_intcurrent < instance->dio_intmin + instance->dio_intdoubl) {      instance->dio_intcurrent++;      PRINTF("RPL: DIO Timer interval doubled %d/n", instance->dio_intcurrent);    }    new_dio_interval(instance);  }#if DEBUG  rpl_print_neighbor_list();#endif}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:49,


示例9: get_local_address

static boolget_local_address(struct sol_network_link_addr *addr){    uip_ds6_addr_t *dsaddr;    dsaddr = uip_ds6_get_global(-1);    if (!dsaddr)        dsaddr = uip_ds6_get_link_local(-1);    SOL_NULL_CHECK(dsaddr, false);    addr->family = SOL_NETWORK_FAMILY_INET6;    addr->port = 0;    memcpy(&addr->addr.in6, &dsaddr->ipaddr, sizeof(addr->addr.in6));    return true;}
开发者ID:amandawrcoelho,项目名称:soletta,代码行数:16,


示例10: start_uip6

static voidstart_uip6(void){  NETSTACK_NETWORK.init();#ifndef WITH_SLIP_RADIO  process_start(&tcpip_process, NULL);#else#if WITH_SLIP_RADIO == 0  process_start(&tcpip_process, NULL);#endif#endif /* WITH_SLIP_RADIO */#if DEBUG  PRINTF("Tentative link-local IPv6 address ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      PRINTF("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);      /* make it hardcoded... */    }    lladdr->state = ADDR_AUTOCONF;    PRINTF("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }#endif /* DEBUG */  if(!UIP_CONF_IPV6_RPL) {    uip_ipaddr_t ipaddr;    int i;    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_TENTATIVE);    PRINTF("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      PRINTF("%02x%02x:",             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    PRINTF("%02x%02x/n",           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  }}
开发者ID:rfuentess,项目名称:contiki,代码行数:45,


示例11: handle_dao_timer

static voidhandle_dao_timer(void *ptr){  rpl_instance_t *instance;  instance = (rpl_instance_t *)ptr;  if(!dio_send_ok && uip_ds6_get_link_local(ADDR_PREFERRED) == NULL) {    PRINTF("RPL: Postpone DAO transmission/n");    ctimer_set(&instance->dao_timer, CLOCK_SECOND, handle_dao_timer, instance);    return;  }  /* Send the DAO to the DAO parent set -- the preferred parent in our case. */  if(instance->current_dag->preferred_parent != NULL) {    PRINTF("RPL: handle_dao_timer - sending DAO/n");    /* Set the route lifetime to the default value. */    dao_output(instance->current_dag->preferred_parent, instance->default_lifetime, NULL);#if UIP_IPV6_MULTICAST_RPL    if(instance->mop == RPL_MOP_STORING_MULTICAST) {      /* Send a DAO for own multicast addresses */      for(i = 0; i < UIP_DS6_MADDR_NB; i++) {        if(uip_ds6_if.maddr_list[i].isused            && uip_is_addr_mcast_global(&uip_ds6_if.maddr_list[i].ipaddr)) {          dao_output(instance->current_dag->preferred_parent, RPL_MCAST_LIFETIME,              &uip_ds6_if.maddr_list[i].ipaddr);        }      }      /* Iterate multicast routes and send DAOs */      for(i = 0; i < UIP_DS6_MCAST_ROUTES; i++) {        /* Don't send if it's also our own address, done that already */        if(uip_ds6_mcast_table[i].isused) {          if(uip_ds6_maddr_lookup(&uip_ds6_mcast_table[i].group) == NULL) {            dao_output(instance->current_dag->preferred_parent, RPL_MCAST_LIFETIME,                &uip_ds6_mcast_table[i].group);          }        }      }    }#endif  } else {    PRINTF("RPL: No suitable DAO parent/n");  }  ctimer_stop(&instance->dao_timer);}
开发者ID:kfathallah,项目名称:contiki-mcast,代码行数:45,


示例12: handle_dio_timer

static voidhandle_dio_timer(void *ptr){  rpl_dag_t *dag;  dag = (rpl_dag_t *)ptr;  PRINTF("RPL: DIO Timer triggered");  if(!dio_send_ok) {    if(uip_ds6_get_link_local(ADDR_PREFERRED) != NULL) {      dio_send_ok = 1;    } else {      PRINTF("RPL: Postponing DIO transmission since link local address is not ok");      ctimer_set(&dag->dio_timer, CLOCK_SECOND, &handle_dio_timer, dag);      return;    }  }  if(dag->dio_send) {    /* send DIO if counter is less than desired redundancy */    if(dag->dio_counter < dag->dio_redundancy) {#if RPL_CONF_STATS      dag->dio_totsend++;#endif /* RPL_CONF_STATS */      dio_output(dag, NULL);    } else {      PRINTF("RPL: Supressing DIO transmission (Xd >= Xd)");//, dag->dio_counter, dag->dio_redundancy);    }    dag->dio_send = 0;    PRINTF("RPL: Scheduling DIO timer Xu ticks in future (sent)");//, dag->dio_next_delay);    ctimer_set(&dag->dio_timer, dag->dio_next_delay, handle_dio_timer, dag);  } else {    /* check if we need to double interval */    if(dag->dio_intcurrent < dag->dio_intmin + dag->dio_intdoubl) {      dag->dio_intcurrent++;      PRINTF("RPL: DIO Timer interval doubled Xd");//, dag->dio_intcurrent);    }    new_dio_interval(dag);  }}
开发者ID:bearxiong99,项目名称:Arduino-IPv6Stack,代码行数:40,


示例13: handle_dao_timer

static voidhandle_dao_timer(void *ptr){  rpl_dag_t *dag;  dag = (rpl_dag_t *)ptr;  if (!dio_send_ok && uip_ds6_get_link_local(ADDR_PREFERRED) == NULL) {    PRINTF("RPL: Postpone DAO transmission... ");    ctimer_set(&dag->dao_timer, CLOCK_SECOND, handle_dao_timer, dag);    return;  }  /* Send the DAO to the DAO parent set -- the preferred parent in our case. */  if(dag->preferred_parent != NULL) {    PRINTF("RPL: handle_dao_timer - sending DAO");    /* Set the route lifetime to the default value. */    dao_output(dag->preferred_parent, dag->default_lifetime);  } else {    PRINTF("RPL: No suitable DAO parent");  }  ctimer_stop(&dag->dao_timer);}
开发者ID:bearxiong99,项目名称:Arduino-IPv6Stack,代码行数:23,


示例14: tcpip_handler

/*---------------------------------------------------------------------------*/static void tcpip_handler(void) {	uint8_t *appdata;	uint8_t reqID;	uint32_t sinklastTX;	if (uip_newdata()) {		// Collect data from received payload		appdata = (uint8_t *) uip_appdata;		//		printf ("sizeof(appdata): %u/n", uip_datalen());		reqID = *appdata; // Check for next lines		appdata += 2; // 01 for alignment		memcpy(&sinklastTX, appdata, 4);		// Stop when reaching condition		if (reqID >= STOPCONDITION) {			stopCond = 1;			printf("I am stopping /n");			return;		}		//Get the time for receiving response		uint32_t time = get_time_ms();		// Updating statistics information for the node		//		PRINTF("Updating statistics information/n");		if (nodeInf.nodeID == 0) { // get nodeId for the first time			uip_ds6_addr_t *addr;			addr = uip_ds6_get_link_local(-1);			nodeInf.nodeID = (addr->ipaddr.u8[sizeof(uip_ipaddr_t) - 2] << 8)					+ addr->ipaddr.u8[sizeof(uip_ipaddr_t) - 1];		}		uint8_t oldresID = nodeInf.resID; // Store the resID		nodeInf.senderlastRX = time;		/*if (nodeInf.resID==0){ // first time received a request		 } else { // received at least one request		 }*/		nodeInf.resID = reqID; // Update resID to be identical with its request's ID		//	nodeInf.senderlastTX = time;		nodeInf.numReq++;		uint16_t sinkTX = (uint16_t) (time - sinklastTX) & 0xffff;		if (nodeInf.sinkMinTX > sinkTX) {			nodeInf.sinkMinTX = sinkTX;		}		if (nodeInf.sinkMaxTX < sinkTX) {			nodeInf.sinkMinTX = sinkTX;		}		/*PRINTF("RX_Time:%lu nodeID=%u resID=%u sinkTX=%u/n",		 time, nodeInf.nodeID, nodeInf.resID, sinkTX);*/		printf("RX: Time : %lu sinklastTX: %lu reqID: %u /n", time, sinklastTX,				reqID);		//client_send();	}}
开发者ID:pvhau,项目名称:contiki-ext,代码行数:63,


示例15: main

//.........这里部分代码省略.........    cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);  }  leds_off(LEDS_ALL);  if(node_id > 0) {    PRINTF("Node id %u./n", node_id);  } else {    PRINTF("Node id not set./n");  }#if NETSTACK_CONF_WITH_IPV6  memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));  /* Setup nullmac-like MAC for 802.15.4 */  queuebuf_init();  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  printf("%s %lu %u/n",         NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:                         NETSTACK_RDC.channel_check_interval()),         CC2420_CONF_CHANNEL);  process_start(&tcpip_process, NULL);  printf("IPv6 ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }  if(!UIP_CONF_IPV6_RPL) {    uip_ipaddr_t ipaddr;    int i;    uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);    uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);    printf("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      printf("%02x%02x:",             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n",           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  }#else /* NETSTACK_CONF_WITH_IPV6 */  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  printf("%s %lu %u/n",         NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:                         NETSTACK_RDC.channel_check_interval()),
开发者ID:13416795,项目名称:contiki,代码行数:67,


示例16: sizeof

struct net_context *net_context_get(enum ip_protocol ip_proto,					const struct net_addr *remote_addr,					uint16_t remote_port,					struct net_addr *local_addr,					uint16_t local_port){#ifdef CONFIG_NETWORKING_WITH_IPV6	const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;	const uip_ds6_addr_t *uip_addr;	uip_ipaddr_t ipaddr;#endif	int i;	struct net_context *context = NULL;	/* User must provide storage for the local address. */	if (!local_addr) {		return NULL;	}#ifdef CONFIG_NETWORKING_WITH_IPV6	if (memcmp(&local_addr->in6_addr, &in6addr_any,				  sizeof(in6addr_any)) == 0) {		uip_addr = uip_ds6_get_global(-1);		if (!uip_addr) {			uip_addr = uip_ds6_get_link_local(-1);		}		if (!uip_addr) {			return NULL;		}		memcpy(&local_addr->in6_addr, &uip_addr->ipaddr,		       sizeof(struct in6_addr));	}#else	if (local_addr->in_addr.s_addr == INADDR_ANY) {		uip_gethostaddr((uip_ipaddr_t *)&local_addr->in_addr);	}#endif	nano_sem_take(&contexts_lock, TICKS_UNLIMITED);	if (local_port) {		if (context_port_used(ip_proto, local_port, local_addr) < 0) {			return NULL;		}	} else {		do {			local_port = random_rand() | 0x8000;		} while (context_port_used(ip_proto, local_port,					   local_addr) == -EEXIST);	}	for (i = 0; i < NET_MAX_CONTEXT; i++) {		if (!contexts[i].tuple.ip_proto) {			contexts[i].tuple.ip_proto = ip_proto;			contexts[i].tuple.remote_addr = (struct net_addr *)remote_addr;			contexts[i].tuple.remote_port = remote_port;			contexts[i].tuple.local_addr = (struct net_addr *)local_addr;			contexts[i].tuple.local_port = local_port;			context = &contexts[i];			break;		}	}	context_sem_give(&contexts_lock);	/* Set our local address */#ifdef CONFIG_NETWORKING_WITH_IPV6	memcpy(&ipaddr.u8, local_addr->in6_addr.s6_addr, sizeof(ipaddr.u8));	if (uip_is_addr_mcast(&ipaddr)) {		uip_ds6_maddr_add(&ipaddr);	} else {		uip_ds6_addr_add(&ipaddr, 0, ADDR_MANUAL);	}#endif	return context;}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:78,


示例17: init_net

/*---------------------------------------------------------------------------*/voidinit_net(void){  set_rime_addr();  cc2420_init();  {    uint8_t longaddr[8];    uint16_t shortaddr;        shortaddr = (linkaddr_node_addr.u8[0] << 8) +                 linkaddr_node_addr.u8[1];    memset(longaddr, 0, sizeof(longaddr));    linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr);    printf_P(PSTR("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x/n"),             longaddr[0], longaddr[1], longaddr[2], longaddr[3],             longaddr[4], longaddr[5], longaddr[6], longaddr[7]);        cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);  }#if NETSTACK_CONF_WITH_IPV6  memcpy(&uip_lladdr.addr, ds2401_id, sizeof(uip_lladdr.addr));  /* Setup nullmac-like MAC for 802.15.4 */  /* sicslowpan_init(sicslowmac_init(&cc2420_driver)); */  /* printf(" %s channel %u/n", sicslowmac_driver.name, CC2420_CONF_CHANNEL); */  /* Setup X-MAC for 802.15.4 */  queuebuf_init();  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  printf_P(PSTR("%s %s, channel check rate %d Hz, radio channel %d/n"),         NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:                         NETSTACK_RDC.channel_check_interval()),         CC2420_CONF_CHANNEL);  process_start(&tcpip_process, NULL);  printf_P(PSTR("Tentative link-local IPv6 address "));  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf_P(PSTR("%02x%02x:"), lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    printf_P(PSTR("%02x%02x/n"), lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }  if(!UIP_CONF_IPV6_RPL) {    uip_ipaddr_t ipaddr;    int i;    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_TENTATIVE);    printf_P(PSTR("Tentative global IPv6 address "));    for(i = 0; i < 7; ++i) {      printf_P(PSTR("%02x%02x:"),             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    printf_P(PSTR("%02x%02x/n"),           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  }#else /* NETSTACK_CONF_WITH_IPV6 */  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  printf_P(PSTR("%s %s, channel check rate %d Hz, radio channel %d/n"),         NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:                         NETSTACK_RDC.channel_check_interval()),         CC2420_CONF_CHANNEL);#endif /* NETSTACK_CONF_WITH_IPV6 */#if NETSTACK_CONF_WITH_IPV4  uip_ipaddr_t hostaddr, netmask;   uip_init();  uip_fw_init();  process_start(&tcpip_process, NULL);  process_start(&slip_process, NULL);  process_start(&uip_fw_process, NULL);    slip_set_input_callback(set_gateway);  /* Construct ip address from four bytes. */  uip_ipaddr(&hostaddr, 172, 16, linkaddr_node_addr.u8[0],                                  linkaddr_node_addr.u8[1]);  /* Construct netmask from four bytes. */  uip_ipaddr(&netmask, 255,255,0,0);//.........这里部分代码省略.........
开发者ID:Babody,项目名称:contiki,代码行数:101,


示例18: contiki_init

/*---------------------------------------------------------------------------*/voidcontiki_init(){  /* Initialize random generator (moved to moteid.c) */  /* Start process handler */  process_init();  /* Start Contiki processes */  process_start(&etimer_process, NULL);  process_start(&sensors_process, NULL);  ctimer_init();  /* Print startup information */  printf(CONTIKI_VERSION_STRING " started. ");  if(node_id > 0) {    printf("Node id is set to %u./n", node_id);  } else {    printf("Node id is not set./n");  }  set_rime_addr();  {    uint8_t longaddr[8];        memset(longaddr, 0, sizeof(longaddr));    linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr);    printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ",           longaddr[0], longaddr[1], longaddr[2], longaddr[3],           longaddr[4], longaddr[5], longaddr[6], longaddr[7]);  }  queuebuf_init();  /* Initialize communication stack */  netstack_init();  printf("%s/%s/%s, channel check rate %lu Hz/n",	 NETSTACK_NETWORK.name, NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:                         NETSTACK_RDC.channel_check_interval()));#if WITH_UIP  /* IPv4 CONFIGURATION */  {    uip_ipaddr_t hostaddr, netmask;    process_start(&tcpip_process, NULL);    process_start(&uip_fw_process, NULL);    process_start(&slip_process, NULL);    slip_set_input_callback(set_gateway);    uip_init();    uip_fw_init();    uip_ipaddr(&hostaddr, 172,16,linkaddr_node_addr.u8[0],linkaddr_node_addr.u8[1]);    uip_ipaddr(&netmask, 255,255,0,0);    uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);    uip_sethostaddr(&hostaddr);    uip_setnetmask(&netmask);    uip_over_mesh_set_net(&hostaddr, &netmask);    uip_over_mesh_set_gateway_netif(&slipif);    uip_fw_default(&meshif);    uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);    rs232_set_input(slip_input_byte);    printf("IPv4 address: %d.%d.%d.%d/n", uip_ipaddr_to_quad(&hostaddr));  }#endif /* WITH_UIP */#if WITH_UIP6  /* IPv6 CONFIGURATION */  {    int i;    uint8_t addr[sizeof(uip_lladdr.addr)];    for(i = 0; i < sizeof(uip_lladdr.addr); i += 2) {      addr[i + 1] = node_id & 0xff;      addr[i + 0] = node_id >> 8;    }    linkaddr_copy((linkaddr_t *)addr, &linkaddr_node_addr);    memcpy(&uip_lladdr.addr, addr, sizeof(uip_lladdr.addr));    process_start(&tcpip_process, NULL);    printf("Tentative link-local IPv6 address ");    {      uip_ds6_addr_t *lladdr;      int i;      lladdr = uip_ds6_get_link_local(-1);      for(i = 0; i < 7; ++i) {	printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],	       lladdr->ipaddr.u8[i * 2 + 1]);      }      printf("%02x%02x/n", lladdr->ipaddr.u8[14],	     lladdr->ipaddr.u8[15]);    }//.........这里部分代码省略.........
开发者ID:200018171,项目名称:contiki,代码行数:101,


示例19: init_net

voidinit_net(void){  /* Start radio and radio receive process */  NETSTACK_RADIO.init();  /* Set addresses BEFORE starting tcpip process */  set_rime_addr();  /* Setup nullmac-like MAC for 802.15.4 */  /* sicslowpan_init(sicslowmac_init(&cc2420_driver)); */  /* printf(" %s channel %u/n", sicslowmac_driver.name, RF_CHANNEL); */  /* Setup X-MAC for 802.15.4 */  queuebuf_init();  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  PRINTA("%s %s, channel %u , check rate %u Hz tx power %u/n", NETSTACK_MAC.name, NETSTACK_RDC.name, rf2xx_get_channel(),      CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 : NETSTACK_RDC.channel_check_interval()),      rf2xx_get_txpower());#if UIP_CONF_IPV6_RPL  PRINTA("RPL Enabled/n");#endif#if UIP_CONF_ROUTER  PRINTA("Routing Enabled/n");#endif  process_start(&tcpip_process, NULL);#if ANNOUNCE_BOOT && UIP_CONF_IPV6  PRINTA("Tentative link-local IPv6 address ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      PRINTA("%02x%02x:", lladdr->ipaddr.u8[i * 2],          lladdr->ipaddr.u8[i * 2 + 1]);    }    PRINTA("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }  if(!UIP_CONF_IPV6_RPL) {    uip_ipaddr_t ipaddr;    int i;    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_TENTATIVE);    PRINTA("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      PRINTA("%02x%02x:",          ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    PRINTA("%02x%02x/n",        ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  }#endif /* ANNOUNCE_BOOT */#if WITH_UIP  uip_ipaddr_t hostaddr, netmask;  uip_init();  uip_fw_init();  process_start(&tcpip_process, NULL);  process_start(&slip_process, NULL);  process_start(&uip_fw_process, NULL);  slip_set_input_callback(set_gateway);  /* Construct ip address from four bytes. */  uip_ipaddr(&hostaddr, 172, 16, rimeaddr_node_addr.u8[0],      rimeaddr_node_addr.u8[1]);  /* Construct netmask from four bytes. */  uip_ipaddr(&netmask, 255,255,0,0);  uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);  /* Set the IP address for this host. */  uip_sethostaddr(&hostaddr);  /* Set the netmask for this host. */  uip_setnetmask(&netmask);  uip_over_mesh_set_net(&hostaddr, &netmask);  /* Register slip interface with forwarding module. */  //uip_fw_register(&slipif);  uip_over_mesh_set_gateway_netif(&slipif);  /* Set slip interface to be a default forwarding interface . */  uip_fw_default(&meshif);  uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);  PRINTA(PSTR("uIP started with IP address %d.%d.%d.%d/n"),      uip_ipaddr_to_quad(&hostaddr));#endif /* WITH_UIP */}
开发者ID:scarecrowli,项目名称:contiki-plus-old,代码行数:96,


示例20: init_net

/*---------------------------------------------------------------------------*/voidinit_net(void){#ifndef WITH_SLIP  uint8_t i;  id.u32[0] = djb2_hash((const uint8_t *)&(SIM->UIDH), 8); /* Use SIM_UIDH, SIM_UIDMH for first half */  id.u32[1] = djb2_hash((const uint8_t *)&(SIM->UIDML), 8); /* Use SIM_UIDML, SIM_UIDL for second half */  id.u8[0] |= 0x02; /* Set the Local/Universal bit to Local */#else  /* Use fixed address for border router. */  id.u32[0] = 0x00000000;  id.u32[1] = 0x00000000;  id.u8[0] = 0x02;  id.u8[7] = 0x01;#endif#if NETSTACK_CONF_WITH_IPV6  set_rime_addr();  NETSTACK_RADIO.init();  {    uint8_t longaddr[8];    uint16_t shortaddr;    shortaddr = (linkaddr_node_addr.u8[0] << 8) +      linkaddr_node_addr.u8[1];    memset(longaddr, 0, sizeof(longaddr));    linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr);    rf230_set_pan_addr(IEEE802154_CONF_PANID, shortaddr, longaddr);  }  rf230_set_channel(RF_CHANNEL);  memcpy(&uip_lladdr.addr, id.u8, sizeof(uip_lladdr.addr));  queuebuf_init();  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  PRINTF("%s %s, channel check rate %d Hz, radio channel %d/n",         NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 :                         NETSTACK_RDC.channel_check_interval()),         RF_CHANNEL);  process_start(&tcpip_process, NULL);  PRINTF("Tentative link-local IPv6 address ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      PRINTF("%04x:", lladdr->ipaddr.u8[i * 2] * 256 +             lladdr->ipaddr.u8[i * 2 + 1]);    }    PRINTF("%04x/n", lladdr->ipaddr.u8[14] * 256 + lladdr->ipaddr.u8[15]);  }  if(!UIP_CONF_IPV6_RPL) {    uip_ipaddr_t ipaddr;    int i;    uip_ip6addr(&ipaddr, 0xfdfd, 0, 0, 0, 0, 0, 0, 0);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);    uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);    PRINTF("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      PRINTF("%04x:",             ipaddr.u8[i * 2] * 256 + ipaddr.u8[i * 2 + 1]);    }    PRINTF("%04x/n",           ipaddr.u8[7 * 2] * 256 + ipaddr.u8[7 * 2 + 1]);  }#else /* If no radio stack should be used only turn on radio and set it to sleep for minimal power consumption */  rf230_init();  rf230_driver.off();#endif /* NETSTACK_CONF_WITH_IPV6 */}
开发者ID:punyal,项目名称:Contiki_3-IPsec,代码行数:78,


示例21: main

intmain(int argc, char *argv[]){  node_id_restore();  /* init system: clocks, board etc */  system_init();  sio2host_init();  leds_init();  leds_on(LEDS_ALL);  system_interrupt_enable_global();  flash_init();  delay_init();  /* Initialize Contiki and our processes. */    #ifdef LOW_POWER_MODE  configure_tc3();  #else  clock_init();  #endif  process_init();  ctimer_init();  rtimer_init();  process_start(&etimer_process, NULL);    /* Set MAC address and node ID */#ifdef NODEID  node_id = NODEID;#ifdef BURN_NODEID  node_id_burn(node_id);#endif /* BURN_NODEID */#else/* NODE_ID */#endif /* NODE_ID */  printf("/r/n/n/n/n Starting the SmartConnect-6LoWPAN /r/n Platform : Atmel IoT device /r/n");  print_reset_causes();  netstack_init(); #if BOARD == SAMR21_XPLAINED_PRO  eui64 = edbg_eui_read_eui64();  SetIEEEAddr(eui64);#else  SetIEEEAddr(node_mac);  #endif   set_link_addr();    rf_set_channel(RF_CHANNEL);  printf("/r/n Configured RF channel: %d/r/n", rf_get_channel());  leds_off(LEDS_ALL);  process_start(&sensors_process, NULL);  energest_init();  ENERGEST_ON(ENERGEST_TYPE_CPU);  if(node_id > 0) {    printf(" Node id %u./r/n", node_id);  } else {    printf(" Node id not set./r/n");  }  /* Setup nullmac-like MAC for 802.15.4 */#if SAMD  memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));#else   memcpy(&uip_lladdr.addr, eui64, sizeof(uip_lladdr.addr));#endif     queuebuf_init();  printf(" %s %lu %d/r/n",         NETSTACK_RDC.name,         (uint32_t) (CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:                         NETSTACK_RDC.channel_check_interval())),         RF_CHANNEL);  process_start(&tcpip_process, NULL);  printf(" IPv6 Address: ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/r/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }  {    uip_ipaddr_t ipaddr;    int i;    uip_ip6addr(&ipaddr, 0xfc00, 0, 0, 0, 0, 0, 0, 0);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);    uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);    printf("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      printf("%02x%02x:",             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/r/n",           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);//.........这里部分代码省略.........
开发者ID:songjw0820,项目名称:contiki_atmel,代码行数:101,


示例22: main

//.........这里部分代码省略.........  if(node_id) {    PRINTF("Node id is set to %u./n", node_id);  } else {    PRINTF("Node id not set/n");  }#if NETSTACK_CONF_WITH_IPV6  memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));  /* Setup nullmac-like MAC for 802.15.4 *//*   sicslowpan_init(sicslowmac_init(&cc2420_driver)); *//*   printf(" %s channel %u/n", sicslowmac_driver.name, CC2420_CONF_CHANNEL); */  /* Setup X-MAC for 802.15.4 */  queuebuf_init();	netstack_init();//  NETSTACK_RDC.init();//  NETSTACK_MAC.init();//  NETSTACK_LLSEC.init();//  NETSTACK_NETWORK.init();  printf("%s %s %s, channel check rate %lu Hz, radio channel %u/n",         NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 :                         NETSTACK_RDC.channel_check_interval()),         CC2420_CONF_CHANNEL);  process_start(&tcpip_process, NULL);  printf("Tentative link-local IPv6 address ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }  if(!UIP_CONF_IPV6_RPL) {    uip_ipaddr_t ipaddr;    int i;    uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);    uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);    printf("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      printf("%02x%02x:",             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n",           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  }#else /* NETSTACK_CONF_WITH_IPV6 */	netstack_init();  //NETSTACK_RDC.init();  //NETSTACK_MAC.init();  //NETSTACK_LLSEC.init();  //NETSTACK_NETWORK.init();  printf("%s %s %s, channel check rate %lu Hz, radio channel %u/n",         NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
开发者ID:mlwymore,项目名称:contiki,代码行数:67,


示例23: main

intmain(int argc, char **argv){#if UIP_CONF_IPV6#if UIP_CONF_IPV6_RPL  printf(CONTIKI_VERSION_STRING " started with IPV6, RPL/n");#else  printf(CONTIKI_VERSION_STRING " started with IPV6/n");#endif#else  printf(CONTIKI_VERSION_STRING " started/n");#endif  /* crappy way of remembering and accessing argc/v */  contiki_argc = argc;  contiki_argv = argv;  /* native under windows is hardcoded to use the first one or two args */  /* for wpcap configuration so this needs to be "removed" from         */  /* contiki_args (used by the native-border-router) */#ifdef __CYGWIN__  contiki_argc--;  contiki_argv++;#ifdef UIP_FALLBACK_INTERFACE  contiki_argc--;  contiki_argv++;#endif#endif  process_init();  process_start(&etimer_process, NULL);  ctimer_init();  set_rime_addr();  queuebuf_init();  netstack_init();  printf("MAC %s RDC %s NETWORK %s/n", NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name);#if WITH_UIP6  memcpy(&uip_lladdr.addr, serial_id, sizeof(uip_lladdr.addr));  process_start(&tcpip_process, NULL);#ifdef __CYGWIN__  process_start(&wpcap_process, NULL);#endif  printf("Tentative link-local IPv6 address ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    /* make it hardcoded... */    lladdr->state = ADDR_AUTOCONF;    printf("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }#else  process_start(&tcpip_process, NULL);#endif  serial_line_init();    autostart_start(autostart_processes);    /* Make standard output unbuffered. */  setvbuf(stdout, (char *)NULL, _IONBF, 0);  select_set_callback(STDIN_FILENO, &stdin_fd);  simple_rpl_init();  ip64_init();  while(1) {    fd_set fdr;    fd_set fdw;    int maxfd;    int i;    int retval;    struct timeval tv;    retval = process_run();    tv.tv_sec = 0;    tv.tv_usec = retval ? 1 : 1000;    FD_ZERO(&fdr);    FD_ZERO(&fdw);    maxfd = 0;    for(i = 0; i <= select_max; i++) {      if(select_callback[i] != NULL && select_callback[i]->set_fd(&fdr, &fdw)) {        maxfd = i;      }    }    retval = select(maxfd + 1, &fdr, &fdw, NULL, &tv);//.........这里部分代码省略.........
开发者ID:ADVANSEE,项目名称:mist,代码行数:101,


示例24: cetic_6lbr_init

/*---------------------------------------------------------------------------*/voidcetic_6lbr_init(void){  uip_ds6_addr_t *local = uip_ds6_get_link_local(-1);  uip_ipaddr_copy(&wsn_ip_local_addr, &local->ipaddr);  LOG6LBR_6ADDR(INFO, &wsn_ip_local_addr, "Tentative local IPv6 address ");  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 CETIC_6LBR_SMARTBRIDGE  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));    wsn_net_prefix_len = nvm_data.wsn_net_prefix_len;    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);    }    LOG6LBR_6ADDR(INFO, &wsn_ip_addr, "Tentative global IPv6 address ");    memcpy(eth_dft_router.u8, &nvm_data.eth_dft_router,           sizeof(nvm_data.eth_dft_router));    if ( !uip_is_addr_unspecified(&eth_dft_router) ) {      uip_ds6_defrt_add(&eth_dft_router, 0);    }    uip_ipaddr_t dns;    memcpy(dns.u8, &nvm_data.dns_server,           sizeof(nvm_data.dns_server));    uip_nameserver_update(&dns, UIP_NAMESERVER_INFINITE_LIFETIME);  } else {                            //End manual configuration    uip_create_unspecified(&wsn_net_prefix);    wsn_net_prefix_len = 0;    uip_create_unspecified(&wsn_ip_addr);  }#endif#if CETIC_6LBR_ROUTER  //WSN network configuration  memcpy(wsn_net_prefix.u8, &nvm_data.wsn_net_prefix,         sizeof(nvm_data.wsn_net_prefix));  wsn_net_prefix_len = nvm_data.wsn_net_prefix_len;  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);  }  LOG6LBR_6ADDR(INFO, &wsn_ip_addr, "Tentative global IPv6 address (WSN) ");  uip_ipaddr_t dns;  memcpy(dns.u8, &nvm_data.dns_server,         sizeof(nvm_data.dns_server));  uip_nameserver_update(&dns, UIP_NAMESERVER_INFINITE_LIFETIME);  //Ethernet network configuration  memcpy(eth_net_prefix.u8, &nvm_data.eth_net_prefix,         sizeof(nvm_data.eth_net_prefix));  memcpy(eth_dft_router.u8, &nvm_data.eth_dft_router,         sizeof(nvm_data.eth_dft_router));  if ( !uip_is_addr_unspecified(&eth_dft_router) ) {    uip_ds6_defrt_add(&eth_dft_router, 0);  }  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);//.........这里部分代码省略.........
开发者ID:kamejoko80,项目名称:6lbr,代码行数:101,


示例25: contiki_init

/*---------------------------------------------------------------------------*/voidcontiki_init(void){  int i;  uint8_t addr[sizeof(uip_lladdr.addr)];  uip_ipaddr_t ipaddr;  uip_ds6_addr_t *lladdr;  uip_ip4addr_t ipv4addr, netmask;  /* Start process handler */  process_init();  /* Start Contiki processes */  process_start(&etimer_process, NULL);  process_start(&sensors_process, NULL);  ctimer_init();  /* Print startup information */  printf(CONTIKI_VERSION_STRING " started. ");  if(node_id > 0) {    printf("Node id is set to %u./n", node_id);  } else {    printf("Node id is not set./n");  }  set_mac_addr();  queuebuf_init();  /* Initialize communication stack */  netstack_init();  printf("%s/%s/%s, channel check rate %lu Hz/n",         NETSTACK_NETWORK.name, NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:                         NETSTACK_RDC.channel_check_interval()));  /* IPv6 CONFIGURATION */  for(i = 0; i < sizeof(uip_lladdr.addr); i += 2) {    addr[i + 1] = node_id & 0xff;    addr[i + 0] = node_id >> 8;  }  linkaddr_copy(addr, &linkaddr_node_addr);  memcpy(&uip_lladdr.addr, addr, sizeof(uip_lladdr.addr));  process_start(&tcpip_process, NULL);  printf("Tentative link-local IPv6 address ");  lladdr = uip_ds6_get_link_local(-1);  for(i = 0; i < 7; ++i) {    printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],           lladdr->ipaddr.u8[i * 2 + 1]);  }  printf("%02x%02x/n", lladdr->ipaddr.u8[14],         lladdr->ipaddr.u8[15]);  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_TENTATIVE);  printf("Tentative global IPv6 address ");  for(i = 0; i < 7; ++i) {    printf("%02x%02x:",           ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);  }  printf("%02x%02x/n",         ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  /* Start serial process */  serial_line_init();  /* Start autostart processes (defined in Contiki application) */  print_processes(autostart_processes);  autostart_start(autostart_processes);  /* Start the SLIP */  printf("Initiating SLIP with IP address is 172.16.0.2./n");  uip_ipaddr(&ipv4addr, 172, 16, 0, 2);  uip_ipaddr(&netmask, 255, 255, 255, 0);  ip64_set_ipv4_address(&ipv4addr, &netmask);  rs232_set_input(slip_input_byte);  log_set_putchar_with_slip(1);  uip_ip4addr_t ip4addr;  uip_ip6addr_t ip6addr;  uip_ipaddr(&ip4addr, 8,8,8,8);  ip64_addr_4to6(&ip4addr, &ip6addr);  uip_nameserver_update((uip_ipaddr_t *)&ip6addr, UIP_NAMESERVER_INFINITE_LIFETIME);}
开发者ID:Babody,项目名称:contiki,代码行数:95,


示例26: init_net

/*---------------------------------------------------------------------------*/voidinit_net(uint8_t node_id){  uint16_t shortaddr;  uint64_t longaddr;  linkaddr_t addr;#if WITH_UIP6  uip_ds6_addr_t *lladdr;  uip_ipaddr_t ipaddr;#endif  uint8_t i;  memset(&shortaddr, 0, sizeof(shortaddr));  memset(&longaddr, 0, sizeof(longaddr));  *((uint8_t *)&shortaddr) = node_id >> 8;  *((uint8_t *)&shortaddr + 1) = node_id;  *((uint8_t *)&longaddr) = node_id >> 8;  *((uint8_t *)&longaddr + 1) = node_id;  for(i = 2; i < sizeof(longaddr); ++i) {    ((uint8_t *)&longaddr)[i] = random_rand();  }  PRINTF("SHORT MAC ADDRESS %02x:%02x/n",         *((uint8_t *) & shortaddr), *((uint8_t *) & shortaddr + 1));  PRINTF("EXTENDED MAC ADDRESS %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x/n",         *((uint8_t *)&longaddr),         *((uint8_t *)&longaddr + 1),         *((uint8_t *)&longaddr + 2),         *((uint8_t *)&longaddr + 3),         *((uint8_t *)&longaddr + 4),         *((uint8_t *)&longaddr + 5),         *((uint8_t *)&longaddr + 6),         *((uint8_t *)&longaddr + 7));  memset(&addr, 0, sizeof(linkaddr_t));  for(i = 0; i < sizeof(addr.u8); ++i) {    addr.u8[i] = ((uint8_t *)&longaddr)[i];  }  linkaddr_set_node_addr(&addr);  PRINTF("Rime started with address: ");  for(i = 0; i < sizeof(addr.u8) - 1; ++i) {    PRINTF("%d.", addr.u8[i]);  }  PRINTF("%d/n", addr.u8[i]);  queuebuf_init();  NETSTACK_RADIO.init();  mrf24j40_set_channel(RF_CHANNEL);  mrf24j40_set_panid(IEEE802154_PANID);  mrf24j40_set_short_mac_addr(shortaddr);  mrf24j40_set_extended_mac_addr(longaddr);  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  PRINTF("%s %s, channel check rate %d Hz, radio channel %u/n",         NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 :                         NETSTACK_RDC.channel_check_interval()), RF_CHANNEL);#if WITH_UIP6#if LINKADDR_CONF_SIZE == 2  memset(&uip_lladdr.addr, 0, sizeof(uip_lladdr.addr));  uip_lladdr.addr[3] = 0xff;  uip_lladdr.addr[4]= 0xfe;  memcpy(&uip_lladdr.addr[6], &shortaddr, sizeof(shortaddr));#else  memcpy(&uip_lladdr.addr, &longaddr, sizeof(uip_lladdr.addr));#endif  process_start(&tcpip_process, NULL);  lladdr = uip_ds6_get_link_local(-1);  PRINTF("Tentative link-local IPv6 address ");  for(i = 0; i < 7; ++i) {    PRINTF("%02x%02x:", lladdr->ipaddr.u8[i * 2], lladdr->ipaddr.u8[i * 2 + 1]);  }  PRINTF("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  if(!UIP_CONF_IPV6_RPL) {    uip_ip6addr(&ipaddr, 0x2001, 0x1418, 0x100, 0x823c, 0, 0, 0, 0);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);    uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);    PRINTF("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {//.........这里部分代码省略.........
开发者ID:200018171,项目名称:contiki,代码行数:101,


示例27: main

/*---------------------------------------------------------------------------*/intmain(void){    /*   * Initalize hardware.   */  halInit();  clock_init();    uart1_init(115200);    /* Led initialization */  leds_init();      INTERRUPTS_ON();   PRINTF("/r/nStarting ");  PRINTF(CONTIKI_VERSION_STRING);  PRINTF(" on %s/r/n", boardDescription->name);   boardPrintStringDescription();  PRINTF("/r/n");   /*   * Initialize Contiki and our processes.   */    process_init();  #if WITH_SERIAL_LINE_INPUT  uart1_set_input(serial_line_input_byte);  serial_line_init();#endif  /* rtimer and ctimer should be initialized before radio duty cycling     layers */  rtimer_init();  /* etimer_process should be initialized before ctimer */  process_start(&etimer_process, NULL);    ctimer_init();  netstack_init();  set_rime_addr();  printf("%s %s, channel check rate %lu Hz/n",         NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:                                  NETSTACK_RDC.channel_check_interval()));  printf("802.15.4 PAN ID 0x%x, EUI-%d:",      IEEE802154_CONF_PANID, UIP_CONF_LL_802154?64:16);  uip_debug_lladdr_print(&linkaddr_node_addr);  printf(", radio channel %u/n", RF_CHANNEL);  procinit_init();  energest_init();  ENERGEST_ON(ENERGEST_TYPE_CPU);  /* Set the Clear Channel Assessment (CCA) threshold of the     radio. The CCA threshold is used both for sending packets and for     waking up ContikiMAC nodes. If the CCA threshold is too high,     ContikiMAC will not wake up from neighbor transmissions. If the     CCA threshold is too low, transmissions will be too restrictive     and no packets will be sent. DEFAULT_RADIO_CCA_THRESHOLD is     defined in this file. */  ST_RadioSetEdCcaThreshold(DEFAULT_RADIO_CCA_THRESHOLD);    autostart_start(autostart_processes);#if UIP_CONF_IPV6  printf("Tentative link-local IPv6 address ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }  if(!UIP_CONF_IPV6_RPL) {    uip_ipaddr_t ipaddr;    int i;    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_TENTATIVE);    printf("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      printf("%02x%02x:",             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n",           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  }#endif /* UIP_CONF_IPV6 */  //.........这里部分代码省略.........
开发者ID:200018171,项目名称:contiki,代码行数:101,


示例28: main

//.........这里部分代码省略.........  if(node_id > 0) {    printf("Node id is set to %u./n", node_id);  } else {    printf("Node id is not set./n");  }#if WITH_UIP6  /* memcpy(&uip_lladdr.addr, ds2411_id, sizeof(uip_lladdr.addr)); */  memcpy(&uip_lladdr.addr, rimeaddr_node_addr.u8,         UIP_LLADDR_LEN > RIMEADDR_SIZE ? RIMEADDR_SIZE : UIP_LLADDR_LEN);  /* Setup nullmac-like MAC for 802.15.4 *//*   sicslowpan_init(sicslowmac_init(&cc2520_driver)); *//*   printf(" %s channel %u/n", sicslowmac_driver.name, RF_CHANNEL); */  /* Setup X-MAC for 802.15.4 */  queuebuf_init();  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  printf("%s %s, channel check rate %lu Hz, radio channel %u/n",         NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:                         NETSTACK_RDC.channel_check_interval()),         RF_CHANNEL);  process_start(&tcpip_process, NULL);  printf("Tentative link-local IPv6 address ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }  if(!UIP_CONF_IPV6_RPL) {    uip_ipaddr_t ipaddr;    int i;    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_TENTATIVE);    printf("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      printf("%02x%02x:",             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n",           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  }#else /* WITH_UIP6 */  NETSTACK_RDC.init();  NETSTACK_MAC.init();  NETSTACK_NETWORK.init();  printf("%s %s, channel check rate %lu Hz, radio channel %u/n",         NETSTACK_MAC.name, NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:                         NETSTACK_RDC.channel_check_interval()),
开发者ID:1uk3,项目名称:contiki,代码行数:67,


示例29: main

//.........这里部分代码省略.........#endif /* CONFIGURE_CC2420 || CONFIGURE_CC2520 */  NETSTACK_RADIO.on();  leds_off(LEDS_ALL);  if(node_id > 0) {    PRINTF("Node id %u./n", node_id);  } else {    PRINTF("Node id not set./n");  }#if WITH_UIP6  memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));  /* Setup nullmac-like MAC for 802.15.4 */  queuebuf_init();  netstack_init();  printf("%s/%s %lu %u/n",         NETSTACK_RDC.name,         NETSTACK_MAC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:                         NETSTACK_RDC.channel_check_interval()),         RF_CHANNEL);  process_start(&tcpip_process, NULL);  printf("IPv6 ");  {    uip_ds6_addr_t *lladdr;    int i;    lladdr = uip_ds6_get_link_local(-1);    for(i = 0; i < 7; ++i) {      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],             lladdr->ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);  }  if(1) {    uip_ipaddr_t ipaddr;    int i;    uip_ip6addr(&ipaddr, 0xfc00, 0, 0, 0, 0, 0, 0, 0);    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);    uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);    printf("Tentative global IPv6 address ");    for(i = 0; i < 7; ++i) {      printf("%02x%02x:",             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);    }    printf("%02x%02x/n",           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);  }#else /* WITH_UIP6 */  netstack_init();  printf("%s %lu %u/n",         NETSTACK_RDC.name,         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:                         NETSTACK_RDC.channel_check_interval()),         RF_CHANNEL);#endif /* WITH_UIP6 */
开发者ID:ADVANSEE,项目名称:mist,代码行数:67,



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


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