Esempio n. 1
0
void xtcpd_check_connection_poll(chanend mac_tx)
{
	for (int i = 0; i < UIP_CONNS; i++) {
		if (uip_conn_needs_poll(&uip_conns[i])) {
			uip_poll_conn(&uip_conns[i]);
#if UIP_CONF_IPV6
            xtcpip_ipv6_output(mac_tx);
#else /* UIP_CONF_IPV6 */
            if (uip_len > 0) {
                uip_arp_out( NULL);
                xtcp_tx_buffer(mac_tx);
            }
#endif /* UIP_CONF_IPV6 */
		}
	}

	for (int i = 0; i < UIP_UDP_CONNS; i++) {
		if (uip_udp_conn_needs_poll(&uip_udp_conns[i])) {
			uip_udp_periodic(i);
#if UIP_CONF_IPV6
             xtcpip_ipv6_output(mac_tx);
#else
            if (uip_len > 0) {
                uip_arp_out(&uip_udp_conns[i]);
                xtcp_tx_buffer(mac_tx);
            }
#endif
		}
	}
}
Esempio n. 2
0
void xtcp_process_incoming_packet(chanend mac_tx)
{
	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);
			}
		}
	}
}
void uip_server(chanend mac_rx, chanend mac_tx, chanend xtcp[], int num_xtcp,
		xtcp_ipconfig_t *ipconfig, chanend connect_status) {

	struct uip_timer periodic_timer, arp_timer, autoip_timer;
	unsigned char hwaddr[6];

	timer_set(&periodic_timer, CLOCK_SECOND / 10);
	timer_set(&autoip_timer, CLOCK_SECOND / 2);
	timer_set(&arp_timer, CLOCK_SECOND * 10);

	xcoredev_init(mac_rx, mac_tx);

	mac_get_macaddr(mac_tx, hwaddr);

	uip_server_init(xtcp, num_xtcp, ipconfig, hwaddr);

	// Main uIP service loop
	while (1)
	{
		xtcpd_service_clients(xtcp, num_xtcp);

		xtcpd_check_connection_poll(mac_tx);

		uip_xtcp_checkstate();
		uip_xtcp_checklink(connect_status);
		uip_len = xcoredev_read(mac_rx, UIP_CONF_BUFFER_SIZE);
		if (uip_len > 0) {
			xtcp_process_incoming_packet(mac_tx);
		}

		xtcp_process_udp_acks(mac_tx);


		if (timer_expired(&arp_timer)) {
			timer_reset(&arp_timer);
			uip_arp_timer();
		}

#if UIP_USE_AUTOIP
		if (timer_expired(&autoip_timer)) {
			timer_reset(&autoip_timer);
			autoip_periodic();
			if (uip_len > 0) {
				xtcp_tx_buffer(mac_tx);
			}
		}
#endif

		if (timer_expired(&periodic_timer)) {

			xtcp_process_periodic_timer(mac_tx);

			timer_reset(&periodic_timer);
		}

	}
	return;
}
Esempio n. 4
0
void xtcp_process_udp_acks(chanend mac_tx)
{
	for (int i = 0; i < UIP_UDP_CONNS; i++) {
		if (uip_udp_conn_has_ack(&uip_udp_conns[i])) {
			uip_udp_ackdata(i);
			if (uip_len > 0) {
				uip_arp_out(&uip_udp_conns[i]);
				xtcp_tx_buffer(mac_tx);
			}
		}
	}
}
Esempio n. 5
0
void xtcpd_check_connection_poll(chanend mac_tx)
{
	for (int i = 0; i < UIP_CONNS; i++) {
		if (uip_conn_needs_poll(&uip_conns[i])) {
			uip_poll_conn(&uip_conns[i]);
			if (uip_len > 0) {
				uip_arp_out( NULL);
				xtcp_tx_buffer(mac_tx);
			}
		}
	}

	for (int i = 0; i < UIP_UDP_CONNS; i++) {
		if (uip_udp_conn_needs_poll(&uip_udp_conns[i])) {
			uip_udp_periodic(i);
			if (uip_len > 0) {
				uip_arp_out(&uip_udp_conns[i]);
				xtcp_tx_buffer(mac_tx);
			}
		}
	}
}
Esempio n. 6
0
void xtcp_process_periodic_timer(chanend mac_tx)
{
#if UIP_IGMP
	igmp_periodic();
	if(uip_len > 0) {
		xtcp_tx_buffer(mac_tx);
	}
#endif
	for (int i = 0; i < UIP_UDP_CONNS; i++) {
		uip_udp_periodic(i);
		if (uip_len > 0) {
			uip_arp_out(&uip_udp_conns[i]);
			xtcp_tx_buffer(mac_tx);
		}
	}

	for (int i = 0; i < UIP_CONNS; i++) {
		uip_periodic(i);
		if (uip_len > 0) {
			uip_arp_out( NULL);
			xtcp_tx_buffer(mac_tx);
		}
	}
}
Esempio n. 7
0
void xtcp_process_udp_acks(chanend mac_tx)
{
	for (int i = 0; i < UIP_UDP_CONNS; i++) {
		if (uip_udp_conn_has_ack(&uip_udp_conns[i])) {
			uip_udp_ackdata(i);
			if (uip_len > 0) {
#if UIP_CONF_IPV4
				uip_arp_out(&uip_udp_conns[i]);
				xtcp_tx_buffer(mac_tx);
#endif
#if UIP_CONF_IPV6
// #warning "Implementation is missing"
#endif
			}
		}
	}
}
Esempio n. 8
0
/* -----------------------------------------------------------------------------
 * 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 */

}
Esempio n. 9
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 */
}