mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2024-10-12 08:23:42 +00:00
Add AUTOIP use in Win32 port (and display ip address in status_callback).
This commit is contained in:
parent
bf8469722f
commit
fb791aa4f8
@ -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
|
/* 1 if you want to do an ARP check on the offered address
|
||||||
(recommended). */
|
(recommended). */
|
||||||
#if LWIP_DHCP
|
#define DHCP_DOES_ARP_CHECK (LWIP_DHCP)
|
||||||
#define DHCP_DOES_ARP_CHECK 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- AUTOIP options ------- */
|
/* ---------- AUTOIP options ------- */
|
||||||
#define LWIP_AUTOIP 0
|
#define LWIP_AUTOIP 0
|
||||||
|
#define LWIP_DHCP_AUTOIP_COOP (LWIP_DHCP && LWIP_AUTOIP)
|
||||||
|
|
||||||
|
|
||||||
/* ---------- UDP options ---------- */
|
/* ---------- UDP options ---------- */
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include "lwip/udp.h"
|
#include "lwip/udp.h"
|
||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
#include "lwip/dhcp.h"
|
#include "lwip/dhcp.h"
|
||||||
|
#include "lwip/autoip.h"
|
||||||
|
|
||||||
/* lwIP netif includes */
|
/* lwIP netif includes */
|
||||||
#include "netif/loopif.h"
|
#include "netif/loopif.h"
|
||||||
@ -66,8 +67,6 @@
|
|||||||
/* ... then we need information about the timer intervals: */
|
/* ... then we need information about the timer intervals: */
|
||||||
#include "lwip/ip_frag.h"
|
#include "lwip/ip_frag.h"
|
||||||
#include "lwip/igmp.h"
|
#include "lwip/igmp.h"
|
||||||
#include "lwip/dhcp.h"
|
|
||||||
#include "lwip/autoip.h"
|
|
||||||
#endif /* NO_SYS */
|
#endif /* NO_SYS */
|
||||||
|
|
||||||
#if PPP_SUPPORT
|
#if PPP_SUPPORT
|
||||||
@ -225,7 +224,11 @@ pppLinkStatusCallback(void *ctx, int errCode, void *arg)
|
|||||||
|
|
||||||
#if LWIP_NETIF_STATUS_CALLBACK
|
#if LWIP_NETIF_STATUS_CALLBACK
|
||||||
void status_callback(struct netif *netif)
|
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 */
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||||
|
|
||||||
@ -261,7 +264,12 @@ msvc_netif_init()
|
|||||||
ipaddr.addr = 0;
|
ipaddr.addr = 0;
|
||||||
netmask.addr = 0;
|
netmask.addr = 0;
|
||||||
printf("Starting lwIP, local interface IP is dhcp-enabled\n");
|
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_GW(&gw);
|
||||||
LWIP_PORT_INIT_IPADDR(&ipaddr);
|
LWIP_PORT_INIT_IPADDR(&ipaddr);
|
||||||
LWIP_PORT_INIT_NETMASK(&netmask);
|
LWIP_PORT_INIT_NETMASK(&netmask);
|
||||||
@ -301,6 +309,8 @@ msvc_netif_init()
|
|||||||
|
|
||||||
#if LWIP_DHCP
|
#if LWIP_DHCP
|
||||||
dhcp_start(&netif);
|
dhcp_start(&netif);
|
||||||
|
#elif LWIP_AUTOIP
|
||||||
|
autoip_start(&netif);
|
||||||
#else /* LWIP_DHCP */
|
#else /* LWIP_DHCP */
|
||||||
netif_set_up(&netif);
|
netif_set_up(&netif);
|
||||||
#endif /* LWIP_DHCP */
|
#endif /* LWIP_DHCP */
|
||||||
@ -396,7 +406,7 @@ void main_loop()
|
|||||||
timers_update();
|
timers_update();
|
||||||
#endif /* NO_SYS */
|
#endif /* NO_SYS */
|
||||||
|
|
||||||
/* check for packets */
|
/* check for packets and link status*/
|
||||||
ethernetif_poll(&netif);
|
ethernetif_poll(&netif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user