diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-10-20 13:47:30 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-10-20 13:47:30 +0000 |
commit | 78ba846c066a97fab1c5f485d4d7fff3bb55d215 (patch) | |
tree | 748852e6262da138e2481a706be911c0b548df57 /apps/nshlib/nsh_netcmds.c | |
parent | 860e5f0524a79a3fc7c776d925d1e73066b7f78d (diff) | |
download | px4-firmware-78ba846c066a97fab1c5f485d4d7fff3bb55d215.tar.gz px4-firmware-78ba846c066a97fab1c5f485d4d7fff3bb55d215.tar.bz2 px4-firmware-78ba846c066a97fab1c5f485d4d7fff3bb55d215.zip |
DNS fixes from Darcy Gong (part 1 of 2)
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5235 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib/nsh_netcmds.c')
-rw-r--r-- | apps/nshlib/nsh_netcmds.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/apps/nshlib/nsh_netcmds.c b/apps/nshlib/nsh_netcmds.c index cfea5a08a..e04dab123 100644 --- a/apps/nshlib/nsh_netcmds.c +++ b/apps/nshlib/nsh_netcmds.c @@ -51,6 +51,7 @@ #include <fcntl.h> /* Needed for open */ #include <libgen.h> /* Needed for basename */ #include <errno.h> +#include <debug.h> #include <nuttx/net/net.h> #include <nuttx/clock.h> @@ -80,6 +81,12 @@ # endif #endif +#ifdef CONFIG_HAVE_GETHOSTBYNAME +# include <netdb.h> +#else +# include <apps/netutils/resolv.h> +#endif + #include "nsh.h" #include "nsh_console.h" @@ -599,7 +606,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) if (optind == argc-1) { staddr = argv[optind]; - if (!uiplib_ipaddrconv(staddr, (FAR unsigned char*)&ipaddr)) + if (dns_gethostip(staddr, &ipaddr) < 0) { goto errout; } @@ -621,7 +628,11 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) /* Loop for the specified count */ - nsh_output(vtbl, "PING %s %d bytes of data\n", staddr, DEFAULT_PING_DATALEN); + nsh_output(vtbl, "PING %d.%d.%d.%d %d bytes of data\n", + (ipaddr ) & 0xff, (ipaddr >> 8 ) & 0xff, + (ipaddr >> 16 ) & 0xff, (ipaddr >> 24 ) & 0xff, + DEFAULT_PING_DATALEN); + start = g_system_timer; for (i = 1; i <= count; i++) { |