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";
94 Catior_i::catiiop (char* string
)
96 // NIL objref encodes as just "iiop:" ... which has already been
97 // removed, so we see it as an empty string.
99 if (!string
|| !*string
)
102 // Type ID not encoded in this string ... makes narrowing rather
103 // expensive, though it does ensure that type-safe narrowing code
104 // gets thoroughly excercised/debugged! Without a typeID, the
105 // _narrow will be required to make an expensive remote "is_a" call.
107 // Remove the "N.N//" prefix, and verify the version's one that we
110 CORBA::Short iiop_version_major
= 1;
111 CORBA::Short iiop_version_minor
= 0;
113 if (ACE_OS::ace_isdigit (string
[0])
114 && ACE_OS::ace_isdigit (string
[2])
117 && string
[4] == '/')
119 iiop_version_major
= (char) (string
[0] - '0');
120 iiop_version_minor
= (char) (string
[2] - '0');
128 static const size_t bufsize
= 512;
130 ACE_OS::snprintf (buf
, bufsize
, "IIOP Version:\t%d.%d\n",
131 iiop_version_major
, iiop_version_minor
);
134 // Pull off the "hostname:port/" part of the objref Get host and
136 CORBA::UShort port_number
;
137 char *cp
= ACE_OS::strchr (string
, ':');
141 throw CORBA::DATA_CONVERSION ();
144 CORBA::String_var hostname
= CORBA::string_alloc (1 +
145 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
147 for (cp
= hostname
.inout ();
155 cp
= ACE_OS::strchr ((char *) string
, '/');
159 throw CORBA::DATA_CONVERSION ();
162 port_number
= (short) ACE_OS::atoi ((char *) string
);
165 ACE_OS::snprintf (buf
, bufsize
, "Host Name:\t%s\n"
166 "Port Number:\t%d\n",
167 hostname
.in (), port_number
);
170 // Parse the object key.
171 // dump the object key to stdout
172 // TAO_POA::decode_string_to_sequence (data->profile.object_key,
174 buffer_
+= "\nThe Object Key as string:\n";
182 Catior_i::catior (char const * str
)
184 // Unhex the bytes, and make a CDR deencapsulation stream from the
187 ACE_Message_Block
mb (ACE_OS::strlen (str
) / 2 + 1
188 + ACE_CDR::MAX_ALIGNMENT
);
189 ACE_CDR::mb_align (&mb
);
191 char * const buffer
= mb
.rd_ptr ();
192 char const * tmp
= (char *) str
;
195 CORBA::Boolean continue_decoding
;
197 // The prefix of the IOR must be removed, and the string must start
198 // with the encapsulation byte
200 while (tmp
[0] && tmp
[1])
204 if (! (ACE_OS::ace_isxdigit (tmp
[0]) && ACE_OS::ace_isxdigit (tmp
[1])))
207 byte
= (u_char
) (ACE::hex2byte (tmp
[0]) << 4);
208 byte
|= ACE::hex2byte (tmp
[1]);
210 buffer
[len
++] = byte
;
214 // Create deencapsulation stream ... then unmarshal objref from that
217 int byteOrder
= *(mb
.rd_ptr ());
221 TAO_InputCDR
stream (&mb
, static_cast<int> (byteOrder
));
223 buffer_
+= "The Byte Order:\t";
225 buffer_
+= "Little Endian\n";
227 buffer_
+= "Big Endian\n";
229 // First, read the type hint. This will be the type_id encoded in an
231 CORBA::String_var type_hint
;
233 if (!(stream
>> type_hint
.inout ()))
235 ACE_ERROR_RETURN ((LM_ERROR
,
236 "cannot read type id\n"),
240 buffer_
+= "The Type Id:\t\"";
241 buffer_
+= type_hint
.in ();
244 // Read the profiles, discarding all until an IIOP profile comes by.
245 // Once we see an IIOP profile, ignore any further ones.
247 // XXX this will need to change someday to let different protocol
248 // code be accessed, not just IIOP. Protocol modules will be
249 // dynamically loaded from shared libraries via ORB_init (), and we
250 // just need to be able to access such preloaded libraries here as
251 // we unmarshal objrefs.
253 CORBA::ULong profiles
= 0;
255 continue_decoding
= stream
.read_ulong (profiles
);
257 // Get the count of profiles that follow.
258 if (!continue_decoding
)
260 ACE_ERROR_RETURN ((LM_ERROR
,
261 "cannot read the profile count\n"),
265 CORBA::ULong profile_counter
= 0;
267 static const size_t bufsize
= 512;
269 ACE_OS::snprintf (buf
, bufsize
,
270 "Number of Profiles in IOR:\t%d\n", profiles
);
273 // No profiles means a NIL objref.
275 return TAO::TRAVERSE_CONTINUE
;
277 while (profiles
-- != 0)
279 ACE_OS::snprintf (buf
, bufsize
, "Profile number:\t%d\n",
283 // We keep decoding until we find a valid IIOP profile.
286 continue_decoding
= stream
.read_ulong (tag
);
288 // Get the profile ID tag.
289 if (!continue_decoding
)
291 ACE_ERROR ((LM_ERROR
, "cannot read profile tag\n"));
296 if (tag
== IOP::TAG_INTERNET_IOP
)
298 continue_decoding
= cat_iiop_profile (stream
);
300 else if (tag
== IOP::TAG_MULTIPLE_COMPONENTS
)
302 continue_decoding
= cat_multiple_components (stream
);
304 else if (tag
== TAO_TAG_SCIOP_PROFILE
)
306 continue_decoding
= cat_sciop_profile (stream
);
308 else if (tag
== TAO_TAG_UIOP_PROFILE
)
310 continue_decoding
= cat_uiop_profile (stream
);
312 else if (tag
== TAO_TAG_SHMEM_PROFILE
)
314 continue_decoding
= cat_shmiop_profile (stream
);
316 else if (tag
== TAO_TAG_DIOP_PROFILE
)
318 continue_decoding
= cat_profile_helper(stream
, "DIOP (GIOP over UDP)");
320 else if (tag
== TAO_TAG_COIOP_PROFILE
)
322 continue_decoding
= cat_coiop_profile(stream
);
324 else if (tag
== TAO_TAG_NSKPW_PROFILE
)
326 continue_decoding
= cat_nskpw_profile (stream
);
328 else if (tag
== TAO_TAG_NSKFS_PROFILE
)
330 continue_decoding
= cat_nskfs_profile (stream
);
335 ACE_OS::snprintf (buf
, bufsize
,
336 "Profile tag = %d (unknown protocol)\n", tag
);
338 continue_decoding
= cat_octet_seq("Profile body", stream
);
345 // Parse the Orbix-style POOP object references, which have the form:
346 //:\ntlj3corba:NS:NC_2::IR:CosNaming_NamingContext
352 // : interface_marker
355 Catior_i::catpoop (char* string
)
357 if (!string
|| !*string
)
360 //if (string [0] == ':'
361 // && string [1] == '\\')
362 // ACE_DEBUG ((LM_DEBUG,
363 // "\nPerhaps we've found some POOP\n"));
366 char *cp
= ACE_OS::strchr (string
, ':');
370 throw CORBA::DATA_CONVERSION ();
373 // Read the hostname.
374 char* hostname
= CORBA::string_alloc (1 +
375 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
385 buffer_
+= "Host Name:\t";
388 CORBA::string_free (hostname
);
390 // read the server name
391 cp
= ACE_OS::strchr (string
, ':');
393 char* server_name
= CORBA::string_alloc (1 +
394 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
396 for (cp
= server_name
;
404 buffer_
+= "Server Name:\t";
405 buffer_
+= server_name
;
408 CORBA::string_free (server_name
);
410 // Read the Orbix specific marker.
411 cp
= ACE_OS::strchr (string
, ':');
413 char* marker
= CORBA::string_alloc (1 +
414 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
424 buffer_
+= "Marker:\t\t";
427 CORBA::string_free (marker
);
429 cp
= ACE_OS::strchr (string
, ':');
432 char* IR_host
= CORBA::string_alloc (1 +
433 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
443 buffer_
+= "IR Host:\t\t";
446 CORBA::string_free (IR_host
);
448 // Read the IR_server
449 cp
= ACE_OS::strchr (string
, ':');
451 char* IR_server
= CORBA::string_alloc (1 +
452 ACE_Utils::truncate_cast
<CORBA::ULong
> (cp
- string
));
462 buffer_
+= "IR Server:\t\t";
463 buffer_
+= IR_server
;
465 CORBA::string_free (IR_server
);
467 // Read the interface_marker
468 buffer_
+= "Interface Marker:\t";
475 Catior_i::cat_tag_orb_type (TAO_InputCDR
& stream
) {
476 CORBA::ULong length
= 0;
477 if (!stream
.read_ulong (length
))
480 TAO_InputCDR
stream2 (stream
, length
);
481 stream
.skip_bytes(length
);
483 CORBA::ULong orbtype
;
485 if (!(stream2
>> orbtype
))
488 static const size_t bufsize
= 512;
497 ACE_OS::snprintf (buf
, bufsize
,
498 "ORB Type: 0x%x (TAO)\n", orbtype
);
503 ACE_OS::snprintf (buf
, bufsize
,
504 "ORB Type: 0x%x (GNU Classpath)\n", orbtype
);
509 ACE_OS::snprintf (buf
, bufsize
,
510 "ORB Type: 0x%x (Orbix)\n", orbtype
);
515 ACE_OS::snprintf (buf
, bufsize
,
516 "ORB Type: 0x%x (JacORB)\n", orbtype
);
521 ACE_OS::snprintf (buf
, bufsize
,
522 "ORB Type: 0x%x (OmniORB)\n", orbtype
);
527 ACE_OS::snprintf (buf
, bufsize
,
528 "ORB Type: 0x%x (Sun)\n", orbtype
);
533 ACE_OS::snprintf (buf
, bufsize
,
534 "ORB Type: 0x%x (TIDorbC++)\n", orbtype
);
539 ACE_OS::snprintf (buf
, bufsize
,
540 "ORB Type: 0x%x (JacORB)\n", orbtype
);
545 ACE_OS::snprintf (buf
, bufsize
,
546 "ORB Type: 0x%x\n", orbtype
);
555 Catior_i::cat_ibm_partner_version (TAO_InputCDR
& stream
) {
557 * IBM Partner version looks like:
558 * 49424d0a 00000008 00000000 1400 0005
559 * The three initial bytes (from left to right) are the ASCII code for IBM,
560 * followed by 0x0A, which specifies that the following bytes handle the
562 * The next four bytes encode the length of the remaining data (in this
564 * The next four null bytes are for future use.
565 * The two bytes for the Partner Version Major field (0x1400) define the
566 * release of the ORB that is being used (1.4.0 in this case).
567 * The Minor field (0x0005) distinguishes in the same release, service
568 * refreshes that contain changes that have affected the backward
571 CORBA::ULong length
= 0;
572 if (!(stream
.read_ulong (length
)))
575 TAO_InputCDR
stream2 (stream
, length
);
576 stream
.skip_bytes(length
);
578 CORBA::ULong version
;
579 if (!(stream2
>> version
))
582 static const size_t bufsize
= 512;
584 ACE_OS::snprintf (buf
, bufsize
, "\tPartner Version: 0x%x\n", version
);
592 Catior_i::cat_tao_tag_endpoints (TAO_InputCDR
& stream
)
594 CORBA::ULong length
= 0;
595 if (!stream
.read_ulong (length
))
598 TAO_InputCDR
stream2 (stream
, length
);
599 stream
.skip_bytes(length
);
601 TAO::IIOPEndpointSequence epseq
;
602 if (!(stream2
>> epseq
))
605 static const size_t bufsize
= 512;
607 for (unsigned int iter
=0; iter
< epseq
.length() ; iter
++) {
608 const char *host
= epseq
[iter
].host
;
609 CORBA::UShort port
= epseq
[iter
].port
;
611 ACE_OS::snprintf (buf
, bufsize
,
612 "Endpoint #%d:\n", iter
+1);
615 ACE_OS::snprintf (buf
, bufsize
,
619 ACE_OS::snprintf (buf
, bufsize
,
623 ACE_OS::snprintf (buf
, bufsize
,
624 "Priority: %d\n", epseq
[iter
].priority
);
632 Catior_i::cat_tag_alternate_endpoints (TAO_InputCDR
& stream
) {
633 CORBA::ULong length
= 0;
634 if (!stream
.read_ulong (length
))
637 TAO_InputCDR
stream2 (stream
, length
);
638 stream
.skip_bytes(length
);
640 CORBA::String_var host
;
642 if (!(stream2
>> host
.out()) ||
645 ACE_ERROR_RETURN ((LM_ERROR
,"cannot extract endpoint info\n"),false);
649 static const size_t bufsize
= 512;
652 ACE_OS::snprintf (buf
, bufsize
,
653 "endpoint: %s:%d\n", host
.in(), port
);
661 Catior_i::cat_tag_policies (TAO_InputCDR
& stream
) {
662 CORBA::ULong length
= 0;
663 if (!stream
.read_ulong (length
))
666 TAO_InputCDR
stream2 (stream
, length
);
667 stream
.skip_bytes(length
);
669 Messaging::PolicyValueSeq policies
;
670 if (!(stream2
>> policies
))
673 static const size_t bufsize
= 512;
676 ACE_OS::snprintf (buf
, bufsize
,
677 "Number of policies: %d\n",
681 for (unsigned int iter
=0; iter
< policies
.length() ; iter
++) {
682 // Create new stream for pvalue contents
683 const CORBA::Octet
*pmbuf
= policies
[iter
].pvalue
.get_buffer ();
685 TAO_InputCDR
stream3 (
686 reinterpret_cast <const char*> (pmbuf
),
687 policies
[iter
].pvalue
.length ());
689 CORBA::Boolean byte_order
;
690 if (!(stream3
>> ACE_InputCDR::to_boolean (byte_order
)))
693 stream3
.reset_byte_order (static_cast <int> (byte_order
));
695 if (policies
[iter
].ptype
== RTCORBA::PRIORITY_MODEL_POLICY_TYPE
) {
697 ACE_OS::snprintf (buf
, bufsize
,
698 "Policy #%d Type: %d (PRIORITY_MODEL_POLICY_TYPE)\n",
699 iter
+1, policies
[iter
].ptype
);
702 RTCORBA::PriorityModel priority_model
;
703 RTCORBA::Priority server_priority
;
705 if (!(stream3
>> priority_model
))
707 if (!(stream3
>> server_priority
))
711 if (priority_model
== RTCORBA::CLIENT_PROPAGATED
) {
712 ACE_OS::snprintf (buf
, bufsize
,
713 "\t Priority Model: %d (CLIENT_PROPAGATED)\n",
715 } else if (priority_model
== RTCORBA::SERVER_DECLARED
) {
716 ACE_OS::snprintf (buf
, bufsize
,
717 "\t Priority Model: %d (SERVER_DECLARED)\n",
720 ACE_OS::snprintf (buf
, bufsize
,
721 "\t Priority Model: %d (UNKNOWN!)\n",
726 ACE_OS::snprintf (buf
, bufsize
,
727 "\t Priority: %d\n", server_priority
);
729 } else if (policies
[iter
].ptype
== RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE
) {
731 ACE_OS::snprintf (buf
, bufsize
,
732 "Policy #%d Type: %d (PRIORITY_BANDED_CONNECTION_POLICY_TYPE)\n",
733 iter
+1, policies
[iter
].ptype
);
735 } else if (policies
[iter
].ptype
== Messaging::REBIND_POLICY_TYPE
) {
737 ACE_OS::snprintf (buf
, bufsize
,
738 "Policy #%d Type: %d (REBIND_POLICY_TYPE)\n",
739 iter
+1, policies
[iter
].ptype
);
741 #if (TAO_HAS_SYNC_SCOPE_POLICY == 1)
742 } else if (policies
[iter
].ptype
== Messaging::SYNC_SCOPE_POLICY_TYPE
) {
744 ACE_OS::snprintf (buf
, bufsize
,
745 "Policy #%d Type: %d (SYNC_SCOPE_POLICY_TYPE)\n",
746 iter
+1, policies
[iter
].ptype
);
749 } else if (policies
[iter
].ptype
== Messaging::REQUEST_PRIORITY_POLICY_TYPE
) {
751 ACE_OS::snprintf (buf
, bufsize
,
752 "Policy #%d Type: %d (REQUEST_PRIORITY_POLICY_TYPE)\n",
753 iter
+1, policies
[iter
].ptype
);
755 } else if (policies
[iter
].ptype
== Messaging::REPLY_PRIORITY_POLICY_TYPE
) {
757 ACE_OS::snprintf (buf
, bufsize
,
758 "Policy #%d Type: %d (REPLY_PRIORITY_POLICY_TYPE)\n",
759 iter
+1, policies
[iter
].ptype
);
761 } else if (policies
[iter
].ptype
== Messaging::REQUEST_START_TIME_POLICY_TYPE
) {
763 ACE_OS::snprintf (buf
, bufsize
,
764 "Policy #%d Type: %d (REQUEST_START_TIME_POLICY_TYPE)\n",
765 iter
+1, policies
[iter
].ptype
);
767 } else if (policies
[iter
].ptype
== Messaging::REQUEST_END_TIME_POLICY_TYPE
) {
769 ACE_OS::snprintf (buf
, bufsize
,
770 "Policy #%d Type: %d (REQUEST_END_TIME_POLICY_TYPE)\n",
771 iter
+1, policies
[iter
].ptype
);
773 } else if (policies
[iter
].ptype
== Messaging::REPLY_START_TIME_POLICY_TYPE
) {
775 ACE_OS::snprintf (buf
, bufsize
,
776 "Policy #%d Type: %d (REPLY_START_TIME_POLICY_TYPE)\n",
777 iter
+1, policies
[iter
].ptype
);
779 } else if (policies
[iter
].ptype
== Messaging::REPLY_END_TIME_POLICY_TYPE
) {
781 ACE_OS::snprintf (buf
, bufsize
,
782 "Policy #%d Type: %d (REPLY_END_TIME_POLICY_TYPE)\n",
783 iter
+1, policies
[iter
].ptype
);
785 } else if (policies
[iter
].ptype
== Messaging::RELATIVE_REQ_TIMEOUT_POLICY_TYPE
) {
787 ACE_OS::snprintf (buf
, bufsize
,
788 "Policy #%d Type: %d (RELATIVE_REQ_TIMEOUT_POLICY_TYPE)\n",
789 iter
+1, policies
[iter
].ptype
);
791 } else if (policies
[iter
].ptype
== Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE
) {
793 ACE_OS::snprintf (buf
, bufsize
,
794 "Policy #%d Type: %d (RELATIVE_RT_TIMEOUT_POLICY_TYPE)\n",
795 iter
+1, policies
[iter
].ptype
);
797 } else if (policies
[iter
].ptype
== Messaging::ROUTING_POLICY_TYPE
) {
799 ACE_OS::snprintf (buf
, bufsize
,
800 "Policy #%d Type: %d (ROUTING_POLICY_TYPE)\n",
801 iter
+1, policies
[iter
].ptype
);
803 } else if (policies
[iter
].ptype
== Messaging::MAX_HOPS_POLICY_TYPE
) {
805 ACE_OS::snprintf (buf
, bufsize
,
806 "Policy #%d Type: %d (MAX_HOPS_POLICY_TYPE)\n",
807 iter
+1, policies
[iter
].ptype
);
809 } else if (policies
[iter
].ptype
== Messaging::QUEUE_ORDER_POLICY_TYPE
) {
811 ACE_OS::snprintf (buf
, bufsize
,
812 "Policy #%d Type: %d (QUEUE_ORDER_POLICY_TYPE)\n",
813 iter
+1, policies
[iter
].ptype
);
815 } else if (policies
[iter
].ptype
== ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID
) {
817 ACE_OS::snprintf (buf
, bufsize
,
818 "Policy #%d Type: %d (COMPRESSOR_ID_LEVEL_LIST_POLICY_ID)\n",
819 iter
+1, policies
[iter
].ptype
);
821 ::Compression::CompressorIdLevelList idlist
;
822 if (!(stream3
>> idlist
))
824 CORBA::ULong index
= 0;
825 for (; index
< idlist
.length(); index
++)
828 ACE_OS::snprintf (buf
, bufsize
,
829 "\t CompressorId: %d Level: %d\n",
830 idlist
[index
].compressor_id
, idlist
[index
].compression_level
);
833 } else if (policies
[iter
].ptype
== ZIOP::COMPRESSION_ENABLING_POLICY_ID
) {
835 ACE_OS::snprintf (buf
, bufsize
,
836 "Policy #%d Type: %d (COMPRESSION_ENABLING_POLICY_ID)\n",
837 iter
+1, policies
[iter
].ptype
);
839 CORBA::Boolean status
;
840 if (!(stream3
>> ACE_InputCDR::to_boolean (status
)))
843 ACE_OS::snprintf (buf
, bufsize
, "\t Enabled: %d\n", status
);
847 ACE_OS::snprintf (buf
, bufsize
,
848 "Policy #%d Type: %d (UNKNOWN)\n", iter
+1,
849 policies
[iter
].ptype
);
858 Catior_i::cat_security_association (const CORBA::UShort
& a
) {
859 // Copied from Security.idl
860 typedef CORBA::UShort AssociationOptions
;
861 const AssociationOptions NoProtection
= 1;
862 const AssociationOptions Integrity
= 2;
863 const AssociationOptions Confidentiality
= 4;
864 const AssociationOptions DetectReplay
= 8;
865 const AssociationOptions DetectMisordering
= 16;
866 const AssociationOptions EstablishTrustInTarget
= 32;
867 const AssociationOptions EstablishTrustInClient
= 64;
868 const AssociationOptions NoDelegation
= 128;
869 const AssociationOptions SimpleDelegation
= 256;
870 const AssociationOptions CompositeDelegation
= 512;
872 #define CHECK_PRINT(X) \
873 if (a & X) { indent (); buffer_ += "" #X "\n"; }
875 CHECK_PRINT(NoProtection
);
876 CHECK_PRINT(Integrity
);
877 CHECK_PRINT(Confidentiality
);
878 CHECK_PRINT(DetectReplay
);
879 CHECK_PRINT(DetectMisordering
);
880 CHECK_PRINT(EstablishTrustInTarget
);
881 CHECK_PRINT(EstablishTrustInClient
);
882 CHECK_PRINT(NoDelegation
);
883 CHECK_PRINT(SimpleDelegation
);
884 CHECK_PRINT(CompositeDelegation
);
890 Catior_i::cat_tag_ssl_sec_trans (TAO_InputCDR
& cdr
) {
892 Decode the following from the stream (copied from SSLIOP.idl)
895 typedef unsigned short AssociationOptions;
900 Security::AssociationOptions target_supports;
901 Security::AssociationOptions target_requires;
906 We duplicate the code here because we do not want the catior
907 utility to be dependent upon SSLIOP.
910 CORBA::ULong length
= 0;
911 if (!cdr
.read_ulong (length
))
914 TAO_InputCDR
stream (cdr
, length
);
915 cdr
.skip_bytes(length
);
917 CORBA::UShort target_supports
;
918 CORBA::UShort target_requires
;
921 if (stream
.read_ushort(target_supports
) == 0)
924 if (stream
.read_ushort(target_requires
) == 0)
927 if (stream
.read_ushort(port
) == 0)
930 static const size_t bufsize
= 512;
934 ACE_OS::snprintf (buf
, bufsize
, "port = %d\n", port
);
937 ACE_OS::snprintf (buf
, bufsize
, "target_supports = 0x%x\n", target_supports
);
940 cat_security_association(target_supports
);
943 ACE_OS::snprintf (buf
, bufsize
, "target_requires = 0x%x\n", target_requires
);
946 cat_security_association(target_requires
);
953 Catior_i::cat_octet_seq (const char *object_name
,
954 TAO_InputCDR
& stream
)
956 CORBA::ULong length
= 0;
957 if (!stream
.read_ulong (length
))
960 static const size_t bufsize
= 512;
964 ACE_OS::snprintf (buf
, bufsize
, "%s len:\t%d\n", object_name
, length
);
968 ACE_OS::snprintf (buf
, bufsize
, "%s as hex:\n", object_name
);
971 CORBA::Octet anOctet
;
972 CORBA::String_var objKey
= CORBA::string_alloc (length
+ 1);
979 for (; i
< length
; ++i
)
988 if (!stream
.read_octet (anOctet
))
991 ACE_OS::snprintf (buf
, bufsize
, "%2.2x ", anOctet
);
993 objKey
[i
] = (char) anOctet
;
1000 ACE_OS::snprintf (buf
, bufsize
,
1001 "The %s as string:\n", object_name
);
1005 for (i
= 0; i
< length
; ++i
)
1008 int tmp
= (unsigned char) c
; // isprint doesn't work with negative vals.(except EOF)
1009 if (ACE_OS::ace_isprint (static_cast<ACE_TCHAR
> (tmp
)))
1021 Catior_i::cat_object_key (TAO_InputCDR
& stream
)
1023 // ... and object key.
1025 return cat_octet_seq ("Object Key", stream
);
1029 Catior_i::_find_info (CORBA::ULong id
)
1031 ACE_CString locale
= "";
1032 ACE_Codeset_Registry::registry_to_locale (id
, locale
, 0, 0);
1037 Catior_i::displayHex (TAO_InputCDR
& str
)
1039 if (!str
.good_bit ())
1042 TAO_InputCDR
clone_str (str
);
1043 CORBA::ULong theSetId
;
1044 if (!str
.read_ulong (theSetId
))
1046 ACE_ERROR ((LM_ERROR
,
1047 "Unable to read codeset ID.\n"));
1051 static const size_t bufsize
= 512;
1053 ACE_OS::snprintf (buf
, bufsize
, " Hex - %x\tDescription - ", theSetId
);
1056 ACE_CString theDescr
= _find_info (theSetId
);
1058 if (theDescr
.length () == 0)
1059 buffer_
+= "Unknown CodeSet\n";
1062 buffer_
+= theDescr
.c_str ();
1068 Catior_i::cat_codeset_info (TAO_InputCDR
& cdr
)
1070 CORBA::ULong length
= 0;
1071 if (cdr
.read_ulong (length
) == 0)
1074 TAO_InputCDR
stream (cdr
, length
);
1075 cdr
.skip_bytes(length
);
1077 static const size_t bufsize
= 512;
1080 ACE_OS::snprintf (buf
, bufsize
, "\tComponent length: %u\n", length
);
1083 buffer_
+= "\tComponent byte order:\t";
1084 buffer_
+= (stream
.byte_order () ? "Little" : "Big");
1085 buffer_
+= " Endian\n";
1087 // CodesetId for char
1088 // CORBA::ULong c_ncsId;
1089 buffer_
+= "\tNative CodeSet for char: ";
1090 displayHex (stream
);
1092 // number of Conversion Codesets for char
1093 CORBA::ULong c_ccslen
= 0;
1095 if (!(stream
>> c_ccslen
))
1096 ACE_ERROR_RETURN ((LM_ERROR
,
1097 "Unable to read number of conversion codesets "
1101 ACE_OS::snprintf (buf
, bufsize
, "\tNumber of CCS for char: %u\n", c_ccslen
);
1105 buffer_
+= "\tConversion Codesets for char are:\n";
1107 // Loop through and display them
1108 CORBA::ULong index
= 0;
1109 for ( ; index
< c_ccslen
; ++index
)
1111 // CodesetId for char
1112 ACE_OS::snprintf (buf
, bufsize
,
1113 "\t" ACE_UINT32_FORMAT_SPECIFIER_ASCII
") ",
1116 displayHex (stream
);
1119 // CodesetId for wchar
1120 buffer_
+= "\tNative CodeSet for wchar: ";
1121 displayHex (stream
);
1123 // number of Conversion Codesets for wchar
1124 CORBA::ULong w_ccslen
=0;
1126 if (!(stream
>> w_ccslen
))
1127 ACE_ERROR_RETURN ((LM_ERROR
,
1128 "Unable to read number of conversion codesets "
1132 ACE_OS::snprintf (buf
, bufsize
, "\tNumber of CCS for wchar: %u\n", w_ccslen
);
1136 buffer_
+= "\tConversion Codesets for wchar are:\n";
1138 // Loop through and display them
1139 for (index
= 0; index
< w_ccslen
; ++index
)
1141 ACE_OS::snprintf (buf
, bufsize
,
1142 "\t " ACE_UINT32_FORMAT_SPECIFIER_ASCII
") ",
1145 displayHex (stream
);
1151 Catior_i::cat_tagged_components (TAO_InputCDR
& stream
)
1153 // ... and object key.
1156 if (!(stream
>> len
))
1159 static const size_t bufsize
= 512;
1162 for (CORBA::ULong i
= 0;
1167 if (!(stream
>> tag
))
1169 ACE_ERROR_RETURN ((LM_ERROR
,
1170 "Unable to read component tag.\n"),
1175 ACE_OS::snprintf (buf
, bufsize
,
1176 "The component <" ACE_UINT32_FORMAT_SPECIFIER_ASCII
1177 "> ID is " ACE_UINT32_FORMAT_SPECIFIER_ASCII
,
1181 if (tag
== IOP::TAG_ORB_TYPE
) {
1182 ACE_OS::snprintf (buf
, bufsize
, " (TAG_ORB_TYPE)\n");
1185 cat_tag_orb_type(stream
);
1187 } else if (tag
== IOP::TAG_CODE_SETS
) {
1188 ACE_OS::snprintf (buf
, bufsize
, " (TAG_CODE_SETS)\n");
1191 cat_codeset_info(stream
);
1193 } else if (tag
== IOP::TAG_ALTERNATE_IIOP_ADDRESS
) {
1194 ACE_OS::snprintf (buf
, bufsize
, " (TAG_ALTERNATE_IIOP_ADDRESS)\n");
1197 cat_tag_alternate_endpoints (stream
);
1199 } else if (tag
== TAO_TAG_ENDPOINTS
) {
1200 ACE_OS::snprintf (buf
, bufsize
, " (TAO_TAG_ENDPOINTS)\n");
1203 cat_tao_tag_endpoints(stream
);
1205 } else if (tag
== IOP::TAG_POLICIES
) {
1206 ACE_OS::snprintf (buf
, bufsize
, " (TAG_POLICIES)\n");
1209 cat_tag_policies(stream
);
1211 } else if (tag
== 20U /* SSLIOP::TAG_SSL_SEC_TRANS */) {
1212 ACE_OS::snprintf (buf
, bufsize
, " (TAG_SSL_SEC_TRANS)\n");
1215 cat_tag_ssl_sec_trans(stream
);
1217 } else if (tag
== 38U /* TAG_RMI_CUSTOM_MAX_STREAM_FORMAT */) {
1218 ACE_OS::snprintf (buf
, bufsize
, "(TAG_RMI_CUSTOM_MAX_STREAM_FORMAT)\n");
1221 cat_octet_seq ("Component Value", stream
);
1223 } else if (tag
== 1229081866U /* IBM_PARTNER_VERSION */) {
1224 ACE_OS::snprintf (buf
, bufsize
, " (IBM_PARTNER_VERSION)\n");
1227 cat_ibm_partner_version (stream
);
1230 ACE_OS::snprintf (buf
, bufsize
, " (Unrecognized tag)\n");
1233 cat_octet_seq ("Component Value", stream
);
1242 Catior_i::cat_profile_helper (TAO_InputCDR
& stream
,
1243 const char *protocol
)
1245 // OK, we've got an IIOP profile. It's going to be
1246 // encapsulated ProfileData. Create a new decoding stream and
1247 // context for it, and tell the "parent" stream that this data
1248 // isn't part of it any more.
1250 CORBA::ULong encap_len
;
1251 if (stream
.read_ulong (encap_len
) == 0)
1253 ACE_ERROR_RETURN ((LM_ERROR
,
1254 "cannot read encap length\n"), false);
1257 // Create the decoding stream from the encapsulation in the
1258 // buffer, and skip the encapsulation.
1259 TAO_InputCDR
str (stream
, encap_len
);
1261 if (!str
.good_bit () || stream
.skip_bytes (encap_len
) == 0)
1264 static const size_t bufsize
= 512;
1267 // Read and verify major, minor versions, ignoring IIOP
1268 // profiles whose versions we don't understand.
1270 // XXX this doesn't actually go back and skip the whole
1272 CORBA::Octet iiop_version_major
= 1;
1273 CORBA::Octet iiop_version_minor
= 0;
1274 if (! (str
.read_octet (iiop_version_major
)
1275 && iiop_version_major
== 1
1276 && str
.read_octet (iiop_version_minor
)
1277 && iiop_version_minor
<= 2))
1280 ACE_OS::snprintf (buf
, bufsize
,
1281 "detected new v%d.%d %s profile that catior cannot decode\n",
1289 ACE_OS::snprintf (buf
, bufsize
,
1290 "%s Version:\t%d.%d\n",
1291 protocol
, iiop_version_major
, iiop_version_minor
);
1294 // Get host and port.
1295 CORBA::UShort port_number
;
1296 CORBA::String_var hostname
;
1297 if (!(str
>> hostname
.inout ()))
1300 buffer_
+= "problem decoding hostname\n";
1304 if (!(str
>> port_number
))
1308 buffer_
+= "Host Name:\t";
1309 buffer_
+= hostname
.in ();
1313 ACE_OS::snprintf (buf
, bufsize
, "Port Number:\t%d\n", port_number
);
1316 if (!cat_object_key (str
))
1319 //IIOP 1.0 does not have tagged_components.
1320 if (!(iiop_version_major
== 1 && iiop_version_minor
== 0))
1322 if (cat_tagged_components (str
) == 0)
1332 Catior_i::cat_coiop_profile (TAO_InputCDR
& stream
)
1334 // OK, we've got an COIOP profile. It's going to be
1335 // encapsulated ProfileData. Create a new decoding stream and
1336 // context for it, and tell the "parent" stream that this data
1337 // isn't part of it any more.
1339 CORBA::ULong encap_len
;
1340 if (stream
.read_ulong (encap_len
) == 0)
1342 ACE_ERROR_RETURN ((LM_ERROR
, "cannot read encap length\n"), false);
1345 // Create the decoding stream from the encapsulation in the
1346 // buffer, and skip the encapsulation.
1347 TAO_InputCDR
str (stream
, encap_len
);
1349 if (!str
.good_bit () || stream
.skip_bytes (encap_len
) == 0)
1352 static const size_t bufsize
= 512;
1355 // Read and verify major, minor versions, ignoring IIOP
1356 // profiles whose versions we don't understand.
1358 // XXX this doesn't actually go back and skip the whole
1360 CORBA::Octet iiop_version_major
= 1;
1361 CORBA::Octet iiop_version_minor
= 0;
1362 if (! (str
.read_octet (iiop_version_major
)
1363 && iiop_version_major
== 1
1364 && str
.read_octet (iiop_version_minor
)
1365 && iiop_version_minor
<= 2))
1368 ACE_OS::snprintf (buf
, bufsize
,
1369 "detected new v%d.%d COIOP profile that catior cannot decode",
1371 iiop_version_minor
);
1376 ACE_OS::snprintf (buf
, bufsize
,
1377 "COIOP Version:\t%d.%d\n",
1379 iiop_version_minor
);
1382 // Get host and port.
1383 CORBA::String_var uuid
;
1384 if (!(str
>> uuid
.inout ()))
1387 buffer_
+= "problem decoding uuid\n";
1392 buffer_
+= "UUID:\t";
1393 buffer_
+= uuid
.in ();
1396 if (cat_object_key (str
) == 0)
1399 //IIOP 1.0 does not have tagged_components.
1400 if (!(iiop_version_major
== 1 && iiop_version_minor
== 0))
1402 if (cat_tagged_components (str
) == 0)
1412 Catior_i::cat_iiop_profile (TAO_InputCDR
& stream
)
1414 return cat_profile_helper (stream
, "IIOP");
1418 Catior_i::cat_shmiop_profile (TAO_InputCDR
& stream
)
1420 return cat_profile_helper (stream
, "SHMIOP");
1424 Catior_i::cat_uiop_profile (TAO_InputCDR
& stream
)
1426 // OK, we've got a UIOP profile. It's going to be encapsulated
1427 // ProfileData. Create a new decoding stream and context for it,
1428 // and tell the "parent" stream that this data isn't part of it any
1431 CORBA::ULong encap_len
;
1432 if (stream
.read_ulong (encap_len
) == 0)
1435 // Create the decoding stream from the encapsulation in the
1436 // buffer, and skip the encapsulation.
1437 TAO_InputCDR
str (stream
, encap_len
);
1439 if (!str
.good_bit () || stream
.skip_bytes (encap_len
) == 0)
1442 static const size_t bufsize
= 512;
1445 // Read and verify major, minor versions, ignoring UIOP
1446 // profiles whose versions we don't understand.
1448 // XXX this doesn't actually go back and skip the whole
1450 CORBA::Octet uiop_version_major
= 1;
1451 CORBA::Octet uiop_version_minor
= 0;
1452 // It appears that as of April 2002 UIOP version is 1.2
1453 if (! (str
.read_octet (uiop_version_major
)
1454 && uiop_version_major
== 1
1455 && str
.read_octet (uiop_version_minor
)
1456 && uiop_version_minor
<= 2))
1459 ACE_OS::snprintf (buf
, bufsize
,
1460 "detected new v%d.%d UIOP profile",
1462 uiop_version_minor
);
1468 ACE_OS::snprintf (buf
, bufsize
,
1469 "UIOP Version:\t%d.%d\n",
1471 uiop_version_minor
);
1474 // Get host and port.
1475 CORBA::String_var rendezvous
;
1476 if ((str
>> rendezvous
.out ()) == 0)
1480 buffer_
+= "Rendezvous point:\t";
1481 buffer_
+= rendezvous
.in ();
1484 if (cat_object_key (str
) == 0)
1487 if (cat_tagged_components (str
) == 0)
1494 Catior_i::cat_multiple_components (TAO_InputCDR
& stream
)
1496 static const size_t bufsize
= 512;
1499 ACE_OS::snprintf (buf
, bufsize
,
1500 "Multiple Components Profile\n");
1502 return cat_tagged_components (stream
);
1506 Catior_i::cat_sciop_profile (TAO_InputCDR
& stream
)
1508 // OK, we've got an SCIOP profile.
1510 CORBA::ULong encap_len
;
1511 if (stream
.read_ulong (encap_len
) == 0)
1513 ACE_ERROR_RETURN ((LM_ERROR
, "cannot read encap length\n"), false);
1516 // Create the decoding stream from the encapsulation in the
1517 // buffer, and skip the encapsulation.
1518 TAO_InputCDR
str (stream
, encap_len
);
1520 if (!str
.good_bit () || stream
.skip_bytes (encap_len
) == 0)
1523 static const size_t bufsize
= 512;
1526 // Read and verify major, minor versions, ignoring IIOP
1527 // profiles whose versions we don't understand.
1529 // XXX this doesn't actually go back and skip the whole
1531 CORBA::Octet iiop_version_major
= 1;
1532 CORBA::Octet iiop_version_minor
= 0;
1533 if (! (str
.read_octet (iiop_version_major
)
1534 && iiop_version_major
== 1
1535 && str
.read_octet (iiop_version_minor
)
1536 && iiop_version_minor
<= 0))
1539 ACE_OS::snprintf (buf
, bufsize
,
1540 "detected new v%d.%d SCIOP profile that catior cannot decode",
1542 iiop_version_minor
);
1548 ACE_OS::snprintf (buf
, bufsize
,
1549 "SCIOP Version:\t%d.%d\n",
1551 iiop_version_minor
);
1554 // Get host and port.
1555 CORBA::UShort port_number
;
1556 CORBA::UShort max_streams
;
1557 CORBA::ULong addresses
;
1559 if (!(str
>> addresses
))
1560 ACE_ERROR_RETURN ((LM_ERROR
,
1561 "Unable to decode number of addresses\n."),
1565 ACE_OS::snprintf (buf
, bufsize
, "Addresses:\t%d\n", addresses
);
1568 for (CORBA::ULong i
= 0; i
< addresses
; ++i
)
1570 CORBA::String_var hostname
;
1571 if (!(str
>> hostname
.inout ()))
1573 ACE_ERROR_RETURN ((LM_ERROR
,
1574 "%I problem decoding hostname\n"),
1579 buffer_
+= "Host Name:\t";
1580 buffer_
+= hostname
.in ();
1585 if (!(str
>> port_number
))
1589 ACE_OS::snprintf (buf
, bufsize
, "Port Number:\t%d\n", port_number
);
1592 if (!(str
>> max_streams
))
1596 ACE_OS::snprintf (buf
, bufsize
, "Max Streams:\t%d\n", max_streams
);
1599 // Unlike IIOP (1.0), SCIOP always has tagged_components.
1600 if (!cat_object_key (str
) || !cat_tagged_components (str
))
1608 Catior_i::cat_nsk_profile_helper (TAO_InputCDR
& stream
,
1609 const char *protocol
)
1611 // OK, we've got an NSK profile. It's going to be
1612 // encapsulated ProfileData. Create a new decoding stream and
1613 // context for it, and tell the "parent" stream that this data
1614 // isn't part of it any more.
1616 CORBA::ULong encap_len
;
1617 if (stream
.read_ulong (encap_len
) == 0)
1619 ACE_ERROR_RETURN ((LM_ERROR
, "cannot read encap length\n"), false);
1622 // Create the decoding stream from the encapsulation in the
1623 // buffer, and skip the encapsulation.
1624 TAO_InputCDR
str (stream
, encap_len
);
1626 if (!str
.good_bit () || stream
.skip_bytes (encap_len
) == 0)
1629 static const size_t bufsize
= 512;
1632 // Read and verify major, minor versions, ignoring NSK
1633 // profiles whose versions we don't understand.
1635 // XXX this doesn't actually go back and skip the whole
1637 CORBA::Octet iiop_version_major
= 1;
1638 CORBA::Octet iiop_version_minor
= 0;
1639 if (! (str
.read_octet (iiop_version_major
)
1640 && iiop_version_major
== 1
1641 && str
.read_octet (iiop_version_minor
)
1642 && iiop_version_minor
<= 2))
1645 ACE_OS::snprintf (buf
, bufsize
,
1646 "detected new v%d.%d %s profile that catior cannot decode",
1654 ACE_OS::snprintf (buf
, bufsize
,
1655 "%s Version:\t%d.%d\n",
1658 iiop_version_minor
);
1663 if (!(str
>> fsaddress
))
1666 buffer_
+= "problem decoding file system address\n";
1672 buffer_
+= "FS Address:\t";
1673 buffer_
+= fsaddress
;
1675 CORBA::string_free (fsaddress
);
1677 if (cat_object_key (str
) == 0)
1680 // Version 1.0 does not have tagged_components.
1681 if (!(iiop_version_major
== 1 && iiop_version_minor
== 0))
1683 if (cat_tagged_components (str
) == 0)
1693 Catior_i::cat_nskpw_profile (TAO_InputCDR
& stream
)
1695 return cat_nsk_profile_helper (stream
, "NSKPW");
1699 Catior_i::cat_nskfs_profile (TAO_InputCDR
& stream
)
1701 return cat_nsk_profile_helper (stream
, "NSKFS");
1707 if (trace_depth_
!= 0)
1709 for(size_t i
= 0; i
< trace_depth_
; i
++)