lwip: use netifapi

The netifapi makes sure, that all operations are done in the context of
the tcpip-thread.

Issue #1327.
This commit is contained in:
Josef Söntgen 2015-03-12 14:12:31 +01:00 committed by Christian Helmuth
parent 5518a21692
commit 6c6375aa83
1 changed files with 7 additions and 6 deletions

View File

@ -163,13 +163,13 @@ extern "C" {
*
* See: http://lwip.wikia.com/wiki/Writing_a_device_driver
*/
struct netif *ret = netif_add(&netif, &ip, &nm, &gw, &nbs,
genode_netif_init, tcpip_input);
if (!ret)
err_t ret = netifapi_netif_add(&netif, &ip, &nm, &gw, &nbs,
genode_netif_init, tcpip_input);
if (ret != ERR_OK)
throw Nic_not_availble();
/* Set Genode's nic as the default nic */
netif_set_default(&netif);
netifapi_netif_set_default(&netif);
/* If no static ip was set, we do dhcp */
if (!ip_addr) {
@ -178,13 +178,14 @@ extern "C" {
netif.status_callback = dhcp_callback;
/* Start DHCP requests */
dhcp_start(&netif);
netifapi_dhcp_start(&netif);
/* Block until DHCP succeeded or a timeout was triggered */
try {
dhcp_semaphore()->down(20000);
} catch (Genode::Timeout_exception) {
PWRN("DHCP timed out!");
netifapi_dhcp_stop(&netif);
return 1;
}
PINF("got IP address %d.%d.%d.%d",
@ -197,7 +198,7 @@ extern "C" {
return 1;
#endif /* LWIP_DHCP */
} else {
netif_set_up(&netif);
netifapi_netif_set_up(&netif);
}
} catch (Nic_not_availble) {
PWRN("NIC not available, loopback is used as default");