00001
00002
00003 #include "tao/params.h"
00004 #include "tao/orbconf.h"
00005
00006 #if !defined (__ACE_INLINE__)
00007 # include "tao/params.inl"
00008 #endif
00009
00010 #include "ace/OS_NS_Thread.h"
00011 #include "ace/Service_Config.h"
00012
00013 ACE_RCSID (tao,
00014 params,
00015 "$Id: params.cpp 79221 2007-08-06 11:01:22Z johnnyw $")
00016
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018
00019 TAO_ORB_Parameters::TAO_ORB_Parameters (void)
00020 : endpoints_map_ (10)
00021 , mcast_discovery_endpoint_ ()
00022 , default_init_ref_ (TAO_DEFAULT_INIT_REFERENCE_INITIALIZER)
00023 , sock_rcvbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ)
00024 , sock_sndbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ)
00025 , nodelay_ (1)
00026 , sock_keepalive_ (0)
00027 , sock_dontroute_ (0)
00028 , cdr_memcpy_tradeoff_ (ACE_DEFAULT_CDR_MEMCPY_TRADEOFF)
00029 , max_message_size_ (0)
00030 , use_dotted_decimal_addresses_ (0)
00031 , cache_incoming_by_dotted_decimal_address_ (0)
00032 , linger_ (-1)
00033 , std_profile_components_ (1)
00034 , ace_sched_policy_ (ACE_SCHED_OTHER)
00035 , sched_policy_ (THR_SCHED_DEFAULT)
00036 , scope_policy_ (THR_SCOPE_PROCESS)
00037 , single_read_optimization_ (1)
00038 , shared_profile_ (0)
00039 , use_parallel_connects_ (false)
00040 , parallel_connect_delay_ (0)
00041 , pref_network_ ()
00042 , disable_rt_collocation_resolver_ (false)
00043 , enforce_preferred_interfaces_ (false)
00044 #if defined (ACE_HAS_IPV6)
00045 , prefer_ipv6_interfaces_ (false)
00046 , connect_ipv6_only_ (false)
00047 , use_ipv6_link_local_ (false)
00048 #endif
00049 , negotiate_codesets_ (true)
00050 , ami_collication_ (true)
00051 , protocols_hooks_name_ ("Protocols_Hooks")
00052 , stub_factory_name_ ("Default_Stub_Factory")
00053 , endpoint_selector_factory_name_ ("Default_Endpoint_Selector_Factory")
00054 , thread_lane_resources_manager_factory_name_ ("Default_Thread_Lane_Resources_Manager_Factory")
00055 , poa_factory_name_ ("TAO_Object_Adapter_Factory")
00056 , poa_factory_directive_
00057 (ACE_TEXT_ALWAYS_CHAR
00058 (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory",
00059 "TAO_PortableServer",
00060 "_make_TAO_Object_Adapter_Factory",
00061 "")))
00062 , collocation_resolver_name_ ("Default_Collocation_Resolver")
00063 {
00064 for (int i = 0; i != TAO_NO_OF_MCAST_SERVICES; ++i)
00065 {
00066 this->service_port_[i] = 0;
00067 }
00068 }
00069
00070 void
00071 TAO_ORB_Parameters::get_endpoint_set (const ACE_CString &lane,
00072 TAO_EndpointSet &endpoint_set)
00073 {
00074
00075 endpoints_map_type::iterator const endpoints =
00076 this->endpoints_map_.find (lane);
00077
00078
00079 if (endpoints == this->endpoints_map_.end ())
00080 return;
00081
00082
00083
00084 int const result =
00085 this->parse_and_add_endpoints ((*endpoints).second,
00086 endpoint_set);
00087
00088 ACE_ASSERT (result == 0);
00089 ACE_UNUSED_ARG (result);
00090 }
00091
00092 int
00093 TAO_ORB_Parameters::add_endpoints (const ACE_CString &lane,
00094 const ACE_CString &additional_endpoints)
00095 {
00096 TAO_EndpointSet endpoint_set;
00097
00098
00099 int const result =
00100 this->parse_and_add_endpoints (additional_endpoints,
00101 endpoint_set);
00102
00103
00104 if (result != 0)
00105 return result;
00106
00107
00108
00109
00110
00111
00112 ACE_CString & existing_endpoints = this->endpoints_map_[lane];
00113
00114
00115 if (existing_endpoints.length () != 0)
00116 {
00117 existing_endpoints += ";";
00118 }
00119
00120 existing_endpoints += additional_endpoints;
00121
00122 return 0;
00123 }
00124
00125 int
00126 TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString &endpoints,
00127 TAO_EndpointSet &endpoint_set)
00128 {
00129
00130
00131
00132
00133
00134
00135
00136 static char const endpoints_delimiter = ';';
00137
00138 size_t const length = endpoints.length ();
00139
00140 if (endpoints[0] == endpoints_delimiter ||
00141 endpoints[length - 1] == endpoints_delimiter)
00142 {
00143 return -1;
00144
00145
00146
00147 }
00148
00149 int status = 0;
00150
00151
00152 if (length > 0)
00153 {
00154 int endpoints_count = 1;
00155
00156 for (size_t j = 0; j != length; ++j)
00157 {
00158 if (endpoints[j] == endpoints_delimiter)
00159 {
00160 ++endpoints_count;
00161 }
00162 }
00163
00164 ssize_t begin = 0;
00165 ssize_t end = endpoints.find (endpoints_delimiter);
00166
00167 for (int i = 0; i < endpoints_count; ++i)
00168 {
00169 if (end == 0)
00170 {
00171
00172
00173
00174
00175
00176 continue;
00177 }
00178
00179 ACE_CString const endpt =
00180 endpoints.substring (begin, end - begin);
00181
00182
00183
00184
00185
00186 ACE_CString::size_type const check_offset = endpt.find ("://");
00187
00188 if (check_offset > 0 &&
00189 check_offset != endpt.npos)
00190 {
00191 endpoint_set.enqueue_tail (endpt);
00192
00193 }
00194 else
00195 {
00196 status = -1;
00197 }
00198
00199 begin = end + 1;
00200 end = endpoints.find (endpoints_delimiter, begin);
00201 }
00202 }
00203 else
00204 {
00205 status = -1;
00206
00207 }
00208
00209 return status;
00210 }
00211
00212 bool
00213 TAO_ORB_Parameters::preferred_interfaces (const char *s)
00214 {
00215
00216
00217
00218
00219
00220 const char* p = s;
00221 bool expect_assign = false;
00222 bool expect_comma = false;
00223 bool expect_char = true;
00224 bool expect_wild = true;
00225 bool found_remote = false;
00226 while (*p != 0)
00227 {
00228 switch (*p)
00229 {
00230 #if !defined (ACE_HAS_IPV6)
00231
00232
00233 case ':':
00234 #endif
00235 case '=':
00236 if (! expect_assign)
00237 return false;
00238 found_remote = true;
00239 expect_assign = false;
00240 expect_char = true;
00241 expect_comma = false;
00242 expect_wild = true;
00243 break;
00244 case ',':
00245 if (! expect_comma)
00246 return false;
00247 found_remote = false;
00248 expect_assign = false;
00249 expect_char = true;
00250 expect_comma = false;
00251 expect_wild = true;
00252 break;
00253 case '*':
00254 case '?':
00255 if (! expect_wild)
00256 return false;
00257 expect_assign = ! found_remote;
00258 expect_char = true;
00259 expect_comma = found_remote;
00260 expect_wild = false;
00261 break;
00262 default:
00263 if (! expect_char)
00264 return false;
00265 expect_assign = ! found_remote;
00266 expect_char = true;
00267 expect_comma = found_remote;
00268 expect_wild = true;
00269 break;
00270 }
00271 ++p;
00272 }
00273 if (!expect_comma || expect_assign)
00274 return false;
00275
00276 this->pref_network_ = s;
00277
00278 return true;
00279 }
00280
00281 const char *
00282 TAO_ORB_Parameters::preferred_interfaces (void) const
00283 {
00284 return this->pref_network_.c_str ();
00285 }
00286
00287 void
00288 TAO_ORB_Parameters::enforce_pref_interfaces (bool p)
00289 {
00290 this->enforce_preferred_interfaces_ = p;
00291 }
00292
00293 bool
00294 TAO_ORB_Parameters::enforce_pref_interfaces (void) const
00295 {
00296 return this->enforce_preferred_interfaces_;
00297 }
00298
00299 #if defined (ACE_HAS_IPV6)
00300 void
00301 TAO_ORB_Parameters::prefer_ipv6_interfaces (bool p)
00302 {
00303 this->prefer_ipv6_interfaces_ = p;
00304 }
00305
00306 bool
00307 TAO_ORB_Parameters::prefer_ipv6_interfaces (void) const
00308 {
00309 return this->prefer_ipv6_interfaces_;
00310 }
00311
00312 void
00313 TAO_ORB_Parameters::connect_ipv6_only (bool p)
00314 {
00315 this->connect_ipv6_only_ = p;
00316 }
00317
00318 bool
00319 TAO_ORB_Parameters::connect_ipv6_only (void) const
00320 {
00321 return this->connect_ipv6_only_;
00322 }
00323
00324 void
00325 TAO_ORB_Parameters::use_ipv6_link_local (bool p)
00326 {
00327 this->use_ipv6_link_local_ = p;
00328 }
00329
00330 bool
00331 TAO_ORB_Parameters::use_ipv6_link_local (void) const
00332 {
00333 return this->use_ipv6_link_local_;
00334 }
00335 #endif
00336
00337 void
00338 TAO_ORB_Parameters::protocols_hooks_name (const char *s)
00339 {
00340 this->protocols_hooks_name_ = s;
00341 }
00342
00343 const char *
00344 TAO_ORB_Parameters::protocols_hooks_name (void) const
00345 {
00346 return this->protocols_hooks_name_.c_str ();
00347 }
00348
00349 void
00350 TAO_ORB_Parameters::thread_lane_resources_manager_factory_name (const char *s)
00351 {
00352 this->thread_lane_resources_manager_factory_name_ = s;
00353 }
00354
00355 const char *
00356 TAO_ORB_Parameters::thread_lane_resources_manager_factory_name (void) const
00357 {
00358 return this->thread_lane_resources_manager_factory_name_.c_str ();
00359 }
00360
00361 void
00362 TAO_ORB_Parameters::stub_factory_name (const char *s)
00363 {
00364 this->stub_factory_name_ = s;
00365 }
00366
00367 const char *
00368 TAO_ORB_Parameters::stub_factory_name (void) const
00369 {
00370 return this->stub_factory_name_.c_str ();
00371 }
00372
00373 void
00374 TAO_ORB_Parameters::poa_factory_name (const char *s)
00375 {
00376 this->poa_factory_name_ = s;
00377 }
00378
00379 const char *
00380 TAO_ORB_Parameters::poa_factory_name (void) const
00381 {
00382 return this->poa_factory_name_.c_str ();
00383 }
00384
00385 void
00386 TAO_ORB_Parameters::poa_factory_directive (const char *s)
00387 {
00388 this->poa_factory_directive_ = s;
00389 }
00390
00391 const char *
00392 TAO_ORB_Parameters::poa_factory_directive (void) const
00393 {
00394 return this->poa_factory_directive_.c_str ();
00395 }
00396
00397 void
00398 TAO_ORB_Parameters::endpoint_selector_factory_name (const char *s)
00399 {
00400 this->endpoint_selector_factory_name_ = s;
00401 }
00402
00403 const char *
00404 TAO_ORB_Parameters::endpoint_selector_factory_name (void) const
00405 {
00406 return this->endpoint_selector_factory_name_.c_str ();
00407 }
00408
00409 TAO_END_VERSIONED_NAMESPACE_DECL