mirror of
https://github.com/ipxe/ipxe
synced 2025-12-20 03:55:46 +03:00
[parseopt] Add parse_timeout()
Parsing a timeout value (specified in milliseconds) into an internal timeout value measured in timer ticks is a common operation. Provide a parse_timeout() value to carry out this conversion automatically. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
#include <getopt.h>
|
||||
#include <ipxe/command.h>
|
||||
#include <ipxe/parseopt.h>
|
||||
#include <ipxe/timer.h>
|
||||
#include <usr/pingmgmt.h>
|
||||
|
||||
/** @file
|
||||
@@ -39,14 +40,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
#define PING_DEFAULT_SIZE 64
|
||||
|
||||
/** Default timeout */
|
||||
#define PING_DEFAULT_TIMEOUT 1000
|
||||
#define PING_DEFAULT_TIMEOUT TICKS_PER_SEC
|
||||
|
||||
/** "ping" options */
|
||||
struct ping_options {
|
||||
/** Payload length */
|
||||
unsigned int size;
|
||||
/** Timeout (in ms) */
|
||||
unsigned int timeout;
|
||||
unsigned long timeout;
|
||||
};
|
||||
|
||||
/** "ping" option list */
|
||||
@@ -54,7 +55,7 @@ static struct option_descriptor ping_opts[] = {
|
||||
OPTION_DESC ( "size", 's', required_argument,
|
||||
struct ping_options, size, parse_integer ),
|
||||
OPTION_DESC ( "timeout", 't', required_argument,
|
||||
struct ping_options, timeout, parse_integer ),
|
||||
struct ping_options, timeout, parse_timeout ),
|
||||
};
|
||||
|
||||
/** "ping" command descriptor */
|
||||
|
||||
Reference in New Issue
Block a user