diff --git a/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.c b/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.c index bb9f8ae5b..d89ab25ee 100644 --- a/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.c +++ b/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.c @@ -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(Ð1, 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); diff --git a/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.h b/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.h index fe939a178..7e001ddd1 100644 --- a/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.h +++ b/demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.h @@ -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