pcapDecoder allows .hex files as input. Make public some Avp methods for serializatio...
[anna.git] / example / diameter / launcher / main.cpp
index 280624c..7a08518 100644 (file)
@@ -358,11 +358,19 @@ public:
 bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw() {
 
   // Get hex string
-  static char buffer[2048];
+  static char buffer[8192];
   std::ifstream infile(pathfile.c_str(), std::ifstream::in);
   if(infile.is_open()) {
     infile >> buffer;
     std::string hexString(buffer, strlen(buffer));
+    // Allow colon separator in hex string: we have to remove them before processing with 'fromHexString':
+    hexString.erase(std::remove(hexString.begin(), hexString.end(), ':'), hexString.end());
+    LOGDEBUG(
+      std::string msg = "Hex string (remove colons if exists): ";
+      msg += hexString;
+      anna::Logger::debug(msg, ANNA_FILE_LOCATION);
+    );
+
     anna::functions::fromHexString(hexString, db);
     // Close file
     infile.close();
@@ -1466,8 +1474,8 @@ throw(anna::RuntimeException) {
      std::string address;
      int port;
      anna::functions::getAddressAndPortFromSocketLiteral(cl.getValue("httpServer"), address, port);
-     //const anna::comm::Device* device = network.find(Device::asAddress(address)); // aqui hay que proporcionar una IP !
-     const anna::comm::Device* device = *((network.resolve(address)->device_begin())); // ArtimaƱa para resolver (IP o hostname)
+     //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());
    }
 
@@ -1497,6 +1505,16 @@ throw(anna::RuntimeException) {
 
       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, 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;
+      }
+
    } catch (anna::RuntimeException &ex) {
       ex.trace();
    }