예제 #1
0
/*---------------------------------------------------------------------------*/
static void
packet_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 */
    }
  }
}
예제 #2
0
/*---------------------------------------------------------------------------*/
static uint8_t
packet_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;
}
예제 #3
0
파일: tcpip.c 프로젝트: kenog/contiki-inga
/*---------------------------------------------------------------------------*/
static void
packet_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 */
}
예제 #4
0
파일: tcpip.c 프로젝트: martinabr/laneflood
/*---------------------------------------------------------------------------*/
static void
packet_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 */
		}
	}
}
예제 #5
0
/*---------------------------------------------------------------------------*/
static void
packet_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 */
}
예제 #6
0
/* -----------------------------------------------------------------------------
 * \brief      Deliver an incoming packet to the TCP/IP stack
 *
 *             This function is called by theServer to
 *             deliver an incoming packet to the TCP/IP stack. The
 *             incoming packet must be present in the uip_buf buffer,
 *             and the length of the packet must be in the global
 *             uip_len variable.
 * -------------------------------------------------------------------------- */
void xtcpip_input(chanend mac_tx)
{
/*_______________*/
#if UIP_CONF_IPV4 /* ORIGINAL_XMOS */
	if (BUF->type == htons(UIP_ETHTYPE_IP)) {
		uip_arp_ipin();
		uip_input();
		if (uip_len > 0) {
			if (uip_udpconnection()
				&& (TCPBUF->proto != UIP_PROTO_ICMP)
				&& (TCPBUF->proto != UIP_PROTO_IGMP))
				uip_arp_out( uip_udp_conn);
			else
				uip_arp_out( NULL);
			xtcp_tx_buffer(mac_tx);
		}
	} else if (BUF->type == htons(UIP_ETHTYPE_ARP)) {
		uip_arp_arpin();

		if (uip_len > 0) {
			xtcp_tx_buffer(mac_tx);
		}
		for (int i = 0; i < UIP_UDP_CONNS; i++) {
			uip_udp_arp_event(i);
			if (uip_len > 0) {
				uip_arp_out(&uip_udp_conns[i]);
				xtcp_tx_buffer(mac_tx);
			}
		}
	}
#endif /* UIP_CONF_IPV4 ORIGINAL_XMOS */
/*_______________*/
	/* contiki tcpip.c */
#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(mac_tx);
#else /* UIP_CONF_TCP_SPLIT */
#if UIP_CONF_IPV6
        xtcpip_ipv6_output(mac_tx);
#else
	PRINTF("tcpip packet_input forward output len %d\n", uip_len);
        xtcpip_output(mac_tx);
#endif
#endif /* UIP_CONF_TCP_SPLIT */
      }
    }
    tcpip_is_forwarding = 0;
  }
#else /* UIP_CONF_IP_FORWARD */
  if(uip_len > 0) {
    uip_input();
    if(uip_len > 0) {
#if UIP_CONF_TCP_SPLIT
      uip_split_output(mac_tx);
#else /* UIP_CONF_TCP_SPLIT */
#if UIP_CONF_IPV6
      xtcpip_ipv6_output(mac_tx);
#else
      PRINTF("tcpip packet_input output len %d\n", uip_len);
      tcpip_output();
#endif
#endif /* UIP_CONF_TCP_SPLIT */
    }
  }
#endif /* UIP_CONF_IP_FORWARD */
}