configurable timeout step
[anna.git] / example / diameter / launcher / Procedure.cpp
index fff5a91..ad3b908 100644 (file)
@@ -28,7 +28,7 @@ namespace {
    void usage (std::string &response) {
      response += "\n\nInvalid arguments. Provide these ones:";
      response += "\n";
-     response += "\n<initial sequence>|<final sequence>|<digits>|<CCR-I xml file>[|CCR-T xml file]";
+     response += "\n<test timeout ms (0: no timeout step)><initial sequence>|<final sequence>|<digits>|<CCR-I xml file>[|CCR-T xml file]";
      response += "\n";
      response += "\nSequences are parsed when needed, over AVPs or internal values:";
      response += "\n";
@@ -43,7 +43,7 @@ namespace {
      response += "\nThe same will be done in MSISDN and IMSI (Subscription-Data AVPs).";
      response += "\nFramed-IP-Address will be sequenced with a direct correspondence to hex value.";
      response += "\n";
-     response += "\nThen, you could provide these arguments: \"2000000|9000000|7|CCR-I.xml|CCR-T.xml\"";
+     response += "\nThen, you could provide these arguments: \"5000|2000000|9000000|7|CCR-I.xml|CCR-T.xml\"";
      response += "\n";
    }
 }
@@ -55,13 +55,14 @@ void Procedure::execute(const std::string &args, std::string &response)  throw(a
   anna::Tokenizer targs;
   targs.apply(args, "|");
 
-  if (targs.size() < 4) {
+  if (targs.size() < 5) {
     usage(response);
     return;
   }
 
   anna::Tokenizer::const_iterator tok_it = targs.begin();
 
+  std::string timeout = anna::Tokenizer::data(tok_it); tok_it++;
   std::string seq_i = anna::Tokenizer::data(tok_it); tok_it++;
   std::string seq_f = anna::Tokenizer::data(tok_it); tok_it++;
   std::string digits = anna::Tokenizer::data(tok_it); tok_it++;
@@ -70,6 +71,7 @@ void Procedure::execute(const std::string &args, std::string &response)  throw(a
   bool haveTermination = (ccr_t != "");
 
   // Test cases cycles:
+  int i_timeout = std::atoi(timeout.c_str());
   unsigned int ll_seq_i = std::atol(seq_i.c_str());
   unsigned int ll_seq_f = std::atol(seq_f.c_str());
   unsigned int ll_seq_size = ll_seq_f - ll_seq_i + 1;
@@ -86,7 +88,7 @@ void Procedure::execute(const std::string &args, std::string &response)  throw(a
   }
 
   unsigned int ll_seq, ll_index;
-  anna::Millisecond timeout(5000);
+  anna::Millisecond timeoutMS(i_timeout);
 
   // Load xml messages:
   anna::diameter::codec::Message ccri, ccrt;
@@ -253,8 +255,10 @@ void Procedure::execute(const std::string &args, std::string &response)  throw(a
     //    test|__TESTID__|sendxml2e|ccr-t.xml
     //    test|__TESTID__|waitfe|272|0|||11111__SEQ8__;BAT004;esmdx0900.gxrel10plusrealm.com;90__SEQ8__|2001
 
-    // Step 1: timeout 5000 ms:
-    tc->addTimeout(timeout);
+    if (i_timeout != 0) {
+      // Step 1: timeout 5000 ms:
+      tc->addTimeout(timeoutMS);
+    }
 
     // Step 2: sendxml2e: CCR-Initial
     tc->addSendxml2e(ccri.code(), oh, -1 /* 'wait for request' step number for answers */);