#include <GIOP_Message_State.h>
Collaboration diagram for TAO_GIOP_Message_State:
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::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. | |
GIOP::MsgType | 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 <state>. | |
CORBA::ULong | read_ulong (const char *buf) const |
Private Attributes | |
TAO_GIOP_Message_Version | giop_version_ |
CORBA::Octet | byte_order_ |
0 = big, 1 = little | |
GIOP::MsgType | message_type_ |
MsgType above. | |
CORBA::ULong | payload_size_ |
In byte_order! | |
CORBA::Octet | more_fragments_ |
This helps to establish the state of the incoming messages.
Definition at line 40 of file GIOP_Message_State.h.
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.
00009 : giop_version_ (TAO_DEF_GIOP_MAJOR, 00010 TAO_DEF_GIOP_MINOR), 00011 byte_order_ (0), 00012 message_type_ (GIOP::Request), 00013 payload_size_ (0), 00014 more_fragments_ (0) 00015 { 00016 }
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 <state>
Definition at line 145 of file GIOP_Message_State.cpp.
References ACE_DEBUG, ACE_TEXT, byte_order_, LM_DEBUG, more_fragments_, TAO_debug_level, and TAO_GIOP_MESSAGE_FLAGS_OFFSET.
Referenced by parse_message_header_i().
00146 { 00147 if (TAO_debug_level > 8) 00148 { 00149 ACE_DEBUG ((LM_DEBUG, 00150 ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info\n") )); 00151 } 00152 00153 // Let us be specific that this is for 1.0 00154 if (this->giop_version_.minor == 0 && 00155 this->giop_version_.major == 1) 00156 { 00157 this->byte_order_ = 00158 buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]; 00159 00160 if (this->byte_order_ != 0 && 00161 this->byte_order_ != 1) 00162 { 00163 if (TAO_debug_level > 2) 00164 { 00165 ACE_DEBUG ((LM_DEBUG, 00166 ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info, ") 00167 ACE_TEXT ("invalid byte order <%d> for version <1.0>\n"), 00168 this->byte_order_)); 00169 } 00170 return -1; 00171 } 00172 } 00173 else 00174 { 00175 // Read the byte ORDER 00176 this->byte_order_ = 00177 (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x01); 00178 00179 // Read the fragment bit 00180 this->more_fragments_ = 00181 (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x02); 00182 00183 if ((buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET] & ~0x3) != 0) 00184 { 00185 if (TAO_debug_level > 2) 00186 { 00187 ACE_DEBUG ((LM_DEBUG, 00188 ACE_TEXT ("TAO (%P|%t) - invalid flags for <%d> ") 00189 ACE_TEXT ("for version <%d %d> \n"), 00190 buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET], 00191 this->giop_version_.major, 00192 this->giop_version_.minor)); 00193 } 00194 return -1; 00195 } 00196 } 00197 00198 return 0; 00199 }
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 202 of file GIOP_Message_State.cpp.
References payload_size_, read_ulong(), and TAO_GIOP_MESSAGE_SIZE_OFFSET.
Referenced by parse_message_header_i().
00203 { 00204 // Move the read pointer 00205 rd_ptr += TAO_GIOP_MESSAGE_SIZE_OFFSET; 00206 00207 this->payload_size_ = this->read_ulong (rd_ptr); 00208 }
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 110 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_debug_level, TAO_GIOP_VERSION_MAJOR_OFFSET, and TAO_GIOP_VERSION_MINOR_OFFSET.
Referenced by parse_message_header_i().
00111 { 00112 if (TAO_debug_level > 8) 00113 { 00114 ACE_DEBUG ((LM_DEBUG, 00115 "TAO (%P|%t) - GIOP_Message_State::get_version_info\n")); 00116 } 00117 00118 // We have a GIOP message on hand. Get its revision numbers 00119 CORBA::Octet incoming_major = buf[TAO_GIOP_VERSION_MAJOR_OFFSET]; 00120 CORBA::Octet incoming_minor = buf[TAO_GIOP_VERSION_MINOR_OFFSET]; 00121 00122 // Check the revision information 00123 if (TAO_GIOP_Message_Generator_Parser_Impl::check_revision ( 00124 incoming_major, 00125 incoming_minor) == 0) 00126 { 00127 if (TAO_debug_level > 0) 00128 { 00129 ACE_DEBUG ((LM_DEBUG, 00130 ACE_TEXT ("TAO (%P|%t) - bad version <%d.%d>\n"), 00131 incoming_major, incoming_minor)); 00132 } 00133 00134 return -1; 00135 } 00136 00137 // Set the version 00138 this->giop_version_.minor = incoming_minor; 00139 this->giop_version_.major = incoming_major; 00140 00141 return 0; 00142 }
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_, and TAO_GIOP_MESSAGE_HEADER_LEN.
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 }
ACE_INLINE GIOP::MsgType TAO_GIOP_Message_State::message_type | ( | CORBA::Octet | type | ) | const [private] |
ACE_INLINE GIOP::MsgType 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.
References more_fragments_.
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.
References more_fragments_.
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 85 of file GIOP_Message_State.cpp.
References ACE_DEBUG, ACE_TEXT, LM_DEBUG, and TAO_debug_level.
00086 { 00087 // The values are hard-coded to support non-ASCII platforms. 00088 if (!(buf [0] == 0x47 // 'G' 00089 && buf [1] == 0x49 // 'I' 00090 && buf [2] == 0x4f // 'O' 00091 && buf [3] == 0x50)) // 'P' 00092 { 00093 if (TAO_debug_level > 0) 00094 ACE_DEBUG ((LM_DEBUG, 00095 ACE_TEXT ("TAO (%P|%t) - ") 00096 ACE_TEXT ("TAO_GIOP_Message_State::parse_magic_bytes, ") 00097 ACE_TEXT ("bad header: ") 00098 ACE_TEXT ("magic word [%02x,%02x,%02x,%02x]\n"), 00099 buf[0], 00100 buf[1], 00101 buf[2], 00102 buf[3])); 00103 return -1; 00104 } 00105 00106 return 0; 00107 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL int TAO_GIOP_Message_State::parse_message_header | ( | ACE_Message_Block & | incoming | ) |
Parse the message 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 TAO_GIOP_MESSAGE_HEADER_LEN.
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_, ACE_Message_Block::rd_ptr(), TAO_debug_level, and TAO_GIOP_MESSAGE_TYPE_OFFSET.
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 char * const buf = incoming.rd_ptr (); 00044 00045 if (this->parse_magic_bytes (buf) == -1 // Parse magic bytes first 00046 || this->get_version_info (buf) == -1 // Get version information 00047 || this->get_byte_order_info (buf) == -1) // Get byte order information 00048 return -1; 00049 00050 // Get the message type 00051 this->message_type_ = this->message_type (buf[TAO_GIOP_MESSAGE_TYPE_OFFSET]); 00052 00053 // Get the size of the message.. 00054 this->get_payload_size (buf); 00055 00056 if (this->payload_size_ == 0) 00057 { 00058 switch (this->message_type_) 00059 { 00060 case GIOP::MessageError: 00061 case GIOP::CloseConnection: 00062 if (TAO_debug_level > 0) 00063 { 00064 char const * const which = 00065 (this->message_type_ == GIOP::CloseConnection) ? "CloseConnection" : 00066 (this->message_type_ == GIOP::MessageError) ? "MessageError" : "unknown"; 00067 ACE_DEBUG ((LM_DEBUG, 00068 ACE_TEXT ("TAO (%P|%t) - GIOP %s received \n"), which)); 00069 } 00070 return 0; 00071 default: 00072 if (TAO_debug_level > 0) 00073 ACE_DEBUG ((LM_DEBUG, 00074 ACE_TEXT ("TAO (%P|%t) - ") 00075 ACE_TEXT ("TAO_GIOP_Message_State::parse_magic_bytes, ") 00076 ACE_TEXT ("Message of size zero recd. \n"))); 00077 return -1; 00078 } 00079 } 00080 00081 return 0; // success 00082 }
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 211 of file GIOP_Message_State.cpp.
References ACE_CDR_BYTE_ORDER, ACE_CDR::swap_4(), and TAO_END_VERSIONED_NAMESPACE_DECL.
Referenced by get_payload_size().
00212 { 00213 CORBA::ULong x = 0; 00214 00215 // We don't need to do this sort of copy. But some compilers (read it 00216 // as SunCC) have a problem in deferencing from the 00217 // reinterpret_cast pointer of the <rd_ptr>, as the <rd_ptr> can be 00218 // on stack. So let us go ahead with this copying... 00219 char buf[] = 00220 { 00221 *rd_ptr, 00222 *(rd_ptr + 1), 00223 *(rd_ptr + 2), 00224 *(rd_ptr + 3) 00225 }; 00226 00227 #if !defined (ACE_DISABLE_SWAP_ON_READ) 00228 if (!(this->byte_order_ != ACE_CDR_BYTE_ORDER)) 00229 { 00230 x = *reinterpret_cast<ACE_CDR::ULong*> (buf); 00231 } 00232 else 00233 { 00234 ACE_CDR::swap_4 (buf, reinterpret_cast<char*> (&x)); 00235 } 00236 #else 00237 x = *reinterpret_cast<ACE_CDR::ULong*> (buf); 00238 #endif /* ACE_DISABLE_SWAP_ON_READ */ 00239 00240 return x; 00241 }
0 = big, 1 = little
Definition at line 108 of file GIOP_Message_State.h.
Referenced by byte_order(), and get_byte_order_info().
Definition at line 105 of file GIOP_Message_State.h.
Referenced by get_version_info(), and giop_version().
GIOP::MsgType 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().
(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.
Referenced by get_byte_order_info(), and more_fragments().
In byte_order!
Definition at line 114 of file GIOP_Message_State.h.
Referenced by get_payload_size(), message_size(), and payload_size().