dump: add -t option to suppress printing per-packet timestamp
Change-Id: I4e0e44c62451629428d2d065692a0cb497a9203a
This commit is contained in:
1 parent
24c0861e33
commit
b5b8f95024
5 files changed
+21
-1
No files matched your search
@@ -54,6 +54,10 @@ Options
|
||||
|
||||
Do not put the interface into promiscuous mode.
|
||||
|
||||
.. option:: -t, --no-timestamp
|
||||
|
||||
Do not print a timestamp for each packet.
|
||||
|
||||
.. option:: -v, --verbose
|
||||
|
||||
Produce verbose output.
|
||||
|
||||
@@ -191,6 +191,17 @@ BOOST_AUTO_TEST_CASE(CaptureUnknownNetworkPacket)
|
||||
BOOST_CHECK(output.is_equal(expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NoTimestamp)
|
||||
{
|
||||
dump.wantTimestamp = false;
|
||||
|
||||
lp::Packet lpPacket;
|
||||
this->receive(lpPacket);
|
||||
|
||||
const std::string expected = "Tunnel Type: EthernetFrame, NDNLPv2-IDLE\n";
|
||||
BOOST_CHECK(output.is_equal(expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(PcapTraceFile)
|
||||
{
|
||||
dump.inputFile = "tests/dump/nack.pcap";
|
||||
|
||||
@@ -74,6 +74,7 @@ main(int argc, char* argv[])
|
||||
("filter,f", po::value<std::string>(&nameFilter),
|
||||
"print packet only if name matches this regular expression")
|
||||
("no-promiscuous-mode,p", po::bool_switch(), "do not put the interface into promiscuous mode")
|
||||
("no-timestamp,t", po::bool_switch(), "do not print a timestamp for each packet")
|
||||
("verbose,v", po::bool_switch(&instance.wantVerbose),
|
||||
"print more detailed information about each packet")
|
||||
("version,V", "print program version and exit")
|
||||
@@ -140,6 +141,7 @@ main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
instance.wantPromisc = !vm["no-promiscuous-mode"].as<bool>();
|
||||
instance.wantTimestamp = !vm["no-timestamp"].as<bool>();
|
||||
|
||||
try {
|
||||
instance.run();
|
||||
|
||||
@@ -158,7 +158,9 @@ NdnDump::printPacket(const pcap_pkthdr* pkthdr, const uint8_t* payload) const
|
||||
}
|
||||
|
||||
std::ostringstream os;
|
||||
printTimestamp(os, pkthdr->ts);
|
||||
if (wantTimestamp) {
|
||||
printTimestamp(os, pkthdr->ts);
|
||||
}
|
||||
|
||||
ssize_t payloadSize = pkthdr->len;
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ public: // options
|
||||
std::string pcapFilter = getDefaultPcapFilter();
|
||||
optional<std::regex> nameFilter;
|
||||
bool wantPromisc = true;
|
||||
bool wantTimestamp = true;
|
||||
bool wantVerbose = false;
|
||||
|
||||
private:
|
||||
|
||||
Reference in new issue
Block a user