mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 02:51:36 +08:00
Ping/DNS fixes (part 2 of 2)
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5236 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -75,6 +75,7 @@ EXTERN int resolv_query(FAR const char *name, FAR struct sockaddr_in *addr);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXTERN int dns_gethostip(const char *hostname, in_addr_t *ipaddr);
|
EXTERN int dns_gethostip(const char *hostname, in_addr_t *ipaddr);
|
||||||
|
|
||||||
#define dns_setserver resolv_conf
|
#define dns_setserver resolv_conf
|
||||||
#define dns_getserver resolv_getserver
|
#define dns_getserver resolv_getserver
|
||||||
#define dns_whois resolv_query
|
#define dns_whois resolv_query
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ config NET_RESOLV_ENTRIES
|
|||||||
---help---
|
---help---
|
||||||
Number of resolver entries. Default: 8
|
Number of resolver entries. Default: 8
|
||||||
|
|
||||||
NET_RESOLV_MAXRESPONSE
|
config NET_RESOLV_MAXRESPONSE
|
||||||
int "Max response size"
|
int "Max response size"
|
||||||
default 96
|
default 96
|
||||||
depends on NETUTILS_RESOLV
|
depends on NETUTILS_RESOLV
|
||||||
|
|||||||
@@ -520,3 +520,12 @@ config NSH_NOMAC
|
|||||||
---help---
|
---help---
|
||||||
Set if your ethernet hardware has no built-in MAC address.
|
Set if your ethernet hardware has no built-in MAC address.
|
||||||
If set, a bogus MAC will be assigned.
|
If set, a bogus MAC will be assigned.
|
||||||
|
|
||||||
|
config NSH_MAX_ROUNDTRIP
|
||||||
|
int "Max Ping Round-Trip (DSEC)"
|
||||||
|
default 20
|
||||||
|
depends on NSH_LIBRARY && NET && !NSH_DISABLE_PING
|
||||||
|
---help---
|
||||||
|
This is the maximum round trip for a response to a ICMP ECHO request.
|
||||||
|
It is in units of deciseconds. The default is 20 (2 seconds).
|
||||||
|
|
||||||
|
|||||||
@@ -215,6 +215,15 @@
|
|||||||
|
|
||||||
#endif /* CONFIG_NSH_TELNET_LOGIN */
|
#endif /* CONFIG_NSH_TELNET_LOGIN */
|
||||||
|
|
||||||
|
/* CONFIG_NSH_MAX_ROUNDTRIP - This is the maximum round trip for a response to
|
||||||
|
* a ICMP ECHO request. It is in units of deciseconds. The default is 20
|
||||||
|
* (2 seconds).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_NSH_MAX_ROUNDTRIP
|
||||||
|
# define CONFIG_NSH_MAX_ROUNDTRIP 20
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Verify support for ROMFS /etc directory support options */
|
/* Verify support for ROMFS /etc directory support options */
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_ROMFSETC
|
#ifdef CONFIG_NSH_ROMFSETC
|
||||||
|
|||||||
@@ -94,8 +94,16 @@
|
|||||||
* Definitions
|
* Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Size of the ECHO data */
|
||||||
|
|
||||||
#define DEFAULT_PING_DATALEN 56
|
#define DEFAULT_PING_DATALEN 56
|
||||||
|
|
||||||
|
/* Get the larger value */
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
# define MAX(a,b) (a > b ? a : b)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -543,6 +551,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
uint32_t start;
|
uint32_t start;
|
||||||
uint32_t next;
|
uint32_t next;
|
||||||
uint32_t dsec = 10;
|
uint32_t dsec = 10;
|
||||||
|
uint32_t maxwait;
|
||||||
uint16_t id;
|
uint16_t id;
|
||||||
bool badarg = false;
|
bool badarg = false;
|
||||||
int count = 10;
|
int count = 10;
|
||||||
@@ -626,6 +635,12 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
|
|
||||||
id = ping_newid();
|
id = ping_newid();
|
||||||
|
|
||||||
|
/* The maximum wait for a response will be the larger of the inter-ping time and
|
||||||
|
* the configured maximum round-trip time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
maxwait = MAX(dsec, CONFIG_NSH_MAX_ROUNDTRIP);
|
||||||
|
|
||||||
/* Loop for the specified count */
|
/* Loop for the specified count */
|
||||||
|
|
||||||
nsh_output(vtbl, "PING %d.%d.%d.%d %d bytes of data\n",
|
nsh_output(vtbl, "PING %d.%d.%d.%d %d bytes of data\n",
|
||||||
@@ -639,7 +654,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
/* Send the ECHO request and wait for the response */
|
/* Send the ECHO request and wait for the response */
|
||||||
|
|
||||||
next = g_system_timer;
|
next = g_system_timer;
|
||||||
seqno = uip_ping(ipaddr, id, i, DEFAULT_PING_DATALEN, dsec);
|
seqno = uip_ping(ipaddr, id, i, DEFAULT_PING_DATALEN, maxwait);
|
||||||
|
|
||||||
/* Was any response returned? We can tell if a non-negative sequence
|
/* Was any response returned? We can tell if a non-negative sequence
|
||||||
* number was returned.
|
* number was returned.
|
||||||
@@ -647,7 +662,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
|
|
||||||
if (seqno >= 0 && seqno <= i)
|
if (seqno >= 0 && seqno <= i)
|
||||||
{
|
{
|
||||||
/* Get the elpased time from the time that the request was
|
/* Get the elapsed time from the time that the request was
|
||||||
* sent until the response was received. If we got a response
|
* sent until the response was received. If we got a response
|
||||||
* to an earlier request, then fudge the elpased time.
|
* to an earlier request, then fudge the elpased time.
|
||||||
*/
|
*/
|
||||||
@@ -655,7 +670,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
elapsed = TICK2MSEC(g_system_timer - next);
|
elapsed = TICK2MSEC(g_system_timer - next);
|
||||||
if (seqno < i)
|
if (seqno < i)
|
||||||
{
|
{
|
||||||
elapsed += 100*dsec*(i - seqno);
|
elapsed += 100 * dsec * (i - seqno);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Report the receipt of the reply */
|
/* Report the receipt of the reply */
|
||||||
@@ -673,7 +688,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
elapsed = TICK2DSEC(g_system_timer - next);
|
elapsed = TICK2DSEC(g_system_timer - next);
|
||||||
if (elapsed < dsec)
|
if (elapsed < dsec)
|
||||||
{
|
{
|
||||||
usleep(100000*dsec);
|
usleep(100000 * (dsec - elapsed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ static inline int ping_timeout(struct icmp_ping_s *pstate)
|
|||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +366,7 @@ int uip_ping(uip_ipaddr_t addr, uint16_t id, uint16_t seqno,
|
|||||||
|
|
||||||
uip_icmpcallbackfree(state.png_cb);
|
uip_icmpcallbackfree(state.png_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
uip_unlock(save);
|
uip_unlock(save);
|
||||||
|
|
||||||
/* Return the negated error number in the event of a failure, or the
|
/* Return the negated error number in the event of a failure, or the
|
||||||
|
|||||||
Reference in New Issue
Block a user