#include <SCIOP_Endpoint.h>
Inheritance diagram for TAO_SCIOP_Endpoint:
Public Member Functions | |
TAO_SCIOP_Endpoint (void) | |
Default constructor. | |
TAO_SCIOP_Endpoint (const char *host, CORBA::UShort port, const ACE_INET_Addr &addr, CORBA::Short priority=TAO_INVALID_PRIORITY) | |
TAO_SCIOP_Endpoint (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses) | |
Constructor. | |
TAO_SCIOP_Endpoint (const char *host, CORBA::UShort port, CORBA::Short priority) | |
Constructor. This constructor is used when decoding endpoints. | |
~TAO_SCIOP_Endpoint (void) | |
Destructor. | |
virtual TAO_Endpoint * | next (void) |
virtual int | addr_to_string (char *buffer, size_t length) |
virtual TAO_Endpoint * | duplicate (void) |
virtual CORBA::Boolean | is_equivalent (const TAO_Endpoint *other_endpoint) |
virtual CORBA::ULong | hash (void) |
Return a hash value for this object. | |
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. | |
bool | is_preferred_network (void) const |
Do we have a preferred local network for the target? | |
const char * | preferred_network (void) const |
Return the preferred network if any. | |
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 (). | |
CORBA::ULong | preferred_interfaces (TAO_ORB_Core *oc) |
TAO_SCIOP_Endpoint (const TAO_SCIOP_Endpoint &) | |
Canonical copy constructor. | |
Private Attributes | |
CORBA::String_var | host_ |
String representing the host name. | |
CORBA::UShort | port_ |
TCP port number. | |
ACE_INET_Addr | object_addr_ |
int | object_addr_set_ |
Flag to indicate if the address has been resolved and set. | |
TAO::IIOP_Endpoint_Info | preferred_path_ |
Preferred path for this endpoint. | |
bool | is_encodable_ |
Is this endpoint created encodable as part of the IOR? | |
TAO_SCIOP_Endpoint * | next_ |
Friends | |
class | TAO_SCIOP_Profile |
class | TAO_SSLIOP_Profile |
SCIOP-specific implementation of PP Framework Endpoint interface.
Definition at line 46 of file SCIOP_Endpoint.h.
|
Default constructor.
Definition at line 57 of file SCIOP_Endpoint.cpp. References TAO_TAG_SCIOP_PROFILE.
00058 : TAO_Endpoint (TAO_TAG_SCIOP_PROFILE) 00059 , host_ () 00060 , port_ (683) // default port (IANA assigned) 00061 , object_addr_ () 00062 , object_addr_set_ (0) 00063 , preferred_path_ () 00064 , is_encodable_ (true) 00065 , next_ (0) 00066 { 00067 } |
|
Constructor. This is the most efficient constructor since it does not require any address resolution processing. Definition at line 41 of file SCIOP_Endpoint.cpp. References TAO_TAG_SCIOP_PROFILE.
00045 : TAO_Endpoint (TAO_TAG_SCIOP_PROFILE, 00046 priority) 00047 , host_ (host) 00048 , port_ (port) 00049 , object_addr_ (addr) 00050 , object_addr_set_ (0) 00051 , preferred_path_ () 00052 , is_encodable_ (true) 00053 , next_ (0) 00054 { 00055 } |
|
Constructor.
Definition at line 27 of file SCIOP_Endpoint.cpp. References set(), and TAO_TAG_SCIOP_PROFILE.
00029 : TAO_Endpoint (TAO_TAG_SCIOP_PROFILE) 00030 , host_ () 00031 , port_ (683) // default port (IANA assigned) 00032 , object_addr_ (addr) 00033 , object_addr_set_ (0) 00034 , preferred_path_ () 00035 , is_encodable_ (true) 00036 , next_ (0) 00037 { 00038 this->set (addr, use_dotted_decimal_addresses); 00039 } |
|
Constructor. This constructor is used when decoding endpoints.
Definition at line 69 of file SCIOP_Endpoint.cpp. References TAO_Endpoint::priority(), and TAO_TAG_SCIOP_PROFILE.
00072 : TAO_Endpoint (TAO_TAG_SCIOP_PROFILE) 00073 , host_ (host) 00074 , port_ (port) 00075 , object_addr_ () 00076 , object_addr_set_ (0) 00077 , preferred_path_ () 00078 , is_encodable_ (true) 00079 , next_ (0) 00080 { 00081 this->priority (priority); 00082 } |
|
Destructor.
Definition at line 84 of file SCIOP_Endpoint.cpp.
00085 { 00086 } |
|
Canonical copy constructor. In private section to prevent clients from invoking this accidentally. Clients should only use duplicate () to make a depp copy Definition at line 88 of file SCIOP_Endpoint.cpp.
00089 : TAO_Endpoint (rhs.tag_, 00090 rhs.priority_) 00091 , host_ (rhs.host_) 00092 , port_ (rhs.port_) 00093 , object_addr_ (rhs.object_addr_) 00094 , object_addr_set_ (rhs.object_addr_set_) 00095 , preferred_path_ (rhs.preferred_path_) 00096 , is_encodable_ (rhs.is_encodable_) 00097 , next_ (0) 00098 { 00099 } |
|
Implements TAO_Endpoint. Definition at line 133 of file SCIOP_Endpoint.cpp. References ACE_OS::sprintf(), and ACE_OS::strlen().
00134 { 00135 size_t actual_len = 00136 ACE_OS::strlen (this->host_.in ()) // chars in host name 00137 + sizeof (':') // delimiter 00138 + ACE_OS::strlen ("65536") // max port 00139 + sizeof ('\0'); 00140 00141 if (length < actual_len) 00142 return -1; 00143 00144 ACE_OS::sprintf (buffer, "%s:%d", 00145 this->host_.in (), this->port_); 00146 00147 return 0; 00148 } |
|
Implements TAO_Endpoint. Definition at line 165 of file SCIOP_Endpoint.cpp. References ACE_NEW_RETURN. Referenced by preferred_interfaces().
00166 { 00167 TAO_SCIOP_Endpoint *endpoint = 0; 00168 00169 // @@NOTE: Not at all exception safe 00170 ACE_NEW_RETURN (endpoint, 00171 TAO_SCIOP_Endpoint (*this), 00172 0); 00173 00174 return endpoint; 00175 } |
|
Return a hash value for this object.
Implements TAO_Endpoint. Definition at line 193 of file SCIOP_Endpoint.cpp. References ACE_GUARD_RETURN, ACE_INET_Addr::get_ip_address(), object_addr_i(), port(), and TAO_SYNCH_MUTEX. Referenced by TAO_SCIOP_Profile::hash().
00194 { 00195 if (this->hash_val_ != 0) 00196 return this->hash_val_; 00197 00198 { 00199 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00200 guard, 00201 this->addr_lookup_lock_, 00202 this->hash_val_); 00203 // .. DCL 00204 if (this->hash_val_ != 0) 00205 return this->hash_val_; 00206 00207 // A few comments about this optimization. The call below will 00208 // deadlock if the object_addr_set is false. If you don't belive 00209 00210 if (!this->object_addr_set_) 00211 { 00212 // Set the object_addr first 00213 (void) this->object_addr_i (); 00214 } 00215 00216 this->hash_val_ = 00217 this->object_addr_.get_ip_address () + this->port (); 00218 } 00219 00220 return this->hash_val_; 00221 } |
|
Copy the string into and return the resulting pointer. This object maintains ownership of this string. Definition at line 151 of file SCIOP_Endpoint.cpp.
|
|
Return a pointer to the host string. This object maintains ownership of this string. Definition at line 7 of file SCIOP_Endpoint.i. Referenced by TAO_SCIOP_Profile::create_profile_body(), TAO_SCIOP_Profile::encode_endpoints(), TAO_SCIOP_Acceptor::is_collocated(), is_equivalent(), and TAO_SCIOP_Connector::make_connection_i().
00008 { 00009 return this->host_.in (); 00010 } |
|
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 178 of file SCIOP_Endpoint.cpp. References host(), port_, and ACE_OS::strcmp(). Referenced by TAO_SCIOP_Profile::do_is_equivalent().
00179 { 00180 TAO_Endpoint *endpt = 00181 const_cast<TAO_Endpoint *> (other_endpoint); 00182 00183 TAO_SCIOP_Endpoint *endpoint = 00184 dynamic_cast<TAO_SCIOP_Endpoint *> (endpt); 00185 if (endpoint == 0) 00186 return 0; 00187 00188 return (this->port_ == endpoint->port_ 00189 && (ACE_OS::strcmp(this->host(), endpoint->host()) == 0)); 00190 } |
|
Do we have a preferred local network for the target?
Definition at line 357 of file SCIOP_Endpoint.cpp. References TAO::IIOP_Endpoint_Info::host. Referenced by TAO_SCIOP_Connector::make_connection_i().
00358 { 00359 return (this->preferred_path_.host.in () != 0); 00360 } |
|
Implements TAO_Endpoint. Definition at line 159 of file SCIOP_Endpoint.cpp.
00160 { 00161 return this->next_; 00162 } |
|
Return a reference to the .
Definition at line 224 of file SCIOP_Endpoint.cpp. References ACE_GUARD_RETURN, object_addr_i(), and TAO_SYNCH_MUTEX. Referenced by TAO_SCIOP_Connector::make_connection_i(), and TAO_SCIOP_Connector::set_validate_endpoint().
00225 { 00226 // The object_addr_ is initialized here, rather than at IOR decode 00227 // time for several reasons: 00228 // 1. A request on the object may never be invoked. 00229 // 2. The DNS setup may have changed dynamically. 00230 // ...etc.. 00231 00232 // Double checked locking optimization. 00233 if (!this->object_addr_set_) 00234 { 00235 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00236 guard, 00237 this->addr_lookup_lock_, 00238 this->object_addr_); 00239 00240 if (!this->object_addr_set_) 00241 { 00242 (void) this->object_addr_i (); 00243 } 00244 } 00245 00246 return this->object_addr_; 00247 } |
|
Helper method for object_addr ().
Definition at line 250 of file SCIOP_Endpoint.cpp. References ACE_INET_Addr::set(), and ACE_Addr::set_type(). Referenced by hash(), and object_addr().
00251 { 00252 if (this->object_addr_.set (this->port_, 00253 this->host_.in ()) == -1) 00254 { 00255 // If this call fails, it most likely due a hostname 00256 // lookup failure caused by a DNS misconfiguration. If 00257 // a request is made to the object at the given host and 00258 // port, then a CORBA::TRANSIENT() exception should be 00259 // thrown. 00260 00261 // Invalidate the ACE_INET_Addr. This is used as a flag 00262 // to denote that ACE_INET_Addr initialization failed. 00263 this->object_addr_.set_type (-1); 00264 } 00265 else 00266 { 00267 this->object_addr_set_ = true; 00268 } 00269 } |
|
Set the port number.
Definition at line 19 of file SCIOP_Endpoint.i.
00020 { 00021 return this->port_ = p; 00022 } |
|
Return the port number.
Definition at line 13 of file SCIOP_Endpoint.i. Referenced by TAO_SCIOP_Profile::encode_endpoints(), hash(), TAO_SCIOP_Acceptor::is_collocated(), TAO_SCIOP_Connector::make_connection_i(), and TAO_SCIOP_Profile::to_string().
00014 { 00015 return this->port_; 00016 } |
|
Generate preferred interfaces from the options passed in by the user. Definition at line 272 of file SCIOP_Endpoint.cpp. References ACE_CString, ACE_DEBUG, duplicate(), TAO_ORB_Parameters::enforce_pref_interfaces(), TAO::IIOP_Endpoint_Info::host, host_, LM_DEBUG, next_, TAO_ORB_Core::orb_params(), TAO_ORB_Parameters::preferred_interfaces(), preferred_path_, ssize_t, CORBA::string_dup(), and TAO_debug_level. Referenced by TAO_SCIOP_Profile::decode_profile().
00273 { 00274 ACE_CString tmp ( 00275 oc->orb_params ()->preferred_interfaces ()); 00276 00277 ssize_t pos = 0; 00278 00279 pos = tmp.find (this->host_.in ()); 00280 00281 TAO_SCIOP_Endpoint *latest = this; 00282 00283 CORBA::ULong count = 0; 00284 00285 while (pos != ACE_CString::npos) 00286 { 00287 // Do we have a "," or an '\0'? 00288 ssize_t new_pos = tmp.find (",", 00289 pos + 1); 00290 00291 // Length of the preferred path 00292 int length = 0; 00293 00294 if (new_pos == ACE_CString::npos) 00295 length = tmp.length () - pos; 00296 else 00297 length = new_pos - pos; 00298 00299 ACE_CString rem_tmp = tmp.substr (pos, length); 00300 00301 // Search for the ":" 00302 ssize_t col_pos = rem_tmp.find (":"); 00303 00304 if (col_pos == ACE_CString::npos) 00305 { 00306 pos = tmp.find (latest->host_.in (), 00307 pos + length); 00308 continue; 00309 } 00310 00311 ACE_CString path = rem_tmp.substr (col_pos + 1); 00312 00313 latest->preferred_path_.host = 00314 CORBA::string_dup (path.c_str ()); 00315 00316 if (TAO_debug_level > 3) 00317 ACE_DEBUG ((LM_DEBUG, 00318 "(%P|%t) Adding path [%s] " 00319 " as preferred path for [%s] \n", 00320 path.c_str (), this->host_.in ())); 00321 00322 pos = tmp.find (latest->host_.in (), 00323 pos + length); 00324 00325 if (pos != ACE_CString::npos) 00326 { 00327 TAO_Endpoint *tmp_ep = 00328 latest->duplicate (); 00329 00330 latest->next_ = dynamic_cast<TAO_SCIOP_Endpoint *> (tmp_ep); 00331 00332 if (latest->next_ == 0) return count; 00333 00334 latest = latest->next_; 00335 ++count; 00336 } 00337 } 00338 00339 if (tmp.length () != 0 && 00340 !oc->orb_params ()->enforce_pref_interfaces ()) 00341 { 00342 TAO_Endpoint *tmp_ep = latest->duplicate (); 00343 00344 latest->next_ = 00345 dynamic_cast<TAO_SCIOP_Endpoint *> (tmp_ep); 00346 00347 if (latest->next_ == 0) return count; 00348 00349 latest->next_->preferred_path_.host = (const char *) 0; 00350 ++count; 00351 } 00352 00353 return count; 00354 } |
|
Return the preferred network if any.
Definition at line 363 of file SCIOP_Endpoint.cpp. References TAO::IIOP_Endpoint_Info::host. Referenced by TAO_SCIOP_Connector::make_connection_i().
00364 { 00365 return this->preferred_path_.host.in (); 00366 } |
|
Helper method for setting INET_Addr.
Definition at line 102 of file SCIOP_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(), LM_DEBUG, MAXHOSTNAMELEN, CORBA::string_dup(), and TAO_debug_level. Referenced by TAO_SCIOP_Endpoint().
00104 { 00105 char tmp_host[MAXHOSTNAMELEN + 1]; 00106 00107 if (use_dotted_decimal_addresses 00108 || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) 00109 { 00110 const char *tmp = addr.get_host_addr (); 00111 if (tmp == 0) 00112 { 00113 if (TAO_debug_level > 0) 00114 ACE_DEBUG ((LM_DEBUG, 00115 ACE_TEXT ("\n\nTAO (%P|%t) ") 00116 ACE_TEXT ("SCIOP_Endpoint::set ") 00117 ACE_TEXT ("- %p\n\n"), 00118 ACE_TEXT ("cannot determine hostname"))); 00119 return -1; 00120 } 00121 else 00122 this->host_ = tmp; 00123 } 00124 else 00125 this->host_ = CORBA::string_dup (tmp_host); 00126 00127 this->port_ = addr.get_port_number(); 00128 00129 return 0; 00130 } |
|
Definition at line 51 of file SCIOP_Endpoint.h. |
|
Definition at line 52 of file SCIOP_Endpoint.h. |
|
String representing the host name.
Definition at line 140 of file SCIOP_Endpoint.h. Referenced by TAO_SCIOP_Profile::decode_profile(), TAO_SCIOP_Profile::parse_string_i(), and preferred_interfaces(). |
|
Is this endpoint created encodable as part of the IOR?
Definition at line 156 of file SCIOP_Endpoint.h. Referenced by TAO_SCIOP_Profile::encode_endpoints(). |
|
SCIOP Endpoints can be stringed into a list. Return the next endpoint in the list, if any. Definition at line 160 of file SCIOP_Endpoint.h. Referenced by TAO_SCIOP_Profile::add_endpoint(), TAO_SCIOP_Profile::create_profile_body(), TAO_SCIOP_Profile::do_is_equivalent(), TAO_SCIOP_Profile::encode_endpoints(), TAO_SCIOP_Profile::hash(), and preferred_interfaces(). |
|
Cached instance of for use in making invocations, etc. Definition at line 147 of file SCIOP_Endpoint.h. Referenced by TAO_SCIOP_Profile::decode_profile(). |
|
Flag to indicate if the address has been resolved and set.
Definition at line 150 of file SCIOP_Endpoint.h. |
|
TCP port number.
Definition at line 143 of file SCIOP_Endpoint.h. Referenced by is_equivalent(), and TAO_SCIOP_Profile::parse_string_i(). |
|
Preferred path for this endpoint.
Definition at line 153 of file SCIOP_Endpoint.h. Referenced by preferred_interfaces(). |