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

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

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

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

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

示例1: handle_incoming_rerr

/*---------------------------------------------------------------------------*/static voidhandle_incoming_rerr(void){  struct uaodv_msg_rerr *rm = (struct uaodv_msg_rerr *)uip_appdata;  struct uaodv_rt_entry *rt;  print_debug("RERR %d.%d.%d.%d -> %d.%d.%d.%d"	      " unreach=%d.%d.%d.%d seq=%lu/n",	      uip_ipaddr_to_quad(&BUF->srcipaddr),	      uip_ipaddr_to_quad(&BUF->destipaddr),	      uip_ipaddr_to_quad((uip_ipaddr_t *)&rm->unreach[0]),	      uip_ntohl(rm->unreach[0].seqno));  if(uip_ipaddr_cmp(&rm->unreach[0].addr, &uip_hostaddr))    return;  rt = uaodv_rt_lookup_any(&rm->unreach[0].addr);  if(rt != NULL && uip_ipaddr_cmp(&rt->nexthop, uip_udp_sender())) {    if((rm->flags & UAODV_RERR_UNKNOWN) || rm->unreach[0].seqno == 0       || SCMP32(rt->hseqno, uip_ntohl(rm->unreach[0].seqno)) <= 0) {      rt->is_bad = 1;      if(rm->flags & UAODV_RERR_UNKNOWN) {	rm->flags &= ~UAODV_RERR_UNKNOWN;	rm->unreach[0].seqno = uip_htonl(rt->hseqno);      }      print_debug("RERR rebroadcast/n");      uip_udp_packet_send(bcastconn, rm, sizeof(struct uaodv_msg_rerr));    }  }}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:31,


示例2: send_rreq

static voidsend_rreq(uip_ipaddr_t *addr){  struct uaodv_msg_rreq *rm = (struct uaodv_msg_rreq *)uip_appdata;  int len;  print_debug("send RREQ for %d.%d.%d.%d/n", uip_ipaddr_to_quad(addr));  rm->type = UAODV_RREQ_TYPE;  rm->dest_seqno = last_known_seqno(addr);  if(rm->dest_seqno == 0)    rm->flags = UAODV_RREQ_UNKSEQNO;  else    rm->flags = 0;  rm->reserved = 0;  rm->hop_count = 0;  rm->rreq_id = uip_htonl(rreq_id++);  uip_ipaddr_copy(&rm->dest_addr, addr);  uip_gethostaddr(&rm->orig_addr);  my_hseqno++;			/* Always */  rm->orig_seqno = uip_htonl(my_hseqno);  bcastconn->ttl = MY_NET_DIAMETER;  len = sizeof(struct uaodv_msg_rreq);  len += add_rreq_extensions(rm + 1);  uip_udp_packet_send(bcastconn, rm, len);}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:26,


示例3: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(server_process, ev, data){  PROCESS_BEGIN();  u16_t hostport = 7777;  printf("TCP listen on %d.%d.%d.%d:%u/n",     uip_ipaddr_to_quad(&uip_hostaddr), hostport);  tcp_listen(uip_htons(hostport));  while(1) {    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);    if (uip_connected()) {      printf("server: client arrived!/n");      connected = 1;      while (!(uip_aborted() || uip_closed() || uip_timedout())) {        PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);      }      if (uip_aborted() || uip_closed()) {        connected = 0;      }    } else {      printf("server: client not accepted!/n");      KLEENET_ASSERT(0 && "server: client not accepted!/n");    }  }  PROCESS_END();}
开发者ID:kincki,项目名称:contiki,代码行数:31,


示例4: add_rreq_extensions

static unsignedadd_rreq_extensions(void *_p){  struct uaodv_bad_hop_ext *p = _p;  uip_ipaddr_t *a = p->addrs;  unsigned i, n;#define SCALE_RETRANS_THRESHOLD (3*4)  cc2420_check_remote(0xffff); /* Age table. */  n = 0;  for (i = 0; i < NNEIGBOURS; i++) {    if (neigbours[i].nretrans >= SCALE_RETRANS_THRESHOLD	&& neigbours[i].mac != 0xffff) {      a->u16[0] = uip_hostaddr.u16[0];      a->u16[1] = neigbours[i].mac;      n++;      if(n == 15)	break;			/* Avoid buffer overrun */      print_debug("BAD HOP %d.%d.%d.%d/t%d/n",		  uip_ipaddr_to_quad(a), neigbours[i].nretrans);    }  }  if(n == 0)    return 0;  p->type = RREQ_BAD_HOP_EXT;  p->length = 2 + 4*n;		/* Two unused bytes + addresses */  return 2 + p->length;		/* Type + len + extension data */}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:31,


示例5: PROCESS_THREAD

/*---------------------------------------------------------------------*/PROCESS_THREAD(test_uaodv_process, ev, data){  static uip_ipaddr_t addr;  PROCESS_BEGIN();  printf("uIP uAODV test process started/n");  uip_ipaddr(&addr, 0,0,0,0);  in_conn = udp_new(&addr, UIP_HTONS(0), NULL);  uip_udp_bind(in_conn, UIP_HTONS(COOJA_PORT));  uip_ipaddr(&addr, 10,10,10,4);  out_conn = udp_new(&addr, UIP_HTONS(COOJA_PORT), NULL);  button_sensor.configure(SENSORS_ACTIVE, 1);  while(1) {    PROCESS_WAIT_EVENT();    if(ev == sensors_event && data == &button_sensor) {      struct uaodv_rt_entry *route;      uip_ipaddr(&addr, 10,10,10,4);      route = uaodv_rt_lookup_any(&addr);      if (route == NULL || route->is_bad) {        printf("%d.%d.%d.%d: lookup %d.%d.%d.%d/n", uip_ipaddr_to_quad(&uip_hostaddr), uip_ipaddr_to_quad(&addr));        uaodv_request_route_to(&addr);      } else {        printf("%d.%d.%d.%d: send to %d.%d.%d.%d/n", uip_ipaddr_to_quad(&uip_hostaddr), uip_ipaddr_to_quad(&addr));        tcpip_poll_udp(out_conn);        PROCESS_WAIT_UNTIL(ev == tcpip_event && uip_poll());        uip_send("cooyah COOJA", 12);      }    }    if(ev == tcpip_event && uip_newdata()) {      ((char*) uip_appdata)[uip_datalen()] = 0;      printf("data received from %d.%d.%d.%d: %s/n",          uip_ipaddr_to_quad(&((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])->srcipaddr),          (char *)uip_appdata);      leds_toggle(LEDS_ALL);    }  }  PROCESS_END();}
开发者ID:Ammar-85,项目名称:contiki-arduino,代码行数:48,


示例6: network_handler

void network_handler(ev, data){	char buf[UIP_BUFSIZE]; // packet data buffer	unsigned short cmd;    // 	DataPayload *dp;	ChannelState *state = NULL;	uint16_t len = uip_datalen();	PRINTF("ipaddr=%d.%d.%d.%d/n", uip_ipaddr_to_quad(&(UDP_HDR->srcipaddr)));	PRINTF("Packet is %d bytes long/n",len);	memcpy(buf, uip_appdata, len);	buf[len] = '/0';	dp = (DataPayload *)buf;	PRINTF("Data is   %d bytes long/n",uip_ntohs(dp->dhdr.tlen));	cmd = dp->hdr.cmd;        // only a byte so no reordering :)	PRINTF("Received a %s command./n", cmdnames[cmd]);	PRINTF("Message for channel %d/n",dp->hdr.dst_chan_num);	if (dp->hdr.dst_chan_num == HOMECHANNEL || cmd == DISCONNECT){		if (cmd == QACK){			state = &home_channel_state;			copy_link_address(state);  		}  		else if (cmd == DISCONNECT){  			state = get_channel_state(dp->hdr.dst_chan_num);			if (state){				remove_channel(state->chan_num);			}			state = &home_channel_state;			copy_link_address(state);  		}  	}	else{				state = get_channel_state(dp->hdr.dst_chan_num);		if (state == NULL){			PRINTF("Channel %d doesn't exist/n", dp->hdr.dst_chan_num);			return;		}		if (check_seqno(state, dp) == 0) {			printf("OH NOES/n");			return;		}else { //CHECK IF RIGHT CONNECTION			//copy_link_address(state);		}	}		// Received a message so reset pingOUT	state->pingOUT = 0;	if      (cmd == QUERY)    PRINTF("I'm a controller, Ignoring QUERY/n");	else if (cmd == CONNECT)  PRINTF("I'm a controller, Ignoring CONNECT/n");	else if (cmd == QACK)     qack_handler(state, dp);	else if (cmd == CACK)     cack_handler(state, dp);	else if (cmd == RESPONSE) response_handler(state, dp);	else if (cmd == CMDACK)   command_ack_handler(state,dp);	else if (cmd == PING)     ping_handler(state, dp);	else if (cmd == PACK)     pack_handler(state, dp);	else if (cmd == DISCONNECT) close_handler(state,dp);}
开发者ID:fergul,项目名称:KNoT,代码行数:59,


示例7: SCMP32

/* Compare sequence numbers as per RFC 3561. */#define SCMP32(a, b) ((int32_t)((a) - (b)))static CC_INLINE uint32_tlast_known_seqno(uip_ipaddr_t *host){  struct uaodv_rt_entry *route = uaodv_rt_lookup_any(host);  if(route != NULL)    return uip_htonl(route->hseqno);  return 0;}static uint32_t rreq_id, my_hseqno;	/* In host byte order! */#define NFWCACHE 16static struct {  uip_ipaddr_t orig;  uint32_t id;} fwcache[NFWCACHE];static CC_INLINE intfwc_lookup(const uip_ipaddr_t *orig, const uint32_t *id){  unsigned n = (orig->u8[2] + orig->u8[3]) % NFWCACHE;  return fwcache[n].id == *id && uip_ipaddr_cmp(&fwcache[n].orig, orig);}static CC_INLINE voidfwc_add(const uip_ipaddr_t *orig, const uint32_t *id){  unsigned n = (orig->u8[2] + orig->u8[3]) % NFWCACHE;  fwcache[n].id = *id;  uip_ipaddr_copy(&fwcache[n].orig, orig);}#ifdef NDEBUG#define PRINTF(...) do {} while (0)#define print_debug(...) do{}while(0)#else#define PRINTF(...) printf(__VA_ARGS__)#ifdef __GNUC__static voidprint_debug(const char *fmt, ...) __attribute__((format(printf, 1, 2)));#endif /* __GNUC__ */static voidprint_debug(const char *fmt, ...){  va_list ap;  va_start(ap, fmt);  printf("%d.%d.%d.%d: ", uip_ipaddr_to_quad(&uip_hostaddr));  vprintf(fmt, ap);  va_end(ap);  return;}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:59,


示例8: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(shell_id_process, ev, data){  char buf[40];  PROCESS_BEGIN();  snprintf(buf, sizeof(buf), "%d.%d.%d.%d", uip_ipaddr_to_quad(&uip_hostaddr));  shell_output_str(&id_command, "IP address: ", buf);  snprintf(buf, sizeof(buf), "%d.%d",	   rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);  shell_output_str(&id_command, "Rime address: ", buf);  PROCESS_END();}
开发者ID:1uk3,项目名称:contiki,代码行数:12,


示例9: set_gateway

static voidset_gateway(void){  if(!is_gateway) {    printf("%d.%d: making myself the IP network gateway./n/n",       linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1]);    printf("IPv4 address of the gateway: %d.%d.%d.%d/n/n",       uip_ipaddr_to_quad(&uip_hostaddr));    uip_over_mesh_set_gateway(&linkaddr_node_addr);    uip_over_mesh_make_announced_gateway();    is_gateway = 1;  }}
开发者ID:200018171,项目名称:contiki,代码行数:13,


示例10: set_gateway

static voidset_gateway(void){  if(!is_gateway) {    leds_on(LEDS_RED);    PRINTF("%d.%d: making myself the IP network gateway./n/n",	   rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);    PRINTF("IPv4 address of the gateway: %d.%d.%d.%d/n/n",	   uip_ipaddr_to_quad(&uip_hostaddr));    uip_over_mesh_set_gateway(&rimeaddr_node_addr);    uip_over_mesh_make_announced_gateway();    is_gateway = 1;  }}
开发者ID:atiselsts,项目名称:contiki-optimized,代码行数:14,


示例11: send_rerr

/*---------------------------------------------------------------------------*/static voidsend_rerr(uip_ipaddr_t *addr, uint32_t *seqno){  struct uaodv_msg_rerr *rm = (struct uaodv_msg_rerr *)uip_appdata;    print_debug("send RERR for %d.%d.%d.%d/n", uip_ipaddr_to_quad(addr));  rm->type = UAODV_RERR_TYPE;  rm->reserved = 0;  rm->dest_count = 1;  uip_ipaddr_copy(&rm->unreach[0].addr, addr);  rm->unreach[0].seqno = *seqno;  if(*seqno == 0)    rm->flags = UAODV_RERR_UNKNOWN;  else    rm->flags = 0;  uip_udp_packet_send(bcastconn, rm, sizeof(struct uaodv_msg_rerr));}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:20,


示例12: send_rrep

/*---------------------------------------------------------------------------*/static voidsend_rrep(uip_ipaddr_t *dest, uip_ipaddr_t *nexthop, uip_ipaddr_t *orig,	  uint32_t *seqno, unsigned hop_count){  struct uaodv_msg_rrep *rm = (struct uaodv_msg_rrep *)uip_appdata;    print_debug("send RREP orig=%d.%d.%d.%d hops=%d/n",	      uip_ipaddr_to_quad(orig), hop_count);  rm->type = UAODV_RREP_TYPE;  rm->flags = 0;  rm->prefix_sz = 0;		/* I.e a /32 route. */  rm->hop_count = hop_count;  uip_ipaddr_copy(&rm->orig_addr, orig);  rm->dest_seqno = *seqno;  uip_ipaddr_copy(&rm->dest_addr, dest);  rm->lifetime = UIP_HTONL(MY_ROUTE_TIMEOUT);  sendto(nexthop, rm, sizeof(struct uaodv_msg_rrep));}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:20,


示例13: init_net

/*---------------------------------------------------------------------------*/voidinit_net(void){  int i;  uip_ipaddr_t hostaddr, netmask;  rimeaddr_t rimeaddr;  /* Init Rime */  ctimer_init();  rimeaddr.u8[0] = node_id & 0xff;  rimeaddr.u8[1] = node_id >> 8;  rimeaddr_set_node_addr(&rimeaddr);  printf("Rime started with address: ");  for(i = 0; i < sizeof(rimeaddr_node_addr.u8) - 1; i++) {    printf("%d.", rimeaddr_node_addr.u8[i]);  }  printf("%d/n", rimeaddr_node_addr.u8[i]);  /* Init uIPv4 */  process_start(&tcpip_process, NULL);  process_start(&uip_fw_process, NULL);  process_start(&slip_process, NULL);  uip_init();  uip_fw_init();  uip_ipaddr(&hostaddr, 172, 16, rimeaddr_node_addr.u8[1], rimeaddr_node_addr.u8[0]);  uip_ipaddr(&netmask, 255,255,0,0);  uip_sethostaddr(&hostaddr);  uip_setnetmask(&netmask);  uip_fw_register(&wsn_if);  uip_fw_default(&slip_if);  rs232_set_input(slip_input_byte);  printf("uIP started with IP address: %d.%d.%d.%d/n", uip_ipaddr_to_quad(&hostaddr));  /* uIPv4 <-> COOJA's packet radio */  /*tcpip_set_outputfunc(sender);*/  cooja_radio.set_receive_function(receiver);}
开发者ID:EDAyele,项目名称:ptunes,代码行数:38,


示例14: httpd_sprint_ip4

/*---------------------------------------------------------------------------*/uint8_thttpd_sprint_ip4(const uip_ip4addr_t *addr, char *result){  return sprintf(result, "%d.%d.%d.%d", uip_ipaddr_to_quad(addr));}
开发者ID:ADVANSEE,项目名称:mist,代码行数:6,


示例15: dhcpTask

static void dhcpTask(void* arg){  int wait; init:  xid++;  s.state = STATE_SENDING;  wait = 1;  while (1) {    send_discover();    if (readResponse(DHCPOFFER, wait) != -1) {      s.state = STATE_OFFER_RECEIVED;      goto selecting;    }    if(wait < 60)      wait = wait * 2;  }   selecting:  xid++;  wait = 1;  do {    send_request();    if (readResponse(DHCPACK, wait) != -1) {      s.state = STATE_CONFIG_RECEIVED;      goto bound;    }    if(wait < 10) {      wait++;    }    else {      goto init;    }  } while(s.state != STATE_CONFIG_RECEIVED);   bound:#if 0  nosPrintf("Got IP address %d.%d.%d.%d/n", uip_ipaddr_to_quad(&s.ipaddr));  nosPrintf("Got netmask %d.%d.%d.%d/n",	 uip_ipaddr_to_quad(&s.netmask));  nosPrintf("Got DNS server %d.%d.%d.%d/n", uip_ipaddr_to_quad(&s.dnsaddr));  nosPrintf("Got default router %d.%d.%d.%d/n",	 uip_ipaddr_to_quad(&s.default_router));  nosPrintf("Lease expires in %ld seconds/n",	 uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]));#endif  dhcpc_configured(&s);  uint32_t leaseLeft = uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]);  uint32_t sleepLeft = leaseLeft / 2;#define MAX_SECS ((INFINITE - 1) / HZ)  while (sleepLeft > 0) {    if (sleepLeft > MAX_SECS) {      wait = MAX_SECS * HZ;      sleepLeft -= MAX_SECS;    }    else {      wait = sleepLeft * HZ;      sleepLeft = 0;    }    posTaskSleep(wait);  }  leaseLeft = leaseLeft / 2;  /* renewing: */  xid++;  do {    send_request();    if (leaseLeft / 2 > MAX_SECS)      wait = MAX_SECS;    else      wait = (leaseLeft / 2);    if (readResponse(DHCPACK, wait) != -1) {      s.state = STATE_CONFIG_RECEIVED;      goto bound;    }//.........这里部分代码省略.........
开发者ID:AriZuu,项目名称:picoos-net,代码行数:101,


示例16: main

/*---------------------------------------------------------------------------*/intmain(void){  process_init();  procinit_init();  ctimer_init();  autostart_start(autostart_processes);    #if !UIP_CONF_IPV6  uip_ipaddr_t addr;  uip_ipaddr(&addr, 192,168,1,2);  printf("IP Address:  %d.%d.%d.%d/n", uip_ipaddr_to_quad(&addr));  uip_sethostaddr(&addr);  uip_ipaddr(&addr, 255,255,255,0);  printf("Subnet Mask: %d.%d.%d.%d/n", uip_ipaddr_to_quad(&addr));  uip_setnetmask(&addr);  uip_ipaddr(&addr, 192,168,1,1);  printf("Def. Router: %d.%d.%d.%d/n", uip_ipaddr_to_quad(&addr));  uip_setdraddr(&addr);#else  {    uip_ipaddr_t ipaddr;        uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);    uip_netif_addr_autoconf_set(&ipaddr, &uip_lladdr);    uip_netif_addr_add(&ipaddr, 16, 0, TENTATIVE);  }#endif  /* Make standard output unbuffered. */  setvbuf(stdout, (char *)NULL, _IONBF, 0);  while(1) {    fd_set fds;    int n;    struct timeval tv;        n = process_run();    /*    if(n > 0) {      printf("%d processes in queue/n");      }*/    tv.tv_sec = 0;    tv.tv_usec = 1;    FD_ZERO(&fds);    FD_SET(STDIN_FILENO, &fds);    select(1, &fds, NULL, NULL, &tv);    if(FD_ISSET(STDIN_FILENO, &fds)) {      char c;      if(read(STDIN_FILENO, &c, 1) > 0) {	serial_line_input_byte(c);      }    }    etimer_request_poll();  }    return 0;}
开发者ID:vickyviolin,项目名称:contiki-arduino-2.2,代码行数:66,


示例17: main

intmain(){  disableIRQ();  disableFIQ();  *AT91C_AIC_IDCR = 0xffffffff;  *AT91C_PMC_PCDR = 0xffffffff;  *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA);    dbg_setup_uart();  printf("Initialising/n");  leds_arch_init();  clock_init();  process_init();  process_start(&etimer_process, NULL);  ctimer_init();  robot_stepper_init();  enableIRQ();  cc2420_init();  cc2420_set_pan_addr(0x2024, 0, &uip_hostaddr.u16[1]);  cc2420_set_channel(RF_CHANNEL);  rime_init(nullmac_init(&cc2420_driver));  printf("CC2420 setup done/n");  rimeaddr_set_node_addr(&node_addr);      #if WITH_UIP  {    uip_ipaddr_t hostaddr, netmask;        uip_init();    uip_ipaddr(&hostaddr, 172,16,               rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);    uip_ipaddr(&netmask, 255,255,0,0);    uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);    printf("Host addr/n");    uip_sethostaddr(&hostaddr);    uip_setnetmask(&netmask);    uip_over_mesh_set_net(&hostaddr, &netmask);    /*    uip_fw_register(&slipif);*/    /*uip_over_mesh_set_gateway_netif(&slipif);*/    uip_fw_default(&meshif);    printf("Mesh init/n");    uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);    printf("uIP started with IP address %d.%d.%d.%d/n",           uip_ipaddr_to_quad(&hostaddr));  }#endif /* WITH_UIP */#if WITH_UIP  process_start(&tcpip_process, NULL);  process_start(&uip_fw_process, NULL); /* Start IP output */#endif /* WITH_UIP */    printf("Heap size: %ld bytes/n", &__heap_end__ - (char*)sbrk(0));  printf("Started/n");  autostart_start(autostart_processes);  printf("Processes running/n");  while(1) {    do {      /* Reset watchdog. */      wdt_reset();    } while(process_run() > 0);    /* Idle! */    /* Stop processor clock */    *AT91C_PMC_SCDR |= AT91C_PMC_PCK;  }  return 0;}
开发者ID:AlphaBetaPhi,项目名称:contiki,代码行数:75,


示例18: sprintf_P

// Requires a buffer of at least 16 bytes to format intovoid NanodeUIP::format_ipaddr(char *buf, uip_ipaddr_t *addr) {  sprintf_P(buf, PSTR("%d.%d.%d.%d"), uip_ipaddr_to_quad(addr));}
开发者ID:skydome,项目名称:NanodeUIP,代码行数:4,


示例19: main

intmain(int argc, char **argv){  /*   * Initalize hardware.   */  msp430_cpu_init();  clock_init();  leds_init();  leds_toggle(LEDS_ALL);  slip_arch_init(BAUD2UBR(115200)); /* Must come before first printf */  printf("Starting %s "	 "($Id: gateway.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $)/n", __FILE__);  ds2411_init();  sensors_light_init();  cc2420_init();  xmem_init();  leds_toggle(LEDS_ALL);  /*   * Hardware initialization done!   */    printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x CHANNEL %d/n",	 ds2411_id[0], ds2411_id[1], ds2411_id[2], ds2411_id[3],	 ds2411_id[4], ds2411_id[5], ds2411_id[6], ds2411_id[7],	 RF_CHANNEL);  uip_ipaddr_copy(&uip_hostaddr, &cc2420if.ipaddr);  uip_ipaddr_copy(&uip_netmask, &cc2420if.netmask);  printf("IP %d.%d.%d.%d netmask %d.%d.%d.%d/n",	 uip_ipaddr_to_quad(&uip_hostaddr), uip_ipaddr_to_quad(&uip_netmask));  cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr.u16[1], ds2411_id);  srand(rand() +	(ds2411_id[3]<<8) + (ds2411_id[4]<<6) + (ds2411_id[5]<<4) +	(ds2411_id[6]<<2) +  ds2411_id[7]);  /*   * Initialize Contiki and our processes.   */  process_init();  process_start(&etimer_process, NULL);  /* Configure IP stack. */  uip_init();  uip_fw_default(&slipif);	/* Point2point, no default router. */  uip_fw_register(&cc2420if);  tcpip_set_forwarding(1);    /* Start IP stack. */  process_start(&tcpip_process, NULL);  process_start(&uip_fw_process, NULL);	/* Start IP output */  process_start(&slip_process, NULL);  process_start(&cc2420_process, NULL);  cc2420_on();  process_start(&uaodv_process, NULL);  process_start(&tcp_loader_process, NULL);  /*   * This is the scheduler loop.   */  printf("process_run().../n");  while (1) {    do {      /* Reset watchdog. */    } while(process_run() > 0);    /* Idle! */  }  return 0;}
开发者ID:kincki,项目名称:contiki,代码行数:72,


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


示例21: handle_incoming_rrep

/*---------------------------------------------------------------------------*/static voidhandle_incoming_rrep(void){  struct uaodv_msg_rrep *rm = (struct uaodv_msg_rrep *)uip_appdata;  struct uaodv_rt_entry *rt;  /* Useless HELLO message? */  if(uip_ipaddr_cmp(&BUF->destipaddr, &uip_broadcast_addr)) {#ifdef AODV_RESPOND_TO_HELLOS    uint32_t net_seqno;#ifdef CC2420_RADIO    int ret = cc2420_check_remote(uip_udp_sender()->u16[1]);    if(ret == REMOTE_YES) {      print_debug("HELLO drop is remote/n");      return;    } else if (ret == REMOTE_NO) {      /* Is neigbour, accept it. */    } else if(cc2420_last_rssi < RSSI_THRESHOLD) {      print_debug("HELLO drop %d %d/n", cc2420_last_rssi, cc2420_last_correlation);      return;    }#endif    /* Sometimes it helps to send a non-requested RREP in response! */    net_seqno = uip_htonl(my_hseqno);    send_rrep(&uip_hostaddr, &BUF->srcipaddr, &BUF->srcipaddr, &net_seqno, 0);#endif    return;  }  print_debug("RREP %d.%d.%d.%d -> %d.%d.%d.%d"	      " dest=%d.%d.%d.%d seq=%lu hops=%u orig=%d.%d.%d.%d/n",	      uip_ipaddr_to_quad(&BUF->srcipaddr),	      uip_ipaddr_to_quad(&BUF->destipaddr),	      uip_ipaddr_to_quad(&rm->dest_addr), uip_ntohl(rm->dest_seqno),	      rm->hop_count,	      uip_ipaddr_to_quad(&rm->orig_addr));  rt = uaodv_rt_lookup(&rm->dest_addr);  /* New forward route? */  if(rt == NULL || (SCMP32(uip_ntohl(rm->dest_seqno), rt->hseqno) > 0)) {    print_debug("Inserting3/n");    rt = uaodv_rt_add(&rm->dest_addr, uip_udp_sender(),		      rm->hop_count, &rm->dest_seqno);#ifdef CC2420_RADIO    /* This link is ok since he is unicasting back to us! */    cc2420_recv_ok(uip_udp_sender());    print_debug("RREP recv ok %d %d/n",		cc2420_last_rssi, cc2420_last_correlation);#endif  } else {    print_debug("Not inserting/n");  }  /* Forward RREP towards originator? */  if(uip_ipaddr_cmp(&rm->orig_addr, &uip_hostaddr)) {    print_debug("ROUTE FOUND/n");    if(rm->flags & UAODV_RREP_ACK) {      struct uaodv_msg_rrep_ack *ack = (void *)uip_appdata;      ack->type = UAODV_RREP_ACK_TYPE;      ack->reserved = 0;      sendto(uip_udp_sender(), ack, sizeof(*ack));    }  } else {    rt = uaodv_rt_lookup(&rm->orig_addr);    if(rt == NULL) {      print_debug("RREP received, but no route back to originator... :-( /n");      return;    }    if(rm->flags & UAODV_RREP_ACK) {      print_debug("RREP with ACK request (ignored)!/n");      /* Don't want any RREP-ACKs in return! */      rm->flags &= ~UAODV_RREP_ACK;    }    rm->hop_count++;    print_debug("Fwd RREP to %d.%d.%d.%d/n", uip_ipaddr_to_quad(&rt->nexthop));    sendto(&rt->nexthop, rm, sizeof(struct uaodv_msg_rrep));  }}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:86,


示例22: handle_incoming_rreq

/*---------------------------------------------------------------------------*/static voidhandle_incoming_rreq(void){  struct uaodv_msg_rreq *rm = (struct uaodv_msg_rreq *)uip_appdata;  uip_ipaddr_t dest_addr, orig_addr;  struct uaodv_rt_entry *rt, *fw = NULL;    print_debug("RREQ %d.%d.%d.%d -> %d.%d.%d.%d ttl=%u"	      " orig=%d.%d.%d.%d seq=%lu hops=%u dest=%d.%d.%d.%d seq=%lu/n",	      uip_ipaddr_to_quad(&BUF->srcipaddr),	      uip_ipaddr_to_quad(&BUF->destipaddr),	      BUF->ttl,	      uip_ipaddr_to_quad(&rm->orig_addr), uip_ntohl(rm->orig_seqno),	      rm->hop_count,	      uip_ipaddr_to_quad(&rm->dest_addr), uip_ntohl(rm->dest_seqno));  if(uip_ipaddr_cmp(&rm->orig_addr, &uip_hostaddr)) {    return;			/* RREQ looped back! */  }#ifdef CC2420_RADIO {   int ret = cc2420_check_remote(uip_udp_sender()->u16[1]);   if(ret == REMOTE_YES) {     print_debug("RREQ drop is remote/n");     return;   } else if (ret == REMOTE_NO) {     /* Is neigbour, accept it. */   } else if(cc2420_last_rssi < RSSI_THRESHOLD) {     print_debug("RREQ drop %d %d/n", cc2420_last_rssi,		 cc2420_last_correlation);     return;   } }#endif#ifdef AODV_BAD_HOP_EXTENSION  if(uip_len > (sizeof(*rm) + 2)) {    struct uaodv_bad_hop_ext *ext = (void *)(uip_appdata + sizeof(*rm));    uint8_t *end = uip_appdata + uip_len;    for(;	(uint8_t *)ext < end;	ext = (void *)((uint8_t *)ext + ext->length + 2)) {      uint8_t *eend = (uint8_t *)ext + ext->length;      if(eend > end)	eend = end;      if(ext->type == RREQ_BAD_HOP_EXT) {	uip_ipaddr_t *a;	for(a = ext->addrs; (uint8_t *)a < eend; a++) {	  if(uip_ipaddr_cmp(a, &uip_hostaddr)) {	    print_debug("BAD_HOP drop/n");	    return;	  }	}      }    }  }#endif /* AODV_BAD_HOP_EXTENSION */  /* New reverse route? */  rt = uaodv_rt_lookup(&rm->orig_addr);  if(rt == NULL     || (SCMP32(uip_ntohl(rm->orig_seqno), rt->hseqno) > 0) /* New route. */     || (SCMP32(uip_ntohl(rm->orig_seqno), rt->hseqno) == 0	 && rm->hop_count < rt->hop_count)) { /* Better route. */    print_debug("Inserting1/n");    rt = uaodv_rt_add(&rm->orig_addr, uip_udp_sender(),		      rm->hop_count, &rm->orig_seqno);  }      /* Check if it is for our address or a fresh route. */  if(uip_ipaddr_cmp(&rm->dest_addr, &uip_hostaddr)     || rm->flags & UAODV_RREQ_DESTONLY) {    fw = NULL;  } else {    fw = uaodv_rt_lookup(&rm->dest_addr);    if(!(rm->flags & UAODV_RREQ_UNKSEQNO)       && fw != NULL       && SCMP32(fw->hseqno, uip_ntohl(rm->dest_seqno)) <= 0) {      fw = NULL;    }  }  if (fw != NULL) {    uint32_t net_seqno;    print_debug("RREQ for known route/n");    uip_ipaddr_copy(&dest_addr, &rm->dest_addr);    uip_ipaddr_copy(&orig_addr, &rm->orig_addr);    net_seqno = uip_htonl(fw->hseqno);    send_rrep(&dest_addr, &rt->nexthop, &orig_addr, &net_seqno,	      fw->hop_count + 1);  } else if(uip_ipaddr_cmp(&rm->dest_addr, &uip_hostaddr)) {    uint32_t net_seqno;    print_debug("RREQ for our address/n");    uip_ipaddr_copy(&dest_addr, &rm->dest_addr);//.........这里部分代码省略.........
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:101,


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


示例24: uip_over_mesh_send

/*---------------------------------------------------------------------------*/uint8_tuip_over_mesh_send(void){  linkaddr_t receiver;  struct route_entry *rt;  /* This function is called by the uip-fw module to send out an IP     packet. We try to send the IP packet to the next hop route, or we     queue the packet and send out a route request for the final     receiver of the packet. */  /* Packets destined to this network is sent using mesh, whereas     packets destined to a network outside this network is sent towards     the gateway node. */  if(uip_ipaddr_maskcmp(&BUF->destipaddr, &netaddr, &netmask)) {    receiver.u8[0] = BUF->destipaddr.u8[2];    receiver.u8[1] = BUF->destipaddr.u8[3];  } else {    if(linkaddr_cmp(&gateway, &linkaddr_node_addr)) {      PRINTF("uip_over_mesh_send: I am gateway, packet to %d.%d.%d.%d to local interface/n",	     uip_ipaddr_to_quad(&BUF->destipaddr));      if(gw_netif != NULL) {	return gw_netif->output();      }      return UIP_FW_DROPPED;    } else if(linkaddr_cmp(&gateway, &linkaddr_null)) {      PRINTF("uip_over_mesh_send: No gateway setup, dropping packet/n");      return UIP_FW_OK;    } else {      PRINTF("uip_over_mesh_send: forwarding packet to %d.%d.%d.%d towards gateway %d.%d/n",	     uip_ipaddr_to_quad(&BUF->destipaddr),	     gateway.u8[0], gateway.u8[1]);      linkaddr_copy(&receiver, &gateway);    }  }  PRINTF("uIP over mesh send to %d.%d with len %d/n",	 receiver.u8[0], receiver.u8[1],	 uip_len);      packetbuf_copyfrom(&uip_buf[UIP_LLH_LEN], uip_len);  /* Send TCP data with the PACKETBUF_ATTR_ERELIABLE set so that     an underlying power-saving MAC layer knows that it should be     waiting for an ACK. */  if(BUF->proto == UIP_PROTO_TCP) {    packetbuf_set_attr(PACKETBUF_ATTR_ERELIABLE, 1);    packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, 1);    /*    packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE, PACKETBUF_ATTR_PACKET_TYPE_STREAM);*/  }  rt = route_lookup(&receiver);  if(rt == NULL) {    PRINTF("uIP over mesh no route to %d.%d/n", receiver.u8[0], receiver.u8[1]);    if(queued_packet == NULL) {      queued_packet = queuebuf_new_from_packetbuf();      linkaddr_copy(&queued_receiver, &receiver);      route_discovery_discover(&route_discovery, &receiver, ROUTE_TIMEOUT);    } else if(!linkaddr_cmp(&queued_receiver, &receiver)) {      route_discovery_discover(&route_discovery, &receiver, ROUTE_TIMEOUT);    }  } else {    route_decay(rt);    send_data(&rt->nexthop);  }  return UIP_FW_OK;}
开发者ID:exziled,项目名称:WeatherSystem,代码行数:70,


示例25: init_net

//.........这里部分代码省略.........#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);  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);  printf_P(PSTR("uIP started with IP address %d.%d.%d.%d/n"),	       uip_ipaddr_to_quad(&hostaddr));#endif /* NETSTACK_CONF_WITH_IPV4 */    }
开发者ID:Babody,项目名称:contiki,代码行数:101,


示例26: main

//.........这里部分代码省略.........  leds_off(LEDS_GREEN);#if TIMESYNCH_CONF_ENABLED  timesynch_init();  timesynch_set_authority_level(linkaddr_node_addr.u8[0]);#endif /* TIMESYNCH_CONF_ENABLED */#if NETSTACK_CONF_WITH_IPV4  process_start(&tcpip_process, NULL);  process_start(&uip_fw_process, NULL); /* Start IP output */  process_start(&slip_process, NULL);  slip_set_input_callback(set_gateway);  {    uip_ipaddr_t hostaddr, netmask;    uip_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_fw_register(&slipif);*/    uip_over_mesh_set_gateway_netif(&slipif);    uip_fw_default(&meshif);    uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);    printf("uIP started with IP address %d.%d.%d.%d/n",           uip_ipaddr_to_quad(&hostaddr));  }#endif /* NETSTACK_CONF_WITH_IPV4 */  energest_init();  ENERGEST_ON(ENERGEST_TYPE_CPU);  print_processes(autostart_processes);  autostart_start(autostart_processes);  /*   * This is the scheduler loop.   */#if DCOSYNCH_CONF_ENABLED  timer_set(&mgt_timer, DCOSYNCH_PERIOD * CLOCK_SECOND);#endif  watchdog_start();  /*  watchdog_stop();*/  while(1) {    int r;    do {      /* Reset watchdog. */      watchdog_periodic();      r = process_run();    } while(r > 0);    /*     * Idle processing.     */    int s = splhigh();    /* Disable interrupts. */    /* uart0_active is for avoiding LPM3 when still sending or receiving */    if(process_nevents() != 0 || uart0_active()) {      splx(s);      /* Re-enable interrupts. */
开发者ID:mlwymore,项目名称:contiki,代码行数:67,


示例27: main

//.........这里部分代码省略.........#endif  leds_off(LEDS_GREEN);#if TIMESYNCH_CONF_ENABLED  timesynch_init();  timesynch_set_authority_level((rimeaddr_node_addr.u8[0] << 4) + 16);#endif /* TIMESYNCH_CONF_ENABLED */#if WITH_UIP  process_start(&tcpip_process, NULL);  process_start(&uip_fw_process, NULL);	/* Start IP output */  process_start(&slip_process, NULL);  slip_set_input_callback(set_gateway);  {    uip_ipaddr_t hostaddr, netmask;    uip_init();    uip_ipaddr(&hostaddr, 172,16,	       rimeaddr_node_addr.u8[0],rimeaddr_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_fw_register(&slipif);*/    uip_over_mesh_set_gateway_netif(&slipif);    uip_fw_default(&meshif);    uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);    printf("uIP started with IP address %d.%d.%d.%d/n",           uip_ipaddr_to_quad(&hostaddr));  }#endif /* WITH_UIP */  energest_init();  ENERGEST_ON(ENERGEST_TYPE_CPU);  watchdog_start();  /* Stop the watchdog */  watchdog_stop();#if !PROCESS_CONF_NO_PROCESS_NAMES  print_processes(autostart_processes);#else /* !PROCESS_CONF_NO_PROCESS_NAMES */  putchar('/n'); /* include putchar() */#endif /* !PROCESS_CONF_NO_PROCESS_NAMES */  autostart_start(autostart_processes);  /*   * This is the scheduler loop.   */  while(1) {    int r;    do {      /* Reset watchdog. */      watchdog_periodic();      r = process_run();    } while(r > 0);    /*     * Idle processing.     */    int s = splhigh();		/* Disable interrupts. */    /* uart1_active is for avoiding LPM3 when still sending or receiving */    if(process_nevents() != 0 || uart1_active()) {      splx(s);                  /* Re-enable interrupts. */    } else {      static unsigned long irq_energest = 0;      /* Re-enable interrupts and go to sleep atomically. */      ENERGEST_OFF(ENERGEST_TYPE_CPU);      ENERGEST_ON(ENERGEST_TYPE_LPM);      /* We only want to measure the processing done in IRQs when we	 are asleep, so we discard the processing time done when we	 were awake. */      energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);      watchdog_stop();      _BIS_SR(GIE | SCG0 | SCG1 | CPUOFF); /* LPM3 sleep. This                                              statement will block                                              until the CPU is                                              woken up by an                                              interrupt that sets                                              the wake up flag. */      /* We get the current processing time for interrupts that was         done during the LPM and store it for next time around.  */      dint();      irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);      eint();      watchdog_start();      ENERGEST_OFF(ENERGEST_TYPE_LPM);      ENERGEST_ON(ENERGEST_TYPE_CPU);    }  }}
开发者ID:1uk3,项目名称:contiki,代码行数:101,


示例28: PT_THREAD

/*---------------------------------------------------------------------------*/staticPT_THREAD(handle_dhcp(process_event_t ev, void *data)){  clock_time_t ticks;  PT_BEGIN(&s.pt);//  printf("handle_dhcp/n"); init:// printf("init/n");  xid++;  s.state = STATE_SENDING;  s.ticks = CLOCK_SECOND * 4;  while(1) {    while(ev != tcpip_event) {      tcpip_poll_udp(s.conn);      PT_YIELD(&s.pt);    }    send_discover();    etimer_set(&s.etimer, s.ticks);    do {      PT_YIELD(&s.pt);//      printf("tcpip_event:%d ev:%d uip_newdata():%d msg_for_me():%d/n",tcpip_event, ev,uip_newdata(),msg_for_me());      if(ev == tcpip_event && uip_newdata() && msg_for_me() == DHCPOFFER) {//    printf("here2/n");	parse_msg();	s.state = STATE_OFFER_RECEIVED;	goto selecting;      }    } while(!etimer_expired(&s.etimer));    if(s.ticks < CLOCK_SECOND * 60) {      s.ticks *= 2;    }  }   selecting:// printf("selecting/n");  xid++;  s.ticks = CLOCK_SECOND;  do {    while(ev != tcpip_event) {      tcpip_poll_udp(s.conn);      PT_YIELD(&s.pt);    }    send_request();    etimer_set(&s.etimer, s.ticks);    do {      PT_YIELD(&s.pt);      if(ev == tcpip_event && uip_newdata() && msg_for_me() == DHCPACK) {	parse_msg();	s.state = STATE_CONFIG_RECEIVED;	goto bound;      }    } while (!etimer_expired(&s.etimer));    if(s.ticks <= CLOCK_SECOND * 10) {      s.ticks += CLOCK_SECOND;    } else {      goto init;    }  } while(s.state != STATE_CONFIG_RECEIVED);   bound:#if 0  printf("Got IP address %d.%d.%d.%d/n", uip_ipaddr_to_quad(&s.ipaddr));  printf("Got netmask %d.%d.%d.%d/n",	 uip_ipaddr_to_quad(&s.netmask));  printf("Got DNS server %d.%d.%d.%d/n", uip_ipaddr_to_quad(&s.dnsaddr));  printf("Got default router %d.%d.%d.%d/n",	 uip_ipaddr_to_quad(&s.default_router));  printf("Lease expires in %ld seconds/n",	 uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]));#endif//  printf("bound/n");  ip64_dhcpc_configured(&s);  #define MAX_TICKS (~((clock_time_t)0) / 2)#define MAX_TICKS32 (~((uint32_t)0))#define IMIN(a, b) ((a) < (b) ? (a) : (b))  if((uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]))*CLOCK_SECOND/2     <= MAX_TICKS32) {    s.ticks = (uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1])	       )*CLOCK_SECOND/2;  } else {    s.ticks = MAX_TICKS32;  }  while(s.ticks > 0) {    ticks = IMIN(s.ticks, MAX_TICKS);    s.ticks -= ticks;    etimer_set(&s.etimer, ticks);    PT_YIELD_UNTIL(&s.pt, etimer_expired(&s.etimer));  }  if((uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]))*CLOCK_SECOND/2     <= MAX_TICKS32) {    s.ticks = (uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1])	       )*CLOCK_SECOND/2;//.........这里部分代码省略.........
开发者ID:examyes,项目名称:SMeshStudio,代码行数:101,



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


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