#include <DIOP_Endpoint.h>
Public Member Functions | |
TAO_DIOP_Endpoint (void) | |
Default constructor. | |
TAO_DIOP_Endpoint (const char *host, CORBA::UShort port, const ACE_INET_Addr &addr, CORBA::Short priority=TAO_INVALID_PRIORITY) | |
TAO_DIOP_Endpoint (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses) | |
Constructor. | |
TAO_DIOP_Endpoint (const char *host, CORBA::UShort port, CORBA::Short priority) | |
Constructor. This constructor is used when decoding endpoints. | |
~TAO_DIOP_Endpoint (void) | |
Destructor. | |
const ACE_INET_Addr & | object_addr (void) const |
Return a reference to the <object_addr>. | |
const char * | host (void) const |
const char * | host (const char *h) |
CORBA::UShort | port (void) const |
Return the port number. | |
CORBA::UShort | port (CORBA::UShort p) |
Set the port number. | |
TAO_Endpoint Methods | |
Please check the documentation in Endpoint.h for details. | |
virtual TAO_Endpoint * | next (void) |
virtual int | addr_to_string (char *buffer, size_t length) |
virtual TAO_Endpoint * | duplicate (void) |
CORBA::Boolean | is_equivalent (const TAO_Endpoint *other_endpoint) |
CORBA::ULong | hash (void) |
Return a hash value for this object. | |
Private Member Functions | |
int | set (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses) |
Helper method for setting INET_Addr. | |
void | object_addr_i (void) const |
Helper method for object_addr () call. | |
Private Attributes | |
CORBA::String_var | host_ |
String representing the host name. | |
CORBA::UShort | port_ |
TCP port number. | |
ACE_INET_Addr | object_addr_ |
bool | object_addr_set_ |
Flag to indicate if the address has been resolved and set. | |
TAO_DIOP_Endpoint * | next_ |
Friends | |
class | TAO_DIOP_Profile |
class | TAO_SSLIOP_Profile |
DIOP-specific implementation of PP Framework Endpoint interface.
Definition at line 44 of file DIOP_Endpoint.h.
TAO_DIOP_Endpoint::TAO_DIOP_Endpoint | ( | void | ) |
Default constructor.
Definition at line 64 of file DIOP_Endpoint.cpp.
: TAO_Endpoint (TAO_TAG_DIOP_PROFILE), host_ (), port_ (0), #if defined (ACE_HAS_IPV6) is_ipv6_decimal_ (false), #endif /* ACE_HAS_IPV6 */ object_addr_ (), object_addr_set_ (false), next_ (0) { }
TAO_DIOP_Endpoint::TAO_DIOP_Endpoint | ( | const char * | host, | |
CORBA::UShort | port, | |||
const ACE_INET_Addr & | addr, | |||
CORBA::Short | priority = TAO_INVALID_PRIORITY | |||
) |
Constructor. This is the most efficient constructor since it does not require any address resolution processing.
Definition at line 46 of file DIOP_Endpoint.cpp.
: TAO_Endpoint (TAO_TAG_DIOP_PROFILE, priority) , host_ () , port_ (port) #if defined (ACE_HAS_IPV6) , is_ipv6_decimal_ (false) #endif /* ACE_HAS_IPV6 */ , object_addr_ (addr) , object_addr_set_ (false) , next_ (0) { this->host (host); // With IPv6 performs check for decimal address }
TAO_DIOP_Endpoint::TAO_DIOP_Endpoint | ( | const ACE_INET_Addr & | addr, | |
int | use_dotted_decimal_addresses | |||
) |
Constructor.
Definition at line 30 of file DIOP_Endpoint.cpp.
: TAO_Endpoint (TAO_TAG_DIOP_PROFILE) , host_ () , port_ (0) #if defined (ACE_HAS_IPV6) , is_ipv6_decimal_ (false) #endif /* ACE_HAS_IPV6 */ , object_addr_ (addr) , object_addr_set_ (false) , next_ (0) { this->set (addr, use_dotted_decimal_addresses); }
TAO_DIOP_Endpoint::TAO_DIOP_Endpoint | ( | const char * | host, | |
CORBA::UShort | port, | |||
CORBA::Short | priority | |||
) |
Constructor. This constructor is used when decoding endpoints.
Definition at line 77 of file DIOP_Endpoint.cpp.
: TAO_Endpoint (TAO_TAG_DIOP_PROFILE, priority), host_ (), port_ (port), #if defined (ACE_HAS_IPV6) is_ipv6_decimal_ (false), #endif /* ACE_HAS_IPV6 */ object_addr_ (), object_addr_set_ (false), next_ (0) { this->host (host); // With IPv6 performs check for decimal address }
TAO_DIOP_Endpoint::~TAO_DIOP_Endpoint | ( | void | ) |
int TAO_DIOP_Endpoint::addr_to_string | ( | char * | buffer, | |
size_t | length | |||
) | [virtual] |
Return true if this endpoint is equivalent to <other_endpoint>. Two endpoints are equivalent iff their port and host are the same.
Implements TAO_Endpoint.
Definition at line 147 of file DIOP_Endpoint.cpp.
{ size_t actual_len = ACE_OS::strlen (this->host_.in ()) // chars in host name + sizeof (':') // delimiter + ACE_OS::strlen ("65536") // max port + sizeof ('\0'); #if defined (ACE_HAS_IPV6) if (this->is_ipv6_decimal_) actual_len += 2; // '[' + ']' #endif /* ACE_HAS_IPV6 */ if (length < actual_len) return -1; #if defined (ACE_HAS_IPV6) if (this->is_ipv6_decimal_) ACE_OS::sprintf (buffer, "[%s]:%d", this->host_.in (), this->port_); else #endif /* ACE_HAS_IPV6 */ ACE_OS::sprintf (buffer, "%s:%d", this->host_.in (), this->port_); return 0; }
TAO_Endpoint * TAO_DIOP_Endpoint::duplicate | ( | void | ) | [virtual] |
Return true if this endpoint is equivalent to <other_endpoint>. Two endpoints are equivalent iff their port and host are the same.
Implements TAO_Endpoint.
Definition at line 194 of file DIOP_Endpoint.cpp.
{ TAO_DIOP_Endpoint *endpoint = 0; ACE_NEW_RETURN (endpoint, TAO_DIOP_Endpoint (this->host_.in (), this->port_, this->object_addr_, this->priority ()), 0); return endpoint; }
CORBA::ULong TAO_DIOP_Endpoint::hash | ( | void | ) | [virtual] |
Return a hash value for this object.
Implements TAO_Endpoint.
Definition at line 222 of file DIOP_Endpoint.cpp.
{ if (this->hash_val_ != 0) return this->hash_val_; { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->addr_lookup_lock_, this->hash_val_); // .. DCL if (this->hash_val_ != 0) return this->hash_val_; this->hash_val_ = ACE::hash_pjw (this->host ()) + this->port (); } return this->hash_val_; }
const char * TAO_DIOP_Endpoint::host | ( | const char * | h | ) |
Copy the string <h> into <host_> and return the resulting pointer. This object maintains ownership of this string.
Definition at line 176 of file DIOP_Endpoint.cpp.
{ this->host_ = h; #if defined (ACE_HAS_IPV6) if (ACE_OS::strchr (h, ':') != 0) this->is_ipv6_decimal_ = true; #endif /* ACE_HAS_IPV6 */ return this->host_.in (); }
const char * TAO_DIOP_Endpoint::host | ( | void | ) | const |
Return a pointer to the host string. This object maintains ownership of this string.
Definition at line 8 of file DIOP_Endpoint.inl.
{ return this->host_.in (); }
CORBA::Boolean TAO_DIOP_Endpoint::is_equivalent | ( | const TAO_Endpoint * | other_endpoint | ) | [virtual] |
Return true if this endpoint is equivalent to <other_endpoint>. Two endpoints are equivalent iff their port and host are the same.
Implements TAO_Endpoint.
Definition at line 209 of file DIOP_Endpoint.cpp.
{ TAO_Endpoint *endpt = const_cast<TAO_Endpoint *> (other_endpoint); TAO_DIOP_Endpoint *endpoint = dynamic_cast<TAO_DIOP_Endpoint *> (endpt); if (endpoint == 0) return 0; return (this->port () == endpoint->port () && ACE_OS::strcmp (this->host (), endpoint->host ()) == 0); }
TAO_Endpoint * TAO_DIOP_Endpoint::next | ( | void | ) | [virtual] |
Return true if this endpoint is equivalent to <other_endpoint>. Two endpoints are equivalent iff their port and host are the same.
Implements TAO_Endpoint.
Definition at line 188 of file DIOP_Endpoint.cpp.
{ return this->next_; }
const ACE_INET_Addr & TAO_DIOP_Endpoint::object_addr | ( | void | ) | const |
Return a reference to the <object_addr>.
Definition at line 244 of file DIOP_Endpoint.cpp.
{ // The object_addr_ is initialized here, rather than at IOR decode // time for several reasons: // 1. A request on the object may never be invoked. // 2. The DNS setup may have changed dynamically. // ...etc.. // Double checked locking optimization. if (!this->object_addr_set_) { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->addr_lookup_lock_, this->object_addr_ ); if (!this->object_addr_set_) { (void) this->object_addr_i (); } } return this->object_addr_; }
void TAO_DIOP_Endpoint::object_addr_i | ( | void | ) | const [private] |
Helper method for object_addr () call.
Definition at line 269 of file DIOP_Endpoint.cpp.
{ // We should have already held the lock #if defined (ACE_HAS_IPV6) bool is_ipv4_decimal_ = false; if (!this->is_ipv6_decimal_) is_ipv4_decimal_ = ACE_OS::strspn (this->host_.in (), ".0123456789") == ACE_OS::strlen (this->host_.in ()); // If this is *not* an IPv4 decimal address at first try to // resolve the address as an IPv6 address; if that fails // (or it's an IPv4 address) and the address is *not* an IPv6 // decimal address try to resolve it as an IPv4 address. if ((is_ipv4_decimal_ || this->object_addr_.set (this->port_, this->host_.in (), 1, AF_INET6) == -1) && (this->is_ipv6_decimal_ || this->object_addr_.set (this->port_, this->host_.in (), 1, AF_INET) == -1)) #else if (this->object_addr_.set (this->port_, this->host_.in ()) == -1) #endif /* ACE_HAS_IPV6 */ { // If this call fails, it most likely due a hostname // lookup failure caused by a DNS misconfiguration. If // a request is made to the object at the given host and // port, then a CORBA::TRANSIENT() exception should be // thrown. // Invalidate the ACE_INET_Addr. This is used as a flag // to denote that ACE_INET_Addr initialization failed. this->object_addr_.set_type (-1); } else { this->object_addr_set_ = true; } }
CORBA::UShort TAO_DIOP_Endpoint::port | ( | CORBA::UShort | p | ) |
CORBA::UShort TAO_DIOP_Endpoint::port | ( | void | ) | const |
int TAO_DIOP_Endpoint::set | ( | const ACE_INET_Addr & | addr, | |
int | use_dotted_decimal_addresses | |||
) | [private] |
Helper method for setting INET_Addr.
Definition at line 98 of file DIOP_Endpoint.cpp.
{ char tmp_host[MAXHOSTNAMELEN + 1]; #if defined (ACE_HAS_IPV6) this->is_ipv6_decimal_ = false; // Reset #endif /* ACE_HAS_IPV6 */ if (use_dotted_decimal_addresses || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) { if (use_dotted_decimal_addresses == 0 && TAO_debug_level > 5) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - DIOP_Endpoint::set, ") ACE_TEXT ("%p\n"), ACE_TEXT ("cannot determine hostname"))); } const char *tmp = addr.get_host_addr (); if (tmp == 0) { if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - ") ACE_TEXT ("DIOP_Endpoint::set, ") ACE_TEXT ("%p\n"), ACE_TEXT ("cannot determine hostname\n"))); return -1; } else { this->host_ = tmp; #if defined (ACE_HAS_IPV6) if (addr.get_type () == PF_INET6) this->is_ipv6_decimal_ = true; #endif /* ACE_HAS_IPV6 */ } } else this->host_ = CORBA::string_dup (tmp_host); this->port_ = addr.get_port_number (); return 0; }
friend class TAO_DIOP_Profile [friend] |
Definition at line 48 of file DIOP_Endpoint.h.
friend class TAO_SSLIOP_Profile [friend] |
Definition at line 49 of file DIOP_Endpoint.h.
CORBA::String_var TAO_DIOP_Endpoint::host_ [private] |
String representing the host name.
Definition at line 124 of file DIOP_Endpoint.h.
TAO_DIOP_Endpoint* TAO_DIOP_Endpoint::next_ [private] |
DIOP Endpoints can be stringed into a list. Return the next endpoint in the list, if any.
Definition at line 143 of file DIOP_Endpoint.h.
ACE_INET_Addr TAO_DIOP_Endpoint::object_addr_ [mutable, private] |
Cached instance of <ACE_INET_Addr> for use in making invocations, etc.
Definition at line 136 of file DIOP_Endpoint.h.
bool TAO_DIOP_Endpoint::object_addr_set_ [mutable, private] |
Flag to indicate if the address has been resolved and set.
Definition at line 139 of file DIOP_Endpoint.h.
CORBA::UShort TAO_DIOP_Endpoint::port_ [private] |
TCP port number.
Definition at line 127 of file DIOP_Endpoint.h.