original files of m241
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipnet_cmd_ping.c,v $ $Revision: 1.99.10.12 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipnet2/src/ipnet_cmd_ping.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth.jonsson@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Implements the "ping" shell command. ping uses ICMP echo
|
||||
* request/response messages to see if a specific node is currently
|
||||
* reachable.
|
||||
*
|
||||
* This version of ping also implements ICMP timestamp
|
||||
* request/response where each intermediate router, between this node
|
||||
* and the node the request is sent to, can insert the time the packet
|
||||
* passed through that router.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_KERNEL
|
||||
#undef IPCOM_KERNEL
|
||||
#endif
|
||||
#include "ipnet_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_INET
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_shell.h>
|
||||
|
||||
#include "ipnet.h"
|
||||
#include "ipnet_h.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
extern int ping(char *host,int numPackets,unsigned long options);
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipnet_cmd_ping
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipnet_cmd_ping(int argc, char **argv)
|
||||
{
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
int i = 0;
|
||||
int len = 0;
|
||||
char *host;
|
||||
int ret = IPCOM_SHELL_SUCCESS;
|
||||
|
||||
if(argc == 1)
|
||||
{
|
||||
(void)ping(IP_NULL,0,0);
|
||||
ret = IPCOM_SHELL_ERR_USAGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i = 1;i<argc;i++)
|
||||
{
|
||||
len += ipcom_strlen(argv[i]);
|
||||
}
|
||||
host = ipcom_malloc(len+argc-1);
|
||||
if(host == IP_NULL)
|
||||
{
|
||||
return IPCOM_SHELL_ERR;
|
||||
}
|
||||
ipcom_memset(host,0,len+argc-1);
|
||||
|
||||
for(i = 1;i<argc;i++)
|
||||
{
|
||||
if(i == (argc-1))
|
||||
{
|
||||
ipcom_sprintf(host,"%s%s",host,argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipcom_sprintf(host,"%s%s ",host,argv[i]);
|
||||
}
|
||||
}
|
||||
if (ping(host,0,0) != 0)
|
||||
ret = IPCOM_SHELL_ERR;
|
||||
ipcom_free(host);
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
return ipnet_cmd_ping_stoppable(argc, argv, IP_NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* IPCOM_USE_INET */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user