Non strict validation. Activate git add in pre-commit hook after astyle.
[anna.git] / example / diameter / pcapDecoder / main.cpp
index 30d9cba..80278e4 100644 (file)
@@ -334,9 +334,10 @@ int main(int argc, char **argv) {
   //check command line arguments
   if(argc < 3) {
     std::string msg = "Usage: "; msg += exec;
-    msg += " <dictionaries> <input file> [--ignore-flags: non-strict validation]\n\n";
-    msg += "       dictionaries: list of comma-separated xml dictionaries (one or more can be provided).\n";
-    msg += "       Input file:   normally a pcap file, but hexadecimal content (colons allowed) can also be decoded (use '.hex' extension).";
+    msg += " <dictionaries> <input file> [--non-strict-validation]\n\n";
+    msg += "       dictionaries:            list of comma-separated xml dictionaries (one or more can be provided).\n";
+    msg += "       Input file:              normally a pcap file, but hexadecimal content (colons allowed) can also be decoded (use '.hex' extension).\n";
+    msg += "       --non-strict-validation: no validation is performed, and wrong flags regarding dictionary are ignored in xml representation.";
     _exit(msg);
   }
 
@@ -346,11 +347,10 @@ int main(int argc, char **argv) {
   bool isHex = (inputFile.substr(inputFile.find_last_of(".") + 1) == "hex");
   std::string outputFile = inputFile; // extension will be added later
   std::string optional = argv[3] ? argv[3] : "";
-  bool ignoreFlags = ((argc == 4) && (optional == "--ignore-flags"));
+  bool non_strict_validation = ((argc == 4) && (optional == "--non-strict-validation"));
   std::cout << "Dictionary(ies) provided: " << dictionaries << std::endl;
   std::cout << "Input file provided:      " << inputFile << std::endl;
-  std::cout << "Validation kindness:      "
-            << (ignoreFlags ? "non strict" : "strict") << std::endl;
+  std::cout << "Validation kindness:      " << (non_strict_validation ? "non strict" : "strict") << std::endl;
   // Logger and engines:
   Logger::setLevel(Logger::Debug);
   Logger::initialize(execBN.c_str(), new TraceWriter(filetrace.c_str(), 2048000));
@@ -395,7 +395,11 @@ int main(int argc, char **argv) {
     _exit(ex.asString());
   }
 
-  codecEngine->ignoreFlagsOnValidation(ignoreFlags);
+  if(non_strict_validation) {
+    codecEngine->setValidationMode(anna::diameter::codec::EngineImpl::ValidationMode::Never);
+    codecEngine->ignoreFlagsOnValidation(true);
+  }
+
   // Tracing:
   //if (cl.exists("trace"))
   //   anna::Logger::setLevel(anna::Logger::asLevel(cl.getValue("trace")));