3 //=============================================================================
5 * @file GIOP_Message_State.h
7 * GIOP utility definitions
9 * @author Chris Cleeland <cleeland@cs.wustl.edu>
10 * @author Carlos O' Ryan <coryan@uci.edu>
11 * @author Balachandran Natarajan <bala@cs.wustl.edu>
12 * @author Johnny Willemsen <jwillemsen@remedy.nl>
14 //=============================================================================
15 #ifndef TAO_GIOP_MESSAGE_STATE_H
16 #define TAO_GIOP_MESSAGE_STATE_H
18 #include /**/ "ace/pre.h"
20 #include "tao/GIOP_Message_Version.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "tao/GIOPC.h"
28 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
31 * @class TAO_GIOP_Message_State
33 * @brief Generic definitions for Message States.
35 * This helps to establish the state of the incoming messages.
38 class TAO_Export TAO_GIOP_Message_State
42 TAO_GIOP_Message_State () = default;
43 ~TAO_GIOP_Message_State () = default;
45 /// Parse the message header.
47 /// \return -1 There was some error parsing the GIOP header
48 /// \return 0 The GIOP header was parsed correctly
49 /// \return 1 There was not enough data in the message block to
51 int parse_message_header (ACE_Message_Block
&incoming
);
53 /// Return the message size
54 CORBA::ULong
message_size () const;
56 /// Return the message size
57 CORBA::ULong
payload_size () const;
59 /// Return the byte order information
60 CORBA::Octet
byte_order () const;
62 /// Return the message type
63 GIOP::MsgType
message_type () const;
65 /// Return the more fragments
66 CORBA::Boolean
more_fragments () const;
68 void more_fragments (CORBA::Boolean fragment
);
70 /// Get the GIOP version
71 TAO_GIOP_Message_Version
const &giop_version () const;
73 /// Return the compressed information
74 CORBA::Boolean
compressed () const;
77 /// Parse the message header.
78 int parse_message_header_i (ACE_Message_Block
&incoming
);
80 /// Checks for the magic word 'GIOP' in the start of the incoming
82 int parse_magic_bytes (char *buf
);
84 /// Extracts the version information from the incoming
85 /// stream. Performs a check for whether the version information is
86 /// right and sets the information in the <state>
87 int get_version_info (char *buf
);
89 /// Extracts the byte order information from the incoming
90 /// stream. Performs a check for whether the byte order information
91 /// right and sets the information in the <state>
92 int get_byte_order_info (char *buf
);
94 /// Gets the size of the payload and set the size in the <state>
95 void get_payload_size (char *buf
);
97 /// Read the unsigned long from the buffer. The @a buf should just
98 /// point to the next 4 bytes data that represent the ULong
99 CORBA::ULong
read_ulong (const char *buf
) const;
102 /// GIOP version information..
103 TAO_GIOP_Message_Version giop_version_
{TAO_DEF_GIOP_MAJOR
, TAO_DEF_GIOP_MINOR
};
105 /// 0 = big, 1 = little
106 CORBA::Octet byte_order_
{0};
109 GIOP::MsgType message_type_
{GIOP::Request
};
112 CORBA::ULong payload_size_
{0};
114 /// (Requests and Replys)
115 /// A value of zero indicates that this message does not have any
116 /// fragments. A value of non-zero indicates that it does have
118 CORBA::Boolean more_fragments_
{false};
121 CORBA::Boolean compressed_
{false};
124 TAO_END_VERSIONED_NAMESPACE_DECL
126 constexpr size_t TAO_GIOP_MESSAGE_HEADER_LEN
= 12;
127 constexpr size_t TAO_GIOP_MESSAGE_SIZE_OFFSET
= 8;
128 constexpr size_t TAO_GIOP_MESSAGE_FLAGS_OFFSET
= 6;
129 constexpr size_t TAO_GIOP_MESSAGE_TYPE_OFFSET
= 7;
130 constexpr size_t TAO_GIOP_VERSION_MINOR_OFFSET
= 5;
131 constexpr size_t TAO_GIOP_VERSION_MAJOR_OFFSET
= 4;
132 constexpr size_t TAO_GIOP_MESSAGE_FRAGMENT_HEADER
= 4;
134 #if defined (__ACE_INLINE__)
135 # include "tao/GIOP_Message_State.inl"
136 #endif /* __ACE_INLINE__ */
138 #include /**/ "ace/post.h"
139 #endif /*TAO_GIOP_MESSAGE_STATE_H*/