24
26
* Command line option handling.
26
static gboolean orbit_use_ipv4 = FALSE;
27
static gboolean orbit_use_ipv6 = FALSE;
28
static gboolean orbit_use_usocks = TRUE;
29
static gboolean orbit_use_irda = FALSE;
30
static gboolean orbit_use_ssl = FALSE;
31
static gboolean orbit_use_genuid_simple = FALSE;
32
static char *orbit_ipsock = NULL;
33
static char *orbit_ipname = NULL;
34
static char *orbit_debug_options = NULL;
29
static gboolean orbit_use_ipv4 = TRUE;
31
static gboolean orbit_use_ipv4 = FALSE;
33
static gboolean orbit_use_ipv6 = FALSE;
35
static gboolean orbit_use_usocks = FALSE;
37
static gboolean orbit_use_usocks = TRUE;
39
static gint orbit_initial_recv_limit = -1;
40
static gboolean orbit_use_irda = FALSE;
41
static gboolean orbit_use_ssl = FALSE;
42
static gboolean orbit_use_genuid_simple = FALSE;
43
static gboolean orbit_local_only = FALSE;
44
static gboolean orbit_use_http_iors = FALSE;
45
static char *orbit_ipsock = NULL;
46
static char *orbit_ipname = NULL;
47
static char *orbit_debug_options = NULL;
48
static char *orbit_naming_ref = NULL;
49
static GSList *orbit_initref_list = NULL;
50
static gboolean orbit_use_corbaloc = FALSE;
37
53
ORBit_ORB_start_servers (CORBA_ORB orb)
39
LINCProtocolInfo *info;
41
for (info = linc_protocol_all (); info->name; info++) {
55
LinkProtocolInfo *info;
56
LinkConnectionOptions create_options = 0;
58
LINK_MUTEX_LOCK (orb->lock);
60
if (orb->servers) { /* beaten to it */
61
LINK_MUTEX_UNLOCK (orb->lock);
66
create_options |= LINK_CONNECTION_LOCAL_ONLY;
68
if (orbit_local_only || (orbit_use_usocks && !(orbit_use_ipv4 || orbit_use_ipv6 || orbit_use_irda || orbit_use_ssl)))
69
link_use_local_hostname (TRUE);
71
for (info = link_protocol_all (); info->name; info++) {
42
72
GIOPServer *server;
44
74
if (!ORBit_proto_use (info->name))
47
server = giop_server_new (orb->default_giop_version,
48
info->name, orbit_ipname,
49
orbit_ipsock, 0, orb);
77
server = giop_server_new (
78
orb->default_giop_version, info->name,
79
orbit_ipname, orbit_ipsock,
51
83
orb->servers = g_slist_prepend (orb->servers, server);
53
if (!(info->flags & LINC_PROTOCOL_SECURE)) {
85
if (!(info->flags & LINK_PROTOCOL_SECURE)) {
54
86
if (!ORBit_proto_use ("SSL"))
57
89
server = giop_server_new (
58
90
orb->default_giop_version, info->name,
59
NULL, NULL, LINC_CONNECTION_SSL, orb);
91
NULL, NULL, LINK_CONNECTION_SSL | create_options,
62
95
orb->servers = g_slist_prepend (orb->servers, server);
74
107
orb->profiles = IOP_start_profiles (orb);
109
LINK_MUTEX_UNLOCK (orb->lock);
113
strip_object_profiles (gpointer o, gpointer b, gpointer c)
115
CORBA_Object obj = o;
116
IOP_delete_profiles (obj->orb, &obj->profile_list);
117
IOP_delete_profiles (obj->orb, &obj->forward_locations);
78
121
ORBit_ORB_shutdown_servers (CORBA_ORB orb)
123
LINK_MUTEX_LOCK (orb->lock);
126
g_hash_table_foreach (orb->objrefs,
127
strip_object_profiles, NULL);
128
g_hash_table_destroy (orb->objrefs);
80
132
IOP_shutdown_profiles (orb->profiles);
81
133
orb->profiles = NULL;
83
135
g_slist_foreach (orb->servers, (GFunc) g_object_unref, NULL);
84
136
g_slist_free (orb->servers);
85
137
orb->servers = NULL;
139
LINK_MUTEX_UNLOCK (orb->lock);
88
142
static ORBitGenUidType
133
209
ORBit_setup_debug_flags (void)
135
211
static GDebugKey debug_keys[] = {
136
{ "traces", ORBIT_DEBUG_TRACES },
137
{ "timings", ORBIT_DEBUG_TIMINGS },
138
{ "types", ORBIT_DEBUG_TYPES },
139
{ "messages", ORBIT_DEBUG_MESSAGES },
140
{ "objects", ORBIT_DEBUG_OBJECTS },
141
{ "giop", ORBIT_DEBUG_GIOP },
142
{ "refs", ORBIT_DEBUG_REFS },
212
{ "traces", ORBIT_DEBUG_TRACES },
213
{ "inproc_traces", ORBIT_DEBUG_INPROC_TRACES },
214
{ "timings", ORBIT_DEBUG_TIMINGS },
215
{ "types", ORBIT_DEBUG_TYPES },
216
{ "messages", ORBIT_DEBUG_MESSAGES },
217
{ "errors", ORBIT_DEBUG_ERRORS },
218
{ "objects", ORBIT_DEBUG_OBJECTS },
219
{ "giop", ORBIT_DEBUG_GIOP },
220
{ "refs", ORBIT_DEBUG_REFS },
221
{ "force_threaded", ORBIT_DEBUG_FORCE_THREADED }
144
223
const char *env_string;
156
235
g_parse_debug_string (orbit_debug_options,
158
237
G_N_ELEMENTS (debug_keys));
239
if (_orbit_debug_flags & ORBIT_DEBUG_INPROC_TRACES)
240
ORBit_small_flags |= ORBIT_SMALL_FORCE_GENERIC_MARSHAL;
160
242
#endif /* G_ENABLE_DEBUG */
162
244
static CORBA_ORB _ORBit_orb = NULL;
163
245
static gulong init_level = 0;
246
static gboolean atexit_shutdown = FALSE;
249
* This is neccessary to clean up any remaining UDS
250
* and to flush any remaining oneway traffic in buffers.
256
CORBA_Environment ev;
258
if (!(orb = _ORBit_orb))
261
init_level = 1; /* clobber it */
262
atexit_shutdown = TRUE;
264
CORBA_exception_init (&ev);
266
CORBA_ORB_destroy (orb, &ev);
267
ORBit_RootObject_release (orb);
269
CORBA_exception_free (&ev);
271
atexit_shutdown = FALSE;
276
ORBit_initial_reference_protected_id (gchar* id)
278
return (!strncmp (id, "RootPOA", strlen("RootPOA")) ||
279
!strncmp (id, "POACurrent", strlen("POACurrent")));
283
ORBit_initial_references_by_user (CORBA_ORB orb,
285
GSList *initref_list,
286
CORBA_Environment *ev)
291
if (ev->_major != CORBA_NO_EXCEPTION)
295
objref = CORBA_ORB_string_to_object (orb, naming_ref, ev);
297
/* FIXME, should abort if invalid option, don't forget
298
* to free resources allocated by ORB */
299
if (ev->_major != CORBA_NO_EXCEPTION) {
300
g_warning ("Option ORBNamingIOR has invalid object reference: %s",
302
CORBA_exception_free (ev);
304
/* FIXME, test type of object for
305
* IDL:omg.org/CosNaming/NamingContext using _is_a()
307
ORBit_set_initial_reference (orb, "NameService", objref);
308
ORBit_RootObject_release (objref);
312
for (l = initref_list; l; l = l->next) {
313
ORBit_OptionKeyValue *tuple = l->data;
315
g_assert (tuple != NULL);
316
g_assert (tuple->key != (gchar*)NULL);
317
g_assert (tuple->value != (gchar*)NULL);
319
objref = CORBA_ORB_string_to_object (orb, tuple->value, ev);
321
/* FIXME, should abort if invalid option,
322
* don't forget to free resources allocated by
324
if (ev->_major != CORBA_NO_EXCEPTION) {
325
g_warning ("Option ORBInitRef has invalid object reference: %s=%s",
326
tuple->key, tuple->value);
327
CORBA_exception_free (ev);
329
if (ORBit_initial_reference_protected_id(tuple->key)) {
330
g_warning ("Option ORBInitRef permission denied: %s=%s",
331
tuple->key, tuple->value);
333
ORBit_set_initial_reference (orb, tuple->key, objref);
336
ORBit_RootObject_release (objref);
166
343
CORBA_ORB_init (int *argc, char **argv,
167
344
CORBA_ORBid orb_identifier,
168
345
CORBA_Environment *ev)
347
gboolean thread_safe;
170
348
CORBA_ORB retval;
171
349
static ORBit_RootObject_Interface orb_if = {
181
359
/* the allocation code uses the bottom bit of any pointer */
182
360
g_assert (ORBIT_ALIGNOF_CORBA_DOUBLE > 2);
362
if (orb_identifier &&
363
strstr (orb_identifier, "orbit-local-non-threaded-orb") != NULL)
184
368
ORBit_option_parse (argc, argv, orbit_supported_options);
186
370
#ifdef G_ENABLE_DEBUG
187
371
ORBit_setup_debug_flags ();
373
if (_orbit_debug_flags & ORBIT_DEBUG_FORCE_THREADED) {
374
g_warning ("-- Forced orb into threaded mode --");
188
377
#endif /* G_ENABLE_DEBUG */
380
giop_recv_set_limit (orbit_initial_recv_limit);
381
giop_init (thread_safe,
382
orbit_use_ipv4 || orbit_use_ipv6 ||
383
orbit_use_irda || orbit_use_ssl);
385
if (orb_identifier && thread_safe &&
386
strstr (orb_identifier, "orbit-io-thread") != NULL)
387
link_set_io_thread (TRUE);
390
_ORBit_object_init ();
192
393
ORBit_locks_initialize ();
196
397
ORBit_RootObject_init (&retval->root_object, &orb_if);
197
398
/* released by CORBA_ORB_destroy */
198
399
_ORBit_orb = ORBit_RootObject_duplicate (retval);
400
_ORBit_orb->lock = link_mutex_new ();
401
g_atexit (shutdown_orb);
200
ORBit_genuid_init (ORBit_genuid_type ());
201
403
retval->default_giop_version = GIOP_LATEST;
203
405
retval->adaptors = g_ptr_array_new ();
204
406
ORBit_init_internals (retval, ev);
407
/* FIXME, handle exceptions */
409
ORBit_initial_references_by_user (retval,
413
/* FIXME, handle exceptions */
206
415
return ORBit_RootObject_duplicate (retval);
210
419
CORBA_ORB_object_to_string (CORBA_ORB orb,
211
const CORBA_Object obj,
212
CORBA_Environment *ev)
420
const CORBA_Object obj,
421
CORBA_Environment *ev)
214
423
GIOPSendBuffer *buf;
215
424
CORBA_octet endianness = GIOP_FLAG_ENDIANNESS;
281
if (strncmp (string, "IOR:", 4)) {
282
if (strstr (string, "://")) {
499
if (strncmp (string, "IOR:", strlen("IOR:")) &&
500
strncmp (string, "corbaloc:", strlen ("corbaloc:")) &&
501
strncmp (string, "iiop:", strlen ("iiop:")) &&
502
strncmp (string, "iiops:", strlen ("iiops:")) &&
503
strncmp (string, "ssliop:", strlen ("ssliop:")) &&
504
strncmp (string, "uiop:", strlen ("uiop:"))) {
506
#if defined ENABLE_HTTP
507
if (orbit_use_http_iors &&
508
strstr (string, "://")) {
509
/* FIXME: this code is a security hazard */
283
510
ior = orb_http_resolve (string);
285
512
return CORBA_OBJECT_NIL;
289
518
CORBA_exception_set_system (
291
520
ex_CORBA_BAD_PARAM,
299
len = strlen (string);
300
while (len > 0 && !g_ascii_isxdigit (string [len - 1]))
307
return CORBA_OBJECT_NIL;
310
tmpbuf = g_alloca (len / 2);
312
for (i = 0; i < len; i += 2)
313
tmpbuf [i/2] = (g_ascii_xdigit_value (string [i]) << 4) |
314
g_ascii_xdigit_value (string [i + 1]);
316
buf = giop_recv_buffer_use_encaps (tmpbuf, len / 2);
318
if (ORBit_demarshal_object (&retval, buf, orb)) {
319
CORBA_exception_set_system (
527
if (!strncmp (string, "IOR:", strlen ("IOR:")))
530
len = strlen (string);
531
while (len > 0 && !g_ascii_isxdigit (string [len - 1]))
538
return CORBA_OBJECT_NIL;
541
tmpbuf = g_alloca (len / 2);
543
for (i = 0; i < len; i += 2)
544
tmpbuf [i/2] = (g_ascii_xdigit_value (string [i]) << 4) |
545
g_ascii_xdigit_value (string [i + 1]);
547
buf = giop_recv_buffer_use_encaps (tmpbuf, len / 2);
549
if (ORBit_demarshal_object (&retval, buf, orb)) {
550
CORBA_exception_set_system (
321
552
ex_CORBA_MARSHAL,
322
553
CORBA_COMPLETED_NO);
324
retval = CORBA_OBJECT_NIL;
327
giop_recv_buffer_unuse (buf);
555
retval = CORBA_OBJECT_NIL;
558
giop_recv_buffer_unuse (buf);
565
return ORBit_object_by_corbaloc (orb, string, ev);
390
624
CORBA_ServiceInformation **service_information,
391
625
CORBA_Environment *ev)
628
* see http://mail.gnome.org/archives/orbit-list/2003-May/msg00093.html
630
* Assigning NULL to parameter service_information is not
631
* compliant to CORBA spec. This operation is part of pseudo
632
* interface and must react like operation of true remote
633
* interface. The question is what value it should point to in
634
* case CORBA_FALSE is returned to caller.
636
4.2.2 Getting Service Information
637
4.2.2.1 get_service_information
639
boolean get_service_information (in ServiceType service_type;
640
out ServiceInformation service_information;);
642
* The get_service_information operation is used to obtain
643
* information about CORBA facilities and services that are
644
* supported by this ORB. The service type for which
645
* information is being requested is passed in as the in
646
* parameter service_type, the values defined by constants in
647
* the CORBA module. If service information is available for
648
* that type, that is returned in the out parameter
649
* service_information, and the operation returns the value
650
* TRUE. If no information for the requested services type is
651
* available, the operation returns FALSE (i.e., the service
652
* is not supported by this ORB).
393
654
*service_information = NULL;
395
656
return CORBA_FALSE;
452
717
CORBA_Object objref;
454
if (!orb->initial_refs)
719
/* FIXME, verify identifier and raise exception for invalid
720
* service names, valid names might be: NameService, RootPOA,
721
* SecurityCurrent, PolicyCurrent, etc. */
723
if (!orb->initial_refs ||
724
!(objref = g_hash_table_lookup (orb->initial_refs, identifier)))
455
725
return CORBA_OBJECT_NIL;
457
objref = g_hash_table_lookup (orb->initial_refs, identifier);
459
727
return ORBit_RootObject_duplicate (objref);
730
CORBA_exception_set (ev,
731
CORBA_USER_EXCEPTION,
732
ex_CORBA_ORB_InvalidName,
734
return CORBA_OBJECT_NIL;
462
738
static CORBA_TypeCode
463
CORBA_TypeCode_allocate (void)
739
ORBit_TypeCode_allocate (void)
465
741
CORBA_TypeCode tc = g_new0 (struct CORBA_TypeCode_struct, 1);
557
819
CORBA_TypeCode retval;
560
retval = CORBA_TypeCode_allocate ();
563
goto tc_alloc_failed;
822
retval = ORBit_TypeCode_allocate ();
565
824
retval->discriminator = ORBit_RootObject_duplicate (discriminator_type);
567
retval->subtypes = g_new0 (CORBA_TypeCode, members->_length);
569
goto subtypes_alloc_failed;
571
retval->subnames = g_new0 (char *, members->_length);
572
if(!retval->subnames)
573
goto subnames_alloc_failed;
826
retval->subtypes = g_new0 (CORBA_TypeCode, members->_length);
827
retval->subnames = g_new0 (char *, members->_length);
575
828
retval->sublabels = g_new0 (CORBA_long, members->_length);
576
if (!retval->sublabels)
577
goto sublabels_alloc_failed;
579
830
retval->kind = CORBA_tk_union;
580
831
retval->name = g_strdup (name);
1088
1219
if (leaked_adaptors) {
1089
g_warning ("CORBA_ORB_destroy: leaked '%d' Object Adaptors", leaked_adaptors);
1220
#ifdef G_ENABLE_DEBUG
1221
if (!atexit_shutdown)
1222
g_warning ("CORBA_ORB_destroy: leaked '%d' Object Adaptors",
1090
1225
CORBA_exception_set_system (
1091
1226
ev, ex_CORBA_FREE_MEM, CORBA_COMPLETED_NO);
1094
1229
if (((ORBit_RootObject)orb)->refs != 2 + leaked_adaptors) {
1095
g_warning ("CORBA_ORB_destroy: ORB still has %d refs.",
1096
((ORBit_RootObject)orb)->refs - 1 - leaked_adaptors);
1230
#ifdef G_ENABLE_DEBUG
1231
if (!atexit_shutdown) {
1232
if (((ORBit_RootObject)orb)->refs == 1 + leaked_adaptors)
1233
g_warning ("CORBA_ORB_destroy: ORB unreffed but not _destroy'd");
1235
g_warning ("CORBA_ORB_destroy: ORB still has %d refs.",
1236
((ORBit_RootObject)orb)->refs - 1 - leaked_adaptors);
1097
1239
CORBA_exception_set_system (
1098
1240
ev, ex_CORBA_FREE_MEM, CORBA_COMPLETED_NO);
1185
static ORBit_option orbit_supported_options[] = {
1186
{"ORBid", ORBIT_OPTION_STRING, NULL}, /* FIXME: unimplemented */
1187
{"ORBImplRepoIOR", ORBIT_OPTION_STRING, NULL}, /* FIXME: unimplemented */
1188
{"ORBIfaceRepoIOR", ORBIT_OPTION_STRING, NULL}, /* FIXME: unimplemented */
1189
{"ORBNamingIOR", ORBIT_OPTION_STRING, NULL}, /* FIXME: unimplemented */
1190
{"ORBRootPOAIOR", ORBIT_OPTION_STRING, NULL}, /* FIXME: huh? */
1191
{"ORBIIOPIPName", ORBIT_OPTION_STRING, &orbit_ipname},
1192
{"ORBIIOPIPSock", ORBIT_OPTION_STRING, &orbit_ipsock},
1193
{"ORBIIOPIPv4", ORBIT_OPTION_BOOLEAN, &orbit_use_ipv4},
1194
{"ORBIIOPIPv6", ORBIT_OPTION_BOOLEAN, &orbit_use_ipv6},
1195
{"ORBIIOPUSock", ORBIT_OPTION_BOOLEAN, &orbit_use_usocks},
1196
{"ORBIIOPUNIX", ORBIT_OPTION_BOOLEAN, &orbit_use_usocks},
1197
{"ORBIIOPIrDA", ORBIT_OPTION_BOOLEAN, &orbit_use_irda},
1198
{"ORBIIOPSSL", ORBIT_OPTION_BOOLEAN, &orbit_use_ssl},
1199
{"ORBSimpleUIDs", ORBIT_OPTION_BOOLEAN, &orbit_use_genuid_simple},
1200
{"ORBDebugFlags", ORBIT_OPTION_STRING, &orbit_debug_options},
1331
const ORBit_option orbit_supported_options[] = {
1332
{ "ORBid", ORBIT_OPTION_STRING, NULL }, /* FIXME: unimplemented */
1333
{ "ORBImplRepoIOR", ORBIT_OPTION_STRING, NULL }, /* FIXME: unimplemented */
1334
{ "ORBIfaceRepoIOR", ORBIT_OPTION_STRING, NULL }, /* FIXME: unimplemented */
1335
{ "ORBNamingIOR", ORBIT_OPTION_STRING, &orbit_naming_ref},
1337
{ "ORBRootPOAIOR", ORBIT_OPTION_STRING, NULL }, /* FIXME: huh? */
1338
{ "ORBIIOPIPName", ORBIT_OPTION_STRING, &orbit_ipname },
1339
{ "ORBIIOPIPSock", ORBIT_OPTION_STRING, &orbit_ipsock },
1340
{ "ORBInitialMsgLimit", ORBIT_OPTION_INT, &orbit_initial_recv_limit },
1341
{ "ORBLocalOnly", ORBIT_OPTION_BOOLEAN, &orbit_local_only },
1342
/* warning: this option is a security risk unless used with LocalOnly */
1343
{ "ORBIIOPIPv4", ORBIT_OPTION_BOOLEAN, &orbit_use_ipv4 },
1344
{ "ORBIIOPIPv6", ORBIT_OPTION_BOOLEAN, &orbit_use_ipv6 },
1345
{ "ORBIIOPUSock", ORBIT_OPTION_BOOLEAN, &orbit_use_usocks },
1346
{ "ORBIIOPUNIX", ORBIT_OPTION_BOOLEAN, &orbit_use_usocks },
1347
{ "ORBIIOPIrDA", ORBIT_OPTION_BOOLEAN, &orbit_use_irda },
1348
{ "ORBIIOPSSL", ORBIT_OPTION_BOOLEAN, &orbit_use_ssl },
1349
/* warning: this option is a security risk */
1350
{ "ORBHTTPIORs", ORBIT_OPTION_BOOLEAN, &orbit_use_http_iors },
1351
/* warning: this option is a security risk */
1352
{ "ORBSimpleUIDs", ORBIT_OPTION_BOOLEAN, &orbit_use_genuid_simple },
1353
{ "ORBDebugFlags", ORBIT_OPTION_STRING, &orbit_debug_options },
1354
{ "ORBInitRef", ORBIT_OPTION_KEY_VALUE, &orbit_initref_list},
1355
{ "ORBCorbaloc", ORBIT_OPTION_BOOLEAN, &orbit_use_corbaloc},