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.

void reset (void)
 Reset the state..


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 .

CORBA::ULong read_ulong (const char *buf) const

Private Attributes

TAO_GIOP_Message_Version giop_version_
CORBA::Octet byte_order_
 0 = big, 1 = little

CORBA::Octet message_type_
 MsgType above.

CORBA::ULong message_size_
 in byte_order!

CORBA::Octet more_fragments_
CORBA::ULong missing_data_
 Missing data.


Friends

class TAO_GIOP_Message_Base

Detailed Description

Generic definitions for Message States.

This helps to establish the state of the incoming messages.

Definition at line 43 of file GIOP_Message_State.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_GIOP_Message_State::TAO_GIOP_Message_State void   ) 
 

Ctor.

Definition at line 19 of file GIOP_Message_State.cpp.

References TAO_DEF_GIOP_MAJOR, and TAO_DEF_GIOP_MINOR.

00020   : giop_version_ (TAO_DEF_GIOP_MAJOR,
00021                    TAO_DEF_GIOP_MINOR),
00022     byte_order_ (0),
00023     message_type_ (0),
00024     message_size_ (0),
00025     more_fragments_ (0),
00026     missing_data_ (0)
00027 {
00028 }


Member Function Documentation

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

Return the byte order information.

Definition at line 23 of file GIOP_Message_State.inl.

00024 {
00025   return this->byte_order_;
00026 }

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

Definition at line 169 of file GIOP_Message_State.cpp.

References ACE_DEBUG, ACE_TEXT, giop_version_, LM_DEBUG, TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, and TAO_debug_level.

Referenced by parse_message_header_i().

00170 {
00171   if (TAO_debug_level > 8)
00172     {
00173       ACE_DEBUG ((LM_DEBUG,
00174                   ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info\n") ));
00175     }
00176 
00177     // Let us be specific that this is for 1.0
00178   if (this->giop_version_.minor == 0 &&
00179       this->giop_version_.major == 1)
00180     {
00181       this->byte_order_ =
00182         buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET];
00183 
00184       if (this->byte_order_ != 0 &&
00185           this->byte_order_ != 1)
00186         {
00187           if (TAO_debug_level > 2)
00188             {
00189               ACE_DEBUG ((LM_DEBUG,
00190                           ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info, ")
00191                           ACE_TEXT ("invalid byte order <%d> for version <1.0>\n"),
00192                           this->byte_order_));
00193             }
00194           return -1;
00195         }
00196     }
00197   else
00198     {
00199       // Read the byte ORDER
00200       this->byte_order_ =
00201         (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x01);
00202 
00203       // Read the fragment bit
00204       this->more_fragments_ =
00205         (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x02);
00206 
00207       if ((buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET] & ~0x3) != 0)
00208         {
00209           if (TAO_debug_level > 2)
00210             {
00211               ACE_DEBUG ((LM_DEBUG,
00212                           ACE_TEXT ("TAO (%P|%t) - invalid flags for <%d> ")
00213                           ACE_TEXT ("for version <%d %d> \n"),
00214                           buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET],
00215                           this->giop_version_.major,
00216                           this->giop_version_.minor));
00217             }
00218           return -1;
00219         }
00220     }
00221 
00222   return 0;
00223 }

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

Gets the size of the payload and set the size in the .

Definition at line 226 of file GIOP_Message_State.cpp.

References read_ulong().

Referenced by parse_message_header_i().

00227 {
00228   // Move the read pointer
00229   rd_ptr += TAO_GIOP_MESSAGE_SIZE_OFFSET;
00230 
00231   this->message_size_ =  this->read_ulong (rd_ptr);
00232 }

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

Definition at line 132 of file GIOP_Message_State.cpp.

References ACE_DEBUG, ACE_TEXT, TAO_GIOP_Message_Generator_Parser_Impl::check_revision(), giop_version_, LM_DEBUG, TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, and TAO_debug_level.

Referenced by parse_message_header_i().

00133 {
00134   if (TAO_debug_level > 8)
00135     {
00136       ACE_DEBUG ((LM_DEBUG,
00137                   "TAO (%P|%t) - GIOP_Message_State::get_version_info\n"));
00138     }
00139 
00140   // We have a GIOP message on hand. Get its revision numbers
00141   CORBA::Octet incoming_major =
00142     buf[TAO_GIOP_VERSION_MAJOR_OFFSET];
00143   CORBA::Octet incoming_minor =
00144     buf[TAO_GIOP_VERSION_MINOR_OFFSET];
00145 
00146   // Check the revision information
00147   if (TAO_GIOP_Message_Generator_Parser_Impl::check_revision (
00148           incoming_major,
00149           incoming_minor) == 0)
00150     {
00151       if (TAO_debug_level > 0)
00152         {
00153           ACE_DEBUG ((LM_DEBUG,
00154                       ACE_TEXT ("TAO (%P|%t) - bad version <%d.%d>\n"),
00155                       incoming_major, incoming_minor));
00156         }
00157 
00158       return -1;
00159     }
00160 
00161   // Set the version
00162   this->giop_version_.minor = incoming_minor;
00163   this->giop_version_.major = incoming_major;
00164 
00165   return 0;
00166 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE CORBA::ULong TAO_GIOP_Message_State::message_size void   )  const
 

Return the message size.

Definition at line 8 of file GIOP_Message_State.inl.

Referenced by TAO_GIOP_Message_Base::consolidate_node(), TAO_GIOP_Message_Base::extract_next_message(), and TAO_GIOP_Message_Base::parse_next_message().

00009 {
00010   CORBA::ULong len =
00011     this->message_size_ + TAO_GIOP_MESSAGE_HEADER_LEN;
00012 
00013   return len; 
00014 }

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 107 of file GIOP_Message_State.cpp.

References ACE_DEBUG, ACE_TEXT, LM_DEBUG, and TAO_debug_level.

Referenced by parse_message_header_i().

00108 {
00109   // The values are hard-coded to support non-ASCII platforms.
00110   if (!(buf [0] == 0x47      // 'G'
00111         && buf [1] == 0x49   // 'I'
00112         && buf [2] == 0x4f   // 'O'
00113         && buf [3] == 0x50)) // 'P'
00114     {
00115       if (TAO_debug_level > 0)
00116         ACE_DEBUG ((LM_DEBUG,
00117                     ACE_TEXT ("TAO (%P|%t) - ")
00118                     ACE_TEXT ("TAO_GIOP_Message_State::parse_magic_bytes, ")
00119                     ACE_TEXT ("bad header: ")
00120                     ACE_TEXT ("magic word [%02x,%02x,%02x,%02x]\n"),
00121                     buf[0],
00122                     buf[1],
00123                     buf[2],
00124                     buf[3]));
00125       return -1;
00126     }
00127 
00128  return 0;
00129 }

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 32 of file GIOP_Message_State.cpp.

References ACE_Message_Block::length(), and parse_message_header_i().

Referenced by TAO_GIOP_Message_Base::consolidate_node(), TAO_GIOP_Message_Base::extract_next_message(), TAO_GIOP_Message_Base::parse_incoming_messages(), and TAO_GIOP_Message_Base::parse_next_message().

00033 {
00034   if (incoming.length () >= TAO_GIOP_MESSAGE_HEADER_LEN)
00035     {
00036       // Parse the GIOP header
00037       return this->parse_message_header_i (incoming);
00038     }
00039 
00040   // One indicates that we didn't have enough data in the message to
00041   // parse the header
00042   return 1;
00043 }

int TAO_GIOP_Message_State::parse_message_header_i ACE_Message_Block incoming  )  [private]
 

Parse the message header.

Definition at line 46 of file GIOP_Message_State.cpp.

References ACE_DEBUG, get_byte_order_info(), get_payload_size(), get_version_info(), LM_DEBUG, parse_magic_bytes(), ACE_Message_Block::rd_ptr(), TAO_debug_level, and TAO_GIOP_MESSAGERROR.

Referenced by parse_message_header().

00047 {
00048   if (TAO_debug_level > 8)
00049     {
00050       ACE_DEBUG ((LM_DEBUG,
00051                   "TAO (%P|%t) - GIOP_Message_State::parse_message_header_i\n"
00052                   ));
00053     }
00054 
00055   // Grab the rd_ptr_ from the message block..
00056   char *buf = incoming.rd_ptr ();
00057 
00058   // Parse the magic bytes first
00059   if (this->parse_magic_bytes (buf) == -1)
00060     {
00061       return -1;
00062     }
00063 
00064   // Get the version information
00065   if (this->get_version_info (buf) == -1)
00066     return -1;
00067 
00068   // Get the byte order information...
00069   if (this->get_byte_order_info (buf) == -1)
00070     return -1;
00071 
00072   // Get the message type
00073   this->message_type_ = buf[TAO_GIOP_MESSAGE_TYPE_OFFSET];
00074 
00075   // Get the size of the message..
00076   this->get_payload_size (buf);
00077 
00078   if (this->message_size_ == 0)
00079     {
00080       if (this->message_type_ == TAO_GIOP_MESSAGERROR)
00081         {
00082           if (TAO_debug_level > 0)
00083             {
00084               ACE_DEBUG ((LM_DEBUG,
00085                           "TAO (%P|%t) -"
00086                           "GIOP_MESSAGE_ERROR received \n"));
00087             }
00088           return 0;
00089         }
00090       else
00091         {
00092           if (TAO_debug_level > 0)
00093             ACE_DEBUG ((LM_DEBUG,
00094                         "TAO (%P|%t) - "
00095                         "Message of  size zero recd. \n"));
00096           return -1;
00097         }
00098     }
00099 
00100   return 0; // success
00101 }

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

Return the message size.

Definition at line 17 of file GIOP_Message_State.inl.

Referenced by TAO_GIOP_Message_Base::consolidate_node(), and TAO_GIOP_Message_Base::parse_next_message().

00018 {
00019   return this->message_size_;
00020 }

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

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

Definition at line 235 of file GIOP_Message_State.cpp.

References ACE_CDR_BYTE_ORDER, and ACE_CDR::swap_4().

Referenced by get_payload_size().

00236 {
00237   CORBA::ULong x = 0;
00238 
00239   // We don't need to do this sort of copy. But some compilers (read it
00240   // as SunCC) have a problem in deferencing from the
00241   // reinterpret_cast pointer of the <rd_ptr>, as the <rd_ptr> can be
00242   // on stack. So let us go ahead with this copying...
00243   char buf[] =
00244     {
00245       *rd_ptr,
00246       *(rd_ptr + 1),
00247       *(rd_ptr + 2),
00248       *(rd_ptr + 3)
00249     };
00250 
00251 #if !defined (ACE_DISABLE_SWAP_ON_READ)
00252   if (!(this->byte_order_ != ACE_CDR_BYTE_ORDER))
00253     {
00254       x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
00255     }
00256   else
00257     {
00258       ACE_CDR::swap_4 (buf, reinterpret_cast<char*> (&x));
00259     }
00260 #else
00261   x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
00262 #endif /* ACE_DISABLE_SWAP_ON_READ */
00263 
00264   return x;
00265 }

ACE_INLINE void TAO_GIOP_Message_State::reset void   ) 
 

Reset the state..

Definition at line 29 of file GIOP_Message_State.inl.

References missing_data_.

Referenced by TAO_GIOP_Message_Base::parse_incoming_messages().

00030 {
00031   this->message_type_ = 0;
00032   this->message_size_ = 0;
00033   this->more_fragments_ = 0;
00034   this->missing_data_ = 0;
00035 }


Friends And Related Function Documentation

friend class TAO_GIOP_Message_Base [friend]
 

Definition at line 72 of file GIOP_Message_State.h.


Member Data Documentation

CORBA::Octet TAO_GIOP_Message_State::byte_order_ [private]
 

0 = big, 1 = little

Definition at line 103 of file GIOP_Message_State.h.

Referenced by TAO_GIOP_Message_Base::init_queued_data().

TAO_GIOP_Message_Version TAO_GIOP_Message_State::giop_version_ [private]
 

Definition at line 100 of file GIOP_Message_State.h.

Referenced by get_byte_order_info(), get_version_info(), and TAO_GIOP_Message_Base::init_queued_data().

CORBA::ULong TAO_GIOP_Message_State::message_size_ [private]
 

in byte_order!

Definition at line 109 of file GIOP_Message_State.h.

CORBA::Octet TAO_GIOP_Message_State::message_type_ [private]
 

MsgType above.

Definition at line 106 of file GIOP_Message_State.h.

Referenced by TAO_GIOP_Message_Base::message_type().

CORBA::ULong TAO_GIOP_Message_State::missing_data_ [private]
 

Missing data.

Definition at line 118 of file GIOP_Message_State.h.

Referenced by reset().

CORBA::Octet TAO_GIOP_Message_State::more_fragments_ [private]
 

(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 115 of file GIOP_Message_State.h.

Referenced by TAO_GIOP_Message_Base::init_queued_data().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:14:17 2006 for TAO by doxygen 1.3.6