summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>1999-12-16 20:16:37 +0000
committerbala <balanatarajan@users.noreply.github.com>1999-12-16 20:16:37 +0000
commitec083559f3adbd5b4d606a2e8629a84297ac1d30 (patch)
tree45a3e15af18de9a51ddadf2a55dba9e77cb2c707
parent6083b50feec188431514268c506bea4bd7054262 (diff)
downloadATCD-ec083559f3adbd5b4d606a2e8629a84297ac1d30.tar.gz
*** empty log message ***
-rw-r--r--TAO/tao/GIOP_Acceptors.cpp1
-rw-r--r--TAO/tao/GIOP_Acceptors.h36
-rw-r--r--TAO/tao/GIOP_Utils.cpp181
-rw-r--r--TAO/tao/GIOP_Utils.h205
-rw-r--r--TAO/tao/GIOP_Utils.i74
5 files changed, 497 insertions, 0 deletions
diff --git a/TAO/tao/GIOP_Acceptors.cpp b/TAO/tao/GIOP_Acceptors.cpp
new file mode 100644
index 00000000000..ca0908bbcf6
--- /dev/null
+++ b/TAO/tao/GIOP_Acceptors.cpp
@@ -0,0 +1 @@
+//$Id$
diff --git a/TAO/tao/GIOP_Acceptors.h b/TAO/tao/GIOP_Acceptors.h
new file mode 100644
index 00000000000..f281354b700
--- /dev/null
+++ b/TAO/tao/GIOP_Acceptors.h
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO
+//
+// = FILENAME
+// GIOP_Acceptors.h
+//
+// = DESCRIPTION
+// Concrete classes for the different versions of GIOP classes
+//
+// = AUTHOR
+// Balachandran Natarajan <bala@cs.wustl.edu>
+//
+// ============================================================================
+#ifndef _TAO_GIOP_ACCEPTORS_H_
+#define _TAO_GIOP_ACCEPTORS_H_
+#include "tao/GIOP_Accept_State.h"
+
+class TAO_Export TAO_GIOP_Acceptor_1_1:
+public TAO_GIOP_Accept_State
+{
+ // = TITLE
+ // Definitions of GIOP 1.1 specific stuff
+ //
+ // = DESCRIPTION
+ // This class will hold the specific details of 1.1
+ //
+ public:
+ private:
+};
+
+#endif /*_TAO_GIOP_ACCEPTORS_H_*/
diff --git a/TAO/tao/GIOP_Utils.cpp b/TAO/tao/GIOP_Utils.cpp
new file mode 100644
index 00000000000..ae0570b430c
--- /dev/null
+++ b/TAO/tao/GIOP_Utils.cpp
@@ -0,0 +1,181 @@
+//$Id$
+#include "tao/debug.h"
+#include "tao/GIOP_Utils.h"
+#include "tao/ORB_Core.h"
+
+
+#if !defined (__ACE_INLINE__)
+# include "tao/GIOP_Utils.i"
+#endif /* __ACE_INLINE__ */
+
+
+
+TAO_GIOP_Message_State::TAO_GIOP_Message_State (TAO_ORB_Core* orb_core)
+ : byte_order (TAO_ENCAP_BYTE_ORDER),
+ more_fragments (0),
+ message_type (TAO_GIOP_MESSAGERROR),
+ message_size (0),
+ current_offset (0),
+ cdr (orb_core->create_input_cdr_data_block (ACE_CDR::DEFAULT_BUFSIZE),
+ TAO_ENCAP_BYTE_ORDER,
+ orb_core),
+ fragments_begin (0),
+ fragments_end (0)
+{
+ //giop_version.major = TAO_DEF_GIOP_MAJOR;
+ //giop_version.minor = TAO_DEF_GIOP_MINOR;
+}
+
+int
+TAO_GIOP_Message_State::is_complete ()
+{
+ if (this->message_size != this->current_offset)
+ return 0;
+
+ if (this->more_fragments)
+ {
+ // This is only one fragment of the complete Request....
+ ACE_Message_Block* current =
+ this->cdr.steal_contents ();
+ if (this->fragments_begin == 0)
+ {
+ this->first_fragment_byte_order = this->byte_order;
+ this->first_fragment_giop_version = this->giop_version;
+ this->first_fragment_message_type = this->message_type;
+ this->fragments_end = this->fragments_begin = current;
+ this->reset ();
+ return 0;
+ }
+
+ return this->append_fragment (current);
+ }
+
+ if (this->fragments_begin != 0)
+ {
+ // This is the last message, but we must defragment before
+ // sending
+
+ ACE_Message_Block* current =
+ this->cdr.steal_contents ();
+ if (this->append_fragment (current) == -1)
+ return -1;
+
+ // Copy the entire chain into the input CDR.....
+ this->cdr.reset (this->fragments_begin,
+ this->first_fragment_byte_order);
+ ACE_Message_Block::release (this->fragments_begin);
+ this->fragments_begin = 0;
+ this->fragments_end = 0;
+
+ this->byte_order = this->first_fragment_byte_order;
+ this->giop_version = this->first_fragment_giop_version;
+ this->message_type = this->first_fragment_message_type;
+
+ /*FALLTHROUGH*/
+ }
+ // else
+ // {
+ // This message has no more fragments, and there where no fragments
+ // before it, just return... notice that this->cdr has the right
+ // contents.
+ // }
+
+ return 1;
+}
+
+int
+TAO_GIOP_Message_State::append_fragment (ACE_Message_Block* current)
+{
+ this->fragments_end->cont (current);
+ this->fragments_end = this->fragments_end->cont ();
+
+ if (this->first_fragment_byte_order != this->byte_order
+ || this->first_fragment_giop_version.major != this->giop_version.major
+ || this->first_fragment_giop_version.minor != this->giop_version.minor)
+ {
+ // Yes, print it out in all debug levels!
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) incompatible fragments:\n"
+ " Different GIOP versions or byte order\n"));
+ this->reset ();
+ return -1;
+ }
+ this->reset ();
+ return 0;
+}
+
+
+void
+TAO_GIOP_Utils::dump_msg (const char */*label*/,
+ const u_char */*ptr*/,
+ size_t /*len*/)
+{
+ if (TAO_debug_level >= 5)
+ {
+ // I will have to print out all the relevant debug messages!!
+ // Let me not wory about that now. I will get back to that at a
+ // later date!!
+ }
+}
+
+CORBA::Boolean
+TAO_GIOP_Utils::start_message (const TAO_GIOP_Version &version,
+ TAO_Pluggable_Message_Type t,
+ TAO_OutputCDR &msg)
+{
+ static CORBA::Octet magic[] =
+ {
+ // The following works on non-ASCII platforms, such as MVS (which
+ // uses EBCDIC).
+ 0x47, // 'G'
+ 0x49, // 'I'
+ 0x4f, // 'O'
+ 0x50, // 'P'
+ };
+
+ static int magic_size = sizeof (magic)/sizeof (magic[0]);
+ msg.write_octet_array (magic, magic_size);
+
+ msg.write_octet (version.major);
+ msg.write_octet (version.minor);
+ msg.write_octet (TAO_ENCAP_BYTE_ORDER);
+
+ CORBA::Octet type = 0;
+
+ // Conversion from the Pluggable Message types to the GIOP types.
+ switch (t)
+ {
+ case (TAO_MESSAGE_REQUEST):
+ type = TAO_GIOP_REQUEST;
+ break;
+ case (TAO_MESSAGE_REPLY):
+ type = TAO_GIOP_REPLY;
+ break;
+ case (TAO_MESSAGE_CANCELREQUEST):
+ type = TAO_GIOP_CANCELREQUEST;
+ break;
+ case (TAO_MESSAGE_LOCATEREQUEST):
+ type = TAO_GIOP_LOCATEREQUEST;
+ break;
+ case (TAO_MESSAGE_LOCATEREPLY):
+ type = TAO_GIOP_LOCATEREPLY;
+ break;
+ case (TAO_MESSAGE_CLOSECONNECTION):
+ type = TAO_GIOP_CLOSECONNECTION;
+ break;
+ case (TAO_MESSAGE_MESSAGERROR):
+ type = TAO_GIOP_MESSAGERROR;
+ break;
+ case (TAO_MESSAGE_FRAGMENT):
+ type = TAO_GIOP_FRAGMENT;
+ break;
+ }
+
+ msg.write_octet ((CORBA::Octet) type);
+
+ // Write a dummy <size> later it is set to the right value...
+ CORBA::ULong size = 0;
+ msg.write_ulong (size);
+
+ return 1;
+}
diff --git a/TAO/tao/GIOP_Utils.h b/TAO/tao/GIOP_Utils.h
new file mode 100644
index 00000000000..89b65dc0523
--- /dev/null
+++ b/TAO/tao/GIOP_Utils.h
@@ -0,0 +1,205 @@
+// -*- C++ -*-
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO
+//
+// = FILENAME
+// GIOP_Message.h
+//
+// = DESCRIPTION
+// Interface for the GIOP messaging protocol
+//
+// = AUTHOR
+// Balachandran Natarajan <bala@cs.wustl.edu>
+//
+// ============================================================================
+#ifndef _TAO_GIOP_UTILS_H_
+#define _TAO_GIOP_UTILS_H_
+#include "tao/Pluggable_Messaging.h"
+
+
+typedef enum GIOP_Messages
+{
+ // = DESCRIPTION
+ // All GIOP messages include a header and message type. Not
+ // really a message type, but needed to bring that information
+ // back somehow.
+
+ // = GIOP message types.
+ TAO_GIOP_REQUEST = 0, // sent by client.
+ TAO_GIOP_REPLY = 1, // by server.
+ TAO_GIOP_CANCELREQUEST = 2, // by client.
+ TAO_GIOP_LOCATEREQUEST = 3, // by client.
+ TAO_GIOP_LOCATEREPLY = 4,
+ TAO_GIOP_CLOSECONNECTION = 5,
+ TAO_GIOP_MESSAGERROR = 6, // by both.
+ TAO_GIOP_FRAGMENT = 7 // by both.
+}TAO_GIOP_Message_Type;
+
+
+
+class TAO_Export TAO_GIOP_Version
+{
+ // = TITLE
+ // Major and Minor version number of the Inter-ORB Protocol.
+public:
+ CORBA::Octet major;
+ // Major version number
+
+ CORBA::Octet minor;
+ // Minor version number
+
+ TAO_GIOP_Version (const TAO_GIOP_Version &src);
+ // Copy constructor
+
+ TAO_GIOP_Version (CORBA::Octet maj = TAO_DEF_GIOP_MAJOR,
+ CORBA::Octet min = TAO_DEF_GIOP_MINOR);
+ // Default constructor.
+
+ ~TAO_GIOP_Version (void);
+ // Destructor.
+
+ void set_version (CORBA::Octet maj, CORBA::Octet min);
+ // Explicitly set the major and minor version.
+
+ TAO_GIOP_Version &operator= (const TAO_GIOP_Version &src);
+ // Copy operator.
+
+ int operator== (const TAO_GIOP_Version &src);
+ int operator!= (const TAO_GIOP_Version &src);
+ // Equality operator
+};
+
+
+class TAO_Export TAO_GIOP_Message_State: public TAO_Message_State_Factory
+{
+ // = TITLE
+ // Generic definitions for Message States.
+ //
+ // = DESCRIPTION
+ // This would represnt the state of the incoming message states.
+ // As the ORB processes incoming messages it need to keep track of
+ // how much of the message has been read. if there are any
+ // fragments following this message etc. This class attempts to
+ // give a generic interface to all the messaging protocols message
+ // states so that the Transport layer does not really know with
+ // whom it is interacting with.
+public:
+ TAO_GIOP_Message_State (TAO_ORB_Core *orb_core);
+ // Ctor
+
+ ~TAO_GIOP_Message_State (void);
+ // Dtor
+
+ void reset (int reset_contents = 1);
+ //Reset the message header state and prepare it to receive the next
+ // event.
+
+ CORBA::Boolean header_received (void) const;
+ // Has the header been received?
+
+ int is_complete (void);
+ // Check if the current message is complete, adjusting the fragments
+ // if required...
+
+ TAO_GIOP_Version giop_version;
+ // Version info
+
+ CORBA::Octet byte_order;
+ // 0 = big, 1 = little
+
+ CORBA::Octet more_fragments;
+ // (Requests and Replys)
+
+ CORBA::Octet message_type;
+ // MsgType above
+
+ CORBA::ULong message_size;
+ // in byte_order!
+
+ CORBA::ULong current_offset;
+ // How much of the payload has been received
+
+ TAO_InputCDR cdr;
+ // This is the InputCDR that will be used to decode the message.
+
+ ACE_Message_Block* fragments_begin;
+ ACE_Message_Block* fragments_end;
+ // The fragments are collected in a chain of message blocks (using
+ // the cont() field). When the complete message is received the
+ // chain is reassembled into <cdr>
+
+ CORBA::Octet first_fragment_byte_order;
+ // The byte order for the the first fragment
+ // @@ The current implementation cannot handle fragments with
+ // different byte orders, this should not be a major problem
+ // because:
+ // 1) It is unlikely that we are going to receive fragments.
+ // 2) The spec *seems* to allow different byte_orders, but it is
+ // unlikely that any ORB will do that.
+ // 3) Even if we allowed that at this layer the CDR classes are
+ // not prepared to handle that.
+
+ TAO_GIOP_Version first_fragment_giop_version;
+ // The GIOP version for the first fragment
+ // @@ Same as above, all GIOP versions must match.
+
+ CORBA::Octet first_fragment_message_type;
+ // If the messages are chained this represents the message type for
+ // the *complete* message (remember that the last message will be
+ // fragment and the upper level needs to know if it is a request,
+ // locate request or what).
+
+private:
+ int append_fragment (ACE_Message_Block* current);
+ // Append <current> to the list of fragments
+ // Also resets the state, because the current message was consumed.
+
+};
+
+
+
+class TAO_Export TAO_GIOP_Utils
+{
+ // = TITLE
+ // Some utility methods for GIOP independent of versions of GIOP
+ //
+ // = DESCRIPTION
+ // Utility methods that would be used by both the Client and
+ // Server side methods in GIOP factory
+
+public:
+
+ static void dump_msg (const char *label,
+ const u_char *ptr,
+ size_t len);
+ // Print out a debug messages..
+
+ static CORBA::Boolean start_message (const TAO_GIOP_Version &version,
+ TAO_Pluggable_Message_Type t,
+ TAO_OutputCDR &msg);
+
+ // Build the header for a message of type <t> into stream <msg>.
+
+
+};
+
+// Some constant definitions that would not change for sometime. I
+// think. So we can have them here till they change
+const size_t TAO_GIOP_HEADER_LEN = 12;
+const size_t TAO_GIOP_LITE_HEADER_LEN = 5;
+
+const size_t TAO_GIOP_VERSION_MINOR_OFFSET = 5;
+const size_t TAO_GIOP_VERSION_MAJOR_OFFSET = 4;
+const size_t TAO_GIOP_MESSAGE_FLAGS_OFFSET = 6;
+const size_t TAO_GIOP_MESSAGE_TYPE_OFFSET = 7;
+const size_t TAO_GIOP_MESSAGE_SIZE_OFFSET = 8;
+
+#if defined (__ACE_INLINE__)
+# include "tao/GIOP_Utils.i"
+#endif /* __ACE_INLINE__ */
+
+#endif /*_TAO_GIOP_UTILS_H_ */
diff --git a/TAO/tao/GIOP_Utils.i b/TAO/tao/GIOP_Utils.i
new file mode 100644
index 00000000000..300ef553422
--- /dev/null
+++ b/TAO/tao/GIOP_Utils.i
@@ -0,0 +1,74 @@
+//$Id$
+//
+// Inlined methods for TAO_GIOP_Version
+//
+
+ACE_INLINE
+TAO_GIOP_Version::TAO_GIOP_Version (const TAO_GIOP_Version &src)
+ : major (src.major),
+ minor (src.minor)
+{
+}
+
+ACE_INLINE
+TAO_GIOP_Version::TAO_GIOP_Version (CORBA::Octet maj, CORBA::Octet min)
+ : major (maj),
+ minor (min)
+{
+}
+
+ACE_INLINE
+TAO_GIOP_Version::~TAO_GIOP_Version (void)
+{
+}
+
+ACE_INLINE TAO_GIOP_Version &
+TAO_GIOP_Version::operator= (const TAO_GIOP_Version &src)
+{
+ if (this == &src)
+ return *this;
+
+ this->major = src.major;
+ this->minor = src.minor;
+ return *this;
+}
+
+
+ACE_INLINE void
+TAO_GIOP_Version::set_version (CORBA::Octet maj, CORBA::Octet min)
+{
+ this->major = maj;
+ this->minor = min;
+}
+
+ACE_INLINE int
+TAO_GIOP_Version::operator== (const TAO_GIOP_Version &src)
+{
+ return this->major == src.major && this->minor == src.minor;
+}
+
+ACE_INLINE int
+TAO_GIOP_Version::operator!= (const TAO_GIOP_Version &src)
+{
+ return !(*this == src);
+}
+
+//
+// Inlined methods for TAO_GIOP_Message_State
+//
+
+ACE_INLINE void
+TAO_GIOP_Message_State::reset (int reset_contents)
+{
+ this->message_size = 0;
+ this->current_offset = 0;
+ this->more_fragments = 0;
+ if (reset_contents)
+ this->cdr.reset_contents ();
+}
+
+ACE_INLINE CORBA::Boolean
+TAO_GIOP_Message_State::header_received (void) const
+{
+ return this->message_size != 0;
+}