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;
     }
diff --git a/tools/peek/ndnpeek/ndnpeek.cpp b/tools/peek/ndnpeek/ndnpeek.cpp
index 8969216..ff7f7a0 100644
--- a/tools/peek/ndnpeek/ndnpeek.cpp
+++ b/tools/peek/ndnpeek/ndnpeek.cpp
@@ -62,12 +62,10 @@
   Interest interest(m_options.name);
   interest.setCanBePrefix(m_options.canBePrefix);
   interest.setMustBeFresh(m_options.mustBeFresh);
+  interest.setInterestLifetime(m_options.interestLifetime);
   if (m_options.link) {
     interest.setForwardingHint(m_options.link->getDelegationList());
   }
-  if (m_options.interestLifetime) {
-    interest.setInterestLifetime(*m_options.interestLifetime);
-  }
 
   if (m_options.isVerbose) {
     std::cerr << "INTEREST: " << interest << std::endl;
diff --git a/tools/peek/ndnpeek/ndnpeek.hpp b/tools/peek/ndnpeek/ndnpeek.hpp
index 0a9f503..d02155f 100644
--- a/tools/peek/ndnpeek/ndnpeek.hpp
+++ b/tools/peek/ndnpeek/ndnpeek.hpp
@@ -47,9 +47,9 @@
   bool canBePrefix = false;
   bool mustBeFresh = false;
   shared_ptr<Link> link;
-  optional<time::milliseconds> interestLifetime;
+  time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME;
 
-  // output behavior options
+  // program behavior options
   bool isVerbose = false;
   bool wantPayloadOnly = false;
   optional<time::milliseconds> timeout;
diff --git a/tools/peek/ndnpoke/main.cpp b/tools/peek/ndnpoke/main.cpp
index 913b0a8..4e8713a 100644
--- a/tools/peek/ndnpoke/main.cpp
+++ b/tools/peek/ndnpoke/main.cpp
@@ -55,7 +55,7 @@
     ("help,h",        "print help and exit")
     ("unsolicited,u", po::bool_switch(&options.wantUnsolicited),
                       "send the Data packet without waiting for an incoming Interest")
-    ("timeout,w",     po::value<time::milliseconds::rep>(), "set timeout (in milliseconds)")
+    ("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 +65,7 @@
     ("final,F",     po::bool_switch(&options.wantFinalBlockId),
                     "set FinalBlockId to the last component of the Data name")
     ("freshness,x", po::value<time::milliseconds::rep>()->default_value(options.freshnessPeriod.count()),
-                    "set FreshnessPeriod (in milliseconds)")
+                    "set FreshnessPeriod, in milliseconds")
     ("identity,i",  po::value<std::string>(), "use the specified identity for signing")
     ("digest,D",    po::bool_switch(&wantDigestSha256),
                     "use DigestSha256 signing method instead of SignatureSha256WithRsa")
@@ -134,13 +134,10 @@
     return 2;
   }
 
-  if (vm.count("freshness") > 0) {
-    auto freshness = vm["freshness"].as<time::milliseconds::rep>();
-    if (freshness < 0) {
-      std::cerr << "ERROR: freshness cannot be negative" << std::endl;
-      return 2;
-    }
-    options.freshnessPeriod = time::milliseconds(freshness);
+  options.freshnessPeriod = time::milliseconds(vm["freshness"].as<time::milliseconds::rep>());
+  if (options.freshnessPeriod < 0_ms) {
+    std::cerr << "ERROR: freshness cannot be negative" << std::endl;
+    return 2;
   }
 
   if (vm.count("identity") > 0) {
@@ -166,12 +163,11 @@
       std::cerr << "ERROR: conflicting '--unsolicited' and '--timeout' options specified" << std::endl;
       return 2;
     }
-    auto timeout = vm["timeout"].as<time::milliseconds::rep>();
-    if (timeout < 0) {
+    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;
     }
-    options.timeout = time::milliseconds(timeout);
   }
 
   try {