#include <SCIOP_Profile.h>
Inheritance diagram for TAO_SCIOP_Profile:
Public Member Functions | |
virtual char | object_key_delimiter (void) const |
TAO_SCIOP_Profile (const ACE_INET_Addr &addr, const TAO::ObjectKey &object_key, const TAO_GIOP_Message_Version &version, TAO_ORB_Core *orb_core) | |
TAO_SCIOP_Profile (const char *host, CORBA::UShort port, const TAO::ObjectKey &object_key, const ACE_INET_Addr &addr, const TAO_GIOP_Message_Version &version, TAO_ORB_Core *orb_core) | |
TAO_SCIOP_Profile (TAO_ORB_Core *orb_core) | |
Profile constructor, default. | |
~TAO_SCIOP_Profile (void) | |
Destructor is to be called only through . | |
virtual char * | to_string () |
Template methods. Please see Profile.h for documentation. | |
virtual int | encode_endpoints (void) |
virtual TAO_Endpoint * | endpoint (void) |
virtual CORBA::ULong | endpoint_count (void) const |
virtual CORBA::ULong | hash (CORBA::ULong max) |
void | add_endpoint (TAO_SCIOP_Endpoint *endp) |
Static Public Member Functions | |
const char * | prefix (void) |
Return the char string prefix. | |
Static Public Attributes | |
const char | object_key_delimiter_ = '/' |
The object key delimiter that SCIOP uses or expects. | |
Protected Member Functions | |
virtual int | decode_profile (TAO_InputCDR &cdr) |
Template methods. Please see Profile.h for the documentation. | |
virtual int | decode_endpoints (void) |
virtual void | parse_string_i (const char *string) |
virtual void | create_profile_body (TAO_OutputCDR &cdr) const |
virtual CORBA::Boolean | do_is_equivalent (const TAO_Profile *other_profile) |
Protected Attributes | |
TAO_SCIOP_Endpoint | endpoint_ |
CORBA::ULong | count_ |
Number of endpoints in the list headed by . |
This class defines the SCIOP profile as specified in the CORBA specification.
Definition at line 43 of file SCIOP_Profile.h.
|
Profile constructor, same as above except the object_key has already been marshaled. Definition at line 32 of file SCIOP_Profile.cpp. References TAO_TAG_SCIOP_PROFILE.
00036 : TAO_Profile (TAO_TAG_SCIOP_PROFILE, 00037 orb_core, 00038 object_key, 00039 version), 00040 endpoint_ (addr, 00041 orb_core->orb_params ()->use_dotted_decimal_addresses ()), 00042 count_ (1) 00043 { 00044 } |
|
Profile constructor, this is the most efficient since it doesn't require any address resolution processing. Definition at line 46 of file SCIOP_Profile.cpp. References TAO_TAG_SCIOP_PROFILE.
00052 : TAO_Profile (TAO_TAG_SCIOP_PROFILE, 00053 orb_core, 00054 object_key, 00055 version), 00056 endpoint_ (host, port, addr), 00057 count_ (1) 00058 { 00059 } |
|
Profile constructor, default.
Definition at line 61 of file SCIOP_Profile.cpp. References TAO_TAG_SCIOP_PROFILE.
00062 : TAO_Profile (TAO_TAG_SCIOP_PROFILE, 00063 orb_core, 00064 TAO_GIOP_Message_Version (TAO_DEF_SCIOP_MAJOR, TAO_DEF_SCIOP_MINOR)), 00065 endpoint_ (), 00066 count_ (1) 00067 { 00068 } |
|
Destructor is to be called only through .
Definition at line 70 of file SCIOP_Profile.cpp. References endpoint(), and TAO_Endpoint::next().
00071 { 00072 // Clean up the list of endpoints since we own it. 00073 // Skip the head, since it is not dynamically allocated. 00074 TAO_Endpoint *tmp = 0; 00075 00076 for (TAO_Endpoint *next = this->endpoint ()->next (); 00077 next != 0; 00078 next = tmp) 00079 { 00080 tmp = next->next (); 00081 delete next; 00082 } 00083 } |
|
Add to this profile's list of endpoints (it is inserted next to the head of the list). This profiles takes ownership of . Definition at line 306 of file SCIOP_Profile.cpp. References TAO_SCIOP_Endpoint::next_. Referenced by TAO_SCIOP_Acceptor::create_shared_profile(), decode_endpoints(), and decode_profile().
|
|
Implements TAO_Profile. Definition at line 359 of file SCIOP_Profile.cpp. References ACE_ERROR, TAO_Tagged_Components::encode(), TAO_SCIOP_Endpoint::host(), TAO::details::unbounded_basic_string_sequence< char >::length(), LM_ERROR, TAO_SCIOP_Endpoint::next_, TAO::Refcounted_ObjectKey::object_key(), TAO_Profile::tagged_components(), TAO_ENCAP_BYTE_ORDER, ACE_OutputCDR::write_octet(), and ACE_OutputCDR::write_ushort().
00360 { 00361 encap.write_octet (TAO_ENCAP_BYTE_ORDER); 00362 00363 // The SCIOP version 00364 encap.write_octet (this->version_.major); 00365 encap.write_octet (this->version_.minor); 00366 00367 // STRING hostname from profile 00368 // encap.write_string (this->endpoint_.host ()); 00369 00370 CORBA::StringSeq strseq; 00371 strseq.length(this->count_); 00372 00373 const TAO_SCIOP_Endpoint *endpoint = &this->endpoint_; 00374 for (CORBA::ULong i = 0; 00375 i < this->count_; 00376 ++i) 00377 { 00378 strseq[i] = endpoint->host(); 00379 endpoint = endpoint->next_; 00380 } 00381 00382 // strseq[0] = this->endpoint_.host(); 00383 encap << strseq; 00384 00385 // UNSIGNED SHORT port number 00386 encap.write_ushort (this->endpoint_.port ()); 00387 00388 // UNSIGNED SHORT max_streams 00389 encap.write_ushort (1); 00390 00391 // OCTET SEQUENCE for object key 00392 if (this->ref_object_key_) 00393 encap << this->ref_object_key_->object_key (); 00394 else 00395 { 00396 ACE_ERROR ((LM_ERROR, 00397 "(%P|%t) TAO - IIOP_Profile::create_profile_body " 00398 "no object key marshalled \n")); 00399 } 00400 00401 // Tagged Components 00402 this->tagged_components ().encode (encap); 00403 } |
|
Implements TAO_Profile. Definition at line 462 of file SCIOP_Profile.cpp. References ACE_NEW_RETURN, add_endpoint(), IOP::TaggedComponent::component_data, TAO::unbounded_value_sequence< T >::get_buffer(), TAO_Tagged_Components::get_component(), TAO::unbounded_value_sequence< TAO_SCIOP_Endpoint_Info >::length(), TAO::unbounded_value_sequence< T >::length(), TAO_Endpoint::priority(), ACE_InputCDR::reset_byte_order(), and IOP::TaggedComponent::tag.
00463 { 00464 IOP::TaggedComponent tagged_component; 00465 tagged_component.tag = TAO_TAG_ENDPOINTS; 00466 00467 if (this->tagged_components_.get_component (tagged_component)) 00468 { 00469 const CORBA::Octet *buf = 00470 tagged_component.component_data.get_buffer (); 00471 00472 TAO_InputCDR in_cdr (reinterpret_cast<const char*> (buf), 00473 tagged_component.component_data.length ()); 00474 00475 // Extract the Byte Order. 00476 CORBA::Boolean byte_order; 00477 if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) 00478 return -1; 00479 in_cdr.reset_byte_order (static_cast<int> (byte_order)); 00480 00481 // Extract endpoints sequence. 00482 TAO_SCIOPEndpointSequence endpoints; 00483 00484 if ((in_cdr >> endpoints) == 0) 00485 return -1; 00486 00487 // Get the priority of the first endpoint (head of the list. 00488 // It's other data is extracted as part of the standard profile 00489 // decoding. 00490 this->endpoint_.priority (endpoints[0].priority); 00491 00492 // Use information extracted from the tagged component to 00493 // populate the profile. Skip the first endpoint, since it is 00494 // always extracted through standard profile body. Also, begin 00495 // from the end of the sequence to preserve endpoint order, 00496 // since <add_endpoint> method reverses the order of endpoints 00497 // in the list. 00498 for (CORBA::ULong i = endpoints.length () - 1; 00499 i > 0; 00500 --i) 00501 { 00502 TAO_SCIOP_Endpoint *endpoint = 0; 00503 ACE_NEW_RETURN (endpoint, 00504 TAO_SCIOP_Endpoint (endpoints[i].host, 00505 endpoints[i].port, 00506 endpoints[i].priority), 00507 -1); 00508 00509 this->add_endpoint (endpoint); 00510 } 00511 } 00512 00513 return 0; 00514 } |
|
Template methods. Please see Profile.h for the documentation.
Implements TAO_Profile. Definition at line 86 of file SCIOP_Profile.cpp. References ACE_DEBUG, ACE_NEW_RETURN, ACE_TEXT, add_endpoint(), ACE_InputCDR::good_bit(), TAO_SCIOP_Endpoint::host_, LM_DEBUG, TAO_SCIOP_Endpoint::object_addr_, TAO_SCIOP_Endpoint::preferred_interfaces(), ACE_InputCDR::read_ushort(), ACE_Addr::set_type(), and TAO_debug_level.
00087 { 00088 // Decode multiple endpoints, starting with the primary (endpoint_) 00089 CORBA::StringSeq endpointSeq; 00090 cdr >> endpointSeq; 00091 00092 this->endpoint_.host_ = endpointSeq[0]; 00093 00094 if (cdr.read_ushort (this->endpoint_.port_) == 0) 00095 { 00096 if (TAO_debug_level > 0) 00097 ACE_DEBUG ((LM_DEBUG, 00098 ACE_TEXT ("TAO (%P|%t) SCIOP_Profile::decode - ") 00099 ACE_TEXT ("error while decoding host/port"))); 00100 return -1; 00101 } 00102 00103 // Add multiple endpoints > 1 00104 00105 for (int i=endpointSeq.length() - 1; i > 0 ; i--) 00106 { 00107 TAO_SCIOP_Endpoint *endpoint = 0; 00108 ACE_NEW_RETURN (endpoint, 00109 TAO_SCIOP_Endpoint (endpointSeq[i], 00110 this->endpoint_.port_, 00111 this->endpoint_.priority()), 00112 -1); 00113 00114 this->count_ += 00115 endpoint->preferred_interfaces (this->orb_core ()); 00116 00117 this->add_endpoint (endpoint); 00118 } 00119 00120 // SCIOR has a max_streams variable 00121 // We are ignoring it for now since ACE SCTP code fixes at 1 anyway. 00122 00123 CORBA::UShort max_streams; 00124 if ((cdr.read_ushort(max_streams)) == 0) { 00125 return -1; 00126 } 00127 00128 if (cdr.good_bit ()) 00129 { 00130 // Invalidate the object_addr_ until first access. 00131 this->endpoint_.object_addr_.set_type (-1); 00132 00133 return 1; 00134 } 00135 00136 return -1; 00137 } |
|
Implements TAO_Profile. Definition at line 240 of file SCIOP_Profile.cpp. References endpoint_, TAO_SCIOP_Endpoint::is_equivalent(), and TAO_SCIOP_Endpoint::next_.
00241 { 00242 const TAO_SCIOP_Profile *op = 00243 dynamic_cast<const TAO_SCIOP_Profile *> (other_profile); 00244 00245 if (op == 0) 00246 return 0; 00247 00248 // Check endpoints equivalence. 00249 const TAO_SCIOP_Endpoint *other_endp = &op->endpoint_; 00250 for (TAO_SCIOP_Endpoint *endp = &this->endpoint_; 00251 endp != 0; 00252 endp = endp->next_) 00253 { 00254 if (endp->is_equivalent (other_endp)) 00255 other_endp = other_endp->next_; 00256 else 00257 return 0; 00258 } 00259 00260 return 1; 00261 } |
|
Implements TAO_Profile. Definition at line 406 of file SCIOP_Profile.cpp. References TAO_SCIOP_Endpoint::host(), TAO_SCIOP_Endpoint::is_encodable_, TAO::unbounded_value_sequence< TAO_SCIOP_Endpoint_Info >::length(), TAO_SCIOP_Endpoint::next_, TAO_SCIOP_Endpoint::port(), TAO_Endpoint::priority(), TAO_Profile::set_tagged_components(), and TAO_ENCAP_BYTE_ORDER.
00407 { 00408 CORBA::ULong actual_count = 0; 00409 00410 const TAO_SCIOP_Endpoint *endpoint = &this->endpoint_; 00411 00412 // Count the number of endpoints that needs to be encoded 00413 for (CORBA::ULong c = 0; 00414 c != this->count_; 00415 ++c) 00416 { 00417 if (endpoint->is_encodable_) 00418 ++actual_count; 00419 00420 endpoint = endpoint->next_; 00421 } 00422 00423 // Create a data structure and fill it with endpoint info for wire 00424 // transfer. 00425 // We include information for the head of the list 00426 // together with other endpoints because even though its addressing 00427 // info is transmitted using standard ProfileBody components, its 00428 // priority is not! 00429 00430 TAO_SCIOPEndpointSequence endpoints; 00431 endpoints.length (actual_count); 00432 00433 endpoint = &this->endpoint_; 00434 00435 for (CORBA::ULong i = 0; 00436 i < this->count_; 00437 ++i) 00438 { 00439 if (endpoint->is_encodable_) 00440 { 00441 endpoints[i].host = endpoint->host (); 00442 endpoints[i].port = endpoint->port (); 00443 endpoints[i].priority = endpoint->priority (); 00444 } 00445 00446 endpoint = endpoint->next_; 00447 } 00448 00449 // Encode the data structure. 00450 TAO_OutputCDR out_cdr; 00451 if ((out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) 00452 == 0) 00453 || (out_cdr << endpoints) == 0) 00454 return -1; 00455 00456 this->set_tagged_components (out_cdr); 00457 00458 return 0; 00459 } |
|
Implements TAO_Profile. Definition at line 294 of file SCIOP_Profile.cpp. Referenced by TAO_SCIOP_Acceptor::create_new_profile(), TAO_SCIOP_Acceptor::create_shared_profile(), and ~TAO_SCIOP_Profile().
00295 { 00296 return &this->endpoint_; 00297 } |
|
Implements TAO_Profile. Definition at line 300 of file SCIOP_Profile.cpp.
00301 { 00302 return this->count_; 00303 } |
|
Implements TAO_Profile. Definition at line 264 of file SCIOP_Profile.cpp. References TAO_SCIOP_Endpoint::hash(), TAO_Profile::hash_service_i(), TAO::unbounded_value_sequence< T >::length(), TAO_GIOP_Message_Version::minor, TAO_SCIOP_Endpoint::next_, TAO::Refcounted_ObjectKey::object_key(), and TAO_Profile::tag().
00266 { 00267 // Get the hash value for all endpoints. 00268 CORBA::ULong hashval = 0; 00269 for (TAO_SCIOP_Endpoint *endp = &this->endpoint_; 00270 endp != 0; 00271 endp = endp->next_) 00272 { 00273 hashval += endp->hash (); 00274 } 00275 00276 hashval += this->version_.minor; 00277 hashval += this->tag (); 00278 00279 const TAO::ObjectKey &ok = 00280 this->ref_object_key_->object_key (); 00281 00282 if (ok.length () >= 4) 00283 { 00284 hashval += ok[1]; 00285 hashval += ok[3]; 00286 } 00287 00288 hashval += this->hash_service_i (max); 00289 00290 return hashval % max; 00291 } |
|
Implements TAO_Profile. Definition at line 27 of file SCIOP_Profile.cpp. References object_key_delimiter_.
00028 { 00029 return TAO_SCIOP_Profile::object_key_delimiter_; 00030 } |
|
Implements TAO_Profile. Definition at line 140 of file SCIOP_Profile.cpp. References ACE_DEBUG, ACE_TEXT, ACE_THROW, ACE_OS::atoi(), TAO::ObjectKey_Table::bind(), TAO::ObjectKey::decode_string_to_sequence(), ACE_INET_Addr::get_host_name(), TAO_SCIOP_Endpoint::host_, LM_DEBUG, MAXHOSTNAMELEN, TAO_ORB_Core::object_key_table(), TAO_Profile::orb_core(), TAO_SCIOP_Endpoint::port_, ACE_OS::strchr(), ACE_OS::strcmp(), CORBA::string_alloc(), CORBA::string_dup(), ACE_OS::strncpy(), and TAO_debug_level.
00142 { 00143 // Pull off the "hostname:port/" part of the objref 00144 // Copy the string because we are going to modify it... 00145 00146 const char *okd = ACE_OS::strchr (ior, this->object_key_delimiter_); 00147 00148 if (okd == 0 || okd == ior) 00149 { 00150 // No object key delimiter or no hostname specified. 00151 ACE_THROW (CORBA::INV_OBJREF ( 00152 CORBA::SystemException::_tao_minor_code ( 00153 TAO::VMCID, 00154 EINVAL), 00155 CORBA::COMPLETED_NO)); 00156 } 00157 00158 // Length of host string. 00159 CORBA::ULong length_host = 0; 00160 00161 const char *cp_pos = ACE_OS::strchr (ior, ':'); // Look for a port 00162 00163 if (cp_pos == ior) 00164 { 00165 // No hostname specified! It is required by the spec. 00166 ACE_THROW (CORBA::INV_OBJREF ( 00167 CORBA::SystemException::_tao_minor_code ( 00168 TAO::VMCID, 00169 EINVAL), 00170 CORBA::COMPLETED_NO)); 00171 } 00172 else if (cp_pos != 0) 00173 { 00174 // A port number or port name was specified. 00175 CORBA::ULong length_port = okd - cp_pos - 1; 00176 00177 CORBA::String_var tmp = CORBA::string_alloc (length_port); 00178 00179 ACE_OS::strncpy (tmp.inout (), cp_pos + 1, length_port); 00180 tmp[length_port] = '\0'; 00181 00182 this->endpoint_.port_ = 00183 static_cast<CORBA::UShort> (ACE_OS::atoi (tmp.in ())); 00184 00185 length_host = cp_pos - ior; 00186 } 00187 else 00188 length_host = okd - ior; 00189 00190 CORBA::String_var tmp = CORBA::string_alloc (length_host); 00191 00192 // Skip the trailing '/' 00193 ACE_OS::strncpy (tmp.inout (), ior, length_host); 00194 tmp[length_host] = '\0'; 00195 00196 this->endpoint_.host_ = tmp._retn (); 00197 00198 if (ACE_OS::strcmp (this->endpoint_.host_.in (), "") == 0) 00199 { 00200 ACE_INET_Addr host_addr; 00201 00202 char tmp_host [MAXHOSTNAMELEN + 1]; 00203 00204 // If no host is specified: assign the default host, i.e. the 00205 // local host. 00206 if (host_addr.get_host_name (tmp_host, 00207 sizeof (tmp_host)) != 0) 00208 { 00209 // Can't get the IP address since the INET_Addr wasn't 00210 // initialized. Just throw an exception. 00211 00212 if (TAO_debug_level > 0) 00213 ACE_DEBUG ((LM_DEBUG, 00214 ACE_TEXT ("\n\nTAO (%P|%t) ") 00215 ACE_TEXT ("SCIOP_Profile::parse_string ") 00216 ACE_TEXT ("- %p\n\n"), 00217 ACE_TEXT ("cannot determine hostname"))); 00218 00219 // @@ What's the right exception to throw here? 00220 ACE_THROW (CORBA::INV_OBJREF ( 00221 CORBA::SystemException::_tao_minor_code ( 00222 TAO::VMCID, 00223 EINVAL), 00224 CORBA::COMPLETED_NO)); 00225 } 00226 else 00227 this->endpoint_.host_ = CORBA::string_dup (tmp_host); 00228 } 00229 00230 TAO::ObjectKey ok; 00231 00232 TAO::ObjectKey::decode_string_to_sequence (ok, 00233 okd + 1); 00234 00235 (void) this->orb_core ()->object_key_table ().bind (ok, 00236 this->ref_object_key_); 00237 } |
|
Return the char string prefix.
Definition at line 353 of file SCIOP_Profile.cpp.
00354 { 00355 return ::prefix_; 00356 } |
|
Template methods. Please see Profile.h for documentation.
Implements TAO_Profile. Definition at line 315 of file SCIOP_Profile.cpp. References TAO::ObjectKey::encode_sequence_to_string(), TAO::Refcounted_ObjectKey::object_key(), object_key_delimiter_, TAO_SCIOP_Endpoint::port(), prefix_, ACE_OS::sprintf(), CORBA::string_alloc(), and ACE_OS::strlen().
00316 { 00317 CORBA::String_var key; 00318 TAO::ObjectKey::encode_sequence_to_string (key.inout(), 00319 this->ref_object_key_->object_key()); 00320 00321 size_t buflen = (8 /* "corbaloc" */ + 00322 1 /* colon separator */ + 00323 ACE_OS::strlen (::prefix_) + 00324 1 /* colon separator */ + 00325 1 /* major version */ + 00326 1 /* decimal point */ + 00327 1 /* minor version */ + 00328 1 /* `@' character */ + 00329 ACE_OS::strlen (this->endpoint_.host ()) + 00330 1 /* colon separator */ + 00331 5 /* port number */ + 00332 1 /* object key separator */ + 00333 ACE_OS::strlen (key.in ())); 00334 00335 char * buf = CORBA::string_alloc (static_cast<CORBA::ULong> (buflen)); 00336 00337 static const char digits [] = "0123456789"; 00338 00339 ACE_OS::sprintf (buf, 00340 "corbaloc:%s:%c.%c@%s:%d%c%s", 00341 ::prefix_, 00342 digits [this->version_.major], 00343 digits [this->version_.minor], 00344 this->endpoint_.host (), 00345 this->endpoint_.port (), 00346 this->object_key_delimiter_, 00347 key.in ()); 00348 00349 return buf; 00350 } |
|
Number of endpoints in the list headed by .
Definition at line 134 of file SCIOP_Profile.h. |
|
Head of this profile's list of endpoints. This endpoint is not dynamically allocated because a profile always contains at least one endpoint. Currently, a profile contains more than one endpoint, i.e., list contains more than just the head, only for two cases (1) when RTCORBA is enabled and (2) the ORB is initialized with -ORBPreferredInterfaces option. However, in the near future, this will be used in for mode as well, e.g., to support TAG_ALTERNATE_IIOP_ADDRESS feature. This is probably as good a place to discuss how the list of endpoints is used for #2. If the ORB is configured to use preferred interfaces for invocation, TAO creates an endpoint per preferred interface. To be clear, every tuple <destination:target> will have an endpoint. What TAO essentially does is that creates it multiple endpoints so that the invocation code path can use existing iterating techniques to try one preferred interface after another (if the first did not work). If the ORB is configured with -ORBEnforcePreferredInterface set to false in addition to the ORBPreferredInterfaces option , TAO creates another endpoint with the preferred bit set to null, so that the invocation code can fall back to a SCTP stack returned local address. Addressing info of the default endpoint, i.e., head of the list, is transmitted using standard SCIOP ProfileBody components. See method documentation above for how the rest of the endpoint list is transmitted. Definition at line 131 of file SCIOP_Profile.h. Referenced by do_is_equivalent(). |
|
The object key delimiter that SCIOP uses or expects.
Definition at line 22 of file SCIOP_Profile.cpp. Referenced by object_key_delimiter(), and to_string(). |