From fb791aa4f8dfec670754c09f1fbfbd3fe5f07048 Mon Sep 17 00:00:00 2001 From: fbernon Date: Sun, 30 Dec 2007 01:15:02 +0000 Subject: [PATCH] Add AUTOIP use in Win32 port (and display ip address in status_callback). --- ports/win32/lwipopts.h | 5 ++--- ports/win32/test.c | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ports/win32/lwipopts.h b/ports/win32/lwipopts.h index 43d63ac..355c7f8 100644 --- a/ports/win32/lwipopts.h +++ b/ports/win32/lwipopts.h @@ -218,13 +218,12 @@ a lot of data that needs to be copied, this should be set high. */ /* 1 if you want to do an ARP check on the offered address (recommended). */ -#if LWIP_DHCP -#define DHCP_DOES_ARP_CHECK 1 -#endif +#define DHCP_DOES_ARP_CHECK (LWIP_DHCP) /* ---------- AUTOIP options ------- */ #define LWIP_AUTOIP 0 +#define LWIP_DHCP_AUTOIP_COOP (LWIP_DHCP && LWIP_AUTOIP) /* ---------- UDP options ---------- */ diff --git a/ports/win32/test.c b/ports/win32/test.c index 4d9bcf6..8ef97e6 100644 --- a/ports/win32/test.c +++ b/ports/win32/test.c @@ -50,6 +50,7 @@ #include "lwip/udp.h" #include "lwip/dns.h" #include "lwip/dhcp.h" +#include "lwip/autoip.h" /* lwIP netif includes */ #include "netif/loopif.h" @@ -66,8 +67,6 @@ /* ... then we need information about the timer intervals: */ #include "lwip/ip_frag.h" #include "lwip/igmp.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" #endif /* NO_SYS */ #if PPP_SUPPORT @@ -225,7 +224,11 @@ pppLinkStatusCallback(void *ctx, int errCode, void *arg) #if LWIP_NETIF_STATUS_CALLBACK void status_callback(struct netif *netif) -{ printf("status_callback==%s\n", netif_is_up(netif)?"UP":"DOWN"); +{ if (netif_is_up(netif)) { + printf("status_callback==UP, local interface IP is %s\n", inet_ntoa(*(struct in_addr*)&(netif->ip_addr))); + } else { + printf("status_callback==DOWN\n"); + } } #endif /* LWIP_NETIF_STATUS_CALLBACK */ @@ -261,7 +264,12 @@ msvc_netif_init() ipaddr.addr = 0; netmask.addr = 0; printf("Starting lwIP, local interface IP is dhcp-enabled\n"); -#else /* LWIP_DHCP */ +#elif LWIP_AUTOIP + gw.addr = 0; + ipaddr.addr = 0; + netmask.addr = 0; + printf("Starting lwIP, local interface IP is autoip-enabled\n"); +#else /* LWIP_AUTOIP */ LWIP_PORT_INIT_GW(&gw); LWIP_PORT_INIT_IPADDR(&ipaddr); LWIP_PORT_INIT_NETMASK(&netmask); @@ -301,6 +309,8 @@ msvc_netif_init() #if LWIP_DHCP dhcp_start(&netif); +#elif LWIP_AUTOIP + autoip_start(&netif); #else /* LWIP_DHCP */ netif_set_up(&netif); #endif /* LWIP_DHCP */ @@ -396,7 +406,7 @@ void main_loop() timers_update(); #endif /* NO_SYS */ - /* check for packets */ + /* check for packets and link status*/ ethernetif_poll(&netif); }