+
+ // Checking command line parameters
+ if(cl.exists("sessionBasedModelsClientSocketSelection")) {
+ std::string type = cl.getValue("sessionBasedModelsClientSocketSelection");
+
+ if((type != "SessionIdHighPart") && (type != "SessionIdOptionalPart") && (type != "RoundRobin")) {
+ throw anna::RuntimeException("Commandline option '-sessionBasedModelsClientSocketSelection' only accepts 'SessionIdHighPart'/'SessionIdOptionalPart'/'RoundRobin' as parameter values", ANNA_FILE_LOCATION);
+ }
+ }
+
+ // Tracing:
+ if(cl.exists("trace"))
+ anna::Logger::setLevel(anna::Logger::asLevel(cl.getValue("trace")));
+
+ LOGINFORMATION(
+ // Help on startup traces:
+ anna::Logger::information(help(), ANNA_FILE_LOCATION);
+ // Test messages dtd:
+ std::string msg = "\n ------------- TESTMESSAGES DTD -------------\n";
+ msg += anna::diameter::codec::MessageDTD;
+ anna::Logger::information(msg, ANNA_FILE_LOCATION);
+ );
+
+ // HTTP Server:
+ if(cl.exists("httpServer")) {
+ anna::comm::Network& network = anna::comm::Network::instantiate();
+ std::string address;
+ int port;
+ anna::functions::getAddressAndPortFromSocketLiteral(cl.getValue("httpServer"), address, port);
+ //const anna::comm::Device* device = network.find(Device::asAddress(address)); // here provide IP
+ const anna::comm::Device* device = *((network.resolve(address)->device_begin())); // trick to solve
+ a_httpServerSocket = new anna::comm::ServerSocket(anna::comm::INetAddress(device, port), cl.exists("httpServerShared") /* shared bind */, &anna::http::Transport::getFactory());
+ }
+
+ // Stack:
+ anna::diameter::codec::Engine *codecEngine = new anna::diameter::codec::Engine();
+ anna::diameter::stack::Engine &stackEngine = anna::diameter::stack::Engine::instantiate();
+ anna::diameter::stack::Dictionary * d = stackEngine.createDictionary(0 /* stack id; its value don't mind, is not used (ADL is monostack) */);
+ // Analyze comma-separated list:
+ anna::Tokenizer lst;
+ std::string dictionaryParameter = cl.getValue("dictionary");
+ lst.apply(dictionaryParameter, ",");
+
+ 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);
+ }
+ }
+
+ codecEngine->setDictionary(d);
+ LOGDEBUG(anna::Logger::debug(codecEngine->asString(), ANNA_FILE_LOCATION));
+
+ if(lst.size() > 1) {
+ std::string all_in_one = "./dictionary-all-in-one.xml";
+ std::ofstream out(all_in_one.c_str(), std::ifstream::out);
+ std::string buffer = d->asXMLString();
+ out.write(buffer.c_str(), buffer.size());
+ out.close();
+ std::cout << "Written accumulated '" << all_in_one << "' (provide it next time to be more comfortable)." << std::endl;
+ }
+