00001
00002
00003 #include "ace/INET_Addr.h"
00004 #include "tao/IIOP_Connection_Handler.h"
00005 #include "tao/IIOP_Transport.h"
00006 #include "tao/Transport_Selection_Guard.h"
00007 #include "tao/SystemException.h"
00008
00009 #if TAO_HAS_TRANSPORT_CURRENT == 1
00010
00011 #include "IIOP_Current_Impl.h"
00012
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015
00016 namespace TAO
00017 {
00018 namespace Transport
00019 {
00020
00021
00022
00023
00024
00025
00026
00027 TAO_IIOP_Connection_Handler*
00028 IIOP_Current_Impl::handler (void)
00029 {
00030 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00031 const TAO_Transport* t = this->transport ();
00032 if (t == 0)
00033 throw NoContext ();
00034
00035 TAO_Connection_Handler *ch = const_cast<TAO_Transport*>(t)->connection_handler ();
00036 if (ch == 0)
00037 throw NoContext ();
00038
00039 return dynamic_cast <TAO_IIOP_Connection_Handler*> (ch);
00040 #else
00041 throw ::CORBA::NO_IMPLEMENT ();
00042 #endif
00043 }
00044
00045
00046
00047
00048 IIOP_Current_Impl::IIOP_Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id)
00049 : Current_Impl (core, tss_slot_id)
00050 {
00051 }
00052
00053
00054
00055
00056 IIOP_Current_Impl::~IIOP_Current_Impl (void)
00057 {
00058 }
00059
00060 CORBA::Long
00061 IIOP_Current_Impl::id (void)
00062 {
00063 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00064
00065
00066 return (CORBA::Long) this->handler ()->get_handle ();
00067 #else
00068 throw ::CORBA::NO_IMPLEMENT ();
00069 #endif
00070 }
00071
00072 ::SSLIOP::Current_ptr
00073 IIOP_Current_Impl::ssliop_current (void)
00074 {
00075 throw ::CORBA::NO_IMPLEMENT ();
00076 }
00077
00078
00079 CORBA::Long
00080 IIOP_Current_Impl::remote_port (void)
00081 {
00082 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00083 TAO_IIOP_Connection_Handler *iiopch =
00084 this->handler ();
00085
00086 ACE_INET_Addr a;
00087 iiopch->peer ().get_remote_addr (a);
00088
00089 return a.get_port_number ();
00090 #else
00091 throw ::CORBA::NO_IMPLEMENT ();
00092 #endif
00093 }
00094
00095 char*
00096 IIOP_Current_Impl::remote_host (void)
00097 {
00098 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00099 TAO_IIOP_Connection_Handler *iiopch =
00100 this->handler ();
00101
00102 ACE_INET_Addr a;
00103 iiopch->peer ().get_remote_addr (a);
00104
00105 return CORBA::string_dup (a.get_host_addr ());
00106 #else
00107 throw ::CORBA::NO_IMPLEMENT ();
00108 #endif
00109 }
00110
00111 CORBA::Long
00112 IIOP_Current_Impl::local_port (void)
00113 {
00114 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00115 TAO_IIOP_Connection_Handler *iiopch =
00116 this->handler ();
00117
00118 ACE_INET_Addr a;
00119 iiopch->peer ().get_local_addr (a);
00120
00121 return a.get_port_number ();
00122 #else
00123 throw ::CORBA::NO_IMPLEMENT ();
00124 #endif
00125 }
00126
00127 char*
00128 IIOP_Current_Impl::local_host (void)
00129 {
00130 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00131 TAO_IIOP_Connection_Handler *iiopch =
00132 this->handler ();
00133
00134 ACE_INET_Addr a;
00135 iiopch->peer ().get_local_addr (a);
00136
00137 return CORBA::string_dup (a.get_host_addr ());
00138 #else
00139 throw ::CORBA::NO_IMPLEMENT ();
00140 #endif
00141 }
00142
00143 }
00144 }
00145
00146
00147 TAO_END_VERSIONED_NAMESPACE_DECL
00148
00149
00150 #endif