[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Defining the default route
From: |
Mason |
Subject: |
[lwip-users] Defining the default route |
Date: |
Mon, 19 Mar 2012 17:11:33 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Firefox/10.0.2 SeaMonkey/2.7.2 |
Hello,
I'm using lwip 1.4.1
Below is the code I use to initialize the network stack.
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
}
void eth_init(void)
{
tcpip_init(do_lwip_init, NULL);
}
When I try to connect to an address outside the LAN, I get an
ERR_RTE error (Routing problem).
Looking at struct netif *ip_route(ip_addr_t *dest)
IIUC, ip_route will check if the address is local,
otherwise, it will send via netif_default when it
is set.
Several questions:
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?
--
Regards.
- [lwip-users] Defining the default route,
Mason <=