00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file IIOP_Acceptor.h 00006 * 00007 * IIOP_Acceptor.h,v 1.64 2006/06/01 12:44:28 jwillemsen Exp 00008 * 00009 * IIOP specific acceptor processing 00010 * 00011 * 00012 * @author Fred Kuhns <fredk@cs.wustl.edu> 00013 * @author Ossama Othman <ossama@uci.edu> 00014 */ 00015 //============================================================================= 00016 00017 00018 #ifndef TAO_IIOP_ACCEPTOR_H 00019 #define TAO_IIOP_ACCEPTOR_H 00020 00021 #include /**/ "ace/pre.h" 00022 00023 #include "tao/orbconf.h" 00024 00025 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00026 # pragma once 00027 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00028 00029 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0) 00030 00031 #include "tao/Transport_Acceptor.h" 00032 #include "tao/IIOP_Connection_Handler.h" 00033 #include "tao/Acceptor_Impl.h" 00034 #include "tao/GIOP_Message_Version.h" 00035 00036 #include "ace/SOCK_Acceptor.h" 00037 #include "ace/Acceptor.h" 00038 00039 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00040 00041 /** 00042 * @class TAO_IIOP_Acceptor 00043 * 00044 * @brief TAO_IIOP_Acceptor 00045 * 00046 * The IIOP-specific bridge class for the concrete acceptor. 00047 */ 00048 class TAO_Export TAO_IIOP_Acceptor : public TAO_Acceptor 00049 { 00050 public: 00051 00052 /* 00053 * Hook that marks begining of all concrete i.e. non virtual 00054 * methods implemented in IIOP_Acceptor class. 00055 */ 00056 //@@ TAO_ACCEPTOR_SPL_CONCRETE_METHODS_COPY_HOOK_START 00057 00058 /// Constructor. 00059 TAO_IIOP_Acceptor (CORBA::Boolean flag = false); 00060 00061 /// Destructor. 00062 ~TAO_IIOP_Acceptor (void); 00063 00064 /// @@ Helper method for the implementation repository, should go 00065 /// away 00066 const ACE_INET_Addr& address (void) const; 00067 00068 /// Returns the array of endpoints in this acceptor 00069 const ACE_INET_Addr *endpoints (void); 00070 00071 /// Returns address for default endpoint 00072 const ACE_INET_Addr& default_address (void) const; 00073 00074 /// Set address for default endpoint 00075 void set_default_address (const ACE_INET_Addr& addr); 00076 00077 typedef ACE_Strategy_Acceptor<TAO_IIOP_Connection_Handler, ACE_SOCK_ACCEPTOR> BASE_ACCEPTOR; 00078 typedef TAO_Creation_Strategy<TAO_IIOP_Connection_Handler> CREATION_STRATEGY; 00079 typedef TAO_Concurrency_Strategy<TAO_IIOP_Connection_Handler> CONCURRENCY_STRATEGY; 00080 typedef TAO_Accept_Strategy<TAO_IIOP_Connection_Handler, ACE_SOCK_ACCEPTOR> ACCEPT_STRATEGY; 00081 00082 //@@ TAO_ACCEPTOR_SPL_CONCRETE_METHODS_COPY_HOOK_END 00083 00084 /** 00085 * The TAO_Acceptor methods, check the documentation in 00086 * Transport_Acceptor.h for details. 00087 */ 00088 virtual int open (TAO_ORB_Core *orb_core, 00089 ACE_Reactor *reactor, 00090 int version_major, 00091 int version_minor, 00092 const char *address, 00093 const char *options = 0); 00094 virtual int open_default (TAO_ORB_Core *orb_core, 00095 ACE_Reactor *reactor, 00096 int version_major, 00097 int version_minor, 00098 const char *options = 0); 00099 virtual int close (void); 00100 virtual int create_profile (const TAO::ObjectKey &object_key, 00101 TAO_MProfile &mprofile, 00102 CORBA::Short priority); 00103 virtual int is_collocated (const TAO_Endpoint *endpoint); 00104 virtual CORBA::ULong endpoint_count (void); 00105 00106 virtual int object_key (IOP::TaggedProfile &profile, 00107 TAO::ObjectKey &key); 00108 00109 //@@ TAO_ACCEPTOR_SPL_CONCRETE_METHODS_COPY_HOOK_START 00110 /** 00111 * Set the host name for the given addr. 00112 * A hostname may be forced by using specified_hostname. This 00113 * is useful if the given address corresponds to more than one 00114 * hostname and the desired one cannot be determined in any 00115 * other way. 00116 * This method is used both when constructing IOR endpoints and LPL 00117 * (listen point lists). 00118 * 00119 * The algorithm used is: 00120 * - If hostname_in_ior_ has been set, it is used "as is"; 00121 * - else if use_dotted_decimal_addresses_ is set, the text representaion 00122 * of the IP is used; 00123 * - else if specified_hostname is given, it used "as is"; 00124 * - else a reverse (address to name) lookup is used to obtain the 00125 * hostname or the IP if no reverse mapping exists. 00126 */ 00127 virtual int hostname (TAO_ORB_Core *orb_core, 00128 ACE_INET_Addr &addr, 00129 char *&host, 00130 const char *specified_hostname = 0); 00131 00132 protected: 00133 00134 /** 00135 * Helper method 00136 * Clear out 'addr' & 'specified_hostname' and initialize them 00137 * based upon 'address'. 00138 */ 00139 int 00140 parse_address (const char *address, 00141 ACE_INET_Addr &addr, 00142 ACE_CString &specified_hostname); 00143 00144 /** 00145 * Set the host name for the given address using the dotted decimal 00146 * format. 00147 */ 00148 int dotted_decimal_address (ACE_INET_Addr &addr, 00149 char *&host); 00150 00151 /** 00152 * Implement the common part of the open*() methods. This method is 00153 * virtual to allow a derived class implementation to be invoked 00154 * instead. 00155 */ 00156 virtual int open_i (const ACE_INET_Addr &addr, 00157 ACE_Reactor *reactor); 00158 00159 /** 00160 * Probe the system for available network interfaces, and initialize 00161 * the <addrs_> array with an ACE_INET_Addr for each network 00162 * interface. The port for each initialized ACE_INET_Addr will be 00163 * set in the open_i() method. This method only gets invoked when 00164 * no explicit hostname is provided in the specified endpoint. 00165 */ 00166 int probe_interfaces (TAO_ORB_Core *orb_core); 00167 00168 /** 00169 * Parse protocol specific options. 00170 * 00171 * Currently supported: 00172 * portspan -- specifies the range of ports over which the acceptor 00173 * should scan looking for a free port (this is convenient 00174 * for situations where you might normally use an ephemeral 00175 * port but can't because you're behind a firewall and don't 00176 * want to permit passage on all ephemeral ports) 00177 */ 00178 int parse_options (const char *options); 00179 00180 /** 00181 * Parse options splits the options list in to an argv array. This 00182 * allows manipulation of the list in a manner similar to 00183 * orb_init. By moving the consumed args to the tail of the list and 00184 * reducing the argc count, the base parse_options_i can be called 00185 * by derived parse_options_i. Method returns -1 if an ill-formed or 00186 * otherwise bogus arg is encountered. The only strictly bogus arg 00187 * was priority, which was a holdover from the early RT IIOP 00188 * implementations. an ill-formed option is one which is missing an 00189 * equal sign or something to the left of it. 00190 */ 00191 virtual int parse_options_i (int &argc, ACE_CString ** argv); 00192 00193 /// Helper method to add a new profile to the mprofile for 00194 /// each endpoint. 00195 int create_new_profile (const TAO::ObjectKey &object_key, 00196 TAO_MProfile &mprofile, 00197 CORBA::Short priority); 00198 00199 /// Helper method to create a profile that contains all of 00200 /// our endpoints. 00201 int create_shared_profile (const TAO::ObjectKey &object_key, 00202 TAO_MProfile &mprofile, 00203 CORBA::Short priority); 00204 //@@ TAO_ACCEPTOR_SPL_CONCRETE_METHODS_COPY_HOOK_END 00205 00206 //@@ TAO_ACCEPTOR_SPL_DATA_MEMBERS_COPY_HOOK_START 00207 protected: 00208 00209 /// Array of ACE_INET_Addr instances, each one corresponding to a 00210 /// given network interface. 00211 ACE_INET_Addr *addrs_; 00212 00213 /** 00214 * The number of ports over which the acceptor should search (starting 00215 * at the port specified in each element of addrs_) for an available 00216 * port. This is specified via the "portspan=" option to the endpoint. 00217 */ 00218 unsigned short port_span_; 00219 00220 /** 00221 * Cache the information about the endpoints serviced by this 00222 * acceptor. 00223 * There may in fact be multiple hostnames for this endpoint. For 00224 * example, if the IP address is INADDR_ANY (0.0.0.0) then there 00225 * will be possibly a different hostname for each interface. 00226 */ 00227 char **hosts_; 00228 00229 /** 00230 * Override the hostname used in the ORBEndPoint. 00231 */ 00232 char *hostname_in_ior_; 00233 00234 /// The number of host names cached in the hosts_ array (equivalent 00235 /// to the number of endpoints opened by this Acceptor). 00236 CORBA::ULong endpoint_count_; 00237 00238 /** 00239 * The GIOP version for this endpoint 00240 * @@ Theoretically they shouldn't be here!! We need to look at a 00241 * way to move this out 00242 */ 00243 TAO_GIOP_Message_Version version_; 00244 00245 /// ORB Core. 00246 TAO_ORB_Core *orb_core_; 00247 00248 /// Should we use GIOP lite?? 00249 const bool lite_flag_; 00250 00251 /// Enable socket option SO_REUSEADDR to be set 00252 int reuse_addr_; 00253 00254 /// Address for default endpoint 00255 ACE_INET_Addr default_address_; 00256 00257 private: 00258 00259 /// The concrete acceptor, as a pointer to it's base class. 00260 BASE_ACCEPTOR base_acceptor_; 00261 00262 /// Acceptor strategies. 00263 CREATION_STRATEGY *creation_strategy_; 00264 CONCURRENCY_STRATEGY *concurrency_strategy_; 00265 ACCEPT_STRATEGY *accept_strategy_; 00266 00267 //@@ TAO_ACCEPTOR_SPL_DATA_MEMBERS_COPY_HOOK_END 00268 }; 00269 00270 TAO_END_VERSIONED_NAMESPACE_DECL 00271 00272 #if defined(__ACE_INLINE__) 00273 #include "tao/IIOP_Acceptor.i" 00274 #endif /* __ACE_INLINE__ */ 00275 00276 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */ 00277 00278 #include /**/ "ace/post.h" 00279 #endif /* TAO_IIOP_ACCEPTOR_H */