TAO_UIPMC_Acceptor Class Reference

TAO_UIPMC_Acceptor. More...

#include <UIPMC_Acceptor.h>

Inheritance diagram for TAO_UIPMC_Acceptor:

Inheritance graph
[legend]
Collaboration diagram for TAO_UIPMC_Acceptor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_UIPMC_Acceptor (CORBA::Boolean flag=0)
 Constructor.

 ~TAO_UIPMC_Acceptor (void)
 Destructor.

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

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)
virtual int create_profile (const TAO::ObjectKey &object_key, TAO_MProfile &mprofile, CORBA::Short priority)
virtual int is_collocated (const TAO_Endpoint *endpoint)
virtual CORBA::ULong endpoint_count (void)
virtual int object_key (IOP::TaggedProfile &profile, TAO::ObjectKey &key)
int hostname (TAO_ORB_Core *orb_core, ACE_INET_Addr &addr, char *&host, const char *specified_hostname=0)
int dotted_decimal_address (ACE_INET_Addr &addr, char *&host)

Protected Member Functions

virtual int open_i (const ACE_INET_Addr &addr, ACE_Reactor *reactor)
virtual int parse_options (const char *options)
 Parse protocol specific options.


Protected Attributes

ACE_INET_Addraddrs_
char ** hosts_
CORBA::ULong endpoint_count_
TAO_GIOP_Message_Version version_
TAO_ORB_Coreorb_core_
 ORB Core.


Private Attributes

TAO_UIPMC_Connection_Handlerconnection_handler_

Detailed Description

TAO_UIPMC_Acceptor.

The UIPMC-specific bridge class for the concrete acceptor.

Definition at line 46 of file UIPMC_Acceptor.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_UIPMC_Acceptor::TAO_UIPMC_Acceptor CORBA::Boolean  flag = 0  ) 
 

Constructor.

Definition at line 27 of file UIPMC_Acceptor.cpp.

References TAO_DEF_GIOP_MAJOR, and TAO_DEF_GIOP_MINOR.

00028   : TAO_Acceptor (IOP::TAG_UIPMC),
00029     addrs_ (0),
00030     hosts_ (0),
00031     endpoint_count_ (0),
00032     version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR),
00033     orb_core_ (0),
00034     connection_handler_ (0)
00035 {
00036 }

TAO_UIPMC_Acceptor::~TAO_UIPMC_Acceptor void   ) 
 

Destructor.

Definition at line 38 of file UIPMC_Acceptor.cpp.

References close(), and CORBA::string_free().

00039 {
00040   // Make sure we are closed before we start destroying the
00041   // strategies.
00042   this->close ();
00043 
00044   delete [] this->addrs_;
00045 
00046   for (size_t i = 0; i < this->endpoint_count_; ++i)
00047     CORBA::string_free (this->hosts_[i]);
00048 
00049   delete [] this->hosts_;
00050 }


Member Function Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const ACE_INET_Addr & TAO_UIPMC_Acceptor::address void   )  const
 

@ Helper method for the implementation repository, should go away

Definition at line 9 of file UIPMC_Acceptor.i.

References ACE_ASSERT.

00010 {
00011   ACE_ASSERT (this->addrs_ != 0);
00012 
00013   // @@ This is busted.
00014   //    The Implementation Repository will have to start supporting
00015   //    IORs with multiple profiles.  For now, we just return the
00016   //    first addr.
00017   //                    -Ossama
00018   return this->addrs_[0];
00019 }

int TAO_UIPMC_Acceptor::close void   )  [virtual]
 

Implements TAO_Acceptor.

Definition at line 79 of file UIPMC_Acceptor.cpp.

Referenced by ~TAO_UIPMC_Acceptor().

00080 {
00081   return 0;
00082 }

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

Implements TAO_Acceptor.

Definition at line 53 of file UIPMC_Acceptor.cpp.

00056 {
00057   // The standard mechanism for adding profiles to object references
00058   // for each pluggable protocol doesn't apply to UIPMC profiles, so
00059   // this function just returns success without doing anything.  The
00060   // appropiate mechanism for getting UIPMC profiles is to call the
00061   // multicast group manager to get a Group reference.  Invocations
00062   // sent to this group reference will be dispatched to the servants
00063   // that belong to that group.
00064   return 0;
00065 }

int TAO_UIPMC_Acceptor::dotted_decimal_address ACE_INET_Addr addr,
char *&  host
 

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

Definition at line 226 of file UIPMC_Acceptor.cpp.

References ACE_DEBUG, ACE_TEXT(), ACE_INET_Addr::get_host_addr(), LM_DEBUG, CORBA::string_dup(), and TAO_debug_level.

Referenced by hostname().

00228 {
00229   const char *tmp = addr.get_host_addr ();
00230   if (tmp == 0)
00231     {
00232       if (TAO_debug_level > 0)
00233         ACE_DEBUG ((LM_DEBUG,
00234                     ACE_TEXT ("\n\nTAO (%P|%t) ")
00235                     ACE_TEXT ("UIPMC_Acceptor::dotted_decimal_address ")
00236                     ACE_TEXT ("- %p\n\n"),
00237                     ACE_TEXT ("cannot determine hostname")));
00238       return -1;
00239     }
00240 
00241   host = CORBA::string_dup (tmp);
00242   return 0;
00243 }

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

Implements TAO_Acceptor.

Definition at line 246 of file UIPMC_Acceptor.cpp.

00247 {
00248   return this->endpoint_count_;
00249 }

ACE_INLINE const ACE_INET_Addr * TAO_UIPMC_Acceptor::endpoints void   ) 
 

Returns the array of endpoints in this acceptor.

Definition at line 22 of file UIPMC_Acceptor.i.

References ACE_ASSERT.

00023 {
00024   ACE_ASSERT (this->addrs_ != 0);
00025 
00026   return this->addrs_;
00027 }

int TAO_UIPMC_Acceptor::hostname TAO_ORB_Core orb_core,
ACE_INET_Addr addr,
char *&  host,
const char *  specified_hostname = 0
 

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.

Definition at line 216 of file UIPMC_Acceptor.cpp.

References dotted_decimal_address().

Referenced by open().

00220 {
00221   // Only have dotted decimal addresses for multicast.
00222   return this->dotted_decimal_address (addr, host);
00223 }

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

Implements TAO_Acceptor.

Definition at line 68 of file UIPMC_Acceptor.cpp.

00069 {
00070   // @@ Not clear how
00071   // to best handle collation.  For example, one servant could
00072   // be collocated, but we still need to send the request out on
00073   // the network to see if there are any other servants in the
00074   // group.
00075   return 0;  // Not collocated
00076 }

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

Implements TAO_Acceptor.

Definition at line 252 of file UIPMC_Acceptor.cpp.

00254 {
00255   // No object key to extract.  Just return success.
00256   return 1;
00257 }

int TAO_UIPMC_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 Pluggable.h for details.

Implements TAO_Acceptor.

Definition at line 85 of file UIPMC_Acceptor.cpp.

References ACE_ERROR_RETURN, ACE_NEW_RETURN, ACE_TEXT(), hostname(), LM_ERROR, MAXHOSTNAMELEN, ACE_OS::memcpy(), open_i(), parse_options(), ACE_INET_Addr::set(), TAO_GIOP_Message_Version::set_version(), and ACE_OS::strchr().

00091 {
00092   this->orb_core_ = orb_core;
00093 
00094   if (this->hosts_ != 0)
00095     {
00096       // The hostname cache has already been set!
00097       // This is bad mojo, i.e. an internal TAO error.
00098       ACE_ERROR_RETURN ((LM_ERROR,
00099                          ACE_TEXT ("TAO (%P|%t) ")
00100                          ACE_TEXT ("UIPMC_Acceptor::open - ")
00101                          ACE_TEXT ("hostname already set\n\n")),
00102                         -1);
00103     }
00104 
00105   if (address == 0)
00106     return -1;
00107 
00108   if (major >=0 && minor >= 0)
00109     this->version_.set_version (static_cast<CORBA::Octet> (major),
00110                                 static_cast<CORBA::Octet> (minor));
00111   // Parse options
00112   if (this->parse_options (options) == -1)
00113     return -1;
00114 
00115   ACE_INET_Addr addr;
00116 
00117   const char *port_separator_loc = ACE_OS::strchr (address, ':');
00118   const char *specified_hostname = 0;
00119   char tmp_host[MAXHOSTNAMELEN + 1];
00120 
00121   // Both host and port have to be specified.
00122   if (addr.set (address) != 0)
00123     return -1;
00124 
00125   // Extract out just the host part of the address.
00126   size_t len = port_separator_loc - address;
00127   ACE_OS::memcpy (tmp_host, address, len);
00128   tmp_host[len] = '\0';
00129 
00130   specified_hostname = tmp_host;
00131 
00132   this->endpoint_count_ = 1;  // Only one hostname to store
00133 
00134   ACE_NEW_RETURN (this->addrs_,
00135                   ACE_INET_Addr[this->endpoint_count_],
00136                   -1);
00137 
00138   ACE_NEW_RETURN (this->hosts_,
00139                   char *[this->endpoint_count_],
00140                   -1);
00141 
00142   this->hosts_[0] = 0;
00143 
00144   if (this->hostname (orb_core,
00145                       addr,
00146                       this->hosts_[0],
00147                       specified_hostname) != 0)
00148     return -1;
00149 
00150   // Copy the addr.  The port is (re)set in
00151   // TAO_UIPMC_Acceptor::open_i().
00152   if (this->addrs_[0].set (addr) != 0)
00153     return -1;
00154 
00155   return this->open_i (addr,
00156                        reactor);
00157 }

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

Implements TAO_Acceptor.

Definition at line 160 of file UIPMC_Acceptor.cpp.

00165 {
00166   // There is no such thing as a default multicast listen
00167   // port.  The mechanism for choosing these ports is done
00168   // when creating the group ids.  (I.e. not here).
00169   return -1;
00170 }

int TAO_UIPMC_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 173 of file UIPMC_Acceptor.cpp.

References ACE_DEBUG, ACE_NEW_RETURN, ACE_TEXT(), ACE_INET_Addr::get_port_number(), LM_DEBUG, TAO_UIPMC_Connection_Handler::local_addr(), TAO_UIPMC_Connection_Handler::open_server(), ACE_Reactor::register_handler(), ACE_Event_Handler::remove_reference(), ACE_INET_Addr::set_port_number(), and TAO_debug_level.

Referenced by open().

00175 {
00176   ACE_NEW_RETURN (this->connection_handler_,
00177                   TAO_UIPMC_Connection_Handler (this->orb_core_),
00178                   -1);
00179 
00180   this->connection_handler_->local_addr (addr);
00181   this->connection_handler_->open_server ();
00182 
00183   int result =
00184     reactor->register_handler (this->connection_handler_,
00185                                ACE_Event_Handler::READ_MASK);
00186   if (result == -1)
00187     return result;
00188 
00189   // Connection handler ownership now belongs to the Reactor.
00190   this->connection_handler_->remove_reference ();
00191 
00192   // Set the port for each addr.  If there is more than one network
00193   // interface then the endpoint created on each interface will be on
00194   // the same port.  This is how a wildcard socket bind() is supposed
00195   // to work.
00196   u_short port = addr.get_port_number ();
00197   for (size_t j = 0; j < this->endpoint_count_; ++j)
00198     this->addrs_[j].set_port_number (port, 1);
00199 
00200   if (TAO_debug_level > 5)
00201     {
00202       for (size_t i = 0; i < this->endpoint_count_; ++i)
00203         {
00204           ACE_DEBUG ((LM_DEBUG,
00205                       ACE_TEXT ("\nTAO (%P|%t) UIPMC_Acceptor::open_i - ")
00206                       ACE_TEXT ("listening on: <%s:%u>\n"),
00207                       this->hosts_[i],
00208                       this->addrs_[i].get_port_number ()));
00209         }
00210     }
00211 
00212   return 0;
00213 }

int TAO_UIPMC_Acceptor::parse_options const char *  options  )  [protected, virtual]
 

Parse protocol specific options.

Definition at line 261 of file UIPMC_Acceptor.cpp.

References ACE_CString, ACE_ERROR_RETURN, ACE_TEXT(), and LM_ERROR.

Referenced by open().

00262 {
00263   if (str == 0)
00264     return 0;  // No options to parse.  Not a problem.
00265 
00266   // Use an option format similar to the one used for CGI scripts in
00267   // HTTP URLs.
00268   // e.g.:  option1=foo&option2=bar
00269 
00270   ACE_CString options (str);
00271 
00272   size_t len = options.length ();
00273 
00274   const char option_delimiter = '&';
00275 
00276   // Count the number of options.
00277 
00278   CORBA::ULong option_count = 1;
00279   // Number of endpoints in the string  (initialized to 1).
00280 
00281   // Only check for endpoints after the protocol specification and
00282   // before the object key.
00283   for (size_t i = 0; i < len; ++i)
00284     if (options[i] == option_delimiter)
00285       option_count++;
00286 
00287   // The idea behind the following loop is to split the options into
00288   // (option, name) pairs.
00289   // For example,
00290   //    `option1=foo&option2=bar'
00291   // will be parsed into:
00292   //    `option1=foo'
00293   //    `option2=bar'
00294 
00295   int begin = 0;
00296   int end = -1;
00297 
00298   for (CORBA::ULong j = 0; j < option_count; ++j)
00299     {
00300       begin += end + 1;
00301 
00302       if (j < option_count - 1)
00303         end = options.find (option_delimiter, begin);
00304       else
00305         end = static_cast<int> (len - begin); // Handle last endpoint differently
00306 
00307       if (end == begin)
00308         ACE_ERROR_RETURN ((LM_ERROR,
00309                            ACE_TEXT ("TAO (%P|%t) Zero length UIPMC option.\n")),
00310                           -1);
00311       else if (end != ACE_CString::npos)
00312         {
00313           ACE_CString opt = options.substring (begin, end);
00314 
00315           int slot = opt.find ("=");
00316 
00317           if (slot == static_cast<int> (len - 1)
00318               || slot == ACE_CString::npos)
00319             ACE_ERROR_RETURN ((LM_ERROR,
00320                                ACE_TEXT ("TAO (%P|%t) UIPMC option <%s> is ")
00321                                ACE_TEXT ("missing a value.\n"),
00322                                opt.c_str ()),
00323                               -1);
00324 
00325           ACE_CString name = opt.substring (0, slot);
00326           ACE_CString value = opt.substring (slot + 1);
00327 
00328           if (name.length () == 0)
00329             ACE_ERROR_RETURN ((LM_ERROR,
00330                                ACE_TEXT ("TAO (%P|%t) Zero length UIPMC ")
00331                                ACE_TEXT ("option name.\n")),
00332                               -1);
00333 
00334           if (name == "priority")
00335             {
00336               ACE_ERROR_RETURN ((LM_ERROR,
00337                                  ACE_TEXT ("TAO (%P|%t) Invalid UIPMC endpoint format: ")
00338                                  ACE_TEXT ("endpoint priorities no longer supported. \n"),
00339                                  value.c_str ()),
00340                                 -1);
00341             }
00342           else
00343             ACE_ERROR_RETURN ((LM_ERROR,
00344                                ACE_TEXT ("TAO (%P|%t) Invalid UIPMC option: <%s>\n"),
00345                                name.c_str ()),
00346                               -1);
00347         }
00348     }
00349   return 0;
00350 }


Member Data Documentation

ACE_INET_Addr* TAO_UIPMC_Acceptor::addrs_ [protected]
 

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

Definition at line 123 of file UIPMC_Acceptor.h.

TAO_UIPMC_Connection_Handler* TAO_UIPMC_Acceptor::connection_handler_ [private]
 

Definition at line 150 of file UIPMC_Acceptor.h.

CORBA::ULong TAO_UIPMC_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 136 of file UIPMC_Acceptor.h.

char** TAO_UIPMC_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 132 of file UIPMC_Acceptor.h.

TAO_ORB_Core* TAO_UIPMC_Acceptor::orb_core_ [protected]
 

ORB Core.

Definition at line 146 of file UIPMC_Acceptor.h.

TAO_GIOP_Message_Version TAO_UIPMC_Acceptor::version_ [protected]
 

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

Definition at line 143 of file UIPMC_Acceptor.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:05:09 2006 for TAO_PortableGroup by doxygen 1.3.6