Fix local server for multiple applications
[anna.git] / include / anna / diameter.comm / OriginHostManager.hpp
index 82c0979..9051052 100644 (file)
@@ -13,6 +13,8 @@
 // Project
 #include <anna/core/Singleton.hpp>
 #include <anna/diameter/defines.hpp>
+#include <anna/core/util/defines.hpp> // U32
+
 
 // Standard
 #include <map>
@@ -45,6 +47,8 @@ class OriginHostManager : public anna::Singleton <OriginHostManager> {
 private:
 
   origin_hosts_t a_origin_hosts;
+  std::map<std::string /* remove OH name */, std::string /* own OH name */> a_remote_to_own_origin_hosts{};
+
 
   // private constructor
   OriginHostManager() {};
@@ -77,6 +81,15 @@ public:
    */
   void registerOriginHost(const std::string &name, OriginHost* originHost) ;
 
+  /**
+   * Registers  the relation between Origin Host for incoming request and
+   * own origin host.
+   *
+   * @param remoteName origin host name for the received CER
+   * @param ownName Own origin host name
+   */
+  void registerRemoteOriginHost(const std::string &remoteName, const std::string &ownName);
+
   /**
    * Get the associated origin host node for a provided name.
    *
@@ -86,6 +99,28 @@ public:
    */
   OriginHost *getOriginHost(const std::string &name) const ;
 
+  /**
+   * Get the associated origin host name for a provided remote origin host name.
+   * This relation was established on CER reception.
+   *
+   * @param name remote origin host name
+   *
+   * @return own origin host, NULL if not found
+   */
+  OriginHost * getOriginHostForRemoteOriginHost(const std::string &name) const;
+
+  /**
+   * Get the associated origin host node for a specific application id
+   * No indexed map by application id, so this search is sequential, but
+   * performance is not required as this is used when receiving CER.
+   *
+   * @applicationId application id to search
+   *
+   * @return Found origin host node, NULL if not found
+   */
+  OriginHost *getOriginHost(const anna::U32 &applicationId) const;
+
+
   /**
      Class XML representation.
      \param parent XML node over which we will put instance information.