mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
Oops.. interrupts must be disabled when uip_arp_update is called
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1635 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+29
-11
@@ -53,11 +53,12 @@ typedef unsigned char boolean;
|
|||||||
# define ERROR (-1)
|
# define ERROR (-1)
|
||||||
# define OK (0)
|
# define OK (0)
|
||||||
#else
|
#else
|
||||||
# include <nuttx/config.h>
|
# include <nuttx/config.h> /* NuttX configuration */
|
||||||
# include <debug.h>
|
# include <debug.h> /* For ndbg, vdbg */
|
||||||
# include <nuttx/compiler.h>
|
# include <nuttx/compiler.h> /* For CONFIG_CPP_HAVE_WARNING */
|
||||||
# include <net/uip/uip-arp.h>
|
# include <arch/irq.h> /* For irqstore() and friends -- REVISIT */
|
||||||
# include <net/uip/dhcpd.h>
|
# include <net/uip/uip-arp.h> /* For low-level ARP interfaces -- REVISIT */
|
||||||
|
# include <net/uip/dhcpd.h> /* Advertised DHCPD APIs */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -262,6 +263,27 @@ static struct dhcpd_state_s g_state;
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: dhcpd_arpupdate
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_NETUTILS_DHCPD_HOST
|
||||||
|
static inline void dhcpd_arpupdate(uint16 *pipaddr, uint8 *phwaddr)
|
||||||
|
{
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
|
/* Disable interrupts and update the ARP table -- very non-portable hack.
|
||||||
|
* REVISIT -- switch to the SIOCSARP ioctl call if/when it is implemented.
|
||||||
|
*/
|
||||||
|
|
||||||
|
flags = irqsave();
|
||||||
|
uip_arp_update(pipaddr, phwaddr);
|
||||||
|
irqrestore(flags);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define dhcpd_arpupdate(pipaddr,phwaddr)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: dhcpd_time
|
* Name: dhcpd_time
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -855,9 +877,7 @@ static int dhcpd_sendpacket(int bbroadcast)
|
|||||||
}
|
}
|
||||||
else if (memcmp(g_state.ds_outpacket.ciaddr, g_anyipaddr, 4) != 0)
|
else if (memcmp(g_state.ds_outpacket.ciaddr, g_anyipaddr, 4) != 0)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_NETUTILS_DHCPD_HOST // Backdoor uIP path to update ARP
|
dhcpd_arpupdate((uint16*)g_state.ds_outpacket.ciaddr, g_state.ds_outpacket.chaddr);
|
||||||
uip_arp_update((uint16*)g_state.ds_outpacket.ciaddr, g_state.ds_outpacket.chaddr);
|
|
||||||
#endif
|
|
||||||
memcpy(&ipaddr, g_state.ds_outpacket.ciaddr, 4);
|
memcpy(&ipaddr, g_state.ds_outpacket.ciaddr, 4);
|
||||||
}
|
}
|
||||||
else if (g_state.ds_outpacket.flags & HTONS(BOOTP_BROADCAST))
|
else if (g_state.ds_outpacket.flags & HTONS(BOOTP_BROADCAST))
|
||||||
@@ -866,9 +886,7 @@ static int dhcpd_sendpacket(int bbroadcast)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_NETUTILS_DHCPD_HOST // Backdoor uIP path to update ARP
|
dhcpd_arpupdate((uint16*)g_state.ds_outpacket.yiaddr, g_state.ds_outpacket.chaddr);
|
||||||
uip_arp_update((uint16*)g_state.ds_outpacket.yiaddr, g_state.ds_outpacket.chaddr);
|
|
||||||
#endif
|
|
||||||
memcpy(&ipaddr, g_state.ds_outpacket.yiaddr, 4);
|
memcpy(&ipaddr, g_state.ds_outpacket.yiaddr, 4);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user