#include <DIOP_Endpoint.h>
Inheritance diagram for TAO_DIOP_Endpoint:
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 . | |
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 | |
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. | |
bool | is_ipv6_decimal_ |
Does the host string represent an IPv6 decimal address. | |
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.
|
Default constructor.
Definition at line 64 of file DIOP_Endpoint.cpp. References TAO_TAG_DIOP_PROFILE.
00065 : TAO_Endpoint (TAO_TAG_DIOP_PROFILE), 00066 host_ (), 00067 port_ (0), 00068 #if defined (ACE_HAS_IPV6) 00069 is_ipv6_decimal_ (false), 00070 #endif /* ACE_HAS_IPV6 */ 00071 object_addr_ (), 00072 object_addr_set_ (false), 00073 next_ (0) 00074 { 00075 } |
|
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. References host(), and TAO_TAG_DIOP_PROFILE.
00050 : TAO_Endpoint (TAO_TAG_DIOP_PROFILE, 00051 priority) 00052 , host_ () 00053 , port_ (port) 00054 #if defined (ACE_HAS_IPV6) 00055 , is_ipv6_decimal_ (false) 00056 #endif /* ACE_HAS_IPV6 */ 00057 , object_addr_ (addr) 00058 , object_addr_set_ (false) 00059 , next_ (0) 00060 { 00061 this->host (host); // With IPv6 performs check for decimal address 00062 } |
|
Constructor.
Definition at line 30 of file DIOP_Endpoint.cpp. References set(), and TAO_TAG_DIOP_PROFILE.
00033 : TAO_Endpoint (TAO_TAG_DIOP_PROFILE) 00034 , host_ () 00035 , port_ (0) 00036 #if defined (ACE_HAS_IPV6) 00037 , is_ipv6_decimal_ (false) 00038 #endif /* ACE_HAS_IPV6 */ 00039 , object_addr_ (addr) 00040 , object_addr_set_ (false) 00041 , next_ (0) 00042 { 00043 this->set (addr, use_dotted_decimal_addresses); 00044 } |
|
Constructor. This constructor is used when decoding endpoints.
Definition at line 77 of file DIOP_Endpoint.cpp. References host(), and TAO_TAG_DIOP_PROFILE.
00080 : TAO_Endpoint (TAO_TAG_DIOP_PROFILE, priority), 00081 host_ (), 00082 port_ (port), 00083 #if defined (ACE_HAS_IPV6) 00084 is_ipv6_decimal_ (false), 00085 #endif /* ACE_HAS_IPV6 */ 00086 object_addr_ (), 00087 object_addr_set_ (false), 00088 next_ (0) 00089 { 00090 this->host (host); // With IPv6 performs check for decimal address 00091 } |
|
Destructor.
Definition at line 93 of file DIOP_Endpoint.cpp.
00094 { 00095 } |
|
Implements TAO_Endpoint. Definition at line 147 of file DIOP_Endpoint.cpp. References ACE_OS::sprintf(), and ACE_OS::strlen().
00148 { 00149 size_t actual_len = 00150 ACE_OS::strlen (this->host_.in ()) // chars in host name 00151 + sizeof (':') // delimiter 00152 + ACE_OS::strlen ("65536") // max port 00153 + sizeof ('\0'); 00154 00155 #if defined (ACE_HAS_IPV6) 00156 if (this->is_ipv6_decimal_) 00157 actual_len += 2; // '[' + ']' 00158 #endif /* ACE_HAS_IPV6 */ 00159 00160 if (length < actual_len) 00161 return -1; 00162 00163 #if defined (ACE_HAS_IPV6) 00164 if (this->is_ipv6_decimal_) 00165 ACE_OS::sprintf (buffer, "[%s]:%d", 00166 this->host_.in (), this->port_); 00167 else 00168 #endif /* ACE_HAS_IPV6 */ 00169 ACE_OS::sprintf (buffer, "%s:%d", 00170 this->host_.in (), this->port_); 00171 00172 return 0; 00173 } |
|
Implements TAO_Endpoint. Definition at line 194 of file DIOP_Endpoint.cpp. References ACE_NEW_RETURN, and TAO_Endpoint::priority().
00195 { 00196 TAO_DIOP_Endpoint *endpoint = 0; 00197 00198 ACE_NEW_RETURN (endpoint, 00199 TAO_DIOP_Endpoint (this->host_.in (), 00200 this->port_, 00201 this->object_addr_, 00202 this->priority ()), 00203 0); 00204 00205 return endpoint; 00206 } |
|
Return a hash value for this object.
Implements TAO_Endpoint. Definition at line 222 of file DIOP_Endpoint.cpp. References ACE_GUARD_RETURN, ACE::hash_pjw(), port(), and TAO_SYNCH_MUTEX. Referenced by TAO_DIOP_Profile::hash().
00223 { 00224 if (this->hash_val_ != 0) 00225 return this->hash_val_; 00226 00227 { 00228 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00229 guard, 00230 this->addr_lookup_lock_, 00231 this->hash_val_); 00232 // .. DCL 00233 if (this->hash_val_ != 0) 00234 return this->hash_val_; 00235 00236 this->hash_val_ = 00237 ACE::hash_pjw (this->host ()) + this->port (); 00238 } 00239 00240 return this->hash_val_; 00241 } |
|
Copy the string into and return the resulting pointer. This object maintains ownership of this string. Definition at line 176 of file DIOP_Endpoint.cpp. References ACE_OS::strchr().
00177 { 00178 this->host_ = h; 00179 #if defined (ACE_HAS_IPV6) 00180 if (ACE_OS::strchr (h, ':') != 0) 00181 this->is_ipv6_decimal_ = true; 00182 #endif /* ACE_HAS_IPV6 */ 00183 00184 return this->host_.in (); 00185 } |
|
Return a pointer to the host string. This object maintains ownership of this string. Definition at line 8 of file DIOP_Endpoint.inl. Referenced by TAO_DIOP_Profile::encode_endpoints(), TAO_DIOP_Acceptor::is_collocated(), is_equivalent(), TAO_DIOP_Connector::make_connection(), TAO_DIOP_Endpoint(), and TAO_DIOP_Profile::to_string().
00009 { 00010 return this->host_.in (); 00011 } |
|
Return true if this endpoint is equivalent to . Two endpoints are equivalent iff their port and host are the same. Implements TAO_Endpoint. Definition at line 209 of file DIOP_Endpoint.cpp. References host(), port(), and ACE_OS::strcmp(). Referenced by TAO_DIOP_Profile::do_is_equivalent().
00210 { 00211 TAO_Endpoint *endpt = const_cast<TAO_Endpoint *> (other_endpoint); 00212 00213 TAO_DIOP_Endpoint *endpoint = dynamic_cast<TAO_DIOP_Endpoint *> (endpt); 00214 if (endpoint == 0) 00215 return 0; 00216 00217 return (this->port () == endpoint->port () 00218 && ACE_OS::strcmp (this->host (), endpoint->host ()) == 0); 00219 } |
|
Implements TAO_Endpoint. Definition at line 188 of file DIOP_Endpoint.cpp.
00189 { 00190 return this->next_; 00191 } |
|
Return a reference to the .
Definition at line 244 of file DIOP_Endpoint.cpp. References ACE_GUARD_RETURN, object_addr_i(), and TAO_SYNCH_MUTEX. Referenced by TAO_DIOP_Connector::make_connection(), and TAO_DIOP_Connector::set_validate_endpoint().
00245 { 00246 // The object_addr_ is initialized here, rather than at IOR decode 00247 // time for several reasons: 00248 // 1. A request on the object may never be invoked. 00249 // 2. The DNS setup may have changed dynamically. 00250 // ...etc.. 00251 00252 // Double checked locking optimization. 00253 if (!this->object_addr_set_) 00254 { 00255 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00256 guard, 00257 this->addr_lookup_lock_, 00258 this->object_addr_ ); 00259 00260 if (!this->object_addr_set_) 00261 { 00262 (void) this->object_addr_i (); 00263 } 00264 } 00265 return this->object_addr_; 00266 } |
|
Helper method for object_addr () call.
Definition at line 269 of file DIOP_Endpoint.cpp. References AF_INET, ACE_INET_Addr::set(), ACE_Addr::set_type(), ACE_OS::strlen(), and ACE_OS::strspn(). Referenced by object_addr().
00270 { 00271 // We should have already held the lock 00272 00273 #if defined (ACE_HAS_IPV6) 00274 bool is_ipv4_decimal_ = false; 00275 if (!this->is_ipv6_decimal_) 00276 is_ipv4_decimal_ = 00277 ACE_OS::strspn (this->host_.in (), ".0123456789") == 00278 ACE_OS::strlen (this->host_.in ()); 00279 00280 // If this is *not* an IPv4 decimal address at first try to 00281 // resolve the address as an IPv6 address; if that fails 00282 // (or it's an IPv4 address) and the address is *not* an IPv6 00283 // decimal address try to resolve it as an IPv4 address. 00284 if ((is_ipv4_decimal_ || 00285 this->object_addr_.set (this->port_, 00286 this->host_.in (), 00287 1, 00288 AF_INET6) == -1) && 00289 (this->is_ipv6_decimal_ || 00290 this->object_addr_.set (this->port_, 00291 this->host_.in (), 00292 1, 00293 AF_INET) == -1)) 00294 #else 00295 if (this->object_addr_.set (this->port_, 00296 this->host_.in ()) == -1) 00297 #endif /* ACE_HAS_IPV6 */ 00298 { 00299 // If this call fails, it most likely due a hostname 00300 // lookup failure caused by a DNS misconfiguration. If 00301 // a request is made to the object at the given host and 00302 // port, then a CORBA::TRANSIENT() exception should be 00303 // thrown. 00304 00305 // Invalidate the ACE_INET_Addr. This is used as a flag 00306 // to denote that ACE_INET_Addr initialization failed. 00307 this->object_addr_.set_type (-1); 00308 } 00309 else 00310 { 00311 this->object_addr_set_ = true; 00312 } 00313 } |
|
Set the port number.
Definition at line 20 of file DIOP_Endpoint.inl.
00021 { 00022 return this->port_ = p; 00023 } |
|
Return the port number.
Definition at line 14 of file DIOP_Endpoint.inl. Referenced by TAO_DIOP_Profile::encode_endpoints(), hash(), TAO_DIOP_Acceptor::is_collocated(), is_equivalent(), TAO_DIOP_Connector::make_connection(), and TAO_DIOP_Profile::to_string().
00015 { 00016 return this->port_; 00017 } |
|
Helper method for setting INET_Addr.
Definition at line 98 of file DIOP_Endpoint.cpp. References ACE_DEBUG, ACE_TEXT, ACE_INET_Addr::get_host_addr(), ACE_INET_Addr::get_host_name(), ACE_INET_Addr::get_port_number(), ACE_Addr::get_type(), LM_DEBUG, MAXHOSTNAMELEN, CORBA::string_dup(), and TAO_debug_level. Referenced by TAO_DIOP_Endpoint().
00100 { 00101 char tmp_host[MAXHOSTNAMELEN + 1]; 00102 00103 #if defined (ACE_HAS_IPV6) 00104 this->is_ipv6_decimal_ = false; // Reset 00105 #endif /* ACE_HAS_IPV6 */ 00106 00107 if (use_dotted_decimal_addresses 00108 || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) 00109 { 00110 if (use_dotted_decimal_addresses == 0 && TAO_debug_level > 5) 00111 { 00112 ACE_DEBUG ((LM_DEBUG, 00113 ACE_TEXT ("TAO (%P|%t) - DIOP_Endpoint::set, ") 00114 ACE_TEXT ("%p\n"), 00115 ACE_TEXT ("cannot determine hostname"))); 00116 } 00117 00118 const char *tmp = addr.get_host_addr (); 00119 if (tmp == 0) 00120 { 00121 if (TAO_debug_level > 0) 00122 ACE_DEBUG ((LM_DEBUG, 00123 ACE_TEXT ("TAO (%P|%t) - ") 00124 ACE_TEXT ("DIOP_Endpoint::set, ") 00125 ACE_TEXT ("%p\n"), 00126 ACE_TEXT ("cannot determine hostname\n"))); 00127 return -1; 00128 } 00129 else 00130 { 00131 this->host_ = tmp; 00132 #if defined (ACE_HAS_IPV6) 00133 if (addr.get_type () == PF_INET6) 00134 this->is_ipv6_decimal_ = true; 00135 #endif /* ACE_HAS_IPV6 */ 00136 } 00137 } 00138 else 00139 this->host_ = CORBA::string_dup (tmp_host); 00140 00141 this->port_ = addr.get_port_number (); 00142 00143 return 0; 00144 } |
|
Definition at line 48 of file DIOP_Endpoint.h. |
|
Definition at line 49 of file DIOP_Endpoint.h. |
|
String representing the host name.
Definition at line 124 of file DIOP_Endpoint.h. Referenced by TAO_DIOP_Profile::parse_string_i(). |
|
Does the host string represent an IPv6 decimal address.
Definition at line 131 of file DIOP_Endpoint.h. Referenced by TAO_DIOP_Profile::create_profile_body(), TAO_DIOP_Profile::encode_endpoints(), TAO_DIOP_Profile::parse_string_i(), and TAO_DIOP_Profile::to_string(). |
|
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. Referenced by TAO_DIOP_Profile::add_endpoint(), TAO_DIOP_Profile::do_is_equivalent(), TAO_DIOP_Profile::encode_endpoints(), TAO_DIOP_Profile::hash(), and TAO_DIOP_Profile::to_string(). |
|
Cached instance of for use in making invocations, etc. Definition at line 136 of file DIOP_Endpoint.h. Referenced by TAO_DIOP_Profile::decode_profile(). |
|
Flag to indicate if the address has been resolved and set.
Definition at line 139 of file DIOP_Endpoint.h. |
|
TCP port number.
Definition at line 127 of file DIOP_Endpoint.h. Referenced by TAO_DIOP_Profile::parse_string_i(). |