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.

TAO_Pluggable_Message_Type message_type (void) const
 Return the message type.

CORBA::Octet more_fragments (void) const
 Return the more fragments.

void more_fragments (CORBA::Octet fragment)
TAO_GIOP_Message_Version const & giop_version (void) const
 Get the GIOP version.


Private Member Functions

int parse_message_header_i (ACE_Message_Block &incoming)
 Parse the message header.

TAO_Pluggable_Message_Type message_type (CORBA::Octet type) const
 Get the message type.

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

TAO_Pluggable_Message_Type message_type_
 MsgType above.

CORBA::ULong payload_size_
 In byte_order!

CORBA::Octet more_fragments_

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_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_GIOP_Message_State::TAO_GIOP_Message_State void   ) 
 

Ctor.

Definition at line 8 of file GIOP_Message_State.inl.

References TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, and TAO_PLUGGABLE_MESSAGE_REQUEST.

00009   : giop_version_ (TAO_DEF_GIOP_MAJOR,
00010                    TAO_DEF_GIOP_MINOR),
00011     byte_order_ (0),
00012     message_type_ (TAO_PLUGGABLE_MESSAGE_REQUEST),
00013     payload_size_ (0),
00014     more_fragments_ (0)
00015 {
00016 }


Member Function Documentation

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

Return the byte order information.

Definition at line 31 of file GIOP_Message_State.inl.

References byte_order_.

Referenced by TAO_Queued_Data::byte_order().

00032 {
00033   return this->byte_order_;
00034 }

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

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

Referenced by parse_message_header_i().

00198 {
00199   if (TAO_debug_level > 8)
00200     {
00201       ACE_DEBUG ((LM_DEBUG,
00202                   ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info\n") ));
00203     }
00204 
00205     // Let us be specific that this is for 1.0
00206   if (this->giop_version_.minor == 0 &&
00207       this->giop_version_.major == 1)
00208     {
00209       this->byte_order_ =
00210         buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET];
00211 
00212       if (this->byte_order_ != 0 &&
00213           this->byte_order_ != 1)
00214         {
00215           if (TAO_debug_level > 2)
00216             {
00217               ACE_DEBUG ((LM_DEBUG,
00218                           ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info, ")
00219                           ACE_TEXT ("invalid byte order <%d> for version <1.0>\n"),
00220                           this->byte_order_));
00221             }
00222           return -1;
00223         }
00224     }
00225   else
00226     {
00227       // Read the byte ORDER
00228       this->byte_order_ =
00229         (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x01);
00230 
00231       // Read the fragment bit
00232       this->more_fragments_ =
00233         (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x02);
00234 
00235       if ((buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET] & ~0x3) != 0)
00236         {
00237           if (TAO_debug_level > 2)
00238             {
00239               ACE_DEBUG ((LM_DEBUG,
00240                           ACE_TEXT ("TAO (%P|%t) - invalid flags for <%d> ")
00241                           ACE_TEXT ("for version <%d %d> \n"),
00242                           buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET],
00243                           this->giop_version_.major,
00244                           this->giop_version_.minor));
00245             }
00246           return -1;
00247         }
00248     }
00249 
00250   return 0;
00251 }

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

References payload_size_, and read_ulong().

Referenced by parse_message_header_i().

00255 {
00256   // Move the read pointer
00257   rd_ptr += TAO_GIOP_MESSAGE_SIZE_OFFSET;
00258 
00259   this->payload_size_ =  this->read_ulong (rd_ptr);
00260 }

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 162 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().

00163 {
00164   if (TAO_debug_level > 8)
00165     {
00166       ACE_DEBUG ((LM_DEBUG,
00167                   "TAO (%P|%t) - GIOP_Message_State::get_version_info\n"));
00168     }
00169 
00170   // We have a GIOP message on hand. Get its revision numbers
00171   CORBA::Octet incoming_major = buf[TAO_GIOP_VERSION_MAJOR_OFFSET];
00172   CORBA::Octet incoming_minor = buf[TAO_GIOP_VERSION_MINOR_OFFSET];
00173 
00174   // Check the revision information
00175   if (TAO_GIOP_Message_Generator_Parser_Impl::check_revision (
00176           incoming_major,
00177           incoming_minor) == 0)
00178     {
00179       if (TAO_debug_level > 0)
00180         {
00181           ACE_DEBUG ((LM_DEBUG,
00182                       ACE_TEXT ("TAO (%P|%t) - bad version <%d.%d>\n"),
00183                       incoming_major, incoming_minor));
00184         }
00185 
00186       return -1;
00187     }
00188 
00189   // Set the version
00190   this->giop_version_.minor = incoming_minor;
00191   this->giop_version_.major = incoming_major;
00192 
00193   return 0;
00194 }

ACE_INLINE TAO_GIOP_Message_Version const & TAO_GIOP_Message_State::giop_version void   )  const
 

Get the GIOP version.

Definition at line 55 of file GIOP_Message_State.inl.

References giop_version_.

Referenced by TAO_Queued_Data::giop_version().

00056 {
00057   return this->giop_version_;
00058 }

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

Return the message size.

Definition at line 19 of file GIOP_Message_State.inl.

References payload_size_.

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

00020 {
00021   return this->payload_size_ + TAO_GIOP_MESSAGE_HEADER_LEN;
00022 }

TAO_Pluggable_Message_Type TAO_GIOP_Message_State::message_type CORBA::Octet  type  )  const [private]
 

Get the message type.

Definition at line 95 of file GIOP_Message_State.cpp.

References ACE_ERROR, ACE_TEXT, LM_ERROR, TAO_debug_level, TAO_GIOP_CANCELREQUEST, TAO_GIOP_CLOSECONNECTION, TAO_GIOP_FRAGMENT, TAO_GIOP_LOCATEREPLY, TAO_GIOP_LOCATEREQUEST, TAO_GIOP_MESSAGERROR, TAO_GIOP_REPLY, TAO_GIOP_REQUEST, TAO_PLUGGABLE_MESSAGE_CANCELREQUEST, TAO_PLUGGABLE_MESSAGE_CLOSECONNECTION, TAO_PLUGGABLE_MESSAGE_FRAGMENT, TAO_PLUGGABLE_MESSAGE_LOCATEREPLY, TAO_PLUGGABLE_MESSAGE_LOCATEREQUEST, TAO_PLUGGABLE_MESSAGE_MESSAGERROR, TAO_PLUGGABLE_MESSAGE_REPLY, and TAO_PLUGGABLE_MESSAGE_REQUEST.

00096 {
00097   // Convert to the right type of Pluggable Messaging message type.
00098 
00099   switch (type)
00100     {
00101     case TAO_GIOP_REQUEST:
00102       return TAO_PLUGGABLE_MESSAGE_REQUEST;
00103     case TAO_GIOP_LOCATEREQUEST:
00104       return TAO_PLUGGABLE_MESSAGE_LOCATEREQUEST;
00105 
00106     case TAO_GIOP_LOCATEREPLY:
00107       return TAO_PLUGGABLE_MESSAGE_LOCATEREPLY;
00108 
00109     case TAO_GIOP_REPLY:
00110       return TAO_PLUGGABLE_MESSAGE_REPLY;
00111 
00112     case TAO_GIOP_CLOSECONNECTION:
00113       return TAO_PLUGGABLE_MESSAGE_CLOSECONNECTION;
00114 
00115     case TAO_GIOP_FRAGMENT:
00116       return TAO_PLUGGABLE_MESSAGE_FRAGMENT;
00117 
00118     case TAO_GIOP_MESSAGERROR:
00119       return TAO_PLUGGABLE_MESSAGE_MESSAGERROR;
00120 
00121     case TAO_GIOP_CANCELREQUEST:
00122       return TAO_PLUGGABLE_MESSAGE_CANCELREQUEST;
00123 
00124     default:
00125         if (TAO_debug_level > 0)
00126           {
00127             ACE_ERROR ((LM_ERROR,
00128                     ACE_TEXT ("TAO (%P|%t) %N:%l        message_type : ")
00129                     ACE_TEXT ("wrong message.\n")));
00130            }
00131     }
00132 
00133   return TAO_PLUGGABLE_MESSAGE_MESSAGERROR;
00134 }

ACE_INLINE TAO_Pluggable_Message_Type TAO_GIOP_Message_State::message_type void   )  const
 

Return the message type.

Definition at line 37 of file GIOP_Message_State.inl.

References message_type_.

Referenced by TAO_Queued_Data::msg_type(), and parse_message_header_i().

00038 {
00039   return this->message_type_;
00040 }

ACE_INLINE void TAO_GIOP_Message_State::more_fragments CORBA::Octet  fragment  ) 
 

Definition at line 49 of file GIOP_Message_State.inl.

00050 {
00051   this->more_fragments_ = fragment;
00052 }

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

Return the more fragments.

Definition at line 43 of file GIOP_Message_State.inl.

Referenced by TAO_Queued_Data::consolidate(), and TAO_Queued_Data::more_fragments().

00044 {
00045   return this->more_fragments_;
00046 }

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

References ACE_DEBUG, ACE_TEXT, LM_DEBUG, and TAO_debug_level.

Referenced by parse_message_header_i().

00138 {
00139   // The values are hard-coded to support non-ASCII platforms.
00140   if (!(buf [0] == 0x47      // 'G'
00141         && buf [1] == 0x49   // 'I'
00142         && buf [2] == 0x4f   // 'O'
00143         && buf [3] == 0x50)) // 'P'
00144     {
00145       if (TAO_debug_level > 0)
00146         ACE_DEBUG ((LM_DEBUG,
00147                     ACE_TEXT ("TAO (%P|%t) - ")
00148                     ACE_TEXT ("TAO_GIOP_Message_State::parse_magic_bytes, ")
00149                     ACE_TEXT ("bad header: ")
00150                     ACE_TEXT ("magic word [%02x,%02x,%02x,%02x]\n"),
00151                     buf[0],
00152                     buf[1],
00153                     buf[2],
00154                     buf[3]));
00155       return -1;
00156     }
00157 
00158  return 0;
00159 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL 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.

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(), and TAO_GIOP_Message_Base::parse_next_message().

00021 {
00022   if (incoming.length () >= TAO_GIOP_MESSAGE_HEADER_LEN)
00023     {
00024       // Parse the GIOP header
00025       return this->parse_message_header_i (incoming);
00026     }
00027 
00028   // One indicates that we didn't have enough data in the message to
00029   // parse the header
00030   return 1;
00031 }

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.

References ACE_DEBUG, ACE_TEXT, get_byte_order_info(), get_payload_size(), get_version_info(), LM_DEBUG, message_type(), message_type_, parse_magic_bytes(), payload_size_, ACE_Message_Block::rd_ptr(), TAO_debug_level, TAO_PLUGGABLE_MESSAGE_CLOSECONNECTION, and TAO_PLUGGABLE_MESSAGE_MESSAGERROR.

Referenced by parse_message_header().

00035 {
00036   if (TAO_debug_level > 8)
00037     {
00038       ACE_DEBUG ((LM_DEBUG,
00039                   ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::parse_message_header_i\n")
00040                   ));
00041     }
00042 
00043   // Grab the rd_ptr_ from the message block..
00044   char *buf = incoming.rd_ptr ();
00045 
00046   // Parse the magic bytes first
00047   if (this->parse_magic_bytes (buf) == -1)
00048     {
00049       return -1;
00050     }
00051 
00052   // Get the version information
00053   if (this->get_version_info (buf) == -1)
00054     return -1;
00055 
00056   // Get the byte order information...
00057   if (this->get_byte_order_info (buf) == -1)
00058     return -1;
00059 
00060   // Get the message type
00061   this->message_type_ = this->message_type (buf[TAO_GIOP_MESSAGE_TYPE_OFFSET]);
00062 
00063   // Get the size of the message..
00064   this->get_payload_size (buf);
00065 
00066   if (this->payload_size_ == 0)
00067     {
00068       switch (this->message_type_)
00069         {
00070         case TAO_PLUGGABLE_MESSAGE_MESSAGERROR:
00071         case TAO_PLUGGABLE_MESSAGE_CLOSECONNECTION:
00072           if (TAO_debug_level > 0)
00073             {
00074               const char* which =
00075                 (this->message_type_ == TAO_PLUGGABLE_MESSAGE_CLOSECONNECTION) ? "CloseConnection" :
00076                 (this->message_type_ == TAO_PLUGGABLE_MESSAGE_MESSAGERROR) ? "MessageError" : "unknown";
00077               ACE_DEBUG ((LM_DEBUG,
00078                           ACE_TEXT ("TAO (%P|%t) - GIOP %s received \n"), which));
00079             }
00080           return 0;
00081         default:
00082           if (TAO_debug_level > 0)
00083             ACE_DEBUG ((LM_DEBUG,
00084                         ACE_TEXT ("TAO (%P|%t) - ")
00085                         ACE_TEXT ("TAO_GIOP_Message_State::parse_magic_bytes, ")
00086                         ACE_TEXT ("Message of size zero recd. \n")));
00087           return -1;
00088         }
00089     }
00090 
00091   return 0; // success
00092 }

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

Return the message size.

Definition at line 25 of file GIOP_Message_State.inl.

References payload_size_.

Referenced by TAO_GIOP_Message_Base::consolidate_node().

00026 {
00027   return this->payload_size_;
00028 }

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

References ACE_CDR_BYTE_ORDER, byte_order_, and ACE_CDR::swap_4().

Referenced by get_payload_size().

00264 {
00265   CORBA::ULong x = 0;
00266 
00267   // We don't need to do this sort of copy. But some compilers (read it
00268   // as SunCC) have a problem in deferencing from the
00269   // reinterpret_cast pointer of the <rd_ptr>, as the <rd_ptr> can be
00270   // on stack. So let us go ahead with this copying...
00271   char buf[] =
00272     {
00273       *rd_ptr,
00274       *(rd_ptr + 1),
00275       *(rd_ptr + 2),
00276       *(rd_ptr + 3)
00277     };
00278 
00279 #if !defined (ACE_DISABLE_SWAP_ON_READ)
00280   if (!(this->byte_order_ != ACE_CDR_BYTE_ORDER))
00281     {
00282       x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
00283     }
00284   else
00285     {
00286       ACE_CDR::swap_4 (buf, reinterpret_cast<char*> (&x));
00287     }
00288 #else
00289   x = *reinterpret_cast<ACE_CDR::ULong*> (buf);
00290 #endif /* ACE_DISABLE_SWAP_ON_READ */
00291 
00292   return x;
00293 }


Member Data Documentation

CORBA::Octet TAO_GIOP_Message_State::byte_order_ [private]
 

0 = big, 1 = little

Definition at line 108 of file GIOP_Message_State.h.

Referenced by byte_order(), get_byte_order_info(), and read_ulong().

TAO_GIOP_Message_Version TAO_GIOP_Message_State::giop_version_ [private]
 

Definition at line 105 of file GIOP_Message_State.h.

Referenced by get_byte_order_info(), get_version_info(), and giop_version().

TAO_Pluggable_Message_Type TAO_GIOP_Message_State::message_type_ [private]
 

MsgType above.

Definition at line 111 of file GIOP_Message_State.h.

Referenced by message_type(), and parse_message_header_i().

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

CORBA::ULong TAO_GIOP_Message_State::payload_size_ [private]
 

In byte_order!

Definition at line 114 of file GIOP_Message_State.h.

Referenced by get_payload_size(), message_size(), parse_message_header_i(), and payload_size().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:14:45 2008 for TAO by doxygen 1.3.6