这篇教程C++ tcpip_ipv6_output函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tcpip_ipv6_output函数的典型用法代码示例。如果您正苦于以下问题:C++ tcpip_ipv6_output函数的具体用法?C++ tcpip_ipv6_output怎么用?C++ tcpip_ipv6_output使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tcpip_ipv6_output函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: packet_input/*---------------------------------------------------------------------------*/static voidpacket_input(void){// printf("Tcpip: packet_input");// rpl_trace(rpl_dataptr_from_packetbuf());#if UIP_CONF_IP_FORWARD if(uip_len > 0) { tcpip_is_forwarding = 1; if(uip_fw_forward() == UIP_FW_LOCAL) { tcpip_is_forwarding = 0; check_for_tcp_syn(); uip_input(); if(uip_len > 0) {#if UIP_CONF_TCP_SPLIT uip_split_output();#else /* UIP_CONF_TCP_SPLIT */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else PRINTF("tcpip packet_input forward output len %d/n", uip_len); tcpip_output();#endif#endif /* UIP_CONF_TCP_SPLIT */ } } tcpip_is_forwarding = 0; }#else /* UIP_CONF_IP_FORWARD */ if(uip_len > 0) {// printf("Tcpip: packet_input 2");// rpl_trace(rpl_dataptr_from_packetbuf()); if(packetbuf_attr(PACKETBUF_ATTR_IS_ANYCAST)) { anycast_packet_received(); } check_for_tcp_syn(); uip_input(); if(uip_len > 0) {// printf("Tcpip: packet_input 3");// rpl_trace(rpl_dataptr_from_packetbuf());#if UIP_CONF_TCP_SPLIT uip_split_output();#else /* UIP_CONF_TCP_SPLIT */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else PRINTF("tcpip packet_input output len %d/n", uip_len); tcpip_output();#endif#endif /* UIP_CONF_TCP_SPLIT */ } }#endif /* UIP_CONF_IP_FORWARD */}
开发者ID:Johnyren,项目名称:orpl,代码行数:54,
示例2: packet_input/*---------------------------------------------------------------------------*/static voidpacket_input(void){ if(uip_len > 0) {#if UIP_CONF_IP_FORWARD tcpip_is_forwarding = 1; if(uip_fw_forward() != UIP_FW_LOCAL) { tcpip_is_forwarding = 0; return; } tcpip_is_forwarding = 0;#endif /* UIP_CONF_IP_FORWARD */ check_for_tcp_syn(); uip_input(); if(uip_len > 0) {#if UIP_CONF_TCP_SPLIT uip_split_output();#else /* UIP_CONF_TCP_SPLIT */#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else /* NETSTACK_CONF_WITH_IPV6 */ PRINTF("tcpip packet_input output len %d/n", uip_len); tcpip_output();#endif /* NETSTACK_CONF_WITH_IPV6 */#endif /* UIP_CONF_TCP_SPLIT */ } }}
开发者ID:1847123212,项目名称:ampm_contiki_wisun,代码行数:31,
示例3: send_ping/*---------------------------------------------------------------------------*/static voidsend_ping(uip_ipaddr_t *dest_addr)#if UIP_CONF_IPV6{ static uint16_t count; 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_ds6_if.cur_hop_limit; uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, dest_addr); uip_ds6_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((uint8_t *)UIP_ICMP_BUF + UIP_ICMPH_LEN, 0, 4); /* put one byte of data */ memset((uint8_t *)UIP_ICMP_BUF + UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN, count, PING_DATALEN); count++; uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN + PING_DATALEN; UIP_IP_BUF->len[0] = (uint8_t)((uip_len - 40) >> 8); UIP_IP_BUF->len[1] = (uint8_t)((uip_len - 40) & 0x00ff); UIP_ICMP_BUF->icmpchksum = 0; UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum(); tcpip_ipv6_output();}
开发者ID:21moons,项目名称:contiki,代码行数:33,
示例4: uip_udp_packet_send/*---------------------------------------------------------------------------*/voiduip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len){#if UIP_UDP if(data != NULL) { uip_udp_conn = c; uip_slen = len; memcpy(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], data, len > UIP_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN? UIP_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN: len); uip_process(UIP_UDP_SEND_CONN);#if UIP_CONF_IPV6_MULTICAST /* Let the multicast engine process the datagram before we send it */ if(uip_is_addr_mcast_routable(&uip_udp_conn->ripaddr)) { UIP_MCAST6.out(); }#endif /* UIP_IPV6_MULTICAST */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else if(uip_len > 0) { tcpip_output(); }#endif } uip_slen = 0;#endif /* UIP_UDP */}
开发者ID:200018171,项目名称:contiki,代码行数:31,
示例5: raven_ping6/* Sends a ping packet out the radio */static voidraven_ping6(void){ /* ping ipv6.google.com*/ uip_ip6addr(&ping_addr,0x2001,0x420,0x5FFF,0x7D,0x2D0,0xB7FF,0xFE23,0xE6DB); //uip_ip6addr(&ping_addr, 0x2001, 0x4860, 0, 0x2001, 0, 0, 0, 0x68); //uip_ip6addr(&ping_addr, 0xaaaa, 0, 0, 0, 0, 0, 0, 1); 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, &ping_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); uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN; 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:arbraham,项目名称:hummingbird,代码行数:32,
示例6: raven_ping6/* Sends a ping packet out the radio */static voidraven_ping6(uip_ipaddr_t *addr, int len){ UIP_IP_BUF->vtc = 0x60; UIP_IP_BUF->tcflow = 0; UIP_IP_BUF->flow = 0; UIP_IP_BUF->proto = UIP_PROTO_ICMP6; UIP_IP_BUF->ttl = UIP_TTL; uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, addr); uip_ds6_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, UIP_ICMP6_ECHO_REQUEST_LEN); /* put len bytes of all one data */ memset((void *)UIP_ICMP_BUF + UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN, 1, len); uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN + len; 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:kincki,项目名称:contiki,代码行数:30,
示例7: packet_input/*---------------------------------------------------------------------------*/static uint8_tpacket_input(struct net_buf *buf){ uint8_t ret = 0;#if UIP_CONF_IP_FORWARD if(uip_len > 0) { tcpip_is_forwarding = 1; if(uip_fw_forward() == UIP_FW_LOCAL) { tcpip_is_forwarding = 0; check_for_tcp_syn(); uip_input(); if(uip_len > 0) {#if UIP_CONF_TCP_SPLIT uip_split_output();#else /* UIP_CONF_TCP_SPLIT */#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else PRINTF("tcpip packet_input forward output len %d/n", uip_len); tcpip_output();#endif#endif /* UIP_CONF_TCP_SPLIT */ } } tcpip_is_forwarding = 0; }#else /* UIP_CONF_IP_FORWARD */ if(uip_len(buf) > 0) { check_for_tcp_syn(buf); ret = uip_input(buf); if(ret && uip_len(buf) > 0) {#if UIP_CONF_TCP_SPLIT uip_split_output(buf);#else /* UIP_CONF_TCP_SPLIT */#if NETSTACK_CONF_WITH_IPV6 PRINTF("tcpip packet_input output len %d/n", uip_len(buf)); ret = tcpip_ipv6_output(buf);#else PRINTF("tcpip packet_input output len %d/n", uip_len(buf)); ret = tcpip_output(buf, NULL);#endif#endif /* UIP_CONF_TCP_SPLIT */ } }#endif /* UIP_CONF_IP_FORWARD */ return ret;}
开发者ID:01org,项目名称:CODK-A-Firmware,代码行数:48,
示例8: packet_input/*---------------------------------------------------------------------------*/static voidpacket_input(void){#if UIP_CONF_IP_FORWARD if(uip_len > 0) { tcpip_is_forwarding = 1; if(uip_fw_forward() == UIP_FW_LOCAL) { tcpip_is_forwarding = 0; check_for_tcp_syn(); uip_input(); if(uip_len > 0) {#if UIP_CONF_TCP_SPLIT uip_split_output();#else /* UIP_CONF_TCP_SPLIT */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else PRINTF("tcpip packet_input forward output len %d/n", uip_len); tcpip_output();#endif#endif /* UIP_CONF_TCP_SPLIT */ } } tcpip_is_forwarding = 0; }#else /* UIP_CONF_IP_FORWARD */ if(uip_len > 0) { check_for_tcp_syn(); uip_input(); if(uip_len > 0) {#if UIP_CONF_TCP_SPLIT uip_split_output();#else /* UIP_CONF_TCP_SPLIT */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else PRINTF("tcpip packet_input output len %d/n", uip_len); tcpip_output();#endif#endif /* UIP_CONF_TCP_SPLIT */ } }#endif /* UIP_CONF_IP_FORWARD */}
开发者ID:kenog,项目名称:contiki-inga,代码行数:45,
示例9: uip_ds6_send_ra_unicast_sollicitedvoiduip_ds6_send_ra_unicast_sollicited(uip_ipaddr_t *dest){ for(locbr = uip_ds6_br_list; locbr < uip_ds6_br_list + UIP_DS6_BR_NB; locbr++) { uip_nd6_ra_output(dest, locbr); tcpip_ipv6_output(); }}
开发者ID:sdefauw,项目名称:contiki,代码行数:10,
示例10: etimer_callbackvoid etimer_callback(struct etimer* et){#if NETSTACK_CONF_WITH_IPV6 #if !UIP_CONF_ROUTER if (et == &uip_ds6_timer_rs) { uip_ds6_send_rs(); tcpip_ipv6_output(); }#endif if (et == &uip_ds6_timer_periodic) { uip_ds6_periodic(); tcpip_ipv6_output(); }#endif}
开发者ID:AriZuu,项目名称:picoos-net,代码行数:20,
示例11: packet_input/*---------------------------------------------------------------------------*/static voidpacket_input(void){ if(uip_len > 0) { check_for_tcp_syn(); uip_input(); if(uip_len > 0) {#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else /* NETSTACK_CONF_WITH_IPV6 */ tcpip_output();#endif /* NETSTACK_CONF_WITH_IPV6 */ } }}
开发者ID:martinabr,项目名称:laneflood,代码行数:16,
示例12: 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,
示例13: raven_ping6/* Useful for debugging so allow external calls */voidraven_ping6(void){#define PING_GOOGLE 0 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_ds6_if.cur_hop_limit;#if PING_GOOGLE if (seqno==1) { uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, uip_ds6_defrt_choose()); //the default router } else if (seqno==2) { uip_ip6addr(&UIP_IP_BUF->destipaddr,0x2001,0x4860,0x800f,0x0000,0x0000,0x0000,0x0000,0x0093); //ipv6.google.com } else if (seqno==3) { uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, uip_ds6_defrt_choose()); //the default router } else {// uip_ip6addr(&UIP_IP_BUF->destipaddr,0x2001,0x0420,0x5FFF,0x007D,0x02D0,0xB7FF,0xFE23,0xE6DB); //?.cisco.com uip_ip6addr(&UIP_IP_BUF->destipaddr,0x2001,0x0420,0x0000,0x0010,0x0250,0x8bff,0xfee8,0xf800); //six.cisco.com } #else uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, uip_ds6_defrt_choose()); //the default router#endif uip_ds6_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] = (uint8_t)((uip_len - 40) >> 8); UIP_IP_BUF->len[1] = (uint8_t)((uip_len - 40) & 0x00FF); UIP_ICMP_BUF->icmpchksum = 0; UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum(); tcpip_ipv6_output();}
开发者ID:1uk3,项目名称:contiki,代码行数:46,
示例14: send_purge_navoidsend_purge_na(uip_ipaddr_t *prefix){ if ( (nvm_data.mode & CETIC_MODE_SMART_MULTI_BR) == 0 ) { return; } LOG6LBR_6ADDR(INFO, prefix, "Sending purge NA for "); uip_ext_len = 0; UIP_IP_BUF->vtc = 0x60; UIP_IP_BUF->tcflow = 0; UIP_IP_BUF->flow = 0; UIP_IP_BUF->len[0] = 0; /* length will not be more than 255 */ UIP_IP_BUF->len[1] = UIP_ICMPH_LEN + UIP_ND6_NA_LEN + UIP_ND6_OPT_LLAO_LEN; UIP_IP_BUF->proto = UIP_PROTO_ICMP6; UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT; uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr); uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, prefix); UIP_ICMP_BUF->type = ICMP6_NA; UIP_ICMP_BUF->icode = 0; UIP_ND6_NA_BUF->flagsreserved = UIP_ND6_NA_FLAG_OVERRIDE; memcpy(&UIP_ND6_NA_BUF->tgtipaddr, prefix, sizeof(uip_ipaddr_t)); create_llao(&uip_buf[uip_l2_l3_icmp_hdr_len + UIP_ND6_NA_LEN], UIP_ND6_OPT_TLLAO); UIP_ICMP_BUF->icmpchksum = 0; UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum(); uip_len = UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_NA_LEN + UIP_ND6_OPT_LLAO_LEN; UIP_STAT(++uip_stat.nd6.sent); PRINTF("Sending Unsolicited NA to "); PRINT6ADDR(&UIP_IP_BUF->destipaddr); PRINTF(" from "); PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF(" with target address "); PRINT6ADDR(&UIP_ND6_NA_BUF->tgtipaddr); PRINTF("/n"); tcpip_ipv6_output();}
开发者ID:drandreas,项目名称:6lbr,代码行数:44,
示例15: ping6handler/*---------------------------------------------------------------------------*/static voidping6handler(){ if(count < PING6_NB) { 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_ds6_if.cur_hop_limit; uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &dest_addr); uip_ds6_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((uint8_t *)UIP_ICMP_BUF + UIP_ICMPH_LEN, 0, 4); /* put one byte of data */ memset((uint8_t *)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] = (uint8_t)((uip_len - 40) >> 8); UIP_IP_BUF->len[1] = (uint8_t)((uip_len - 40) & 0x00FF); UIP_ICMP_BUF->icmpchksum = 0; UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum(); PRINTF("Echo Request to "); PRINT6ADDR(&UIP_IP_BUF->destipaddr); PRINTF(" from "); PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF("/n"); UIP_STAT(++uip_stat.icmp.sent); tcpip_ipv6_output(); count++; etimer_set(&ping6_periodic_timer, 3 * CLOCK_SECOND); } else {
开发者ID:naguirre,项目名称:calaos-wireless-sensor-network,代码行数:43,
示例16: uip_udp_packet_send/*---------------------------------------------------------------------------*/voiduip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len){#if UIP_UDP if(data != NULL) { uip_udp_conn = c; uip_slen = len; memcpy(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], data, len > UIP_BUFSIZE? UIP_BUFSIZE: len); uip_process(UIP_UDP_SEND_CONN);#if UIP_CONF_IPV6 tcpip_ipv6_output();#else if(uip_len > 0) { tcpip_output(); }#endif } uip_slen = 0;#endif /* UIP_UDP */}
开发者ID:GregStoreX,项目名称:contiki,代码行数:22,
示例17: uip_split_output/*-----------------------------------------------------------------------------*/voiduip_split_output(void){#if UIP_TCP u16_t tcplen, len1, len2; /* We only try to split maximum sized TCP segments. */ if(BUF->proto == UIP_PROTO_TCP && uip_len == UIP_BUFSIZE) { tcplen = uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN; /* Split the segment in two. If the original packet length was odd, we make the second packet one byte larger. */ len1 = len2 = tcplen / 2; if(len1 + len2 < tcplen) { ++len2; } /* Create the first packet. This is done by altering the length field of the IP header and updating the checksums. */ uip_len = len1 + UIP_TCPIP_HLEN + UIP_LLH_LEN;#if UIP_CONF_IPV6 /* For IPv6, the IP length field does not include the IPv6 IP header length. */ BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);#else /* UIP_CONF_IPV6 */ BUF->len[0] = (uip_len - UIP_LLH_LEN) >> 8; BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;#endif /* UIP_CONF_IPV6 */ /* Recalculate the TCP checksum. */ BUF->tcpchksum = 0; BUF->tcpchksum = ~(uip_tcpchksum());#if !UIP_CONF_IPV6 /* Recalculate the IP checksum. */ BUF->ipchksum = 0; BUF->ipchksum = ~(uip_ipchksum());#endif /* UIP_CONF_IPV6 */ /* Transmit the first packet. */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);#endif /* UIP_CONF_IPV6 */ /* Now, create the second packet. To do this, it is not enough to just alter the length field, but we must also update the TCP sequence number and point the uip_appdata to a new place in memory. This place is determined by the length of the first packet (len1). */ uip_len = len2 + UIP_TCPIP_HLEN + UIP_LLH_LEN;#if UIP_CONF_IPV6 /* For IPv6, the IP length field does not include the IPv6 IP header length. */ BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);#else /* UIP_CONF_IPV6 */ BUF->len[0] = (uip_len - UIP_LLH_LEN) >> 8; BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;#endif /* UIP_CONF_IPV6 */ memcpy(uip_appdata, (u8_t *)uip_appdata + len1, len2); uip_add32(BUF->seqno, len1); BUF->seqno[0] = uip_acc32[0]; BUF->seqno[1] = uip_acc32[1]; BUF->seqno[2] = uip_acc32[2]; BUF->seqno[3] = uip_acc32[3]; /* Recalculate the TCP checksum. */ BUF->tcpchksum = 0; BUF->tcpchksum = ~(uip_tcpchksum());#if !UIP_CONF_IPV6 /* Recalculate the IP checksum. */ BUF->ipchksum = 0; BUF->ipchksum = ~(uip_ipchksum());#endif /* UIP_CONF_IPV6 */ /* Transmit the second packet. */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);#endif /* UIP_CONF_IPV6 */ return; }
开发者ID:AmesianX,项目名称:OpenPCR,代码行数:90,
示例18: eventhandler/*---------------------------------------------------------------------------*/static voideventhandler(c_event_t ev, p_data_t data){#if UIP_TCP static unsigned char i;// register struct listenport *l;#endif /*UIP_TCP*/ switch(ev) { case EVENT_TYPE_TIMER_EXP: /* We get this event if one of our timers have expired. */ { /* Check the clock so see if we should call the periodic uIP processing. */ if(data == &periodic && etimer_expired(&periodic)) {#if UIP_TCP for(i = 0; i < UIP_CONNS; ++i) { if(uip_conn_active(i)) { /* Only restart the timer if there are active connections. */ etimer_restart(&periodic); uip_periodic(i);#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else if(uip_len > 0) { PRINTF("tcpip_output from periodic len %d/n/r", uip_len); tcpip_output(); PRINTF("tcpip_output after periodic len %d/n/r", uip_len); }#endif /* NETSTACK_CONF_WITH_IPV6 */ } }#endif /* UIP_TCP */#if UIP_CONF_IP_FORWARD uip_fw_periodic();#endif /* UIP_CONF_IP_FORWARD */ } #if NETSTACK_CONF_WITH_IPV6#if UIP_CONF_IPV6_REASSEMBLY /* * check the timer for reassembly */ if(data == &uip_reass_timer && etimer_expired(&uip_reass_timer)) { uip_reass_over(); tcpip_ipv6_output(); }#endif /* UIP_CONF_IPV6_REASSEMBLY */ /* * check the different timers for neighbor discovery and * stateless autoconfiguration */ /*if(data == &uip_ds6_timer_periodic && etimer_expired(&uip_ds6_timer_periodic)) { uip_ds6_periodic(); tcpip_ipv6_output(); }*/#if !UIP_CONF_ROUTER if(data == &uip_ds6_timer_rs && etimer_expired(&uip_ds6_timer_rs)) { uip_ds6_send_rs(); tcpip_ipv6_output(); }#endif /* !UIP_CONF_ROUTER */ if(data == &uip_ds6_timer_periodic && etimer_expired(&uip_ds6_timer_periodic)) { uip_ds6_periodic(); tcpip_ipv6_output(); }#endif /* NETSTACK_CONF_WITH_IPV6 */ } break; #if UIP_TCP case EVENT_TYPE_TCP_POLL: if(data != NULL) { uip_poll_conn(data);#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else /* NETSTACK_CONF_WITH_IPV6 */ if(uip_len > 0) { PRINTF("tcpip_output from tcp poll len %d/n/r", uip_len); tcpip_output(); }#endif /* NETSTACK_CONF_WITH_IPV6 */ /* Start the periodic polling, if it isn't already active. */ start_periodic_tcp_timer(); } break;#endif /* UIP_TCP */#if UIP_UDP case EVENT_TYPE_UDP_POLL: if(data != NULL) { uip_udp_periodic_conn(data);#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();//.........这里部分代码省略.........
开发者ID:kamejoko80,项目名称:emb6,代码行数:101,
示例19: xtcp_process_timer/* ----------------------------------------------------------------------------- * Process periodical stuff. * * In contiki, this is handlet by the eventhandler of the tcpip.c file * with the process event "PROCESS_EVENT_TIMER". * -------------------------------------------------------------------------- */void xtcp_process_timer(chanend mac_tx, xtcp_tmr_event_type_t event){#if UIP_IGMP igmp_periodic(); if(uip_len > 0) { xtcp_tx_buffer(mac_tx); }#endif if(event == XTCP_TMR_PERIODIC) {#if UIP_TCP for(int i = 0; i < UIP_CONNS; ++i) { if(uip_conn_active(i)) { uip_periodic(i);#if UIP_CONF_IPV6 xtcpip_ipv6_output(mac_tx);#else if(uip_len > 0) { PRINTF("tcpip_output from periodic len %d/n", uip_len); tcpip_output(); PRINTF("tcpip_output after periodic len %d/n", uip_len); }#endif /* UIP_CONF_IPV6 */ } }#endif /* UIP_TCP */#if UIP_CONF_IP_FORWARD uip_fw_periodic();#endif /* UIP_CONF_IP_FORWARD */ } /*XXX CHSC HACK*/#if UIP_CONF_IPV6#if UIP_CONF_IPV6_REASSEMBLY /* * check the timer for reassembly */ if(etimer_expired(&uip_reass_timer)) { uip_reass_over(); tcpip_ipv6_output(); }#endif /* UIP_CONF_IPV6_REASSEMBLY */ /* * check the different timers for neighbor discovery and * stateless autoconfiguration */ /*if(data == &uip_ds6_timer_periodic && etimer_expired(&uip_ds6_timer_periodic)) { uip_ds6_periodic(); tcpip_ipv6_output(); }*/#if !UIP_CONF_ROUTER if(etimer_expired(&uip_ds6_timer_rs)) { uip_ds6_send_rs(); xtcpip_ipv6_output(mac_tx); }#endif /* !UIP_CONF_ROUTER */ if(etimer_expired(&uip_ds6_timer_periodic)) { uip_ds6_periodic(); xtcpip_ipv6_output(mac_tx); }#endif /* UIP_CONF_IPV6 */}
开发者ID:graymalkin,项目名称:sc_xtcp,代码行数:69,
示例20: ping6handler/*---------------------------------------------------------------------------*/static uint8_tping6handler(process_event_t ev, process_data_t data){ if(count == 0){#if MACDEBUG // Setup destination address. addr[0] = 0xFE80; addr[4] = 0x6466; addr[5] = 0x6666; addr[6] = 0x6666; addr[7] = 0x6666; uip_ip6addr(&dest_addr, addr[0], addr[1],addr[2], addr[3],addr[4],addr[5],addr[6],addr[7]); // Set the command to fool the 'if' below. memcpy(command, (void *)"ping6", 5);#else/* prompt */ printf("> "); /** /note the scanf here is blocking (the all stack is blocked waiting * for user input). This is far from ideal and could be improved */ // scanf("%s", command); command[0] = 'p'; command[1] = 'i'; command[2] = 'n'; command[3] = 'g'; command[4] = '6'; if(strcmp(command,"ping6") != 0){ PRINTF("> invalid command/n"); return 0; } /* if(scanf(" %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x", &addr[0],&addr[1],&addr[2],&addr[3], &addr[4],&addr[5],&addr[6],&addr[7]) == 8){*/ uip_ip6addr(&dest_addr, addr[0], addr[1],addr[2], addr[3],addr[4],addr[5],addr[6],addr[7]); /* } else { PRINTF("> invalid ipv6 address format/n"); return 0; }*/#endif } if((strcmp(command,"ping6") == 0) && (count < PING6_NB)){ 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_ds6_if.cur_hop_limit; uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &dest_addr); uip_ds6_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((uint8_t *)UIP_ICMP_BUF + UIP_ICMPH_LEN, 0, 4); /* put one byte of data */ memset((uint8_t *)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] = (uint8_t)((uip_len - 40) >> 8); UIP_IP_BUF->len[1] = (uint8_t)((uip_len - 40) & 0x00FF); UIP_ICMP_BUF->icmpchksum = 0; UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum(); PRINTF("Sending Echo Request to"); PRINT6ADDR(&UIP_IP_BUF->destipaddr); PRINTF("from"); PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF("/n"); UIP_STAT(++uip_stat.icmp.sent); tcpip_ipv6_output(); count++; etimer_set(&ping6_periodic_timer, 3 * CLOCK_SECOND); return 1; }
开发者ID:GhaziAMOR,项目名称:contiki-2.7_workspace,代码行数:89,
示例21: packet_input/*---------------------------------------------------------------------------*/static voidpacket_input(void){#if FORWARDER rpl_instance_t *instance; uint8_t octet; uint8_t ip6id; int rssi_temp; uint8_t send_rssi; rimeaddr_t packet_from_addr; packet_from_addr = *packetbuf_addr(PACKETBUF_ADDR_SENDER); instance = &instance_table[0]; octet = packet_from_addr.u8[7]; ip6id = (octet & 0b00111111) << 2; tcp_rssi = packetbuf_attr(PACKETBUF_ATTR_RSSI); if(is_mobile_node(octet) == 1) { packet_input_count++; rssi_temp = tcp_rssi - 45; if(tcp_rssi > 200) { rssi_temp = tcp_rssi - 255 - 46; } rssi_sum += rssi_temp; if(packet_input_count == WINDOW_SIZE) { rssi_sum = rssi_sum / WINDOW_SIZE; PRINTF("RSSI = %d/n", rssi_sum); PRINTF("packet input count = %d/n", packet_input_count); if(rssi_sum <= -90) { send_rssi = rssi_sum + 255 + 46; dis_output(NULL, 1, 0, send_rssi, ip6id); } rssi_sum = 0; packet_input_count = 0; } }#endif#if UIP_CONF_IP_FORWARD if(uip_len > 0) { tcpip_is_forwarding = 1; if(uip_fw_forward() == UIP_FW_LOCAL) { tcpip_is_forwarding = 0; check_for_tcp_syn(); uip_input(); if(uip_len > 0) {#if UIP_CONF_TCP_SPLIT uip_split_output();#else /* UIP_CONF_TCP_SPLIT */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else PRINTF("tcpip packet_input forward output len %d/n", uip_len); tcpip_output();#endif#endif /* UIP_CONF_TCP_SPLIT */ } } tcpip_is_forwarding = 0; }#else /* UIP_CONF_IP_FORWARD */ if(uip_len > 0) { check_for_tcp_syn(); uip_input(); if(uip_len > 0) {#if UIP_CONF_TCP_SPLIT uip_split_output();#else /* UIP_CONF_TCP_SPLIT */#if UIP_CONF_IPV6 tcpip_ipv6_output();#else PRINTF("tcpip packet_input output len %d/n", uip_len); tcpip_output();#endif#endif /* UIP_CONF_TCP_SPLIT */ } }#endif /* UIP_CONF_IP_FORWARD */}
开发者ID:jiangxianliang,项目名称:smart-HOP,代码行数:80,
示例22: netMainThreadvoid netMainThread(void* arg){ uint8_t i;#if !NETSTACK_CONF_WITH_IPV6 POSTIMER_t arpTimer;#endif POSTIMER_t periodicTimer; int sendRequested; bool packetSeen;#if !NETSTACK_CONF_WITH_IPV6 arpTimer = posTimerCreate(); P_ASSERT("netMainThread1", arpTimer != NULL); posTimerSet(arpTimer, uipGiant, MS(10000), MS(10000)); posTimerStart(arpTimer);#endif periodicTimer = posTimerCreate(); P_ASSERT("netMainThread2", periodicTimer != NULL); posTimerSet(periodicTimer, uipGiant, MS(500), MS(500)); posTimerStart(periodicTimer); posMutexLock(uipMutex); packetSeen = false; while(1) { posMutexUnlock(uipMutex); // Using semaphore here is not fully optimal. // As it is a counting one, it can get bumped // to larger value than 1 by upper or interrupt // layer. However, not much harm is done, // this loop just spins extra times without // doing nothing useful. // A Pico]OS Flag object would be perfect, // but it doesn't work with posTimer* functions. if (!packetSeen || pollTicks == INFINITE) posSemaWait(uipGiant, pollTicks); posMutexLock(uipMutex); sendRequested = dataToSend; dataToSend = 0; packetSeen = false; if (sendRequested) { for(i = 0; i < UIP_CONNS; i++) { uip_len = 0; uip_poll_conn(&uip_conns[i]); if(uip_len > 0) {#if NETCFG_UIP_SPLIT == 1 uip_split_output();#else#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else tcpip_output();#endif#endif } }#if UIP_UDP for(i = 0; i < UIP_UDP_CONNS; i++) { uip_len = 0; uip_udp_periodic(i); if(uip_len > 0) {#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else tcpip_output();#endif } }#endif /* UIP_UDP */ } packetSeen = netInterfacePoll(); if (posTimerFired(periodicTimer)) { for(i = 0; i < UIP_CONNS; i++) { uip_periodic(i); if(uip_len > 0) {#if NETCFG_UIP_SPLIT == 1 uip_split_output();//.........这里部分代码省略.........
开发者ID:AriZuu,项目名称:picoos-net,代码行数:101,
示例23: eventhandler/*---------------------------------------------------------------------------*/static voideventhandler(process_event_t ev, process_data_t data){#if UIP_TCP static unsigned char i; register struct listenport *l;#endif /*UIP_TCP*/ struct process *p; switch(ev) { case PROCESS_EVENT_EXITED: /* This is the event we get if a process has exited. We go through the TCP/IP tables to see if this process had any open connections or listening TCP ports. If so, we'll close those connections. */ p = (struct process *)data;#if UIP_TCP l = s.listenports; for(i = 0; i < UIP_LISTENPORTS; ++i) { if(l->p == p) { uip_unlisten(l->port); l->port = 0; l->p = PROCESS_NONE; } ++l; } { struct uip_conn *cptr; for(cptr = &uip_conns[0]; cptr < &uip_conns[UIP_CONNS]; ++cptr) { if(cptr->appstate.p == p) { cptr->appstate.p = PROCESS_NONE; cptr->tcpstateflags = UIP_CLOSED; } } }#endif /* UIP_TCP */#if UIP_UDP { struct uip_udp_conn *cptr; for(cptr = &uip_udp_conns[0]; cptr < &uip_udp_conns[UIP_UDP_CONNS]; ++cptr) { if(cptr->appstate.p == p) { cptr->lport = 0; } } }#endif /* UIP_UDP */ break; case PROCESS_EVENT_TIMER: /* We get this event if one of our timers have expired. */ { /* Check the clock so see if we should call the periodic uIP processing. */ if(data == &periodic && etimer_expired(&periodic)) {#if UIP_TCP for(i = 0; i < UIP_CONNS; ++i) { if(uip_conn_active(i)) { /* Only restart the timer if there are active connections. */ etimer_restart(&periodic); uip_periodic(i);#if UIP_CONF_IPV6 tcpip_ipv6_output();#else if(uip_len > 0) { PRINTF("tcpip_output from periodic len %d/n", uip_len); tcpip_output(); PRINTF("tcpip_output after periodic len %d/n", uip_len); }#endif /* UIP_CONF_IPV6 */ } }#endif /* UIP_TCP */#if UIP_CONF_IP_FORWARD uip_fw_periodic();#endif /* UIP_CONF_IP_FORWARD */ }#if UIP_CONF_IPV6#if UIP_CONF_IPV6_REASSEMBLY /* * check the timer for reassembly */ if(data == &uip_reass_timer && etimer_expired(&uip_reass_timer)) { uip_reass_over(); tcpip_ipv6_output(); }#endif /* UIP_CONF_IPV6_REASSEMBLY */ /* * check the different timers for neighbor discovery and * stateless autoconfiguration *///.........这里部分代码省略.........
开发者ID:kenog,项目名称:contiki-inga,代码行数:101,
示例24: tcpip_ipv6_outputvoidtcpip_ipv6_output(void){ uip_ds6_nbr_t *nbr = NULL; uip_ipaddr_t *nexthop; if(uip_len == 0) { return; } if(uip_len > UIP_LINK_MTU) { UIP_LOG("tcpip_ipv6_output: Packet to big"); uip_clear_buf(); return; } if(uip_is_addr_unspecified(&UIP_IP_BUF->destipaddr)){ UIP_LOG("tcpip_ipv6_output: Destination address unspecified"); uip_clear_buf(); return; } if(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { /* Next hop determination */ nbr = NULL; /* We first check if the destination address is on our immediate link. If so, we simply use the destination address as our nexthop address. */ if(uip_ds6_is_addr_onlink(&UIP_IP_BUF->destipaddr)){ nexthop = &UIP_IP_BUF->destipaddr; } else { uip_ds6_route_t *route; /* Check if we have a route to the destination address. */ route = uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr); /* No route was found - we send to the default route instead. */ if(route == NULL) { PRINTF("tcpip_ipv6_output: no route found, using default route/n"); nexthop = uip_ds6_defrt_choose(); if(nexthop == NULL) {#ifdef UIP_FALLBACK_INTERFACE PRINTF("FALLBACK: removing ext hdrs & setting proto %d %d/n", uip_ext_len, *((uint8_t *)UIP_IP_BUF + 40)); if(uip_ext_len > 0) { extern void remove_ext_hdr(void); uint8_t proto = *((uint8_t *)UIP_IP_BUF + 40); remove_ext_hdr(); /* This should be copied from the ext header... */ UIP_IP_BUF->proto = proto; } /* Inform the other end that the destination is not reachable. If it's * not informed routes might get lost unexpectedly until there's a need * to send a new packet to the peer */ if(UIP_FALLBACK_INTERFACE.output() < 0) { PRINTF("FALLBACK: output error. Reporting DST UNREACH/n"); uip_icmp6_error_output(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0); uip_flags = 0; tcpip_ipv6_output(); return; }#else PRINTF("tcpip_ipv6_output: Destination off-link but no route/n");#endif /* !UIP_FALLBACK_INTERFACE */ uip_clear_buf(); return; } } else { /* A route was found, so we look up the nexthop neighbor for the route. */ nexthop = uip_ds6_route_nexthop(route); /* If the nexthop is dead, for example because the neighbor never responded to link-layer acks, we drop its route. */ if(nexthop == NULL) {#if UIP_CONF_IPV6_RPL /* If we are running RPL, and if we are the root of the network, we'll trigger a global repair berfore we remove the route. */ rpl_dag_t *dag; rpl_instance_t *instance; dag = (rpl_dag_t *)route->state.dag; if(dag != NULL) { instance = dag->instance; rpl_repair_root(instance->instance_id); }#endif /* UIP_CONF_IPV6_RPL */ uip_ds6_route_rm(route); /* We don't have a nexthop to send the packet to, so we drop it. */ return; } }#if TCPIP_CONF_ANNOTATE_TRANSMISSIONS if(nexthop != NULL) { static uint8_t annotate_last;//.........这里部分代码省略.........
开发者ID:1847123212,项目名称:ampm_contiki_wisun,代码行数:101,
示例25: smcp_plat_outbound_finishsmcp_status_tsmcp_plat_outbound_finish(smcp_t self,const uint8_t* data_ptr, coap_size_t data_len, int flags){ SMCP_EMBEDDED_SELF_HOOK; smcp_status_t ret = SMCP_STATUS_FAILURE; assert(uip_udp_conn == self->plat.udp_conn); uip_slen = data_len; require_action(uip_slen<SMCP_MAX_PACKET_LENGTH, bail, ret = SMCP_STATUS_MESSAGE_TOO_BIG); if (data_ptr != uip_sappdata) { memmove( uip_sappdata, data_ptr, uip_slen ); data_ptr = (const uint8_t*)uip_sappdata; }#if 0 // TODO: For some reason this isn't working anymore. Investigate. if(self->is_responding) { // We are responding, let uIP handle preparing the packet. } else#endif { // Here we explicitly tickle UIP to send the packet. // Change the remote IP address temporarily. uip_ipaddr_copy(&uip_udp_conn->ripaddr, &self->plat.sockaddr_remote.smcp_addr); smcp_get_current_instance()->plat.udp_conn->rport = self->plat.sockaddr_remote.smcp_port; uip_process(UIP_UDP_SEND_CONN);#if UIP_CONF_IPV6_MULTICAST /* Let the multicast engine process the datagram before we send it */ if (uip_is_addr_mcast_routable(&uip_udp_conn->ripaddr)) { UIP_MCAST6.out(); }#endif /* UIP_IPV6_MULTICAST */ // TODO: This next part is somewhat contiki-ish. Abstract somehow?#if UIP_CONF_IPV6 tcpip_ipv6_output();#else tcpip_output();#endif // Since we just sent out packet, we need to zero out uip_slen // to prevent uIP from trying to send out a packet. uip_slen = 0; // Make our remote address unspecified again, so that we can continue // to receive traffic. memset(&smcp_get_current_instance()->plat.udp_conn->ripaddr, 0, sizeof(uip_ipaddr_t)); smcp_get_current_instance()->plat.udp_conn->rport = 0; } ret = SMCP_STATUS_OK;bail: return ret;}
开发者ID:robbie-cao,项目名称:smcp,代码行数:64,
示例26: uip_split_output/*-----------------------------------------------------------------------------*/voiduip_split_output(void){#if UIP_TCP uint16_t tcplen, len1, len2; /* We only split TCP segments that are larger than or equal to UIP_SPLIT_SIZE, which is configurable through UIP_SPLIT_CONF_SIZE. */ if(BUF->proto == UIP_PROTO_TCP && uip_len >= UIP_SPLIT_SIZE + UIP_TCPIP_HLEN) { tcplen = uip_len - UIP_TCPIP_HLEN; /* Split the segment in two. If the original packet length was odd, we make the second packet one byte larger. */ len1 = len2 = tcplen / 2; if(len1 + len2 < tcplen) { ++len2; } /* Create the first packet. This is done by altering the length field of the IP header and updating the checksums. */ uip_len = len1 + UIP_TCPIP_HLEN;#if NETSTACK_CONF_WITH_IPV6 /* For IPv6, the IP length field does not include the IPv6 IP header length. */ BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);#else /* NETSTACK_CONF_WITH_IPV6 */ BUF->len[0] = uip_len >> 8; BUF->len[1] = uip_len & 0xff;#endif /* NETSTACK_CONF_WITH_IPV6 */ /* Recalculate the TCP checksum. */ BUF->tcpchksum = 0; BUF->tcpchksum = ~(uip_tcpchksum());#if !NETSTACK_CONF_WITH_IPV6 /* Recalculate the IP checksum. */ BUF->ipchksum = 0; BUF->ipchksum = ~(uip_ipchksum());#endif /* NETSTACK_CONF_WITH_IPV6 */ /* Transmit the first packet. */ /* uip_fw_output();*/#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else tcpip_output();#endif /* NETSTACK_CONF_WITH_IPV6 */ /* Now, create the second packet. To do this, it is not enough to just alter the length field, but we must also update the TCP sequence number and point the uip_appdata to a new place in memory. This place is detemined by the length of the first packet (len1). */ uip_len = len2 + UIP_TCPIP_HLEN;#if NETSTACK_CONF_WITH_IPV6 /* For IPv6, the IP length field does not include the IPv6 IP header length. */ BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);#else /* NETSTACK_CONF_WITH_IPV6 */ BUF->len[0] = uip_len >> 8; BUF->len[1] = uip_len & 0xff;#endif /* NETSTACK_CONF_WITH_IPV6 */ /* uip_appdata += len1;*/ memcpy(uip_appdata, (uint8_t *)uip_appdata + len1, len2); uip_add32(BUF->seqno, len1); BUF->seqno[0] = uip_acc32[0]; BUF->seqno[1] = uip_acc32[1]; BUF->seqno[2] = uip_acc32[2]; BUF->seqno[3] = uip_acc32[3]; /* Recalculate the TCP checksum. */ BUF->tcpchksum = 0; BUF->tcpchksum = ~(uip_tcpchksum());#if !NETSTACK_CONF_WITH_IPV6 /* Recalculate the IP checksum. */ BUF->ipchksum = 0; BUF->ipchksum = ~(uip_ipchksum());#endif /* NETSTACK_CONF_WITH_IPV6 */ /* Transmit the second packet. */ /* uip_fw_output();*/#if NETSTACK_CONF_WITH_IPV6 tcpip_ipv6_output();#else tcpip_output();#endif /* NETSTACK_CONF_WITH_IPV6 */ return; }
开发者ID:13416795,项目名称:contiki,代码行数:96,
注:本文中的tcpip_ipv6_output函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tcpip_output函数代码示例 C++ tcpip_init函数代码示例 |