Public Member Functions | Private Member Functions | Private Attributes

TAO_GIOP_Message_State Class Reference

Generic definitions for Message States. More...

#include <GIOP_Message_State.h>

Collaboration diagram for TAO_GIOP_Message_State:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_GIOP_Message_State (void)
 Ctor.
int parse_message_header (ACE_Message_Block &incoming)
CORBA::ULong message_size (void) const
 Return the message size.
CORBA::ULong payload_size (void) const
 Return the message size.
CORBA::Octet byte_order (void) const
 Return the byte order information.
GIOP::MsgType message_type (void) const
 Return the message type.
CORBA::Boolean more_fragments (void) const
 Return the more fragments.
void more_fragments (CORBA::Boolean fragment)
TAO_GIOP_Message_Version const & giop_version (void) const
 Get the GIOP version.
CORBA::Boolean compressed (void) const
 Return the compressed information.

Private Member Functions

int parse_message_header_i (ACE_Message_Block &incoming)
 Parse the message header.
int parse_magic_bytes (char *buf)
int get_version_info (char *buf)
int get_byte_order_info (char *buf)
void get_payload_size (char *buf)
 Gets the size of the payload and set the size in the <state>
CORBA::ULong read_ulong (const char *buf) const

Private Attributes

TAO_GIOP_Message_Version giop_version_
 GIOP version information..
CORBA::Octet byte_order_
 0 = big, 1 = little
GIOP::MsgType message_type_
 MsgType above.
CORBA::ULong payload_size_
 In byte_order!
CORBA::Boolean more_fragments_
CORBA::Boolean compressed_
 Compressed.

Detailed Description

Generic definitions for Message States.

This helps to establish the state of the incoming messages.

Definition at line 40 of file GIOP_Message_State.h.


Constructor & Destructor Documentation

TAO_GIOP_Message_State::TAO_GIOP_Message_State ( void   ) 

Ctor.

Definition at line 8 of file GIOP_Message_State.inl.


Member Function Documentation

CORBA::Octet TAO_GIOP_Message_State::byte_order ( void   )  const

Return the byte order information.

Definition at line 32 of file GIOP_Message_State.inl.

{
  return this->byte_order_;
}

CORBA::Boolean TAO_GIOP_Message_State::compressed ( void   )  const

Return the compressed information.

int TAO_GIOP_Message_State::get_byte_order_info ( char *  buf  )  [private]

Extracts the byte order information from the incoming stream. Performs a check for whether the byte order information right and sets the information in the <state>

Definition at line 147 of file GIOP_Message_State.cpp.

{
  if (TAO_debug_level > 8)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info\n") ));
    }

    // Let us be specific that this is for 1.0
  if (this->giop_version_.minor == 0 && this->giop_version_.major == 1)
    {
      this->byte_order_ =
        buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET];

      if (this->byte_order_ != 0 && this->byte_order_ != 1)
        {
          if (TAO_debug_level > 2)
            {
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info, ")
                          ACE_TEXT ("invalid byte order <%d> for version <1.0>\n"),
                          this->byte_order_));
            }
          return -1;
        }
    }
  else
    {
      // Read the byte ORDER
      this->byte_order_ =
        (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x01);

      // Read the fragment bit
      this->more_fragments_ =
        ((buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x02) == 2);

      this->compressed_ = (buf[0] == 0x5A);
    }

  return 0;
}

void TAO_GIOP_Message_State::get_payload_size ( char *  buf  )  [private]

Gets the size of the payload and set the size in the <state>

Definition at line 190 of file GIOP_Message_State.cpp.

{
  // Move the read pointer
  rd_ptr += TAO_GIOP_MESSAGE_SIZE_OFFSET;

  this->payload_size_ =  this->read_ulong (rd_ptr);
}

int TAO_GIOP_Message_State::get_version_info ( char *  buf  )  [private]

Extracts the version information from the incoming stream. Performs a check for whether the version information is right and sets the information in the <state>

Definition at line 112 of file GIOP_Message_State.cpp.

{
  if (TAO_debug_level > 8)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "TAO (%P|%t) - GIOP_Message_State::get_version_info\n"));
    }

  // We have a GIOP message on hand. Get its revision numbers
  CORBA::Octet incoming_major = buf[TAO_GIOP_VERSION_MAJOR_OFFSET];
  CORBA::Octet incoming_minor = buf[TAO_GIOP_VERSION_MINOR_OFFSET];

  // Check the revision information
  if (TAO_GIOP_Message_Generator_Parser_Impl::check_revision (
          incoming_major,
          incoming_minor) == 0)
    {
      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - bad version <%d.%d>\n"),
                      incoming_major, incoming_minor));
        }

      return -1;
    }

  // Set the version
  this->giop_version_.minor = incoming_minor;
  this->giop_version_.major = incoming_major;

  return 0;
}

TAO_GIOP_Message_Version const & TAO_GIOP_Message_State::giop_version ( void   )  const

Get the GIOP version.

Definition at line 56 of file GIOP_Message_State.inl.

{
  return this->giop_version_;
}

CORBA::ULong TAO_GIOP_Message_State::message_size ( void   )  const

Return the message size.

Definition at line 20 of file GIOP_Message_State.inl.

GIOP::MsgType TAO_GIOP_Message_State::message_type ( void   )  const

Return the message type.

Definition at line 38 of file GIOP_Message_State.inl.

{
  return this->message_type_;
}

CORBA::Boolean TAO_GIOP_Message_State::more_fragments ( void   )  const

Return the more fragments.

Definition at line 44 of file GIOP_Message_State.inl.

{
  return this->more_fragments_;
}

void TAO_GIOP_Message_State::more_fragments ( CORBA::Boolean  fragment  ) 

Definition at line 50 of file GIOP_Message_State.inl.

{
  this->more_fragments_ = fragment;
}

int TAO_GIOP_Message_State::parse_magic_bytes ( char *  buf  )  [private]

Checks for the magic word 'GIOP' in the start of the incoing stream

Definition at line 88 of file GIOP_Message_State.cpp.

{
  if (!((buf [0] == 0x5A || buf [0] == 0x47)     // 'Z' or 'G' (depending on compression)
        && buf [1] == 0x49   // 'I'
        && buf [2] == 0x4f   // 'O'
        && buf [3] == 0x50)) // 'P'
    {
      if (TAO_debug_level > 0)
        ACE_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("TAO (%P|%t) - ")
                    ACE_TEXT ("TAO_GIOP_Message_State::parse_magic_bytes, ")
                    ACE_TEXT ("bad %cIOP header: ")
                    ACE_TEXT ("magic word [%02x,%02x,%02x,%02x]\n"),
                    buf[0],
                    buf[0],
                    buf[1],
                    buf[2],
                    buf[3]));
      return -1;
    }
 return 0;
}

int TAO_GIOP_Message_State::parse_message_header ( ACE_Message_Block incoming  ) 

Parse the message header.

Returns:
-1 There was some error parsing the GIOP header
0 The GIOP header was parsed correctly
1 There was not enough data in the message block to parse the header

Definition at line 20 of file GIOP_Message_State.cpp.

{
  if (incoming.length () >= TAO_GIOP_MESSAGE_HEADER_LEN)
    {
      // Parse the GIOP header
      return this->parse_message_header_i (incoming);
    }

  // One indicates that we didn't have enough data in the message to
  // parse the header
  return 1;
}

int TAO_GIOP_Message_State::parse_message_header_i ( ACE_Message_Block incoming  )  [private]

Parse the message header.

Definition at line 34 of file GIOP_Message_State.cpp.

{
  if (TAO_debug_level > 8)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::parse_message_header_i\n")
                  ));
    }

  char * const buf = incoming.rd_ptr ();

  if (this->parse_magic_bytes (buf) == -1        // Parse magic bytes first
      || this->get_version_info (buf) == -1      // Get version information
      || this->get_byte_order_info (buf) == -1)  // Get byte order information
    {
      return -1;
    }

  // Get the message type
  this->message_type_ =
    static_cast <GIOP::MsgType> (buf[TAO_GIOP_MESSAGE_TYPE_OFFSET]);

  // Get the size of the message..
  this->get_payload_size (buf);

  if (this->payload_size_ == 0)
    {
      switch (this->message_type_)
        {
        case GIOP::MessageError:
        case GIOP::CloseConnection:
          if (TAO_debug_level > 0)
            {
              char const * const which =
                (this->message_type_ == GIOP::CloseConnection) ? "CloseConnection" :
                (this->message_type_ == GIOP::MessageError) ? "MessageError" : "unknown";
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("TAO (%P|%t) - GIOP %C received\n"), which));
            }
          return 0;
        default:
          if (TAO_debug_level > 0)
            ACE_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("TAO (%P|%t) - ")
                        ACE_TEXT ("TAO_GIOP_Message_State::parse_magic_bytes, ")
                        ACE_TEXT ("Message of size zero recd.\n")));
          return -1;
        }
    }

  return 0; // success
}

CORBA::ULong TAO_GIOP_Message_State::payload_size ( void   )  const

Return the message size.

Definition at line 26 of file GIOP_Message_State.inl.

{
  return this->payload_size_;
}

CORBA::ULong TAO_GIOP_Message_State::read_ulong ( const char *  buf  )  const [private]

Read the unsigned long from the buffer. The buf should just point to the next 4 bytes data that represent the ULong

Definition at line 199 of file GIOP_Message_State.cpp.

{
  CORBA::ULong x = 0;

  // We don't need to do this sort of copy. But some compilers (read it
  // as SunCC) have a problem in deferencing from the
  // reinterpret_cast pointer of the <rd_ptr>, as the <rd_ptr> can be
  // on stack. So let us go ahead with this copying...
  char buf[] =
    {
      *rd_ptr,
      *(rd_ptr + 1),
      *(rd_ptr + 2),
      *(rd_ptr + 3)
    };

#if !defined (ACE_DISABLE_SWAP_ON_READ)
  if (!(this->byte_order_ != ACE_CDR_BYTE_ORDER))
    {
      ACE_CDR::ULong* pul = reinterpret_cast<ACE_CDR::ULong*> (buf);
      x = *pul;
    }
  else
    {
      ACE_CDR::swap_4 (buf, reinterpret_cast<char*> (&x));
    }
#else
  x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
#endif /* ACE_DISABLE_SWAP_ON_READ */

  return x;
}


Member Data Documentation

0 = big, 1 = little

Definition at line 108 of file GIOP_Message_State.h.

Compressed.

Definition at line 123 of file GIOP_Message_State.h.

GIOP version information..

Definition at line 105 of file GIOP_Message_State.h.

GIOP::MsgType TAO_GIOP_Message_State::message_type_ [private]

MsgType above.

Definition at line 111 of file GIOP_Message_State.h.

(Requests and Replys) A value of zero indicates that this message does not have any fragments. A value of non-zero indicates that it does have fragments.

Definition at line 120 of file GIOP_Message_State.h.

In byte_order!

Definition at line 114 of file GIOP_Message_State.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines