- std::string dictionaries = argv[1];
- std::string pcapFile = argv[2];
- std::string optional = argv[3] ? argv[3] : "";
- bool ignoreFlags = ((argc == 4) && (optional == "--ignore-flags"));
- std::cout << "Dictionary(ies) provided: " << dictionaries << std::endl;
- std::cout << "Pcap file provided: " << pcapFile << std::endl;
- std::cout << "Validation kindness: "
- << (ignoreFlags ? "non strict" : "strict") << std::endl;
- // Logger and engines:
- Logger::setLevel(Logger::Debug);
- Logger::initialize("pcapDecoder", new TraceWriter("file.trace", 2048000));
- anna::diameter::codec::Engine *codecEngine =
- new anna::diameter::codec::Engine();
- anna::diameter::stack::Engine &stackEngine =
- anna::diameter::stack::Engine::instantiate();
-
- try {
- anna::diameter::stack::Dictionary * d = stackEngine.createDictionary(
- 0 /* stack id */);
- // Analyze comma-separated list:
- anna::Tokenizer lst;
- lst.apply(dictionaries, ",");
-
- if(lst.size() >= 1) { // always true (at least one, because -dictionary is mandatory)
- anna::Tokenizer::const_iterator tok_min(lst.begin());
- anna::Tokenizer::const_iterator tok_max(lst.end());
- anna::Tokenizer::const_iterator tok_iter;
- std::string pathFile;
- d->allowUpdates();
-
- for(tok_iter = tok_min; tok_iter != tok_max; tok_iter++) {
- pathFile = anna::Tokenizer::data(tok_iter);
- d->load(pathFile);
- }
- }
+ std::string inputFile = argv[1];
+ bool isHex = (inputFile.substr(inputFile.find_last_of(".") + 1) == "hex");
+ std::string outputFile = inputFile; // extension will be added later
+ std::string optionals;
+ int indx = 2;
+ while(indx < argc) { optionals += " "; optionals += argv[indx]; indx++; }
+
+ bool debug = (optionals.find("--debug") != std::string::npos);
+ bool writeHex = (optionals.find("--write-hex") != std::string::npos);
+ Logger::setLevel(debug ? Logger::Debug:Logger::Warning);
+ Logger::initialize(execBN.c_str(), new TraceWriter(filetrace.c_str(), 2048000));