00001 #include "tao/IIOP_Profile.h"
00002
00003 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00004
00005 #include "tao/ORB_Core.h"
00006 #include "tao/debug.h"
00007 #include "tao/IIOP_EndpointsC.h"
00008 #include "tao/CDR.h"
00009 #include "tao/SystemException.h"
00010
00011 #include "ace/OS_NS_string.h"
00012 #include "ace/OS_NS_stdio.h"
00013
00014 ACE_RCSID (tao,
00015 IIOP_Profile,
00016 "$Id: IIOP_Profile.cpp 86712 2009-09-15 07:55:56Z sma $")
00017
00018 #include "ace/os_include/os_netdb.h"
00019
00020 static const char the_prefix[] = "iiop";
00021
00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00023
00024 TAO_IIOP_Profile::~TAO_IIOP_Profile (void)
00025 {
00026
00027
00028 TAO_Endpoint *tmp = 0;
00029
00030 for (TAO_Endpoint *next = this->endpoint ()->next ();
00031 next != 0;
00032 next = tmp)
00033 {
00034 tmp = next->next ();
00035 delete next;
00036 }
00037 }
00038
00039
00040
00041 const char TAO_IIOP_Profile::object_key_delimiter_ = '/';
00042
00043 char
00044 TAO_IIOP_Profile::object_key_delimiter (void) const
00045 {
00046 return TAO_IIOP_Profile::object_key_delimiter_;
00047 }
00048
00049
00050
00051 TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr &addr,
00052 const TAO::ObjectKey &object_key,
00053 const TAO_GIOP_Message_Version &version,
00054 TAO_ORB_Core *orb_core)
00055 : TAO_Profile (IOP::TAG_INTERNET_IOP,
00056 orb_core,
00057 object_key,
00058 version),
00059 endpoint_ (addr,
00060 orb_core->orb_params ()->use_dotted_decimal_addresses ()),
00061 last_endpoint_ (&this->endpoint_),
00062 count_ (1)
00063 {
00064 }
00065
00066 TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host,
00067 CORBA::UShort port,
00068 const TAO::ObjectKey &object_key,
00069 const ACE_INET_Addr &addr,
00070 const TAO_GIOP_Message_Version &version,
00071 TAO_ORB_Core *orb_core)
00072 : TAO_Profile (IOP::TAG_INTERNET_IOP,
00073 orb_core,
00074 object_key,
00075 version),
00076 endpoint_ (host, port, addr),
00077 last_endpoint_ (&this->endpoint_),
00078 count_ (1)
00079 {
00080 }
00081
00082 TAO_IIOP_Profile::TAO_IIOP_Profile (TAO_ORB_Core *orb_core)
00083 : TAO_Profile (IOP::TAG_INTERNET_IOP,
00084 orb_core,
00085 TAO_GIOP_Message_Version (TAO_DEF_GIOP_MAJOR,
00086 TAO_DEF_GIOP_MINOR)),
00087 endpoint_ (),
00088 last_endpoint_ (&this->endpoint_),
00089 count_ (1)
00090 {
00091 }
00092
00093
00094 int
00095 TAO_IIOP_Profile::decode_profile (TAO_InputCDR& cdr)
00096 {
00097
00098
00099
00100 CORBA::String_var host;
00101 CORBA::UShort port;
00102
00103 if (cdr.read_string(host.out()) == 0 ||
00104 cdr.read_ushort (port) == 0)
00105 {
00106 if (TAO_debug_level > 0)
00107 ACE_DEBUG ((LM_DEBUG,
00108 ACE_TEXT ("TAO (%P|%t) IIOP_Profile::decode - ")
00109 ACE_TEXT ("error while decoding host/port\n")));
00110 return -1;
00111 }
00112
00113 this->endpoint_.host(host.in());
00114 this->endpoint_.port(port);
00115
00116 if (cdr.good_bit ())
00117 {
00118
00119 this->endpoint_.object_addr_.set_type (-1);
00120
00121 const char* csv = this->orb_core()->orb_params()->preferred_interfaces();
00122 bool const enforce =
00123 this->orb_core()->orb_params()->enforce_pref_interfaces();
00124 this->count_ += this->endpoint_.preferred_interfaces(csv, enforce, *this);
00125
00126 return 1;
00127 }
00128
00129 return -1;
00130 }
00131
00132 void
00133 TAO_IIOP_Profile::parse_string_i (const char *ior)
00134 {
00135
00136
00137
00138 const char *okd = ACE_OS::strchr (ior, this->object_key_delimiter_);
00139
00140 if (okd == 0 || okd == ior)
00141 {
00142
00143 throw ::CORBA::INV_OBJREF (
00144 CORBA::SystemException::_tao_minor_code (
00145 0,
00146 EINVAL),
00147 CORBA::COMPLETED_NO);
00148 }
00149
00150
00151 CORBA::ULong length_host = 0;
00152
00153 const char *cp_pos_overrun = ACE_OS::strchr (ior, ':');
00154 const char *cp_pos = (cp_pos_overrun < okd) ? cp_pos_overrun : 0;
00155 #if defined (ACE_HAS_IPV6)
00156
00157 bool ipv6_in_host = false;
00158
00159
00160
00161 if ((this->version().major > TAO_MIN_IPV6_IIOP_MAJOR ||
00162 this->version().minor >= TAO_MIN_IPV6_IIOP_MINOR) &&
00163 ior[0] == '[')
00164 {
00165
00166
00167 const char *cp_pos_a_overrun = ACE_OS::strchr(ior, ']');
00168 const char *cp_pos_a = (cp_pos_a_overrun < okd) ? cp_pos_a_overrun : 0;
00169 if (cp_pos_a == 0)
00170 {
00171
00172 if (TAO_debug_level > 0)
00173 {
00174 ACE_ERROR ((LM_ERROR,
00175 ACE_TEXT ("\nTAO (%P|%t) IIOP_Profile: ")
00176 ACE_TEXT ("Invalid IPv6 decimal address specified.\n")));
00177 }
00178
00179 throw ::CORBA::INV_OBJREF (
00180 CORBA::SystemException::_tao_minor_code (
00181 0,
00182 EINVAL),
00183 CORBA::COMPLETED_NO);
00184 }
00185 else
00186 {
00187 if (cp_pos_a[1] == ':')
00188 cp_pos = cp_pos_a + 1;
00189 else
00190 cp_pos = 0;
00191 ipv6_in_host = true;
00192 }
00193 }
00194 #endif
00195
00196 if (cp_pos == ior)
00197 {
00198
00199
00200 if (TAO_debug_level > 0)
00201 {
00202 ACE_ERROR ((LM_ERROR,
00203 ACE_TEXT ("\nTAO (%P|%t) IIOP_Profile: ")
00204 ACE_TEXT ("Host address may be omited only when no port has been specified.\n")));
00205 }
00206
00207 throw ::CORBA::INV_OBJREF (
00208 CORBA::SystemException::_tao_minor_code (
00209 0,
00210 EINVAL),
00211 CORBA::COMPLETED_NO);
00212 }
00213 else if (cp_pos != 0)
00214 {
00215
00216 CORBA::ULong length_port = okd - cp_pos - 1;
00217 CORBA::String_var tmp = CORBA::string_alloc (length_port);
00218
00219 if (tmp.in() != 0)
00220 {
00221 ACE_OS::strncpy (tmp.inout (), cp_pos + 1, length_port);
00222 tmp[length_port] = '\0';
00223 }
00224
00225 if (length_port == 0)
00226 {
00227 this->endpoint_.port_ = 2809;
00228
00229 }
00230 else if (tmp.in () != 0 && ACE_OS::strspn (tmp.in (), "1234567890") == length_port)
00231 {
00232 this->endpoint_.port_ =
00233 static_cast<CORBA::UShort> (ACE_OS::atoi (tmp.in ()));
00234 }
00235 else
00236 {
00237 ACE_INET_Addr ia;
00238 if (tmp.in () == 0 || ia.string_to_addr (tmp.in ()) == -1)
00239 {
00240 throw ::CORBA::INV_OBJREF (
00241 CORBA::SystemException::_tao_minor_code (
00242 0,
00243 EINVAL),
00244 CORBA::COMPLETED_NO);
00245 }
00246 else
00247 {
00248 this->endpoint_.port_ = ia.get_port_number ();
00249 }
00250 }
00251 length_host = cp_pos - ior;
00252 }
00253 else
00254 length_host = okd - ior;
00255
00256 #if defined (ACE_HAS_IPV6)
00257 if (ipv6_in_host)
00258 length_host -= 2;
00259 #endif
00260
00261 CORBA::String_var tmp = CORBA::string_alloc (length_host);
00262
00263 #if defined (ACE_HAS_IPV6)
00264 if (ipv6_in_host)
00265 ACE_OS::strncpy (tmp.inout (), ior + 1, length_host);
00266 else
00267 #endif
00268
00269 ACE_OS::strncpy (tmp.inout (), ior, length_host);
00270 tmp[length_host] = '\0';
00271
00272 this->endpoint_.host_ = tmp._retn ();
00273 #if defined (ACE_HAS_IPV6)
00274 this->endpoint_.is_ipv6_decimal_ = ipv6_in_host;
00275 #endif
00276
00277 if (ACE_OS::strcmp (this->endpoint_.host_.in (), "") == 0)
00278 {
00279 ACE_INET_Addr host_addr;
00280
00281 char tmp_host [MAXHOSTNAMELEN + 1];
00282
00283
00284
00285 if (host_addr.get_host_name (tmp_host,
00286 sizeof (tmp_host)) != 0)
00287 {
00288
00289
00290
00291 if (TAO_debug_level > 0)
00292 ACE_DEBUG ((LM_DEBUG,
00293 ACE_TEXT ("\n\nTAO (%P|%t) ")
00294 ACE_TEXT ("IIOP_Profile::parse_string ")
00295 ACE_TEXT ("- %p\n\n"),
00296 ACE_TEXT ("cannot determine hostname")));
00297
00298
00299 throw ::CORBA::INV_OBJREF (
00300 CORBA::SystemException::_tao_minor_code (
00301 0,
00302 EINVAL),
00303 CORBA::COMPLETED_NO);
00304 }
00305 else
00306 this->endpoint_.host_ = CORBA::string_dup (tmp_host);
00307 }
00308
00309 TAO::ObjectKey ok;
00310
00311 TAO::ObjectKey::decode_string_to_sequence (ok,
00312 okd + 1);
00313
00314 (void) this->orb_core ()->object_key_table ().bind (ok,
00315 this->ref_object_key_);
00316 }
00317
00318 CORBA::Boolean
00319 TAO_IIOP_Profile::do_is_equivalent (const TAO_Profile *other_profile)
00320 {
00321 if (other_profile == this)
00322 return true;
00323
00324 const TAO_IIOP_Profile *op =
00325 dynamic_cast<const TAO_IIOP_Profile *> (other_profile);
00326
00327
00328 if (op == 0)
00329 return false;
00330
00331 if (this->count_ == 0 && op->count_ == 0)
00332 return true;
00333 if (this->count_ != op->count_)
00334 return false;
00335
00336 const TAO_IIOP_Endpoint *other_endp = &op->endpoint_;
00337 for (TAO_IIOP_Endpoint *endp = &this->endpoint_;
00338 endp != 0;
00339 endp = endp->next_)
00340 {
00341 if (endp->is_equivalent (other_endp))
00342 other_endp = other_endp->next_;
00343 else
00344 return false;
00345 }
00346
00347 return true;
00348 }
00349
00350 CORBA::ULong
00351 TAO_IIOP_Profile::hash (CORBA::ULong max)
00352 {
00353
00354 CORBA::ULong hashval = 0;
00355 for (TAO_IIOP_Endpoint *endp = &this->endpoint_;
00356 endp != 0;
00357 endp = endp->next_)
00358 {
00359 hashval += endp->hash ();
00360 }
00361
00362 hashval += this->version_.minor;
00363 hashval += this->tag ();
00364
00365 const TAO::ObjectKey &ok =
00366 this->ref_object_key_->object_key ();
00367
00368 if (ok.length () >= 4)
00369 {
00370 hashval += ok[1];
00371 hashval += ok[3];
00372 }
00373
00374 hashval += TAO_Profile::hash_service_i (max);
00375
00376 return hashval % max;
00377 }
00378
00379 TAO_Endpoint*
00380 TAO_IIOP_Profile::endpoint (void)
00381 {
00382 return &this->endpoint_;
00383 }
00384
00385 TAO_Endpoint *
00386 TAO_IIOP_Profile::base_endpoint (void)
00387 {
00388
00389
00390 return &this->endpoint_;
00391 }
00392
00393 CORBA::ULong
00394 TAO_IIOP_Profile::endpoint_count (void) const
00395 {
00396 return this->count_;
00397 }
00398
00399 void
00400 TAO_IIOP_Profile::add_endpoint (TAO_IIOP_Endpoint *endp)
00401 {
00402 this->last_endpoint_->next_ = endp;
00403 this->last_endpoint_ = endp;
00404
00405 ++this->count_;
00406 }
00407
00408 void
00409 TAO_IIOP_Profile::remove_endpoint (TAO_IIOP_Endpoint *endp)
00410 {
00411 if (endp == 0)
00412 return;
00413
00414
00415 if (endp == &this->endpoint_)
00416 {
00417 if (--this->count_ > 0)
00418 {
00419 TAO_IIOP_Endpoint* n = this->endpoint_.next_;
00420 this->endpoint_ = *n;
00421
00422
00423 this->endpoint_.next_ = n->next_;
00424 if (this->last_endpoint_ == n)
00425 {
00426 this->last_endpoint_ = &this->endpoint_;
00427 }
00428 delete n;
00429 }
00430 return;
00431 }
00432
00433 TAO_IIOP_Endpoint* prev = &this->endpoint_;
00434 TAO_IIOP_Endpoint* cur = this->endpoint_.next_;
00435
00436 while (cur != 0)
00437 {
00438 if (cur == endp)
00439 break;
00440 prev = cur;
00441 cur = cur->next_;
00442 }
00443
00444 if (cur != 0)
00445 {
00446 prev->next_ = cur->next_;
00447 cur->next_ = 0;
00448 --this->count_;
00449 if (this->last_endpoint_ == cur)
00450 {
00451 this->last_endpoint_ = prev;
00452 }
00453 delete cur;
00454 }
00455 }
00456
00457 void
00458 TAO_IIOP_Profile::remove_generic_endpoint (TAO_Endpoint *ep)
00459 {
00460 this->remove_endpoint(dynamic_cast<TAO_IIOP_Endpoint *>(ep));
00461 }
00462
00463 void
00464 TAO_IIOP_Profile::add_generic_endpoint (TAO_Endpoint *endp)
00465 {
00466 TAO_IIOP_Endpoint *iep = dynamic_cast<TAO_IIOP_Endpoint *>(endp);
00467 if (iep != 0)
00468 {
00469 TAO_IIOP_Endpoint *clone;
00470 ACE_NEW (clone, TAO_IIOP_Endpoint(*iep));
00471 this->add_endpoint(clone);
00472 }
00473 }
00474
00475 char *
00476 TAO_IIOP_Profile::to_string (void)
00477 {
00478
00479
00480 CORBA::String_var key;
00481 TAO::ObjectKey::encode_sequence_to_string (key.inout(),
00482 this->ref_object_key_->object_key ());
00483
00484 size_t buflen = (
00485 8 +
00486 1 +
00487 1 +
00488 ACE_OS::strlen (key.in ()));
00489 size_t const pfx_len = (
00490 ACE_OS::strlen (::the_prefix) +
00491 1 );
00492
00493 const TAO_IIOP_Endpoint *endp = 0;
00494 for (endp = &this->endpoint_; endp != 0; endp = endp->next_)
00495 {
00496 buflen += (
00497 pfx_len +
00498 1 +
00499 1 +
00500 1 +
00501 1 +
00502 ACE_OS::strlen (endp->host ()) +
00503 1 +
00504 5 +
00505 1 );
00506 #if defined (ACE_HAS_IPV6)
00507 if (endp->is_ipv6_decimal_)
00508 buflen += 2;
00509 #endif
00510 }
00511
00512 static const char digits [] = "0123456789";
00513
00514 char * buf = CORBA::string_alloc (static_cast<CORBA::ULong> (buflen));
00515
00516 ACE_OS::strcpy(buf, "corbaloc:");
00517
00518 for (endp = &this->endpoint_; endp != 0; endp = endp->next_)
00519 {
00520 if(&this->endpoint_ != endp)
00521 ACE_OS::strcat(buf, ",");
00522
00523 #if defined (ACE_HAS_IPV6)
00524 if (endp->is_ipv6_decimal_)
00525 {
00526
00527 ACE_CString tmp(endp->host ());
00528 ACE_CString::size_type pos = tmp.find('%');
00529 if (pos != ACE_CString::npos)
00530 {
00531 tmp = tmp.substr(0, pos + 1);
00532 tmp[pos] = '\0';
00533 }
00534 ACE_OS::sprintf (buf + ACE_OS::strlen(buf),
00535 "%s:%c.%c@[%s]:%d",
00536 ::the_prefix,
00537 digits [this->version_.major],
00538 digits [this->version_.minor],
00539 tmp.c_str (),
00540 endp->port () );
00541 }
00542 else
00543 #endif
00544 ACE_OS::sprintf (buf + ACE_OS::strlen(buf),
00545 "%s:%c.%c@%s:%d",
00546 ::the_prefix,
00547 digits [this->version_.major],
00548 digits [this->version_.minor],
00549 endp->host (),
00550 endp->port () );
00551
00552 }
00553 ACE_OS::sprintf (buf + ACE_OS::strlen(buf),
00554 "%c%s",
00555 this->object_key_delimiter_,
00556 key.in ());
00557
00558 return buf;
00559 }
00560
00561 const char *
00562 TAO_IIOP_Profile::prefix (void)
00563 {
00564 return ::the_prefix;
00565 }
00566
00567 void
00568 TAO_IIOP_Profile::create_profile_body (TAO_OutputCDR &encap) const
00569 {
00570 encap.write_octet (TAO_ENCAP_BYTE_ORDER);
00571
00572
00573 encap.write_octet (this->version_.major);
00574 encap.write_octet (this->version_.minor);
00575
00576
00577 #if defined (ACE_HAS_IPV6)
00578
00579
00580 const char* host = 0;
00581 const char* pos = 0;
00582 if (this->endpoint_.is_ipv6_decimal_ &&
00583 (pos = ACE_OS::strchr (host = this->endpoint_.host (), '%')) != 0)
00584 {
00585 ACE_CString tmp;
00586 size_t len = pos - host;
00587 tmp.set (this->endpoint_.host (), len, 1);
00588 encap.write_string (tmp.c_str ());
00589 }
00590 else
00591 #endif
00592 encap.write_string (this->endpoint_.host ());
00593
00594
00595 encap.write_ushort (this->endpoint_.port ());
00596
00597
00598 if (this->ref_object_key_)
00599 encap << this->ref_object_key_->object_key ();
00600 else
00601 {
00602 ACE_ERROR ((LM_ERROR,
00603 "(%P|%t) TAO - IIOP_Profile::create_profile_body "
00604 "no object key marshalled\n"));
00605 }
00606
00607 if (this->version_.major > 1 || this->version_.minor > 0)
00608 this->tagged_components ().encode (encap);
00609 }
00610
00611 int
00612 TAO_IIOP_Profile::encode_alternate_endpoints (void)
00613 {
00614
00615
00616 const TAO_IIOP_Endpoint *endpoint = &this->endpoint_;
00617 for (CORBA::ULong i = 1;
00618 i < this->count_;
00619 ++i)
00620 {
00621
00622
00623
00624 endpoint = endpoint->next_;
00625
00626 if (!endpoint->is_encodable_)
00627 continue;
00628
00629
00630
00631
00632 TAO_OutputCDR out_cdr;
00633
00634 #if defined (ACE_HAS_IPV6)
00635
00636
00637 const char* host = 0;
00638 const char* pos = 0;
00639 if (endpoint->is_ipv6_decimal_ &&
00640 (pos = ACE_OS::strchr (host = endpoint->host (), '%')) != 0)
00641 {
00642 ACE_CString tmp;
00643 size_t len = pos - host;
00644 tmp.set (endpoint->host (), len, 1);
00645 if (!(out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))
00646 || !(out_cdr << tmp.c_str ())
00647 || !(out_cdr << endpoint->port ()))
00648 return -1;
00649 out_cdr.write_string (len, endpoint->host ());
00650 }
00651 else
00652 #endif
00653 if (!(out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))
00654 || !(out_cdr << endpoint->host ())
00655 || !(out_cdr << endpoint->port ()))
00656 return -1;
00657
00658 IOP::TaggedComponent tagged_component;
00659 tagged_component.tag = IOP::TAG_ALTERNATE_IIOP_ADDRESS;
00660
00661 size_t length = out_cdr.total_length ();
00662 tagged_component.component_data.length
00663 (static_cast<CORBA::ULong>(length));
00664 CORBA::Octet *buf =
00665 tagged_component.component_data.get_buffer ();
00666
00667 for (const ACE_Message_Block *iterator = out_cdr.begin ();
00668 iterator != 0;
00669 iterator = iterator->cont ())
00670 {
00671 size_t i_length = iterator->length ();
00672 ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);
00673
00674 buf += i_length;
00675 }
00676
00677
00678
00679 tagged_components_.set_component (tagged_component);
00680 }
00681 return 0;
00682 }
00683
00684 int
00685 TAO_IIOP_Profile::encode_endpoints (void)
00686 {
00687 CORBA::ULong actual_count = 0;
00688
00689 const TAO_IIOP_Endpoint *endpoint = &this->endpoint_;
00690
00691
00692 for (CORBA::ULong c = 0;
00693 c != this->count_;
00694 ++c)
00695 {
00696 if (endpoint->is_encodable_)
00697 ++actual_count;
00698
00699 endpoint = endpoint->next_;
00700 }
00701
00702
00703
00704
00705
00706
00707
00708
00709 TAO::IIOPEndpointSequence endpoints;
00710 endpoints.length (actual_count);
00711
00712 endpoint = &this->endpoint_;
00713
00714 for (CORBA::ULong i = 0;
00715 i < actual_count;
00716 ++i)
00717 {
00718 if (endpoint->is_encodable_)
00719 {
00720 #if defined (ACE_HAS_IPV6)
00721 if (endpoint->is_ipv6_decimal_)
00722 {
00723
00724 ACE_CString tmp(endpoint->host ());
00725 ACE_CString::size_type pos = tmp.find('%');
00726 if (pos != ACE_CString::npos)
00727 {
00728 tmp = tmp.substr (0, pos + 1);
00729 tmp[pos] = '\0';
00730 endpoints[i].host = tmp.c_str();
00731 }
00732 else
00733 endpoints[i].host = tmp.c_str();
00734 }
00735 else
00736 #endif
00737 endpoints[i].host = endpoint->host ();
00738 endpoints[i].port = endpoint->port ();
00739 endpoints[i].priority = endpoint->priority ();
00740 }
00741 endpoint = endpoint->next_;
00742 }
00743
00744
00745 TAO_OutputCDR out_cdr;
00746 if (!(out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))
00747 || !(out_cdr << endpoints))
00748 return -1;
00749
00750 this->set_tagged_components (out_cdr);
00751
00752 return 0;
00753 }
00754
00755
00756 int
00757 TAO_IIOP_Profile::decode_endpoints (void)
00758 {
00759 IOP::TaggedComponent tagged_component;
00760 tagged_component.tag = TAO_TAG_ENDPOINTS;
00761
00762 if (this->tagged_components_.get_component (tagged_component))
00763 {
00764 const CORBA::Octet *buf =
00765 tagged_component.component_data.get_buffer ();
00766
00767 TAO_InputCDR in_cdr (reinterpret_cast<const char *> (buf),
00768 tagged_component.component_data.length ());
00769
00770
00771 CORBA::Boolean byte_order;
00772 if (!(in_cdr >> ACE_InputCDR::to_boolean (byte_order)))
00773 return -1;
00774 in_cdr.reset_byte_order (static_cast<int> (byte_order));
00775
00776
00777 TAO::IIOPEndpointSequence endpoints;
00778
00779 if (!(in_cdr >> endpoints))
00780 return -1;
00781
00782
00783
00784
00785 this->endpoint_.priority (endpoints[0].priority);
00786
00787
00788
00789
00790
00791
00792
00793 for (CORBA::ULong i = endpoints.length () - 1;
00794 i > 0;
00795 --i)
00796 {
00797 TAO_IIOP_Endpoint *endpoint = 0;
00798 ACE_NEW_RETURN (endpoint,
00799 TAO_IIOP_Endpoint (endpoints[i].host,
00800 endpoints[i].port,
00801 endpoints[i].priority),
00802 -1);
00803
00804 this->add_endpoint (endpoint);
00805 }
00806 }
00807
00808
00809
00810
00811 IOP::MultipleComponentProfile& tc = this->tagged_components_.components();
00812 for (CORBA::ULong index = 0; index < tc.length(); index++)
00813 {
00814 if (tc[index].tag != IOP::TAG_ALTERNATE_IIOP_ADDRESS)
00815 continue;
00816 const CORBA::Octet *buf =
00817 tc[index].component_data.get_buffer ();
00818
00819 TAO_InputCDR in_cdr (reinterpret_cast<const char*>(buf),
00820 tc[index].component_data.length ());
00821
00822
00823 CORBA::Boolean byte_order;
00824 if (!(in_cdr >> ACE_InputCDR::to_boolean (byte_order)))
00825 return -1;
00826
00827 in_cdr.reset_byte_order (static_cast<int>(byte_order));
00828
00829 CORBA::String_var host;
00830 CORBA::Short port;
00831
00832 if (!(in_cdr >> host.out()) || !(in_cdr >> port))
00833 return -1;
00834
00835 TAO_IIOP_Endpoint *endpoint = 0;
00836 ACE_NEW_RETURN (endpoint,
00837 TAO_IIOP_Endpoint (host.in(),
00838 port,
00839 TAO_INVALID_PRIORITY),
00840 -1);
00841
00842 this->add_endpoint (endpoint);
00843 }
00844
00845 return 0;
00846 }
00847
00848
00849 TAO_END_VERSIONED_NAMESPACE_DECL
00850
00851 #endif