#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. | |
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_ |
This helps to establish the state of the incoming messages.
Definition at line 40 of file GIOP_Message_State.h.
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
|
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 } |
|
Definition at line 49 of file GIOP_Message_State.inl.
00050 { 00051 this->more_fragments_ = fragment; 00052 } |
|
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 } |
|
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 } |
|
Parse the message 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 } |
|
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 } |
|
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 } |
|
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 } |
|
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(). |
|
Definition at line 105 of file GIOP_Message_State.h. Referenced by get_byte_order_info(), get_version_info(), and giop_version(). |
|
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. |
|
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(). |