[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Defining the default route
From: |
Mason |
Subject: |
Re: [lwip-users] Defining the default route |
Date: |
Tue, 20 Mar 2012 09:35:58 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Firefox/10.0.2 SeaMonkey/2.7.2 |
Simon Goldschmidt wrote:
> Mason wrote:
>
>> 1) The correct function to use is netif_set_default, right?
>>
>> 2) If I use static addressing, I have to declare the
>> default route myself, using netif_set_default?
>>
>> 3) When using DHCP, does the DHCP code take care of
>> declaring the default route, or do I have to do it
>> myself, like point 2?
>
> 1) is always right. DHCP or AutoIP cannot change routing:
> you can have multiple netifs with DHCP or AutoIP enabled.
I thought lwip didn't support multi-homing very well?
Anyway, if I understand correctly, my init code should be:
static void do_lwip_init(void *arg)
{
struct netif *netif = malloc(sizeof *netif);
memset(netif, 0, sizeof *netif);
#if USE_DHCP
netif_add(netif, NULL, NULL, NULL, NULL, ethernetif_init, tcpip_input);
dhcp_start(netif);
#else
ip_addr_t addr, mask;
IP4_ADDR(&addr, 192, 168, 1, 42);
IP4_ADDR(&mask, 255, 255, 255, 0);
netif_add(netif, &addr, &mask, NULL, NULL, ethernetif_init, tcpip_input);
netif_set_up(netif);
#endif
netif_set_default(netif);
}
(And, as Ueli has pointed out, I must provide the address of a
gateway in the static addressing case.)
--
Regards.