summaryrefslogtreecommitdiffstats
path: root/src/hci
diff options
context:
space:
mode:
authorMichael Brown2014-10-23 17:30:58 +0200
committerMichael Brown2014-10-23 17:39:42 +0200
commit1c34ca70d199ceee9d663986e377b7f74c826d0c (patch)
tree31fd9def4bbf41ed099b33d3d86bb03134a2a41f /src/hci
parent[ping] Report timed-out pings via the callback function (diff)
downloadipxe-1c34ca70d199ceee9d663986e377b7f74c826d0c.tar.gz
ipxe-1c34ca70d199ceee9d663986e377b7f74c826d0c.tar.xz
ipxe-1c34ca70d199ceee9d663986e377b7f74c826d0c.zip
[ping] Allow termination after a specified number of packets
Add the "-c <count>" option to the "ping" command, allowing for automatic termination after a specified number of packets. When a number of packets is specified: - if a serious error (i.e. length mismatch or content mismatch) occurs, then the ping will be immediately terminated with the relevant status code; - if at least one response is received successfully, and all errors are non-serious (i.e. timeouts or out-of-sequence responses), then the ping will be terminated after the final response (or timeout) with a success status; - if no responses are received successfully, then the ping will be terminated after the final timeout with ETIMEDOUT. If no number of packets is specified, then the ping will continue until manually interrupted. Originally-implemented-by: Cedric Levasseur <cyr-ius@ipocus.net> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci')
-rw-r--r--src/hci/commands/ping_cmd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/hci/commands/ping_cmd.c b/src/hci/commands/ping_cmd.c
index d514a2a2..92c5443a 100644
--- a/src/hci/commands/ping_cmd.c
+++ b/src/hci/commands/ping_cmd.c
@@ -48,6 +48,8 @@ struct ping_options {
unsigned int size;
/** Timeout (in ms) */
unsigned long timeout;
+ /** Number of packets to send (or zero for no limit) */
+ unsigned int count;
};
/** "ping" option list */
@@ -56,6 +58,8 @@ static struct option_descriptor ping_opts[] = {
struct ping_options, size, parse_integer ),
OPTION_DESC ( "timeout", 't', required_argument,
struct ping_options, timeout, parse_timeout ),
+ OPTION_DESC ( "count", 'c', required_argument,
+ struct ping_options, count, parse_integer ),
};
/** "ping" command descriptor */
@@ -87,7 +91,8 @@ static int ping_exec ( int argc, char **argv ) {
hostname = argv[optind];
/* Ping */
- if ( ( rc = ping ( hostname, opts.timeout, opts.size ) ) != 0 )
+ if ( ( rc = ping ( hostname, opts.timeout, opts.size,
+ opts.count ) ) != 0 )
return rc;
return 0;