diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-03-21 17:30:38 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-03-21 17:30:38 +0000 |
commit | 118c4424f2f67b67c9fb96cf7cadeac3a0935e38 (patch) | |
tree | 8ad80ad9f7607a2b9627620c6dc65f7a055e5079 | |
parent | 931f978f82f6f5f4bef7adc9513366d26f6f866c (diff) | |
download | px4-nuttx-118c4424f2f67b67c9fb96cf7cadeac3a0935e38.tar.gz px4-nuttx-118c4424f2f67b67c9fb96cf7cadeac3a0935e38.tar.bz2 px4-nuttx-118c4424f2f67b67c9fb96cf7cadeac3a0935e38.zip |
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
-rw-r--r-- | nuttx/netutils/dhcpd/dhcpd.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/nuttx/netutils/dhcpd/dhcpd.c b/nuttx/netutils/dhcpd/dhcpd.c index 522936f88..53e7462b2 100644 --- a/nuttx/netutils/dhcpd/dhcpd.c +++ b/nuttx/netutils/dhcpd/dhcpd.c @@ -53,11 +53,12 @@ typedef unsigned char boolean; # define ERROR (-1) # define OK (0) #else -# include <nuttx/config.h> -# include <debug.h> -# include <nuttx/compiler.h> -# include <net/uip/uip-arp.h> -# include <net/uip/dhcpd.h> +# include <nuttx/config.h> /* NuttX configuration */ +# include <debug.h> /* For ndbg, vdbg */ +# include <nuttx/compiler.h> /* For CONFIG_CPP_HAVE_WARNING */ +# include <arch/irq.h> /* For irqstore() and friends -- REVISIT */ +# include <net/uip/uip-arp.h> /* For low-level ARP interfaces -- REVISIT */ +# include <net/uip/dhcpd.h> /* Advertised DHCPD APIs */ #endif #include <sys/types.h> @@ -263,6 +264,27 @@ static struct dhcpd_state_s g_state; ****************************************************************************/ /**************************************************************************** + * 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 ****************************************************************************/ @@ -855,9 +877,7 @@ static int dhcpd_sendpacket(int bbroadcast) } else if (memcmp(g_state.ds_outpacket.ciaddr, g_anyipaddr, 4) != 0) { -#ifndef CONFIG_NETUTILS_DHCPD_HOST // Backdoor uIP path to update ARP - uip_arp_update((uint16*)g_state.ds_outpacket.ciaddr, g_state.ds_outpacket.chaddr); -#endif + dhcpd_arpupdate((uint16*)g_state.ds_outpacket.ciaddr, g_state.ds_outpacket.chaddr); memcpy(&ipaddr, g_state.ds_outpacket.ciaddr, 4); } else if (g_state.ds_outpacket.flags & HTONS(BOOTP_BROADCAST)) @@ -866,9 +886,7 @@ static int dhcpd_sendpacket(int bbroadcast) } else { -#ifndef CONFIG_NETUTILS_DHCPD_HOST // Backdoor uIP path to update ARP - uip_arp_update((uint16*)g_state.ds_outpacket.yiaddr, g_state.ds_outpacket.chaddr); -#endif + dhcpd_arpupdate((uint16*)g_state.ds_outpacket.yiaddr, g_state.ds_outpacket.chaddr); memcpy(&ipaddr, g_state.ds_outpacket.yiaddr, 4); } #endif |