chunks+peek+ping: use correct underlying type for time::milliseconds
Change-Id: I3f46f846401eccc0c11d3abcd1a5ebff89056f7d
diff --git a/tools/peek/ndnpeek/main.cpp b/tools/peek/ndnpeek/main.cpp
index ead3d70..70977aa 100644
--- a/tools/peek/ndnpeek/main.cpp
+++ b/tools/peek/ndnpeek/main.cpp
@@ -54,8 +54,9 @@
po::options_description genericOptDesc("Generic options");
genericOptDesc.add_options()
("help,h", "print help and exit")
- ("payload,p", po::bool_switch(&options.wantPayloadOnly), "print payload only, instead of full packet")
- ("timeout,w", po::value<int>(), "set timeout (in milliseconds)")
+ ("payload,p", po::bool_switch(&options.wantPayloadOnly),
+ "print payload only, instead of full packet")
+ ("timeout,w", po::value<time::milliseconds::rep>(), "execution timeout, in milliseconds")
("verbose,v", po::bool_switch(&options.isVerbose), "turn on verbose output")
("version,V", "print version and exit")
;
@@ -65,7 +66,8 @@
("prefix,P", po::bool_switch(&options.canBePrefix), "set CanBePrefix")
("fresh,f", po::bool_switch(&options.mustBeFresh), "set MustBeFresh")
("link-file", po::value<std::string>(), "set ForwardingHint from a file")
- ("lifetime,l", po::value<int>(), "set InterestLifetime (in milliseconds)")
+ ("lifetime,l", po::value<time::milliseconds::rep>()->default_value(options.interestLifetime.count()),
+ "set InterestLifetime, in milliseconds")
;
po::options_description visibleOptDesc;
@@ -115,21 +117,15 @@
return 2;
}
- if (vm.count("lifetime") > 0) {
- if (vm["lifetime"].as<int>() >= 0) {
- options.interestLifetime = time::milliseconds(vm["lifetime"].as<int>());
- }
- else {
- std::cerr << "ERROR: lifetime cannot be negative" << std::endl;
- return 2;
- }
+ options.interestLifetime = time::milliseconds(vm["lifetime"].as<time::milliseconds::rep>());
+ if (options.interestLifetime < 0_ms) {
+ std::cerr << "ERROR: lifetime cannot be negative" << std::endl;
+ return 2;
}
if (vm.count("timeout") > 0) {
- if (vm["timeout"].as<int>() >= 0) {
- options.timeout = time::milliseconds(vm["timeout"].as<int>());
- }
- else {
+ options.timeout = time::milliseconds(vm["timeout"].as<time::milliseconds::rep>());
+ if (*options.timeout < 0_ms) {
std::cerr << "ERROR: timeout cannot be negative" << std::endl;
return 2;
}