Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / TransportCurrent / IIOP_Current_Impl.cpp
blobbb4bec3ecc98994681d176b16a69360a4a738b55
1 #include "ace/INET_Addr.h"
2 #include "ace/Truncate.h"
3 #include "tao/IIOP_Connection_Handler.h"
4 #include "tao/IIOP_Transport.h"
5 #include "tao/Transport_Selection_Guard.h"
6 #include "tao/SystemException.h"
8 #if TAO_HAS_TRANSPORT_CURRENT == 1
10 #include "IIOP_Current_Impl.h"
12 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
15 namespace TAO
17 namespace Transport
19 /// Obtains the IIOP_Connection_Handler associated with the
20 /// Transport. Will throw NoContext if the (selected) transport
21 /// () == 0, or if transport->connection_handler () == 0. Will
22 /// throw NoContext, if no transport has been selected yet.
24 TAO_IIOP_Connection_Handler*
25 IIOP_Current_Impl::handler ()
27 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
28 const TAO_Transport* t = this->transport ();
29 if (t == 0)
30 throw NoContext ();
32 TAO_Connection_Handler *ch = const_cast<TAO_Transport*>(t)->connection_handler ();
33 if (ch == 0)
34 throw NoContext ();
36 // Make sure that this connection handler is for IIOP. This
37 // implementation is not intended to operate under SSLIOP.
38 TAO_IIOP_Connection_Handler* iiop_ch =
39 dynamic_cast <TAO_IIOP_Connection_Handler*> (ch);
40 if (iiop_ch == 0)
41 throw NoContext ();
43 return iiop_ch;
44 #else
45 throw ::CORBA::NO_IMPLEMENT ();
46 #endif
50 /// Ctor
52 IIOP_Current_Impl::IIOP_Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id)
53 : Current_Impl (core, tss_slot_id)
58 /// Dtor
60 IIOP_Current_Impl::~IIOP_Current_Impl ()
64 CORBA::Long
65 IIOP_Current_Impl::id ()
67 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
68 // Need to use cast to pacify windows compilers complaining
69 // about the implicit HANDLE -> CORBA::Long conversion.
70 return ACE_Utils::truncate_cast<CORBA::Long> ((intptr_t)this->handler ()->get_handle ());
71 #else
72 throw ::CORBA::NO_IMPLEMENT ();
73 #endif
76 ::SSLIOP::Current_ptr
77 IIOP_Current_Impl::ssliop_current ()
79 throw ::CORBA::NO_IMPLEMENT ();
83 CORBA::Long
84 IIOP_Current_Impl::remote_port ()
86 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
87 TAO_IIOP_Connection_Handler *iiopch =
88 this->handler ();
90 ACE_INET_Addr a;
91 iiopch->peer ().get_remote_addr (a);
93 return a.get_port_number ();
94 #else
95 throw ::CORBA::NO_IMPLEMENT ();
96 #endif
99 char*
100 IIOP_Current_Impl::remote_host ()
102 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
103 TAO_IIOP_Connection_Handler *iiopch =
104 this->handler ();
106 ACE_INET_Addr a;
107 iiopch->peer ().get_remote_addr (a);
109 return CORBA::string_dup (a.get_host_addr ());
110 #else
111 throw ::CORBA::NO_IMPLEMENT ();
112 #endif
115 CORBA::Long
116 IIOP_Current_Impl::local_port ()
118 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
119 TAO_IIOP_Connection_Handler *iiopch =
120 this->handler ();
122 ACE_INET_Addr a;
123 iiopch->peer ().get_local_addr (a);
125 return a.get_port_number ();
126 #else
127 throw ::CORBA::NO_IMPLEMENT ();
128 #endif
131 char*
132 IIOP_Current_Impl::local_host ()
134 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
135 TAO_IIOP_Connection_Handler *iiopch =
136 this->handler ();
138 ACE_INET_Addr a;
139 iiopch->peer ().get_local_addr (a);
141 return CORBA::string_dup (a.get_host_addr ());
142 #else
143 throw ::CORBA::NO_IMPLEMENT ();
144 #endif
151 TAO_END_VERSIONED_NAMESPACE_DECL
154 #endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */