Fix problem with ping that prevent ping from going outside local network (Darcy Gong)

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5204 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-09-29 14:13:04 +00:00
parent 4333422d5f
commit ccb682f332
7 changed files with 145 additions and 120 deletions
+3
View File
@@ -3450,3 +3450,6 @@
original configuration had too much stuff turned on. Reducing original configuration had too much stuff turned on. Reducing
stack sizes, some features, and buffer sizes made the stack sizes, some features, and buffer sizes made the
configuration reliable (Reading from the LCD is still disabled). configuration reliable (Reading from the LCD is still disabled).
* net/uip/uip_icmpping.c: Fix problem that prevented ping from
going outside of local network. Submitted by Darcy Gong
+12 -11
View File
@@ -716,11 +716,12 @@ Where <subdir> is one of the following:
nuttx-code/NxWidgets/UnitTests/README.txt nuttx-code/NxWidgets/UnitTests/README.txt
Here is the quick summary of the build steps: Here is the quick summary of the build steps (Assuming that all of
the required packages are available in a directory ~/nuttx-code):
1. Intall the nxwm configuration 1. Intall the nxwm configuration
$ cd ~/nuttx/nuttx-code/tools $ cd ~/nuttx-code/tools
$ ./configure.sh shenzhou/nxwm $ ./configure.sh shenzhou/nxwm
2. Make the build context (only) 2. Make the build context (only)
@@ -732,27 +733,27 @@ Where <subdir> is one of the following:
3. Install the nxwm unit test 3. Install the nxwm unit test
$ cd ~/nuttx/nuttx-code/NxWidgets $ cd ~/nuttx-code/NxWidgets
$ tools/install.sh ~/nuttx/nuttx-code/apps nxwm $ tools/install.sh ~/nuttx-code/apps nxwm
Creating symbolic link Creating symbolic link
- To ~/nuttx/nuttx-code/NxWidgets/UnitTests/nxwm - To ~/nuttx-code/NxWidgets/UnitTests/nxwm
- At ~/nuttx/nuttx-code/apps/external - At ~/nuttx-code/apps/external
4. Build the NxWidgets library 4. Build the NxWidgets library
$ cd ~/nuttx/nuttx-code/NxWidgets/libnxwidgets $ cd ~/nuttx-code/NxWidgets/libnxwidgets
$ make TOPDIR=~/nuttx/nuttx-code $ make TOPDIR=~/nuttx-code
... ...
5. Build the NxWM library 5. Build the NxWM library
$ cd ~/nuttx/nuttx-code/NxWidgets/nxwm $ cd ~/nuttx-code/NxWidgets/nxwm
$ make TOPDIR=~/nuttx/nuttx-code $ make TOPDIR=~/nuttx-code
... ...
6. Built NuttX with the installed unit test as the application 6. Built NuttX with the installed unit test as the application
$ cd ~/nuttx/nuttx-code $ cd ~/nuttx-code
$ make $ make
NOTE: Reading from the LCD is not currently supported by this NOTE: Reading from the LCD is not currently supported by this
+3 -3
View File
@@ -409,15 +409,15 @@ nxwm
This is a special configuration setup for the NxWM window manager This is a special configuration setup for the NxWM window manager
UnitTest. The NxWM window manager can be found here: UnitTest. The NxWM window manager can be found here:
trunk/NxWidgets/nxwm nuttx-code/NxWidgets/nxwm
The NxWM unit test can be found at: The NxWM unit test can be found at:
trunk/NxWidgets/UnitTests/nxwm nuttx-code/NxWidgets/UnitTests/nxwm
Documentation for installing the NxWM unit test can be found here: Documentation for installing the NxWM unit test can be found here:
trunk/NxWidgets/UnitTests/READEM.txt nuttx-code/NxWidgets/UnitTests/READEM.txt
NOTE: There is an issue with running this example under the NOTE: There is an issue with running this example under the
simulation. In the default configuration, this example will simulation. In the default configuration, this example will
+15 -14
View File
@@ -947,21 +947,22 @@ Where <subdir> is one of the following:
This is a special configuration setup for the NxWM window manager This is a special configuration setup for the NxWM window manager
UnitTest. The NxWM window manager can be found here: UnitTest. The NxWM window manager can be found here:
trunk/NxWidgets/nxwm nuttx-code/NxWidgets/nxwm
The NxWM unit test can be found at: The NxWM unit test can be found at:
trunk/NxWidgets/UnitTests/nxwm nuttx-code/NxWidgets/UnitTests/nxwm
Documentation for installing the NxWM unit test can be found here: Documentation for installing the NxWM unit test can be found here:
trunk/NxWidgets/UnitTests/README.txt nuttx-code/NxWidgets/UnitTests/README.txt
Here is the quick summary of the build steps: Here is the quick summary of the build steps (Assuming that all of
the required packages are available in a directory ~/nuttx-code):
1. Intall the nxwm configuration 1. Intall the nxwm configuration
$ cd ~/nuttx/trunk/nuttx/tools $ cd ~/nuttx-code/nuttx/tools
$ ./configure.sh stm3220g-eval/nxwm $ ./configure.sh stm3220g-eval/nxwm
2. Make the build context (only) 2. Make the build context (only)
@@ -973,27 +974,27 @@ Where <subdir> is one of the following:
3. Install the nxwm unit test 3. Install the nxwm unit test
$ cd ~/nuttx/trunk/NxWidgets $ cd ~/nuttx-code/NxWidgets
$ tools/install.sh ~/nuttx/trunk/apps nxwm $ tools/install.sh ~/nuttx-code/apps nxwm
Creating symbolic link Creating symbolic link
- To ~/nuttx/trunk/NxWidgets/UnitTests/nxwm - To ~/nuttx-code/NxWidgets/UnitTests/nxwm
- At ~/nuttx/trunk/apps/external - At ~/nuttx-code/apps/external
4. Build the NxWidgets library 4. Build the NxWidgets library
$ cd ~/nuttx/trunk/NxWidgets/libnxwidgets $ cd ~/nuttx-code/NxWidgets/libnxwidgets
$ make TOPDIR=~/nuttx/trunk/nuttx $ make TOPDIR=~/nuttx-code/nuttx
... ...
5. Build the NxWM library 5. Build the NxWM library
$ cd ~/nuttx/trunk/NxWidgets/nxwm $ cd ~/nuttx-code/NxWidgets/nxwm
$ make TOPDIR=~//nuttx/trunk/nuttx $ make TOPDIR=~/nuttx-code/nuttx
... ...
6. Built NuttX with the installed unit test as the application 6. Built NuttX with the installed unit test as the application
$ cd ~/nuttx/trunk/nuttx $ cd ~/nuttx-code/nuttx
$ make $ make
ostest: ostest:
+13 -1
View File
@@ -507,7 +507,7 @@ CONFIG_STMPE811_THRESHX=39
CONFIG_STMPE811_THRESHY=51 CONFIG_STMPE811_THRESHY=51
# #
# USB Device Configuration # STM32 USB OTG FS Device Configuration
# #
CONFIG_USBDEV=n CONFIG_USBDEV=n
CONFIG_USBDEV_ISOCHRONOUS=n CONFIG_USBDEV_ISOCHRONOUS=n
@@ -518,6 +518,18 @@ CONFIG_USBDEV_MAXPOWER=100
CONFIG_USBDEV_TRACE=n CONFIG_USBDEV_TRACE=n
CONFIG_USBDEV_TRACE_NRECORDS=128 CONFIG_USBDEV_TRACE_NRECORDS=128
#
# STM32 USB OTG FS Host Configuration
#
CONFIG_USBHOST=n
#CONFIG_STM32_OTGFS_RXFIFO_SIZE
#CONFIG_STM32_OTGFS_NPTXFIFO_SIZE
#CONFIG_STM32_OTGFS_PTXFIFO_SIZE
#CONFIG_STM32_OTGFS_DESCSIZE
CONFIG_STM32_OTGFS_SOFINTR=n
CONFIG_STM32_USBHOST_REGDEBUG=n
CONFIG_STM32_USBHOST_PKTDUMP=n
# #
# USB Serial Device Configuration # USB Serial Device Configuration
# #
+15 -14
View File
@@ -1226,21 +1226,22 @@ Where <subdir> is one of the following:
This is a special configuration setup for the NxWM window manager This is a special configuration setup for the NxWM window manager
UnitTest. The NxWM window manager can be found here: UnitTest. The NxWM window manager can be found here:
trunk/NxWidgets/nxwm nuttx-code/NxWidgets/nxwm
The NxWM unit test can be found at: The NxWM unit test can be found at:
trunk/NxWidgets/UnitTests/nxwm nuttx-code/NxWidgets/UnitTests/nxwm
Documentation for installing the NxWM unit test can be found here: Documentation for installing the NxWM unit test can be found here:
trunk/NxWidgets/UnitTests/README.txt nuttx-code/NxWidgets/UnitTests/README.txt
Here is the quick summary of the build steps: Here is the quick summary of the build steps (Assuming that all of
the required packages are available in a directory ~/nuttx-code):
1. Intall the nxwm configuration 1. Intall the nxwm configuration
$ cd ~/nuttx/trunk/nuttx/tools $ cd ~/nuttx-code/nuttx/tools
$ ./configure.sh stm3240g-eval/nxwm $ ./configure.sh stm3240g-eval/nxwm
2. Make the build context (only) 2. Make the build context (only)
@@ -1252,27 +1253,27 @@ Where <subdir> is one of the following:
3. Install the nxwm unit test 3. Install the nxwm unit test
$ cd ~/nuttx/trunk/NxWidgets $ cd ~/nuttx-code/NxWidgets
$ tools/install.sh ~/nuttx/trunk/apps nxwm $ tools/install.sh ~/nuttx-code/apps nxwm
Creating symbolic link Creating symbolic link
- To ~/nuttx/trunk/NxWidgets/UnitTests/nxwm - To ~/nuttx-code/NxWidgets/UnitTests/nxwm
- At ~/nuttx/trunk/apps/external - At ~/nuttx-code/apps/external
4. Build the NxWidgets library 4. Build the NxWidgets library
$ cd ~/nuttx/trunk/NxWidgets/libnxwidgets $ cd ~/nuttx-code/NxWidgets/libnxwidgets
$ make TOPDIR=~/nuttx/trunk/nuttx $ make TOPDIR=~/nuttx-code/nuttx
... ...
5. Build the NxWM library 5. Build the NxWM library
$ cd ~/nuttx/trunk/NxWidgets/nxwm $ cd ~/nuttx-code/NxWidgets/nxwm
$ make TOPDIR=~//nuttx/trunk/nuttx $ make TOPDIR=~/nuttx-code/nuttx
... ...
6. Built NuttX with the installed unit test as the application 6. Built NuttX with the installed unit test as the application
$ cd ~/nuttx/trunk/nuttx $ cd ~/nuttx-code/nuttx
$ make $ make
ostest: ostest:
+26 -19
View File
@@ -152,25 +152,10 @@ static uint16_t ping_interrupt(struct uip_driver_s *dev, void *conn,
{ {
struct icmp_ping_s *pstate = (struct icmp_ping_s *)pvpriv; struct icmp_ping_s *pstate = (struct icmp_ping_s *)pvpriv;
uint8_t *ptr; uint8_t *ptr;
int failcode = -ETIMEDOUT;
int i; int i;
nllvdbg("flags: %04x\n", flags); nllvdbg("flags: %04x\n", flags);
if (pstate) if (pstate)
{
/* Check if this device is on the same network as the destination device. */
if (!uip_ipaddr_maskcmp(pstate->png_addr, dev->d_ipaddr, dev->d_netmask))
{
/* Destination address was not on the local network served by this
* device. If a timeout occurs, then the most likely reason is
* that the destination address is not reachable.
*/
nllvdbg("Not reachable\n");
failcode = -ENETUNREACH;
}
else
{ {
/* Check if this is a ICMP ECHO reply. If so, return the sequence /* Check if this is a ICMP ECHO reply. If so, return the sequence
* number to the caller. NOTE: We may not even have sent the * number to the caller. NOTE: We may not even have sent the
@@ -181,7 +166,8 @@ static uint16_t ping_interrupt(struct uip_driver_s *dev, void *conn,
if ((flags & UIP_ECHOREPLY) != 0 && conn != NULL) if ((flags & UIP_ECHOREPLY) != 0 && conn != NULL)
{ {
struct uip_icmpip_hdr *icmp = (struct uip_icmpip_hdr *)conn; struct uip_icmpip_hdr *icmp = (struct uip_icmpip_hdr *)conn;
nlldbg("ECHO reply: id=%d seqno=%d\n", ntohs(icmp->id), ntohs(icmp->seqno)); nlldbg("ECHO reply: id=%d seqno=%d\n",
ntohs(icmp->id), ntohs(icmp->seqno));
if (ntohs(icmp->id) == pstate->png_id) if (ntohs(icmp->id) == pstate->png_id)
{ {
@@ -200,7 +186,7 @@ static uint16_t ping_interrupt(struct uip_driver_s *dev, void *conn,
/* Check: /* Check:
* If the outgoing packet is available (it may have been claimed * If the outgoing packet is available (it may have been claimed
* by a sendto interrupt serving a different thread * by a sendto interrupt serving a different thread)
* -OR- * -OR-
* If the output buffer currently contains unprocessed incoming * If the output buffer currently contains unprocessed incoming
* data. * data.
@@ -249,21 +235,42 @@ static uint16_t ping_interrupt(struct uip_driver_s *dev, void *conn,
pstate->png_sent = true; pstate->png_sent = true;
return flags; return flags;
} }
}
/* Check if the selected timeout has elapsed */ /* Check if the selected timeout has elapsed */
if (ping_timeout(pstate)) if (ping_timeout(pstate))
{ {
/* Yes.. report the timeout */ int failcode;
/* Check if this device is on the same network as the destination
* device.
*/
if (!uip_ipaddr_maskcmp(pstate->png_addr, dev->d_ipaddr, dev->d_netmask))
{
/* Destination address was not on the local network served by this
* device. If a timeout occurs, then the most likely reason is
* that the destination address is not reachable.
*/
nlldbg("Not reachable\n");
failcode = -ENETUNREACH;
}
else
{
nlldbg("Ping timeout\n"); nlldbg("Ping timeout\n");
failcode = -ETIMEDOUT;
}
/* Report the failure */
pstate->png_result = failcode; pstate->png_result = failcode;
goto end_wait; goto end_wait;
} }
/* Continue waiting */ /* Continue waiting */
} }
return flags; return flags;
end_wait: end_wait: