Beispiel #1
0
void Test_uip_arp_arpout(CuTest *tc) {

	u8_t temp_buf[]= "\x11\x22\x33\x44\x55\x66\x77\x88\x99\x00\xAA\xBB\x08\x00"
	"\x45"  //ipv4, 4*5=20byte
	"\x00"
	"\x00\x14" //fra
	"\x00\x00"
	"\x00\x00"
	"\x11" //ttl
	"\x06" //tcp
	"\x00\x00"  //header checksum,dont fit now
	"\xC0\xA8\x00\x02"
	"\xff\xff\xff\x00" //ip broadcast,subnet broad cast
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";

	iprintf_s(temp_buf,sizeof(temp_buf));
	uip_arp_init();
	memcpy(uip_buf,temp_buf,60);//broad cast,=dest ip equeals mask
	uip_arp_out();
    CuAssertHexEquals_Msg(tc,"arp out 1",0xFF,IPBUF->ethhdr.dest.addr[0]);
    IPBUF->destipaddr[0]=0xA8C0;
    IPBUF->destipaddr[1]=0x0300;
    uip_arp_out();
    CuAssertHexEquals_Msg(tc,"arp out 2",0xFF,IPBUF->ethhdr.dest.addr[0]);
    CuAssertHexEquals_Msg(tc,"arp out 3",0xFF,IPBUF->ethhdr.dest.addr[1]);
    CuAssertHexEquals_Msg(tc,"arp out 4",0xFF,IPBUF->ethhdr.dest.addr[2]);
    CuAssertHexEquals_Msg(tc,"arp out 5",0xFF,IPBUF->ethhdr.dest.addr[3]);
    CuAssertHexEquals_Msg(tc,"arp out 6",0xFF,IPBUF->ethhdr.dest.addr[4]);
    CuAssertHexEquals_Msg(tc,"arp out 7",0xFF,IPBUF->ethhdr.dest.addr[5]);
    CuAssertHexEquals_Msg(tc,"arp out 8",HTONS(UIP_ETHTYPE_ARP),BUF->ethhdr.type);
    CuAssertHexEquals_Msg(tc,"arp out 8",0x0608,BUF->ethhdr.type);
}
Beispiel #2
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	
}
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
		}
	}
}
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);
			}
		}
	}
}
Beispiel #5
0
void Network::on_idle(void *argument)
{
    if (!ethernet->isUp()) return;

    int len= sizeof(uip_buf); // set maximum size
    if (ethernet->_receive_frame(uip_buf, &len)) {
        uip_len = len;
        this->handlePacket();

    } else {

        if (timer_expired(&periodic_timer)) { /* no packet but periodic_timer time out (0.1s)*/
            timer_reset(&periodic_timer);

            for (int 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();
                    tapdev_send(uip_buf, uip_len);
                }
            }

#if UIP_CONF_UDP
            for (int 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();
                    tapdev_send(uip_buf, uip_len);
                }
            }
#endif
        }
/*
        This didn't work actually made it worse,it should have worked though
        else{
            // TODO if the command queue is below a certain amount we should poll any stopped connections
            if(command_q->size() < 4) {
                for (struct uip_conn *connr = &uip_conns[0]; connr <= &uip_conns[UIP_CONNS - 1]; ++connr) {
                    if(uip_stopped(connr)){
                        // Force a poll of this
                        printf("Force poll of connection\n");
                        uip_poll_conn(connr);
                    }
                }
            }
        }
*/
        /* Call the ARP timer function every 10 seconds. */
        if (timer_expired(&arp_timer)) {
            timer_reset(&arp_timer);
            uip_arp_timer();
        }
    }
}
Beispiel #6
0
void ethernet_service(void) {
	int i;
	struct uip_eth_hdr *buf = (struct uip_eth_hdr *)&uip_buf[0];

	etimer_request_poll();
	process_run();

	uip_len = liteethmac_poll();
	if(uip_len > 0) {
		if(buf->type == uip_htons(UIP_ETHTYPE_IP)) {
			uip_arp_ipin();
			uip_input();
			if(uip_len > 0) {
				uip_arp_out();
				liteethmac_send();
			}
		} else if(buf->type == uip_htons(UIP_ETHTYPE_ARP)) {
			uip_arp_arpin();
			if(uip_len > 0)
				liteethmac_send();
		}
	} else if (elapsed(&uip_periodic_event, uip_periodic_period)) {
		for(i = 0; i < UIP_CONNS; i++) {
			uip_periodic(i);

			if(uip_len > 0) {
				uip_arp_out();
				liteethmac_send();
			}
		}
	}
	if (elapsed(&uip_arp_event, uip_arp_period)) {
		uip_arp_timer();
	}
}
void deal(){
    int i;
    if(uip_len > 0) {
        if(BUF_IF->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();
                current_dev->eth_tx(current_dev, uip_buf, uip_len);
            }
        } else if(BUF_IF->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) {
                current_dev->eth_tx(current_dev, uip_buf, uip_len);
            }
        }

    } else 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();
                current_dev->eth_tx(current_dev, uip_buf, uip_len);	
            }
        }

#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();
                current_dev->eth_tx(current_dev, uip_buf, uip_len);	
            }
        }
#endif /* UIP_UDP */

        /* Call the ARP timer function every 10 seconds. */
        if(timer_expired(&arp_timer)) {
            timer_reset(&arp_timer);
            uip_arp_timer();
        }
    }
    //rt_exit_critical();

    return 0;
}
Beispiel #8
0
void NanodeUIP::poll(void) {
  int i;

  uip_len = enc28j60PacketReceive(UIP_BUFSIZE,uip_buf);
  if(uip_len > 0) {
    if(BUF->type == UIP_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();
	enc28j60PacketSend(uip_len,uip_buf);
      }
    } else if(BUF->type == UIP_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) {
	enc28j60PacketSend(uip_len,uip_buf);
      }
    }
  } else 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();
	enc28j60PacketSend(uip_len,uip_buf);
      }
    }

#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();
	enc28j60PacketSend(uip_len,uip_buf);
      }
    }
#endif /* UIP_UDP */

    /* Call the ARP timer function every 10 seconds. */
    if(timer_expired(&arp_timer)) {
      timer_reset(&arp_timer);
      uip_arp_timer();
    }
  }
}
Beispiel #9
0
/**
 * @brief   Process Network
 * @param   None
 * @retval  None
 */
void Network_Process(void)
{
	static uint8_t arp_counter = 0;

	int i;
	for (i = 0; i < UIP_CONNS; i++)
	{
		uip_periodic(i);
		if (uip_len > 0)
		{
			uip_arp_out();
			enc28j60_send_packet((uint8_t *)uip_buf, uip_len);
		}
	}

	#if UIP_UDP
		for (i = 0; i < UIP_UDP_CONNS; i++)
		{
			uip_udp_periodic(i);
			if (uip_len > 0)
			{
				uip_arp_out();
				network_send();
			}
		}
	#endif /* UIP_UDP */

	if (++arp_counter >= 50)
	{
		arp_counter = 0;
		uip_arp_timer();
	}

	uip_len = enc28j60_recv_packet((uint8_t *)uip_buf, UIP_BUFSIZE);
	if (uip_len > 0)
	{
		if (((struct uip_eth_hdr *)&uip_buf[0])->type == htons(UIP_ETHTYPE_IP))
		{
			uip_arp_ipin();
			uip_input();
			if (uip_len > 0)
			{
				uip_arp_out();
				enc28j60_send_packet((uint8_t *)uip_buf, uip_len);
			}
		}
		else if (((struct uip_eth_hdr *)&uip_buf[0])->type == htons(UIP_ETHTYPE_ARP))
		{
			uip_arp_arpin();
			if (uip_len > 0)
			{
				enc28j60_send_packet((uint8_t *)uip_buf, uip_len);
			}
		}
	}
}
Beispiel #10
0
Datei: TcpIp.c Projekt: AndTH/GCA
/**
 *******************************************************************************************
 * @fn         void TcpIpMain(void)
 * @brief      Update the uIP stack.
 * @return     None
 * @attention
 *******************************************************************************************
 */
void TcpIpMain(void)
{
   uint8_t                                 Index;

   uip_len = nic_poll();
   if (uip_len == 0)
   {
         // If timed out, call periodic function for each connection
         if (TcpIpUipTimerCounter >= TCP_IP_CNT_TIME)
         {
            TcpIpUipTimerCounter = 0;
            for (Index = 0; Index < UIP_CONNS; Index++)
            {
               uip_periodic(Index);
               if (uip_len > 0)
               {
                  uip_arp_out();
                  nic_send();
               }
            }

            /* Call the ARP timer function every ~10 seconds. */
            if (++TcpIpUipArpTimerCounter >= TCP_IP_ARP_CNT_TIME)
            {
               uip_arp_timer();
               TcpIpUipArpTimerCounter = 0;
            }
         }
   }
   else                                                                        // packet received
   {
      // process an IP packet
      if (TCP_IP_BUF->type == htons(UIP_ETHTYPE_IP))
      {
         uip_arp_ipin();
         uip_input();
         if (uip_len > 0)
         {
            uip_arp_out();
            nic_send();
         }
      }
      // process an ARP packet
      else if (TCP_IP_BUF->type == htons(UIP_ETHTYPE_ARP))
      {
         uip_arp_arpin();
         if (uip_len > 0)
            nic_send();
      }

      TcpIpUipTimerCounter = 0;
   }
}
Beispiel #11
0
void uip_timeout_entry(void* parameter)//由于TIMEOUT函数,不参与调度
{
   // struct timer periodic_timer, arp_timer;
    static uint8_t cnt;
    int i;
	/* post message to ethernet thread */

    //if ((rt_sem_take(msg,RT_WAITING_NO)) != -RT_ETIMEOUT) 
    //if (timer_expired(&periodic_timer)) //5s enter once
    {
       //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();
	      TransmitPacket();
	  }
       }
#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();
	      TransmitPacket();
	    }
        }
#endif /* UIP_UDP */
      
       /* Call the ARP timer function every 10 seconds. */
       //if (timer_expired(&arp_timer)) 
       if (++cnt >= 2) //t
       {
	  //timer_reset(&arp_timer);
	  uip_arp_timer();
          cnt = 0;
       }
    }
  
}
Beispiel #12
0
err_t
tcpip_input(struct pbuf *p, struct netif *inp)
{
    int i;
    u8_t *pdata;
    if (uip_len)
    {
        uip_arp_out();
        if (( pdata =(u8_t*)malloc(1500*sizeof(u8_t))) == NULL)
        {
            pbuf_free(p);
            return 1;
        }
        for (i=0; i < (UIP_LLH_LEN + 40); ++i) // 14+40 =54
        {
            pdata[i] =  uip_buf[i]; /* get dest an src ipaddr */
        }
        // Copy the data portion part
        for(; i < uip_len; ++i)
        {
            pdata[i] =  uip_appdata[i - UIP_LLH_LEN - 40 ];
        }
        p ->payload = pdata;
        p->len = uip_len;
        inp->linkoutput(inp,p);
        rt_free(pdata);
        return 1;
    }
    else
    {
        pbuf_free(p);
        return 0;
    }
}
Beispiel #13
0
static int vnet_uiptxpoll(struct uip_driver_s *dev)
{
  FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;

  /* If the polling resulted in data that should be sent out on the network,
   * the field d_len is set to a value > 0.
   */

  if (vnet->sk_dev.d_len > 0)
    {
      uip_arp_out(&vnet->sk_dev);
      vnet_transmit(vnet);

      /* Check if there is room in the device to hold another packet. If not,
       * return a non-zero value to terminate the poll.
       */
      if (vnet_is_txbuff_full(vnet->vnet))
	  return 1;
    }

  /* If zero is returned, the polling will continue until all connections have
   * been examined.
   */

  return 0;
}
Beispiel #14
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;
}
Beispiel #15
0
static int e1000_uiptxpoll(struct uip_driver_s *dev)
{
    struct e1000_dev *e1000 = (struct e1000_dev *)dev->d_private;
    int tail = e1000->tx_ring.tail;

    /* If the polling resulted in data that should be sent out on the network,
     * the field d_len is set to a value > 0.
     */

    if (e1000->uip_dev.d_len > 0) {
		uip_arp_out(&e1000->uip_dev);
		e1000_transmit(e1000);

		/* Check if there is room in the device to hold another packet. If not,
		 * return a non-zero value to terminate the poll.
		 */
		if (!e1000->tx_ring.desc[tail].desc_status)
			return -1;
    }

    /* If zero is returned, the polling will continue until all connections have
     * been examined.
     */

    return 0;
}
Beispiel #16
0
uint8_t
tapdev_output(void)
{
   uip_arp_out();
   tapdev_send();  
   return 0;
}
Beispiel #17
0
void Network::handlePacket(void)
{
    if (uip_len > 0) {  /* received packet */
        //printf("handlePacket: %d\n", uip_len);

        if (BUF->type == htons(UIP_ETHTYPE_IP)) { /* IP packet */
            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();
                network_device_send();
            }

        } else if (BUF->type == htons(UIP_ETHTYPE_ARP)) { /*ARP packet */
            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) {
                tapdev_send(uip_buf, uip_len);  /* ARP ack*/
            }

        } else {
            printf("Unknown ethernet packet type %04X\n", htons(BUF->type));
            uip_len = 0;
        }
    }
}
/*---------------------------------------------------------------------------*/
static void
output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
{
  uip_arp_out();
  lan91c96_send();
  dump_packet();
}
Beispiel #19
0
/*---------------------------------------------------------------------------*/
uint8_t
ethernet_output(void)
{
  uip_arp_out();
  ethernet_send();
  
  return 0;
}
Beispiel #20
0
u8_t
wpcap_output(void)
{
   uip_arp_out();
   wpcap_send();  

   return 0;
}
Beispiel #21
0
/*---------------------------------------------------------------------------*/
static u8_t
output(void)
{
  uip_arp_out();
  cs8900a_send();
  
  return 0;
}
Beispiel #22
0
/*---------------------------------------------------------------------------*/
u8_t
rtl8019_output(void)
{
  uip_arp_out();
  RTL8019dev_send();

  return 0;
}
Beispiel #23
0
static void maybe_send(void)
{
  /* 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();
    nic_send(NULL);
  }
}
Beispiel #24
0
void nethandler_periodic()
{
	int i;

	times(UIP_CONNS, i) {
		uip_periodic(i);
		if (uip_len > 0) {
			uip_arp_out();
			network_send();
		}
	}
Beispiel #25
0
/*---------------------------------------------------------------------------*/
static u8_t
output(void)
{
  
  uip_arp_out();
  lan91c96_send();

  dump_packet();
  
  return 0;
}
Beispiel #26
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);
			}
		}
	}
}
Beispiel #27
0
/*
 * TCP/IP periodic timer.
 */
static void PeriodicTimerHandler(eventid_t id) {
  int i;

  (void)id;
  for (i = 0; i < UIP_CONNS; i++) {
    uip_periodic(i);
    if (uip_len > 0) {
      uip_arp_out();
      network_device_send();
    }
  }
}
Beispiel #28
0
/*-----------------------------------------------------------------------------------*/
static void
timer(void)
{
  for(i = 0; i < UIP_CONNS; ++i) {
    uip_periodic(i);
    if(uip_len > 0) {
      uip_arp_out();
      rtl8019as_send();
    }
  }

  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();
      rtl8019as_send();
    }
  }   
}
Beispiel #29
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);
			}
		}
	}
}
Beispiel #30
0
void rtos_vnet_recv(struct rgmp_vnet *vnet_dummy, char *data, int len)
{
    // now only support 1 vnet
    struct vnet_driver_s *vnet = &g_vnet[0];

    do {
	/* Check for errors and update statistics */

	/* Check if the packet is a valid size for the uIP buffer configuration */
	if (len > CONFIG_NET_BUFSIZE || len < 14) {
#ifdef CONFIG_DEBUG
	    cprintf("VNET: receive invalid packet of size %d\n", len);
#endif
	    return;
	}

	// Copy the data data from the hardware to vnet->sk_dev.d_buf.  Set
	// amount of data in vnet->sk_dev.d_len
	memcpy(vnet->sk_dev.d_buf, data, len);
	vnet->sk_dev.d_len = len;

	/* We only accept IP packets of the configured type and ARP packets */

#ifdef CONFIG_NET_IPv6
	if (BUF->type == HTONS(UIP_ETHTYPE_IP6))
#else
	if (BUF->type == HTONS(UIP_ETHTYPE_IP))
#endif
	{
	    uip_arp_ipin(&vnet->sk_dev);
	    uip_input(&vnet->sk_dev);

	    // If the above function invocation resulted in data that should be
	    // sent out on the network, the field  d_len will set to a value > 0.
	    if (vnet->sk_dev.d_len > 0) {
		uip_arp_out(&vnet->sk_dev);
		vnet_transmit(vnet);
	    }
	}
	else if (BUF->type == htons(UIP_ETHTYPE_ARP)) {
	    uip_arp_arpin(&vnet->sk_dev);

	    // If the above function invocation resulted in data that should be
	    // sent out on the network, the field  d_len will set to a value > 0.
	    if (vnet->sk_dev.d_len > 0) {
		vnet_transmit(vnet);
	    }
	}
    }
    while (0); /* While there are more packets to be processed */
}