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

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

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

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

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

示例1: uecmd_net_main

voiduecmd_net_main(){  if (!uip_newdata())    return;  char *p = (char *) uip_appdata;  /* This may be 1-2 chars too big in case there is a /r or /n, but it saves us a counting loop */  char cmd[uip_datalen() + 1];  char *dp = cmd;  /* Copy over into temporary buffer, remove /r /n if present, add /0 */  while (p < (char *) uip_appdata + uip_datalen())  {    if (*p == '/r' || *p == '/n')      break;    *dp++ = *p++;  }  *dp = 0;  uip_slen = 0;  while (uip_slen < UIP_BUFSIZE - UIP_IPUDPH_LEN)  {    int16_t len = ecmd_parse_command(cmd, ((char *) uip_appdata) + uip_slen,                                     (UIP_BUFSIZE - UIP_IPUDPH_LEN) -                                     uip_slen);    uint8_t real_len = len;    if (!is_ECMD_FINAL(len))    {                           /* what about the errors ? */      /* convert ECMD_AGAIN back to ECMD_FINAL */      real_len = (uint8_t) ECMD_AGAIN(len);    }    uip_slen += real_len + 1;    ((char *) uip_appdata)[uip_slen - 1] = '/n';    if (real_len == len || len == 0)      break;  }  /* Sent data out */  uip_udp_conn_t echo_conn;  uip_ipaddr_copy(echo_conn.ripaddr, BUF->srcipaddr);  echo_conn.rport = BUF->srcport;  echo_conn.lport = HTONS(ECMD_UDP_PORT);  uip_udp_conn = &echo_conn;  uip_process(UIP_UDP_SEND_CONN);  router_output();  uip_slen = 0;}
开发者ID:adlerweb,项目名称:ethersex,代码行数:50,


示例2: output

static voidoutput(void){#if FALLBACK_HAS_ETHERNET_HEADERS&&0  if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) {    /* Do not bounce packets back to fallback if the packet was received from it */    PRINTF("FUT: trapping pingpong");	return;  }  uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr);#endif    PRINTF("FUT: %u/n", uip_len);	wfall_send(0);}
开发者ID:AWRyder,项目名称:contiki,代码行数:14,


示例3: udpstella_net_main

voidudpstella_net_main(void){    if (!uip_newdata ())	return;    uip_slen = 0;    uint16_t len = uip_len;    uint8_t buffer[uip_len];    memcpy(buffer, uip_appdata, uip_len);    struct udpstella_packet* packet = (struct udpstella_packet*)buffer;    uint8_t* answer = uip_appdata;    while (len>=sizeof(struct udpstella_packet)) {	    if (packet->type == STELLA_GETALL) {		answer[0] = 's';		answer[1] = 't';		answer[2] = 'e';		answer[3] = 'l';		answer[4] = 'l';		answer[5] = 'a';		answer[6] = (uint8_t)STELLA_CHANNELS;		for (uint8_t c=0;c<STELLA_CHANNELS;++c) {			answer[7+c] = stella_brightness[c];		}		uip_slen += STELLA_CHANNELS+6;		answer += STELLA_CHANNELS+6;	    } else {			stella_setValue(packet->type, packet->channel, packet->value);	    }     	packet++;     	len-=sizeof(struct udpstella_packet);     }    if (uip_slen == 0) return;	/* Sent data out */	uip_udp_conn_t echo_conn;	uip_ipaddr_copy(echo_conn.ripaddr, BUF->srcipaddr);	echo_conn.rport = BUF->srcport;	echo_conn.lport = HTONS(UDP_STELLA_PORT);	uip_udp_conn = &echo_conn;	uip_process(UIP_UDP_SEND_CONN);	router_output();	uip_slen = 0;}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:50,


示例4: sendto

/*---------------------------------------------------------------------------*/static voidsendto(const uip_ipaddr_t *dest, const void *buf, int len){  /* XXX: this is a HACK! We're updating the uIP UDP connection     "unicastconn" so that the destination address is the next-hop,     and we're patching the "uip_udp_conn" variable so that it points     the this connection instead. THIS IS NOT A NICE WAY TO DO THIS,     but it is currently nicer than the alternative (requesting a new     poll, and remembering the state, etc.). */    uip_ipaddr_copy(&unicastconn->ripaddr, dest);  uip_udp_conn = unicastconn;  uip_udp_packet_send(unicastconn, buf, len);}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:15,


示例5: uip_udp_packet_sendto

/*---------------------------------------------------------------------------*/voiduip_udp_packet_sendto(struct uip_udp_conn *c, const void *data, int len,		      const uip_ipaddr_t *toaddr, uint16_t toport){  uip_ipaddr_t curaddr;  uint16_t curport;  if(toaddr != NULL) {    /* Save current IP addr/port. */    uip_ipaddr_copy(&curaddr, &c->ripaddr);    curport = c->rport;    /* Load new IP addr/port */    uip_ipaddr_copy(&c->ripaddr, toaddr);    c->rport = toport;    uip_udp_packet_send(c, data, len);    /* Restore old IP addr/port */    uip_ipaddr_copy(&c->ripaddr, &curaddr);    c->rport = curport;  }}
开发者ID:200018171,项目名称:contiki,代码行数:24,


示例6: collectd_processing

/* * this function process the request which fall into 2 cases: request, and reply * an example of receiving request:  		{		'status': 'start',		//start/stop		'update': 1,			//in second		'addr': 'aaaa::1',		'port': 20000		} */char collectd_processing(u8_t* const input, const u16_t input_len, collectd_conf_t *collectd_conf) {	static jsmn_parser p;	static jsmntok_t tokens[MAX_TOKEN];	static char value[TOKEN_LEN];	//values to save temp from input json (before make sure json msg is valid)	u8_t commandtype;	u16_t update;	u16_t srcport;	uip_ipaddr_t mnaddr;	int r;	input[input_len] = 0;	PRINTF("%s/n", input);	jsmn_init(&p);	r = jsmn_parse(&p, (char*)input, tokens, MAX_TOKEN);	check(r == JSMN_SUCCESS);	//get status	check(js_get(input, tokens, MAX_TOKEN, "status", value, MAX_TOKEN) == JSMN_TOKEN_SUCCESS);	check( (strcmp(value, "start")==0) || (strcmp(value, "stop")==0) );	commandtype = (strcmp(value, "start") == 0)? COMMAND_START : COMMAND_STOP;	//PRINTF("start = %d/n", commandtype);	check(js_get(input, tokens, MAX_TOKEN, "update", value, MAX_TOKEN) == JSMN_TOKEN_SUCCESS);	errno = 0;	update = (u16_t)strtol(value, NULL, 10);		//convert to base 10	check(!(errno == ERANGE || (errno != 0 && update == 0)));	//PRINTF("update = %d/n", update);	check(js_get(input, tokens, MAX_TOKEN, "addr", value, MAX_TOKEN) == JSMN_TOKEN_SUCCESS);	check(uiplib_ipaddrconv(value, &mnaddr) == 1);	//PRINT6ADDR(&mnaddr);	//PRINTF("/n");	check(js_get(input, tokens, MAX_TOKEN, "port", value, MAX_TOKEN) == JSMN_TOKEN_SUCCESS);	errno = 0;	srcport = (u16_t)strtol(value, NULL, 10);		//convert to base 10	check(!(errno == ERANGE || (errno != 0 && update == 0)));	//PRINTF("port = %d/n", srcport);	/*save the request to conf*/	collectd_conf->send_active = commandtype;	collectd_conf->update_freq_in_sec = update;	collectd_conf->mnrport = srcport;	uip_ipaddr_copy(&collectd_conf->mnaddr, &mnaddr);	return COLLECTD_ERROR_NO_ERROR;}
开发者ID:anhquang,项目名称:contiki,代码行数:59,


示例7: nllvdbg

FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,                                      FAR const uip_ipaddr_t *addr){  FAR struct igmp_group_s *group;  uip_lock_t flags;  nllvdbg("addr: %08x dev: %p/n", *addr, dev);  if (up_interrupt_context())    {#if CONFIG_PREALLOC_IGMPGROUPS > 0      grplldbg("Use a pre-allocated group entry/n");      group = uip_grpprealloc();#else      grplldbg("Cannot allocate from interrupt handler/n");      group = NULL;#endif    }  else    {      grplldbg("Allocate from the heap/n");      group = uip_grpheapalloc();    }  grplldbg("group: %p/n", group);  /* Check if we succesfully allocated a group structure */  if (group)    {      /* Initialize the non-zero elements of the group structure */      uip_ipaddr_copy(group->grpaddr, *addr);      sem_init(&group->sem, 0, 0);      /* Initialize the group timer (but don't start it yet) */      group->wdog = wd_create();      DEBUGASSERT(group->wdog);      /* Interrupts must be disabled in order to modify the group list */      flags = uip_lock();      /* Add the group structure to the list in the device structure */      sq_addfirst((FAR sq_entry_t*)group, &dev->grplist);      uip_unlock(flags);    }  return group;}
开发者ID:CNCBASHER,项目名称:Firmware,代码行数:49,


示例8: uip_netif_addr_add

/*---------------------------------------------------------------------------*/voiduip_netif_addr_add(uip_ipaddr_t *ipaddr, u8_t length, unsigned long vlifetime, uip_netif_type type) {    /* check prefix has the right length if we are doing autoconf */  if((type == AUTOCONF) && (length != UIP_DEFAULT_PREFIX_LEN)) {    UIP_LOG("Error: UNSUPPORTED PREFIX LENGTH");    return;  }    /* check if addr does not already exist and find a free entry */  for(i = 0; i < UIP_CONF_NETIF_MAX_ADDRESSES; ++i) {    if(uip_netif_physical_if.addresses[i].state == NOT_USED){      /*       * Copying address       * If we are doing autoconf, ipaddr is a prefix, we copy the 128 bits       * of it, then overwrite the last 64 bits with the interface ID at        * next if statement.       * Otherwise ipaddr is an address, we just copy it       */      uip_ipaddr_copy(&uip_netif_physical_if.addresses[i].ipaddr, ipaddr);      if(type == AUTOCONF) {        /* construct address from prefix and layer2 id */        uip_netif_addr_autoconf_set(&uip_netif_physical_if.addresses[i].ipaddr, &uip_lladdr);      }       /* setting state, type */      uip_netif_physical_if.addresses[i].state = TENTATIVE;      uip_netif_physical_if.addresses[i].type = type;      /* setting lifetime timer if lieftime is not infinite */      if(vlifetime != 0) {        stimer_set(&(uip_netif_physical_if.addresses[i].vlifetime), vlifetime);        uip_netif_physical_if.addresses[i].is_infinite = 0;      } else {        uip_netif_physical_if.addresses[i].is_infinite = 1;      }      PRINTF("Created new address");      PRINT6ADDR(&uip_netif_physical_if.addresses[i].ipaddr);      PRINTF("for interface/n");         /* schedule DAD */      uip_netif_sched_dad(&uip_netif_physical_if.addresses[i]);            return;    }  }   /* If we did not find space, log */   UIP_LOG("ADDRESS LIST FULL");  return;}
开发者ID:EDAyele,项目名称:ptunes,代码行数:50,


示例9: uip_sock_init

/*-------------------------------------------| Name:uip_sock_init| Description:| Parameters:| Return Type:| Comments:| See:---------------------------------------------*/int uip_sock_init(void) {#if defined (USE_UIP)   int i;   socketList = (socket_t*)&_socketList;   socksconn_state_list = (struct socksconn_state*)&_socksconn_state_list;   uip_init();   #if UIP_CONF_IPV6   {      uip_ip6addr_t ip6addr;      memcpy(uip_lladdr.addr, "/x00/x0c/x29/x28/x23/x45", 6); // Set in zigbeestack.cpp (UID)          uip_ip6addr(&ip6addr, 0xfe80,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0002);      uip_sethostaddr(&ip6addr);      uip_ipaddr_copy(&uip_hostaddr, &ip6addr);      tcpip_init();  // rpl_init() is called inside tcpip_init()      clock_init();      uip_ds6_addr_add(&ip6addr, 0, ADDR_MANUAL);   }   #endif   //ethernet   #if defined(USE_IF_ETHERNET)      #if !UIP_CONF_IPV6   uip_arp_init();   #endif#endif    for(i=0; i<MAX_SOCKET; i++) {      #if UIP_CONF_IPV6      socketList[i].addr_in.sin6_port=0;      #else      socketList[i].addr_in.sin_port=0;      #endif      socketList[i].socksconn=NULL;      socketList[i].desc = -1;   }   for(i=0; i<UIP_CONNS; i++) {      socksconn_state_list[i].hsocks=NULL;      uip_conns[i].appstate.state = &socksconn_state_list[i];   }   for(;i<(UIP_CONNS+UIP_UDP_CONNS);i++){      socksconn_state_list[i].hsocks=NULL;      uip_udp_conns[i-UIP_CONNS].appstate.state = &socksconn_state_list[i];   }#else   return -1;#endif   return 0;}
开发者ID:lepton-distribution,项目名称:lepton,代码行数:57,


示例10: handle_pir_frame

void handle_pir_frame(uint8_t *frame){	if (frame[1] == REQUEST_MSG)		{			if (frame[2] == PIR_REGISTER)			{				uip_ipaddr_copy(&register_address, &UIP_IP_BUF->srcipaddr);				pir_registered = PIR_REGISTERED;			}			else			{				pir_registered = PIR_N_REGISTERED;			}		}}
开发者ID:bearxiong99,项目名称:tdma_demo,代码行数:15,


示例11: tcpip_handler

/*--------------------------------------------------------------------------------------------*/ void tcpip_handler(struct udp_tx *udp_tx_info){	 if(uip_newdata()){		 ((char *)uip_appdata)[uip_datalen()] = 0;		 		PRINTF("Server received: '%s' from [", (char *)uip_appdata);		 		PRINT6ADDR(&UIP_IP_BUF->srcipaddr);		 		PRINTF("]:%u",UIP_HTONS(UIP_UDP_BUF->srcport));		 		PRINTF("/n");		 		uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);		 		server_conn->rport=uip_htons(3007);		 		PRINTF("Responding with message: ");		 		udp_data_handler(uip_appdata,udp_tx_info);	 } }
开发者ID:notank,项目名称:contiki,代码行数:16,


示例12: uecmd_net_init

voiduecmd_net_init(){  uip_ipaddr_t ip;  uip_ipaddr_copy(&ip, all_ones_addr);  uip_udp_conn_t *uecmd_conn = uip_udp_new(&ip, 0, uecmd_net_main);  if (!uecmd_conn)  {    debug_printf("ecmd: udp failed/n");    return;  }  uip_udp_bind(uecmd_conn, HTONS(ECMD_UDP_PORT));}
开发者ID:adlerweb,项目名称:ethersex,代码行数:15,


示例13: uip_ds6_route_add

/*---------------------------------------------------------------------------*/uip_ds6_route_t *uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length, uip_ipaddr_t *nexthop,                  uint8_t metric){  if(uip_ds6_list_loop     ((uip_ds6_element_t *)uip_ds6_routing_table, UIP_DS6_ROUTE_NB,      sizeof(uip_ds6_route_t), ipaddr, length,      (uip_ds6_element_t **)&locroute) == FREESPACE) {    locroute->isused = 1;    uip_ipaddr_copy(&(locroute->ipaddr), ipaddr);    locroute->length = length;    uip_ipaddr_copy(&(locroute->nexthop), nexthop);    locroute->metric = metric;    PRINTF("DS6: adding route: ");    PRINT6ADDR(ipaddr);    PRINTF(" via ");    PRINT6ADDR(nexthop);    PRINTF("");    ANNOTATE("#L u 1;blue", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);  }  return locroute;}
开发者ID:bearxiong99,项目名称:Arduino-IPv6Stack,代码行数:25,


示例14: DHCPServerApp_GetUnleasedIP

/** Retrieves the next unleased IP in the IP address pool. * *  /param[out] NewIPAddress  Location where the generated IP Address should be stored */static void DHCPServerApp_GetUnleasedIP(uip_ipaddr_t* const NewIPAddress){	uip_ipaddr_copy(NewIPAddress, &uip_hostaddr);	/** Look through the current subnet, skipping the broadcast and zero IP addresses */	for (uint8_t IP = 1; IP < 254; IP++)	{		/* Update new IP address to lease with the current IP address to test */		NewIPAddress->u8[3] = IP;		/* If we've found an unleased IP, abort with the updated IP stored for the called */		if (!(DHCPServerApp_CheckIfIPLeased(NewIPAddress)))		  return;	}}
开发者ID:Steffen-Engel,项目名称:lufa,代码行数:19,


示例15: zbus_raw_net_main

voidzbus_raw_net_main(void) {  if (uip_newdata ())    {      /* 600ms timeout */      uip_udp_conn->appstate.zbus_raw.timeout = 3;      uip_ipaddr_copy(uip_udp_conn->ripaddr, BUF->srcipaddr);      uip_udp_conn->rport = BUF->srcport;            zbus_send_data(uip_appdata, uip_len);      return;    }  if (! uip_udp_conn->appstate.zbus_raw.timeout)    return;  if (-- uip_udp_conn->appstate.zbus_raw.timeout)    return;			/* timeout not yet over. */  uip_ipaddr_copy(uip_udp_conn->ripaddr, all_ones_addr);  uip_udp_conn->rport = 0;}
开发者ID:muccc,项目名称:matemat,代码行数:24,


示例16: uip_ds6_maddr_add

/*---------------------------------------------------------------------------*/uip_ds6_maddr_t *uip_ds6_maddr_add(uip_ipaddr_t *ipaddr){  if(uip_ds6_list_loop     ((uip_ds6_element_t *)uip_ds6_if.maddr_list, UIP_DS6_MADDR_NB,      sizeof(uip_ds6_maddr_t), ipaddr, 128,      (uip_ds6_element_t **)&locmaddr) == FREESPACE) {    locmaddr->isused = 1;    locmaddr->isreported = 0;    uip_ipaddr_copy(&locmaddr->ipaddr, ipaddr);    mld_report_now();    return locmaddr;  }  return NULL;}
开发者ID:ChristianKniep,项目名称:hexabus,代码行数:16,


示例17: udp_socket_connect

/*---------------------------------------------------------------------------*/intudp_socket_connect(struct udp_socket *c,                   uip_ipaddr_t *remote_addr,                   uint16_t remote_port){  if(c == NULL || c->udp_conn == NULL) {    return -1;  }  if(remote_addr != NULL) {    uip_ipaddr_copy(&c->udp_conn->ripaddr, remote_addr);  }  c->udp_conn->rport = UIP_HTONS(remote_port);  return 1;}
开发者ID:hudkmr,项目名称:zephyr,代码行数:16,


示例18: artnet_send

static voidartnet_send(const uip_ipaddr_t *dest, uint16_t len){  uip_udp_conn_t artnet_conn;  uip_ipaddr_copy(&(artnet_conn.ripaddr), dest);  artnet_conn.rport = HTONS(artnet_port);  artnet_conn.lport = HTONS(artnet_port);  uip_udp_conn = &artnet_conn;  uip_slen = len;  uip_process(UIP_UDP_SEND_CONN);  router_output();  uip_slen = 0;}
开发者ID:AnDann,项目名称:ethersex,代码行数:15,


示例19: handle_incoming_reg

/*---------------------------------------------------------------------------*/static voidhandle_incoming_reg(const uip_ipaddr_t *owner, servreg_hack_id_t id, uint8_t seqno){  servreg_hack_item_t *t;  struct servreg_hack_registration *r;  /* Walk through list, see if we already have a service ID     registered. If so, we do different things depending on the seqno     of the update: if the seqno is older than what we have, we     discard the incoming registration. If the seqno is newer than     what we have, we reset the lifetime timer of the current     registration.     If we did not have the service registered already, we allocate a     new registration and put it on our list. If we cannot allocate a     service registration, we discard the incoming registration (for     now - we might later choose to discard the oldest registration     that we have). */  for(t = servreg_hack_list_head();      t != NULL;      t = list_item_next(t)) {    if(servreg_hack_item_id(t) == id) {      r = t;      if(SEQNO_LT(r->seqno, seqno)) {        r->seqno = seqno;        timer_set(&r->timer, LIFETIME);        /* Put item first on list, so that subsequent lookups will           find this one. */        list_remove(others_services, r);        list_push(others_services, r);      }      return;    }  }  r = memb_alloc(&registrations);  if(r == NULL) {    printf("servreg_hack_register: error, could not allocate memory, should reclaim another registration but this has not been implemented yet./n");    return;  }  r->id = id;  r->seqno = 1;  uip_ipaddr_copy(&r->addr, owner);  timer_set(&r->timer, LIFETIME);  list_add(others_services, r);}
开发者ID:EmuxEvans,项目名称:contiki-cc2530eb,代码行数:49,


示例20: raven_ping6

/* Sends a ping packet out the radio */static voidraven_ping6(void){    /* ping the router */    // Setup destination address.    struct uip_nd6_defrouter *defrouter;    uint8_t i,tmp;    defrouter = uip_nd6_choose_defrouter();    /* Get address from defrouter struct */    memcpy(addr, defrouter->nb->ipaddr.u8, 16);    /* Swap the bytes in the address array */    for (i=0;i<8;i++)    {        tmp = addr[i] & 0xff;        addr[i] >>= 8;        addr[i] |= tmp << 8;    }    uip_ip6addr(&dest_addr, addr[0], addr[1],addr[2],                addr[3],addr[4],addr[5],addr[6],addr[7]);      UIP_IP_BUF->vtc = 0x60;    UIP_IP_BUF->tcflow = 1;    UIP_IP_BUF->flow = 0;    UIP_IP_BUF->proto = UIP_PROTO_ICMP6;    UIP_IP_BUF->ttl = uip_netif_physical_if.cur_hop_limit;    uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &dest_addr);    uip_netif_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);     UIP_ICMP_BUF->type = ICMP6_ECHO_REQUEST;    UIP_ICMP_BUF->icode = 0;    /* set identifier and sequence number to 0 */    memset((void *)UIP_ICMP_BUF + UIP_ICMPH_LEN, 0, 4);    /* put one byte of data */    memset((void *)UIP_ICMP_BUF + UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN,           count, PING6_DATALEN);             uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN + PING6_DATALEN;    UIP_IP_BUF->len[0] = (u8_t)((uip_len - 40) >> 8);    UIP_IP_BUF->len[1] = (u8_t)((uip_len - 40) & 0x00FF);        UIP_ICMP_BUF->icmpchksum = 0;    UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();           tcpip_ipv6_output();}
开发者ID:EDAyele,项目名称:ptunes,代码行数:49,


示例21: rpl_purge_routes

/*---------------------------------------------------------------------------*/voidrpl_purge_routes(void){  uip_ds6_route_t *r;  uip_ipaddr_t prefix;  rpl_dag_t *dag;  /* First pass, decrement lifetime */  r = uip_ds6_route_head();  while(r != NULL) {    if(r->state.lifetime >= 1) {      /*       * If a route is at lifetime == 1, set it to 0, scheduling it for       * immediate removal below. This achieves the same as the original code,       * which would delete lifetime <= 1       */      r->state.lifetime--;    }    r = uip_ds6_route_next(r);  }  /* Second pass, remove dead routes */  r = uip_ds6_route_head();  while(r != NULL) {    if(r->state.lifetime < 1) {      /* Routes with lifetime == 1 have only just been decremented from 2 to 1,       * thus we want to keep them. Hence < and not <= */      uip_ipaddr_copy(&prefix, &r->ipaddr);      uip_ds6_route_rm(r);      r = uip_ds6_route_head();      printf("No more routes to ");      PRINT6ADDR(&prefix);      dag = default_instance->current_dag;      /* Propagate this information with a No-Path DAO to preferred parent if we are not a RPL Root */      if(dag->rank != ROOT_RANK(default_instance)) {        PRINTF(" -> generate No-Path DAO/n");        dao_output_target(dag->preferred_parent, &prefix, RPL_ZERO_LIFETIME);        /* Don't schedule more than 1 No-Path DAO, let next iteration handle that */        return;      }      PRINTF("/n");    } else {      r = uip_ds6_route_next(r);    }  }}
开发者ID:zhuzhudaxia,项目名称:contiki-2.7,代码行数:49,


示例22: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(shell_irc_process, ev, data){  char *next;  struct shell_input *input;    PROCESS_BEGIN();  next = strchr(data, ' ');  if(next == NULL) {    shell_output_str(&irc_command,		     "irc <server> <nick>: server as address", "");    PROCESS_EXIT();  }  *next = 0;  ++next;  strncpy(server, data, sizeof(server));  strncpy(nick, next, sizeof(nick));    running = 1;  uiplib_ipaddrconv(server, (u8_t *)&serveraddr);  ircc_connect(&s, server, &serveraddr, nick);  while(running) {    PROCESS_WAIT_EVENT();    if(ev == shell_event_input) {      input = data;      if(input->len1 > 0) {	parse_line(input->data1);      }    } else if(ev == tcpip_event) {      ircc_appcall(data);#if 0                } else if(ev == resolv_event_found) {      /* Either found a hostname, or not. */      if((char *)data != NULL &&	 resolv_lookup((char *)data) != NULL) {	uip_ipaddr_copy(serveraddr, ipaddr);	ircc_connect(&s, server, serveraddr, nick);      } else {	shell_output_str(&irc_command, "Host not found.", "");      }#endif /* 0 */    }  }  PROCESS_END();}
开发者ID:EDAyele,项目名称:ptunes,代码行数:49,


示例23: uaodv_bad_dest

voiduaodv_bad_dest(uip_ipaddr_t *dest){  struct uaodv_rt_entry *rt = uaodv_rt_lookup_any(dest);  if(rt == NULL)    bad_seqno = 0;		/* Or flag this in RERR? */  else {    rt->is_bad = 1;    bad_seqno = uip_htonl(rt->hseqno);  }  uip_ipaddr_copy(&bad_dest, dest);  command = COMMAND_SEND_RERR;  process_post(&uaodv_process, PROCESS_EVENT_MSG, NULL);}
开发者ID:Ammar-85,项目名称:osd-contiki,代码行数:16,


示例24: uip_ds6_maddr_add

/*---------------------------------------------------------------------------*/uip_ds6_maddr_t *uip_ds6_maddr_add(const uip_ipaddr_t *ipaddr){  if(uip_ds6_list_loop     ((uip_ds6_element_t *)uip_ds6_if.maddr_list, UIP_DS6_MADDR_NB,      sizeof(uip_ds6_maddr_t), (void*)ipaddr, 128,      (uip_ds6_element_t **)&locmaddr) == FREESPACE) {    locmaddr->isused = 1;    uip_ipaddr_copy(&locmaddr->ipaddr, ipaddr);    PRINTF("Adding maddr ");    PRINT6ADDR(&locmaddr->ipaddr);    PRINTF("/n");    return locmaddr;  }  return NULL;}
开发者ID:CurieBSP,项目名称:zephyr,代码行数:17,


示例25: uip_ds6_maddr_add

/*---------------------------------------------------------------------------*/uip_ds6_maddr_t *uip_ds6_maddr_add(uip_ipaddr_t *ipaddr){  if(uip_ds6_list_loop     ((uip_ds6_element_t *)uip_ds6_if.maddr_list, UIP_DS6_MADDR_NB,      sizeof(uip_ds6_maddr_t), ipaddr, 128,      (uip_ds6_element_t **)&locmaddr) == FREESPACE) {    locmaddr->isused = 1;    uip_ipaddr_copy(&locmaddr->ipaddr, ipaddr);#if UIP_CONF_MLD    uip_icmp6_mldv1_schedule_report(locmaddr);#endif    return locmaddr;  }  return NULL;}
开发者ID:dv1990,项目名称:hexabus,代码行数:17,


示例26: _udp_states_init

void _udp_states_init(void) {    debug_printf("UDP_STATES registert states (befor init) %x/n", udp_states_n_registert_states);    udp_states_n_registert_states=0; //no states are registert    debug_printf("UDP_STATES registert states (after init) %x/n", udp_states_n_registert_states);    udp_states_n_registert_callbacks=0; //no callbacks registert    uip_ipaddr_t io;    uip_ipaddr_copy (&ip, all_ones_addr);    uip_udp_conn_t *udp_states_connection = uip_udp_new (&ip, 0, _udp_states_process); //register the protocol    if (!udp_states_connection)        return;    uip_udp_bind (udp_states_connection, HTONS (UDP_STATES_PORT)); //bind the protocol to the Port}
开发者ID:asuro,项目名称:ethersex,代码行数:16,


示例27: vmm_netstack_send_icmp_echo

/** * uIP doesn't provide a mechanism to create a raw-IP packet so * we trigger the sending of ECHO_REQUEST by sending ourself an * ECHO_REPLY message with all-zeroes destination IP address. * * A global completion variable is used to notify the reception  * of the actual ECHO_REPLY */int vmm_netstack_send_icmp_echo(u8 *ripaddr, u16 size, u16 seqno, 			      struct vmm_icmp_echo_reply *reply){	struct vmm_mbuf *mbuf;	struct uip_icmp_echo_request *echo_req;	u16 all_zeroes_addr[] = {0, 0}; 	u8 *tmp;	u64 timeout = (u64)20000000000;	u16 ethsize;	/* Create a mbuf */	MGETHDR(mbuf, 0, 0);	ethsize = UIP_ICMP_LLH_LEN + UIP_ICMP_ECHO_DLEN;	MEXTMALLOC(mbuf, ethsize, 0);	mbuf->m_len = mbuf->m_pktlen = ethsize;	/* Skip the src & dst mac addresses as they will be filled by 	 * uip_netport_loopback_send */	tmp = mtod(mbuf, u8 *) + 12;	/* IPv4 ethertype */	*tmp++ = 0x08;	*tmp++ = 0x00;	/* Fillup the echo_request structure embedded in ICMP payload */	echo_req = (struct uip_icmp_echo_request *)(tmp + UIP_ICMP_IPH_LEN);	uip_ipaddr_copy(echo_req->ripaddr, ripaddr);	echo_req->len = size;	echo_req->seqno = seqno;	/* Fillup the IP header */	uip_create_ip_pkt(tmp, all_zeroes_addr, (ethsize - UIP_LLH_LEN));	/* Fillup the ICMP header at last as the icmpchksum is calculated 	 * over entire icmp message */	uip_create_icmp_pkt(tmp, ICMP_ECHO_REPLY, 			    (ethsize - UIP_LLH_LEN - UIP_IPH_LEN), 0);	/* Update pointer to store uip_ping_reply */	uip_ping_reply = reply;	/* Send the mbuf to self to trigger ICMP_ECHO */	uip_netport_loopback_send(mbuf);	/* Wait for the reply until timeout */	vmm_completion_wait_timeout(&uip_ping_done, &timeout);	/* The callback has copied the reply data before completing, so we	 * can safely set the pointer as NULL to prevent unwanted callbacks */	uip_ping_reply = NULL;	if(timeout == (u64)0) 		return VMM_EFAIL;	return VMM_OK;}
开发者ID:jhludwig,项目名称:xvisor,代码行数:55,


示例28: uip_ds6_defrt_add

/*---------------------------------------------------------------------------*/uip_ds6_defrt_t *uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval){  uip_ds6_defrt_t *d;#if DEBUG != DEBUG_NONE  assert_nbr_routes_list_sane();#endif /* DEBUG != DEBUG_NONE */  PRINTF("uip_ds6_defrt_add/n");  d = uip_ds6_defrt_lookup(ipaddr);  if(d == NULL) {    d = memb_alloc(&defaultroutermemb);    if(d == NULL) {      PRINTF("uip_ds6_defrt_add: could not add default route to ");      PRINT6ADDR(ipaddr);      PRINTF(", out of memory/n");      return NULL;    } else {      PRINTF("uip_ds6_defrt_add: adding default route to ");      PRINT6ADDR(ipaddr);      PRINTF("/n");    }    list_push(defaultrouterlist, d);  }  uip_ipaddr_copy(&d->ipaddr, ipaddr);  if(interval != 0) {    stimer_set(&d->lifetime, interval);    d->isinfinite = 0;  } else {    d->isinfinite = 1;  }  ANNOTATE("#L %u 1/n", ipaddr->u8[sizeof(uip_ipaddr_t) - 1]);#if UIP_DS6_NOTIFICATIONS  call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_ADD, ipaddr, ipaddr);#endif#if DEBUG != DEBUG_NONE  assert_nbr_routes_list_sane();#endif /* DEBUG != DEBUG_NONE */  return d;}
开发者ID:BaliAutomation,项目名称:contiki,代码行数:48,


示例29: uecmd_net_main

void uecmd_net_main() {	if (!uip_newdata ())		return;	char *p = (char *)uip_appdata;	/* Add /0 to the data and remove /n from the data */	do {		if (*p == '/r' || *p == '/n') {			break;		}	} while ( ++p <= ((char *)uip_appdata + uip_datalen()));	/* Parse the Data */	*p = 0;	char cmd[p - (char *)uip_appdata];	strncpy(cmd, uip_appdata, p - (char *)uip_appdata + 1);	uip_slen = 0;	while (uip_slen < UIP_BUFSIZE - UIP_IPUDPH_LEN) {		int16_t len = ecmd_parse_command(cmd, ((char *)uip_appdata) + uip_slen,						 (UIP_BUFSIZE - UIP_IPUDPH_LEN) - uip_slen);		uint8_t real_len = len;		if (!is_ECMD_FINAL(len)) { /* what about the errors ? */			/* convert ECMD_AGAIN back to ECMD_FINAL */			real_len = (uint8_t) ECMD_AGAIN(len);		}		uip_slen += real_len + 1;		((char *)uip_appdata)[uip_slen - 1] = '/n';		if (real_len == len || len == 0)			break;	}	/* Sent data out */	uip_udp_conn_t echo_conn;	uip_ipaddr_copy(echo_conn.ripaddr, BUF->srcipaddr);	echo_conn.rport = BUF->srcport;	echo_conn.lport = HTONS(ECMD_UDP_PORT);	uip_udp_conn = &echo_conn;	uip_process(UIP_UDP_SEND_CONN);	router_output();	uip_slen = 0;}
开发者ID:EtherGraf,项目名称:ethersex,代码行数:47,


示例30: send_to_peer

intsend_to_peer(struct dtls_context_t *ctx, 	     session_t *session, uint8 *data, size_t len) {  struct uip_udp_conn *conn = (struct uip_udp_conn *)dtls_get_app_data(ctx);  uip_ipaddr_copy(&conn->ripaddr, &session->addr);  conn->rport = session->port;  uip_udp_packet_send(conn, data, len);  /* Restore server connection to allow data from any node */  memset(&conn->ripaddr, 0, sizeof(conn->ripaddr));  memset(&conn->rport, 0, sizeof(conn->rport));  return len;}
开发者ID:Thonex,项目名称:tinydtls,代码行数:17,



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


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