How to use lwip timers in other modules

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to use lwip timers in other modules

Giuseppe Modugno
I'd like to use lwip timers in other modules of my application. However
I have a difficulty, because I need one timer at a very first stage of
startup, where I can't call lwip_init() yet.

In my case, I think it would be better to split lwip_init() in two
functions: lwip_core_init() and lwip_init().
lwip_core_init() could be:

   stats_init();
#if !NO_SYS
   sys_init();
#endif /* !NO_SYS */
   mem_init();
   memp_init();
#if LWIP_TIMERS
   sys_timeouts_init();
#endif /* LWIP_TIMERS */

Other initializations should be left in lwip_init():

#ifndef LWIP_SKIP_CONST_CHECK
   int a = 0;
   LWIP_UNUSED_ARG(a);
   LWIP_ASSERT("LWIP_CONST_CAST not implemented correctly. Check your
lwIP port.", LWIP_CONST_CAST(void *, &a) == &a);
#endif
#ifndef LWIP_SKIP_PACKING_CHECK
   LWIP_ASSERT("Struct packing not implemented correctly. Check your
lwIP port.", sizeof(struct packed_struct_test) ==
PACKED_STRUCT_TEST_EXPECTED_SIZE);
#endif

   /* Modules initialization */
   pbuf_init();
   netif_init();
#if LWIP_IPV4
   ip_init();
#if LWIP_ARP
   etharp_init();
#endif /* LWIP_ARP */
#endif /* LWIP_IPV4 */
#if LWIP_RAW
   raw_init();
#endif /* LWIP_RAW */
#if LWIP_UDP
   udp_init();
#endif /* LWIP_UDP */
#if LWIP_TCP
   tcp_init();
#endif /* LWIP_TCP */
#if LWIP_IGMP
   igmp_init();
#endif /* LWIP_IGMP */
#if LWIP_DNS
   dns_init();
#endif /* LWIP_DNS */
#if PPP_SUPPORT
   ppp_init();
#endif

What do you think?



_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel