Go to the documentation of this file.00001
00002
00003 #include "tao/EndpointPolicy/IIOPEndpointValue_i.h"
00004
00005 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00006
00007 #include "tao/IIOP_Endpoint.h"
00008 #include "tao/IIOP_Acceptor.h"
00009 #include "ace/OS_NS_strings.h"
00010
00011 ACE_RCSID (IIOPEndpointValue,
00012 IIOPEndpointValue_i,
00013 "$Id: IIOPEndpointValue_i.cpp 82428 2008-07-27 01:05:44Z mesnier_p $")
00014
00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00016
00017 IIOPEndpointValue_i::IIOPEndpointValue_i ()
00018 :host_(""),
00019 port_(0)
00020 {
00021 }
00022
00023 IIOPEndpointValue_i::IIOPEndpointValue_i (const char *host, CORBA::UShort port)
00024 :host_(host),
00025 port_(port)
00026 {
00027 if (this->addr_.set(port, host) != 0 || host == 0 || host[0] == 0)
00028 this->addr_.set_type (-1);
00029 }
00030
00031 IIOPEndpointValue_i::~IIOPEndpointValue_i (void)
00032 {
00033 }
00034
00035 CORBA::Boolean
00036 IIOPEndpointValue_i::is_equivalent (const TAO_Endpoint * endpoint) const
00037 {
00038 const TAO_IIOP_Endpoint *iep =
00039 dynamic_cast<const TAO_IIOP_Endpoint *>(endpoint);
00040 if (iep == 0)
00041 return 0;
00042 return this->addr_.get_type() != -1 ? this->addr_ == iep->object_addr() :
00043 this->is_equivalent_i (iep->port(), iep->host());
00044 }
00045
00046 CORBA::Boolean
00047 IIOPEndpointValue_i::is_equivalent_i (CORBA::UShort port,
00048 const char *host) const
00049 {
00050 bool is_eq = this->port_ == port;
00051 if (is_eq)
00052 is_eq = (this->host_.in()[0] == '\0' ||
00053 ACE_OS::strcasecmp(host, this->host_.in()) == 0);
00054 return is_eq;
00055 }
00056
00057 CORBA::Boolean
00058 IIOPEndpointValue_i::validate_acceptor(TAO_Acceptor * acceptor,
00059 bool is_multi_prot) const
00060 {
00061 TAO_IIOP_Acceptor *iacc = dynamic_cast<TAO_IIOP_Acceptor *>(acceptor);
00062 if (iacc == 0)
00063 return false;
00064
00065 #if 0
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 const ACE_INET_Addr * eps = iacc->endpoints ();
00076 CORBA::ULong eps_count = iacc->endpoint_count ();
00077 for (CORBA::ULong eps_idx = 0; eps_idx < eps_count; ++ eps_idx)
00078 {
00079 char hostname[513];
00080 eps[eps_idx].get_host_name(hostname,512);
00081 if (this->is_equivalent_i(eps[eps_idx].get_port_number(),hostname))
00082 return true;
00083 }
00084 return false;
00085 #else
00086
00087
00088
00089
00090
00091 return is_multi_prot || this->host_.in()[0] != '\0';
00092 #endif
00093 }
00094
00095 char *
00096 IIOPEndpointValue_i::host (void)
00097 {
00098 return CORBA::string_dup (this->host_.in());
00099 }
00100
00101 void
00102 IIOPEndpointValue_i::host (const char *h)
00103 {
00104 this->host_ = h;
00105 if (this->addr_.set(this->port_, this->host_.in ()) != 0)
00106 this->addr_.set_type (-1);
00107 }
00108
00109 CORBA::UShort
00110 IIOPEndpointValue_i::port (void)
00111 {
00112 return this->port_;
00113 }
00114
00115 void
00116 IIOPEndpointValue_i::port (CORBA::UShort p )
00117 {
00118 this->port_ = p;
00119 if (this->addr_.set(this->port_, this->host_.in ()) != 0)
00120 this->addr_.set_type (-1);
00121 }
00122
00123 CORBA::ULong
00124 IIOPEndpointValue_i::protocol_tag (void)
00125 {
00126 return IOP::TAG_INTERNET_IOP;
00127 }
00128
00129 TAO_END_VERSIONED_NAMESPACE_DECL
00130
00131 #endif