示例#1
0
void tcpip_periodic_timer()
{
	int i;
    MT_TimerExpired();

	if(timer_expired(&periodic_timer)) {
		timer_reset(&periodic_timer);
		for(i = 0; i < UIP_CONNS; i++) {
			uip_periodic(i);
			/* If the above function invocation resulted in data that
			should be sent out on the network, the global variable
			uip_len is set to a value > 0. */
			if(uip_len > 0) {
				uip_arp_out();
				mt76xx_dev_send();
			}
		}

#if UIP_UDP
		for(i = 0; i < UIP_UDP_CONNS; i++) {
			uip_udp_periodic(i);
			/* If the above function invocation resulted in data that
			should be sent out on the network, the global variable
			uip_len is set to a value > 0. */
			if(uip_len > 0) {
				uip_arp_out();
				mt76xx_dev_send();
			}
		}
#endif /* UIP_UDP */

		/* Call the ARP timer function every 10 seconds. */
		if(timer_expired(&arp_timer)) {
			timer_reset(&arp_timer);
			uip_arp_timer();
		}
    }
#if 0
	if(timer_expired(&cli_timer)) {
		clk = (clk > (CLOCK_SECOND*60))?clk:(clk*2);
		timer_set(&cli_timer, clk);
		
		if ((cli_fd == -1) && 
			memcmp(uip_hostaddr, 0x00000000, sizeof(uip_hostaddr))) {
			struct uip_conn *conn = NULL;
			uip_ipaddr_t srv_ip;
			
			uip_ipaddr(srv_ip, IoTpAd.ComCfg.IoT_ServeIP[0], IoTpAd.ComCfg.IoT_ServeIP[1],
					IoTpAd.ComCfg.IoT_ServeIP[2], IoTpAd.ComCfg.IoT_ServeIP[3]);
			conn = uip_connect(&srv_ip, HTONS(IoTpAd.ComCfg.IoT_TCP_Srv_Port));
			if(conn) {
				conn->lport = HTONS(7682);
				cli_fd = conn->fd;
			} else {
				printf("connect fail\n");
			}	
		}
	}
#endif	
}
示例#2
0
int netif_rx(u8_t *p, u16_t len)
{
    /*avoid Rx packet length > UIP buffer size  and cause UIP buffer overflow*/
    if (len <= UIP_BUFSIZE + 2) {
        mt76xx_dev_read(p, len);
    } else {
        printf_high("netif_rx length error: %d > %d\n", len, UIP_BUFSIZE + 2);
        return -1;
    }

    if (uip_len > 0) {
        if (BUF->type == htons(UIP_ETHTYPE_IP)) {
            uip_arp_ipin();
            uip_input();
            /* If the above function invocation resulted in data that
            should be sent out on the network, the global variable
            uip_len is set to a value > 0. */
            if (uip_len > 0) {
                uip_arp_out();
                mt76xx_dev_send();
            }
        } else if (BUF->type == htons(UIP_ETHTYPE_ARP)) {
            uip_arp_arpin();
            /* If the above function invocation resulted in data that
            should be sent out on the network, the global variable
            uip_len is set to a value > 0. */
            if (uip_len > 0) {
                mt76xx_dev_send();
            }
        }
    }
    return 0;
}