TAO_UIPMC_Connector Class Reference

UIPMC-specific Connector bridge for pluggable protocols. More...

#include <UIPMC_Connector.h>

Inheritance diagram for TAO_UIPMC_Connector:

Inheritance graph
[legend]
Collaboration diagram for TAO_UIPMC_Connector:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_UIPMC_Connector (void)
 Constructor.

 ~TAO_UIPMC_Connector (void)
 Destructor.

int open (TAO_ORB_Core *orb_core)
int close (void)
TAO_Profilecreate_profile (TAO_InputCDR &cdr)
virtual int check_prefix (const char *endpoint)
virtual char object_key_delimiter (void) const

Protected Member Functions

int set_validate_endpoint (TAO_Endpoint *endpoint)
TAO_Transportmake_connection (TAO::Profile_Transport_Resolver *r, TAO_Transport_Descriptor_Interface &desc, ACE_Time_Value *timeout=0)
virtual TAO_Profilemake_profile (void)
virtual int cancel_svc_handler (TAO_Connection_Handler *svc_handler)
 Cancel the passed cvs handler from the connector.


Detailed Description

UIPMC-specific Connector bridge for pluggable protocols.

Concrete instance of the TAO_Connector class. Responsible for establishing a connection with a server and is called from the Connector_Registory.

Definition at line 44 of file UIPMC_Connector.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_UIPMC_Connector::TAO_UIPMC_Connector void   ) 
 

Constructor.

Definition at line 21 of file UIPMC_Connector.cpp.

00022   : TAO_Connector (IOP::TAG_UIPMC)
00023 {
00024 }

TAO_UIPMC_Connector::~TAO_UIPMC_Connector void   ) 
 

Destructor.

Definition at line 26 of file UIPMC_Connector.cpp.

00027 {
00028 }


Member Function Documentation

int TAO_UIPMC_Connector::cancel_svc_handler TAO_Connection_Handler svc_handler  )  [protected, virtual]
 

Cancel the passed cvs handler from the connector.

Implements TAO_Connector.

Definition at line 280 of file UIPMC_Connector.cpp.

00282 {
00283   // Noop
00284   return 0;
00285 }

int TAO_UIPMC_Connector::check_prefix const char *  endpoint  )  [virtual]
 

Implements TAO_Connector.

Definition at line 251 of file UIPMC_Connector.cpp.

References ACE_OS::strchr(), and ACE_OS::strncasecmp().

00252 {
00253   // Check for a valid string
00254   if (!endpoint || !*endpoint)
00255     return -1;  // Failure
00256 
00257   static const char protocol[] = "miop";
00258   static size_t const len = sizeof (protocol) - 1;
00259 
00260   size_t const slot = ACE_OS::strchr (endpoint, ':') - endpoint;
00261 
00262   // Check for the proper prefix in the IOR.  If the proper prefix
00263   // isn't in the IOR then it is not an IOR we can use.
00264   if (slot == len
00265       && ACE_OS::strncasecmp (endpoint, protocol, len) == 0)
00266     return 0;
00267 
00268   return -1;
00269   // Failure: not a MIOP IOR
00270   // DO NOT throw an exception here.
00271 }

int TAO_UIPMC_Connector::close void   )  [virtual]
 

Implements TAO_Connector.

Definition at line 43 of file UIPMC_Connector.cpp.

00044 {
00045   return 0;
00046 }

TAO_Profile * TAO_UIPMC_Connector::create_profile TAO_InputCDR cdr  )  [virtual]
 

Implements TAO_Connector.

Definition at line 213 of file UIPMC_Connector.cpp.

References TAO_Profile::_decr_refcnt(), ACE_NEW_RETURN, and TAO_Profile::decode().

00214 {
00215   TAO_Profile *pfile;
00216   ACE_NEW_RETURN (pfile,
00217                   TAO_UIPMC_Profile (this->orb_core ()),
00218                   0);
00219 
00220   int r = pfile->decode (cdr);
00221   if (r == -1)
00222     {
00223       pfile->_decr_refcnt ();
00224       pfile = 0;
00225     }
00226 
00227   return pfile;
00228 }

TAO_Transport * TAO_UIPMC_Connector::make_connection TAO::Profile_Transport_Resolver r,
TAO_Transport_Descriptor_Interface desc,
ACE_Time_Value timeout = 0
[protected, virtual]
 

Implements TAO_Connector.

Definition at line 89 of file UIPMC_Connector.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_NEW_RETURN, ACE_TCHAR, ACE_TEXT(), ACE_TEXT_CHAR_TO_TCHAR, TAO_UIPMC_Connection_Handler::addr(), ACE_INET_Addr::addr_to_string(), TAO::Transport_Cache_Manager::cache_transport(), TAO_UIPMC_Connection_Handler::close(), TAO_ORB_Parameters::connect_ipv6_only(), TAO_Transport_Descriptor_Interface::endpoint(), ACE_Svc_Handler<, >::get_handle(), ACE_Addr::get_type(), TAO_UIPMC_Endpoint::host(), INADDR_ANY, ACE_INET_Addr::is_ipv4_mapped_ipv6(), TAO_ORB_Core::lane_resources(), LM_DEBUG, LM_ERROR, TAO_UIPMC_Connection_Handler::local_addr(), MAXHOSTNAMELEN, TAO_UIPMC_Endpoint::object_addr(), TAO_UIPMC_Connection_Handler::open(), TAO_Connector::orb_core(), TAO_ORB_Core::orb_params(), TAO_UIPMC_Endpoint::port(), ACE_INET_Addr::set(), TAO_debug_level, TAO_Connection_Handler::transport(), TAO_Thread_Lane_Resources::transport_cache(), and UIPMC_TRANSPORT.

00092 {
00093   TAO_UIPMC_Endpoint *uipmc_endpoint =
00094     dynamic_cast<TAO_UIPMC_Endpoint *> (desc.endpoint ());
00095 
00096   if (uipmc_endpoint == 0)
00097     return 0;
00098 
00099   const ACE_INET_Addr &remote_address =
00100     uipmc_endpoint->object_addr ();
00101 
00102 #if defined (ACE_HAS_IPV6) && !defined (ACE_HAS_IPV6_V6ONLY)
00103   // Check if we need to invalidate accepted connections
00104   // from IPv4 mapped IPv6 addresses
00105   if (this->orb_core ()->orb_params ()->connect_ipv6_only () &&
00106       remote_address.is_ipv4_mapped_ipv6 ())
00107     {
00108       if (TAO_debug_level > 0)
00109         {
00110           ACE_TCHAR remote_as_string[MAXHOSTNAMELEN + 16];
00111 
00112           (void) remote_address.addr_to_string (remote_as_string,
00113                                                 sizeof remote_as_string);
00114 
00115           ACE_ERROR ((LM_ERROR,
00116                       ACE_TEXT ("TAO (%P|%t) - UIPMC_Connector::open, ")
00117                       ACE_TEXT ("invalid connection to IPv4 mapped IPv6 interface <%s>!\n"),
00118                       remote_as_string));
00119         }
00120       return 0;
00121     }
00122 #endif /* ACE_HAS_IPV6 && ACE_HAS_IPV6_V6ONLY */
00123 
00124   TAO_UIPMC_Connection_Handler *svc_handler = 0;
00125 
00126   ACE_NEW_RETURN (svc_handler,
00127                   TAO_UIPMC_Connection_Handler (this->orb_core ()),
00128                   0);
00129 
00130   u_short port = 0;
00131   const ACE_UINT32 ia_any = INADDR_ANY;
00132   ACE_INET_Addr local_addr(port, ia_any);
00133 
00134 #if defined (ACE_HAS_IPV6)
00135   if (remote_address.get_type () == AF_INET6)
00136     local_addr.set (port,
00137                     ACE_IPV6_ANY);
00138 #endif /* ACE_HAS_IPV6 */
00139 
00140   svc_handler->local_addr (local_addr);
00141   svc_handler->addr (remote_address);
00142 
00143   int retval = svc_handler->open (0);
00144 
00145   // Failure to open a connection.
00146   if (retval != 0)
00147     {
00148       // Close the handler (this will also delete svc_handler).
00149       svc_handler->close ();
00150 
00151       if (TAO_debug_level > 0)
00152         {
00153           ACE_ERROR ((LM_ERROR,
00154                       "TAO (%P|%t) - UIPMC_Connector::make_connection, "
00155                       "could not make a new connection\n"));
00156         }
00157 
00158       return 0;
00159     }
00160 
00161   if (TAO_debug_level > 2)
00162     ACE_DEBUG ((LM_DEBUG,
00163                 ACE_TEXT ("TAO (%P|%t) - UIPMC_Connector::make_connection, ")
00164                 ACE_TEXT ("new connection on HANDLE %d\n"),
00165                 svc_handler->get_handle ()));
00166 
00167   UIPMC_TRANSPORT *transport =
00168     dynamic_cast<UIPMC_TRANSPORT *> (svc_handler->transport ());
00169 
00170   // In case of errors transport is zero
00171   if (transport == 0)
00172     {
00173       // Close the handler (this will also delete svc_handler).
00174       svc_handler->close ();
00175 
00176       // Give users a clue to the problem.
00177       if (TAO_debug_level > 3)
00178           ACE_ERROR ((LM_ERROR,
00179                       "TAO (%P|%t) - UIPMC_Connector::make_connection, "
00180                       "connection to <%s:%u> failed (%p)\n",
00181                       ACE_TEXT_CHAR_TO_TCHAR (uipmc_endpoint->host ()),
00182                       uipmc_endpoint->port (),
00183                       ACE_TEXT ("errno")));
00184 
00185       return 0;
00186     }
00187 
00188   // Add the handler to Cache
00189   retval =
00190     this->orb_core ()->lane_resources ().transport_cache ().cache_transport (&desc,
00191                                                                              transport);
00192 
00193   // Failure in adding to cache.
00194   if (retval != 0)
00195     {
00196       // Close the handler (this will also delete svc_handler).
00197       svc_handler->close ();
00198 
00199       if (TAO_debug_level > 0)
00200         {
00201           ACE_ERROR ((LM_ERROR,
00202                       "TAO (%P|%t) - UIPMC_Connector::make_connection, "
00203                       "could not add the new connection to cache\n"));
00204         }
00205 
00206       return 0;
00207     }
00208 
00209   return transport;
00210 }

TAO_Profile * TAO_UIPMC_Connector::make_profile void   )  [protected, virtual]
 

Implements TAO_Connector.

Definition at line 231 of file UIPMC_Connector.cpp.

References ACE_NEW_THROW_EX.

00232 {
00233   // The endpoint should be of the form:
00234   //    N.n@host:port/object_key
00235   // or:
00236   //    host:port/object_key
00237 
00238   TAO_Profile *profile = 0;
00239   ACE_NEW_THROW_EX (profile,
00240                     TAO_UIPMC_Profile (this->orb_core ()),
00241                     CORBA::NO_MEMORY (
00242                       CORBA::SystemException::_tao_minor_code (
00243                         TAO::VMCID,
00244                         ENOMEM),
00245                       CORBA::COMPLETED_NO));
00246 
00247   return profile;
00248 }

char TAO_UIPMC_Connector::object_key_delimiter void   )  const [virtual]
 

Implements TAO_Connector.

Definition at line 274 of file UIPMC_Connector.cpp.

00275 {
00276   return TAO_UIPMC_Profile::object_key_delimiter_;
00277 }

int TAO_UIPMC_Connector::open TAO_ORB_Core orb_core  )  [virtual]
 

Implements TAO_Connector.

Definition at line 31 of file UIPMC_Connector.cpp.

References TAO_Connector::create_connect_strategy(), and TAO_Connector::orb_core().

00032 {
00033   this->orb_core (orb_core);
00034 
00035   // For the sake of uniformity do
00036   if (this->create_connect_strategy () == -1)
00037     return -1;
00038 
00039   return 0;
00040 }

int TAO_UIPMC_Connector::set_validate_endpoint TAO_Endpoint endpoint  )  [protected, virtual]
 

= More TAO_Connector methods, please check the documentation on Transport_Connector.h

Implements TAO_Connector.

Definition at line 49 of file UIPMC_Connector.cpp.

References ACE_DEBUG, ACE_TEXT(), AF_INET, ACE_Addr::get_type(), LM_DEBUG, TAO_UIPMC_Endpoint::object_addr(), TAO_Endpoint::tag(), and TAO_debug_level.

00050 {
00051   if (endpoint->tag () != IOP::TAG_UIPMC)
00052     return -1;
00053 
00054   TAO_UIPMC_Endpoint *uipmc_endpoint =
00055     dynamic_cast<TAO_UIPMC_Endpoint *> (endpoint);
00056 
00057   if (uipmc_endpoint == 0)
00058     return -1;
00059 
00060   const ACE_INET_Addr &remote_address =
00061     uipmc_endpoint->object_addr ();
00062 
00063   // Verify that the remote ACE_INET_Addr was initialized properly.
00064   // Failure can occur if hostname lookup failed when initializing the
00065   // remote ACE_INET_Addr.
00066 #if defined (ACE_HAS_IPV6)
00067   if (remote_address.get_type () != AF_INET &&
00068       remote_address.get_type () != AF_INET6)
00069 #else /* ACE_HAS_IPV6 */
00070   if (remote_address.get_type () != AF_INET)
00071 #endif /* !ACE_HAS_IPV6 */
00072     {
00073       if (TAO_debug_level > 0)
00074         {
00075           ACE_DEBUG ((LM_DEBUG,
00076                       ACE_TEXT ("TAO (%P|%t) UIPMC connection failed.\n")
00077                       ACE_TEXT ("TAO (%P|%t) This is most likely ")
00078                       ACE_TEXT ("due to a hostname lookup ")
00079                       ACE_TEXT ("failure.\n")));
00080         }
00081 
00082       return -1;
00083     }
00084 
00085   return 0;
00086 }


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 16:24:29 2008 for TAO_PortableGroup by doxygen 1.3.6