2 #include "tao/EndpointPolicy/IIOPEndpointValue_i.h"
4 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
6 #include "tao/IIOP_Endpoint.h"
7 #include "tao/IIOP_Acceptor.h"
8 #include "ace/OS_NS_strings.h"
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
12 IIOPEndpointValue_i::IIOPEndpointValue_i ()
18 IIOPEndpointValue_i::IIOPEndpointValue_i (const char *host
, CORBA::UShort port
)
22 if (this->addr_
.set(port
, host
) != 0 || host
== 0 || host
[0] == 0)
23 this->addr_
.set_type (-1);
26 IIOPEndpointValue_i::~IIOPEndpointValue_i ()
31 IIOPEndpointValue_i::is_equivalent (const TAO_Endpoint
* endpoint
) const
33 const TAO_IIOP_Endpoint
*iep
=
34 dynamic_cast<const TAO_IIOP_Endpoint
*>(endpoint
);
37 return this->addr_
.get_type() != -1 ? this->addr_
== iep
->object_addr() :
38 this->is_equivalent_i (iep
->port(), iep
->host());
42 IIOPEndpointValue_i::is_equivalent_i (CORBA::UShort port
,
43 const char *host
) const
45 bool is_eq
= this->port_
== port
;
47 is_eq
= (this->host_
.in()[0] == '\0' ||
48 ACE_OS::strcasecmp(host
, this->host_
.in()) == 0);
53 IIOPEndpointValue_i::validate_acceptor(TAO_Acceptor
* acceptor
,
54 bool is_multi_prot
) const
56 TAO_IIOP_Acceptor
*iacc
= dynamic_cast<TAO_IIOP_Acceptor
*>(acceptor
);
61 // @@@ mesnier_p@ociweb.com @@@
62 // This test was originally intended to validate that there is an
63 // acceptor available which supports the target endpoint. However,
64 // variablility in the definition of a "hostname" makes this hard
65 // to determine, without adding more overhead, probably to the
66 // IIOP_Acceptor class.
67 // I'm not sure this level of validation is really required, so
68 // for now I'm just leaving it out.
70 const ACE_INET_Addr
* eps
= iacc
->endpoints ();
71 CORBA::ULong eps_count
= iacc
->endpoint_count ();
72 for (CORBA::ULong eps_idx
= 0; eps_idx
< eps_count
; ++ eps_idx
)
75 eps
[eps_idx
].get_host_name(hostname
,512);
76 if (this->is_equivalent_i(eps
[eps_idx
].get_port_number(),hostname
))
81 // @@@ mesnier_p@ociweb.com @@@
82 // Rather than blindly returning true, we need to reject defaulted
83 // endpoint hosts except when the ORB has more than one protocol
86 return is_multi_prot
|| this->host_
.in()[0] != '\0';
91 IIOPEndpointValue_i::host ()
93 return CORBA::string_dup (this->host_
.in());
97 IIOPEndpointValue_i::host (const char *h
)
100 if (this->addr_
.set(this->port_
, this->host_
.in ()) != 0)
101 this->addr_
.set_type (-1);
105 IIOPEndpointValue_i::port ()
111 IIOPEndpointValue_i::port (CORBA::UShort p
)
114 if (this->addr_
.set(this->port_
, this->host_
.in ()) != 0)
115 this->addr_
.set_type (-1);
119 IIOPEndpointValue_i::protocol_tag ()
121 return IOP::TAG_INTERNET_IOP
;
124 TAO_END_VERSIONED_NAMESPACE_DECL
126 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */