AnsweredAssumed Answered

uIP question

Question asked by karakaya.mehmet on Dec 24, 2012
Latest reply on Apr 10, 2013 by Andrew Neil
uint32_t uIPMain(void)
{
uint32_t i;
uip_ipaddr_t ipaddr;
struct timer periodic_timer, arp_timer;
  
  // Sys timer init 1/100 sec tick
  clock_init(2);
  
  timer_set(&periodic_timer, CLOCK_SECOND / 2);
  timer_set(&arp_timer, CLOCK_SECOND * 10);
  
  // Initialize the ethernet device driver
  // Init MAC
  // Phy network negotiation
  tapdev_init();
  
  // uIP web server
  // Initialize the uIP TCP/IP stack.
  uip_init();
  
  // Init WEB server
  uip_ipaddr(ipaddr, 192,168,1,100);
  //printf("IP Address: 192.168.0.100\n\r");
  uip_sethostaddr(ipaddr);
  uip_ipaddr(ipaddr, 192,168,1,3);
  uip_setdraddr(ipaddr);
  uip_ipaddr(ipaddr, 255,255,255,0);
  uip_setnetmask(ipaddr);
  
  // Initialize the HTTP server.
  httpd_init();
  // Run WEB server and wait any key for exit
  while(1)
  {
  
    uip_len = tapdev_read(uip_buf);
    if(uip_len > 0)
    {
      if(BUF->type == htons(UIP_ETHTYPE_IP))
      {
          uip_process(1);
          /* 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);
          }
      }
      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)
        {
            tapdev_send(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();
          tapdev_send(uip_buf,uip_len);
        }
      }
  
      /* Call the ARP timer function every 10 seconds. */
      if(timer_expired(&arp_timer))
      {
        timer_reset(&arp_timer);
        uip_arp_timer();
      }
    }
  
  }
  return(1);
}
hello forum

I am new to TCP/IP
anybody who used uIP before can answer my question ?

this above is main body if uIP
how must I modify this code
so that it doesnot act as a webserver
but receives and sends back 200 or 300 bytes of data ?

thank you

Outcomes