Updated logging to include the class/method so that it is more obvious where these...
[ACE_TAO.git] / TAO / tao / IIOP_Acceptor.h
blob124d7f786977806bc8341bcdbe5c6d61d36dc498
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file IIOP_Acceptor.h
7 * IIOP specific acceptor processing
9 * @author Fred Kuhns <fredk@cs.wustl.edu>
10 * @author Ossama Othman <ossama@uci.edu>
12 //=============================================================================
15 #ifndef TAO_IIOP_ACCEPTOR_H
16 #define TAO_IIOP_ACCEPTOR_H
18 #include /**/ "ace/pre.h"
20 #include "tao/orbconf.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
28 #include "tao/Transport_Acceptor.h"
29 #include "tao/IIOP_Connection_Handler.h"
30 #include "tao/Acceptor_Impl.h"
31 #include "tao/GIOP_Message_Version.h"
33 #include "ace/SOCK_Acceptor.h"
34 #include "ace/Acceptor.h"
36 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
38 /**
39 * @class TAO_IIOP_Acceptor
41 * @brief TAO_IIOP_Acceptor
43 * The IIOP-specific bridge class for the concrete acceptor.
45 class TAO_Export TAO_IIOP_Acceptor : public TAO_Acceptor
47 public:
48 /// Constructor.
49 TAO_IIOP_Acceptor (void);
51 /// Destructor.
52 ~TAO_IIOP_Acceptor (void);
54 /// @@ Helper method for the implementation repository, should go
55 /// away
56 const ACE_INET_Addr& address () const;
58 /// Returns the array of endpoints in this acceptor
59 const ACE_INET_Addr *endpoints (void);
61 /// Returns address for default endpoint
62 const ACE_INET_Addr& default_address () const;
64 /// Set address for default endpoint
65 void set_default_address (const ACE_INET_Addr& addr);
67 typedef TAO_Strategy_Acceptor<TAO_IIOP_Connection_Handler, ACE_SOCK_ACCEPTOR> BASE_ACCEPTOR;
68 typedef TAO_Creation_Strategy<TAO_IIOP_Connection_Handler> CREATION_STRATEGY;
69 typedef TAO_Concurrency_Strategy<TAO_IIOP_Connection_Handler> CONCURRENCY_STRATEGY;
70 typedef TAO_Accept_Strategy<TAO_IIOP_Connection_Handler, ACE_SOCK_ACCEPTOR> ACCEPT_STRATEGY;
72 /**
73 * The TAO_Acceptor methods, check the documentation in
74 * Transport_Acceptor.h for details.
76 virtual int open (TAO_ORB_Core *orb_core,
77 ACE_Reactor *reactor,
78 int version_major,
79 int version_minor,
80 const char *address,
81 const char *options = 0);
82 virtual int open_default (TAO_ORB_Core *orb_core,
83 ACE_Reactor *reactor,
84 int version_major,
85 int version_minor,
86 const char *options = 0);
87 virtual int close (void);
88 virtual int create_profile (const TAO::ObjectKey &object_key,
89 TAO_MProfile &mprofile,
90 CORBA::Short priority);
91 virtual int is_collocated (const TAO_Endpoint *endpoint);
92 virtual CORBA::ULong endpoint_count (void);
94 virtual int object_key (IOP::TaggedProfile &profile,
95 TAO::ObjectKey &key);
97 /**
98 * Set the host name for the given @a addr.
99 * A hostname may be forced by using @a specified_hostname. This
100 * is useful if the given address corresponds to more than one
101 * hostname and the desired one cannot be determined in any
102 * other way.
103 * This method is used both when constructing IOR endpoints and LPL
104 * (listen point lists).
106 * The algorithm used is:
107 * - If hostname_in_ior_ has been set, it is used "as is";
108 * - else if use_dotted_decimal_addresses_ is set, the text representation
109 * of the IP is used;
110 * - else if specified_hostname is given, it used "as is";
111 * - else a reverse (address to name) lookup is used to obtain the
112 * hostname or the IP if no reverse mapping exists.
114 virtual int hostname (TAO_ORB_Core *orb_core,
115 const ACE_INET_Addr &addr,
116 char *&host,
117 const char *specified_hostname = 0);
119 protected:
121 * Helper method
122 * Clear out 'addr' & 'specified_hostname' and initialize them based
123 * upon 'address'. If a non-zero pointer is passed in for def_type,
124 * this will be set to AF_INET6 if IPv6 support is enabled and
125 * supplied hostname is either [] or [::]. It will be set to AF_INET
126 * if the hostname is 0.0.0.0, otherwise it is set to
127 * AF_UNSPEC. This value is then passed to probe_interfaces by open.
130 parse_address (const char *address,
131 ACE_INET_Addr &addr,
132 ACE_CString &specified_hostname,
133 int *def_type = 0);
136 * Set the host name for the given address using the dotted decimal
137 * format.
139 int dotted_decimal_address (const ACE_INET_Addr &addr,
140 char *&host);
143 * Implement the common part of the open*() methods. This method is
144 * virtual to allow a derived class implementation to be invoked
145 * instead.
147 virtual int open_i (const ACE_INET_Addr &addr,
148 ACE_Reactor *reactor);
151 * Probe the system for available network interfaces, and initialize
152 * the <addrs_> array with an ACE_INET_Addr for each network
153 * interface. The port for each initialized ACE_INET_Addr will be
154 * set in the open_i() method. This method only gets invoked when
155 * no explicit hostname is provided in the specified endpoint.
157 * The optional argument def_type is used to constrain the resulting
158 * list of interfaces to be either only IPv6 or IPv4, or both, when
159 * ACE_HAS_IPV6 is enabled and the source endpoint was an explicitly
160 * declared wildcard.
162 int probe_interfaces (TAO_ORB_Core *orb_core, int def_type = AF_UNSPEC);
165 * Parse protocol specific options.
167 * Currently supported:
168 * portspan -- specifies the range of ports over which the acceptor
169 * should scan looking for a free port (this is convenient
170 * for situations where you might normally use an ephemeral
171 * port but can't because you're behind a firewall and don't
172 * want to permit passage on all ephemeral ports)
174 int parse_options (const char *options);
177 * Parse options splits the options list in to an argv array. This
178 * allows manipulation of the list in a manner similar to
179 * orb_init. By moving the consumed args to the tail of the list and
180 * reducing the argc count, the base parse_options_i can be called
181 * by derived parse_options_i. Method returns -1 if an ill-formed or
182 * otherwise bogus arg is encountered. The only strictly bogus arg
183 * was priority, which was a holdover from the early RT IIOP
184 * implementations. an ill-formed option is one which is missing an
185 * equal sign or something to the left of it.
187 virtual int parse_options_i (int &argc, ACE_CString ** argv);
189 /// Helper method to add a new profile to the mprofile for
190 /// each endpoint.
191 int create_new_profile (const TAO::ObjectKey &object_key,
192 TAO_MProfile &mprofile,
193 CORBA::Short priority);
195 /// Helper method to create a profile that contains all of
196 /// our endpoints.
197 int create_shared_profile (const TAO::ObjectKey &object_key,
198 TAO_MProfile &mprofile,
199 CORBA::Short priority);
201 private:
202 void operator= (const TAO_IIOP_Acceptor &);
203 TAO_IIOP_Acceptor (const TAO_IIOP_Acceptor &);
205 protected:
206 /// Array of ACE_INET_Addr instances, each one corresponding to a
207 /// given network interface.
208 ACE_INET_Addr *addrs_;
211 * The number of ports over which the acceptor should search (starting
212 * at the port specified in each element of addrs_) for an available
213 * port. This is specified via the "portspan=" option to the endpoint.
215 unsigned short port_span_;
218 * Cache the information about the endpoints serviced by this
219 * acceptor.
220 * There may in fact be multiple hostnames for this endpoint. For
221 * example, if the IP address is INADDR_ANY (0.0.0.0) then there
222 * will be possibly a different hostname for each interface.
224 char **hosts_;
227 * Override the hostname used in the ORBEndPoint.
229 char *hostname_in_ior_;
231 /// The number of host names cached in the hosts_ array (equivalent
232 /// to the number of endpoints opened by this Acceptor).
233 CORBA::ULong endpoint_count_;
236 * The GIOP version for this endpoint
237 * @@ Theoretically they shouldn't be here!! We need to look at a
238 * way to move this out
240 TAO_GIOP_Message_Version version_;
242 /// ORB Core.
243 TAO_ORB_Core *orb_core_;
245 /// Enable socket option SO_REUSEADDR to be set
246 int reuse_addr_;
248 /// Address for default endpoint
249 ACE_INET_Addr default_address_;
251 private:
252 /// The concrete acceptor, as a pointer to it's base class.
253 BASE_ACCEPTOR base_acceptor_;
255 /// Acceptor strategies.
256 CREATION_STRATEGY *creation_strategy_;
257 CONCURRENCY_STRATEGY *concurrency_strategy_;
258 ACCEPT_STRATEGY *accept_strategy_;
261 TAO_END_VERSIONED_NAMESPACE_DECL
263 #if defined(__ACE_INLINE__)
264 #include "tao/IIOP_Acceptor.inl"
265 #endif /* __ACE_INLINE__ */
267 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */
269 #include /**/ "ace/post.h"
270 #endif /* TAO_IIOP_ACCEPTOR_H */