123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
-
-
- FILE_LICENCE ( GPL2_OR_LATER );
-
- #include <stdint.h>
- #include <stdio.h>
- #include <string.h>
- #include <ipxe/pinger.h>
- #include <ipxe/monojob.h>
- #include <ipxe/timer.h>
- #include <usr/pingmgmt.h>
-
-
-
-
- static void ping_callback ( struct sockaddr *peer, unsigned int sequence,
- size_t len, int rc ) {
-
-
- printf ( "%zd bytes from %s: seq=%d",
- len, ( peer ? sock_ntoa ( peer ) : "<none>" ), sequence );
- if ( rc != 0 )
- printf ( ": %s", strerror ( rc ) );
- printf ( "\n" );
- }
-
-
- int ping ( const char *hostname, unsigned long timeout, size_t len,
- unsigned int count, int quiet ) {
- int rc;
-
-
- 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;
- }
-
-
- if ( ( rc = monojob_wait ( NULL, 0 ) ) != 0 ) {
- if ( ! quiet )
- printf ( "Finished: %s\n", strerror ( rc ) );
- return rc;
- }
-
- return 0;
- }
|