85 |
#if LWIP_DHCP /* don't build if not configured for use in lwipopt.h */ |
#if LWIP_DHCP /* don't build if not configured for use in lwipopt.h */ |
86 |
|
|
87 |
/** global transaction identifier, must be |
/** global transaction identifier, must be |
88 |
* unique for each DHCP request. */ |
* unique for each DHCP request. We simply increment, starting |
89 |
|
* with this value (easy to match with a packet analyzer) */ |
90 |
static u32_t xid = 0xABCD0000; |
static u32_t xid = 0xABCD0000; |
91 |
|
|
92 |
/** DHCP client state machine functions */ |
/** DHCP client state machine functions */ |
806 |
netif_set_netmask(netif, &sn_mask); |
netif_set_netmask(netif, &sn_mask); |
807 |
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08lx\n", gw_addr.addr)); |
LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08lx\n", gw_addr.addr)); |
808 |
netif_set_gw(netif, &gw_addr); |
netif_set_gw(netif, &gw_addr); |
809 |
|
/* bring the interface up */ |
810 |
|
netif_set_up(netif); |
811 |
/* netif is now bound to DHCP leased address */ |
/* netif is now bound to DHCP leased address */ |
812 |
dhcp_set_state(dhcp, DHCP_BOUND); |
dhcp_set_state(dhcp, DHCP_BOUND); |
813 |
} |
} |
963 |
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; |
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; |
964 |
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; |
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; |
965 |
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %u msecs\n", msecs)); |
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %u msecs\n", msecs)); |
966 |
|
/* bring the interface down */ |
967 |
|
netif_set_down(netif); |
968 |
/* remove IP address from interface */ |
/* remove IP address from interface */ |
969 |
netif_set_ipaddr(netif, IP_ADDR_ANY); |
netif_set_ipaddr(netif, IP_ADDR_ANY); |
970 |
netif_set_gw(netif, IP_ADDR_ANY); |
netif_set_gw(netif, IP_ADDR_ANY); |
971 |
netif_set_netmask(netif, IP_ADDR_ANY); |
netif_set_netmask(netif, IP_ADDR_ANY); |
972 |
|
|
973 |
/* TODO: netif_down(netif); */ |
/* TODO: netif_down(netif); */ |
974 |
return result; |
return result; |
975 |
} |
} |