Added runtime lwip settings.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1216 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2009-10-11 18:01:55 +00:00
parent cebf9128d7
commit f1badd1b29
2 changed files with 30 additions and 5 deletions

View File

@ -220,7 +220,7 @@ static err_t ethernetif_init(struct netif *netif) {
/**
* @brief LWIP handling thread.
*
* @param[in] p not used
* @param[in] p pointer to a @p lwipthread_opts structure or @p NULL
* @return The function does not return.
*/
msg_t lwip_thread(void *p) {
@ -238,10 +238,25 @@ msg_t lwip_thread(void *p) {
ip_init();
tcpip_init(NULL, NULL);
/* TCP/IP parameters.*/
LWIP_IPADDR(&ip);
LWIP_GATEWAY(&gateway);
LWIP_NETMASK(&netmask);
/* TCP/IP parameters, runtime or compile time.*/
if (p) {
struct lwipthread_opts *opts = p;
if (opts->macaddress) {
unsigned i;
for (i = 0; i < 6; i++)
thisif.hwaddr[i] = opts->macaddress[i];
macSetAddress(&ETH1, thisif.hwaddr);
}
ip.addr = opts->address;
gateway.addr = opts->gateway;
netmask.addr = opts->netmask;
}
else {
LWIP_IPADDR(&ip);
LWIP_GATEWAY(&gateway);
LWIP_NETMASK(&netmask);
}
netif_add(&thisif, &ip, &netmask, &gateway, NULL, ethernetif_init, tcpip_input);
netif_set_default(&thisif);

View File

@ -102,6 +102,16 @@
#define LWIP_IFNAME1 's'
#endif
/**
* @brief Runtime TCP/IP settings.
*/
struct lwipthread_opts {
uint8_t *macaddress;
uint32_t address;
uint32_t netmask;
uint32_t gateway;
};
extern WORKING_AREA(wa_lwip_thread, LWIP_THREAD_STACK_SIZE);
#ifdef __cplusplus