diff options
Diffstat (limited to 'TAO/tao/GIOP_Message_State.cpp')
-rw-r--r-- | TAO/tao/GIOP_Message_State.cpp | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/TAO/tao/GIOP_Message_State.cpp b/TAO/tao/GIOP_Message_State.cpp index 6f30b76136b..6100e1fb4fe 100644 --- a/TAO/tao/GIOP_Message_State.cpp +++ b/TAO/tao/GIOP_Message_State.cpp @@ -14,14 +14,13 @@ ACE_RCSID (tao, GIOP_Message_State, "$Id$") -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - TAO_GIOP_Message_State::TAO_GIOP_Message_State (void) : giop_version_ (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR), byte_order_ (0), message_type_ (0), message_size_ (0), + request_id_ (0), more_fragments_ (0), missing_data_ (0) { @@ -97,7 +96,8 @@ TAO_GIOP_Message_State::parse_message_header_i (ACE_Message_Block &incoming) } } - return 0; // success + // Get the request id + return this->parse_fragment_header (buf, incoming.length ()); } @@ -169,7 +169,7 @@ TAO_GIOP_Message_State::get_byte_order_info (char *buf) if (TAO_debug_level > 8) { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info\n") )); + "TAO (%P|%t) - GIOP_Message_State::get_byte_order_info\n")); } // Let us be specific that this is for 1.0 @@ -185,8 +185,8 @@ TAO_GIOP_Message_State::get_byte_order_info (char *buf) if (TAO_debug_level > 2) { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - GIOP_Message_State::get_byte_order_info, ") - ACE_TEXT ("invalid byte order <%d> for version <1.0>\n"), + "TAO (%P|%t) - GIOP_Message_State::get_byte_order_info, " + "invalid byte order <%d> for version <1.0>\n", this->byte_order_)); } return -1; @@ -229,8 +229,36 @@ TAO_GIOP_Message_State::get_payload_size (char *rd_ptr) this->message_size_ = this->read_ulong (rd_ptr); } + + +int +TAO_GIOP_Message_State::parse_fragment_header (const char *buf, + size_t length) +{ + // By this point we are doubly sure that we have a more or less + // valid GIOP message with a valid major revision number. + if ((this->giop_version_.major > 1 || this->giop_version_.minor >= 2) && + (this->more_fragments_ || this->message_type_ == TAO_GIOP_FRAGMENT)) + { + static const size_t len = + TAO_GIOP_MESSAGE_HEADER_LEN + TAO_GIOP_MESSAGE_FRAGMENT_HEADER; + + // If there is not enough data in the header to get the request + // id, then we need to indicate that by returning 1. + if (length < len) + return 1; + + // Fragmented message in GIOP 1.2 should have a fragment header + // following the GIOP header. + buf += TAO_GIOP_MESSAGE_HEADER_LEN; + this->request_id_ = this->read_ulong (buf); + } + + return 0; +} + CORBA::ULong -TAO_GIOP_Message_State::read_ulong (const char *rd_ptr) const +TAO_GIOP_Message_State::read_ulong (const char *rd_ptr) { CORBA::ULong x = 0; @@ -238,13 +266,11 @@ TAO_GIOP_Message_State::read_ulong (const char *rd_ptr) const // as SunCC) have a problem in deferencing from the // reinterpret_cast pointer of the <rd_ptr>, as the <rd_ptr> can be // on stack. So let us go ahead with this copying... - char buf[] = - { - *rd_ptr, - *(rd_ptr + 1), - *(rd_ptr + 2), - *(rd_ptr + 3) - }; + char buf [4]; + buf[0] = *rd_ptr; + buf[1] = *(rd_ptr + 1); + buf[2] = *(rd_ptr + 2); + buf[3] = *(rd_ptr + 3); #if !defined (ACE_DISABLE_SWAP_ON_READ) if (!(this->byte_order_ != ACE_CDR_BYTE_ORDER)) @@ -261,5 +287,3 @@ TAO_GIOP_Message_State::read_ulong (const char *rd_ptr) const return x; } - -TAO_END_VERSIONED_NAMESPACE_DECL |