lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] lwip init and handling


From: Bernhard 'Gustl' Bauer
Subject: [lwip-users] lwip init and handling
Date: Wed, 23 Feb 2005 09:57:54 +0100
User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)

Hi,

I'm new to lwip and a bit unsure how to do it. I don't have a hw yet so I can do no tests at the moment.

I don't have a system and I want to use dhcp. My lwipopts.h:
--------------------------------------------
#define MEM_ALIGNMENT                   4
#define LWIP_DHCP                       1
#define LWIP_NOASSERT
#define NO_SYS                          1
--------------------------------------------

My init process look like this:
--------------------------------------------
  raw_init();
  etharp_init();
  cs8900if_init(&eth0);
  eth0.hwaddr[0] = 0x00;
  eth0.hwaddr[1] = 0x01;
  eth0.hwaddr[2] = 0x02;
  eth0.hwaddr[3] = 0x03;
  eth0.hwaddr[4] = 0x04;
  eth0.hwaddr[5] = 0x05;
  mem_init();
  memp_init();
  pbuf_init();
  netif_init();
  ip_init();
  udp_init();
  tcp_init();
  IP4_ADDR(&gw, 192,168,0,1);
  IP4_ADDR(&ipaddr, 192,168,0,2);
  IP4_ADDR(&netmask, 255,255,255,0);
  netif_add(&eth0,&ipaddr,&netmask, &gw, NULL, cs8900if_init,ip_input);
  netif_set_default(&eth0);
--------------------------------------------
Did I forget something or is it in wrong order?

To handle the packets I wrote this function which is call periodically from the main loop:
--------------------------------------------
void handle_eth(void) {
        cs8900if_service(&eth0);
        
        if (timer_250ms==1) {
                timer_250ms=0;
                tcp_tmr();              // every 250ms
        }
        if (timer_500ms==1) {
                timer_500ms=0;
                dhcp_fine_tmr();        // every 500 ms
        }
        if (timer_5s==1) {
                timer_5s=0;
                etharp_tmr();           // every 5s
        }
        if (timer_60s==1) {
                timer_60s=0;
                dhcp_coarse_tmr();      // every 60s
        }
}
--------------------------------------------
The timer_* varibales are set by an IRQ in these intervalls. I'm not sure if the intervalls are correct. The website indicated that tcp_tmr() should be called every 100ms. Did I forgot a timer?. Every 60s all *_tmr() functions are called. Is there an order I have to meet?


TIA Gustl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]