ACE+TAO-6_5_17
[ACE_TAO.git] / TAO / utils / catior / Catior_i.cpp
blob917d965291b9efa193be1bbc0b3ebb3086355e83
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;
94 CORBA::Boolean
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)
101 return false;
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
109 // accept
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])
116 && string [1] == '.'
117 && string [3] == '/'
118 && string [4] == '/')
120 iiop_version_major = (char) (string [0] - '0');
121 iiop_version_minor = (char) (string [2] - '0');
122 string += 5;
124 else
126 string += 2;
129 static const size_t bufsize = 512;
130 char buf[bufsize];
131 ACE_OS::snprintf (buf, bufsize, "IIOP Version:\t%d.%d\n",
132 iiop_version_major, iiop_version_minor);
133 buffer_ += buf;
135 // Pull off the "hostname:port/" part of the objref Get host and
136 // port.
137 CORBA::UShort port_number;
138 char *cp = ACE_OS::strchr (string, ':');
140 if (cp == 0)
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 ();
149 *string != ':';
150 *cp++ = *string++)
151 continue;
153 *cp = 0;
154 ++string;
156 cp = ACE_OS::strchr ((char *) string, '/');
158 if (cp == 0)
160 throw CORBA::DATA_CONVERSION ();
163 port_number = (short) ACE_OS::atoi ((char *) string);
164 string = ++cp;
166 ACE_OS::snprintf (buf, bufsize, "Host Name:\t%s\n"
167 "Port Number:\t%d\n",
168 hostname.in (), port_number);
169 buffer_ += buf;
171 // Parse the object key.
172 // dump the object key to stdout
173 // TAO_POA::decode_string_to_sequence (data->profile.object_key,
174 // string);
175 buffer_ += "\nThe Object Key as string:\n";
176 buffer_ += string;
177 buffer_ += "\n";
179 return true;
182 CORBA::Boolean
183 Catior_i::catior (char const * str)
185 // Unhex the bytes, and make a CDR deencapsulation stream from the
186 // resulting data.
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;
194 size_t len = 0;
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])
203 u_char byte;
205 if (! (ACE_OS::ace_isxdigit (tmp [0]) && ACE_OS::ace_isxdigit (tmp [1])))
206 break;
208 byte = (u_char) (ACE::hex2byte (tmp [0]) << 4);
209 byte |= ACE::hex2byte (tmp [1]);
211 buffer[len++] = byte;
212 tmp += 2;
215 // Create deencapsulation stream ... then unmarshal objref from that
216 // stream.
218 int byteOrder = *(mb.rd_ptr ());
220 mb.rd_ptr (1);
221 mb.wr_ptr (len);
222 TAO_InputCDR stream (&mb, static_cast<int> (byteOrder));
224 buffer_ += "The Byte Order:\t";
225 if (byteOrder == 1)
226 buffer_ += "Little Endian\n";
227 else
228 buffer_ += "Big Endian\n";
230 // First, read the type hint. This will be the type_id encoded in an
231 // object reference.
232 CORBA::String_var type_hint;
234 if (!(stream >> type_hint.inout ()))
236 ACE_ERROR_RETURN ((LM_ERROR,
237 "cannot read type id\n"),
238 TAO::TRAVERSE_STOP);
241 buffer_ += "The Type Id:\t\"";
242 buffer_ += type_hint.in ();
243 buffer_ += "\"\n";
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"),
263 TAO::TRAVERSE_STOP);
266 CORBA::ULong profile_counter = 0;
268 static const size_t bufsize = 512;
269 char buf[bufsize];
270 ACE_OS::snprintf (buf, bufsize,
271 "Number of Profiles in IOR:\t%d\n", profiles);
272 buffer_ += buf;
274 // No profiles means a NIL objref.
275 if (profiles == 0)
276 return TAO::TRAVERSE_CONTINUE;
277 else
278 while (profiles-- != 0)
280 ACE_OS::snprintf (buf, bufsize, "Profile number:\t%d\n",
281 ++profile_counter);
282 buffer_ += buf;
284 // We keep decoding until we find a valid IIOP profile.
285 CORBA::ULong tag;
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"));
293 continue;
296 trace_depth_++;
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);
333 else
335 indent ();
336 ACE_OS::snprintf (buf, bufsize,
337 "Profile tag = %d (unknown protocol)\n", tag);
338 buffer_ += buf;
339 continue_decoding = cat_octet_seq("Profile body", stream);
341 trace_depth_--;
343 return true;
346 // Parse the Orbix-style POOP object references, which have the form:
347 //:\ntlj3corba:NS:NC_2::IR:CosNaming_NamingContext
348 // :\ hostname
349 // : server_name
350 // : marker
351 // : IR_host
352 // : IR_server
353 // : interface_marker
355 CORBA::Boolean
356 Catior_i::catpoop (char* string)
358 if (!string || !*string)
359 return false;
361 //if (string [0] == ':'
362 // && string [1] == '\\')
363 // ACE_DEBUG ((LM_DEBUG,
364 // "\nPerhaps we've found some POOP\n"));
365 string += 2;
367 char *cp = ACE_OS::strchr (string, ':');
369 if (cp == 0)
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));
378 for (cp = hostname;
379 *string != ':';
380 *cp++ = *string++)
381 continue;
383 *cp = 0;
384 ++string;
386 buffer_ += "Host Name:\t";
387 buffer_ += hostname;
388 buffer_ += "\n";
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;
398 *string != ':';
399 *cp++ = *string++)
400 continue;
402 *cp = 0;
403 ++string;
405 buffer_ += "Server Name:\t";
406 buffer_ += server_name;
407 buffer_ += "\n",
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));
417 for (cp = marker;
418 *string != ':';
419 *cp++ = *string++)
420 continue;
422 *cp = 0;
423 ++string;
425 buffer_ += "Marker:\t\t";
426 buffer_ += marker;
427 buffer_ += "\n";
428 CORBA::string_free (marker);
430 cp = ACE_OS::strchr (string, ':');
432 // Read the IR_host.
433 char* IR_host = CORBA::string_alloc (1 +
434 ACE_Utils::truncate_cast<CORBA::ULong> (cp - string));
436 for (cp = IR_host;
437 *string != ':';
438 *cp++ = *string++)
439 continue;
441 *cp = 0;
442 ++string;
444 buffer_ += "IR Host:\t\t";
445 buffer_ += IR_host;
446 buffer_ += "\n";
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));
455 for (cp = IR_server;
456 *string != ':';
457 *cp++ = *string++)
458 continue;
460 *cp = 0;
461 ++string;
463 buffer_ += "IR Server:\t\t";
464 buffer_ += IR_server;
465 buffer_ += "\n";
466 CORBA::string_free (IR_server);
468 // Read the interface_marker
469 buffer_ += "Interface Marker:\t";
470 buffer_ += string;
471 buffer_ += "\n";
472 return true;
475 CORBA::Boolean
476 Catior_i::cat_tag_orb_type (TAO_InputCDR& stream) {
477 CORBA::ULong length = 0;
478 if (!stream.read_ulong (length))
479 return true;
481 TAO_InputCDR stream2 (stream, length);
482 stream.skip_bytes(length);
484 CORBA::ULong orbtype;
486 if (!(stream2 >> orbtype))
487 return false;
489 static const size_t bufsize = 512;
490 char buf[bufsize];
492 indent();
494 switch (orbtype)
496 case TAO_ORB_TYPE:
498 ACE_OS::snprintf (buf, bufsize,
499 "ORB Type: 0x%x (TAO)\n", orbtype);
500 break;
502 case 0x47430000 :
504 ACE_OS::snprintf (buf, bufsize,
505 "ORB Type: 0x%x (GNU Classpath)\n", orbtype);
506 break;
508 case 0x49540000 :
510 ACE_OS::snprintf (buf, bufsize,
511 "ORB Type: 0x%x (Orbix)\n", orbtype);
512 break;
514 case 0x4A430000 :
516 ACE_OS::snprintf (buf, bufsize,
517 "ORB Type: 0x%x (JacORB)\n", orbtype);
518 break;
520 case 0x41540000 :
522 ACE_OS::snprintf (buf, bufsize,
523 "ORB Type: 0x%x (OmniORB)\n", orbtype);
524 break;
526 case 0x53550000 :
528 ACE_OS::snprintf (buf, bufsize,
529 "ORB Type: 0x%x (Sun)\n", orbtype);
530 break;
532 case 0x29A:
534 ACE_OS::snprintf (buf, bufsize,
535 "ORB Type: 0x%x (TIDorbC++)\n", orbtype);
536 break;
538 case 0x4a414300:
540 ACE_OS::snprintf (buf, bufsize,
541 "ORB Type: 0x%x (JacORB)\n", orbtype);
542 break;
544 default:
546 ACE_OS::snprintf (buf, bufsize,
547 "ORB Type: 0x%x\n", orbtype);
549 break;
551 buffer_ += buf;
552 return true;
555 CORBA::Boolean
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
562 * partner version.
563 * The next four bytes encode the length of the remaining data (in this
564 * case 8 bytes)
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
570 * compatibility
572 CORBA::ULong length = 0;
573 if (!(stream.read_ulong (length)))
574 return true;
576 TAO_InputCDR stream2 (stream, length);
577 stream.skip_bytes(length);
579 CORBA::ULong version;
580 if (!(stream2 >> version))
581 return false;
583 static const size_t bufsize = 512;
584 char buf[bufsize];
585 ACE_OS::snprintf (buf, bufsize, "\tPartner Version: 0x%x\n", version);
586 buffer_ += buf;
588 return true;
592 CORBA::Boolean
593 Catior_i::cat_tao_tag_endpoints (TAO_InputCDR& stream)
595 CORBA::ULong length = 0;
596 if (!stream.read_ulong (length))
597 return true;
599 TAO_InputCDR stream2 (stream, length);
600 stream.skip_bytes(length);
602 TAO::IIOPEndpointSequence epseq;
603 if (!(stream2 >> epseq))
604 return true;
606 static const size_t bufsize = 512;
607 char buf[bufsize];
608 for (unsigned int iter=0; iter < epseq.length() ; iter++) {
609 const char *host = epseq[iter].host;
610 CORBA::UShort port = epseq[iter].port;
611 indent ();
612 ACE_OS::snprintf (buf, bufsize,
613 "Endpoint #%d:\n", iter+1);
614 buffer_ += buf;
615 indent ();
616 ACE_OS::snprintf (buf, bufsize,
617 "Host: %s\n", host);
618 buffer_ += buf;
619 indent ();
620 ACE_OS::snprintf (buf, bufsize,
621 "Port: %d\n", port);
622 buffer_ += buf;
623 indent ();
624 ACE_OS::snprintf (buf, bufsize,
625 "Priority: %d\n", epseq[iter].priority);
626 buffer_ += buf;
629 return true;
632 CORBA::Boolean
633 Catior_i::cat_tag_alternate_endpoints (TAO_InputCDR& stream) {
634 CORBA::ULong length = 0;
635 if (!stream.read_ulong (length))
636 return true;
638 TAO_InputCDR stream2 (stream, length);
639 stream.skip_bytes(length);
641 CORBA::String_var host;
642 CORBA::UShort port;
643 if (!(stream2 >> host.out()) ||
644 !(stream2 >> port))
646 ACE_ERROR_RETURN ((LM_ERROR,"cannot extract endpoint info\n"),false);
648 else
650 static const size_t bufsize = 512;
651 char buf[bufsize];
652 indent ();
653 ACE_OS::snprintf (buf, bufsize,
654 "endpoint: %s:%d\n", host.in(), port);
655 buffer_ += buf;
658 return true;
661 CORBA::Boolean
662 Catior_i::cat_tag_policies (TAO_InputCDR& stream) {
663 CORBA::ULong length = 0;
664 if (!stream.read_ulong (length))
665 return true;
667 TAO_InputCDR stream2 (stream, length);
668 stream.skip_bytes(length);
670 Messaging::PolicyValueSeq policies;
671 if (!(stream2 >> policies))
672 return true;
674 static const size_t bufsize = 512;
675 char buf[bufsize];
676 indent ();
677 ACE_OS::snprintf (buf, bufsize,
678 "Number of policies: %d\n",
679 policies.length());
680 buffer_ += buf;
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)))
692 return true;
694 stream3.reset_byte_order (static_cast <int> (byte_order));
696 if (policies[iter].ptype == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) {
697 indent ();
698 ACE_OS::snprintf (buf, bufsize,
699 "Policy #%d Type: %d (PRIORITY_MODEL_POLICY_TYPE)\n",
700 iter+1, policies[iter].ptype);
701 buffer_ += buf;
703 RTCORBA::PriorityModel priority_model;
704 RTCORBA::Priority server_priority;
706 if (!(stream3 >> priority_model))
707 return true;
708 if (!(stream3 >> server_priority))
709 return true;
711 indent ();
712 if (priority_model == RTCORBA::CLIENT_PROPAGATED) {
713 ACE_OS::snprintf (buf, bufsize,
714 "\t Priority Model: %d (CLIENT_PROPAGATED)\n",
715 priority_model);
716 } else if (priority_model == RTCORBA::SERVER_DECLARED) {
717 ACE_OS::snprintf (buf, bufsize,
718 "\t Priority Model: %d (SERVER_DECLARED)\n",
719 priority_model);
720 } else {
721 ACE_OS::snprintf (buf, bufsize,
722 "\t Priority Model: %d (UNKNOWN!)\n",
723 priority_model);
725 buffer_ += buf;
726 indent ();
727 ACE_OS::snprintf (buf, bufsize,
728 "\t Priority: %d\n", server_priority);
729 buffer_ += buf;
731 } else if (policies[iter].ptype == RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE) {
732 indent ();
733 ACE_OS::snprintf (buf, bufsize,
734 "Policy #%d Type: %d (PRIORITY_BANDED_CONNECTION_POLICY_TYPE)\n",
735 iter+1, policies[iter].ptype);
736 buffer_ += buf;
737 } else if (policies[iter].ptype == Messaging::REBIND_POLICY_TYPE) {
738 indent ();
739 ACE_OS::snprintf (buf, bufsize,
740 "Policy #%d Type: %d (REBIND_POLICY_TYPE)\n",
741 iter+1, policies[iter].ptype);
742 buffer_ += buf;
743 #if (TAO_HAS_SYNC_SCOPE_POLICY == 1)
744 } else if (policies[iter].ptype == Messaging::SYNC_SCOPE_POLICY_TYPE) {
745 indent ();
746 ACE_OS::snprintf (buf, bufsize,
747 "Policy #%d Type: %d (SYNC_SCOPE_POLICY_TYPE)\n",
748 iter+1, policies[iter].ptype);
749 buffer_ += buf;
750 #endif
751 } else if (policies[iter].ptype == Messaging::REQUEST_PRIORITY_POLICY_TYPE) {
752 indent ();
753 ACE_OS::snprintf (buf, bufsize,
754 "Policy #%d Type: %d (REQUEST_PRIORITY_POLICY_TYPE)\n",
755 iter+1, policies[iter].ptype);
756 buffer_ += buf;
757 } else if (policies[iter].ptype == Messaging::REPLY_PRIORITY_POLICY_TYPE) {
758 indent ();
759 ACE_OS::snprintf (buf, bufsize,
760 "Policy #%d Type: %d (REPLY_PRIORITY_POLICY_TYPE)\n",
761 iter+1, policies[iter].ptype);
762 buffer_ += buf;
763 } else if (policies[iter].ptype == Messaging::REQUEST_START_TIME_POLICY_TYPE) {
764 indent ();
765 ACE_OS::snprintf (buf, bufsize,
766 "Policy #%d Type: %d (REQUEST_START_TIME_POLICY_TYPE)\n",
767 iter+1, policies[iter].ptype);
768 buffer_ += buf;
769 } else if (policies[iter].ptype == Messaging::REQUEST_END_TIME_POLICY_TYPE) {
770 indent ();
771 ACE_OS::snprintf (buf, bufsize,
772 "Policy #%d Type: %d (REQUEST_END_TIME_POLICY_TYPE)\n",
773 iter+1, policies[iter].ptype);
774 buffer_ += buf;
775 } else if (policies[iter].ptype == Messaging::REPLY_START_TIME_POLICY_TYPE) {
776 indent ();
777 ACE_OS::snprintf (buf, bufsize,
778 "Policy #%d Type: %d (REPLY_START_TIME_POLICY_TYPE)\n",
779 iter+1, policies[iter].ptype);
780 buffer_ += buf;
781 } else if (policies[iter].ptype == Messaging::REPLY_END_TIME_POLICY_TYPE) {
782 indent ();
783 ACE_OS::snprintf (buf, bufsize,
784 "Policy #%d Type: %d (REPLY_END_TIME_POLICY_TYPE)\n",
785 iter+1, policies[iter].ptype);
786 buffer_ += buf;
787 } else if (policies[iter].ptype == Messaging::RELATIVE_REQ_TIMEOUT_POLICY_TYPE) {
788 indent ();
789 ACE_OS::snprintf (buf, bufsize,
790 "Policy #%d Type: %d (RELATIVE_REQ_TIMEOUT_POLICY_TYPE)\n",
791 iter+1, policies[iter].ptype);
792 buffer_ += buf;
793 } else if (policies[iter].ptype == Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE) {
794 indent ();
795 ACE_OS::snprintf (buf, bufsize,
796 "Policy #%d Type: %d (RELATIVE_RT_TIMEOUT_POLICY_TYPE)\n",
797 iter+1, policies[iter].ptype);
798 buffer_ += buf;
799 } else if (policies[iter].ptype == Messaging::ROUTING_POLICY_TYPE) {
800 indent ();
801 ACE_OS::snprintf (buf, bufsize,
802 "Policy #%d Type: %d (ROUTING_POLICY_TYPE)\n",
803 iter+1, policies[iter].ptype);
804 buffer_ += buf;
805 } else if (policies[iter].ptype == Messaging::MAX_HOPS_POLICY_TYPE) {
806 indent ();
807 ACE_OS::snprintf (buf, bufsize,
808 "Policy #%d Type: %d (MAX_HOPS_POLICY_TYPE)\n",
809 iter+1, policies[iter].ptype);
810 buffer_ += buf;
811 } else if (policies[iter].ptype == Messaging::QUEUE_ORDER_POLICY_TYPE) {
812 indent ();
813 ACE_OS::snprintf (buf, bufsize,
814 "Policy #%d Type: %d (QUEUE_ORDER_POLICY_TYPE)\n",
815 iter+1, policies[iter].ptype);
816 buffer_ += buf;
817 } else if (policies[iter].ptype == ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID) {
818 indent ();
819 ACE_OS::snprintf (buf, bufsize,
820 "Policy #%d Type: %d (COMPRESSOR_ID_LEVEL_LIST_POLICY_ID)\n",
821 iter+1, policies[iter].ptype);
822 buffer_ += buf;
823 ::Compression::CompressorIdLevelList idlist;
824 if (!(stream3 >> idlist))
825 return true;
826 CORBA::ULong index = 0;
827 for (; index < idlist.length(); index++)
829 indent ();
830 ACE_OS::snprintf (buf, bufsize,
831 "\t CompressorId: %d Level: %d\n",
832 idlist[index].compressor_id, idlist[index].compression_level);
833 buffer_ += buf;
835 } else if (policies[iter].ptype == ZIOP::COMPRESSION_ENABLING_POLICY_ID) {
836 indent ();
837 ACE_OS::snprintf (buf, bufsize,
838 "Policy #%d Type: %d (COMPRESSION_ENABLING_POLICY_ID)\n",
839 iter+1, policies[iter].ptype);
840 buffer_ += buf;
841 CORBA::Boolean status;
842 if (!(stream3 >> ACE_InputCDR::to_boolean (status)))
843 return true;
844 indent ();
845 ACE_OS::snprintf (buf, bufsize, "\t Enabled: %d\n", status);
846 buffer_ += buf;
847 } else {
848 indent ();
849 ACE_OS::snprintf (buf, bufsize,
850 "Policy #%d Type: %d (UNKNOWN)\n", iter+1,
851 policies[iter].ptype);
852 buffer_ += buf;
856 return true;
859 CORBA::Boolean
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);
888 return false;
891 CORBA::Boolean
892 Catior_i::cat_tag_ssl_sec_trans (TAO_InputCDR& cdr) {
894 Decode the following from the stream (copied from SSLIOP.idl)
896 module Security {
897 typedef unsigned short AssociationOptions;
900 module SSLIOP {
901 struct SSL {
902 Security::AssociationOptions target_supports;
903 Security::AssociationOptions target_requires;
904 unsigned short port;
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))
914 return false;
916 TAO_InputCDR stream (cdr, length);
917 cdr.skip_bytes(length);
919 CORBA::UShort target_supports;
920 CORBA::UShort target_requires;
921 CORBA::UShort port;
923 if (stream.read_ushort(target_supports) == 0)
924 return false;
926 if (stream.read_ushort(target_requires) == 0)
927 return false;
929 if (stream.read_ushort(port) == 0)
930 return false;
932 static const size_t bufsize = 512;
933 char buf[bufsize];
935 indent ();
936 ACE_OS::snprintf (buf, bufsize, "port = %d\n", port);
937 buffer_ += buf;
938 indent ();
939 ACE_OS::snprintf (buf, bufsize, "target_supports = 0x%x\n", target_supports);
940 buffer_ += buf;
941 trace_depth_++;
942 cat_security_association(target_supports);
943 trace_depth_--;
944 indent ();
945 ACE_OS::snprintf (buf, bufsize, "target_requires = 0x%x\n", target_requires);
946 buffer_ += buf;
947 trace_depth_++;
948 cat_security_association(target_requires);
949 trace_depth_--;
951 return true;
954 CORBA::Boolean
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))
960 return true;
962 static const size_t bufsize = 512;
963 char buf[bufsize];
965 indent ();
966 ACE_OS::snprintf (buf, bufsize, "%s len:\t%d\n", object_name, length);
967 buffer_ += buf;
969 indent ();
970 ACE_OS::snprintf (buf, bufsize, "%s as hex:\n", object_name);
971 buffer_ += buf;
973 CORBA::Octet anOctet;
974 CORBA::String_var objKey = CORBA::string_alloc (length + 1);
976 short counter = -1;
978 indent ();
979 CORBA::ULong i = 0;
981 for (; i < length; ++i)
983 if (++counter == 16)
985 buffer_ += "\n";
986 indent ();
987 counter = 0;
990 if (!stream.read_octet (anOctet))
991 return false;
993 ACE_OS::snprintf (buf, bufsize, "%2.2x ", anOctet);
994 buffer_ += buf;
995 objKey[i] = (char) anOctet;
998 objKey[i] = '\0';
1000 buffer_ += "\n";
1001 indent ();
1002 ACE_OS::snprintf (buf, bufsize,
1003 "The %s as string:\n", object_name);
1004 buffer_ += buf;
1005 indent ();
1007 for (i = 0; i < length; ++i)
1009 char c = objKey[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)))
1012 buffer_ += c;
1013 else
1014 buffer_ += ".";
1017 buffer_ += "\n";
1019 return true;
1022 CORBA::Boolean
1023 Catior_i::cat_object_key (TAO_InputCDR& stream)
1025 // ... and object key.
1027 return cat_octet_seq ("Object Key", stream);
1030 ACE_CString
1031 Catior_i::_find_info (CORBA::ULong id)
1033 ACE_CString locale = "";
1034 ACE_Codeset_Registry::registry_to_locale (id, locale, 0, 0);
1035 return locale;
1038 void
1039 Catior_i::displayHex (TAO_InputCDR & str)
1041 if (str.good_bit () == 0)
1042 return;
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"));
1050 return;
1053 static const size_t bufsize = 512;
1054 char buf[bufsize];
1055 ACE_OS::snprintf (buf, bufsize, " Hex - %x\tDescription - ", theSetId);
1056 buffer_ += buf;
1058 ACE_CString theDescr = _find_info (theSetId);
1060 if (theDescr.length () == 0)
1061 buffer_ += "Unknown CodeSet\n";
1062 else
1064 buffer_ += theDescr.c_str ();
1065 buffer_ += "\n";
1069 CORBA::Boolean
1070 Catior_i::cat_codeset_info (TAO_InputCDR& cdr)
1072 CORBA::ULong length = 0;
1073 if (cdr.read_ulong (length) == 0)
1074 return false;
1076 TAO_InputCDR stream (cdr, length);
1077 cdr.skip_bytes(length);
1079 static const size_t bufsize = 512;
1080 char buf[bufsize];
1082 ACE_OS::snprintf (buf, bufsize, "\tComponent length: %u\n", length);
1083 buffer_ += buf;
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 "
1100 "for char.\n"),
1101 false);
1103 ACE_OS::snprintf (buf, bufsize, "\tNumber of CCS for char %u\n", c_ccslen);
1104 buffer_ += buf;
1106 if (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 ") ",
1116 index + 1);
1117 buffer_ += buf;
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 "
1131 "for wchar.\n"),
1132 false);
1134 ACE_OS::snprintf (buf, bufsize, "\tNumber of CCS for wchar %u\n", w_ccslen);
1135 buffer_ += buf;
1137 if (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 ") ",
1145 index + 1);
1146 buffer_ += buf;
1147 displayHex (stream);
1149 return true;
1152 CORBA::Boolean
1153 Catior_i::cat_tagged_components (TAO_InputCDR& stream)
1155 // ... and object key.
1157 CORBA::ULong len;
1158 if (!(stream >> len))
1159 return false;
1161 static const size_t bufsize = 512;
1162 char buf[bufsize];
1164 for (CORBA::ULong i = 0;
1165 i != len;
1166 ++i)
1168 CORBA::ULong tag;
1169 if (!(stream >> tag))
1171 ACE_ERROR_RETURN ((LM_ERROR,
1172 "Unable to read component tag.\n"),
1173 false);
1176 indent ();
1177 ACE_OS::snprintf (buf, bufsize,
1178 "The component <" ACE_UINT32_FORMAT_SPECIFIER_ASCII
1179 "> ID is " ACE_UINT32_FORMAT_SPECIFIER_ASCII,
1180 i+1, tag);
1181 buffer_ += buf;
1183 if (tag == IOP::TAG_ORB_TYPE) {
1184 ACE_OS::snprintf (buf, bufsize, " (TAG_ORB_TYPE)\n");
1185 buffer_ += buf;
1186 trace_depth_ += 2;
1187 cat_tag_orb_type(stream);
1188 trace_depth_ -= 2;
1189 } else if (tag == IOP::TAG_CODE_SETS) {
1190 ACE_OS::snprintf (buf, bufsize, " (TAG_CODE_SETS)\n");
1191 buffer_ += buf;
1192 trace_depth_ += 2;
1193 cat_codeset_info(stream);
1194 trace_depth_ -= 2;
1195 } else if (tag == IOP::TAG_ALTERNATE_IIOP_ADDRESS) {
1196 ACE_OS::snprintf (buf, bufsize, " (TAG_ALTERNATE_IIOP_ADDRESS)\n");
1197 buffer_ += buf;
1198 trace_depth_ += 2;
1199 cat_tag_alternate_endpoints (stream);
1200 trace_depth_ -= 2;
1201 } else if (tag == TAO_TAG_ENDPOINTS) {
1202 ACE_OS::snprintf (buf, bufsize, " (TAO_TAG_ENDPOINTS)\n");
1203 buffer_ += buf;
1204 trace_depth_ += 2;
1205 cat_tao_tag_endpoints(stream);
1206 trace_depth_ -= 2;
1207 } else if (tag == IOP::TAG_POLICIES) {
1208 ACE_OS::snprintf (buf, bufsize, " (TAG_POLICIES)\n");
1209 buffer_ += buf;
1210 trace_depth_ += 2;
1211 cat_tag_policies(stream);
1212 trace_depth_ -= 2;
1213 } else if (tag == 20U /* SSLIOP::TAG_SSL_SEC_TRANS */) {
1214 ACE_OS::snprintf (buf, bufsize, " (TAG_SSL_SEC_TRANS)\n");
1215 buffer_ += buf;
1216 trace_depth_ += 2;
1217 cat_tag_ssl_sec_trans(stream);
1218 trace_depth_ -= 2;
1219 } else if (tag == 38U /* TAG_RMI_CUSTOM_MAX_STREAM_FORMAT */) {
1220 ACE_OS::snprintf (buf, bufsize, "(TAG_RMI_CUSTOM_MAX_STREAM_FORMAT)\n");
1221 buffer_ += buf;
1222 trace_depth_ += 2;
1223 cat_octet_seq ("Component Value", stream);
1224 trace_depth_ -= 2;
1225 } else if (tag == 1229081866U /* IBM_PARTNER_VERSION */) {
1226 ACE_OS::snprintf (buf, bufsize, " (IBM_PARTNER_VERSION)\n");
1227 buffer_ += buf;
1228 trace_depth_ += 2;
1229 cat_ibm_partner_version (stream);
1230 trace_depth_ -= 2;
1231 } else {
1232 ACE_OS::snprintf (buf, bufsize, " (Unrecognized tag)\n");
1233 buffer_ += buf;
1234 trace_depth_ += 2;
1235 cat_octet_seq ("Component Value", stream);
1236 trace_depth_ -= 2;
1240 return true;
1243 CORBA::Boolean
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)
1264 return false;
1266 static const size_t bufsize = 512;
1267 char buf[bufsize];
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
1273 // encapsulation...
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))
1281 indent ();
1282 ACE_OS::snprintf (buf, bufsize,
1283 "detected new v%d.%d %s profile that catior cannot decode\n",
1284 iiop_version_major,
1285 iiop_version_minor,
1286 protocol);
1287 buffer_ += buf;
1288 return true;
1291 ACE_OS::snprintf (buf, bufsize,
1292 "%s Version:\t%d.%d\n",
1293 protocol, iiop_version_major, iiop_version_minor);
1294 buffer_ += buf;
1296 // Get host and port.
1297 CORBA::UShort port_number;
1298 CORBA::String_var hostname;
1299 if (!(str >> hostname.inout ()))
1301 indent ();
1302 buffer_ += "problem decoding hostname\n";
1303 return true;
1306 if (!(str >> port_number))
1307 return false;
1309 indent ();
1310 buffer_ += "Host Name:\t";
1311 buffer_ += hostname.in ();
1312 buffer_ += "\n";
1314 indent ();
1315 ACE_OS::snprintf (buf, bufsize, "Port Number:\t%d\n", port_number);
1316 buffer_ += buf;
1318 if (!cat_object_key (str))
1319 return false;
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)
1325 return false;
1327 return true;
1329 else
1330 return false;
1333 CORBA::Boolean
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)
1352 return false;
1354 static const size_t bufsize = 512;
1355 char buf[bufsize];
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
1361 // encapsulation...
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))
1369 indent ();
1370 ACE_OS::snprintf (buf, bufsize,
1371 "detected new v%d.%d COIOP profile that catior cannot decode",
1372 iiop_version_major,
1373 iiop_version_minor);
1374 buffer_ += buf;
1375 return true;
1378 ACE_OS::snprintf (buf, bufsize,
1379 "COIOP Version:\t%d.%d\n",
1380 iiop_version_major,
1381 iiop_version_minor);
1382 buffer_ += buf;
1384 // Get host and port.
1385 CORBA::String_var uuid;
1386 if (!(str >> uuid.inout ()))
1388 indent ();
1389 buffer_ += "problem decoding uuid\n";
1390 return true;
1393 indent ();
1394 buffer_ += "UUID:\t";
1395 buffer_ += uuid.in ();
1396 buffer_ += "\n";
1398 if (cat_object_key (str) == 0)
1399 return false;
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)
1405 return false;
1407 return true;
1409 else
1410 return false;
1413 CORBA::Boolean
1414 Catior_i::cat_iiop_profile (TAO_InputCDR& stream)
1416 return cat_profile_helper (stream, "IIOP");
1419 CORBA::Boolean
1420 Catior_i::cat_shmiop_profile (TAO_InputCDR& stream)
1422 return cat_profile_helper (stream, "SHMIOP");
1425 CORBA::Boolean
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
1431 // more.
1433 CORBA::ULong encap_len;
1434 if (stream.read_ulong (encap_len) == 0)
1435 return false;
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)
1442 return false;
1444 static const size_t bufsize = 512;
1445 char buf[bufsize];
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
1451 // encapsulation...
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))
1460 indent ();
1461 ACE_OS::snprintf (buf, bufsize,
1462 "detected new v%d.%d UIOP profile",
1463 uiop_version_major,
1464 uiop_version_minor);
1465 buffer_ += buf;
1466 return true;
1469 indent ();
1470 ACE_OS::snprintf (buf, bufsize,
1471 "UIOP Version:\t%d.%d\n",
1472 uiop_version_major,
1473 uiop_version_minor);
1474 buffer_ += buf;
1476 // Get host and port.
1477 CORBA::String_var rendezvous;
1478 if ((str >> rendezvous.out ()) == 0)
1479 return false;
1481 indent ();
1482 buffer_ += "Rendezvous point:\t";
1483 buffer_ += rendezvous.in ();
1484 buffer_ += "\n";
1486 if (cat_object_key (str) == 0)
1487 return false;
1489 if (cat_tagged_components (str) == 0)
1490 return false;
1492 return true;
1495 CORBA::Boolean
1496 Catior_i::cat_multiple_components (TAO_InputCDR& stream)
1498 static const size_t bufsize = 512;
1499 char buf[bufsize];
1501 ACE_OS::snprintf (buf, bufsize,
1502 "Multiple Components Profile\n");
1503 buffer_ += buf;
1504 return cat_tagged_components (stream);
1507 CORBA::Boolean
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)
1523 return false;
1525 static const size_t bufsize = 512;
1526 char buf[bufsize];
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
1532 // encapsulation...
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))
1540 indent ();
1541 ACE_OS::snprintf (buf, bufsize,
1542 "detected new v%d.%d SCIOP profile that catior cannot decode",
1543 iiop_version_major,
1544 iiop_version_minor);
1545 buffer_ += buf;
1546 return true;
1549 indent ();
1550 ACE_OS::snprintf (buf, bufsize,
1551 "SCIOP Version:\t%d.%d\n",
1552 iiop_version_major,
1553 iiop_version_minor);
1554 buffer_ += buf;
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."),
1564 false);
1566 indent ();
1567 ACE_OS::snprintf (buf, bufsize, "Addresses:\t%d\n", addresses);
1568 buffer_ += buf;
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"),
1577 false);
1580 indent ();
1581 buffer_ += "Host Name:\t";
1582 buffer_ += hostname.in ();
1583 buffer_ += "\n";
1587 if (!(str >> port_number))
1588 return false;
1590 indent ();
1591 ACE_OS::snprintf (buf, bufsize, "Port Number:\t%d\n", port_number);
1592 buffer_ += buf;
1594 if (!(str >> max_streams))
1595 return false;
1597 indent ();
1598 ACE_OS::snprintf (buf, bufsize, "Max Streams:\t%d\n", max_streams);
1599 buffer_ += buf;
1601 // Unlike IIOP (1.0), SCIOP always has tagged_components.
1602 if (!cat_object_key (str) || !cat_tagged_components (str))
1603 return false;
1605 return true;
1609 CORBA::Boolean
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)
1629 return false;
1631 static const size_t bufsize = 512;
1632 char buf[bufsize];
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
1638 // encapsulation...
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))
1646 indent ();
1647 ACE_OS::snprintf (buf, bufsize,
1648 "detected new v%d.%d %s profile that catior cannot decode",
1649 iiop_version_major,
1650 iiop_version_minor,
1651 protocol);
1652 buffer_ += buf;
1653 return true;
1656 ACE_OS::snprintf (buf, bufsize,
1657 "%s Version:\t%d.%d\n",
1658 protocol,
1659 iiop_version_major,
1660 iiop_version_minor);
1661 buffer_ += buf;
1663 // Get address
1664 char* fsaddress;
1665 if (!(str >> fsaddress))
1667 indent ();
1668 buffer_ += "problem decoding file system address\n";
1669 return true;
1673 indent ();
1674 buffer_ += "FS Address:\t";
1675 buffer_ += fsaddress;
1676 buffer_ += "\n";
1677 CORBA::string_free (fsaddress);
1679 if (cat_object_key (str) == 0)
1680 return false;
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)
1686 return false;
1688 return true;
1690 else
1691 return false;
1694 CORBA::Boolean
1695 Catior_i::cat_nskpw_profile (TAO_InputCDR& stream)
1697 return cat_nsk_profile_helper (stream, "NSKPW");
1700 CORBA::Boolean
1701 Catior_i::cat_nskfs_profile (TAO_InputCDR& stream)
1703 return cat_nsk_profile_helper (stream, "NSKFS");
1706 void
1707 Catior_i::indent()
1709 if (trace_depth_ != 0)
1711 for(size_t i = 0; i < trace_depth_; i++)
1712 buffer_ += " ";