#include <DIOP_Connection_Handler.h>
Inheritance diagram for TAO_DIOP_Connection_Handler:


Public Member Functions | |
| TAO_DIOP_Connection_Handler (ACE_Thread_Manager *t=0) | |
| TAO_DIOP_Connection_Handler (TAO_ORB_Core *orb_core, CORBA::Boolean flag) | |
| Constructor. | |
| ~TAO_DIOP_Connection_Handler (void) | |
| Destructor. | |
| virtual int | open (void *) |
| virtual int | open_server (void) |
| int | close (u_long=0) |
| int | add_transport_to_cache (void) |
| Add ourselves to Cache. | |
| int | set_dscp_codepoint (CORBA::Boolean set_network_priority) |
| Set Diff-Serv codepoint on outgoing packets. | |
| virtual int | open_handler (void *) |
Event Handler overloads | |
| virtual int | resume_handler (void) |
| virtual int | close_connection (void) |
| virtual int | handle_input (ACE_HANDLE) |
| virtual int | handle_output (ACE_HANDLE) |
| virtual int | handle_close (ACE_HANDLE, ACE_Reactor_Mask) |
| virtual int | handle_timeout (const ACE_Time_Value ¤t_time, const void *act=0) |
The DIOP Additions | |
| ACE_HANDLE | get_handle (void) const |
| const ACE_INET_Addr & | addr (void) |
| void | addr (const ACE_INET_Addr &addr) |
| const ACE_INET_Addr & | local_addr (void) |
| void | local_addr (const ACE_INET_Addr &addr) |
| const ACE_INET_Addr & | server_addr (void) |
| void | server_addr (const ACE_INET_Addr &addr) |
| const ACE_SOCK_Dgram & | dgram (void) |
Protected Member Functions | |
TAO_Connection Handler overloads | |
| virtual int | release_os_resources (void) |
Protected Attributes | |
The DIOP Additions | |
| ACE_SOCK_Dgram | udp_socket_ |
| ACE_INET_Addr | addr_ |
| This is always the remote address. | |
| ACE_INET_Addr | local_addr_ |
| This is always the local address for the connector. | |
Private Attributes | |
| int | dscp_codepoint_ |
| Stores the type of service value. | |
The Connection handler which is common for the Acceptor and the Connector
Definition at line 49 of file DIOP_Connection_Handler.h.
|
|
Definition at line 30 of file DIOP_Connection_Handler.cpp. References ACE_ASSERT, IPDSFIELD_DSCP_DEFAULT, and TAO_DIOP_SVC_HANDLER.
00031 : TAO_DIOP_SVC_HANDLER (t, 0 , 0), 00032 TAO_Connection_Handler (0), 00033 dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2) 00034 { 00035 // This constructor should *never* get called, it is just here to 00036 // make the compiler happy: the default implementation of the 00037 // Creation_Strategy requires a constructor with that signature, we 00038 // don't use that implementation, but some (most?) compilers 00039 // instantiate it anyway. 00040 ACE_ASSERT (0); 00041 } |
|
||||||||||||
|
Constructor.
Definition at line 44 of file DIOP_Connection_Handler.cpp. References ACE_NEW, IPDSFIELD_DSCP_DEFAULT, TAO_DIOP_SVC_HANDLER, and TAO_Connection_Handler::transport().
00046 : TAO_DIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0), 00047 TAO_Connection_Handler (orb_core), 00048 dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2) 00049 { 00050 TAO_DIOP_Transport* specific_transport = 0; 00051 ACE_NEW (specific_transport, 00052 TAO_DIOP_Transport(this, orb_core, flag)); 00053 00054 // store this pointer (indirectly increment ref count) 00055 this->transport (specific_transport); 00056 } |
|
|
Destructor.
Definition at line 59 of file DIOP_Connection_Handler.cpp. References ACE_SOCK::close(), TAO_Connection_Handler::transport(), and udp_socket_.
00060 {
00061 delete this->transport ();
00062 this->udp_socket_.close ();
00063 }
|
|
|
Add ourselves to Cache.
|
|
|
Definition at line 81 of file DIOP_Connection_Handler.cpp.
00082 {
00083 this->addr_ = addr;
00084 }
|
|
|
Definition at line 74 of file DIOP_Connection_Handler.cpp. Referenced by TAO_DIOP_Connector::make_connection(), TAO_DIOP_Transport::recv(), and TAO_DIOP_Transport::send().
00075 {
00076 return this->addr_;
00077 }
|
|
|
Close called by the Acceptor or Connector when connection establishment fails. Reimplemented from ACE_Svc_Handler<, >. Definition at line 251 of file DIOP_Connection_Handler.cpp. References TAO_Connection_Handler::close_handler().
00252 {
00253 return this->close_handler ();
00254 }
|
|
|
Implements TAO_Connection_Handler. Definition at line 202 of file DIOP_Connection_Handler.cpp. References TAO_Connection_Handler::close_connection_eh(). Referenced by handle_output().
00203 {
00204 return this->close_connection_eh (this);
00205 }
|
|
|
Definition at line 102 of file DIOP_Connection_Handler.cpp. References udp_socket_. Referenced by TAO_DIOP_Acceptor::open_i(), TAO_DIOP_Transport::recv(), TAO_DIOP_Transport::send(), and set_dscp_codepoint().
00103 {
00104 return this->udp_socket_;
00105 }
|
|
|
Reimplemented from ACE_Svc_Handler<, >. Definition at line 67 of file DIOP_Connection_Handler.cpp. References ACE_IPC_SAP::get_handle(), and udp_socket_. Referenced by TAO_DIOP_Connector::make_connection().
00068 {
00069 return this->udp_socket_.get_handle ();
00070 }
|
|
||||||||||||
|
Reimplemented from ACE_Svc_Handler<, >. Definition at line 239 of file DIOP_Connection_Handler.cpp.
00241 {
00242 // No asserts here since the handler is registered with the Reactor
00243 // and the handler ownership is given to the Reactor. When the
00244 // Reactor closes, it will call handle_close() on the handler. It
00245 // is however important to overwrite handle_close() to do nothing
00246 // since the base class does too much.
00247 return 0;
00248 }
|
|
|
Implements TAO_Connection_Handler. Definition at line 208 of file DIOP_Connection_Handler.cpp. References TAO_Connection_Handler::handle_input_eh().
00209 {
00210 return this->handle_input_eh (h, this);
00211 }
|
|
|
Reimplemented from ACE_Event_Handler. Definition at line 214 of file DIOP_Connection_Handler.cpp. References close_connection(), and TAO_Connection_Handler::handle_output_eh().
00215 {
00216 int result =
00217 this->handle_output_eh (handle, this);
00218
00219 if (result == -1)
00220 {
00221 this->close_connection ();
00222 return 0;
00223 }
00224
00225 return result;
00226 }
|
|
||||||||||||
|
Reimplemented from ACE_Svc_Handler<, >. Definition at line 229 of file DIOP_Connection_Handler.cpp.
00231 {
00232 // We don't use this upcall from the Reactor. However, we should
00233 // override this since the base class returns -1 which will result
00234 // in handle_close() getting called.
00235 return 0;
00236 }
|
|
|
Definition at line 95 of file DIOP_Connection_Handler.cpp.
00096 {
00097 local_addr_ = addr;
00098 }
|
|
|
Definition at line 88 of file DIOP_Connection_Handler.cpp. Referenced by TAO_DIOP_Connector::make_connection(), and TAO_DIOP_Acceptor::open_i().
00089 {
00090 return local_addr_;
00091 }
|
|
|
Called by the when the handler is completely connected. Argument is unused. Reimplemented from ACE_Svc_Handler<, >. Definition at line 115 of file DIOP_Connection_Handler.cpp. References ACE_CATCHANY, ACE_CHECK_RETURN, ACE_DEBUG, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_TRY, ACE_TRY_CHECK, TAO_Protocols_Hooks::client_protocol_properties_at_orb_level(), ACE_INET_Addr::get_port_number(), TAO_ORB_Core::get_protocols_hooks(), LM_DEBUG, ACE_SOCK_Dgram::open(), TAO_Transport::opened_as(), TAO_Connection_Handler::orb_core(), TAO_Transport::post_open(), TAO_Protocols_Hooks::server_protocol_properties_at_orb_level(), TAO_LF_Event::state_changed(), TAO_debug_level, TAO_Connection_Handler::transport(), and udp_socket_. Referenced by TAO_DIOP_Connector::make_connection(), and open_handler().
00116 {
00117 // Currently, the DIOP properties are not used. This code is here
00118 // for consistency with other protocols.
00119 TAO_DIOP_Protocol_Properties protocol_properties;
00120
00121 TAO_Protocols_Hooks *tph =
00122 this->orb_core ()->get_protocols_hooks ();
00123
00124 bool client =
00125 this->transport ()->opened_as () == TAO::TAO_CLIENT_ROLE;
00126
00127 ACE_DECLARE_NEW_CORBA_ENV;
00128
00129 ACE_TRY
00130 {
00131 if (client)
00132 {
00133 tph->client_protocol_properties_at_orb_level (
00134 protocol_properties
00135 ACE_ENV_ARG_PARAMETER);
00136 ACE_TRY_CHECK;
00137 }
00138 else
00139 {
00140 tph->server_protocol_properties_at_orb_level (
00141 protocol_properties
00142 ACE_ENV_ARG_PARAMETER);
00143 ACE_TRY_CHECK;
00144 }
00145 }
00146 ACE_CATCHANY
00147 {
00148 return -1;
00149 }
00150 ACE_ENDTRY;
00151 ACE_CHECK_RETURN (-1);
00152
00153 this->udp_socket_.open (this->local_addr_);
00154
00155 if (TAO_debug_level > 5)
00156 {
00157 ACE_DEBUG ((LM_DEBUG,
00158 ACE_TEXT("\nTAO (%P|%t) TAO_DIOP_Connection_Handler::open -")
00159 ACE_TEXT("listening on: <%s:%u>\n"),
00160 ACE_TEXT_CHAR_TO_TCHAR (this->local_addr_.get_host_name ()),
00161 this->local_addr_.get_port_number ()));
00162 }
00163
00164 // Set that the transport is now connected, if fails we return -1
00165 // Use C-style cast b/c otherwise we get warnings on lots of
00166 // compilers
00167 if (!this->transport ()->post_open ((size_t) this->get_handle ()))
00168 return -1;
00169
00170 this->state_changed (TAO_LF_Event::LFS_SUCCESS,
00171 this->orb_core ()->leader_follower ());
00172
00173 return 0;
00174 }
|
|
|
Connection_Handler overloads Implements TAO_Connection_Handler. Definition at line 109 of file DIOP_Connection_Handler.cpp.
00110 {
00111 return this->open (v);
00112 }
|
|
|
Definition at line 177 of file DIOP_Connection_Handler.cpp. References ACE_DEBUG, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_INET_Addr::get_port_number(), TAO_Transport::id(), LM_DEBUG, ACE_SOCK_Dgram::open(), TAO_debug_level, TAO_Connection_Handler::transport(), and udp_socket_. Referenced by TAO_DIOP_Acceptor::open_i().
00178 {
00179 this->udp_socket_.open (this->local_addr_);
00180 if( TAO_debug_level > 5)
00181 {
00182 ACE_DEBUG ((LM_DEBUG,
00183 ACE_TEXT("\nTAO (%P|%t) TAO_DIOP_Connection_Handler::open_server -")
00184 ACE_TEXT("listening on %s:%d\n"),
00185 ACE_TEXT_CHAR_TO_TCHAR (this->local_addr_.get_host_name ()),
00186 this->local_addr_.get_port_number ()
00187 ));
00188 }
00189
00190 this->transport ()->id ((size_t) this->get_handle ());
00191
00192 return 0;
00193 }
|
|
|
Reimplemented from TAO_Connection_Handler. Definition at line 257 of file DIOP_Connection_Handler.cpp. References ACE_Svc_Handler<, >::peer().
00258 {
00259 return this->peer ().close ();
00260 }
|
|
|
Reimplemented from ACE_Event_Handler. Definition at line 196 of file DIOP_Connection_Handler.cpp.
00197 {
00198 return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER;
00199 }
|
|
|
|
|
|
|
|
|
Set Diff-Serv codepoint on outgoing packets.
Reimplemented from TAO_Connection_Handler. Definition at line 263 of file DIOP_Connection_Handler.cpp. References ACE_DEBUG, dgram(), TAO_Protocols_Hooks::get_dscp_codepoint(), TAO_ORB_Core::get_protocols_hooks(), IPDSFIELD_DSCP_DEFAULT, LM_DEBUG, TAO_Connection_Handler::orb_core(), ACE_SOCK::set_option(), and TAO_debug_level.
00264 {
00265 int tos = IPDSFIELD_DSCP_DEFAULT << 2;
00266
00267 if (set_network_priority)
00268 {
00269 TAO_Protocols_Hooks *tph =
00270 this->orb_core ()->get_protocols_hooks ();
00271
00272 CORBA::Long codepoint =
00273 tph->get_dscp_codepoint ();
00274
00275 tos = (int)(codepoint) << 2;
00276 }
00277
00278 if (tos != this->dscp_codepoint_)
00279 {
00280 int result = this->dgram ().set_option (IPPROTO_IP,
00281 IP_TOS,
00282 (int *) &tos ,
00283 (int) sizeof (tos));
00284
00285 if (TAO_debug_level)
00286 {
00287 ACE_DEBUG ((LM_DEBUG,
00288 "TAO (%P|%t) - DIOP_Connection_Handler::"
00289 "set_dscp_codepoint -> dscp: %x; result: %d; %s\n",
00290 tos,
00291 result,
00292 result == -1 ? "try running as superuser" : ""));
00293 }
00294
00295 // On successful setting of TOS field.
00296 if (result == 0)
00297 this->dscp_codepoint_ = tos;
00298
00299 }
00300
00301 return 0;
00302 }
|
|
|
This is always the remote address.
Definition at line 149 of file DIOP_Connection_Handler.h. |
|
|
Stores the type of service value.
Definition at line 158 of file DIOP_Connection_Handler.h. |
|
|
This is always the local address for the connector.
Definition at line 152 of file DIOP_Connection_Handler.h. |
|
|
Definition at line 146 of file DIOP_Connection_Handler.h. Referenced by dgram(), get_handle(), open(), open_server(), and ~TAO_DIOP_Connection_Handler(). |
1.3.6