TAO::SSLIOP::Transport Class Reference

SSLIOP-specific transport implementation. More...

#include <SSLIOP_Transport.h>

Inheritance diagram for TAO::SSLIOP::Transport:

Inheritance graph
[legend]
Collaboration diagram for TAO::SSLIOP::Transport:

Collaboration graph
[legend]
List of all members.

Overridden Template Methods

These are implementations of template methods declared by TAO_Transport.

virtual int send_request (TAO_Stub *stub, TAO_ORB_Core *orb_core, TAO_OutputCDR &stream, TAO_Message_Semantics message_semantics, ACE_Time_Value *max_wait_time)
virtual int send_message (TAO_OutputCDR &stream, TAO_Stub *stub=0, TAO_Message_Semantics message_semantics=TAO_Transport::TAO_TWOWAY_REQUEST, ACE_Time_Value *max_time_wait=0)
virtual int generate_request_header (TAO_Operation_Details &opdetails, TAO_Target_Specification &spec, TAO_OutputCDR &msg)
virtual int tear_listen_point_list (TAO_InputCDR &cdr)
 Open teh service context list and process it.
virtual ACE_Event_Handlerevent_handler_i (void)
virtual TAO_Connection_Handlerconnection_handler_i (void)
virtual ssize_t send (iovec *iov, int iovcnt, size_t &bytes_transferred, const ACE_Time_Value *timeout=0)
 Write the complete Message_Block chain to the connection.
virtual ssize_t recv (char *buf, size_t len, const ACE_Time_Value *s=0)
 Read len bytes from into buf.

Public Member Functions

 Transport (Connection_Handler *handler, TAO_ORB_Core *orb_core)
 Constructor.
 ~Transport (void)
 Default destructor.
virtual int handle_input (TAO_Resume_Handle &rh, ACE_Time_Value *max_wait_time=0)

Private Member Functions

void set_bidir_context_info (TAO_Operation_Details &opdetails)
int get_listen_point (IIOP::ListenPointList &listen_point_list, TAO_Acceptor *acceptor)

Private Attributes

Connection_Handlerconnection_handler_

Detailed Description

SSLIOP-specific transport implementation.

SSLIOP-specific transport implementation.

Definition at line 61 of file SSLIOP_Transport.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::SSLIOP::Transport::Transport ( Connection_Handler handler,
TAO_ORB_Core orb_core 
)

Constructor.

Definition at line 26 of file SSLIOP_Transport.cpp.

00029   : TAO_Transport (IOP::TAG_INTERNET_IOP, orb_core),
00030     connection_handler_ (handler)
00031 {
00032 }

TAO::SSLIOP::Transport::~Transport ( void   ) 

Default destructor.

Definition at line 34 of file SSLIOP_Transport.cpp.

00035 {
00036 }


Member Function Documentation

TAO_Connection_Handler * TAO::SSLIOP::Transport::connection_handler_i ( void   )  [protected, virtual]

Todo:
These methods IMHO should have more meaningful names. The names seem to indicate nothing.

Implements TAO_Transport.

Definition at line 45 of file SSLIOP_Transport.cpp.

References connection_handler_.

00046 {
00047   return this->connection_handler_;
00048 }

ACE_Event_Handler * TAO::SSLIOP::Transport::event_handler_i ( void   )  [protected, virtual]

Todo:
These methods IMHO should have more meaningful names. The names seem to indicate nothing.

Implements TAO_Transport.

Definition at line 39 of file SSLIOP_Transport.cpp.

References connection_handler_.

00040 {
00041   return this->connection_handler_;
00042 }

int TAO::SSLIOP::Transport::generate_request_header ( TAO_Operation_Details opdetails,
TAO_Target_Specification spec,
TAO_OutputCDR msg 
) [virtual]

Todo:
These methods IMHO should have more meaningful names. The names seem to indicate nothing.

Reimplemented from TAO_Transport.

Definition at line 174 of file SSLIOP_Transport.cpp.

References TAO_Transport::bidirectional_flag(), TAO_Transport::generate_request_header(), TAO_GIOP_Message_Base::is_ready_for_bidirectional(), TAO_Transport::messaging_object_, and TAO_Operation_Details::request_id().

00178 {
00179   // Check whether we have a Bi Dir IIOP policy set, whether the
00180   // messaging objects are ready to handle bidirectional connections
00181   // and also make sure that we have not recd. or sent any information
00182   // regarding this before...
00183   if (this->orb_core ()->bidir_giop_policy ()
00184       && this->messaging_object_->is_ready_for_bidirectional (msg)
00185       && this->bidirectional_flag () < 0)
00186     {
00187       this->set_bidir_context_info (opdetails);
00188 
00189       // Set the flag to 1
00190       this->bidirectional_flag (1);
00191 
00192       // At the moment we enable BiDIR giop we have to get a new
00193       // request id to make sure that we follow the even/odd rule
00194       // for request id's. We only need to do this when enabled
00195       // it, after that the Transport Mux Strategy will make sure
00196       // that the rule is followed
00197       opdetails.request_id (this->tms ()->request_id ());
00198     }
00199 
00200   // We are going to pass on this request to the underlying messaging
00201   // layer. It should take care of this request
00202   return TAO_Transport::generate_request_header (opdetails, spec, msg);
00203 }

int TAO::SSLIOP::Transport::get_listen_point ( IIOP::ListenPointList &  listen_point_list,
TAO_Acceptor acceptor 
) [private]

Add the listen points in acceptor to the listen_point_list if this connection is in the same interface as that of the endpoints in the acceptor.

Definition at line 273 of file SSLIOP_Transport.cpp.

References ACE_ERROR_RETURN, ACE_TEXT(), ACE_INET_Addr::get_port_number(), ACE_Addr::get_type(), LM_ERROR, ACE_INET_Addr::set_port_number(), TAO::SSLIOP::Acceptor::ssl_component(), ACE_OS::strchr(), and CORBA::string_dup().

00276 {
00277   TAO::SSLIOP::Acceptor *ssliop_acceptor =
00278     dynamic_cast<TAO::SSLIOP::Acceptor *> (acceptor);
00279 
00280   if (ssliop_acceptor == 0)
00281     return -1;
00282 
00283   // Get the array of IIOP (not SSLIOP!) endpoints serviced by the
00284   // SSLIOP_Acceptor.
00285   const ACE_INET_Addr *endpoint_addr = ssliop_acceptor->endpoints ();
00286 
00287   // Get the count
00288   size_t const count = ssliop_acceptor->endpoint_count ();
00289 
00290   // The SSL port is stored in the SSLIOP::SSL component associated
00291   // with the SSLIOP_Acceptor.
00292   const ::SSLIOP::SSL &ssl = ssliop_acceptor->ssl_component ();
00293 
00294   // Get the local address of the connection
00295   ACE_INET_Addr local_addr;
00296   {
00297     if (this->connection_handler_->peer ().get_local_addr (local_addr) == -1)
00298       {
00299         ACE_ERROR_RETURN ((LM_ERROR,
00300                            ACE_TEXT ("(%P|%t) Could not resolve local host")
00301                            ACE_TEXT (" address in get_listen_point()\n")),
00302                         -1);
00303       }
00304 
00305   }
00306 
00307   // Note: Looks like there is no point in sending the list of
00308   // endpoints on interfaces on which this connection has not
00309   // been established. If this is wrong, please correct me.
00310   CORBA::String_var local_interface;
00311 
00312   // Get the hostname for the local address
00313   if (ssliop_acceptor->hostname (this->orb_core_,
00314                                  local_addr,
00315                                  local_interface.out ()) == -1)
00316     {
00317       ACE_ERROR_RETURN ((LM_ERROR,
00318                          ACE_TEXT ("(%P|%t) Could not resolve local host")
00319                          ACE_TEXT (" name \n")),
00320                         -1);
00321     }
00322 
00323 #if defined (ACE_HAS_IPV6)
00324   // If this is an IPv6 decimal linklocal address containing a scopeid than
00325   // remove the scopeid from the information being sent.
00326   const char *cp_scope = 0;
00327   if (local_addr.get_type () == PF_INET6 &&
00328         (cp_scope = ACE_OS::strchr (local_interface.in (), '%')) != 0)
00329     {
00330       CORBA::ULong len = cp_scope - local_interface.in ();
00331       local_interface[len] = '\0';
00332     }
00333 #endif /* ACE_HAS_IPV6 */
00334 
00335   for (size_t index = 0; index < count; ++index)
00336     {
00337       // Make sure port numbers are equal so the following comparison
00338       // only concerns the IP(v4/v6) address.
00339       local_addr.set_port_number (endpoint_addr[index].get_port_number ());
00340 
00341       if (local_addr == endpoint_addr[index])
00342         {
00343           // Get the count of the number of elements
00344           CORBA::ULong const len = listen_point_list.length ();
00345 
00346           // Increase the length by 1
00347           listen_point_list.length (len + 1);
00348 
00349           // We have the connection and the acceptor endpoint on the
00350           // same interface
00351           IIOP::ListenPoint & point = listen_point_list[len];
00352           point.host = CORBA::string_dup (local_interface.in ());
00353 
00354           // All endpoints, if more than one, serviced by the
00355           // SSLIOP_Acceptor should be listening on the same port (due
00356           // to the bind to the INADDR_ANY address).
00357           point.port = ssl.port;
00358         }
00359     }
00360 
00361   return 1;
00362 }

int TAO::SSLIOP::Transport::handle_input ( TAO_Resume_Handle rh,
ACE_Time_Value max_wait_time = 0 
) [virtual]

Overload of the handle_input () in the TAO_Transport class. This is required to set up the state guard. The thread-per-connection and wait on RW strategies call this handle_input ().

Reimplemented from TAO_Transport.

Definition at line 51 of file SSLIOP_Transport.cpp.

References TAO_Transport::handle_input().

00053 {
00054   int result = 0;
00055 
00056   // Set up the SSLIOP::Current object.
00057   TAO::SSLIOP::State_Guard ssl_state_guard (this->connection_handler_, result);
00058 
00059   if (result == -1)
00060     return -1;
00061 
00062   return TAO_Transport::handle_input (rh, max_wait_time);
00063 }

ssize_t TAO::SSLIOP::Transport::recv ( char *  buf,
size_t  len,
const ACE_Time_Value s = 0 
) [protected, virtual]

Read len bytes from into buf.

Implements TAO_Transport.

Definition at line 81 of file SSLIOP_Transport.cpp.

References ACE_DEBUG, ACE_TEXT(), connection_handler_, LM_DEBUG, ACE_Svc_Handler<, >::peer(), and TAO_debug_level.

00084 {
00085   ssize_t const n = this->connection_handler_->peer ().recv (buf,
00086                                                              len,
00087                                                              max_wait_time);
00088 
00089   // Most of the errors handling is common for
00090   // Now the message has been read
00091   if (n == -1 && TAO_debug_level > 4 && errno != ETIME)
00092     {
00093       ACE_DEBUG ((LM_DEBUG,
00094                   ACE_TEXT ("TAO (%P|%t) - SSLIOP_Transport[%d]::recv, ")
00095                   ACE_TEXT ("read failure - %m errno %d\n"),
00096                   this->id (),
00097                   errno));
00098     }
00099 
00100   // Error handling
00101   if (n == -1)
00102     {
00103       if (errno == EWOULDBLOCK)
00104         return 0;
00105 
00106       return -1;
00107     }
00108   // @@ What are the other error handling here??
00109   else if (n == 0)
00110     {
00111       return -1;
00112     }
00113 
00114   return n;
00115 }

ssize_t TAO::SSLIOP::Transport::send ( iovec *  iov,
int  iovcnt,
size_t &  bytes_transferred,
const ACE_Time_Value timeout = 0 
) [protected, virtual]

Write the complete Message_Block chain to the connection.

Implements TAO_Transport.

Definition at line 66 of file SSLIOP_Transport.cpp.

References connection_handler_, and ACE_Svc_Handler<, >::peer().

00070 {
00071   ssize_t const retval =
00072     this->connection_handler_->peer ().sendv (iov, iovcnt, max_wait_time);
00073 
00074   if (retval > 0)
00075     bytes_transferred = retval;
00076 
00077   return retval;
00078 }

int TAO::SSLIOP::Transport::send_message ( TAO_OutputCDR stream,
TAO_Stub stub = 0,
TAO_Message_Semantics  message_semantics = TAO_Transport::TAO_TWOWAY_REQUEST,
ACE_Time_Value max_time_wait = 0 
) [virtual]

Todo:
These methods IMHO should have more meaningful names. The names seem to indicate nothing.

Definition at line 138 of file SSLIOP_Transport.cpp.

References ACE_ERROR, ACE_TEXT(), ACE_OutputCDR::begin(), LM_ERROR, TAO_Transport::send_message_shared(), and TAO_debug_level.

00142 {
00143   // Format the message in the stream first
00144   if (this->messaging_object_->format_message (stream) != 0)
00145     return -1;
00146 
00147   // Strictly speaking, should not need to loop here because the
00148   // socket never gets set to a nonblocking mode ... some Linux
00149   // versions seem to need it though.  Leaving it costs little.
00150 
00151   // This guarantees to send all data (bytes) or return an error.
00152   ssize_t const n = this->send_message_shared (stub,
00153                                                message_semantics,
00154                                                stream.begin (),
00155                                                max_wait_time);
00156 
00157   if (n == -1)
00158     {
00159       if (TAO_debug_level)
00160         ACE_ERROR ((LM_ERROR,
00161                     ACE_TEXT ("TAO (%P|%t) - SSLIOP_Transport::send_message, ")
00162                     ACE_TEXT ("closing transport %d after fault %p\n"),
00163                     this->id (),
00164                     ACE_TEXT ("send_message ()\n")));
00165 
00166       return -1;
00167     }
00168 
00169   return 1;
00170 }

int TAO::SSLIOP::Transport::send_request ( TAO_Stub stub,
TAO_ORB_Core orb_core,
TAO_OutputCDR stream,
TAO_Message_Semantics  message_semantics,
ACE_Time_Value max_wait_time 
) [virtual]

Todo:
These methods IMHO should have more meaningful names. The names seem to indicate nothing.

Definition at line 118 of file SSLIOP_Transport.cpp.

References TAO_Transport::orb_core().

00123 {
00124   if (this->ws_->sending_request (orb_core, message_semantics) == -1)
00125     return -1;
00126 
00127   if (this->send_message (stream,
00128                           stub,
00129                           message_semantics,
00130                           max_wait_time) == -1)
00131 
00132     return -1;
00133 
00134   return 0;
00135 }

void TAO::SSLIOP::Transport::set_bidir_context_info ( TAO_Operation_Details opdetails  )  [private]

Set the Bidirectional context info in the service context list.

Definition at line 228 of file SSLIOP_Transport.cpp.

References TAO_Thread_Lane_Resources::acceptor_registry(), ACE_ERROR, TAO_Acceptor_Registry::begin(), TAO_Acceptor_Registry::end(), TAO_ORB_Core::lane_resources(), LM_ERROR, TAO_Transport::orb_core(), TAO_Operation_Details::request_service_context(), TAO_Service_Context::set_context(), and TAO_ENCAP_BYTE_ORDER.

00230 {
00231   // Get a handle on to the acceptor registry
00232   TAO_Acceptor_Registry &ar =
00233     this->orb_core ()->lane_resources ().acceptor_registry ();
00234 
00235   // Get the first acceptor in the registry
00236   TAO_AcceptorSetIterator acceptor = ar.begin ();
00237 
00238   IIOP::ListenPointList listen_point_list;
00239 
00240   for (;
00241        acceptor != ar.end ();
00242        acceptor++)
00243     {
00244       // Check whether it is a IIOP acceptor
00245       if ((*acceptor)->tag () == IOP::TAG_INTERNET_IOP)
00246         {
00247           if (this->get_listen_point (listen_point_list, *acceptor) == -1)
00248             {
00249               ACE_ERROR ((LM_ERROR,
00250                           "TAO (%P|%t) - SSLIOP_Transport::set_bidir_info, ",
00251                           "error getting listen_point \n"));
00252               return;
00253             }
00254         }
00255     }
00256 
00257   // We have the ListenPointList at this point. Create a output CDR
00258   // stream at this point
00259   TAO_OutputCDR cdr;
00260 
00261   // Marshall the information into the stream
00262   if ((cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) == 0)
00263       || (cdr << listen_point_list) == 0)
00264     return;
00265 
00266   // Add this info in to the svc_list
00267   opdetails.request_service_context ().set_context (IOP::BI_DIR_IIOP, cdr);
00268   return;
00269 }

int TAO::SSLIOP::Transport::tear_listen_point_list ( TAO_InputCDR cdr  )  [virtual]

Open teh service context list and process it.

Reimplemented from TAO_Transport.

Definition at line 206 of file SSLIOP_Transport.cpp.

References TAO_Transport::bidirectional_flag(), connection_handler_, TAO::SSLIOP::Connection_Handler::process_listen_point_list(), and ACE_InputCDR::reset_byte_order().

00207 {
00208   CORBA::Boolean byte_order;
00209   if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
00210     return -1;
00211 
00212   cdr.reset_byte_order (static_cast<int> (byte_order));
00213 
00214   IIOP::ListenPointList listen_list;
00215   if ((cdr >> listen_list) == 0)
00216     return -1;
00217 
00218   // As we have received a bidirectional information, set the flag to
00219   // 0
00220   this->bidirectional_flag (0);
00221 
00222   return this->connection_handler_->process_listen_point_list (listen_list);
00223 }


Member Data Documentation

Connection_Handler* TAO::SSLIOP::Transport::connection_handler_ [private]

The connection service handler used for accessing lower layer communication protocols.

Definition at line 138 of file SSLIOP_Transport.h.

Referenced by connection_handler_i(), event_handler_i(), recv(), send(), and tear_listen_point_list().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:48:59 2010 for TAO_SSLIOP by  doxygen 1.4.7