TAO_IIOP_Acceptor Class Reference

TAO_IIOP_Acceptor. More...

#include <IIOP_Acceptor.h>

Inheritance diagram for TAO_IIOP_Acceptor:

Inheritance graph
[legend]
Collaboration diagram for TAO_IIOP_Acceptor:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Strategy_Acceptor<
TAO_IIOP_Connection_Handler,
ACE_SOCK_ACCEPTOR
BASE_ACCEPTOR
typedef TAO_Creation_Strategy<
TAO_IIOP_Connection_Handler
CREATION_STRATEGY
typedef TAO_Concurrency_Strategy<
TAO_IIOP_Connection_Handler
CONCURRENCY_STRATEGY
typedef TAO_Accept_Strategy<
TAO_IIOP_Connection_Handler,
ACE_SOCK_ACCEPTOR
ACCEPT_STRATEGY

Public Member Functions

 TAO_IIOP_Acceptor (CORBA::Boolean flag=false)
 Constructor.

 ~TAO_IIOP_Acceptor (void)
 Destructor.

const ACE_INET_Addraddress (void) const
const ACE_INET_Addrendpoints (void)
 Returns the array of endpoints in this acceptor.

const ACE_INET_Addrdefault_address (void) const
 Returns address for default endpoint.

void set_default_address (const ACE_INET_Addr &addr)
 Set address for default endpoint.

virtual int open (TAO_ORB_Core *orb_core, ACE_Reactor *reactor, int version_major, int version_minor, const char *address, const char *options=0)
virtual int open_default (TAO_ORB_Core *orb_core, ACE_Reactor *reactor, int version_major, int version_minor, const char *options=0)
virtual int close (void)
 Closes the acceptor.

virtual int create_profile (const TAO::ObjectKey &object_key, TAO_MProfile &mprofile, CORBA::Short priority)
virtual int is_collocated (const TAO_Endpoint *endpoint)
 Return 1 if the endpoint has the same address as the acceptor.

virtual CORBA::ULong endpoint_count (void)
virtual int object_key (IOP::TaggedProfile &profile, TAO::ObjectKey &key)
virtual int hostname (TAO_ORB_Core *orb_core, ACE_INET_Addr &addr, char *&host, const char *specified_hostname=0)

Protected Member Functions

int parse_address (const char *address, ACE_INET_Addr &addr, ACE_CString &specified_hostname)
int dotted_decimal_address (ACE_INET_Addr &addr, char *&host)
virtual int open_i (const ACE_INET_Addr &addr, ACE_Reactor *reactor)
int probe_interfaces (TAO_ORB_Core *orb_core)
int parse_options (const char *options)
virtual int parse_options_i (int &argc, ACE_CString **argv)
int create_new_profile (const TAO::ObjectKey &object_key, TAO_MProfile &mprofile, CORBA::Short priority)
int create_shared_profile (const TAO::ObjectKey &object_key, TAO_MProfile &mprofile, CORBA::Short priority)

Protected Attributes

ACE_INET_Addraddrs_
unsigned short port_span_
char ** hosts_
char * hostname_in_ior_
CORBA::ULong endpoint_count_
TAO_GIOP_Message_Version version_
TAO_ORB_Coreorb_core_
 ORB Core.

const bool lite_flag_
 Should we use GIOP lite??

int reuse_addr_
 Enable socket option SO_REUSEADDR to be set.

ACE_INET_Addr default_address_
 Address for default endpoint.


Private Attributes

BASE_ACCEPTOR base_acceptor_
 The concrete acceptor, as a pointer to it's base class.

CREATION_STRATEGYcreation_strategy_
 Acceptor strategies.

CONCURRENCY_STRATEGYconcurrency_strategy_
ACCEPT_STRATEGYaccept_strategy_

Detailed Description

TAO_IIOP_Acceptor.

The IIOP-specific bridge class for the concrete acceptor.

Definition at line 48 of file IIOP_Acceptor.h.


Member Typedef Documentation

typedef TAO_Accept_Strategy<TAO_IIOP_Connection_Handler, ACE_SOCK_ACCEPTOR> TAO_IIOP_Acceptor::ACCEPT_STRATEGY
 

Definition at line 80 of file IIOP_Acceptor.h.

typedef ACE_Strategy_Acceptor<TAO_IIOP_Connection_Handler, ACE_SOCK_ACCEPTOR> TAO_IIOP_Acceptor::BASE_ACCEPTOR
 

Definition at line 77 of file IIOP_Acceptor.h.

typedef TAO_Concurrency_Strategy<TAO_IIOP_Connection_Handler> TAO_IIOP_Acceptor::CONCURRENCY_STRATEGY
 

Definition at line 79 of file IIOP_Acceptor.h.

typedef TAO_Creation_Strategy<TAO_IIOP_Connection_Handler> TAO_IIOP_Acceptor::CREATION_STRATEGY
 

Definition at line 78 of file IIOP_Acceptor.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_IIOP_Acceptor::TAO_IIOP_Acceptor CORBA::Boolean  flag = false  ) 
 

Constructor.

Definition at line 32 of file IIOP_Acceptor.cpp.

References ACE_IPV6_ANY, TAO_DEF_GIOP_MAJOR, and TAO_DEF_GIOP_MINOR.

00033   : TAO_Acceptor (IOP::TAG_INTERNET_IOP),
00034     addrs_ (0),
00035     port_span_ (1),
00036     hosts_ (0),
00037     hostname_in_ior_ (0),
00038     endpoint_count_ (0),
00039     version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR),
00040     orb_core_ (0),
00041     lite_flag_ (flag),
00042     reuse_addr_ (1),
00043 #if defined (ACE_HAS_IPV6)
00044     default_address_ (static_cast<unsigned short> (0), ACE_IPV6_ANY, AF_INET6),
00045 #else
00046     default_address_ (static_cast<unsigned short> (0), static_cast<ACE_UINT32> (INADDR_ANY)),
00047 #endif /* ACE_HAS_IPV6 */
00048     base_acceptor_ (),
00049     creation_strategy_ (0),
00050     concurrency_strategy_ (0),
00051     accept_strategy_ (0)
00052 {
00053 }

TAO_IIOP_Acceptor::~TAO_IIOP_Acceptor void   ) 
 

Destructor.

Definition at line 57 of file IIOP_Acceptor.cpp.

References addrs_, close(), endpoint_count_, hostname_in_ior_, hosts_, and CORBA::string_free().

00058 {
00059   // Make sure we are closed before we start destroying the
00060   // strategies.
00061   this->close ();
00062 
00063   delete this->creation_strategy_;
00064   delete this->concurrency_strategy_;
00065   delete this->accept_strategy_;
00066 
00067   delete [] this->addrs_;
00068 
00069   for (CORBA::ULong i = 0; i < this->endpoint_count_; ++i)
00070     CORBA::string_free (this->hosts_[i]);
00071 
00072   delete [] this->hosts_;
00073 
00074   delete [] this->hostname_in_ior_;
00075 }


Member Function Documentation

const ACE_INET_Addr& TAO_IIOP_Acceptor::address void   )  const
 

@ Helper method for the implementation repository, should go away

int TAO_IIOP_Acceptor::close void   )  [virtual]
 

Closes the acceptor.

Implements TAO_Acceptor.

Definition at line 265 of file IIOP_Acceptor.cpp.

References base_acceptor_, and ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::close().

Referenced by ~TAO_IIOP_Acceptor().

00266 {
00267   return this->base_acceptor_.close ();
00268 }

int TAO_IIOP_Acceptor::create_new_profile const TAO::ObjectKey object_key,
TAO_MProfile mprofile,
CORBA::Short  priority
[protected]
 

Helper method to add a new profile to the mprofile for each endpoint.

Definition at line 104 of file IIOP_Acceptor.cpp.

References TAO_Profile::_decr_refcnt(), ACE_NEW_RETURN, addrs_, TAO_ORB_Core::codeset_manager(), TAO_IIOP_Profile::endpoint(), endpoint_count_, ACE_INET_Addr::get_port_number(), TAO_MProfile::give_profile(), TAO_MProfile::grow(), TAO_ORB_Core::orb_params(), TAO_Endpoint::priority(), TAO_MProfile::profile_count(), TAO_Codeset_Manager::set_codeset(), TAO_Tagged_Components::set_orb_type(), TAO_MProfile::size(), TAO_ORB_Parameters::std_profile_components(), ACE_OS::strcmp(), TAO_Profile::tagged_components(), TAO_ORB_TYPE, and version_.

Referenced by create_profile().

00107 {
00108   // Adding this->endpoint_count_ to the TAO_MProfile.
00109   const int count = mprofile.profile_count ();
00110   if ((mprofile.size () - count) < this->endpoint_count_
00111       && mprofile.grow (count + this->endpoint_count_) == -1)
00112     return -1;
00113 
00114   // Create a profile for each acceptor endpoint.
00115   for (CORBA::ULong i = 0; i < this->endpoint_count_; ++i)
00116     {
00117       // Skip if the host name
00118       if (i > 0
00119           && (this->addrs_[i].get_port_number() == this->addrs_[0].get_port_number())
00120           && ACE_OS::strcmp(this->hosts_[i], this->hosts_[0]) == 0)
00121         continue;
00122 
00123       TAO_IIOP_Profile *pfile = 0;
00124       ACE_NEW_RETURN (pfile,
00125                       TAO_IIOP_Profile (this->hosts_[i],
00126                                         this->addrs_[i].get_port_number (),
00127                                         object_key,
00128                                         this->addrs_[i],
00129                                         this->version_,
00130                                         this->orb_core_),
00131                       -1);
00132       pfile->endpoint ()->priority (priority);
00133 
00134       if (mprofile.give_profile (pfile) == -1)
00135         {
00136           pfile->_decr_refcnt ();
00137           pfile = 0;
00138           return -1;
00139         }
00140 
00141       // Do not add any tagged components to the profile if configured
00142       // by the user not to do so, or if an IIOP 1.0 endpoint is being
00143       // created (IIOP 1.0 did not support tagged components).
00144       if (this->orb_core_->orb_params ()->std_profile_components () == 0
00145           || (this->version_.major == 1 && this->version_.minor == 0))
00146         continue;
00147 
00148       pfile->tagged_components ().set_orb_type (TAO_ORB_TYPE);
00149 
00150       TAO_Codeset_Manager *csm = this->orb_core_->codeset_manager();
00151       if (csm)
00152         csm->set_codeset(pfile->tagged_components());
00153     }
00154 
00155   return 0;
00156 }

int TAO_IIOP_Acceptor::create_profile const TAO::ObjectKey object_key,
TAO_MProfile mprofile,
CORBA::Short  priority
[virtual]
 

Create the corresponding profile for this endpoint. If share_profile is set to true, the pluggable protocol implementation should try to add the endpoint to a profile in the mprofile that is of the same type. Currently, this is used when RT CORBA is enabled.

Implements TAO_Acceptor.

Definition at line 82 of file IIOP_Acceptor.cpp.

References create_new_profile(), create_shared_profile(), endpoint_count_, TAO_ORB_Core::orb_params(), TAO_ORB_Parameters::shared_profile(), and TAO_INVALID_PRIORITY.

00085 {
00086   // Sanity check.
00087   if (this->endpoint_count_ == 0)
00088     return -1;
00089 
00090   // Check if multiple endpoints should be put in one profile or
00091   // if they should be spread across multiple profiles.
00092   if (priority == TAO_INVALID_PRIORITY &&
00093       this->orb_core_->orb_params ()->shared_profile () == 0)
00094     return this->create_new_profile (object_key,
00095                                      mprofile,
00096                                      priority);
00097   else
00098     return this->create_shared_profile (object_key,
00099                                         mprofile,
00100                                         priority);
00101 }

int TAO_IIOP_Acceptor::create_shared_profile const TAO::ObjectKey object_key,
TAO_MProfile mprofile,
CORBA::Short  priority
[protected]
 

Helper method to create a profile that contains all of our endpoints.

Definition at line 159 of file IIOP_Acceptor.cpp.

References TAO_Profile::_decr_refcnt(), ACE_NEW_RETURN, TAO_IIOP_Profile::add_endpoint(), addrs_, TAO_ORB_Core::codeset_manager(), TAO_IIOP_Profile::endpoint(), endpoint_count_, ACE_INET_Addr::get_port_number(), TAO_MProfile::get_profile(), TAO_MProfile::give_profile(), TAO_ORB_Core::orb_params(), TAO_Endpoint::priority(), TAO_MProfile::profile_count(), TAO_Codeset_Manager::set_codeset(), TAO_Tagged_Components::set_orb_type(), TAO_ORB_Parameters::std_profile_components(), ACE_OS::strcmp(), TAO_Profile::tag(), TAO_Profile::tagged_components(), TAO_ORB_TYPE, TAO_PHandle, and version_.

Referenced by create_profile().

00162 {
00163   CORBA::ULong index = 0;
00164   TAO_Profile *pfile = 0;
00165   TAO_IIOP_Profile *iiop_profile = 0;
00166 
00167   // First see if <mprofile> already contains a IIOP profile.
00168   for (TAO_PHandle i = 0; i != mprofile.profile_count (); ++i)
00169     {
00170       pfile = mprofile.get_profile (i);
00171       if (pfile->tag () == IOP::TAG_INTERNET_IOP)
00172         {
00173           iiop_profile = dynamic_cast<TAO_IIOP_Profile *> (pfile);
00174           break;
00175         }
00176     }
00177 
00178   // If <mprofile> doesn't contain a IIOP_Profile, we need to create
00179   // one.
00180   if (iiop_profile == 0)
00181     {
00182       ACE_NEW_RETURN (iiop_profile,
00183                       TAO_IIOP_Profile (this->hosts_[0],
00184                                         this->addrs_[0].get_port_number (),
00185                                         object_key,
00186                                         this->addrs_[0],
00187                                         this->version_,
00188                                         this->orb_core_),
00189                       -1);
00190 
00191       iiop_profile->endpoint ()->priority (priority);
00192 
00193       if (mprofile.give_profile (iiop_profile) == -1)
00194         {
00195           iiop_profile->_decr_refcnt ();
00196           iiop_profile = 0;
00197           return -1;
00198         }
00199 
00200       // Do not add any tagged components to the profile if configured
00201       // by the user not to do so, or if an IIOP 1.0 endpoint is being
00202       // created (IIOP 1.0 did not support tagged components).
00203       if (this->orb_core_->orb_params ()->std_profile_components () != 0
00204           && (this->version_.major >= 1 && this->version_.minor >= 1))
00205         {
00206           iiop_profile->tagged_components ().set_orb_type (TAO_ORB_TYPE);
00207           TAO_Codeset_Manager *csm = this->orb_core_->codeset_manager();
00208           if (csm)
00209             csm->set_codeset(iiop_profile->tagged_components());
00210         }
00211 
00212       index = 1;
00213     }
00214 
00215   // Add any remaining acceptor endpoints to the IIOP_Profile.
00216   for (;
00217        index < this->endpoint_count_;
00218        ++index)
00219     {
00220       if (index > 0 &&
00221           this->addrs_[index].get_port_number() == this->addrs_[0].get_port_number() &&
00222           ACE_OS::strcmp(this->hosts_[index], this->hosts_[0]) == 0)
00223         continue;
00224 
00225       TAO_IIOP_Endpoint *endpoint = 0;
00226       ACE_NEW_RETURN (endpoint,
00227                       TAO_IIOP_Endpoint (this->hosts_[index],
00228                                          this->addrs_[index].get_port_number (),
00229                                          this->addrs_[index]),
00230                       -1);
00231       endpoint->priority (priority);
00232       iiop_profile->add_endpoint (endpoint);
00233     }
00234 
00235   return 0;
00236 }

const ACE_INET_Addr& TAO_IIOP_Acceptor::default_address void   )  const
 

Returns address for default endpoint.

Referenced by TAO_Acceptor_Registry::open_default(), and TAO_Acceptor_Registry::open_i().

int TAO_IIOP_Acceptor::dotted_decimal_address ACE_INET_Addr addr,
char *&  host
[protected]
 

Set the host name for the given address using the dotted decimal format.

Definition at line 766 of file IIOP_Acceptor.cpp.

References ACE_ERROR, ACE_TEXT, ACE_INET_Addr::get_host_addr(), ACE_INET_Addr::get_host_name(), ACE_INET_Addr::get_port_number(), ACE_Addr::get_type(), ACE_INET_Addr::is_any(), LM_ERROR, ACE_INET_Addr::set(), CORBA::string_dup(), and TAO_debug_level.

Referenced by hostname().

00768 {
00769   int result = 0;
00770   const char *tmp = 0;
00771 
00772   // If the IP address in the INET_Addr is the IN(6)ADDR_ANY address,
00773   // then force the actual IP address to be used by initializing a new
00774   // INET_Addr with the hostname from the original one.  If that fails
00775   // then something is seriously wrong with the systems networking
00776   // setup.
00777   if (addr.is_any ())
00778     {
00779       ACE_INET_Addr new_addr;
00780 #if defined (ACE_HAS_IPV6)
00781       result = new_addr.set (addr.get_port_number (),
00782                              addr.get_host_name (),
00783                              1, /* encode */
00784                              addr.get_type ());
00785 #else /* ACE_HAS_IPV6 */
00786       result = new_addr.set (addr.get_port_number (),
00787                              addr.get_host_name ());
00788 #endif /* !ACE_HAS_IPV6 */
00789       tmp = new_addr.get_host_addr ();
00790     }
00791   else
00792     tmp = addr.get_host_addr ();
00793 
00794   if (tmp == 0 || result != 0)
00795     {
00796       if (TAO_debug_level > 0)
00797         ACE_ERROR ((LM_ERROR,
00798                     ACE_TEXT ("TAO (%P|%t) - ")
00799                     ACE_TEXT ("IIOP_Acceptor::dotted_decimal_address, ")
00800                     ACE_TEXT ("- %p, "),
00801                     ACE_TEXT ("cannot determine hostname\n")));
00802       return -1;
00803     }
00804 
00805   host = CORBA::string_dup (tmp);
00806   return 0;
00807 }

CORBA::ULong TAO_IIOP_Acceptor::endpoint_count void   )  [virtual]
 

Returns the number of endpoints this acceptor is listening on. This is used for determining how many profiles will be generated for this acceptor.

Implements TAO_Acceptor.

Definition at line 996 of file IIOP_Acceptor.cpp.

References endpoint_count_.

Referenced by TAO_IIOP_Transport::get_listen_point().

00997 {
00998   return this->endpoint_count_;
00999 }

const ACE_INET_Addr* TAO_IIOP_Acceptor::endpoints void   ) 
 

Returns the array of endpoints in this acceptor.

Referenced by TAO_IIOP_Transport::get_listen_point().

int TAO_IIOP_Acceptor::hostname TAO_ORB_Core orb_core,
ACE_INET_Addr addr,
char *&  host,
const char *  specified_hostname = 0
[virtual]
 

Set the host name for the given addr. A hostname may be forced by using specified_hostname. This is useful if the given address corresponds to more than one hostname and the desired one cannot be determined in any other way. This method is used both when constructing IOR endpoints and LPL (listen point lists).

The algorithm used is:

  • If hostname_in_ior_ has been set, it is used "as is";
  • else if use_dotted_decimal_addresses_ is set, the text representaion of the IP is used;
  • else if specified_hostname is given, it used "as is";
  • else a reverse (address to name) lookup is used to obtain the hostname or the IP if no reverse mapping exists.

Definition at line 590 of file IIOP_Acceptor.cpp.

References ACE_DEBUG, ACE_TEXT, dotted_decimal_address(), ACE_INET_Addr::get_host_name(), hostname_in_ior_, ACE_INET_Addr::is_ipv4_compat_ipv6(), LM_DEBUG, MAXHOSTNAMELEN, TAO_ORB_Core::orb_params(), CORBA::string_dup(), TAO_debug_level, and TAO_ORB_Parameters::use_dotted_decimal_addresses().

Referenced by TAO_IIOP_Transport::get_listen_point(), open(), and probe_interfaces().

00594 {
00595   if (this->hostname_in_ior_ != 0)
00596     {
00597       if (TAO_debug_level >= 5)
00598           ACE_DEBUG ((LM_DEBUG,
00599                       ACE_TEXT ("TAO (%P|%t) IIOP_Acceptor - ")
00600                       ACE_TEXT ("Overriding the hostname with <%s>\n"),
00601                       this->hostname_in_ior_));
00602 
00603       host = CORBA::string_dup (this->hostname_in_ior_);
00604     }
00605   else if (orb_core->orb_params ()->use_dotted_decimal_addresses ())
00606     {
00607       // If dotted decimal addresses are enabled,
00608       // just return ours.
00609       return this->dotted_decimal_address (addr, host);
00610     }
00611   else if (specified_hostname != 0)
00612     {
00613       // If the user specified a hostname, pass it back
00614       // blindly as it overrides our choice of hostname.
00615       host = CORBA::string_dup (specified_hostname);
00616     }
00617   else
00618     {
00619       char tmp_host[MAXHOSTNAMELEN + 1];
00620 
00621       // Get the hostname associated with our address
00622 #if defined (ACE_HAS_IPV6)
00623       // If we have a IPv4-compatible IPv6 address don't do hostname lookup
00624       // because that gets us into trouble. Most likely we get the same hostname
00625       // returned as for the actual IPv4 address but resolving that into an IPv6
00626       // address at the client will fail.
00627       if (addr.is_ipv4_compat_ipv6 () ||
00628           addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0)
00629 #else /* ACE_HAS_IPV6 */
00630       if (addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0)
00631 #endif /* !ACE_HAS_IPV6 */
00632         {
00633           // On failure, just return the decimal address.
00634           return this->dotted_decimal_address (addr, host);
00635         }
00636       else
00637         {
00638           host = CORBA::string_dup (tmp_host);
00639         }
00640     }
00641 
00642   return 0;
00643 }

int TAO_IIOP_Acceptor::is_collocated const TAO_Endpoint endpoint  )  [virtual]
 

Return 1 if the endpoint has the same address as the acceptor.

Implements TAO_Acceptor.

Definition at line 239 of file IIOP_Acceptor.cpp.

References addrs_, endpoint_count_, ACE_INET_Addr::get_port_number(), TAO_IIOP_Endpoint::host(), hosts_, TAO_IIOP_Endpoint::port(), and ACE_OS::strcmp().

00240 {
00241   const TAO_IIOP_Endpoint *endp =
00242     dynamic_cast<const TAO_IIOP_Endpoint *> (endpoint);
00243 
00244   // Make sure the dynamically cast pointer is valid.
00245   if (endp == 0)
00246     return 0;
00247 
00248   for (CORBA::ULong i = 0; i < this->endpoint_count_; ++i)
00249     {
00250       // compare the port and host name.  Please do *NOT* optimize
00251       // this code by comparing the IP address instead.  That would
00252       // trigger the following bug:
00253       //
00254       // http://deuce.doc.wustl.edu/bugzilla/show_bug.cgi?id=1220
00255       //
00256       if (endp->port() == this->addrs_[i].get_port_number()
00257           && ACE_OS::strcmp(endp->host(), this->hosts_[i]) == 0)
00258         return 1;
00259     }
00260 
00261   return 0;
00262 }

int TAO_IIOP_Acceptor::object_key IOP::TaggedProfile profile,
TAO::ObjectKey key
[virtual]
 

This method fetches the key from the profile. Protocols that are pluggable can send data that are specific in the profile_data field encapsulated as a octet stream. This method allows those protocols to get the object key from the encapsulation.

Implements TAO_Acceptor.

Definition at line 1002 of file IIOP_Acceptor.cpp.

References ACE_DEBUG, ACE_TEXT, TAO::unbounded_value_sequence< T >::get_buffer(), TAO::unbounded_value_sequence< T >::length(), LM_DEBUG, CORBA::Octet, TAO::String_var< charT >::out(), IOP::TaggedProfile::profile_data, ACE_InputCDR::read_octet(), ACE_InputCDR::read_string(), ACE_InputCDR::read_ushort(), CORBA::String_var, and TAO_debug_level.

01004 {
01005   // Create the decoding stream from the encapsulation in the buffer,
01006 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
01007   TAO_InputCDR cdr (profile.profile_data.mb ());
01008 #else
01009   TAO_InputCDR cdr (reinterpret_cast<char*> (profile.profile_data.get_buffer ()),
01010                     profile.profile_data.length ());
01011 #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
01012 
01013   CORBA::Octet major;
01014   CORBA::Octet minor = CORBA::Octet();
01015 
01016   // Read the version. We just read it here. We don't*do any*
01017   // processing.
01018   if (!(cdr.read_octet (major)
01019         && cdr.read_octet (minor)))
01020     {
01021       if (TAO_debug_level > 0)
01022         {
01023           ACE_DEBUG ((LM_DEBUG,
01024                       ACE_TEXT ("TAO (%P|%t) - TAO_IIOP_Acceptor::object_key, v%d.%d\n"),
01025                       major,
01026                       minor));
01027         }
01028       return -1;
01029     }
01030 
01031   CORBA::String_var host;
01032   CORBA::UShort port = 0;
01033 
01034   // Get host and port. No processing here too..
01035   if (cdr.read_string (host.out ()) == 0
01036       || cdr.read_ushort (port) == 0)
01037     {
01038       if (TAO_debug_level > 0)
01039         {
01040           ACE_DEBUG ((LM_DEBUG,
01041                       ACE_TEXT ("TAO (%P|%t) - TAO_IIOP_Acceptor::object_key, ")
01042                       ACE_TEXT ("error while decoding host/port\n")));
01043         }
01044       return -1;
01045     }
01046 
01047   // ... and object key.
01048   if ((cdr >> object_key) == 0)
01049     return -1;
01050 
01051   // We are NOT bothered about the rest.
01052 
01053   return 1;
01054 }

int TAO_IIOP_Acceptor::open TAO_ORB_Core orb_core,
ACE_Reactor reactor,
int  version_major,
int  version_minor,
const char *  address,
const char *  options = 0
[virtual]
 

The TAO_Acceptor methods, check the documentation in Transport_Acceptor.h for details.

Implements TAO_Acceptor.

Definition at line 271 of file IIOP_Acceptor.cpp.

References ACE_CString, ACE_DEBUG, ACE_ERROR_RETURN, ACE_NEW_RETURN, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, addrs_, TAO_ORB_Parameters::connect_ipv6_only(), endpoint_count_, ACE_INET_Addr::get_port_number(), ACE_Addr::get_type(), hostname(), hostname_in_ior_, hosts_, ACE_INET_Addr::is_ipv4_mapped_ipv6(), LM_DEBUG, LM_ERROR, open_i(), TAO_ORB_Core::orb_params(), parse_address(), parse_options(), probe_interfaces(), ACE_INET_Addr::set(), TAO_GIOP_Message_Version::set_version(), TAO_debug_level, and version_.

00277 {
00278   if (TAO_debug_level > 2)
00279     {
00280       ACE_DEBUG ((LM_DEBUG,
00281                   ACE_TEXT ("TAO (%P|%t) - ")
00282                   ACE_TEXT ("IIOP_Acceptor::open, address==%s, options=%s\n"),
00283                   address, options));
00284     }
00285 
00286   this->orb_core_ = orb_core;
00287 
00288   if (this->hosts_ != 0)
00289     {
00290       // The hostname cache has already been set!
00291       // This is bad mojo, i.e. an internal TAO error.
00292       ACE_ERROR_RETURN ((LM_ERROR,
00293                          ACE_TEXT ("TAO (%P|%t) - ")
00294                          ACE_TEXT ("IIOP_Acceptor::open, ")
00295                          ACE_TEXT ("hostname already set\n\n")),
00296                         -1);
00297     }
00298 
00299   if (address == 0)
00300     return -1;
00301 
00302   if (major >=0 && minor >= 0)
00303     this->version_.set_version (static_cast<CORBA::Octet> (major),
00304                                 static_cast<CORBA::Octet> (minor));
00305   // Parse options
00306   if (this->parse_options (options) == -1)
00307     return -1;
00308 
00309   ACE_CString specified_hostname;
00310   ACE_INET_Addr addr;
00311 
00312   if (this->parse_address (address, addr, specified_hostname) == -1)
00313     return -1;
00314 
00315   if (specified_hostname.length() == 0)
00316     {
00317       // The address is a port number or port name.  No hostname was
00318       // specified.  The hostname for each network interface and the
00319       // fully qualified domain name must be obtained.
00320 
00321       // Check for multiple network interfaces.
00322       if (this->probe_interfaces (orb_core) == -1)
00323         return -1;
00324 
00325       return this->open_i (addr, reactor);
00326     }
00327 
00328 #if defined (ACE_HAS_IPV6)
00329   // Check for violation of ORBConnectIPV6Only option
00330   if (this->orb_core_->orb_params ()->connect_ipv6_only () &&
00331       (addr.get_type () != AF_INET6 ||
00332        addr.is_ipv4_mapped_ipv6 ()))
00333     {
00334       ACE_ERROR_RETURN ((LM_ERROR,
00335                          ACE_TEXT ("TAO (%P|%t) - ")
00336                          ACE_TEXT ("IIOP_Acceptor::open, ")
00337                          ACE_TEXT ("non-IPv6 endpoints not allowed when ")
00338                          ACE_TEXT ("connect_ipv6_only is set\n\n")),
00339                         -1);
00340     }
00341 #endif /* ACE_HAS_IPV6 */
00342 
00343   if (TAO_debug_level > 2)
00344     {
00345       ACE_DEBUG ((LM_DEBUG,
00346                   ACE_TEXT ("TAO (%P|%t) - ")
00347                   ACE_TEXT ("IIOP_Acceptor::open, specified host=%s:%d\n"),
00348                   (specified_hostname.length() == 0 ? "<null>" : specified_hostname.c_str()),
00349                   addr.get_port_number ()));
00350     }
00351 
00352   this->endpoint_count_ = 1;  // Only one hostname to store
00353 
00354   ACE_NEW_RETURN (this->addrs_,
00355                   ACE_INET_Addr[this->endpoint_count_],
00356                   -1);
00357 
00358   ACE_NEW_RETURN (this->hosts_,
00359                   char *[this->endpoint_count_],
00360                   -1);
00361 
00362   this->hosts_[0] = 0;
00363 
00364   if (this->hostname_in_ior_ != 0)
00365     {
00366       if (TAO_debug_level > 2)
00367         {
00368           ACE_DEBUG ((LM_DEBUG,
00369                       ACE_TEXT ("TAO (%P|%t) - ")
00370                       ACE_TEXT ("IIOP_Acceptor::open, ")
00371                       ACE_TEXT ("Overriding address in IOR with %s\n"),
00372                       ACE_TEXT_CHAR_TO_TCHAR (this->hostname_in_ior_)));
00373         }
00374       specified_hostname = this->hostname_in_ior_;
00375     }
00376 
00377   if (this->hostname (orb_core,
00378                       addr,
00379                       this->hosts_[0],
00380                       specified_hostname.c_str()) != 0)
00381     return -1;
00382 
00383   // Copy the addr.  The port is (re)set in
00384   // TAO_IIOP_Acceptor::open_i().
00385   if (this->addrs_[0].set (addr) != 0)
00386     return -1;
00387 
00388   return this->open_i (addr,
00389                        reactor);
00390 }

int TAO_IIOP_Acceptor::open_default TAO_ORB_Core orb_core,
ACE_Reactor reactor,
int  version_major,
int  version_minor,
const char *  options = 0
[virtual]
 

Open an acceptor with the given protocol version on a default endpoint

Implements TAO_Acceptor.

Definition at line 393 of file IIOP_Acceptor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT, hosts_, LM_ERROR, open_i(), parse_options(), probe_interfaces(), ACE_INET_Addr::set(), TAO_GIOP_Message_Version::set_version(), and version_.

00398 {
00399   this->orb_core_ = orb_core;
00400 
00401   if (this->hosts_ != 0)
00402     {
00403       // The hostname cache has already been set!
00404       // This is bad mojo, i.e. an internal TAO error.
00405       ACE_ERROR_RETURN ((LM_ERROR,
00406                          ACE_TEXT ("TAO (%P|%t) - ")
00407                          ACE_TEXT ("IIOP_Acceptor::open_default, ")
00408                          ACE_TEXT ("hostname already set\n\n")),
00409                         -1);
00410     }
00411 
00412   if (major >= 0 && minor >= 0)
00413     this->version_.set_version (static_cast<CORBA::Octet> (major),
00414                                 static_cast<CORBA::Octet> (minor));
00415 
00416   // Parse options
00417   if (this->parse_options (options) == -1)
00418     return -1;
00419 
00420   // Check for multiple network interfaces.
00421   if (this->probe_interfaces (orb_core) == -1)
00422     return -1;
00423 
00424   // Now that each network interface's hostname has been cached, open
00425   // an endpoint on each network interface using the INADDR_ANY
00426   // address.
00427   ACE_INET_Addr addr;
00428 
00429   if (addr.set (this->default_address_) != 0)
00430     return -1;
00431 
00432   return this->open_i (addr,
00433                        reactor);
00434 }

int TAO_IIOP_Acceptor::open_i const ACE_INET_Addr addr,
ACE_Reactor reactor
[protected, virtual]
 

Implement the common part of the open*() methods. This method is virtual to allow a derived class implementation to be invoked instead.

Definition at line 437 of file IIOP_Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::acceptor(), ACE_CLOEXEC, ACE_DEBUG, ACE_ERROR, ACE_MAX_DEFAULT_PORT, ACE_NEW_RETURN, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, addrs_, base_acceptor_, TAO_ORB_Parameters::connect_ipv6_only(), default_address_, endpoint_count_, ACE_INET_Addr::get_port_number(), ACE_INET_Addr::is_any(), LM_DEBUG, LM_ERROR, ACE_Strategy_Acceptor< SVC_HANDLER, >::open(), TAO_ORB_Core::orb_params(), port_span_, ACE_INET_Addr::set_port_number(), and TAO_debug_level.

Referenced by open(), and open_default().

00439 {
00440   ACE_NEW_RETURN (this->creation_strategy_,
00441                   CREATION_STRATEGY (this->orb_core_,
00442                                      this->lite_flag_),
00443                   -1);
00444 
00445   ACE_NEW_RETURN (this->concurrency_strategy_,
00446                   CONCURRENCY_STRATEGY (this->orb_core_),
00447                   -1);
00448 
00449   ACE_NEW_RETURN (this->accept_strategy_,
00450                   ACCEPT_STRATEGY (this->orb_core_),
00451                   -1);
00452 
00453   unsigned short requested_port = addr.get_port_number ();
00454   if (requested_port == 0)
00455     {
00456       // don't care, i.e., let the OS choose an ephemeral port
00457       if (this->base_acceptor_.open (addr,
00458                                      reactor,
00459                                      this->creation_strategy_,
00460                                      this->accept_strategy_,
00461                                      this->concurrency_strategy_,
00462                                      0, 0, 0, 1,
00463                                      this->reuse_addr_) == -1)
00464         {
00465           if (TAO_debug_level > 0)
00466             ACE_DEBUG ((LM_DEBUG,
00467                         ACE_TEXT ("TAO (%P|%t) - IIOP_Acceptor::open_i, ")
00468                         ACE_TEXT ("%p, "),
00469                         ACE_TEXT ("cannot open acceptor\n")));
00470           return -1;
00471         }
00472     }
00473   else
00474     {
00475       ACE_INET_Addr a(addr);
00476 
00477       bool found_a_port = false;
00478       ACE_UINT32 last_port = requested_port + this->port_span_ - 1;
00479       if (last_port > ACE_MAX_DEFAULT_PORT)
00480         {
00481           last_port = ACE_MAX_DEFAULT_PORT;
00482         }
00483 
00484       for (ACE_UINT32 p = requested_port; p <= last_port; p++)
00485         {
00486           if (TAO_debug_level > 5)
00487             ACE_DEBUG ((LM_DEBUG,
00488                         ACE_TEXT ("TAO (%P|%t) - IIOP_Acceptor::open_i, ")
00489                         ACE_TEXT ("trying to listen on port %d\n"), p));
00490 
00491           // Now try to actually open on that port
00492           a.set_port_number ((u_short)p);
00493           if (this->base_acceptor_.open (a,
00494                                          reactor,
00495                                          this->creation_strategy_,
00496                                          this->accept_strategy_,
00497                                          this->concurrency_strategy_,
00498                                          0, 0, 0, 1,
00499                                          this->reuse_addr_) != -1)
00500             {
00501               found_a_port = true;
00502               break;
00503             }
00504         }
00505 
00506       // Now, if we couldn't locate a port, we punt
00507       if (! found_a_port)
00508         {
00509           if (TAO_debug_level > 0)
00510             ACE_DEBUG ((LM_DEBUG,
00511                         ACE_TEXT ("TAO (%P|%t) - IIOP_Acceptor::open_i, ")
00512                         ACE_TEXT ("cannot open acceptor in port range (%d,%d)")
00513                         ACE_TEXT ("- %p\n"),
00514                         requested_port, last_port, ACE_TEXT("")));
00515           return -1;
00516         }
00517     }
00518 
00519 #if defined (ACE_HAS_IPV6) && defined (ACE_HAS_IPV6_V6ONLY)
00520   // Check if need to prevent this acceptor from accepting connections
00521   // from IPv4 mapped IPv6 addresses
00522   if (this->orb_core_->orb_params ()->connect_ipv6_only () &&
00523       addr.is_any ())
00524   {
00525     if (TAO_debug_level > 5)
00526       ACE_DEBUG ((LM_DEBUG,
00527                   ACE_TEXT("TAO (%P|%t) - IIOP_Acceptor::open_i, ")
00528                   ACE_TEXT("setting IPV6_V6ONLY\n")));
00529 
00530     // Prevent server from accepting connections from IPv4-mapped addresses.
00531     int on = 1;
00532     if (this->base_acceptor_.acceptor ().set_option (IPPROTO_IPV6,
00533                                                      IPV6_V6ONLY,
00534                                                      (void *) &on,
00535                                                      sizeof (on)) == -1)
00536       {
00537         ACE_ERROR ((LM_ERROR,
00538                     ACE_TEXT ("TAO (%P|%t) - IIOP_Acceptor::open_i, ")
00539                     ACE_TEXT ("%p\n"),
00540                     ACE_TEXT ("cannot set IPV6_V6ONLY")));
00541       }
00542   }
00543 #endif /* ACE_HAS_IPV6 && ACE_HAS_IPV6_V6ONLY */
00544 
00545   ACE_INET_Addr address;
00546 
00547   // We do this make sure the port number the endpoint is listening on
00548   // gets set in the addr.
00549   if (this->base_acceptor_.acceptor ().get_local_addr (address) != 0)
00550     {
00551       if (TAO_debug_level > 0)
00552         ACE_ERROR ((LM_ERROR,
00553                     ACE_TEXT ("TAO (%P|%t) - IIOP_Acceptor::open_i, ")
00554                     ACE_TEXT ("%p"),
00555                     ACE_TEXT ("cannot get local addr\n")));
00556       return -1;
00557     }
00558 
00559   // Set the port for each addr.  If there is more than one network
00560   // interface then the endpoint created on each interface will be on
00561   // the same port.  This is how a wildcard socket bind() is supposed
00562   // to work.
00563   unsigned short port = address.get_port_number ();
00564   for (CORBA::ULong j = 0; j < this->endpoint_count_; ++j)
00565     this->addrs_[j].set_port_number (port, 1);
00566 
00567   this->default_address_.set_port_number (port);
00568 
00569   (void) this->base_acceptor_.acceptor().enable (ACE_CLOEXEC);
00570   // This avoids having child processes acquire the listen socket thereby
00571   // denying the server the opportunity to restart on a well-known endpoint.
00572   // This does not affect the aberrent behavior on Win32 platforms.
00573 
00574   if (TAO_debug_level > 5)
00575     {
00576       for (CORBA::ULong i = 0; i < this->endpoint_count_; ++i)
00577         {
00578           ACE_DEBUG ((LM_DEBUG,
00579                       ACE_TEXT ("TAO (%P|%t) - IIOP_Acceptor::open_i, ")
00580                       ACE_TEXT ("listening on: <%s:%u>\n"),
00581                       ACE_TEXT_CHAR_TO_TCHAR(this->hosts_[i]),
00582                       this->addrs_[i].get_port_number ()));
00583         }
00584     }
00585 
00586   return 0;
00587 }

int TAO_IIOP_Acceptor::parse_address const char *  address,
ACE_INET_Addr addr,
ACE_CString specified_hostname
[protected]
 

Helper method Clear out 'addr' & 'specified_hostname' and initialize them based upon 'address'.

Definition at line 647 of file IIOP_Acceptor.cpp.

References ACE_ERROR_RETURN, ACE_TEXT, ACE_OS::atoi(), default_address_, ACE_INET_Addr::get_port_number(), LM_ERROR, TAO_GIOP_Message_Version::major, MAXHOSTNAMELEN, ACE_OS::memcpy(), TAO_GIOP_Message_Version::minor, ACE_INET_Addr::set(), ACE_INET_Addr::set_port_number(), ACE_OS::strchr(), TAO_MIN_IPV6_IIOP_MAJOR, TAO_MIN_IPV6_IIOP_MINOR, and version_.

Referenced by open().

00650 {
00651   {
00652     ACE_INET_Addr tmp;
00653     addr.set (tmp);
00654     specified_hostname.clear();
00655   }
00656 
00657   const char *port_separator_loc = ACE_OS::strchr (address, ':');
00658   char tmp_host[MAXHOSTNAMELEN + 1];
00659 
00660 #if defined (ACE_HAS_IPV6)
00661   // IPv6 numeric address in host string?
00662   bool ipv6_in_host = false;
00663 
00664 
00665   // Check if this is a (possibly) IPv6 supporting profile containing a
00666   // numeric IPv6 address representation.
00667   if ((this->version_.major > TAO_MIN_IPV6_IIOP_MAJOR ||
00668         this->version_.minor >= TAO_MIN_IPV6_IIOP_MINOR) &&
00669       address[0] == '[')
00670     {
00671       // In this case we have to find the end of the numeric address and
00672       // start looking for the port separator from there.
00673       const char *cp_pos = ACE_OS::strchr(address, ']');
00674       if (cp_pos == 0)
00675         {
00676           // No valid IPv6 address specified.
00677           ACE_ERROR_RETURN ((LM_ERROR,
00678                              ACE_TEXT ("TAO (%P|%t) - ")
00679                              ACE_TEXT ("IIOP_Acceptor::open, ")
00680                              ACE_TEXT ("Invalid IPv6 decimal address specified\n\n")),
00681                             -1);
00682         }
00683       else
00684         {
00685           if (cp_pos[1] == ':')    // Look for a port
00686             port_separator_loc = cp_pos + 1;
00687           else
00688             port_separator_loc = 0;
00689           // Extract out just the host part of the address.
00690           const size_t len = cp_pos - (address + 1);
00691           ACE_OS::memcpy (tmp_host, address + 1, len);
00692           tmp_host[len] = '\0';
00693           ipv6_in_host = true; // host string contains full IPv6 numeric address
00694         }
00695     }
00696 #endif /* ACE_HAS_IPV6 */
00697 
00698   if (port_separator_loc == address)
00699     {
00700       // First convert the port into a usable form.
00701       if (addr.set (address + sizeof (':')) != 0)
00702         return -1;
00703 
00704       this->default_address_.set_port_number (addr.get_port_number ());
00705 
00706       // Now reset the port and set the host.
00707       if (addr.set (this->default_address_) != 0)
00708         return -1;
00709     }
00710   else if (port_separator_loc == 0)
00711     {
00712       // The address is a hostname.  No port was specified, so assume
00713       // port zero (port will be chosen for us).
00714 #if defined (ACE_HAS_IPV6)
00715       if (ipv6_in_host)
00716         {
00717           if (addr.set ((unsigned short) 0, tmp_host) != 0)
00718             return -1;
00719 
00720           specified_hostname = tmp_host;
00721         }
00722       else
00723       {
00724 #endif /* ACE_HAS_IPV6 */
00725         if (addr.set ((unsigned short) 0, address) != 0)
00726           return -1;
00727 
00728         specified_hostname = address;
00729 #if defined (ACE_HAS_IPV6)
00730       }
00731 #endif /* ACE_HAS_IPV6 */
00732     }
00733   else
00734     {
00735       // Host and port were specified.
00736 #if defined (ACE_HAS_IPV6)
00737       if (ipv6_in_host)
00738         {
00739           u_short port =
00740             static_cast<u_short> (ACE_OS::atoi (port_separator_loc + sizeof (':')));
00741 
00742           if (addr.set (port, tmp_host) != 0)
00743             return -1;
00744         }
00745       else
00746         {
00747 #endif /* ACE_HAS_IPV6 */
00748           if (addr.set (address) != 0)
00749             return -1;
00750 
00751           // Extract out just the host part of the address.
00752           const size_t len = port_separator_loc - address;
00753           ACE_OS::memcpy (tmp_host, address, len);
00754           tmp_host[len] = '\0';
00755 #if defined (ACE_HAS_IPV6)
00756         }
00757 #endif /* ACE_HAS_IPV6 */
00758       specified_hostname = tmp_host;
00759     }
00760 
00761   return 1;
00762 }

int TAO_IIOP_Acceptor::parse_options const char *  options  )  [protected]
 

Parse protocol specific options.

Currently supported: portspan -- specifies the range of ports over which the acceptor should scan looking for a free port (this is convenient for situations where you might normally use an ephemeral port but can't because you're behind a firewall and don't want to permit passage on all ephemeral ports)

Definition at line 1057 of file IIOP_Acceptor.cpp.

References ACE_CString, ACE_ERROR, ACE_NEW_RETURN, ACE_TEXT, LM_ERROR, parse_options_i(), and ssize_t.

Referenced by open(), and open_default().

01058 {
01059   if (str == 0)
01060     return 0;  // No options to parse.  Not a problem.
01061 
01062   // Use an option format similar to the one used for CGI scripts in
01063   // HTTP URLs.
01064   // e.g.:  option1=foo&option2=bar
01065 
01066   const ACE_CString options (str);
01067 
01068   const size_t len = options.length ();
01069 
01070   static const char option_delimiter = '&';
01071 
01072   // Count the number of options.
01073   int argc = 1;
01074 
01075   for (size_t i = 0; i < len; ++i)
01076     if (options[i] == option_delimiter)
01077       argc++;
01078 
01079   // The idea behind the following loop is to split the options into
01080   // (option, name) pairs.
01081   // For example,
01082   //    `option1=foo&option2=bar'
01083   // will be parsed into:
01084   //    `option1=foo'
01085   //    `option2=bar'
01086 
01087   ACE_CString *argv_base = 0;
01088   ACE_NEW_RETURN (argv_base, ACE_CString[argc],-1);
01089   ACE_CString **argv = 0;
01090   ACE_NEW_RETURN (argv, ACE_CString*[argc],-1);
01091 
01092   ssize_t begin = 0;
01093   ssize_t end = -1;
01094   int result = 0;
01095   for (int j = 0; j < argc; ++j)
01096     {
01097       begin = end + 1;
01098 
01099       if (j < argc - 1)
01100         end = options.find (option_delimiter, begin);
01101       else
01102         end = static_cast<ssize_t> (len);
01103 
01104       if (end == begin)
01105         {
01106           ACE_ERROR ((LM_ERROR,
01107                       ACE_TEXT ("TAO (%P|%t) - Zero length IIOP option.\n")));
01108           result = -1;
01109           break;
01110         }
01111       else if (end != ACE_CString::npos)
01112         {
01113           argv_base[j] = options.substring (begin, end);
01114           argv[j] = &argv_base[j];
01115         }
01116     }
01117 
01118   if (result == 0)
01119     result = this->parse_options_i (argc,argv);
01120 
01121   if (argc > 0)
01122     {
01123       ACE_ERROR ((LM_ERROR,
01124                   ACE_TEXT ("TAO (%P|%t) - IIOP")
01125                   ACE_TEXT (" endpoint has %d unknown options:\n"),
01126                   argc));
01127       for (int i = 0; i < argc; i++)
01128         ACE_ERROR ((LM_ERROR,
01129                     ACE_TEXT("\t%s\n"),
01130                     argv[i]->c_str()));
01131       result = -1;
01132     }
01133   delete [] argv;
01134   delete [] argv_base;
01135   return result;
01136 }

int TAO_IIOP_Acceptor::parse_options_i int &  argc,
ACE_CString **  argv
[protected, virtual]
 

Parse options splits the options list in to an argv array. This allows manipulation of the list in a manner similar to orb_init. By moving the consumed args to the tail of the list and reducing the argc count, the base parse_options_i can be called by derived parse_options_i. Method returns -1 if an ill-formed or otherwise bogus arg is encountered. The only strictly bogus arg was priority, which was a holdover from the early RT IIOP implementations. an ill-formed option is one which is missing an equal sign or something to the left of it.

Definition at line 1139 of file IIOP_Acceptor.cpp.

References ACE_CString, ACE_ERROR_RETURN, ACE_MAX_DEFAULT_PORT, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_OS::atoi(), hostname_in_ior_, LM_ERROR, port_span_, and ssize_t.

Referenced by parse_options().

01141 {
01142   int i = 0;
01143   while (i < argc)
01144     {
01145       size_t len = argv[i]->length();
01146       ssize_t slot = argv[i]->find ("=");
01147 
01148       if (slot == static_cast <ssize_t> (len - 1)
01149           || slot == ACE_CString::npos)
01150         ACE_ERROR_RETURN ((LM_ERROR,
01151                            ACE_TEXT ("TAO (%P|%t) - IIOP option <%s> is ")
01152                            ACE_TEXT ("missing a value.\n"),
01153                            ACE_TEXT_CHAR_TO_TCHAR(argv[i]->c_str ())),
01154                           -1);
01155 
01156       ACE_CString name = argv[i]->substring (0, slot);
01157       ACE_CString value = argv[i]->substring (slot + 1);
01158 
01159       if (name.length () == 0)
01160         ACE_ERROR_RETURN ((LM_ERROR,
01161                            ACE_TEXT ("TAO (%P|%t) Zero length IIOP ")
01162                            ACE_TEXT ("option name.\n")),
01163                           -1);
01164       if (name == "priority")
01165         {
01166           ACE_ERROR_RETURN ((LM_ERROR,
01167                              ACE_TEXT ("TAO (%P|%t) Invalid IIOP endpoint format: ")
01168                              ACE_TEXT ("endpoint priorities no longer supported. \n"),
01169                              value.c_str ()),
01170                             -1);
01171         }
01172       else if (name == "portspan")
01173         {
01174           int range = static_cast <int> (ACE_OS::atoi (value.c_str ()));
01175           // @@ What's the lower bound on the range?  zero, or one?
01176           if (range < 1 || range > ACE_MAX_DEFAULT_PORT)
01177             ACE_ERROR_RETURN ((LM_ERROR,
01178                                ACE_TEXT ("TAO (%P|%t) Invalid IIOP endpoint ")
01179                                ACE_TEXT ("portspan: <%s>\n")
01180                                ACE_TEXT ("Valid range 1 -- %d\n"),
01181                                value.c_str (), ACE_MAX_DEFAULT_PORT),
01182                               -1);
01183 
01184           this->port_span_ = static_cast <u_short> (range);
01185         }
01186       else if (name == "hostname_in_ior")
01187         {
01188           this->hostname_in_ior_ = value.rep ();
01189         }
01190       else if (name == "reuse_addr")
01191         {
01192           this->reuse_addr_ = ACE_OS::atoi (value.c_str ());
01193         }
01194       else
01195         {
01196           // the name is not known, skip to the next option
01197           i++;
01198           continue;
01199         }
01200       // at the end, we've consumed this argument. Shift the list and
01201       // put this one on the end. This technique has the effect of
01202       // putting them in reverse order, but that doesn't matter, since
01203       // these arguments are only whole strings.
01204       --argc;
01205       ACE_CString *temp = argv[i];
01206       for (int j = i; j <= argc-1; j++)
01207         argv[j] = argv[j+1];
01208       argv[argc] = temp;
01209     }
01210   return 0;
01211 }

int TAO_IIOP_Acceptor::probe_interfaces TAO_ORB_Core orb_core  )  [protected]
 

Probe the system for available network interfaces, and initialize the array with an ACE_INET_Addr for each network interface. The port for each initialized ACE_INET_Addr will be set in the open_i() method. This method only gets invoked when no explicit hostname is provided in the specified endpoint.

Definition at line 810 of file IIOP_Acceptor.cpp.

References ACE_DEBUG, ACE_NEW_RETURN, ACE_TEXT, addrs_, TAO_ORB_Parameters::connect_ipv6_only(), default_address_, endpoint_count_, ENOTSUP, ACE::get_ip_interfaces(), ACE_Addr::get_type(), hostname(), ACE_INET_Addr::is_ipv4_mapped_ipv6(), ACE_INET_Addr::is_linklocal(), ACE_INET_Addr::is_loopback(), LM_WARNING, ACE_OS::memset(), TAO_ORB_Core::orb_params(), ACE_INET_Addr::set(), and TAO_debug_level.

Referenced by open(), and open_default().

00811 {
00812   // Extract the hostname for each network interface, and then cache
00813   // it.  The hostnames will then be used when creating a
00814   // TAO_IIOP_Profile for each endpoint setup on the probed
00815   // network interfaces.
00816   ACE_INET_Addr *if_addrs = 0;
00817   size_t if_cnt = 0;
00818 
00819   if (ACE::get_ip_interfaces (if_cnt, if_addrs) != 0
00820       && errno != ENOTSUP)
00821     {
00822       // In the case where errno == ENOTSUP, if_cnt and if_addrs will
00823       // not be modified, and will each remain equal to zero.  This
00824       // causes the default interface to be used.
00825       return -1;
00826     }
00827 
00828   if (if_cnt == 0 || if_addrs == 0)
00829     {
00830       if (TAO_debug_level > 0)
00831         {
00832           ACE_DEBUG ((LM_WARNING,
00833                       ACE_TEXT ("TAO (%P|%t) - Unable to probe network ")
00834                       ACE_TEXT ("interfaces. Using default.\n")));
00835         }
00836 
00837       if_cnt = 1; // Force the network interface count to be one.
00838       delete [] if_addrs;
00839       ACE_NEW_RETURN (if_addrs,
00840                       ACE_INET_Addr[if_cnt],
00841                       -1);
00842     }
00843 
00844   // Scan for the loopback interface since it shouldn't be included in
00845   // the list of cached hostnames unless it is the only interface.
00846   size_t lo_cnt = 0;  // Loopback interface count
00847   for (size_t j = 0; j < if_cnt; ++j)
00848     if (if_addrs[j].is_loopback ())
00849       ++lo_cnt;
00850 
00851 #if defined (ACE_HAS_IPV6)
00852   size_t ipv4_cnt = 0;
00853   size_t ipv4_lo_cnt = 0;
00854   bool ipv6_non_ll = false;
00855   // Scan for IPv4 interfaces since these should not be included
00856   // when IPv6-only is selected.
00857   for (size_t j = 0; j < if_cnt; ++j)
00858     if (if_addrs[j].get_type () != AF_INET6 ||
00859         if_addrs[j].is_ipv4_mapped_ipv6 ())
00860       {
00861         ++ipv4_cnt;
00862         if (if_addrs[j].is_loopback ())
00863           ++ipv4_lo_cnt;  // keep track of IPv4 loopback ifs
00864       }
00865     else if (!if_addrs[j].is_linklocal () &&
00866              !if_addrs[j].is_loopback())
00867       {
00868         ipv6_non_ll = true; // we have at least 1 non-local IPv6 if
00869       }
00870 #endif /* ACE_HAS_IPV6 */
00871 
00872   // The instantiation for this template is in
00873   // tao/IIOP_Connector.cpp.
00874   ACE_Auto_Basic_Array_Ptr<ACE_INET_Addr> safe_if_addrs (if_addrs);
00875 
00876 #if defined (ACE_HAS_IPV6)
00877 #if defined (ACE_WIN32)
00878   bool ipv4_only = this->default_address_.get_type () == AF_INET;
00879   bool ipv6_only =
00880     this->default_address_.get_type () == AF_INET6 || orb_core->orb_params ()->connect_ipv6_only ();
00881 #else
00882   bool ipv4_only = false;
00883   bool ipv6_only = orb_core->orb_params ()->connect_ipv6_only ();
00884 #endif
00885   // If the loopback interface is the only interface then include it
00886   // in the list of interfaces to query for a hostname, otherwise
00887   // exclude it from the list.
00888   bool ignore_lo;
00889   if (ipv6_only)
00890     // only exclude loopback if non-local if exists
00891     ignore_lo = ipv6_non_ll;
00892   else if (ipv4_only)
00893     ignore_lo = ipv4_cnt != ipv4_lo_cnt;
00894   else
00895     ignore_lo = if_cnt != lo_cnt;
00896 
00897   // Adjust counts for IPv6 only if required
00898   size_t if_ok_cnt = if_cnt;
00899   if (ipv6_only)
00900     {
00901       if_ok_cnt -= ipv4_cnt;
00902       lo_cnt -= ipv4_lo_cnt;
00903       ipv4_lo_cnt = 0;
00904     }
00905   else if (ipv4_only)
00906     {
00907       if_ok_cnt = ipv4_cnt;
00908       lo_cnt = ipv4_lo_cnt;
00909     }
00910 
00911   // In case there are no non-local IPv6 ifs in the list only exclude
00912   // IPv4 loopback.
00913   // IPv6 loopback will be needed to successfully connect IPv6 clients
00914   // in a localhost environment.
00915   if (!ipv4_only && !ipv6_non_ll)
00916     lo_cnt = ipv4_lo_cnt;
00917 
00918   if (!ignore_lo)
00919     this->endpoint_count_ = static_cast<CORBA::ULong> (if_ok_cnt);
00920   else
00921     this->endpoint_count_ = static_cast<CORBA::ULong> (if_ok_cnt - lo_cnt);
00922 #else /* ACE_HAS_IPV6 */
00923   // If the loopback interface is the only interface then include it
00924   // in the list of interfaces to query for a hostname, otherwise
00925   // exclude it from the list.
00926   bool ignore_lo;
00927   ignore_lo = if_cnt != lo_cnt;
00928   if (!ignore_lo)
00929     this->endpoint_count_ = static_cast<CORBA::ULong> (if_cnt);
00930   else
00931     this->endpoint_count_ = static_cast<CORBA::ULong> (if_cnt - lo_cnt);
00932 #endif /* !ACE_HAS_IPV6 */
00933 
00934   ACE_NEW_RETURN (this->addrs_,
00935                   ACE_INET_Addr[this->endpoint_count_],
00936                   -1);
00937 
00938   ACE_NEW_RETURN (this->hosts_,
00939                   char *[this->endpoint_count_],
00940                   -1);
00941 
00942   ACE_OS::memset (this->hosts_, 0, sizeof (char*) * this->endpoint_count_);
00943 
00944   // The number of hosts/interfaces we want to cache may not be the
00945   // same as the number of detected interfaces so keep a separate
00946   // count.
00947   size_t host_cnt = 0;
00948 
00949   for (size_t i = 0; i < if_cnt; ++i)
00950     {
00951 #if defined (ACE_HAS_IPV6)
00952       // Ignore any loopback interface if there are other
00953       // non-loopback interfaces.
00954       if (ignore_lo &&
00955           if_addrs[i].is_loopback () &&
00956           (ipv4_only ||
00957            ipv6_non_ll ||
00958            if_addrs[i].get_type () != AF_INET6))
00959         continue;
00960 
00961       // Ignore any non-IPv4 interfaces when so required.
00962       if (ipv4_only &&
00963           (if_addrs[i].get_type () != AF_INET))
00964         continue;
00965 
00966       // Ignore any non-IPv6 interfaces when so required.
00967       if (ipv6_only &&
00968           (if_addrs[i].get_type () != AF_INET6 ||
00969            if_addrs[i].is_ipv4_mapped_ipv6 ()))
00970         continue;
00971 #else /* ACE_HAS_IPV6 */
00972       // Ignore any loopback interface if there are other
00973       // non-loopback interfaces.
00974       if (ignore_lo &&
00975           if_addrs[i].is_loopback ())
00976         continue;
00977 #endif /* !ACE_HAS_IPV6 */
00978 
00979       if (this->hostname (orb_core,
00980                           if_addrs[i],
00981                           this->hosts_[host_cnt]) != 0)
00982         return -1;
00983 
00984       // Copy the addr.  The port is (re)set in
00985       // TAO_IIOP_Acceptor::open_i().
00986       if (this->addrs_[host_cnt].set (if_addrs[i]) != 0)
00987         return -1;
00988 
00989       ++host_cnt;
00990     }
00991 
00992   return 0;
00993 }

void TAO_IIOP_Acceptor::set_default_address const ACE_INET_Addr addr  ) 
 

Set address for default endpoint.

Referenced by TAO_Acceptor_Registry::open_default(), and TAO_Acceptor_Registry::open_i().


Member Data Documentation

ACCEPT_STRATEGY* TAO_IIOP_Acceptor::accept_strategy_ [private]
 

Definition at line 265 of file IIOP_Acceptor.h.

ACE_INET_Addr* TAO_IIOP_Acceptor::addrs_ [protected]
 

Array of ACE_INET_Addr instances, each one corresponding to a given network interface.

Definition at line 211 of file IIOP_Acceptor.h.

Referenced by create_new_profile(), create_shared_profile(), is_collocated(), open(), open_i(), probe_interfaces(), and ~TAO_IIOP_Acceptor().

BASE_ACCEPTOR TAO_IIOP_Acceptor::base_acceptor_ [private]
 

The concrete acceptor, as a pointer to it's base class.

Definition at line 260 of file IIOP_Acceptor.h.

Referenced by close(), and open_i().

CONCURRENCY_STRATEGY* TAO_IIOP_Acceptor::concurrency_strategy_ [private]
 

Definition at line 264 of file IIOP_Acceptor.h.

CREATION_STRATEGY* TAO_IIOP_Acceptor::creation_strategy_ [private]
 

Acceptor strategies.

Definition at line 263 of file IIOP_Acceptor.h.

ACE_INET_Addr TAO_IIOP_Acceptor::default_address_ [protected]
 

Address for default endpoint.

Definition at line 255 of file IIOP_Acceptor.h.

Referenced by open_i(), parse_address(), and probe_interfaces().

CORBA::ULong TAO_IIOP_Acceptor::endpoint_count_ [protected]
 

The number of host names cached in the hosts_ array (equivalent to the number of endpoints opened by this Acceptor).

Definition at line 236 of file IIOP_Acceptor.h.

Referenced by create_new_profile(), create_profile(), create_shared_profile(), endpoint_count(), is_collocated(), open(), open_i(), probe_interfaces(), and ~TAO_IIOP_Acceptor().

char* TAO_IIOP_Acceptor::hostname_in_ior_ [protected]
 

Override the hostname used in the ORBEndPoint.

Definition at line 232 of file IIOP_Acceptor.h.

Referenced by hostname(), open(), parse_options_i(), and ~TAO_IIOP_Acceptor().

char** TAO_IIOP_Acceptor::hosts_ [protected]
 

Cache the information about the endpoints serviced by this acceptor. There may in fact be multiple hostnames for this endpoint. For example, if the IP address is INADDR_ANY (0.0.0.0) then there will be possibly a different hostname for each interface.

Definition at line 227 of file IIOP_Acceptor.h.

Referenced by is_collocated(), open(), open_default(), and ~TAO_IIOP_Acceptor().

const bool TAO_IIOP_Acceptor::lite_flag_ [protected]
 

Should we use GIOP lite??

Definition at line 249 of file IIOP_Acceptor.h.

TAO_ORB_Core* TAO_IIOP_Acceptor::orb_core_ [protected]
 

ORB Core.

Definition at line 246 of file IIOP_Acceptor.h.

unsigned short TAO_IIOP_Acceptor::port_span_ [protected]
 

The number of ports over which the acceptor should search (starting at the port specified in each element of addrs_) for an available port. This is specified via the "portspan=" option to the endpoint.

Definition at line 218 of file IIOP_Acceptor.h.

Referenced by open_i(), and parse_options_i().

int TAO_IIOP_Acceptor::reuse_addr_ [protected]
 

Enable socket option SO_REUSEADDR to be set.

Definition at line 252 of file IIOP_Acceptor.h.

TAO_GIOP_Message_Version TAO_IIOP_Acceptor::version_ [protected]
 

The GIOP version for this endpoint @ Theoretically they shouldn't be here!! We need to look at a way to move this out

Definition at line 243 of file IIOP_Acceptor.h.

Referenced by create_new_profile(), create_shared_profile(), open(), open_default(), and parse_address().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:14:26 2006 for TAO by doxygen 1.3.6