Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

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 Methods

 TAO_GIOP_Message_State (TAO_ORB_Core *orb_core=0, TAO_GIOP_Message_Base *base=0)
 Ctor. More...

int take_values_from_message_block (const ACE_Message_Block &mb)
CORBA::ULong message_size (void) const
 Return the message size. More...

CORBA::ULong payload_size (void) const
 Return the message size. More...

CORBA::Octet byte_order (void) const
 Return the byte order information. More...

const TAO_GIOP_Message_Versiongiop_version () const
 Return GIOP version information. More...

CORBA::Octet more_fragments () const
 (Requests and Replys). More...

CORBA::Octet message_type () const
 MsgType above. More...

void reset (void)
 Reset the state.. More...


Private Methods

int set_version_info_from_buffer (const char *buf)
 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>. More...

int set_byte_order_info_from_buffer (const char *buf)
 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>. More...

void set_payload_size_from_buffer (const char *buf)
 Gets the size of the payload and set the size in the <state>. More...

int parse_fragment_header (const char *buf, size_t length)
 Parses the GIOP FRAGMENT_HEADER information from the incoming stream. More...

CORBA::ULong read_ulong (const char *buf)
 Read the unsigned long from the buffer. The <buf> should just point to the next 4 bytes data that represent the ULong. More...


Private Attributes

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

CORBA::Octet message_type_
 MsgType above. More...

CORBA::ULong message_size_
 in byte_order! More...

CORBA::ULong request_id_
 Request Id from the Fragment header. More...

CORBA::Octet more_fragments_
 (Requests and Replys). More...

CORBA::ULong missing_data_
 Missing data. More...


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


Constructor & Destructor Documentation

TAO_GIOP_Message_State::TAO_GIOP_Message_State TAO_ORB_Core   orb_core = 0,
TAO_GIOP_Message_Base   base = 0
 

Ctor.

Definition at line 59 of file GIOP_Message_State.cpp.

References TAO_DEF_GIOP_MAJOR, and TAO_DEF_GIOP_MINOR.

00062   : giop_version_ (TAO_DEF_GIOP_MAJOR,
00063                    TAO_DEF_GIOP_MINOR),
00064     byte_order_ (0),
00065     message_type_ (0),
00066     message_size_ (0),
00067     request_id_ (0),
00068     more_fragments_ (0),
00069     missing_data_ (0)
00070 {
00071 }


Member Function Documentation

ACE_INLINE CORBA::Octet TAO_GIOP_Message_State::byte_order void    const
 

Return the byte order information.

Returns:
0 big-endian 1 little-endian

Definition at line 21 of file GIOP_Message_State.inl.

References byte_order_.

00022 {
00023   return this->byte_order_;
00024 }

ACE_INLINE const TAO_GIOP_Message_Version & TAO_GIOP_Message_State::giop_version   const
 

Return GIOP version information.

Definition at line 37 of file GIOP_Message_State.inl.

References giop_version_.

00038 {
00039   return this->giop_version_;
00040 }

ACE_INLINE CORBA::ULong TAO_GIOP_Message_State::message_size void    const
 

Return the message size.

Definition at line 6 of file GIOP_Message_State.inl.

References message_size_, and TAO_GIOP_MESSAGE_HEADER_LEN.

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

ACE_INLINE CORBA::Octet TAO_GIOP_Message_State::message_type   const
 

MsgType above.

Definition at line 49 of file GIOP_Message_State.inl.

References message_type_.

00050 {
00051   return this->message_type_;
00052 }

ACE_INLINE CORBA::Octet TAO_GIOP_Message_State::more_fragments   const
 

(Requests and Replys).

Definition at line 43 of file GIOP_Message_State.inl.

References more_fragments_.

00044 {
00045   return this->more_fragments_;
00046 }

int TAO_GIOP_Message_State::parse_fragment_header const char *    buf,
size_t    length
[private]
 

Parses the GIOP FRAGMENT_HEADER information from the incoming stream.

Definition at line 198 of file GIOP_Message_State.cpp.

References giop_version_, TAO_GIOP_Message_Version::minor, read_ulong, request_id_, TAO_GIOP_MESSAGE_FRAGMENT_HEADER, and TAO_GIOP_MESSAGE_HEADER_LEN.

Referenced by take_values_from_message_block.

00200 {
00201   size_t len =
00202     TAO_GIOP_MESSAGE_FRAGMENT_HEADER + TAO_GIOP_MESSAGE_HEADER_LEN;
00203 
00204   buf += TAO_GIOP_MESSAGE_HEADER_LEN;
00205 
00206   // By this point we are doubly sure that we have a more or less
00207   // valid GIOP message with a valid major revision number.
00208   if (this->giop_version_.minor >= 2 && length > len)
00209     {
00210       // Fragmented message in GIOP 1.2 should have a fragment header
00211       // following the GIOP header.  Grab the rd_ptr to get that
00212       // info.
00213       this->request_id_ = this->read_ulong (buf);
00214 
00215       // As we parsed the header
00216       return 1;
00217     }
00218 
00219   return 0;
00220 }

ACE_INLINE CORBA::ULong TAO_GIOP_Message_State::payload_size void    const
 

Return the message size.

Definition at line 15 of file GIOP_Message_State.inl.

References message_size_.

00016 {
00017   return this->message_size_;
00018 }

CORBA::ULong TAO_GIOP_Message_State::read_ulong const char *    buf [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 223 of file GIOP_Message_State.cpp.

References ACE_CDR_BYTE_ORDER, byte_order_, ACE_CDR::swap_4, and ACE_CDR::ULong.

Referenced by parse_fragment_header, and set_payload_size_from_buffer.

00224 {
00225   CORBA::ULong x = 0;
00226 
00227   // We dont need to do this sort of copy. But some compilers (read it
00228   // as solaris ones) have a problem in deferencing from the
00229   // reinterpret_cast pointer of the <rd_ptr>, as the <rd_ptr> can be
00230   // on stack. So let us go ahead with this copying...
00231   char buf [4];
00232   buf[0] = *rd_ptr;
00233   buf[1] = *(rd_ptr + 1);
00234   buf[2] = *(rd_ptr + 2);
00235   buf[3] = *(rd_ptr + 3);
00236 
00237 #if !defined (ACE_DISABLE_SWAP_ON_READ)
00238   if (!(this->byte_order_ != ACE_CDR_BYTE_ORDER))
00239     {
00240       x = *ACE_reinterpret_cast (ACE_CDR::ULong*, buf);
00241     }
00242   else
00243     {
00244       ACE_CDR::swap_4 (buf, ACE_reinterpret_cast (char*, &x));
00245     }
00246 #else
00247   x = *ACE_reinterpret_cast(ACE_CDR::ULong*, buf);
00248 #endif /* ACE_DISABLE_SWAP_ON_READ */
00249 
00250   return x;
00251 }

ACE_INLINE void TAO_GIOP_Message_State::reset void   
 

Reset the state..

Definition at line 27 of file GIOP_Message_State.inl.

References message_size_, message_type_, missing_data_, more_fragments_, and request_id_.

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

int TAO_GIOP_Message_State::set_byte_order_info_from_buffer const 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 149 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, more_fragments_, and TAO_GIOP_MESSAGE_FLAGS_OFFSET.

Referenced by take_values_from_message_block.

00150 {
00151   // Let us be specific that this is for 1.0
00152   if (this->giop_version_.minor == 0 &&
00153       this->giop_version_.major == 1)
00154     {
00155       this->byte_order_ =
00156         buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET];
00157 
00158       if (this->byte_order_ != 0 &&
00159           this->byte_order_ != 1)
00160         {
00161           if (TAO_debug_level > 2)
00162             ACE_DEBUG ((LM_DEBUG,
00163                         "TAO (%P|%t) - GIOP_Message_State::get_byte_order_info, "
00164                         "invalid byte order <%d> for version <1.0>\n",
00165                         this->byte_order_));
00166           return -1;
00167         }
00168     }
00169   else
00170     {
00171       // Read the byte ORDER
00172       this->byte_order_ =
00173         (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x01);
00174 
00175       // Read the fragment bit
00176       this->more_fragments_ =
00177         (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x02);
00178 
00179       if ((buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET] & ~0x3) != 0)
00180         {
00181           if (TAO_debug_level > 2)
00182           ACE_DEBUG ((LM_DEBUG,
00183                       ACE_TEXT ("TAO (%P|%t) - invalid flags for <%d>")
00184                       ACE_TEXT (" for version <%d %d> \n"),
00185                       buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET],
00186                       this->giop_version_.major,
00187                       this->giop_version_.minor));
00188           return -1;
00189         }
00190     }
00191 
00192   return 0;
00193 }

ACE_INLINE void TAO_GIOP_Message_State::set_payload_size_from_buffer const char *    buf [private]
 

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

Definition at line 55 of file GIOP_Message_State.inl.

References message_size_, read_ulong, and TAO_GIOP_MESSAGE_SIZE_OFFSET.

Referenced by take_values_from_message_block.

00056 {
00057   // Move the read pointer
00058   rd_ptr += TAO_GIOP_MESSAGE_SIZE_OFFSET;
00059 
00060   this->message_size_ =  this->read_ulong (rd_ptr);
00061 }

int TAO_GIOP_Message_State::set_version_info_from_buffer const 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 118 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, TAO_GIOP_VERSION_MAJOR_OFFSET, and TAO_GIOP_VERSION_MINOR_OFFSET.

Referenced by take_values_from_message_block.

00119 {
00120   // We have a GIOP message on hand. Get its revision numbers
00121   CORBA::Octet incoming_major = buf[TAO_GIOP_VERSION_MAJOR_OFFSET];
00122   CORBA::Octet incoming_minor = buf[TAO_GIOP_VERSION_MINOR_OFFSET];
00123 
00124   // Check the revision information
00125   if (TAO_GIOP_Message_Generator_Parser_Impl::check_revision (
00126           incoming_major,
00127           incoming_minor) == 0)
00128     {
00129       if (TAO_debug_level > 0)
00130         {
00131           ACE_DEBUG ((LM_DEBUG,
00132                       ACE_TEXT ("TAO (%P|%t) - ")
00133                       ACE_TEXT ("GIOP_Message_State::set_version_info_from_buffer:")
00134                       ACE_TEXT ("bad version <%d.%d>\n"),
00135                       incoming_major, incoming_minor));
00136         }
00137 
00138       return -1;
00139     }
00140 
00141   // Set the version
00142   this->giop_version_.minor = incoming_minor;
00143   this->giop_version_.major = incoming_major;
00144 
00145   return 0;
00146 }

int TAO_GIOP_Message_State::take_values_from_message_block const ACE_Message_Block   mb
 

Definition at line 76 of file GIOP_Message_State.cpp.

References ACE_DEBUG, ACE_Message_Block::length, LM_DEBUG, message_size_, message_type_, parse_fragment_header, ACE_Message_Block::rd_ptr, set_byte_order_info_from_buffer, set_payload_size_from_buffer, set_version_info_from_buffer, TAO_GIOP_MESSAGE_TYPE_OFFSET, and TAO_GIOP_MESSAGERROR.

00079 {
00080   const char* buf = mb.rd_ptr ();
00081 
00082   // Get the version information
00083   if (this->set_version_info_from_buffer (buf) == -1)
00084     return -1;
00085 
00086   // Get the byte order information...
00087   if (this->set_byte_order_info_from_buffer (buf) == -1)
00088     return -1;
00089 
00090   // Get the message type
00091   this->message_type_ = buf[TAO_GIOP_MESSAGE_TYPE_OFFSET];
00092 
00093   // Get the size of the message..
00094   this->set_payload_size_from_buffer (buf);
00095 
00096   // Get the request id
00097   this->parse_fragment_header (buf, mb.length ());
00098 
00099   if (this->message_size_ == 0)
00100     {
00101       if (this->message_type_ == TAO_GIOP_MESSAGERROR)
00102         {
00103           if (TAO_debug_level > 0)
00104             ACE_DEBUG ((LM_DEBUG, "(%P|%t) GIOP_Message_State::take_values: GIOP_MESSAGE_ERROR rcv'd.\n"));
00105           return 0;
00106         }
00107       else
00108         {
00109           if (TAO_debug_level > 0)
00110             ACE_DEBUG ((LM_DEBUG, "(%P|%t) GIOP_Message_State::take_values: Message of size zero rcv'd.\n"));
00111           return -1;
00112         }
00113     }
00114   return 0;
00115 }


Friends And Related Function Documentation

friend class TAO_GIOP_Message_Base [friend]
 

Definition at line 79 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 109 of file GIOP_Message_State.h.

Referenced by byte_order, read_ulong, and set_byte_order_info_from_buffer.

TAO_GIOP_Message_Version TAO_GIOP_Message_State::giop_version_ [private]
 

Definition at line 106 of file GIOP_Message_State.h.

Referenced by giop_version, parse_fragment_header, set_byte_order_info_from_buffer, and set_version_info_from_buffer.

CORBA::ULong TAO_GIOP_Message_State::message_size_ [private]
 

in byte_order!

Definition at line 115 of file GIOP_Message_State.h.

Referenced by message_size, payload_size, reset, set_payload_size_from_buffer, and take_values_from_message_block.

CORBA::Octet TAO_GIOP_Message_State::message_type_ [private]
 

MsgType above.

Definition at line 112 of file GIOP_Message_State.h.

Referenced by message_type, reset, and take_values_from_message_block.

CORBA::ULong TAO_GIOP_Message_State::missing_data_ [private]
 

Missing data.

Definition at line 124 of file GIOP_Message_State.h.

Referenced by reset.

CORBA::Octet TAO_GIOP_Message_State::more_fragments_ [private]
 

(Requests and Replys).

Definition at line 121 of file GIOP_Message_State.h.

Referenced by more_fragments, reset, and set_byte_order_info_from_buffer.

CORBA::ULong TAO_GIOP_Message_State::request_id_ [private]
 

Request Id from the Fragment header.

Definition at line 118 of file GIOP_Message_State.h.

Referenced by parse_fragment_header, and reset.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:16:53 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002