Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created April 26, 2013 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Habbie/5466621 to your computer and use it in GitHub Desktop.
Save Habbie/5466621 to your computer and use it in GitHub Desktop.
Patch to add a timeout option.
Index: dnsreplay.cc
===================================================================
--- dnsreplay.cc (revision 1092)
+++ dnsreplay.cc (working copy)
@@ -64,6 +64,7 @@
StatBag S;
bool g_quiet=true;
+uint16_t g_timeout=0;
namespace po = boost::program_options;
@@ -334,7 +335,7 @@
string packet;
IPEndpoint remote;
- int res=waitForData(s_socket->getHandle(), 0, 25000);
+ int res=waitForData(s_socket->getHandle(), g_timeout, 25000);
if(res < 0 || res==0)
return;
@@ -563,7 +564,8 @@
("packet-limit", po::value<uint32_t>()->default_value(0), "stop after this many packets")
("quiet", po::value<bool>()->default_value(true), "don't be too noisy")
("recursive", po::value<bool>()->default_value(true), "look at recursion desired packets, or not (defaults true)")
- ("speedup", po::value<uint16_t>()->default_value(1), "replay at this speedup");
+ ("speedup", po::value<uint16_t>()->default_value(1), "replay at this speedup")
+ ("timeout", po::value<uint16_t>()->default_value(0), "wait at least this many seconds for a reply");
po::options_description alloptions;
po::options_description hidden("hidden options");
@@ -602,6 +604,7 @@
g_quiet = g_vm["quiet"].as<bool>();
uint16_t speedup=g_vm["speedup"].as<uint16_t>();
+ g_timeout=g_vm["timeout"].as<uint16_t>();
PcapPacketReader pr(g_vm["pcap-source"].as<string>());
s_socket= new Socket(InterNetwork, Datagram);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment