3 //=============================================================================
5 * @file IIOP_Endpoint.h
7 * IIOP implementation of PP Framework Endpoint interface.
9 * @author Marina Spivak <marina@cs.wustl.edu>
11 //=============================================================================
13 #ifndef TAO_IIOP_ENDPOINT_H
14 #define TAO_IIOP_ENDPOINT_H
16 #include /**/ "ace/pre.h"
18 #include "tao/orbconf.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
26 #include "tao/CORBA_String.h"
27 #include "tao/IIOP_EndpointsC.h"
28 #include "tao/Endpoint.h"
30 #include "ace/INET_Addr.h"
31 #include "ace/Vector_T.h"
33 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
35 class TAO_IIOP_Connection_Handler
;
36 class TAO_IIOP_Profile
;
39 * @class TAO_IIOP_Endpoint
41 * @brief TAO_IIOP_Endpoint
43 * IIOP-specific implementation of PP Framework Endpoint interface.
45 class TAO_Export TAO_IIOP_Endpoint
: public TAO_Endpoint
48 // @todo Lose these friends!
49 friend class TAO_IIOP_Profile
;
50 friend class TAO_SSLIOP_Profile
;
52 /// Default constructor.
55 /// Constructor. This is the most efficient constructor since it
56 /// does not require any address resolution processing.
57 TAO_IIOP_Endpoint (const char *host
,
59 const ACE_INET_Addr
&addr
,
60 CORBA::Short priority
= TAO_INVALID_PRIORITY
);
63 TAO_IIOP_Endpoint (const ACE_INET_Addr
&addr
,
64 int use_dotted_decimal_addresses
);
66 /// Constructor. This constructor is used when decoding endpoints.
67 TAO_IIOP_Endpoint (const char *host
,
69 CORBA::Short priority
);
72 ~TAO_IIOP_Endpoint () = default;
74 // = Implementation of abstract TAO_Endpoint methods. See
75 // Endpoint.h for their documentation.
77 virtual TAO_Endpoint
*next ();
80 * Return the next endpoint in the list, but use protocol-specific
81 * filtering to constrain the value. The orb core is needed to supply
82 * any sort of filter arguments, and the root endpoint is needed in case
83 * the algorithm needs to rewind. If the supplied root is 0, then this
84 * is assumed to be the candidate next endpoint.
86 * To use this, the caller starts off the change with root == 0. This
87 * is a bit of a violation in logic, a more correct implementation would
88 * accept this == 0 and a non-null root.
89 * To do iteration using next_filtered, do:
90 * for (TAO_Endpoint *ep = root_endpoint->next_filtered (orb_core, 0);
92 * ep = ep->next_filtered(orb_core, root_endpoint)) { }
94 virtual TAO_Endpoint
*next_filtered (TAO_ORB_Core
*, TAO_Endpoint
*root
);
96 virtual int addr_to_string (char *buffer
, size_t length
);
98 /// Makes a copy of @c this
99 virtual TAO_Endpoint
*duplicate ();
101 /// Return true if this endpoint is equivalent to @a other_endpoint. Two
102 /// endpoints are equivalent if their port and host are the same.
103 virtual CORBA::Boolean
is_equivalent (const TAO_Endpoint
*other_endpoint
);
105 /// Return a hash value for this object.
106 virtual CORBA::ULong
hash ();
108 // = IIOP_Endpoint-specific methods.
110 /// Return a reference to the <object_addr>.
111 const ACE_INET_Addr
&object_addr () const;
113 /// Return a pointer to the host string. This object maintains
114 /// ownership of this string.
115 const char *host () const;
117 /// Copy the string @a h into <host_> and return the resulting pointer.
118 /// This object maintains ownership of this string.
119 const char *host (const char *h
);
121 /// Return the port number.
122 CORBA::UShort
port () const;
124 /// Set the port number.
125 CORBA::UShort
port (CORBA::UShort p
);
127 /// Do we have a preferred local network for the target?
128 bool is_preferred_network () const;
130 /// Return the preferred network if any.
131 const char *preferred_network () const;
133 #if defined (ACE_HAS_IPV6)
134 /// Does the host string represent an IPv6 decimal address.
135 bool is_ipv6_decimal () const;
136 #endif /* ACE_HAS_IPV6 */
138 /// Need to have an assignment operator since the IIOP_Profile class may
139 /// have to reorder its list of endpoints based on filtering by the EndpointPolicy.
140 TAO_IIOP_Endpoint
& operator= (const TAO_IIOP_Endpoint
& other
);
142 /// Given a comma separated list of preferred interface directives, which
143 /// are of the form <wild_remote>=<wild_local>, this function will retrieve
144 /// the list of preferred local ip addresses by matching wild_local against
145 /// the list of all local ip interfaces, for any directive where wild_remote
146 /// matches the host from our endpoint.
147 static void find_preferred_interfaces (const ACE_CString
& host
,
148 const ACE_CString
& csvPreferred
,
149 ACE_Vector
<ACE_CString
>& preferred
);
152 TAO_IIOP_Endpoint
*next_filtered_i (TAO_IIOP_Endpoint
*root
,
157 /// Helper method for setting INET_Addr.
158 int set (const ACE_INET_Addr
&addr
,
159 int use_dotted_decimal_addresses
);
161 /// Helper method for object_addr () call.
162 void object_addr_i () const;
164 /// Generate preferred interfaces from the options passed in by the
166 CORBA::ULong
preferred_interfaces (const char *csvPreferred
,
168 TAO_IIOP_Profile
&profile
);
170 /// Chain a new duplicate of ourself with the specified
171 /// local preferred interface.
172 TAO_IIOP_Endpoint
*add_local_endpoint (TAO_IIOP_Endpoint
*ep
,
174 TAO_IIOP_Profile
&profile
);
176 /// Canonical copy constructor
178 * In private section to prevent clients from invoking this
179 * accidentally. Clients should only use duplicate () to make a deep
182 TAO_IIOP_Endpoint (const TAO_IIOP_Endpoint
&);
185 /// String representing the host name.
186 CORBA::String_var host_
;
191 #if defined (ACE_HAS_IPV6)
192 /// Does the host string represent an IPv6 decimal address.
193 bool is_ipv6_decimal_
;
194 #endif /* ACE_HAS_IPV6 */
196 /// Is this endpoint created encodable as part of the IOR?
199 /// Flag to indicate if the address has been resolved and set.
200 mutable bool object_addr_set_
;
202 /// Cached instance of ACE_INET_Addr for use in making
203 /// invocations, etc.
204 mutable ACE_INET_Addr object_addr_
;
206 /// Preferred path for this endpoint.
207 TAO::IIOP_Endpoint_Info preferred_path_
;
209 /// IIOP Endpoints can be strung into a list. Return the next
210 /// endpoint in the list, if any.
211 TAO_IIOP_Endpoint
*next_
;
214 TAO_END_VERSIONED_NAMESPACE_DECL
216 #if defined (__ACE_INLINE__)
217 # include "tao/IIOP_Endpoint.inl"
218 #endif /* __ACE_INLINE__ */
220 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */
222 #include /**/ "ace/post.h"
223 #endif /* TAO_IIOP_PROFILE_H */