Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / utils / catior / Catior_i.cpp
blobb41f6c75319acb9c8d9a7443ce30566db8c452f0
2 //=============================================================================
3 /**
4 * @file Catior_i.cpp
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 //=============================================================================
14 #include "Catior_i.h"
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"
26 #include "tao/CDR.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"
35 Catior_i::Catior_i()
36 : trace_depth_(0),
37 buffer_()
42 CORBA::Boolean
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:";
49 char * str = 0;
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 ();
62 b = catior (str);
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 ();
73 b = catiiop (str);
75 else if (aString.find (poopPrefix) != ACE_CString::npos)
77 buffer_ += "Decoding a POOP IOR\n";
79 str = aString.rep ();
80 b = catpoop (str);
82 else
84 buffer_ += "Don't know how to decode this IOR\n";
87 delete [] str;
88 output = buffer_;
89 return b;
93 CORBA::Boolean
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)
100 return false;
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
108 // accept
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])
115 && string [1] == '.'
116 && string [3] == '/'
117 && string [4] == '/')
119 iiop_version_major = (char) (string [0] - '0');
120 iiop_version_minor = (char) (string [2] - '0');
121 string += 5;
123 else
125 string += 2;
128 static const size_t bufsize = 512;
129 char buf[bufsize];
130 ACE_OS::snprintf (buf, bufsize, "IIOP Version:\t%d.%d\n",
131 iiop_version_major, iiop_version_minor);
132 buffer_ += buf;
134 // Pull off the "hostname:port/" part of the objref Get host and
135 // port.
136 CORBA::UShort port_number;
137 char *cp = ACE_OS::strchr (string, ':');
139 if (cp == 0)
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 ();
148 *string != ':';
149 *cp++ = *string++)
150 continue;
152 *cp = 0;
153 ++string;
155 cp = ACE_OS::strchr ((char *) string, '/');
157 if (cp == 0)
159 throw CORBA::DATA_CONVERSION ();
162 port_number = (short) ACE_OS::atoi ((char *) string);
163 string = ++cp;
165 ACE_OS::snprintf (buf, bufsize, "Host Name:\t%s\n"
166 "Port Number:\t%d\n",
167 hostname.in (), port_number);
168 buffer_ += buf;
170 // Parse the object key.
171 // dump the object key to stdout
172 // TAO_POA::decode_string_to_sequence (data->profile.object_key,
173 // string);
174 buffer_ += "\nThe Object Key as string:\n";
175 buffer_ += string;
176 buffer_ += "\n";
178 return true;
181 CORBA::Boolean
182 Catior_i::catior (char const * str)
184 // Unhex the bytes, and make a CDR deencapsulation stream from the
185 // resulting data.
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;
193 size_t len = 0;
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])
202 u_char byte;
204 if (! (ACE_OS::ace_isxdigit (tmp [0]) && ACE_OS::ace_isxdigit (tmp [1])))
205 break;
207 byte = (u_char) (ACE::hex2byte (tmp [0]) << 4);
208 byte |= ACE::hex2byte (tmp [1]);
210 buffer[len++] = byte;
211 tmp += 2;
214 // Create deencapsulation stream ... then unmarshal objref from that
215 // stream.
217 int byteOrder = *(mb.rd_ptr ());
219 mb.rd_ptr (1);
220 mb.wr_ptr (len);
221 TAO_InputCDR stream (&mb, static_cast<int> (byteOrder));
223 buffer_ += "The Byte Order:\t";
224 if (byteOrder == 1)
225 buffer_ += "Little Endian\n";
226 else
227 buffer_ += "Big Endian\n";
229 // First, read the type hint. This will be the type_id encoded in an
230 // object reference.
231 CORBA::String_var type_hint;
233 if (!(stream >> type_hint.inout ()))
235 ACE_ERROR_RETURN ((LM_ERROR,
236 "cannot read type id\n"),
237 TAO::TRAVERSE_STOP);
240 buffer_ += "The Type Id:\t\"";
241 buffer_ += type_hint.in ();
242 buffer_ += "\"\n";
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"),
262 TAO::TRAVERSE_STOP);
265 CORBA::ULong profile_counter = 0;
267 static const size_t bufsize = 512;
268 char buf[bufsize];
269 ACE_OS::snprintf (buf, bufsize,
270 "Number of Profiles in IOR:\t%d\n", profiles);
271 buffer_ += buf;
273 // No profiles means a NIL objref.
274 if (profiles == 0)
275 return TAO::TRAVERSE_CONTINUE;
276 else
277 while (profiles-- != 0)
279 ACE_OS::snprintf (buf, bufsize, "Profile number:\t%d\n",
280 ++profile_counter);
281 buffer_ += buf;
283 // We keep decoding until we find a valid IIOP profile.
284 CORBA::ULong tag;
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"));
292 continue;
295 trace_depth_++;
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);
332 else
334 indent ();
335 ACE_OS::snprintf (buf, bufsize,
336 "Profile tag = %d (unknown protocol)\n", tag);
337 buffer_ += buf;
338 continue_decoding = cat_octet_seq("Profile body", stream);
340 trace_depth_--;
342 return true;
345 // Parse the Orbix-style POOP object references, which have the form:
346 //:\ntlj3corba:NS:NC_2::IR:CosNaming_NamingContext
347 // :\ hostname
348 // : server_name
349 // : marker
350 // : IR_host
351 // : IR_server
352 // : interface_marker
354 CORBA::Boolean
355 Catior_i::catpoop (char* string)
357 if (!string || !*string)
358 return false;
360 //if (string [0] == ':'
361 // && string [1] == '\\')
362 // ACE_DEBUG ((LM_DEBUG,
363 // "\nPerhaps we've found some POOP\n"));
364 string += 2;
366 char *cp = ACE_OS::strchr (string, ':');
368 if (cp == 0)
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));
377 for (cp = hostname;
378 *string != ':';
379 *cp++ = *string++)
380 continue;
382 *cp = 0;
383 ++string;
385 buffer_ += "Host Name:\t";
386 buffer_ += hostname;
387 buffer_ += "\n";
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;
397 *string != ':';
398 *cp++ = *string++)
399 continue;
401 *cp = 0;
402 ++string;
404 buffer_ += "Server Name:\t";
405 buffer_ += server_name;
406 buffer_ += "\n",
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));
416 for (cp = marker;
417 *string != ':';
418 *cp++ = *string++)
419 continue;
421 *cp = 0;
422 ++string;
424 buffer_ += "Marker:\t\t";
425 buffer_ += marker;
426 buffer_ += "\n";
427 CORBA::string_free (marker);
429 cp = ACE_OS::strchr (string, ':');
431 // Read the IR_host.
432 char* IR_host = CORBA::string_alloc (1 +
433 ACE_Utils::truncate_cast<CORBA::ULong> (cp - string));
435 for (cp = IR_host;
436 *string != ':';
437 *cp++ = *string++)
438 continue;
440 *cp = 0;
441 ++string;
443 buffer_ += "IR Host:\t\t";
444 buffer_ += IR_host;
445 buffer_ += "\n";
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));
454 for (cp = IR_server;
455 *string != ':';
456 *cp++ = *string++)
457 continue;
459 *cp = 0;
460 ++string;
462 buffer_ += "IR Server:\t\t";
463 buffer_ += IR_server;
464 buffer_ += "\n";
465 CORBA::string_free (IR_server);
467 // Read the interface_marker
468 buffer_ += "Interface Marker:\t";
469 buffer_ += string;
470 buffer_ += "\n";
471 return true;
474 CORBA::Boolean
475 Catior_i::cat_tag_orb_type (TAO_InputCDR& stream) {
476 CORBA::ULong length = 0;
477 if (!stream.read_ulong (length))
478 return true;
480 TAO_InputCDR stream2 (stream, length);
481 stream.skip_bytes(length);
483 CORBA::ULong orbtype;
485 if (!(stream2 >> orbtype))
486 return false;
488 static const size_t bufsize = 512;
489 char buf[bufsize];
491 indent();
493 switch (orbtype)
495 case TAO_ORB_TYPE:
497 ACE_OS::snprintf (buf, bufsize,
498 "ORB Type: 0x%x (TAO)\n", orbtype);
499 break;
501 case 0x47430000 :
503 ACE_OS::snprintf (buf, bufsize,
504 "ORB Type: 0x%x (GNU Classpath)\n", orbtype);
505 break;
507 case 0x49540000 :
509 ACE_OS::snprintf (buf, bufsize,
510 "ORB Type: 0x%x (Orbix)\n", orbtype);
511 break;
513 case 0x4A430000 :
515 ACE_OS::snprintf (buf, bufsize,
516 "ORB Type: 0x%x (JacORB)\n", orbtype);
517 break;
519 case 0x41540000 :
521 ACE_OS::snprintf (buf, bufsize,
522 "ORB Type: 0x%x (OmniORB)\n", orbtype);
523 break;
525 case 0x53550000 :
527 ACE_OS::snprintf (buf, bufsize,
528 "ORB Type: 0x%x (Sun)\n", orbtype);
529 break;
531 case 0x29A:
533 ACE_OS::snprintf (buf, bufsize,
534 "ORB Type: 0x%x (TIDorbC++)\n", orbtype);
535 break;
537 case 0x4a414300:
539 ACE_OS::snprintf (buf, bufsize,
540 "ORB Type: 0x%x (JacORB)\n", orbtype);
541 break;
543 default:
545 ACE_OS::snprintf (buf, bufsize,
546 "ORB Type: 0x%x\n", orbtype);
548 break;
550 buffer_ += buf;
551 return true;
554 CORBA::Boolean
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
561 * partner version.
562 * The next four bytes encode the length of the remaining data (in this
563 * case 8 bytes)
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
569 * compatibility
571 CORBA::ULong length = 0;
572 if (!(stream.read_ulong (length)))
573 return true;
575 TAO_InputCDR stream2 (stream, length);
576 stream.skip_bytes(length);
578 CORBA::ULong version;
579 if (!(stream2 >> version))
580 return false;
582 static const size_t bufsize = 512;
583 char buf[bufsize];
584 ACE_OS::snprintf (buf, bufsize, "\tPartner Version: 0x%x\n", version);
585 buffer_ += buf;
587 return true;
591 CORBA::Boolean
592 Catior_i::cat_tao_tag_endpoints (TAO_InputCDR& stream)
594 CORBA::ULong length = 0;
595 if (!stream.read_ulong (length))
596 return true;
598 TAO_InputCDR stream2 (stream, length);
599 stream.skip_bytes(length);
601 TAO::IIOPEndpointSequence epseq;
602 if (!(stream2 >> epseq))
603 return true;
605 static const size_t bufsize = 512;
606 char buf[bufsize];
607 for (unsigned int iter=0; iter < epseq.length() ; iter++) {
608 const char *host = epseq[iter].host;
609 CORBA::UShort port = epseq[iter].port;
610 indent ();
611 ACE_OS::snprintf (buf, bufsize,
612 "Endpoint #%d:\n", iter+1);
613 buffer_ += buf;
614 indent ();
615 ACE_OS::snprintf (buf, bufsize,
616 "Host: %s\n", host);
617 buffer_ += buf;
618 indent ();
619 ACE_OS::snprintf (buf, bufsize,
620 "Port: %d\n", port);
621 buffer_ += buf;
622 indent ();
623 ACE_OS::snprintf (buf, bufsize,
624 "Priority: %d\n", epseq[iter].priority);
625 buffer_ += buf;
628 return true;
631 CORBA::Boolean
632 Catior_i::cat_tag_alternate_endpoints (TAO_InputCDR& stream) {
633 CORBA::ULong length = 0;
634 if (!stream.read_ulong (length))
635 return true;
637 TAO_InputCDR stream2 (stream, length);
638 stream.skip_bytes(length);
640 CORBA::String_var host;
641 CORBA::UShort port;
642 if (!(stream2 >> host.out()) ||
643 !(stream2 >> port))
645 ACE_ERROR_RETURN ((LM_ERROR,"cannot extract endpoint info\n"),false);
647 else
649 static const size_t bufsize = 512;
650 char buf[bufsize];
651 indent ();
652 ACE_OS::snprintf (buf, bufsize,
653 "endpoint: %s:%d\n", host.in(), port);
654 buffer_ += buf;
657 return true;
660 CORBA::Boolean
661 Catior_i::cat_tag_policies (TAO_InputCDR& stream) {
662 CORBA::ULong length = 0;
663 if (!stream.read_ulong (length))
664 return true;
666 TAO_InputCDR stream2 (stream, length);
667 stream.skip_bytes(length);
669 Messaging::PolicyValueSeq policies;
670 if (!(stream2 >> policies))
671 return true;
673 static const size_t bufsize = 512;
674 char buf[bufsize];
675 indent ();
676 ACE_OS::snprintf (buf, bufsize,
677 "Number of policies: %d\n",
678 policies.length());
679 buffer_ += buf;
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)))
691 return true;
693 stream3.reset_byte_order (static_cast <int> (byte_order));
695 if (policies[iter].ptype == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) {
696 indent ();
697 ACE_OS::snprintf (buf, bufsize,
698 "Policy #%d Type: %d (PRIORITY_MODEL_POLICY_TYPE)\n",
699 iter+1, policies[iter].ptype);
700 buffer_ += buf;
702 RTCORBA::PriorityModel priority_model;
703 RTCORBA::Priority server_priority;
705 if (!(stream3 >> priority_model))
706 return true;
707 if (!(stream3 >> server_priority))
708 return true;
710 indent ();
711 if (priority_model == RTCORBA::CLIENT_PROPAGATED) {
712 ACE_OS::snprintf (buf, bufsize,
713 "\t Priority Model: %d (CLIENT_PROPAGATED)\n",
714 priority_model);
715 } else if (priority_model == RTCORBA::SERVER_DECLARED) {
716 ACE_OS::snprintf (buf, bufsize,
717 "\t Priority Model: %d (SERVER_DECLARED)\n",
718 priority_model);
719 } else {
720 ACE_OS::snprintf (buf, bufsize,
721 "\t Priority Model: %d (UNKNOWN!)\n",
722 priority_model);
724 buffer_ += buf;
725 indent ();
726 ACE_OS::snprintf (buf, bufsize,
727 "\t Priority: %d\n", server_priority);
728 buffer_ += buf;
729 } else if (policies[iter].ptype == RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE) {
730 indent ();
731 ACE_OS::snprintf (buf, bufsize,
732 "Policy #%d Type: %d (PRIORITY_BANDED_CONNECTION_POLICY_TYPE)\n",
733 iter+1, policies[iter].ptype);
734 buffer_ += buf;
735 } else if (policies[iter].ptype == Messaging::REBIND_POLICY_TYPE) {
736 indent ();
737 ACE_OS::snprintf (buf, bufsize,
738 "Policy #%d Type: %d (REBIND_POLICY_TYPE)\n",
739 iter+1, policies[iter].ptype);
740 buffer_ += buf;
741 #if (TAO_HAS_SYNC_SCOPE_POLICY == 1)
742 } else if (policies[iter].ptype == Messaging::SYNC_SCOPE_POLICY_TYPE) {
743 indent ();
744 ACE_OS::snprintf (buf, bufsize,
745 "Policy #%d Type: %d (SYNC_SCOPE_POLICY_TYPE)\n",
746 iter+1, policies[iter].ptype);
747 buffer_ += buf;
748 #endif
749 } else if (policies[iter].ptype == Messaging::REQUEST_PRIORITY_POLICY_TYPE) {
750 indent ();
751 ACE_OS::snprintf (buf, bufsize,
752 "Policy #%d Type: %d (REQUEST_PRIORITY_POLICY_TYPE)\n",
753 iter+1, policies[iter].ptype);
754 buffer_ += buf;
755 } else if (policies[iter].ptype == Messaging::REPLY_PRIORITY_POLICY_TYPE) {
756 indent ();
757 ACE_OS::snprintf (buf, bufsize,
758 "Policy #%d Type: %d (REPLY_PRIORITY_POLICY_TYPE)\n",
759 iter+1, policies[iter].ptype);
760 buffer_ += buf;
761 } else if (policies[iter].ptype == Messaging::REQUEST_START_TIME_POLICY_TYPE) {
762 indent ();
763 ACE_OS::snprintf (buf, bufsize,
764 "Policy #%d Type: %d (REQUEST_START_TIME_POLICY_TYPE)\n",
765 iter+1, policies[iter].ptype);
766 buffer_ += buf;
767 } else if (policies[iter].ptype == Messaging::REQUEST_END_TIME_POLICY_TYPE) {
768 indent ();
769 ACE_OS::snprintf (buf, bufsize,
770 "Policy #%d Type: %d (REQUEST_END_TIME_POLICY_TYPE)\n",
771 iter+1, policies[iter].ptype);
772 buffer_ += buf;
773 } else if (policies[iter].ptype == Messaging::REPLY_START_TIME_POLICY_TYPE) {
774 indent ();
775 ACE_OS::snprintf (buf, bufsize,
776 "Policy #%d Type: %d (REPLY_START_TIME_POLICY_TYPE)\n",
777 iter+1, policies[iter].ptype);
778 buffer_ += buf;
779 } else if (policies[iter].ptype == Messaging::REPLY_END_TIME_POLICY_TYPE) {
780 indent ();
781 ACE_OS::snprintf (buf, bufsize,
782 "Policy #%d Type: %d (REPLY_END_TIME_POLICY_TYPE)\n",
783 iter+1, policies[iter].ptype);
784 buffer_ += buf;
785 } else if (policies[iter].ptype == Messaging::RELATIVE_REQ_TIMEOUT_POLICY_TYPE) {
786 indent ();
787 ACE_OS::snprintf (buf, bufsize,
788 "Policy #%d Type: %d (RELATIVE_REQ_TIMEOUT_POLICY_TYPE)\n",
789 iter+1, policies[iter].ptype);
790 buffer_ += buf;
791 } else if (policies[iter].ptype == Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE) {
792 indent ();
793 ACE_OS::snprintf (buf, bufsize,
794 "Policy #%d Type: %d (RELATIVE_RT_TIMEOUT_POLICY_TYPE)\n",
795 iter+1, policies[iter].ptype);
796 buffer_ += buf;
797 } else if (policies[iter].ptype == Messaging::ROUTING_POLICY_TYPE) {
798 indent ();
799 ACE_OS::snprintf (buf, bufsize,
800 "Policy #%d Type: %d (ROUTING_POLICY_TYPE)\n",
801 iter+1, policies[iter].ptype);
802 buffer_ += buf;
803 } else if (policies[iter].ptype == Messaging::MAX_HOPS_POLICY_TYPE) {
804 indent ();
805 ACE_OS::snprintf (buf, bufsize,
806 "Policy #%d Type: %d (MAX_HOPS_POLICY_TYPE)\n",
807 iter+1, policies[iter].ptype);
808 buffer_ += buf;
809 } else if (policies[iter].ptype == Messaging::QUEUE_ORDER_POLICY_TYPE) {
810 indent ();
811 ACE_OS::snprintf (buf, bufsize,
812 "Policy #%d Type: %d (QUEUE_ORDER_POLICY_TYPE)\n",
813 iter+1, policies[iter].ptype);
814 buffer_ += buf;
815 } else if (policies[iter].ptype == ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID) {
816 indent ();
817 ACE_OS::snprintf (buf, bufsize,
818 "Policy #%d Type: %d (COMPRESSOR_ID_LEVEL_LIST_POLICY_ID)\n",
819 iter+1, policies[iter].ptype);
820 buffer_ += buf;
821 ::Compression::CompressorIdLevelList idlist;
822 if (!(stream3 >> idlist))
823 return true;
824 CORBA::ULong index = 0;
825 for (; index < idlist.length(); index++)
827 indent ();
828 ACE_OS::snprintf (buf, bufsize,
829 "\t CompressorId: %d Level: %d\n",
830 idlist[index].compressor_id, idlist[index].compression_level);
831 buffer_ += buf;
833 } else if (policies[iter].ptype == ZIOP::COMPRESSION_ENABLING_POLICY_ID) {
834 indent ();
835 ACE_OS::snprintf (buf, bufsize,
836 "Policy #%d Type: %d (COMPRESSION_ENABLING_POLICY_ID)\n",
837 iter+1, policies[iter].ptype);
838 buffer_ += buf;
839 CORBA::Boolean status;
840 if (!(stream3 >> ACE_InputCDR::to_boolean (status)))
841 return true;
842 indent ();
843 ACE_OS::snprintf (buf, bufsize, "\t Enabled: %d\n", status);
844 buffer_ += buf;
845 } else {
846 indent ();
847 ACE_OS::snprintf (buf, bufsize,
848 "Policy #%d Type: %d (UNKNOWN)\n", iter+1,
849 policies[iter].ptype);
850 buffer_ += buf;
854 return true;
857 CORBA::Boolean
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);
886 return false;
889 CORBA::Boolean
890 Catior_i::cat_tag_ssl_sec_trans (TAO_InputCDR& cdr) {
892 Decode the following from the stream (copied from SSLIOP.idl)
894 module Security {
895 typedef unsigned short AssociationOptions;
898 module SSLIOP {
899 struct SSL {
900 Security::AssociationOptions target_supports;
901 Security::AssociationOptions target_requires;
902 unsigned short port;
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))
912 return false;
914 TAO_InputCDR stream (cdr, length);
915 cdr.skip_bytes(length);
917 CORBA::UShort target_supports;
918 CORBA::UShort target_requires;
919 CORBA::UShort port;
921 if (stream.read_ushort(target_supports) == 0)
922 return false;
924 if (stream.read_ushort(target_requires) == 0)
925 return false;
927 if (stream.read_ushort(port) == 0)
928 return false;
930 static const size_t bufsize = 512;
931 char buf[bufsize];
933 indent ();
934 ACE_OS::snprintf (buf, bufsize, "port = %d\n", port);
935 buffer_ += buf;
936 indent ();
937 ACE_OS::snprintf (buf, bufsize, "target_supports = 0x%x\n", target_supports);
938 buffer_ += buf;
939 trace_depth_++;
940 cat_security_association(target_supports);
941 trace_depth_--;
942 indent ();
943 ACE_OS::snprintf (buf, bufsize, "target_requires = 0x%x\n", target_requires);
944 buffer_ += buf;
945 trace_depth_++;
946 cat_security_association(target_requires);
947 trace_depth_--;
949 return true;
952 CORBA::Boolean
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))
958 return true;
960 static const size_t bufsize = 512;
961 char buf[bufsize];
963 indent ();
964 ACE_OS::snprintf (buf, bufsize, "%s len:\t%d\n", object_name, length);
965 buffer_ += buf;
967 indent ();
968 ACE_OS::snprintf (buf, bufsize, "%s as hex:\n", object_name);
969 buffer_ += buf;
971 CORBA::Octet anOctet;
972 CORBA::String_var objKey = CORBA::string_alloc (length + 1);
974 short counter = -1;
976 indent ();
977 CORBA::ULong i = 0;
979 for (; i < length; ++i)
981 if (++counter == 16)
983 buffer_ += "\n";
984 indent ();
985 counter = 0;
988 if (!stream.read_octet (anOctet))
989 return false;
991 ACE_OS::snprintf (buf, bufsize, "%2.2x ", anOctet);
992 buffer_ += buf;
993 objKey[i] = (char) anOctet;
996 objKey[i] = '\0';
998 buffer_ += "\n";
999 indent ();
1000 ACE_OS::snprintf (buf, bufsize,
1001 "The %s as string:\n", object_name);
1002 buffer_ += buf;
1003 indent ();
1005 for (i = 0; i < length; ++i)
1007 char c = objKey[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)))
1010 buffer_ += c;
1011 else
1012 buffer_ += ".";
1015 buffer_ += "\n";
1017 return true;
1020 CORBA::Boolean
1021 Catior_i::cat_object_key (TAO_InputCDR& stream)
1023 // ... and object key.
1025 return cat_octet_seq ("Object Key", stream);
1028 ACE_CString
1029 Catior_i::_find_info (CORBA::ULong id)
1031 ACE_CString locale = "";
1032 ACE_Codeset_Registry::registry_to_locale (id, locale, 0, 0);
1033 return locale;
1036 void
1037 Catior_i::displayHex (TAO_InputCDR & str)
1039 if (!str.good_bit ())
1040 return;
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"));
1048 return;
1051 static const size_t bufsize = 512;
1052 char buf[bufsize];
1053 ACE_OS::snprintf (buf, bufsize, " Hex - %x\tDescription - ", theSetId);
1054 buffer_ += buf;
1056 ACE_CString theDescr = _find_info (theSetId);
1058 if (theDescr.length () == 0)
1059 buffer_ += "Unknown CodeSet\n";
1060 else
1062 buffer_ += theDescr.c_str ();
1063 buffer_ += "\n";
1067 CORBA::Boolean
1068 Catior_i::cat_codeset_info (TAO_InputCDR& cdr)
1070 CORBA::ULong length = 0;
1071 if (cdr.read_ulong (length) == 0)
1072 return false;
1074 TAO_InputCDR stream (cdr, length);
1075 cdr.skip_bytes(length);
1077 static const size_t bufsize = 512;
1078 char buf[bufsize];
1080 ACE_OS::snprintf (buf, bufsize, "\tComponent length: %u\n", length);
1081 buffer_ += buf;
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 "
1098 "for char.\n"),
1099 false);
1101 ACE_OS::snprintf (buf, bufsize, "\tNumber of CCS for char: %u\n", c_ccslen);
1102 buffer_ += buf;
1104 if (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 ") ",
1114 index + 1);
1115 buffer_ += buf;
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 "
1129 "for wchar.\n"),
1130 false);
1132 ACE_OS::snprintf (buf, bufsize, "\tNumber of CCS for wchar: %u\n", w_ccslen);
1133 buffer_ += buf;
1135 if (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 ") ",
1143 index + 1);
1144 buffer_ += buf;
1145 displayHex (stream);
1147 return true;
1150 CORBA::Boolean
1151 Catior_i::cat_tagged_components (TAO_InputCDR& stream)
1153 // ... and object key.
1155 CORBA::ULong len;
1156 if (!(stream >> len))
1157 return false;
1159 static const size_t bufsize = 512;
1160 char buf[bufsize];
1162 for (CORBA::ULong i = 0;
1163 i != len;
1164 ++i)
1166 CORBA::ULong tag;
1167 if (!(stream >> tag))
1169 ACE_ERROR_RETURN ((LM_ERROR,
1170 "Unable to read component tag.\n"),
1171 false);
1174 indent ();
1175 ACE_OS::snprintf (buf, bufsize,
1176 "The component <" ACE_UINT32_FORMAT_SPECIFIER_ASCII
1177 "> ID is " ACE_UINT32_FORMAT_SPECIFIER_ASCII,
1178 i+1, tag);
1179 buffer_ += buf;
1181 if (tag == IOP::TAG_ORB_TYPE) {
1182 ACE_OS::snprintf (buf, bufsize, " (TAG_ORB_TYPE)\n");
1183 buffer_ += buf;
1184 trace_depth_ += 2;
1185 cat_tag_orb_type(stream);
1186 trace_depth_ -= 2;
1187 } else if (tag == IOP::TAG_CODE_SETS) {
1188 ACE_OS::snprintf (buf, bufsize, " (TAG_CODE_SETS)\n");
1189 buffer_ += buf;
1190 trace_depth_ += 2;
1191 cat_codeset_info(stream);
1192 trace_depth_ -= 2;
1193 } else if (tag == IOP::TAG_ALTERNATE_IIOP_ADDRESS) {
1194 ACE_OS::snprintf (buf, bufsize, " (TAG_ALTERNATE_IIOP_ADDRESS)\n");
1195 buffer_ += buf;
1196 trace_depth_ += 2;
1197 cat_tag_alternate_endpoints (stream);
1198 trace_depth_ -= 2;
1199 } else if (tag == TAO_TAG_ENDPOINTS) {
1200 ACE_OS::snprintf (buf, bufsize, " (TAO_TAG_ENDPOINTS)\n");
1201 buffer_ += buf;
1202 trace_depth_ += 2;
1203 cat_tao_tag_endpoints(stream);
1204 trace_depth_ -= 2;
1205 } else if (tag == IOP::TAG_POLICIES) {
1206 ACE_OS::snprintf (buf, bufsize, " (TAG_POLICIES)\n");
1207 buffer_ += buf;
1208 trace_depth_ += 2;
1209 cat_tag_policies(stream);
1210 trace_depth_ -= 2;
1211 } else if (tag == 20U /* SSLIOP::TAG_SSL_SEC_TRANS */) {
1212 ACE_OS::snprintf (buf, bufsize, " (TAG_SSL_SEC_TRANS)\n");
1213 buffer_ += buf;
1214 trace_depth_ += 2;
1215 cat_tag_ssl_sec_trans(stream);
1216 trace_depth_ -= 2;
1217 } else if (tag == 38U /* TAG_RMI_CUSTOM_MAX_STREAM_FORMAT */) {
1218 ACE_OS::snprintf (buf, bufsize, "(TAG_RMI_CUSTOM_MAX_STREAM_FORMAT)\n");
1219 buffer_ += buf;
1220 trace_depth_ += 2;
1221 cat_octet_seq ("Component Value", stream);
1222 trace_depth_ -= 2;
1223 } else if (tag == 1229081866U /* IBM_PARTNER_VERSION */) {
1224 ACE_OS::snprintf (buf, bufsize, " (IBM_PARTNER_VERSION)\n");
1225 buffer_ += buf;
1226 trace_depth_ += 2;
1227 cat_ibm_partner_version (stream);
1228 trace_depth_ -= 2;
1229 } else {
1230 ACE_OS::snprintf (buf, bufsize, " (Unrecognized tag)\n");
1231 buffer_ += buf;
1232 trace_depth_ += 2;
1233 cat_octet_seq ("Component Value", stream);
1234 trace_depth_ -= 2;
1238 return true;
1241 CORBA::Boolean
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)
1262 return false;
1264 static const size_t bufsize = 512;
1265 char buf[bufsize];
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
1271 // encapsulation...
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))
1279 indent ();
1280 ACE_OS::snprintf (buf, bufsize,
1281 "detected new v%d.%d %s profile that catior cannot decode\n",
1282 iiop_version_major,
1283 iiop_version_minor,
1284 protocol);
1285 buffer_ += buf;
1286 return true;
1289 ACE_OS::snprintf (buf, bufsize,
1290 "%s Version:\t%d.%d\n",
1291 protocol, iiop_version_major, iiop_version_minor);
1292 buffer_ += buf;
1294 // Get host and port.
1295 CORBA::UShort port_number;
1296 CORBA::String_var hostname;
1297 if (!(str >> hostname.inout ()))
1299 indent ();
1300 buffer_ += "problem decoding hostname\n";
1301 return true;
1304 if (!(str >> port_number))
1305 return false;
1307 indent ();
1308 buffer_ += "Host Name:\t";
1309 buffer_ += hostname.in ();
1310 buffer_ += "\n";
1312 indent ();
1313 ACE_OS::snprintf (buf, bufsize, "Port Number:\t%d\n", port_number);
1314 buffer_ += buf;
1316 if (!cat_object_key (str))
1317 return false;
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)
1323 return false;
1325 return true;
1327 else
1328 return false;
1331 CORBA::Boolean
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)
1350 return false;
1352 static const size_t bufsize = 512;
1353 char buf[bufsize];
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
1359 // encapsulation...
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))
1367 indent ();
1368 ACE_OS::snprintf (buf, bufsize,
1369 "detected new v%d.%d COIOP profile that catior cannot decode",
1370 iiop_version_major,
1371 iiop_version_minor);
1372 buffer_ += buf;
1373 return true;
1376 ACE_OS::snprintf (buf, bufsize,
1377 "COIOP Version:\t%d.%d\n",
1378 iiop_version_major,
1379 iiop_version_minor);
1380 buffer_ += buf;
1382 // Get host and port.
1383 CORBA::String_var uuid;
1384 if (!(str >> uuid.inout ()))
1386 indent ();
1387 buffer_ += "problem decoding uuid\n";
1388 return true;
1391 indent ();
1392 buffer_ += "UUID:\t";
1393 buffer_ += uuid.in ();
1394 buffer_ += "\n";
1396 if (cat_object_key (str) == 0)
1397 return false;
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)
1403 return false;
1405 return true;
1407 else
1408 return false;
1411 CORBA::Boolean
1412 Catior_i::cat_iiop_profile (TAO_InputCDR& stream)
1414 return cat_profile_helper (stream, "IIOP");
1417 CORBA::Boolean
1418 Catior_i::cat_shmiop_profile (TAO_InputCDR& stream)
1420 return cat_profile_helper (stream, "SHMIOP");
1423 CORBA::Boolean
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
1429 // more.
1431 CORBA::ULong encap_len;
1432 if (stream.read_ulong (encap_len) == 0)
1433 return false;
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)
1440 return false;
1442 static const size_t bufsize = 512;
1443 char buf[bufsize];
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
1449 // encapsulation...
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))
1458 indent ();
1459 ACE_OS::snprintf (buf, bufsize,
1460 "detected new v%d.%d UIOP profile",
1461 uiop_version_major,
1462 uiop_version_minor);
1463 buffer_ += buf;
1464 return true;
1467 indent ();
1468 ACE_OS::snprintf (buf, bufsize,
1469 "UIOP Version:\t%d.%d\n",
1470 uiop_version_major,
1471 uiop_version_minor);
1472 buffer_ += buf;
1474 // Get host and port.
1475 CORBA::String_var rendezvous;
1476 if ((str >> rendezvous.out ()) == 0)
1477 return false;
1479 indent ();
1480 buffer_ += "Rendezvous point:\t";
1481 buffer_ += rendezvous.in ();
1482 buffer_ += "\n";
1484 if (cat_object_key (str) == 0)
1485 return false;
1487 if (cat_tagged_components (str) == 0)
1488 return false;
1490 return true;
1493 CORBA::Boolean
1494 Catior_i::cat_multiple_components (TAO_InputCDR& stream)
1496 static const size_t bufsize = 512;
1497 char buf[bufsize];
1499 ACE_OS::snprintf (buf, bufsize,
1500 "Multiple Components Profile\n");
1501 buffer_ += buf;
1502 return cat_tagged_components (stream);
1505 CORBA::Boolean
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)
1521 return false;
1523 static const size_t bufsize = 512;
1524 char buf[bufsize];
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
1530 // encapsulation...
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))
1538 indent ();
1539 ACE_OS::snprintf (buf, bufsize,
1540 "detected new v%d.%d SCIOP profile that catior cannot decode",
1541 iiop_version_major,
1542 iiop_version_minor);
1543 buffer_ += buf;
1544 return true;
1547 indent ();
1548 ACE_OS::snprintf (buf, bufsize,
1549 "SCIOP Version:\t%d.%d\n",
1550 iiop_version_major,
1551 iiop_version_minor);
1552 buffer_ += buf;
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."),
1562 false);
1564 indent ();
1565 ACE_OS::snprintf (buf, bufsize, "Addresses:\t%d\n", addresses);
1566 buffer_ += buf;
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"),
1575 false);
1578 indent ();
1579 buffer_ += "Host Name:\t";
1580 buffer_ += hostname.in ();
1581 buffer_ += "\n";
1585 if (!(str >> port_number))
1586 return false;
1588 indent ();
1589 ACE_OS::snprintf (buf, bufsize, "Port Number:\t%d\n", port_number);
1590 buffer_ += buf;
1592 if (!(str >> max_streams))
1593 return false;
1595 indent ();
1596 ACE_OS::snprintf (buf, bufsize, "Max Streams:\t%d\n", max_streams);
1597 buffer_ += buf;
1599 // Unlike IIOP (1.0), SCIOP always has tagged_components.
1600 if (!cat_object_key (str) || !cat_tagged_components (str))
1601 return false;
1603 return true;
1607 CORBA::Boolean
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)
1627 return false;
1629 static const size_t bufsize = 512;
1630 char buf[bufsize];
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
1636 // encapsulation...
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))
1644 indent ();
1645 ACE_OS::snprintf (buf, bufsize,
1646 "detected new v%d.%d %s profile that catior cannot decode",
1647 iiop_version_major,
1648 iiop_version_minor,
1649 protocol);
1650 buffer_ += buf;
1651 return true;
1654 ACE_OS::snprintf (buf, bufsize,
1655 "%s Version:\t%d.%d\n",
1656 protocol,
1657 iiop_version_major,
1658 iiop_version_minor);
1659 buffer_ += buf;
1661 // Get address
1662 char* fsaddress;
1663 if (!(str >> fsaddress))
1665 indent ();
1666 buffer_ += "problem decoding file system address\n";
1667 return true;
1671 indent ();
1672 buffer_ += "FS Address:\t";
1673 buffer_ += fsaddress;
1674 buffer_ += "\n";
1675 CORBA::string_free (fsaddress);
1677 if (cat_object_key (str) == 0)
1678 return false;
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)
1684 return false;
1686 return true;
1688 else
1689 return false;
1692 CORBA::Boolean
1693 Catior_i::cat_nskpw_profile (TAO_InputCDR& stream)
1695 return cat_nsk_profile_helper (stream, "NSKPW");
1698 CORBA::Boolean
1699 Catior_i::cat_nskfs_profile (TAO_InputCDR& stream)
1701 return cat_nsk_profile_helper (stream, "NSKFS");
1704 void
1705 Catior_i::indent()
1707 if (trace_depth_ != 0)
1709 for(size_t i = 0; i < trace_depth_; i++)
1710 buffer_ += " ";