diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-10-11 18:01:55 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-10-11 18:01:55 +0000 |
commit | f1badd1b2946417f65230bc5d1608b837391125f (patch) | |
tree | d87b1f38b1ba00abab391d094cbc3ec77b4d7dad /demos/ARM7-AT91SAM7X-LWIP-GCC | |
parent | cebf9128d7b9d25e5da5f00782b1fdae072588aa (diff) | |
download | ChibiOS-f1badd1b2946417f65230bc5d1608b837391125f.tar.gz ChibiOS-f1badd1b2946417f65230bc5d1608b837391125f.tar.bz2 ChibiOS-f1badd1b2946417f65230bc5d1608b837391125f.zip |
Added runtime lwip settings.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1216 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/ARM7-AT91SAM7X-LWIP-GCC')
-rw-r--r-- | demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.c | 25 | ||||
-rw-r--r-- | demos/ARM7-AT91SAM7X-LWIP-GCC/lwip/lwipthread.h | 10 |
2 files changed, 30 insertions, 5 deletions
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
|