2 #include "tao/GIOP_Message_Generator_Parser_12.h"
4 #include "tao/GIOP_Utils.h"
5 #include "tao/GIOP_Message_Locate_Header.h"
6 #include "tao/operation_details.h"
8 #include "tao/Pluggable_Messaging_Utils.h"
9 #include "tao/GIOP_Message_State.h"
10 #include "tao/TAO_Server_Request.h"
12 #include "tao/ORB_Core.h"
13 #include "tao/Transport.h"
16 // This is used by GIOP1.2. This is to align the message body on a
17 // 8-octet boundary. This is declared static so that it is in file
19 static constexpr size_t TAO_GIOP_MESSAGE_ALIGN_PTR
= 8;
21 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
24 TAO_GIOP_Message_Generator_Parser_12::write_request_header (
25 const TAO_Operation_Details
&opdetails
,
26 TAO_Target_Specification
&spec
,
29 // First the request id
30 if (!(msg
<< opdetails
.request_id ()))
33 CORBA::Octet
const response_flags
= opdetails
.response_flags ();
35 // Here are the Octet values for different policies. See the meaning
36 // of response_flags of RequestHeader_1_2 in the CORBA specification as
37 // to why the values below are used.
38 // '00000000' for SYNC_NONE
39 // '00000000' for SYNC_WITH_TRANSPORT
40 // '00000001' for SYNC_WITH_SERVER
41 // '00000011' for SYNC_WITH_TARGET
42 // '00000011' for regular two ways, but if they are invoked via a
43 // DII with INV_NO_RESPONSE flag set then we need to send '00000001'
45 // We have not implemented the policy INV_NO_RESPONSE for DII.
46 if (response_flags
== TAO_TWOWAY_RESPONSE_FLAG
)
47 msg
<< ACE_OutputCDR::from_octet (3);
48 // Second the response flags
49 // Sync scope - ignored by server if request is not oneway.
50 else if (response_flags
== CORBA::Octet (Messaging::SYNC_NONE
)
51 || response_flags
== CORBA::Octet (Messaging::SYNC_WITH_TRANSPORT
)
52 || response_flags
== CORBA::Octet (TAO::SYNC_DELAYED_BUFFERING
))
53 // No response required.
54 msg
<< ACE_OutputCDR::from_octet (0);
56 else if (response_flags
== CORBA::Octet (Messaging::SYNC_WITH_SERVER
))
57 // Return before dispatching to the servant
58 msg
<< ACE_OutputCDR::from_octet (1);
60 else if (response_flags
== CORBA::Octet (Messaging::SYNC_WITH_TARGET
))
61 // Return after dispatching servant.
62 msg
<< ACE_OutputCDR::from_octet (3);
64 // Until more flags are defined by the OMG.
68 CORBA::Octet reserved
[3] = {0, 0, 0};
70 msg
.write_octet_array (reserved
, 3);
72 if (!this->marshall_target_spec (spec
, msg
))
75 // Write the operation name
76 msg
.write_string (opdetails
.opname_len (),
79 // Write the service context list
80 if (!(msg
<< opdetails
.request_service_info ()))
83 // We align the pointer only if the operation has arguments.
84 if (opdetails
.in_argument_flag ()
85 && msg
.align_write_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR
) == -1)
94 TAO_GIOP_Message_Generator_Parser_12::write_locate_request_header (
95 CORBA::ULong request_id
,
96 TAO_Target_Specification
&spec
,
99 // Write the request id
100 if (!(msg
<< request_id
))
103 // Write the target address
104 if (!(this->marshall_target_spec (spec
, msg
)))
107 // I dont think we need to align the pointer to an 8 byte boundary
109 // We need to align the pointer
110 // if (msg.align_write_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR) == -1)
118 TAO_GIOP_Message_Generator_Parser_12::write_reply_header (
119 TAO_OutputCDR
& output
,
120 TAO_Pluggable_Reply_Params_Base
&reply
)
122 // Write the request ID
123 if (!(output
.write_ulong (reply
.request_id_
)))
126 // Write the reply status
127 if (!(output
.write_ulong (reply
.reply_status ())))
130 if (!(output
<< reply
.service_context_notowned ()))
133 if (reply
.argument_flag_
)
135 // If we have some data to be marshalled, then we align the
136 // pointer to a 8 byte boundary. Else, we just leave it throu
137 if (output
.align_write_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR
) == -1)
146 TAO_GIOP_Message_Generator_Parser_12::write_locate_reply_mesg (
147 TAO_OutputCDR
& output
,
148 CORBA::ULong request_id
,
149 TAO_GIOP_Locate_Status_Msg
&status_info
)
151 if (!(output
.write_ulong (request_id
)))
154 // Make the header for the locate request
155 if (!(output
.write_ulong (status_info
.status
)))
158 // Note: We dont align the pointer to an 8 byte boundary for a
159 // locate reply body. This is due to an urgent issue raised by Michi
160 // in the OMG. I discussed this with Michi today (09/07/2001) and I
161 // learn that this has been passed. Hence the change..
163 if (status_info.status == TAO_GIOP_OBJECT_FORWARD ||
164 status_info.status == TAO_GIOP_OBJECT_FORWARD_PERM)
166 // We have to send some data, so align the pointer
167 if (output.align_write_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR) == -1)
173 switch (status_info
.status
)
175 case GIOP::OBJECT_FORWARD
:
177 // More likely than not we will not have this in TAO
178 case GIOP::OBJECT_FORWARD_PERM
:
180 CORBA::Object_ptr object_ptr
=
181 status_info
.forward_location_var
.in ();
183 if (!(output
<< object_ptr
))
185 if (TAO_debug_level
> 0)
189 ACE_TEXT ("TAO (%P|%t|%N|%l) write_locate_reply_mesg-")
190 ACE_TEXT (" cannot marshal object reference\n")
196 case GIOP::LOC_SYSTEM_EXCEPTION
:
197 case GIOP::LOC_NEEDS_ADDRESSING_MODE
:
198 // Do we do these in TAO??
199 // What to do here???? I dont really know. I have to do a survey
200 // of the specifications that uses this.
210 TAO_GIOP_Message_Generator_Parser_12::write_fragment_header (
212 CORBA::ULong request_id
)
214 return (cdr
<< request_id
);
216 // No need to align write pointer to an 8 byte boundary since it
217 // should already be aligned (12 for GIOP messager + 4 for fragment
218 // header = 16 -- a multiple of 8)
222 TAO_GIOP_Message_Generator_Parser_12::parse_request_header (
223 TAO_ServerRequest
&request
)
225 // Get the input CDR in the request class
226 TAO_InputCDR
& input
= *request
.incoming ();
228 CORBA::Boolean hdr_status
= input
.good_bit ();
230 CORBA::ULong req_id
= 0;
231 // Get the rest of the request header ...
232 hdr_status
= hdr_status
&& input
.read_ulong (req_id
);
234 request
.request_id (req_id
);
236 CORBA::Octet response_flags
= CORBA::Octet();
237 hdr_status
= hdr_status
&& input
.read_octet (response_flags
);
239 request
.response_expected ((response_flags
> 0));
241 // The high bit of the octet has been set if the SyncScope policy
242 // value is SYNC_WITH_SERVER.
243 request
.sync_with_server ((response_flags
== 1));
246 input
.skip_bytes (3);
248 // Unmarshal the target address field.
250 hdr_status
&& request
.profile ().unmarshall_target_address(input
);
252 CORBA::ULong length
= 0;
253 hdr_status
= hdr_status
&& input
.read_ulong (length
);
257 // Do not include NULL character at the end.
258 // @@ This is not getting demarshaled using the codeset
261 // Notice that there are no memory allocations involved
263 request
.operation (input
.rd_ptr (),
265 0 /* TAO_ServerRequest does NOT own string */);
266 hdr_status
= input
.skip_bytes (length
);
269 // Tear out the service context ... we currently ignore it, but it
270 // should probably be passed to each ORB service as appropriate
271 // (e.g. transactions, security).
273 // NOTE: As security support kicks in, this is a good place to
274 // verify a digital signature, if that is required in this security
275 // environment. It may be required even when using IPSEC security
277 IOP::ServiceContextList
&req_service_info
= request
.request_service_info ();
279 if (!(input
>> req_service_info
))
283 TAOLIB_ERROR ((LM_ERROR
,
284 ACE_TEXT ("TAO (%P|%t) parse_request_header, ")
285 ACE_TEXT ("extracting context\n")));
291 if (req_service_info
.length() > 0)
293 request
.orb_core ()->service_context_registry ().
294 process_service_contexts (req_service_info
, *(request
.transport ()), &request
);
297 if (input
.length () > 0)
299 // Reset the read_ptr to an 8-byte boundary.
300 input
.align_read_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR
);
303 return hdr_status
? 0 : -1;
308 TAO_GIOP_Message_Generator_Parser_12::parse_locate_header (
309 TAO_GIOP_Locate_Request_Header
&request
)
312 TAO_InputCDR
&msg
= request
.incoming_stream ();
314 // Get the request id.
315 CORBA::ULong req_id
= 0;
316 CORBA::Boolean hdr_status
= msg
.read_ulong (req_id
);
318 // Store it in the Locate request classes
319 request
.request_id (req_id
);
321 // Unmarshal the target address field.
323 hdr_status
&& request
.profile ().unmarshall_target_address(msg
);
325 // Reset the pointer to an 8-byte bouns]dary
326 msg
.align_read_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR
);
328 return hdr_status
? 0 : -1;
332 TAO_GIOP_Message_Generator_Parser_12::parse_reply (
334 TAO_Pluggable_Reply_Params
¶ms
)
336 if (TAO_GIOP_Message_Generator_Parser::parse_reply (cdr
, params
) == -1)
339 if (!(cdr
>> params
.svc_ctx_
))
343 TAOLIB_ERROR ((LM_ERROR
,
344 ACE_TEXT ("TAO (%P|%t) parse_reply, ")
345 ACE_TEXT ("extracting context\n")));
351 if (cdr
.length () > 0)
353 // Align the read pointer on an 8-byte boundary
354 cdr
.align_read_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR
);
361 TAO_GIOP_Message_Generator_Parser_12::parse_locate_reply (
363 TAO_Pluggable_Reply_Params
¶ms
)
365 if (TAO_GIOP_Message_Generator_Parser::parse_locate_reply (cdr
, params
) == -1)
368 // Note: We dont align the pointer to an 8 byte boundary for a
369 // locate reply body. This is due to an urgent issue raised by Michi
370 // in the OMG. I discussed this with Michi today (09/07/2001) and I
371 // learn that this has been passed. Hence the change..
372 /*if (cdr.length () > 0)
374 // Align the read pointer on an 8-byte boundary
375 cdr.align_read_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR);
383 TAO_GIOP_Message_Generator_Parser_12::major_version () const
385 return static_cast<CORBA::Octet
> (1);
390 TAO_GIOP_Message_Generator_Parser_12::minor_version () const
392 return static_cast<CORBA::Octet
> (2);
396 TAO_GIOP_Message_Generator_Parser_12::is_ready_for_bidirectional () const
398 // We do support bidirectional
403 TAO_GIOP_Message_Generator_Parser_12::marshall_target_spec (
404 TAO_Target_Specification
&spec
,
407 switch (spec
.specifier ())
409 case TAO_Target_Specification::Key_Addr
:
411 // As this is a union send in the discriminant first
412 if (!(msg
<< GIOP::KeyAddr
))
415 // Get the object key
416 const TAO::ObjectKey
*key
= spec
.object_key ();
420 // Marshall in the object key
428 TAOLIB_DEBUG ((LM_DEBUG
,
429 ACE_TEXT ("(%N |%l) Unable to handle this request\n")));
435 case TAO_Target_Specification::Profile_Addr
:
437 // As this is a union send in the discriminant first
438 if (!(msg
<< GIOP::ProfileAddr
))
442 const IOP::TaggedProfile
*pfile
= spec
.profile ();
446 // Marshall in the object key
447 if (!(msg
<< *pfile
))
454 TAOLIB_DEBUG ((LM_DEBUG
,
455 ACE_TEXT ("(%N |%l) Unable to handle this request\n")));
461 case TAO_Target_Specification::Reference_Addr
:
463 // As this is a union send in the discriminant first
464 if (!(msg
<< GIOP::ReferenceAddr
))
468 IOP::IOR
*ior
= nullptr;
469 CORBA::ULong
const index
= spec
.iop_ior (ior
);
473 // This is a struct IORAddressingInfo. So, marshall each
474 // member of the struct one after another in the order
485 TAOLIB_DEBUG ((LM_DEBUG
,
486 ACE_TEXT ("(%N |%l) Unable to handle this request\n")));
495 TAOLIB_DEBUG ((LM_DEBUG
,
496 ACE_TEXT ("(%N |%l) Unable to handle this request\n")));
505 TAO_GIOP_Message_Generator_Parser_12::fragment_header_length () const
507 return TAO_GIOP_MESSAGE_FRAGMENT_HEADER
;
510 TAO_END_VERSIONED_NAMESPACE_DECL