[ping] Allow "ping" command output to be inhibited

Originally-implemented-by: Cedric Levasseur <cyr-ius@ipocus.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2014-10-23 16:52:08 +01:00
parent 1c34ca70d1
commit dea6a6c1a0
4 changed files with 17 additions and 9 deletions

View File

@@ -59,22 +59,24 @@ static void ping_callback ( struct sockaddr *peer, unsigned int sequence,
* @v timeout Timeout between pings, in ticks
* @v len Payload length
* @v count Number of packets to send (or zero for no limit)
* @v quiet Inhibit output
* @ret rc Return status code
*/
int ping ( const char *hostname, unsigned long timeout, size_t len,
unsigned int count ) {
unsigned int count, int quiet ) {
int rc;
/* Create pinger */
if ( ( rc = create_pinger ( &monojob, hostname, timeout, len,
count, ping_callback ) ) != 0 ) {
if ( ( rc = create_pinger ( &monojob, hostname, timeout, len, count,
( quiet ? NULL : ping_callback ) ) ) != 0 ){
printf ( "Could not start ping: %s\n", strerror ( rc ) );
return rc;
}
/* Wait for ping to complete */
if ( ( rc = monojob_wait ( NULL, 0 ) ) != 0 ) {
printf ( "Finished: %s\n", strerror ( rc ) );
if ( ! quiet )
printf ( "Finished: %s\n", strerror ( rc ) );
return rc;
}