00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file GIOP_Message_State.h 00006 * 00007 * GIOP_Message_State.h,v 1.17 2006/02/22 20:52:11 frehberger Exp 00008 * 00009 * GIOP utility definitions 00010 * 00011 * 00012 * @author Chris Cleeland <cleeland@cs.wustl.edu> 00013 * @author Carlos O' Ryan <coryan@uci.edu> 00014 * @author Balachandran Natarajan <bala@cs.wustl.edu> 00015 */ 00016 //============================================================================= 00017 #ifndef TAO_GIOP_MESSAGE_STATE_H 00018 #define TAO_GIOP_MESSAGE_STATE_H 00019 00020 #include /**/ "ace/pre.h" 00021 00022 #include "tao/GIOP_Message_Version.h" 00023 00024 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00025 # pragma once 00026 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00027 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 class TAO_ORB_Core; 00032 class TAO_GIOP_Message_Base; 00033 00034 00035 /** 00036 * @class TAO_GIOP_Message_State 00037 * 00038 * @brief Generic definitions for Message States. 00039 * 00040 * This helps to establish the state of the incoming messages. 00041 */ 00042 00043 class TAO_Export TAO_GIOP_Message_State 00044 { 00045 public: 00046 00047 /// Ctor 00048 TAO_GIOP_Message_State (void); 00049 00050 /// Parse the message header. 00051 /// 00052 /// \return -1 There was some error parsing the GIOP header 00053 /// \return 0 The GIOP header was parsed correctly 00054 /// \return 1 There was not enough data in the message block to 00055 /// parse the header 00056 int parse_message_header (ACE_Message_Block &incoming); 00057 00058 /// Return the message size 00059 CORBA::ULong message_size (void) const; 00060 00061 /// Return the message size 00062 CORBA::ULong payload_size (void) const; 00063 00064 /// Return the byte order information 00065 CORBA::Octet byte_order (void) const; 00066 00067 /// Reset the state.. 00068 void reset (void); 00069 00070 private: 00071 00072 friend class TAO_GIOP_Message_Base; 00073 00074 /// Parse the message header. 00075 int parse_message_header_i (ACE_Message_Block &incoming); 00076 00077 /// Checks for the magic word 'GIOP' in the start of the incoing 00078 /// stream 00079 int parse_magic_bytes (char *buf); 00080 00081 /// Extracts the version information from the incoming 00082 /// stream. Performs a check for whether the version information is 00083 /// right and sets the information in the <state> 00084 int get_version_info (char *buf); 00085 00086 /// Extracts the byte order information from the incoming 00087 /// stream. Performs a check for whether the byte order information 00088 /// right and sets the information in the <state> 00089 int get_byte_order_info (char *buf); 00090 00091 /// Gets the size of the payload and set the size in the <state> 00092 void get_payload_size (char *buf); 00093 00094 /// Read the unsigned long from the buffer. The <buf> should just 00095 /// point to the next 4 bytes data that represent the ULong 00096 CORBA::ULong read_ulong (const char *buf) const; 00097 00098 private: 00099 // GIOP version information.. 00100 TAO_GIOP_Message_Version giop_version_; 00101 00102 /// 0 = big, 1 = little 00103 CORBA::Octet byte_order_; 00104 00105 /// MsgType above 00106 CORBA::Octet message_type_; 00107 00108 /// in byte_order! 00109 CORBA::ULong message_size_; 00110 00111 /// (Requests and Replys) 00112 /// A value of zero indicates that this message does not have any 00113 /// fragments. A value of non-zero indicates that it does have 00114 /// fragments. 00115 CORBA::Octet more_fragments_; 00116 00117 /// Missing data 00118 CORBA::ULong missing_data_; 00119 }; 00120 00121 TAO_END_VERSIONED_NAMESPACE_DECL 00122 00123 static const size_t TAO_GIOP_MESSAGE_HEADER_LEN = 12; 00124 static const size_t TAO_GIOP_MESSAGE_SIZE_OFFSET = 8; 00125 static const size_t TAO_GIOP_MESSAGE_FLAGS_OFFSET = 6; 00126 static const size_t TAO_GIOP_MESSAGE_TYPE_OFFSET = 7; 00127 static const size_t TAO_GIOP_VERSION_MINOR_OFFSET = 5; 00128 static const size_t TAO_GIOP_VERSION_MAJOR_OFFSET = 4; 00129 static const size_t TAO_GIOP_MESSAGE_FRAGMENT_HEADER = 4; 00130 00131 #if defined (__ACE_INLINE__) 00132 # include "tao/GIOP_Message_State.inl" 00133 #endif /* __ACE_INLINE__ */ 00134 00135 #include /**/ "ace/post.h" 00136 #endif /*TAO_GIOP_MESSAGE_STATE_H*/