2 //=============================================================================
6 * Reads stringified IORs and outputs the encoded information.
8 * @author Jeff Hopper <jrhopper@cts.com> SCIOP and Tagged component modifications by: Jason Cohen
9 * @author Lockheed Martin ATL <jcohen@atl.lmco.com> Split into a separate library by: Chad Elliott <elliott_c@ociweb.com>
11 //=============================================================================
15 #include "tao/Messaging_PolicyValueC.h"
16 #include "tao/Messaging/Messaging_TypesC.h"
17 #include "tao/ZIOP/ZIOP.h"
18 #include "tao/Compression/Compression.h"
19 #include "tao/RTCORBA/RTCORBA.h"
20 #include "tao/AnyTypeCode/Marshal.h"
21 #include "tao/IIOP_Profile.h"
22 #include "tao/ORB_Constants.h"
23 #include "tao/Transport_Acceptor.h"
24 #include "tao/IIOP_EndpointsC.h"
25 #include "tao/Tagged_Components.h"
27 #include "ace/Codeset_Registry.h"
28 #include "ace/Get_Opt.h"
29 #include "ace/streams.h"
30 #include "ace/OS_NS_ctype.h"
31 #include "ace/OS_NS_stdio.h"
32 #include "ace/Argv_Type_Converter.h"
33 #include "ace/Log_Msg.h"
43 Catior_i::decode (const ACE_CString
& aString
, ACE_CString
& output
)
45 const ACE_CString iorPrefix
= "IOR:";
46 const ACE_CString iiopPrefix
= "iiop:";
47 const ACE_CString poopPrefix
= ":IR:";
50 CORBA::Boolean b
= false;
51 if (aString
.find (iorPrefix
) == 0)
53 buffer_
+= "Decoding an IOR:\n";
55 // Strip the IOR: off the string.
56 size_t prefixLength
= iorPrefix
.length ();
57 ACE_CString subString
=
58 aString
.substring (prefixLength
,
59 aString
.length () - prefixLength
);
60 subString
[subString
.length ()] = '\0';
61 str
= subString
.rep ();
64 else if (aString
.find (iiopPrefix
) == 0)
66 buffer_
+= "Decoding an IIOP URL IOR\n";
68 size_t prefixLength
= iiopPrefix
.length ();
69 ACE_CString subString
=
70 aString
.substring (prefixLength
,
71 aString
.length () - prefixLength
);
72 str
= subString
.rep ();
75 else if (aString
.find (poopPrefix
) != ACE_CString::npos
)
77 buffer_
+= "Decoding a POOP IOR\n";
84 buffer_
+= "Don't know how to decode this IOR\n";
95 Catior_i::catiiop (char* string
)
97 // NIL objref encodes as just "iiop:" ... which has already been
98 // removed, so we see it as an empty string.
100 if (!string
|| !*string
)
103 // Type ID not encoded in this string ... makes narrowing rather
104 // expensive, though it does ensure that type-safe narrowing code
105 // gets thoroughly excercised/debugged! Without a typeID, the
106 // _narrow will be required to make an expensive remote "is_a" call.
108 // Remove the "N.N//" prefix, and verify the version's one that we
111 CORBA::Short iiop_version_major
= 1;
112 CORBA::Short iiop_version_minor
= 0;
114 if (ACE_OS::ace_isdigit (string
[0])
115 && ACE_OS::ace_isdigit (string
[2])
118 && string
[4] == '/')
120 iiop_version_major
= (char) (string
[0] - '0');
121 iiop_version_minor
= (char) (string
[2] - '0');
129 static const size_t bufsize
= 512;
131 ACE_OS::snprintf (buf
, bufsize
, "IIOP Version:\t%d.%d\n",
132 iiop_version_major
, iiop_version_minor
);
135 // Pull off the "hostname:port/" part of the objref Get host and
137 CORBA::UShort port_number
;
138 char *cp
= ACE_OS::strchr (string
, ':');
142 throw CORBA::DATA_CONVERSION ();
145 CORBA::String_var hostname
= CORBA::string_alloc (1 +
146 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
148 for (cp
= hostname
.inout ();
156 cp
= ACE_OS::strchr ((char *) string
, '/');
160 throw CORBA::DATA_CONVERSION ();
163 port_number
= (short) ACE_OS::atoi ((char *) string
);
166 ACE_OS::snprintf (buf
, bufsize
, "Host Name:\t%s\n"
167 "Port Number:\t%d\n",
168 hostname
.in (), port_number
);
171 // Parse the object key.
172 // dump the object key to stdout
173 // TAO_POA::decode_string_to_sequence (data->profile.object_key,
175 buffer_
+= "\nThe Object Key as string:\n";
183 Catior_i::catior (char const * str
)
185 // Unhex the bytes, and make a CDR deencapsulation stream from the
188 ACE_Message_Block
mb (ACE_OS::strlen (str
) / 2 + 1
189 + ACE_CDR::MAX_ALIGNMENT
);
190 ACE_CDR::mb_align (&mb
);
192 char * const buffer
= mb
.rd_ptr ();
193 char const * tmp
= (char *) str
;
196 CORBA::Boolean continue_decoding
;
198 // The prefix of the IOR must be removed, and the string must start
199 // with the encapsulation byte
201 while (tmp
[0] && tmp
[1])
205 if (! (ACE_OS::ace_isxdigit (tmp
[0]) && ACE_OS::ace_isxdigit (tmp
[1])))
208 byte
= (u_char
) (ACE::hex2byte (tmp
[0]) << 4);
209 byte
|= ACE::hex2byte (tmp
[1]);
211 buffer
[len
++] = byte
;
215 // Create deencapsulation stream ... then unmarshal objref from that
218 int byteOrder
= *(mb
.rd_ptr ());
222 TAO_InputCDR
stream (&mb
, static_cast<int> (byteOrder
));
224 buffer_
+= "The Byte Order:\t";
226 buffer_
+= "Little Endian\n";
228 buffer_
+= "Big Endian\n";
230 // First, read the type hint. This will be the type_id encoded in an
232 CORBA::String_var type_hint
;
234 if (!(stream
>> type_hint
.inout ()))
236 ACE_ERROR_RETURN ((LM_ERROR
,
237 "cannot read type id\n"),
241 buffer_
+= "The Type Id:\t\"";
242 buffer_
+= type_hint
.in ();
245 // Read the profiles, discarding all until an IIOP profile comes by.
246 // Once we see an IIOP profile, ignore any further ones.
248 // XXX this will need to change someday to let different protocol
249 // code be accessed, not just IIOP. Protocol modules will be
250 // dynamically loaded from shared libraries via ORB_init (), and we
251 // just need to be able to access such preloaded libraries here as
252 // we unmarshal objrefs.
254 CORBA::ULong profiles
= 0;
256 continue_decoding
= stream
.read_ulong (profiles
);
258 // Get the count of profiles that follow.
259 if (!continue_decoding
)
261 ACE_ERROR_RETURN ((LM_ERROR
,
262 "cannot read the profile count\n"),
266 CORBA::ULong profile_counter
= 0;
268 static const size_t bufsize
= 512;
270 ACE_OS::snprintf (buf
, bufsize
,
271 "Number of Profiles in IOR:\t%d\n", profiles
);
274 // No profiles means a NIL objref.
276 return TAO::TRAVERSE_CONTINUE
;
278 while (profiles
-- != 0)
280 ACE_OS::snprintf (buf
, bufsize
, "Profile number:\t%d\n",
284 // We keep decoding until we find a valid IIOP profile.
287 continue_decoding
= stream
.read_ulong (tag
);
289 // Get the profile ID tag.
290 if (!continue_decoding
)
292 ACE_ERROR ((LM_ERROR
, "cannot read profile tag\n"));
297 if (tag
== IOP::TAG_INTERNET_IOP
)
299 continue_decoding
= cat_iiop_profile (stream
);
301 else if (tag
== IOP::TAG_MULTIPLE_COMPONENTS
)
303 continue_decoding
= cat_multiple_components (stream
);
305 else if (tag
== TAO_TAG_SCIOP_PROFILE
)
307 continue_decoding
= cat_sciop_profile (stream
);
309 else if (tag
== TAO_TAG_UIOP_PROFILE
)
311 continue_decoding
= cat_uiop_profile (stream
);
313 else if (tag
== TAO_TAG_SHMEM_PROFILE
)
315 continue_decoding
= cat_shmiop_profile (stream
);
317 else if (tag
== TAO_TAG_DIOP_PROFILE
)
319 continue_decoding
= cat_profile_helper(stream
, "DIOP (GIOP over UDP)");
321 else if (tag
== TAO_TAG_COIOP_PROFILE
)
323 continue_decoding
= cat_coiop_profile(stream
);
325 else if (tag
== TAO_TAG_NSKPW_PROFILE
)
327 continue_decoding
= cat_nskpw_profile (stream
);
329 else if (tag
== TAO_TAG_NSKFS_PROFILE
)
331 continue_decoding
= cat_nskfs_profile (stream
);
336 ACE_OS::snprintf (buf
, bufsize
,
337 "Profile tag = %d (unknown protocol)\n", tag
);
339 continue_decoding
= cat_octet_seq("Profile body", stream
);
346 // Parse the Orbix-style POOP object references, which have the form:
347 //:\ntlj3corba:NS:NC_2::IR:CosNaming_NamingContext
353 // : interface_marker
356 Catior_i::catpoop (char* string
)
358 if (!string
|| !*string
)
361 //if (string [0] == ':'
362 // && string [1] == '\\')
363 // ACE_DEBUG ((LM_DEBUG,
364 // "\nPerhaps we've found some POOP\n"));
367 char *cp
= ACE_OS::strchr (string
, ':');
371 throw CORBA::DATA_CONVERSION ();
374 // Read the hostname.
375 char* hostname
= CORBA::string_alloc (1 +
376 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
386 buffer_
+= "Host Name:\t";
389 CORBA::string_free (hostname
);
391 // read the server name
392 cp
= ACE_OS::strchr (string
, ':');
394 char* server_name
= CORBA::string_alloc (1 +
395 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
397 for (cp
= server_name
;
405 buffer_
+= "Server Name:\t";
406 buffer_
+= server_name
;
409 CORBA::string_free (server_name
);
411 // Read the Orbix specific marker.
412 cp
= ACE_OS::strchr (string
, ':');
414 char* marker
= CORBA::string_alloc (1 +
415 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
425 buffer_
+= "Marker:\t\t";
428 CORBA::string_free (marker
);
430 cp
= ACE_OS::strchr (string
, ':');
433 char* IR_host
= CORBA::string_alloc (1 +
434 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
444 buffer_
+= "IR Host:\t\t";
447 CORBA::string_free (IR_host
);
449 // Read the IR_server
450 cp
= ACE_OS::strchr (string
, ':');
452 char* IR_server
= CORBA::string_alloc (1 +
453 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
463 buffer_
+= "IR Server:\t\t";
464 buffer_
+= IR_server
;
466 CORBA::string_free (IR_server
);
468 // Read the interface_marker
469 buffer_
+= "Interface Marker:\t";
476 Catior_i::cat_tag_orb_type (TAO_InputCDR
& stream
) {
477 CORBA::ULong length
= 0;
478 if (!stream
.read_ulong (length
))
481 TAO_InputCDR
stream2 (stream
, length
);
482 stream
.skip_bytes(length
);
484 CORBA::ULong orbtype
;
486 if (!(stream2
>> orbtype
))
489 static const size_t bufsize
= 512;
498 ACE_OS::snprintf (buf
, bufsize
,
499 "ORB Type: 0x%x (TAO)\n", orbtype
);
504 ACE_OS::snprintf (buf
, bufsize
,
505 "ORB Type: 0x%x (GNU Classpath)\n", orbtype
);
510 ACE_OS::snprintf (buf
, bufsize
,
511 "ORB Type: 0x%x (Orbix)\n", orbtype
);
516 ACE_OS::snprintf (buf
, bufsize
,
517 "ORB Type: 0x%x (JacORB)\n", orbtype
);
522 ACE_OS::snprintf (buf
, bufsize
,
523 "ORB Type: 0x%x (OmniORB)\n", orbtype
);
528 ACE_OS::snprintf (buf
, bufsize
,
529 "ORB Type: 0x%x (Sun)\n", orbtype
);
534 ACE_OS::snprintf (buf
, bufsize
,
535 "ORB Type: 0x%x (TIDorbC++)\n", orbtype
);
540 ACE_OS::snprintf (buf
, bufsize
,
541 "ORB Type: 0x%x (JacORB)\n", orbtype
);
546 ACE_OS::snprintf (buf
, bufsize
,
547 "ORB Type: 0x%x\n", orbtype
);
556 Catior_i::cat_ibm_partner_version (TAO_InputCDR
& stream
) {
558 * IBM Partner version looks like:
559 * 49424d0a 00000008 00000000 1400 0005
560 * The three initial bytes (from left to right) are the ASCII code for IBM,
561 * followed by 0x0A, which specifies that the following bytes handle the
563 * The next four bytes encode the length of the remaining data (in this
565 * The next four null bytes are for future use.
566 * The two bytes for the Partner Version Major field (0x1400) define the
567 * release of the ORB that is being used (1.4.0 in this case).
568 * The Minor field (0x0005) distinguishes in the same release, service
569 * refreshes that contain changes that have affected the backward
572 CORBA::ULong length
= 0;
573 if (!(stream
.read_ulong (length
)))
576 TAO_InputCDR
stream2 (stream
, length
);
577 stream
.skip_bytes(length
);
579 CORBA::ULong version
;
580 if (!(stream2
>> version
))
583 static const size_t bufsize
= 512;
585 ACE_OS::snprintf (buf
, bufsize
, "\tPartner Version: 0x%x\n", version
);
593 Catior_i::cat_tao_tag_endpoints (TAO_InputCDR
& stream
)
595 CORBA::ULong length
= 0;
596 if (!stream
.read_ulong (length
))
599 TAO_InputCDR
stream2 (stream
, length
);
600 stream
.skip_bytes(length
);
602 TAO::IIOPEndpointSequence epseq
;
603 if (!(stream2
>> epseq
))
606 static const size_t bufsize
= 512;
608 for (unsigned int iter
=0; iter
< epseq
.length() ; iter
++) {
609 const char *host
= epseq
[iter
].host
;
610 CORBA::UShort port
= epseq
[iter
].port
;
612 ACE_OS::snprintf (buf
, bufsize
,
613 "Endpoint #%d:\n", iter
+1);
616 ACE_OS::snprintf (buf
, bufsize
,
620 ACE_OS::snprintf (buf
, bufsize
,
624 ACE_OS::snprintf (buf
, bufsize
,
625 "Priority: %d\n", epseq
[iter
].priority
);
633 Catior_i::cat_tag_alternate_endpoints (TAO_InputCDR
& stream
) {
634 CORBA::ULong length
= 0;
635 if (!stream
.read_ulong (length
))
638 TAO_InputCDR
stream2 (stream
, length
);
639 stream
.skip_bytes(length
);
641 CORBA::String_var host
;
643 if (!(stream2
>> host
.out()) ||
646 ACE_ERROR_RETURN ((LM_ERROR
,"cannot extract endpoint info\n"),false);
650 static const size_t bufsize
= 512;
653 ACE_OS::snprintf (buf
, bufsize
,
654 "endpoint: %s:%d\n", host
.in(), port
);
662 Catior_i::cat_tag_policies (TAO_InputCDR
& stream
) {
663 CORBA::ULong length
= 0;
664 if (!stream
.read_ulong (length
))
667 TAO_InputCDR
stream2 (stream
, length
);
668 stream
.skip_bytes(length
);
670 Messaging::PolicyValueSeq policies
;
671 if (!(stream2
>> policies
))
674 static const size_t bufsize
= 512;
677 ACE_OS::snprintf (buf
, bufsize
,
678 "Number of policies: %d\n",
682 for (unsigned int iter
=0; iter
< policies
.length() ; iter
++) {
683 // Create new stream for pvalue contents
684 const CORBA::Octet
*pmbuf
= policies
[iter
].pvalue
.get_buffer ();
686 TAO_InputCDR
stream3 (
687 reinterpret_cast <const char*> (pmbuf
),
688 policies
[iter
].pvalue
.length ());
690 CORBA::Boolean byte_order
;
691 if (!(stream3
>> ACE_InputCDR::to_boolean (byte_order
)))
694 stream3
.reset_byte_order (static_cast <int> (byte_order
));
696 if (policies
[iter
].ptype
== RTCORBA::PRIORITY_MODEL_POLICY_TYPE
) {
698 ACE_OS::snprintf (buf
, bufsize
,
699 "Policy #%d Type: %d (PRIORITY_MODEL_POLICY_TYPE)\n",
700 iter
+1, policies
[iter
].ptype
);
703 RTCORBA::PriorityModel priority_model
;
704 RTCORBA::Priority server_priority
;
706 if (!(stream3
>> priority_model
))
708 if (!(stream3
>> server_priority
))
712 if (priority_model
== RTCORBA::CLIENT_PROPAGATED
) {
713 ACE_OS::snprintf (buf
, bufsize
,
714 "\t Priority Model: %d (CLIENT_PROPAGATED)\n",
716 } else if (priority_model
== RTCORBA::SERVER_DECLARED
) {
717 ACE_OS::snprintf (buf
, bufsize
,
718 "\t Priority Model: %d (SERVER_DECLARED)\n",
721 ACE_OS::snprintf (buf
, bufsize
,
722 "\t Priority Model: %d (UNKNOWN!)\n",
727 ACE_OS::snprintf (buf
, bufsize
,
728 "\t Priority: %d\n", server_priority
);
731 } else if (policies
[iter
].ptype
== RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE
) {
733 ACE_OS::snprintf (buf
, bufsize
,
734 "Policy #%d Type: %d (PRIORITY_BANDED_CONNECTION_POLICY_TYPE)\n",
735 iter
+1, policies
[iter
].ptype
);
737 } else if (policies
[iter
].ptype
== Messaging::REBIND_POLICY_TYPE
) {
739 ACE_OS::snprintf (buf
, bufsize
,
740 "Policy #%d Type: %d (REBIND_POLICY_TYPE)\n",
741 iter
+1, policies
[iter
].ptype
);
743 #if (TAO_HAS_SYNC_SCOPE_POLICY == 1)
744 } else if (policies
[iter
].ptype
== Messaging::SYNC_SCOPE_POLICY_TYPE
) {
746 ACE_OS::snprintf (buf
, bufsize
,
747 "Policy #%d Type: %d (SYNC_SCOPE_POLICY_TYPE)\n",
748 iter
+1, policies
[iter
].ptype
);
751 } else if (policies
[iter
].ptype
== Messaging::REQUEST_PRIORITY_POLICY_TYPE
) {
753 ACE_OS::snprintf (buf
, bufsize
,
754 "Policy #%d Type: %d (REQUEST_PRIORITY_POLICY_TYPE)\n",
755 iter
+1, policies
[iter
].ptype
);
757 } else if (policies
[iter
].ptype
== Messaging::REPLY_PRIORITY_POLICY_TYPE
) {
759 ACE_OS::snprintf (buf
, bufsize
,
760 "Policy #%d Type: %d (REPLY_PRIORITY_POLICY_TYPE)\n",
761 iter
+1, policies
[iter
].ptype
);
763 } else if (policies
[iter
].ptype
== Messaging::REQUEST_START_TIME_POLICY_TYPE
) {
765 ACE_OS::snprintf (buf
, bufsize
,
766 "Policy #%d Type: %d (REQUEST_START_TIME_POLICY_TYPE)\n",
767 iter
+1, policies
[iter
].ptype
);
769 } else if (policies
[iter
].ptype
== Messaging::REQUEST_END_TIME_POLICY_TYPE
) {
771 ACE_OS::snprintf (buf
, bufsize
,
772 "Policy #%d Type: %d (REQUEST_END_TIME_POLICY_TYPE)\n",
773 iter
+1, policies
[iter
].ptype
);
775 } else if (policies
[iter
].ptype
== Messaging::REPLY_START_TIME_POLICY_TYPE
) {
777 ACE_OS::snprintf (buf
, bufsize
,
778 "Policy #%d Type: %d (REPLY_START_TIME_POLICY_TYPE)\n",
779 iter
+1, policies
[iter
].ptype
);
781 } else if (policies
[iter
].ptype
== Messaging::REPLY_END_TIME_POLICY_TYPE
) {
783 ACE_OS::snprintf (buf
, bufsize
,
784 "Policy #%d Type: %d (REPLY_END_TIME_POLICY_TYPE)\n",
785 iter
+1, policies
[iter
].ptype
);
787 } else if (policies
[iter
].ptype
== Messaging::RELATIVE_REQ_TIMEOUT_POLICY_TYPE
) {
789 ACE_OS::snprintf (buf
, bufsize
,
790 "Policy #%d Type: %d (RELATIVE_REQ_TIMEOUT_POLICY_TYPE)\n",
791 iter
+1, policies
[iter
].ptype
);
793 } else if (policies
[iter
].ptype
== Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE
) {
795 ACE_OS::snprintf (buf
, bufsize
,
796 "Policy #%d Type: %d (RELATIVE_RT_TIMEOUT_POLICY_TYPE)\n",
797 iter
+1, policies
[iter
].ptype
);
799 } else if (policies
[iter
].ptype
== Messaging::ROUTING_POLICY_TYPE
) {
801 ACE_OS::snprintf (buf
, bufsize
,
802 "Policy #%d Type: %d (ROUTING_POLICY_TYPE)\n",
803 iter
+1, policies
[iter
].ptype
);
805 } else if (policies
[iter
].ptype
== Messaging::MAX_HOPS_POLICY_TYPE
) {
807 ACE_OS::snprintf (buf
, bufsize
,
808 "Policy #%d Type: %d (MAX_HOPS_POLICY_TYPE)\n",
809 iter
+1, policies
[iter
].ptype
);
811 } else if (policies
[iter
].ptype
== Messaging::QUEUE_ORDER_POLICY_TYPE
) {
813 ACE_OS::snprintf (buf
, bufsize
,
814 "Policy #%d Type: %d (QUEUE_ORDER_POLICY_TYPE)\n",
815 iter
+1, policies
[iter
].ptype
);
817 } else if (policies
[iter
].ptype
== ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID
) {
819 ACE_OS::snprintf (buf
, bufsize
,
820 "Policy #%d Type: %d (COMPRESSOR_ID_LEVEL_LIST_POLICY_ID)\n",
821 iter
+1, policies
[iter
].ptype
);
823 ::Compression::CompressorIdLevelList idlist
;
824 if (!(stream3
>> idlist
))
826 CORBA::ULong index
= 0;
827 for (; index
< idlist
.length(); index
++)
830 ACE_OS::snprintf (buf
, bufsize
,
831 "\t CompressorId: %d Level: %d\n",
832 idlist
[index
].compressor_id
, idlist
[index
].compression_level
);
835 } else if (policies
[iter
].ptype
== ZIOP::COMPRESSION_ENABLING_POLICY_ID
) {
837 ACE_OS::snprintf (buf
, bufsize
,
838 "Policy #%d Type: %d (COMPRESSION_ENABLING_POLICY_ID)\n",
839 iter
+1, policies
[iter
].ptype
);
841 CORBA::Boolean status
;
842 if (!(stream3
>> ACE_InputCDR::to_boolean (status
)))
845 ACE_OS::snprintf (buf
, bufsize
, "\t Enabled: %d\n", status
);
849 ACE_OS::snprintf (buf
, bufsize
,
850 "Policy #%d Type: %d (UNKNOWN)\n", iter
+1,
851 policies
[iter
].ptype
);
860 Catior_i::cat_security_association (const CORBA::UShort
& a
) {
861 // Copied from Security.idl
862 typedef CORBA::UShort AssociationOptions
;
863 const AssociationOptions NoProtection
= 1;
864 const AssociationOptions Integrity
= 2;
865 const AssociationOptions Confidentiality
= 4;
866 const AssociationOptions DetectReplay
= 8;
867 const AssociationOptions DetectMisordering
= 16;
868 const AssociationOptions EstablishTrustInTarget
= 32;
869 const AssociationOptions EstablishTrustInClient
= 64;
870 const AssociationOptions NoDelegation
= 128;
871 const AssociationOptions SimpleDelegation
= 256;
872 const AssociationOptions CompositeDelegation
= 512;
874 #define CHECK_PRINT(X) \
875 if (a & X) { indent (); buffer_ += "" #X "\n"; }
877 CHECK_PRINT(NoProtection
);
878 CHECK_PRINT(Integrity
);
879 CHECK_PRINT(Confidentiality
);
880 CHECK_PRINT(DetectReplay
);
881 CHECK_PRINT(DetectMisordering
);
882 CHECK_PRINT(EstablishTrustInTarget
);
883 CHECK_PRINT(EstablishTrustInClient
);
884 CHECK_PRINT(NoDelegation
);
885 CHECK_PRINT(SimpleDelegation
);
886 CHECK_PRINT(CompositeDelegation
);
892 Catior_i::cat_tag_ssl_sec_trans (TAO_InputCDR
& cdr
) {
894 Decode the following from the stream (copied from SSLIOP.idl)
897 typedef unsigned short AssociationOptions;
902 Security::AssociationOptions target_supports;
903 Security::AssociationOptions target_requires;
908 We duplicate the code here because we do not want the catior
909 utility to be dependent upon SSLIOP.
912 CORBA::ULong length
= 0;
913 if (!cdr
.read_ulong (length
))
916 TAO_InputCDR
stream (cdr
, length
);
917 cdr
.skip_bytes(length
);
919 CORBA::UShort target_supports
;
920 CORBA::UShort target_requires
;
923 if (stream
.read_ushort(target_supports
) == 0)
926 if (stream
.read_ushort(target_requires
) == 0)
929 if (stream
.read_ushort(port
) == 0)
932 static const size_t bufsize
= 512;
936 ACE_OS::snprintf (buf
, bufsize
, "port = %d\n", port
);
939 ACE_OS::snprintf (buf
, bufsize
, "target_supports = 0x%x\n", target_supports
);
942 cat_security_association(target_supports
);
945 ACE_OS::snprintf (buf
, bufsize
, "target_requires = 0x%x\n", target_requires
);
948 cat_security_association(target_requires
);
955 Catior_i::cat_octet_seq (const char *object_name
,
956 TAO_InputCDR
& stream
)
958 CORBA::ULong length
= 0;
959 if (!stream
.read_ulong (length
))
962 static const size_t bufsize
= 512;
966 ACE_OS::snprintf (buf
, bufsize
, "%s len:\t%d\n", object_name
, length
);
970 ACE_OS::snprintf (buf
, bufsize
, "%s as hex:\n", object_name
);
973 CORBA::Octet anOctet
;
974 CORBA::String_var objKey
= CORBA::string_alloc (length
+ 1);
981 for (; i
< length
; ++i
)
990 if (!stream
.read_octet (anOctet
))
993 ACE_OS::snprintf (buf
, bufsize
, "%2.2x ", anOctet
);
995 objKey
[i
] = (char) anOctet
;
1002 ACE_OS::snprintf (buf
, bufsize
,
1003 "The %s as string:\n", object_name
);
1007 for (i
= 0; i
< length
; ++i
)
1010 int tmp
= (unsigned char) c
; // isprint doesn't work with negative vals.(except EOF)
1011 if (ACE_OS::ace_isprint (static_cast<ACE_TCHAR
> (tmp
)))
1023 Catior_i::cat_object_key (TAO_InputCDR
& stream
)
1025 // ... and object key.
1027 return cat_octet_seq ("Object Key", stream
);
1031 Catior_i::_find_info (CORBA::ULong id
)
1033 ACE_CString locale
= "";
1034 ACE_Codeset_Registry::registry_to_locale (id
, locale
, 0, 0);
1039 Catior_i::displayHex (TAO_InputCDR
& str
)
1041 if (str
.good_bit () == 0)
1044 TAO_InputCDR
clone_str (str
);
1045 CORBA::ULong theSetId
;
1046 if (!str
.read_ulong (theSetId
))
1048 ACE_ERROR ((LM_ERROR
,
1049 "Unable to read codeset ID.\n"));
1053 static const size_t bufsize
= 512;
1055 ACE_OS::snprintf (buf
, bufsize
, " Hex - %x\tDescription - ", theSetId
);
1058 ACE_CString theDescr
= _find_info (theSetId
);
1060 if (theDescr
.length () == 0)
1061 buffer_
+= "Unknown CodeSet\n";
1064 buffer_
+= theDescr
.c_str ();
1070 Catior_i::cat_codeset_info (TAO_InputCDR
& cdr
)
1072 CORBA::ULong length
= 0;
1073 if (cdr
.read_ulong (length
) == 0)
1076 TAO_InputCDR
stream (cdr
, length
);
1077 cdr
.skip_bytes(length
);
1079 static const size_t bufsize
= 512;
1082 ACE_OS::snprintf (buf
, bufsize
, "\tComponent length: %u\n", length
);
1085 buffer_
+= "\tComponent byte order:\t";
1086 buffer_
+= (stream
.byte_order () ? "Little" : "Big");
1087 buffer_
+= " Endian\n";
1089 // CodesetId for char
1090 // CORBA::ULong c_ncsId;
1091 buffer_
+= "\tNative CodeSet for char: ";
1092 displayHex (stream
);
1094 // number of Conversion Codesets for char
1095 CORBA::ULong c_ccslen
= 0;
1097 if (!(stream
>> c_ccslen
))
1098 ACE_ERROR_RETURN ((LM_ERROR
,
1099 "Unable to read number of conversion codesets "
1103 ACE_OS::snprintf (buf
, bufsize
, "\tNumber of CCS for char %u\n", c_ccslen
);
1107 buffer_
+= "\tConversion Codesets for char are:\n";
1109 // Loop through and display them
1110 CORBA::ULong index
= 0;
1111 for ( ; index
< c_ccslen
; ++index
)
1113 // CodesetId for char
1114 ACE_OS::snprintf (buf
, bufsize
,
1115 "\t" ACE_UINT32_FORMAT_SPECIFIER_ASCII
") ",
1118 displayHex (stream
);
1121 // CodesetId for wchar
1122 buffer_
+= "\tNative CodeSet for wchar: ";
1123 displayHex (stream
);
1125 // number of Conversion Codesets for wchar
1126 CORBA::ULong w_ccslen
=0;
1128 if (!(stream
>> w_ccslen
))
1129 ACE_ERROR_RETURN ((LM_ERROR
,
1130 "Unable to read number of conversion codesets "
1134 ACE_OS::snprintf (buf
, bufsize
, "\tNumber of CCS for wchar %u\n", w_ccslen
);
1138 buffer_
+= "\tConversion Codesets for wchar are:\n";
1140 // Loop through and display them
1141 for (index
= 0; index
< w_ccslen
; ++index
)
1143 ACE_OS::snprintf (buf
, bufsize
,
1144 "\t " ACE_UINT32_FORMAT_SPECIFIER_ASCII
") ",
1147 displayHex (stream
);
1153 Catior_i::cat_tagged_components (TAO_InputCDR
& stream
)
1155 // ... and object key.
1158 if (!(stream
>> len
))
1161 static const size_t bufsize
= 512;
1164 for (CORBA::ULong i
= 0;
1169 if (!(stream
>> tag
))
1171 ACE_ERROR_RETURN ((LM_ERROR
,
1172 "Unable to read component tag.\n"),
1177 ACE_OS::snprintf (buf
, bufsize
,
1178 "The component <" ACE_UINT32_FORMAT_SPECIFIER_ASCII
1179 "> ID is " ACE_UINT32_FORMAT_SPECIFIER_ASCII
,
1183 if (tag
== IOP::TAG_ORB_TYPE
) {
1184 ACE_OS::snprintf (buf
, bufsize
, " (TAG_ORB_TYPE)\n");
1187 cat_tag_orb_type(stream
);
1189 } else if (tag
== IOP::TAG_CODE_SETS
) {
1190 ACE_OS::snprintf (buf
, bufsize
, " (TAG_CODE_SETS)\n");
1193 cat_codeset_info(stream
);
1195 } else if (tag
== IOP::TAG_ALTERNATE_IIOP_ADDRESS
) {
1196 ACE_OS::snprintf (buf
, bufsize
, " (TAG_ALTERNATE_IIOP_ADDRESS)\n");
1199 cat_tag_alternate_endpoints (stream
);
1201 } else if (tag
== TAO_TAG_ENDPOINTS
) {
1202 ACE_OS::snprintf (buf
, bufsize
, " (TAO_TAG_ENDPOINTS)\n");
1205 cat_tao_tag_endpoints(stream
);
1207 } else if (tag
== IOP::TAG_POLICIES
) {
1208 ACE_OS::snprintf (buf
, bufsize
, " (TAG_POLICIES)\n");
1211 cat_tag_policies(stream
);
1213 } else if (tag
== 20U /* SSLIOP::TAG_SSL_SEC_TRANS */) {
1214 ACE_OS::snprintf (buf
, bufsize
, " (TAG_SSL_SEC_TRANS)\n");
1217 cat_tag_ssl_sec_trans(stream
);
1219 } else if (tag
== 38U /* TAG_RMI_CUSTOM_MAX_STREAM_FORMAT */) {
1220 ACE_OS::snprintf (buf
, bufsize
, "(TAG_RMI_CUSTOM_MAX_STREAM_FORMAT)\n");
1223 cat_octet_seq ("Component Value", stream
);
1225 } else if (tag
== 1229081866U /* IBM_PARTNER_VERSION */) {
1226 ACE_OS::snprintf (buf
, bufsize
, " (IBM_PARTNER_VERSION)\n");
1229 cat_ibm_partner_version (stream
);
1232 ACE_OS::snprintf (buf
, bufsize
, " (Unrecognized tag)\n");
1235 cat_octet_seq ("Component Value", stream
);
1244 Catior_i::cat_profile_helper (TAO_InputCDR
& stream
,
1245 const char *protocol
)
1247 // OK, we've got an IIOP profile. It's going to be
1248 // encapsulated ProfileData. Create a new decoding stream and
1249 // context for it, and tell the "parent" stream that this data
1250 // isn't part of it any more.
1252 CORBA::ULong encap_len
;
1253 if (stream
.read_ulong (encap_len
) == 0)
1255 ACE_ERROR_RETURN ((LM_ERROR
,
1256 "cannot read encap length\n"), false);
1259 // Create the decoding stream from the encapsulation in the
1260 // buffer, and skip the encapsulation.
1261 TAO_InputCDR
str (stream
, encap_len
);
1263 if (str
.good_bit () == 0 || stream
.skip_bytes (encap_len
) == 0)
1266 static const size_t bufsize
= 512;
1269 // Read and verify major, minor versions, ignoring IIOP
1270 // profiles whose versions we don't understand.
1272 // XXX this doesn't actually go back and skip the whole
1274 CORBA::Octet iiop_version_major
= 1;
1275 CORBA::Octet iiop_version_minor
= 0;
1276 if (! (str
.read_octet (iiop_version_major
)
1277 && iiop_version_major
== 1
1278 && str
.read_octet (iiop_version_minor
)
1279 && iiop_version_minor
<= 2))
1282 ACE_OS::snprintf (buf
, bufsize
,
1283 "detected new v%d.%d %s profile that catior cannot decode\n",
1291 ACE_OS::snprintf (buf
, bufsize
,
1292 "%s Version:\t%d.%d\n",
1293 protocol
, iiop_version_major
, iiop_version_minor
);
1296 // Get host and port.
1297 CORBA::UShort port_number
;
1298 CORBA::String_var hostname
;
1299 if (!(str
>> hostname
.inout ()))
1302 buffer_
+= "problem decoding hostname\n";
1306 if (!(str
>> port_number
))
1310 buffer_
+= "Host Name:\t";
1311 buffer_
+= hostname
.in ();
1315 ACE_OS::snprintf (buf
, bufsize
, "Port Number:\t%d\n", port_number
);
1318 if (!cat_object_key (str
))
1321 //IIOP 1.0 does not have tagged_components.
1322 if (!(iiop_version_major
== 1 && iiop_version_minor
== 0))
1324 if (cat_tagged_components (str
) == 0)
1334 Catior_i::cat_coiop_profile (TAO_InputCDR
& stream
)
1336 // OK, we've got an COIOP profile. It's going to be
1337 // encapsulated ProfileData. Create a new decoding stream and
1338 // context for it, and tell the "parent" stream that this data
1339 // isn't part of it any more.
1341 CORBA::ULong encap_len
;
1342 if (stream
.read_ulong (encap_len
) == 0)
1344 ACE_ERROR_RETURN ((LM_ERROR
, "cannot read encap length\n"), false);
1347 // Create the decoding stream from the encapsulation in the
1348 // buffer, and skip the encapsulation.
1349 TAO_InputCDR
str (stream
, encap_len
);
1351 if (str
.good_bit () == 0 || stream
.skip_bytes (encap_len
) == 0)
1354 static const size_t bufsize
= 512;
1357 // Read and verify major, minor versions, ignoring IIOP
1358 // profiles whose versions we don't understand.
1360 // XXX this doesn't actually go back and skip the whole
1362 CORBA::Octet iiop_version_major
= 1;
1363 CORBA::Octet iiop_version_minor
= 0;
1364 if (! (str
.read_octet (iiop_version_major
)
1365 && iiop_version_major
== 1
1366 && str
.read_octet (iiop_version_minor
)
1367 && iiop_version_minor
<= 2))
1370 ACE_OS::snprintf (buf
, bufsize
,
1371 "detected new v%d.%d COIOP profile that catior cannot decode",
1373 iiop_version_minor
);
1378 ACE_OS::snprintf (buf
, bufsize
,
1379 "COIOP Version:\t%d.%d\n",
1381 iiop_version_minor
);
1384 // Get host and port.
1385 CORBA::String_var uuid
;
1386 if (!(str
>> uuid
.inout ()))
1389 buffer_
+= "problem decoding uuid\n";
1394 buffer_
+= "UUID:\t";
1395 buffer_
+= uuid
.in ();
1398 if (cat_object_key (str
) == 0)
1401 //IIOP 1.0 does not have tagged_components.
1402 if (!(iiop_version_major
== 1 && iiop_version_minor
== 0))
1404 if (cat_tagged_components (str
) == 0)
1414 Catior_i::cat_iiop_profile (TAO_InputCDR
& stream
)
1416 return cat_profile_helper (stream
, "IIOP");
1420 Catior_i::cat_shmiop_profile (TAO_InputCDR
& stream
)
1422 return cat_profile_helper (stream
, "SHMIOP");
1426 Catior_i::cat_uiop_profile (TAO_InputCDR
& stream
)
1428 // OK, we've got a UIOP profile. It's going to be encapsulated
1429 // ProfileData. Create a new decoding stream and context for it,
1430 // and tell the "parent" stream that this data isn't part of it any
1433 CORBA::ULong encap_len
;
1434 if (stream
.read_ulong (encap_len
) == 0)
1437 // Create the decoding stream from the encapsulation in the
1438 // buffer, and skip the encapsulation.
1439 TAO_InputCDR
str (stream
, encap_len
);
1441 if (str
.good_bit () == 0 || stream
.skip_bytes (encap_len
) == 0)
1444 static const size_t bufsize
= 512;
1447 // Read and verify major, minor versions, ignoring UIOP
1448 // profiles whose versions we don't understand.
1450 // XXX this doesn't actually go back and skip the whole
1452 CORBA::Octet uiop_version_major
= 1;
1453 CORBA::Octet uiop_version_minor
= 0;
1454 // It appears that as of April 2002 UIOP version is 1.2
1455 if (! (str
.read_octet (uiop_version_major
)
1456 && uiop_version_major
== 1
1457 && str
.read_octet (uiop_version_minor
)
1458 && uiop_version_minor
<= 2))
1461 ACE_OS::snprintf (buf
, bufsize
,
1462 "detected new v%d.%d UIOP profile",
1464 uiop_version_minor
);
1470 ACE_OS::snprintf (buf
, bufsize
,
1471 "UIOP Version:\t%d.%d\n",
1473 uiop_version_minor
);
1476 // Get host and port.
1477 CORBA::String_var rendezvous
;
1478 if ((str
>> rendezvous
.out ()) == 0)
1482 buffer_
+= "Rendezvous point:\t";
1483 buffer_
+= rendezvous
.in ();
1486 if (cat_object_key (str
) == 0)
1489 if (cat_tagged_components (str
) == 0)
1496 Catior_i::cat_multiple_components (TAO_InputCDR
& stream
)
1498 static const size_t bufsize
= 512;
1501 ACE_OS::snprintf (buf
, bufsize
,
1502 "Multiple Components Profile\n");
1504 return cat_tagged_components (stream
);
1508 Catior_i::cat_sciop_profile (TAO_InputCDR
& stream
)
1510 // OK, we've got an SCIOP profile.
1512 CORBA::ULong encap_len
;
1513 if (stream
.read_ulong (encap_len
) == 0)
1515 ACE_ERROR_RETURN ((LM_ERROR
, "cannot read encap length\n"), false);
1518 // Create the decoding stream from the encapsulation in the
1519 // buffer, and skip the encapsulation.
1520 TAO_InputCDR
str (stream
, encap_len
);
1522 if (str
.good_bit () == 0 || stream
.skip_bytes (encap_len
) == 0)
1525 static const size_t bufsize
= 512;
1528 // Read and verify major, minor versions, ignoring IIOP
1529 // profiles whose versions we don't understand.
1531 // XXX this doesn't actually go back and skip the whole
1533 CORBA::Octet iiop_version_major
= 1;
1534 CORBA::Octet iiop_version_minor
= 0;
1535 if (! (str
.read_octet (iiop_version_major
)
1536 && iiop_version_major
== 1
1537 && str
.read_octet (iiop_version_minor
)
1538 && iiop_version_minor
<= 0))
1541 ACE_OS::snprintf (buf
, bufsize
,
1542 "detected new v%d.%d SCIOP profile that catior cannot decode",
1544 iiop_version_minor
);
1550 ACE_OS::snprintf (buf
, bufsize
,
1551 "SCIOP Version:\t%d.%d\n",
1553 iiop_version_minor
);
1556 // Get host and port.
1557 CORBA::UShort port_number
;
1558 CORBA::UShort max_streams
;
1559 CORBA::ULong addresses
;
1561 if (!(str
>> addresses
))
1562 ACE_ERROR_RETURN ((LM_ERROR
,
1563 "Unable to decode number of addresses\n."),
1567 ACE_OS::snprintf (buf
, bufsize
, "Addresses:\t%d\n", addresses
);
1570 for (CORBA::ULong i
= 0; i
< addresses
; ++i
)
1572 CORBA::String_var hostname
;
1573 if (!(str
>> hostname
.inout ()))
1575 ACE_ERROR_RETURN ((LM_ERROR
,
1576 "%I problem decoding hostname\n"),
1581 buffer_
+= "Host Name:\t";
1582 buffer_
+= hostname
.in ();
1587 if (!(str
>> port_number
))
1591 ACE_OS::snprintf (buf
, bufsize
, "Port Number:\t%d\n", port_number
);
1594 if (!(str
>> max_streams
))
1598 ACE_OS::snprintf (buf
, bufsize
, "Max Streams:\t%d\n", max_streams
);
1601 // Unlike IIOP (1.0), SCIOP always has tagged_components.
1602 if (!cat_object_key (str
) || !cat_tagged_components (str
))
1610 Catior_i::cat_nsk_profile_helper (TAO_InputCDR
& stream
,
1611 const char *protocol
)
1613 // OK, we've got an NSK profile. It's going to be
1614 // encapsulated ProfileData. Create a new decoding stream and
1615 // context for it, and tell the "parent" stream that this data
1616 // isn't part of it any more.
1618 CORBA::ULong encap_len
;
1619 if (stream
.read_ulong (encap_len
) == 0)
1621 ACE_ERROR_RETURN ((LM_ERROR
, "cannot read encap length\n"), false);
1624 // Create the decoding stream from the encapsulation in the
1625 // buffer, and skip the encapsulation.
1626 TAO_InputCDR
str (stream
, encap_len
);
1628 if (str
.good_bit () == 0 || stream
.skip_bytes (encap_len
) == 0)
1631 static const size_t bufsize
= 512;
1634 // Read and verify major, minor versions, ignoring NSK
1635 // profiles whose versions we don't understand.
1637 // XXX this doesn't actually go back and skip the whole
1639 CORBA::Octet iiop_version_major
= 1;
1640 CORBA::Octet iiop_version_minor
= 0;
1641 if (! (str
.read_octet (iiop_version_major
)
1642 && iiop_version_major
== 1
1643 && str
.read_octet (iiop_version_minor
)
1644 && iiop_version_minor
<= 2))
1647 ACE_OS::snprintf (buf
, bufsize
,
1648 "detected new v%d.%d %s profile that catior cannot decode",
1656 ACE_OS::snprintf (buf
, bufsize
,
1657 "%s Version:\t%d.%d\n",
1660 iiop_version_minor
);
1665 if (!(str
>> fsaddress
))
1668 buffer_
+= "problem decoding file system address\n";
1674 buffer_
+= "FS Address:\t";
1675 buffer_
+= fsaddress
;
1677 CORBA::string_free (fsaddress
);
1679 if (cat_object_key (str
) == 0)
1682 // Version 1.0 does not have tagged_components.
1683 if (!(iiop_version_major
== 1 && iiop_version_minor
== 0))
1685 if (cat_tagged_components (str
) == 0)
1695 Catior_i::cat_nskpw_profile (TAO_InputCDR
& stream
)
1697 return cat_nsk_profile_helper (stream
, "NSKPW");
1701 Catior_i::cat_nskfs_profile (TAO_InputCDR
& stream
)
1703 return cat_nsk_profile_helper (stream
, "NSKFS");
1709 if (trace_depth_
!= 0)
1711 for(size_t i
= 0; i
< trace_depth_
; i
++)