[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [task #7213] Add a lwip_init function
From: |
Frédéric Bernon |
Subject: |
[lwip-devel] [task #7213] Add a lwip_init function |
Date: |
Fri, 17 Aug 2007 08:57:18 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6 |
Follow-up Comment #6, task #7213 (project lwip):
The reason of my preference of calling lwip_init from tcpip_init is just that
tcpip_init got two parameters, and lwip_init could have no one since all _init
modules got none.
So there is solution #1:
void
lwip_init()
{ #if LWIP_STATS
stats_init ();
#endif /* STATS */
#if (NO_SYS == 0)
sys_init ();
#endif /* (NO_SYS == 0) */
mem_init ();
memp_init ();
pbuf_init ();
#if LWIP_ARP
etharp_init();
#endif /* LWIP_ARP */
netif_init ();
#if LWIP_SOCKET
lwip_socket_init();
#endif /* LWIP_SOCKET */
#if LWIP_AUTOIP
autoip_init();
#endif /* LWIP_AUTOIP */
ip_init();
#if LWIP_UDP
udp_init();
#endif /* LWIP_UDP */
#if LWIP_TCP
tcp_init();
#endif /* LWIP_TCP */
}
void
tcpip_init(void (* initfunc)(void *), void *arg)
{ lwip_init();
...
}
So there is solution #2:
void
lwip_init(void (* initfunc)(void *), void *arg)
{ #if LWIP_STATS
stats_init ();
#endif /* STATS */
#if (NO_SYS == 0)
sys_init ();
#endif /* (NO_SYS == 0) */
mem_init ();
memp_init ();
pbuf_init ();
#if LWIP_ARP
etharp_init();
#endif /* LWIP_ARP */
netif_init ();
#if LWIP_SOCKET
lwip_socket_init();
#endif /* LWIP_SOCKET */
#if LWIP_AUTOIP
autoip_init();
#endif /* LWIP_AUTOIP */
ip_init();
#if LWIP_UDP
udp_init();
#endif /* LWIP_UDP */
#if LWIP_TCP
tcp_init();
#endif /* LWIP_TCP */
#if LWIP_SOCKET || LWIP_NETCONN
tcpip_init( initfunc, arg);
#endif /* LWIP_SOCKET || LWIP_NETCONN */
}
This second one need to also add a LWIP_NETCONN option (perhaps we can just
check MEMP_NUM_NETCONN, but it need that a user who don't want it set it to 0
in his lwipopts.h. I prefer the explicit LWIP_NETCONN to tell which layer we
use.
Note I not put here igmp_init & snmp_init. The first one need to be change
for initialize its group list when a netif is added (minor change, ftas, but,
todo). The second need to have initialize some fields like this:
#if LWIP_SNMP
snmp_set_sysdesr ( sysdescr_default, &sysdescr_len_default);
snmp_set_syscontact ( syscontact_default, &syscontact_len_default);
snmp_set_sysname ( sysname_default, &sysname_len_default);
snmp_set_syslocation( syslocation_default, &syslocation_len_default);
/*snmp_set_snmpenableauthentraps();
snmp_set_sysobjid() (if you have a private MIB);
snmp_trap_dst_enable( 0, True);
snmp_trap_dst_ip_set( 0, struct ip_addr *dst);
+traps*/
snmp_init ();
#endif /* LWIP_SNMP */
So, in this case, lwip_init should be extend with all these values, or, we
should document that these variables have to be global defined with these
specific names, or the user have to add these lines manually.
Last, there is the problem with netifs: if we add them after tcpip_init, we
have to use netifapi.c functions.
So, in solution #1, the init sequence will be :
lwip_init();
#if LWIP_SNMP
snmp_init()+others;
#endif
netif_add(...);
#if LWIP_DHCP
dhcp_start(...);
#endif
tcpip_init(initfunc,arg);
In solution #2, the init sequence will be:
lwip_init(initfunc,arg);
#if LWIP_SNMP
snmp_init()+others;
#endif
netifapi_netif_add(...);
#if LWIP_DHCP
netifapi_dhcp_start(...);
#endif
There is also the solution to use the "initfunc" to do all post-lwip_init
calls.
So, solution#1 is more "classical", solution#2 seems simplest, but need to
use netifapi with is a new api. I don't have any preference, as long we can
have a reference framework for ports, apps, and docs. Of course, a reference
framework can be "replace" by anything the user want if, like Jared say, he
doesn't like it.
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/task/?7213>
_______________________________________________
Message posté via/par Savannah
http://savannah.nongnu.org/
- [lwip-devel] [task #7213] Add a lwip_init function, Frédéric Bernon, 2007/08/15
- [lwip-devel] [task #7213] Add a lwip_init function, Frédéric Bernon, 2007/08/15
- [lwip-devel] [task #7213] Add a lwip_init function, Jared Grubb, 2007/08/15
- [lwip-devel] [task #7213] Add a lwip_init function, Frédéric Bernon, 2007/08/15
- [lwip-devel] [task #7213] Add a lwip_init function, Jared Grubb, 2007/08/16
- [lwip-devel] [task #7213] Add a lwip_init function, Kieran Mansley, 2007/08/17
- [lwip-devel] [task #7213] Add a lwip_init function,
Frédéric Bernon <=
- [lwip-devel] [task #7213] Add a lwip_init function, Kieran Mansley, 2007/08/17
- [lwip-devel] [task #7213] Add a lwip_init function, Frédéric Bernon, 2007/08/17
- [lwip-devel] [task #7213] Add a lwip_init function, Jared Grubb, 2007/08/17
- [lwip-devel] [task #7213] Add a lwip_init function, Frédéric Bernon, 2007/08/20
- RE: [lwip-devel] [task #7213] Add a lwip_init function, Goldschmidt Simon, 2007/08/21
- [lwip-devel] [task #7213] Add a lwip_init function, Simon Goldschmidt, 2007/08/21
- [lwip-devel] [task #7213] Add a lwip_init function, Frédéric Bernon, 2007/08/21
- [lwip-devel] [task #7213] Add a lwip_init function, Simon Goldschmidt, 2007/08/21
- [lwip-devel] [task #7213] Add a lwip_init function, Frédéric Bernon, 2007/08/21
- [lwip-devel] [task #7213] Add a lwip_init function, Jared Grubb, 2007/08/21