mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 00:14:02 +00:00
More robust DHCP ARP reply checking.
This commit is contained in:
parent
6880fa62f8
commit
8579e4144f
@ -633,8 +633,9 @@ void dhcp_inform(struct netif *netif)
|
|||||||
*/
|
*/
|
||||||
void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr)
|
void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr)
|
||||||
{
|
{
|
||||||
|
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()\n"));
|
||||||
/* is this DHCP client doing an ARP check? */
|
/* is a DHCP client doing an ARP check? */
|
||||||
if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) {
|
if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) {
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08lx\n", addr->addr));
|
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08lx\n", addr->addr));
|
||||||
/* did a host respond with the address we
|
/* did a host respond with the address we
|
||||||
|
@ -431,7 +431,7 @@ void
|
|||||||
etharp_ip_input(struct netif *netif, struct pbuf *p)
|
etharp_ip_input(struct netif *netif, struct pbuf *p)
|
||||||
{
|
{
|
||||||
struct ethip_hdr *hdr;
|
struct ethip_hdr *hdr;
|
||||||
|
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||||
/* Only insert an entry if the source IP address of the
|
/* Only insert an entry if the source IP address of the
|
||||||
incoming IP packet comes from a host on the local network. */
|
incoming IP packet comes from a host on the local network. */
|
||||||
hdr = p->payload;
|
hdr = p->payload;
|
||||||
@ -473,6 +473,8 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
|||||||
u8_t i;
|
u8_t i;
|
||||||
u8_t for_us;
|
u8_t for_us;
|
||||||
|
|
||||||
|
LWIP_ASSERT("netif != NULL", netif != NULL);
|
||||||
|
|
||||||
/* drop short ARP packets */
|
/* drop short ARP packets */
|
||||||
if (p->tot_len < sizeof(struct etharp_hdr)) {
|
if (p->tot_len < sizeof(struct etharp_hdr)) {
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr)));
|
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr)));
|
||||||
@ -554,9 +556,12 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
|||||||
/* ARP reply. We already updated the ARP cache earlier. */
|
/* ARP reply. We already updated the ARP cache earlier. */
|
||||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n"));
|
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n"));
|
||||||
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
|
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
|
||||||
/* When unconfigured, DHCP wants to know about ARP replies from the
|
/* DHCP wants to know about ARP replies from any host with an
|
||||||
* address offered to us, as that means someone else uses it already! */
|
* IP address also offered to us by the DHCP server. We do not
|
||||||
if (netif->ip_addr.addr == 0) dhcp_arp_reply(netif, &sipaddr);
|
* want to take a duplicate IP address on a single network.
|
||||||
|
* @todo How should we handle redundant (fail-over) interfaces?
|
||||||
|
* */
|
||||||
|
dhcp_arp_reply(netif, &sipaddr);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user