summaryrefslogtreecommitdiff
path: root/TAO/tao/Strategies/SCIOP_Endpoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/Strategies/SCIOP_Endpoint.cpp')
-rw-r--r--TAO/tao/Strategies/SCIOP_Endpoint.cpp174
1 files changed, 143 insertions, 31 deletions
diff --git a/TAO/tao/Strategies/SCIOP_Endpoint.cpp b/TAO/tao/Strategies/SCIOP_Endpoint.cpp
index 16ef07973b9..b6806457b62 100644
--- a/TAO/tao/Strategies/SCIOP_Endpoint.cpp
+++ b/TAO/tao/Strategies/SCIOP_Endpoint.cpp
@@ -11,6 +11,7 @@
#include "ace/Log_Msg.h"
#include "ace/Synch.h"
#include "ace/OS_NS_stdio.h"
+#include "ORB_Core.h"
ACE_RCSID (Strategies,
SCIOP_Endpoint,
@@ -25,11 +26,13 @@ ACE_RCSID (Strategies,
TAO_SCIOP_Endpoint::TAO_SCIOP_Endpoint (const ACE_INET_Addr &addr,
int use_dotted_decimal_addresses)
: TAO_Endpoint (TAO_TAG_SCIOP_PROFILE)
- , host_ ()
- , port_ (683) // default port (IANA assigned)
- , object_addr_ (addr)
- , object_addr_set_ (0)
- , next_ (0)
+ , host_ ()
+ , port_ (683) // default port (IANA assigned)
+ , object_addr_ (addr)
+ , object_addr_set_ (0)
+ , preferred_path_ ()
+ , is_encodable_ (true)
+ , next_ (0)
{
this->set (addr, use_dotted_decimal_addresses);
}
@@ -40,39 +43,40 @@ TAO_SCIOP_Endpoint::TAO_SCIOP_Endpoint (const char *host,
CORBA::Short priority)
: TAO_Endpoint (TAO_TAG_SCIOP_PROFILE,
priority)
- , host_ ()
- , port_ (port)
- , object_addr_ (addr)
- , object_addr_set_ (0)
- , next_ (0)
+ , host_ (host)
+ , port_ (port)
+ , object_addr_ (addr)
+ , object_addr_set_ (0)
+ , preferred_path_ ()
+ , is_encodable_ (true)
+ , next_ (0)
{
- if (host != 0)
- this->host_ = host;
}
TAO_SCIOP_Endpoint::TAO_SCIOP_Endpoint (void)
: TAO_Endpoint (TAO_TAG_SCIOP_PROFILE)
- , host_ ()
- , port_ (683) // default port (IANA assigned)
- , object_addr_ ()
- , object_addr_set_ (0)
- , next_ (0)
+ , host_ ()
+ , port_ (683) // default port (IANA assigned)
+ , object_addr_ ()
+ , object_addr_set_ (0)
+ , preferred_path_ ()
+ , is_encodable_ (true)
+ , next_ (0)
{
}
TAO_SCIOP_Endpoint::TAO_SCIOP_Endpoint (const char *host,
- CORBA::UShort port,
- CORBA::Short priority)
+ CORBA::UShort port,
+ CORBA::Short priority)
: TAO_Endpoint (TAO_TAG_SCIOP_PROFILE)
- , host_ ()
- , port_ (port)
- , object_addr_ ()
- , object_addr_set_ (0)
- , next_ (0)
+ , host_ (host)
+ , port_ (port)
+ , object_addr_ ()
+ , object_addr_set_ (0)
+ , preferred_path_ ()
+ , is_encodable_ (true)
+ , next_ (0)
{
- if (host != 0)
- this->host_ = host;
-
this->priority (priority);
}
@@ -80,6 +84,19 @@ TAO_SCIOP_Endpoint::~TAO_SCIOP_Endpoint (void)
{
}
+TAO_SCIOP_Endpoint::TAO_IIOP_Endpoint (const TAO_SCIOP_Endpoint &rhs)
+ : TAO_Endpoint (rhs.tag_,
+ rhs.priority_)
+ , host_ (rhs.host_)
+ , port_ (rhs.port_)
+ , object_addr_ (rhs.object_addr_)
+ , object_addr_set_ (rhs.object_addr_set_)
+ , preferred_path_ (rhs.preferred_path_)
+ , is_encodable_ (rhs.is_encodable_)
+ , next_ (0)
+{
+}
+
int
TAO_SCIOP_Endpoint::set (const ACE_INET_Addr &addr,
int use_dotted_decimal_addresses)
@@ -148,11 +165,9 @@ TAO_SCIOP_Endpoint::duplicate (void)
{
TAO_SCIOP_Endpoint *endpoint = 0;
+ // @@NOTE: Not at all exception safe
ACE_NEW_RETURN (endpoint,
- TAO_SCIOP_Endpoint (this->host_.in (),
- this->port_,
- this->object_addr_,
- this->priority ()),
+ TAO_SCIOP_Endpoint (*this),
0);
return endpoint;
@@ -252,4 +267,101 @@ TAO_SCIOP_Endpoint::object_addr_i (void) const
}
}
+CORBA::ULong
+TAO_SCIOP_Endpoint::preferred_interfaces (TAO_ORB_Core *oc)
+{
+ ACE_CString tmp (
+ oc->orb_params ()->preferred_interfaces ());
+
+ ssize_t pos = 0;
+
+ pos = tmp.find (this->host_.in ());
+
+ TAO_IIOP_Endpoint *latest = this;
+
+ CORBA::ULong count = 0;
+
+ while (pos != ACE_CString::npos)
+ {
+ // Do we have a "," or an '\0'?
+ ssize_t new_pos = tmp.find (",",
+ pos + 1);
+
+ // Length of the preferred path
+ int length = 0;
+
+ if (new_pos == ACE_CString::npos)
+ length = tmp.length () - pos;
+ else
+ length = new_pos - pos;
+
+ ACE_CString rem_tmp = tmp.substr (pos, length);
+
+ // Search for the ":"
+ ssize_t col_pos = rem_tmp.find (":");
+
+ if (col_pos == ACE_CString::npos)
+ {
+ pos = tmp.find (latest->host_.in (),
+ pos + length);
+ continue;
+ }
+
+ ACE_CString path = rem_tmp.substr (col_pos + 1);
+
+ latest->preferred_path_.host =
+ CORBA::string_dup (path.c_str ());
+
+ if (TAO_debug_level > 3)
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) Adding path [%s] "
+ " as preferred path for [%s] \n",
+ path.c_str (), this->host_.in ()));
+
+ pos = tmp.find (latest->host_.in (),
+ pos + length);
+
+ if (pos != ACE_CString::npos)
+ {
+ TAO_Endpoint *tmp_ep =
+ latest->duplicate ();
+
+ latest->next_ = dynamic_cast<TAO_SCIOP_Endpoint *> (tmp_ep);
+
+ if (latest->next_ == 0) return count;
+
+ latest = latest->next_;
+ ++count;
+ }
+ }
+
+ if (tmp.length () != 0 &&
+ !oc->orb_params ()->enforce_pref_interfaces ())
+ {
+ TAO_Endpoint *tmp_ep = latest->duplicate ();
+
+ latest->next_ =
+ dynamic_cast<TAO_SCIOP_Endpoint *> (tmp_ep);
+
+ if (latest->next_ == 0) return count;
+
+ latest->next_->preferred_path_.host = (const char *) 0;
+ ++count;
+ }
+
+ return count;
+}
+
+bool
+TAO_SCIOP_Endpoint::is_preferred_network (void) const
+{
+ return (this->preferred_path_.host.in () != 0);
+}
+
+const char *
+TAO_SCIOP_Endpoint::preferred_network (void) const
+{
+ return this->preferred_path_.host.in ();
+}
+
#endif /* TAO_HAS_SCIOP == 1 */