00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file IIOP_Endpoint.h 00006 * 00007 * $Id: IIOP_Endpoint.h 73791 2006-07-27 20:54:56Z wotte $ 00008 * 00009 IIOP implementation of PP Framework Endpoint interface. 00010 * 00011 * @author Marina Spivak <marina@cs.wustl.edu> 00012 */ 00013 //============================================================================= 00014 00015 #ifndef TAO_IIOP_ENDPOINT_H 00016 #define TAO_IIOP_ENDPOINT_H 00017 00018 #include /**/ "ace/pre.h" 00019 00020 #include "tao/orbconf.h" 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 # pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0) 00027 00028 #include "tao/CORBA_String.h" 00029 #include "tao/IIOP_EndpointsC.h" 00030 #include "tao/Endpoint.h" 00031 00032 #include "ace/INET_Addr.h" 00033 00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00035 00036 class TAO_IIOP_Connection_Handler; 00037 00038 /** 00039 * @class TAO_IIOP_Endpoint 00040 * 00041 * @brief TAO_IIOP_Endpoint 00042 * 00043 * IIOP-specific implementation of PP Framework Endpoint interface. 00044 */ 00045 class TAO_Export TAO_IIOP_Endpoint : public TAO_Endpoint 00046 { 00047 public: 00048 00049 //@@ TAO_ENDPOINT_SPL_PUBLIC_METHODS_COPY_HOOK_START 00050 00051 // @todo Lose these friends! 00052 friend class TAO_IIOP_Profile; 00053 friend class TAO_SSLIOP_Profile; 00054 00055 // = Initialization and termination methods. 00056 00057 /// Default constructor. 00058 TAO_IIOP_Endpoint (void); 00059 00060 /// Constructor. This is the most efficient constructor since it 00061 /// does not require any address resolution processing. 00062 TAO_IIOP_Endpoint (const char *host, 00063 CORBA::UShort port, 00064 const ACE_INET_Addr &addr, 00065 CORBA::Short priority = TAO_INVALID_PRIORITY); 00066 00067 /// Constructor. 00068 TAO_IIOP_Endpoint (const ACE_INET_Addr &addr, 00069 int use_dotted_decimal_addresses); 00070 00071 /// Constructor. This constructor is used when decoding endpoints. 00072 TAO_IIOP_Endpoint (const char *host, 00073 CORBA::UShort port, 00074 CORBA::Short priority); 00075 00076 00077 //@@ TAO_ENDPOINT_SPL_PUBLIC_METHODS_COPY_HOOK_END 00078 00079 /// Destructor. 00080 ~TAO_IIOP_Endpoint (void); 00081 00082 00083 // = Implementation of abstract TAO_Endpoint methods. See 00084 // Endpoint.h for their documentation. 00085 00086 virtual TAO_Endpoint *next (void); 00087 00088 /** 00089 * Return the next endpoint in the list, but use protocol-specific 00090 * filtering to constrain the value. The orb core is needed to supply 00091 * any sort of filter arguments, and the root endpoint is needed in case 00092 * the algorithm needs to rewind. If the supplied root is 0, then this 00093 * is assumed to be the candidate next endpoint. 00094 * 00095 * To use this, the caller starts off the change with root == 0. This 00096 * is a bit of a violation in logic, a more correct implementation would 00097 * accept this == 0 and a non-null root. 00098 * To do iteration using next_filtered, do: 00099 * for (TAO_Endpoint *ep = root_endpoint->next_filtered (orb_core, 0); 00100 * ep != 0; 00101 * ep = ep->next_filtered(orb_core, root_endpoint)) { } 00102 */ 00103 virtual TAO_Endpoint *next_filtered (TAO_ORB_Core *, TAO_Endpoint *root); 00104 00105 virtual int addr_to_string (char *buffer, size_t length); 00106 00107 /// Makes a copy of @c this 00108 virtual TAO_Endpoint *duplicate (void); 00109 00110 /// Return true if this endpoint is equivalent to @a other_endpoint. Two 00111 /// endpoints are equivalent if their port and host are the same. 00112 virtual CORBA::Boolean is_equivalent (const TAO_Endpoint *other_endpoint); 00113 00114 /// Return a hash value for this object. 00115 virtual CORBA::ULong hash (void); 00116 00117 // = IIOP_Endpoint-specific methods. 00118 00119 /* 00120 * Hook to copy only the non virtual concrete methods implemented 00121 * in this class to the derived class in the specialization. 00122 */ 00123 //@@ TAO_ENDPOINT_SPL_PUBLIC_METHODS_COPY_HOOK_START 00124 00125 /// Return a reference to the <object_addr>. 00126 const ACE_INET_Addr &object_addr (void) const; 00127 00128 /// Return a pointer to the host string. This object maintains 00129 /// ownership of this string. 00130 const char *host (void) const; 00131 00132 /// Copy the string <h> into <host_> and return the resulting pointer. 00133 /// This object maintains ownership of this string. 00134 const char *host (const char *h); 00135 00136 /// Return the port number. 00137 CORBA::UShort port (void) const; 00138 00139 /// Set the port number. 00140 CORBA::UShort port (CORBA::UShort p); 00141 00142 /// Do we have a preferred local network for the target? 00143 bool is_preferred_network (void) const; 00144 00145 /// Return the preferred network if any. 00146 const char *preferred_network (void) const; 00147 00148 #if defined (ACE_HAS_IPV6) 00149 /// Does the host string represent an IPv6 decimal address. 00150 bool is_ipv6_decimal (void) const; 00151 #endif /* ACE_HAS_IPV6 */ 00152 00153 //@@ TAO_ENDPOINT_SPL_PUBLIC_METHODS_COPY_HOOK_END 00154 00155 00156 /// Need to have an assignment operator since the IIOP_Profile class may 00157 /// have to reorder its list of endpoints based on filtering by the EndpointPolicy. 00158 TAO_IIOP_Endpoint & operator= (const TAO_IIOP_Endpoint& other); 00159 00160 private: 00161 TAO_IIOP_Endpoint *next_filtered_i (TAO_IIOP_Endpoint *root, 00162 bool ipv6_only, 00163 bool prefer_ipv6, 00164 bool want_ipv6); 00165 00166 00167 //@@ TAO_ENDPOINT_SPL_PRIVATE_DATA_COPY_HOOK_START 00168 00169 /// Helper method for setting INET_Addr. 00170 int set (const ACE_INET_Addr &addr, 00171 int use_dotted_decimal_addresses); 00172 00173 /// Helper method for object_addr () call. 00174 void object_addr_i (void) const; 00175 00176 /// Generate preferred interfaces from the options passed in by the 00177 /// user. 00178 CORBA::ULong preferred_interfaces (const char* csvPreferred, bool enforce); 00179 00180 /// Chain a new duplicate of ourself with the specified 00181 /// local preferred interface. 00182 TAO_IIOP_Endpoint* add_local_endpoint(TAO_IIOP_Endpoint* ep, const char* local); 00183 00184 /// Canonical copy constructor 00185 /** 00186 * In private section to prevent clients from invoking this 00187 * accidentally. Clients should only use duplicate () to make a depp 00188 * copy 00189 */ 00190 TAO_IIOP_Endpoint (const TAO_IIOP_Endpoint &); 00191 00192 private: 00193 00194 /// String representing the host name. 00195 CORBA::String_var host_; 00196 00197 /// TCP port number. 00198 CORBA::UShort port_; 00199 00200 #if defined (ACE_HAS_IPV6) 00201 /// Does the host string represent an IPv6 decimal address. 00202 bool is_ipv6_decimal_; 00203 #endif /* ACE_HAS_IPV6 */ 00204 00205 /// Is this endpoint created encodable as part of the IOR? 00206 bool is_encodable_; 00207 00208 /// Flag to indicate if the address has been resolved and set. 00209 mutable bool object_addr_set_; 00210 00211 /// Cached instance of ACE_INET_Addr for use in making 00212 /// invocations, etc. 00213 mutable ACE_INET_Addr object_addr_; 00214 00215 /// Preferred path for this endpoint. 00216 TAO::IIOP_Endpoint_Info preferred_path_; 00217 00218 /// IIOP Endpoints can be stringed into a list. Return the next 00219 /// endpoint in the list, if any. 00220 TAO_IIOP_Endpoint *next_; 00221 00222 //@@ TAO_ENDPOINT_SPL_PRIVATE_DATA_COPY_HOOK_END 00223 }; 00224 00225 TAO_END_VERSIONED_NAMESPACE_DECL 00226 00227 #if defined (__ACE_INLINE__) 00228 # include "tao/IIOP_Endpoint.inl" 00229 #endif /* __ACE_INLINE__ */ 00230 00231 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */ 00232 00233 #include /**/ "ace/post.h" 00234 #endif /* TAO_IIOP_PROFILE_H */