1%%--------------------------------------------------------------------
2%%
3%% %CopyrightBegin%
4%%
5%% Copyright Ericsson AB 2000-2016. All Rights Reserved.
6%%
7%% Licensed under the Apache License, Version 2.0 (the "License");
8%% you may not use this file except in compliance with the License.
9%% You may obtain a copy of the License at
10%%
11%%     http://www.apache.org/licenses/LICENSE-2.0
12%%
13%% Unless required by applicable law or agreed to in writing, software
14%% distributed under the License is distributed on an "AS IS" BASIS,
15%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16%% See the License for the specific language governing permissions and
17%% limitations under the License.
18%%
19%% %CopyrightEnd%
20%%
21%%
22%%----------------------------------------------------------------------
23%% File    : orber_pi.erl
24%% Purpose :
25%% Comments:
26%% * Each Interceptor is represented by Module where
27%%              Module - refers to a module which must export the functions:
28%%                       (1)  receive_request
29%%                       (2)  send_other
30%%                       (3)  receive_service_contexts
31%%                       (4)  send_reply
32%%                       (5)  send_exception
33%%                       (6)  send_request
34%%                       (7)  send_poll
35%%                       (8)  receive_reply
36%%                       (9)  receive_exception
37%%                       (10) receive_other
38%%                       or
39%%                       (11) new_out_connection
40%%                       (12) new_in_connection
41%%                       (13) in_request
42%%                       (14) out_reply
43%%                       (15) out_request
44%%                       (16) in_reply
45%%
46%%              Functions (1) - (10) for Portable and (11) - (16) for
47%%              Native Interceptors.
48%%
49%%----------------------------------------------------------------------
50
51-module(orber_pi).
52
53%%--------------- INCLUDES -----------------------------------
54-include_lib("orber/include/corba.hrl").
55-include_lib("orber/include/ifr_types.hrl").
56-include_lib("orber/include/orber_pi.hrl").
57-include_lib("orber/src/orber_iiop.hrl").
58
59%%--------------- EXPORTS-------------------------------------
60%% API external
61-export([%% Native Intercepotors API
62	 new_out_connection/5,
63	 new_in_connection/5,
64	 closed_in_connection/2,
65	 closed_out_connection/2,
66	 in_request_enc/4,
67	 out_reply_enc/5,
68	 out_request_enc/6,
69	 in_reply_enc/6,
70	 in_request/4,
71	 out_reply/5,
72	 out_request/6,
73	 in_reply/6,
74	 %% Portable Interceptors
75	 server_start_receive/7,
76	 server_start_send/2,
77	 client_receive/2,
78	 client_send/2,
79	 codefactory_create_codec/1,
80	 codec_encode/2,
81	 codec_encode_value/2,
82	 codec_decode/2,
83	 codec_decode_value/3,
84	 %% RequestInfo
85	 '_get_request_id'/1,
86	 '_get_operation'/1,
87	 '_get_arguments'/1,
88	 '_get_exceptions'/1,
89	 '_get_contexts'/1,
90	 '_get_operation_context'/1,
91	 '_get_result'/1,
92	 '_get_response_expected'/1,
93	 '_get_sync_scope'/1,
94	 '_get_reply_status'/1,
95	 '_get_forward_reference'/1,
96	 get_slot/2,
97	 get_request_service_context/2,
98	 get_reply_service_context/2,
99	 %% ClientRequestInfo (inherrits RequestInfo)
100	 '_get_target'/1,
101	 '_get_effective_target'/1,
102	 '_get_effective_profile'/1,
103	 '_get_received_exception'/1,
104	 '_get_received_exception_id'/1,
105	 get_effective_component/2,
106	 get_effective_components/2,
107	 get_request_policy/2,
108	 add_request_service_policy/3,
109	 %% ServerRequestInfo (inherrits RequestInfo)
110	 '_get_sending_exception'/1,
111	 '_get_object_id'/1,
112	 '_get_adapter_id'/1,
113	 '_get_target_most_derived_interface'/1,
114	 get_server_policy/2,
115	 set_slot/3,
116	 target_is_a/2,
117	 add_reply_service_context/3]).
118
119%%=============== DATA STRUCTURES ============================
120%%--------------- ClientRequestInfo --------------------------
121-record('ClientRequestInfo',
122	{request_id,
123	 operation,
124	 arguments,
125	 exceptions,
126	 contexts,
127	 operation_context,
128	 result,
129	 response_expected,
130	 sync_scope = 'SYNC_NONE',
131	 reply_status,
132	 forward_reference,
133	 endian,
134	 target,
135	 effective_target,
136	 effective_profile,
137	 received_exception,
138	 received_exception_id}).
139
140-define(createInitCRI(_ReqID, _Op, _Args, _Ctxs, _OpCtx, _RespExp, _Target,
141		      _ETarget, _EProf),
142	#'ClientRequestInfo'{request_id        = _ReqID,
143			     operation         = _Op,
144			     arguments         = _Args,
145			     contexts          = _Ctxs,
146			     operation_context = _OpCtx,
147			     response_expected = _RespExp,
148			     target            = _Target,
149			     effective_target  = _ETarget,
150			     effective_profile = _EProf}).
151
152
153%%--------------- ServerRequestInfo --------------------------
154-record('ServerRequestInfo',
155	{request_id,
156	 operation,
157	 arguments,
158	 exceptions,
159	 contexts,
160	 operation_context,
161	 result,
162	 response_expected,
163	 sync_scope = 'SYNC_NONE',
164	 reply_status,
165	 forward_reference,
166	 endian,
167	 sending_exception,
168	 object_id,
169	 adapter_id,
170	 target_most_derived_interface}).
171
172-define(createInitSRI(_ReqID, _Op, _RespExp),
173	#'ServerRequestInfo'{request_id        = _ReqID,
174			     operation         = _Op,
175			     response_expected = _RespExp}).
176
177
178%%--------------- DEFINES ------------------------------------
179-define(DEBUG_LEVEL, 9).
180
181-define(EFORMAT(_F, _A), exit(lists:flatten(io_lib:format(_F, _A)))).
182
183%%------------------------------------------------------------
184%%------------- NATIVE INTERCEPTOR FUNCTIONS------------------
185%%------------------------------------------------------------
186%% function : new_in_connection
187%% Arguments:
188%% Returns  :
189%% Exception:
190%% Effect   :
191%%------------------------------------------------------------
192new_in_connection(PIs, Host, Port, SHost, SPort) ->
193    case catch new_in_connection(PIs, undefined, Host, Port, SHost, SPort) of
194	{'EXIT', R} ->
195	    orber:dbg("[~p] orber_pi:new_in_connection(~p); exit(~p)",
196		      [?LINE, PIs, R], ?DEBUG_LEVEL),
197	    ?EFORMAT("Supplied Interceptors unable to create a valid new_in_connection"
198		     "Reason: ~p", [{'EXIT', R}]);
199	{'EXCEPTION', E} ->
200	    orber:dbg("[~p] orber_pi:new_in_connection(~p); exception(~p)",
201		      [?LINE, PIs, E], ?DEBUG_LEVEL),
202	    ?EFORMAT("Supplied Interceptors unable to create a valid new_in_connection"
203		     "Reason: ~p", [{'EXCEPTION', E}]);
204	Ref ->
205	    Ref
206    end.
207
208new_in_connection([], Ref, _, _, _, _) ->
209    Ref;
210new_in_connection([Mod|T], Ref, Host, Port, SHost, SPort) ->
211    case get_arity(Mod, new_in_connection) of
212	5 ->
213	    NewRef = Mod:new_in_connection(Ref, Host, Port, SHost, SPort),
214	    new_in_connection(T, NewRef, Host, Port, SHost, SPort);
215	3 ->
216	    NewRef = Mod:new_in_connection(Ref, Host, Port),
217	    new_in_connection(T, NewRef, Host, Port, SHost, SPort)
218    end.
219
220get_arity(Mod, Func) ->
221    get_arity(Mod, Func, true).
222get_arity(Mod, Func, Retry) ->
223    case erlang:function_exported(Mod, Func, 5) of
224	true ->
225	    5;
226	false ->
227	    case erlang:function_exported(Mod, Func, 3) of
228		true ->
229		    3;
230		false when Retry == true ->
231		    {module, _} = code:ensure_loaded(Mod),
232		    get_arity(Mod, Func, false);
233		false ->
234		    exit("Unable to load interceptor")
235	    end
236    end.
237
238%%------------------------------------------------------------
239%% function : closed_in_connection
240%% Arguments:
241%% Returns  :
242%% Exception:
243%% Effect   :
244%%------------------------------------------------------------
245closed_in_connection(PIs, Ref) ->
246    case catch closed_in_connection_helper(PIs, Ref) of
247	{'EXIT', R} ->
248	    orber:dbg("[~p] orber_pi:closed_in_connection(~p, ~p); exit(~p)",
249		      [?LINE, PIs, Ref, R], ?DEBUG_LEVEL),
250	    ok;
251	{'EXCEPTION', E} ->
252	    orber:dbg("[~p] orber_pi:closed_in_connection(~p, ~p); exception(~p)",
253		      [?LINE, PIs, Ref, E], ?DEBUG_LEVEL),
254	    ok;
255	_ ->
256	    ok
257    end.
258
259closed_in_connection_helper([], _Ref) ->
260    ok;
261closed_in_connection_helper([Mod|T], Ref) ->
262    NewRef = Mod:closed_in_connection(Ref),
263    closed_in_connection_helper(T, NewRef).
264
265
266%%------------------------------------------------------------
267%% function : new_out_connection
268%% Arguments:
269%% Returns  :
270%% Exception:
271%% Effect   :
272%%------------------------------------------------------------
273new_out_connection(PIs, Host, Port, SHost, SPort) ->
274    case catch new_out_connection(PIs, undefined, Host, Port, SHost, SPort) of
275	{'EXIT', R} ->
276	    orber:dbg("[~p] orber_pi:new_out_connection(~p); exit(~p)",
277		      [?LINE, PIs, R], ?DEBUG_LEVEL),
278	    ?EFORMAT("Supplied Interceptors unable to create a valid new_out_connection"
279		     "Reason: ~p", [{'EXIT', R}]);
280	{'EXCEPTION', E} ->
281	    orber:dbg("[~p] orber_pi:new_out_connection(~p); exception(~p)",
282		      [?LINE, PIs, E], ?DEBUG_LEVEL),
283	    ?EFORMAT("Supplied Interceptors unable to create a valid new_out_connection"
284		     "Reason: ~p", [{'EXCEPTION', E}]);
285	Ref ->
286	    Ref
287    end.
288
289new_out_connection([], Ref, _, _, _, _) ->
290    Ref;
291new_out_connection([Mod|T], Ref, Host, Port, SHost, SPort) ->
292    case get_arity(Mod, new_out_connection) of
293	5 ->
294	    NewRef = Mod:new_out_connection(Ref, Host, Port, SHost, SPort),
295	    new_out_connection(T, NewRef, Host, Port, SHost, SPort);
296	3 ->
297	    NewRef = Mod:new_out_connection(Ref, Host, Port),
298	    new_out_connection(T, NewRef, Host, Port, SHost, SPort)
299    end.
300
301%%------------------------------------------------------------
302%% function : closed_out_connection
303%% Arguments:
304%% Returns  :
305%% Exception:
306%% Effect   :
307%%------------------------------------------------------------
308closed_out_connection(PIs, Ref) ->
309    case catch closed_out_connection_helper(PIs, Ref) of
310	{'EXIT', R} ->
311	    orber:dbg("[~p] orber_pi:closed_out_connection(~p); exit(~p)",
312		      [?LINE, PIs, R], ?DEBUG_LEVEL),
313	    ok;
314	{'EXCEPTION', E} ->
315	    orber:dbg("[~p] orber_pi:closed_out_connection(~p); exception(~p)",
316		      [?LINE, PIs, E], ?DEBUG_LEVEL),
317	    ok;
318	_ ->
319	    ok
320    end.
321
322closed_out_connection_helper([], _Ref) ->
323    ok;
324closed_out_connection_helper([Mod|T], Ref) ->
325    NewRef = Mod:closed_out_connection(Ref),
326    closed_out_connection_helper(T, NewRef).
327
328%%------------------------------------------------------------
329%% function : in_request_enc
330%% Arguments:
331%% Returns  :
332%% Exception:
333%% Effect   : Intercepts an incoming request (server-side).
334%%------------------------------------------------------------
335in_request_enc(PIs, ReqHdr, Ref, Msg) ->
336    case catch in_request_enc(PIs, ReqHdr, Ref, Msg, undefined) of
337	{'EXIT', R} ->
338	    orber:dbg("[~p] orber_pi:in_request_enc(~p, ~p, ~p); exit(~p)",
339		      [?LINE, PIs, Ref, Msg, R], ?DEBUG_LEVEL),
340	    corba:raise(#'MARSHAL'{completion_status=?COMPLETED_NO});
341	{'EXCEPTION', E} ->
342	    orber:dbg("[~p] orber_pi:in_request_enc(~p, ~p, ~p); exception(~p)",
343		      [?LINE, PIs, Ref, Msg, E], ?DEBUG_LEVEL),
344	    corba:raise(E);
345	NewMsg ->
346	    NewMsg
347    end.
348
349in_request_enc([], _, _, Msg, _) ->
350    Msg;
351in_request_enc([Mod|T], ReqHdr, Ref, Msg, Args) ->
352    {NewMsg, NewArgs} = Mod:in_request_encoded(Ref, ReqHdr#request_header.object_key,
353					       ReqHdr#request_header.service_context,
354					       ReqHdr#request_header.operation,
355					       Msg, Args),
356    in_request_enc(T, ReqHdr, Ref, NewMsg, NewArgs).
357
358%%------------------------------------------------------------
359%% function : in_request
360%% Arguments:
361%% Returns  :
362%% Exception:
363%% Effect   : Intercepts an incoming request (server-side).
364%%------------------------------------------------------------
365in_request(PIs, ReqHdr, Ref, Msg) ->
366    case catch in_request(PIs, ReqHdr, Ref, Msg, undefined) of
367	{'EXIT', R} ->
368	    orber:dbg("[~p] orber_pi:in_request(~p, ~p, ~p); exit(~p)",
369		      [?LINE, PIs, Ref, Msg, R], ?DEBUG_LEVEL),
370	    corba:raise(#'MARSHAL'{completion_status=?COMPLETED_NO});
371	{'EXCEPTION', E} ->
372	    orber:dbg("[~p] orber_pi:in_request(~p, ~p, ~p); exception(~p)",
373		      [?LINE, PIs, Ref, Msg, E], ?DEBUG_LEVEL),
374	    corba:raise(E);
375	NewMsg ->
376	    NewMsg
377    end.
378
379in_request([], _, _, Msg, _) ->
380    Msg;
381in_request([Mod|T], ReqHdr, Ref, Msg, Args) ->
382    {NewMsg, NewArgs} = Mod:in_request(Ref, ReqHdr#request_header.object_key,
383				       ReqHdr#request_header.service_context,
384				       ReqHdr#request_header.operation,
385				       Msg, Args),
386    in_request(T, ReqHdr, Ref, NewMsg, NewArgs).
387
388%%------------------------------------------------------------
389%% function : out_reply_enc
390%% Arguments:
391%% Returns  :
392%% Exception:
393%% Effect   : Intercept an outgoing reply (server-side).
394%%------------------------------------------------------------
395out_reply_enc(PIs, ReqHdr, Ref, Msg, Ctx) ->
396    case catch out_reply_enc(PIs, ReqHdr, Ref, Msg, undefined, Ctx) of
397	{'EXIT', R} ->
398	    orber:dbg("[~p] orber_pi:out_reply_enc(~p, ~p, ~p); exit(~p)",
399		      [?LINE, PIs, Ref, Msg, R], ?DEBUG_LEVEL),
400	    corba:raise(#'MARSHAL'{completion_status=?COMPLETED_MAYBE});
401	{'EXCEPTION', E} ->
402	    orber:dbg("[~p] orber_pi:out_reply_enc(~p, ~p, ~p); exception(~p)",
403		      [?LINE, PIs, Ref, Msg, E], ?DEBUG_LEVEL),
404	    corba:raise(E);
405	NewMsg ->
406	    NewMsg
407    end.
408out_reply_enc([], _, _, Msg, _, _) ->
409    Msg;
410out_reply_enc([Mod|T], ReqHdr, Ref, Msg, Args, Ctx) ->
411    {NewMsg, NewArgs} = Mod:out_reply_encoded(Ref, ReqHdr#request_header.object_key,
412					      Ctx, %% Out Context.
413					      ReqHdr#request_header.operation,
414					      Msg, Args),
415    out_reply_enc(T, ReqHdr, Ref, NewMsg, NewArgs, Ctx).
416
417
418%%------------------------------------------------------------
419%% function : out_reply
420%% Arguments:
421%% Returns  :
422%% Exception:
423%% Effect   : Intercept an outgoing reply (server-side).
424%%------------------------------------------------------------
425out_reply(PIs, ReqHdr, Ref, Msg, Ctx) ->
426    case catch out_reply(PIs, ReqHdr, Ref, Msg, undefined, Ctx) of
427	{'EXIT', R} ->
428	    orber:dbg("[~p] orber_pi:out_reply(~p, ~p, ~p); exit(~p)",
429		      [?LINE, PIs, Ref, Msg, R], ?DEBUG_LEVEL),
430	    corba:raise(#'MARSHAL'{completion_status=?COMPLETED_MAYBE});
431	NewMsg ->
432	    NewMsg
433    end.
434out_reply([], _, _, Msg, _, _) ->
435    Msg;
436out_reply([Mod|T], ReqHdr, Ref, Msg, Args, Ctx) ->
437    {NewMsg, NewArgs} = Mod:out_reply(Ref, ReqHdr#request_header.object_key,
438				      Ctx, %% Out Context.
439				      ReqHdr#request_header.operation,
440				      Msg, Args),
441    out_reply(T, ReqHdr, Ref, NewMsg, NewArgs, Ctx).
442
443
444%%------------------------------------------------------------
445%% function : out_request_enc
446%% Arguments:
447%% Returns  :
448%% Exception:
449%% Effect   : Intercept an outgoing request (client-side).
450%%------------------------------------------------------------
451out_request_enc(PIs, ObjKey, Ctx, Op, Ref, Msg) ->
452    case catch out_request_enc(PIs, ObjKey, Ctx, Op, Ref, Msg, undefined) of
453	{'EXIT', R} ->
454	    orber:dbg("[~p] orber_pi:out_request_enc(~p, ~p, ~p); exit(~p)",
455		      [?LINE, PIs, Ref, Msg, R], ?DEBUG_LEVEL),
456	    corba:raise(#'MARSHAL'{completion_status=?COMPLETED_NO});
457	{'EXCEPTION', E} ->
458	    orber:dbg("[~p] orber_pi:out_request_enc(~p, ~p, ~p); exception(~p)",
459		      [?LINE, PIs, Ref, Msg, E], ?DEBUG_LEVEL),
460	    corba:raise(E);
461	NewMsg ->
462	    NewMsg
463    end.
464
465out_request_enc([], _, _, _, _, Msg, _) ->
466    Msg;
467out_request_enc([Mod|T], ObjKey, Ctx, Op, Ref, Msg, Args) ->
468    {NewMsg, NewArgs} = Mod:out_request_encoded(Ref, ObjKey, Ctx, Op, Msg, Args),
469    out_request_enc(T, ObjKey, Ctx, Op, Ref, NewMsg, NewArgs).
470
471
472%%------------------------------------------------------------
473%% function : out_request
474%% Arguments:
475%% Returns  :
476%% Exception:
477%% Effect   : Intercept an outgoing request (client-side).
478%%------------------------------------------------------------
479out_request(PIs, ObjKey, Ctx, Op, Ref, Msg) ->
480    case catch out_request(PIs, ObjKey, Ctx, Op, Ref, Msg, undefined) of
481	{'EXIT', R} ->
482	    orber:dbg("[~p] orber_pi:out_request(~p, ~p, ~p); exit(~p)",
483		      [?LINE, PIs, Ref, Msg, R], ?DEBUG_LEVEL),
484	    corba:raise(#'MARSHAL'{completion_status=?COMPLETED_NO});
485	{'EXCEPTION', E} ->
486	    orber:dbg("[~p] orber_pi:out_request(~p, ~p, ~p); exception(~p)",
487		      [?LINE, PIs, Ref, Msg, E], ?DEBUG_LEVEL),
488	    corba:raise(E);
489	NewMsg ->
490	    NewMsg
491    end.
492
493out_request([], _, _, _, _, Msg, _) ->
494    Msg;
495out_request([Mod|T], ObjKey, Ctx, Op, Ref, Msg, Args) ->
496    {NewMsg, NewArgs} = Mod:out_request(Ref, ObjKey, Ctx, Op, Msg, Args),
497    out_request(T, ObjKey, Ctx, Op, Ref, NewMsg, NewArgs).
498
499
500%%------------------------------------------------------------
501%% function :in_reply_enc
502%% Arguments:
503%% Returns  :
504%% Exception:
505%% Effect   : Intercept an incoming reply (client-side)
506%%------------------------------------------------------------
507in_reply_enc(PIs, ObjKey, Ctx, Op, Ref, Msg) ->
508    case catch in_reply_enc(PIs, ObjKey, Ctx, Op, Ref, Msg, undefined) of
509	{'EXIT', R} ->
510	    orber:dbg("[~p] orber_pi:in_reply_enc(~p, ~p, ~p); exit(~p)",
511		      [?LINE, PIs, Ref, Msg, R], ?DEBUG_LEVEL),
512	    corba:raise(#'MARSHAL'{completion_status=?COMPLETED_MAYBE});
513	{'EXCEPTION', E} ->
514	    orber:dbg("[~p] orber_pi:in_reply_enc(~p, ~p, ~p); exception(~p)",
515		      [?LINE, PIs, Ref, Msg, E], ?DEBUG_LEVEL),
516	    corba:raise(E);
517	NewMsg ->
518	    NewMsg
519    end.
520
521in_reply_enc([], _, _, _, _, Msg, _) ->
522    Msg;
523in_reply_enc([Mod|T], ObjKey, Ctx, Op, Ref, Msg, Args) ->
524    {NewMsg, NewArgs} = Mod:in_reply_encoded(Ref, ObjKey, Ctx, Op, Msg, Args),
525    in_reply_enc(T, ObjKey, Ctx, Op, Ref, NewMsg, NewArgs).
526
527%%------------------------------------------------------------
528%% function :in_reply
529%% Arguments:
530%% Returns  :
531%% Exception:
532%% Effect   : Intercept an incoming reply (client-side)
533%%------------------------------------------------------------
534in_reply(PIs, ObjKey, Ctx, Op, Ref, Msg) ->
535    case catch in_reply(PIs, ObjKey, Ctx, Op, Ref, Msg, undefined) of
536	{'EXIT', R} ->
537	    orber:dbg("[~p] orber_pi:in_reply(~p, ~p, ~p); exit(~p)",
538		      [?LINE, PIs, Ref, Msg, R], ?DEBUG_LEVEL),
539	    corba:raise(#'MARSHAL'{completion_status=?COMPLETED_MAYBE});
540	NewMsg ->
541	    NewMsg
542    end.
543
544in_reply([], _, _, _, _, Msg, _) ->
545    Msg;
546in_reply([Mod|T], ObjKey, Ctx, Op, Ref, Msg, Args) ->
547    {NewMsg, NewArgs} = Mod:in_reply(Ref, ObjKey, Ctx, Op, Msg, Args),
548    in_reply(T, ObjKey, Ctx, Op, Ref, NewMsg, NewArgs).
549
550
551
552
553%%------------------------------------------------------------
554%%------------- CODEC FUNCTIONS ------------------------------
555%%------------------------------------------------------------
556%% function : codefactory_create_codec
557%% Arguments: #IOP_N_Encoding{}
558%% Returns  : CodecRef
559%% Exception:
560%% Effect   :
561%%------------------------------------------------------------
562codefactory_create_codec(#'IOP_N_Encoding'{format = 'IOP_N_ENCODING_CDR_ENCAPS',
563					   major_version = Major,
564					   minor_version = Minor})
565  when is_integer(Major) andalso is_integer(Minor) ->
566    {Major, Minor};
567codefactory_create_codec(_) ->
568    corba:raise(#'IOP_N_CodecFactory_UnknownEncoding'{}).
569
570%%------------------------------------------------------------
571%% function : codec_encode
572%% Arguments: Version - GIOP version
573%%            Any - #any{}
574%% Returns  : CORBA::OctetSeq
575%% Exception:
576%% Effect   :
577%%------------------------------------------------------------
578codec_encode(Version, Any) when is_record(Any, any) ->
579    %% Encode ByteOrder
580    {Bytes, Len} = cdr_encode:enc_type('tk_octet', Version, 0, [], 0),
581    {Bytes2, _Len2} = cdr_encode:enc_type('tk_any', Version, Any, Bytes, Len),
582    list_to_binary(lists:reverse(Bytes2));
583codec_encode(_Version, _Any) ->
584    corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).
585
586%%------------------------------------------------------------
587%% function : codec_encode_value
588%% Arguments: Version - GIOP version
589%%            Any - #any{}
590%% Returns  : CORBA::OctetSeq
591%% Exception:
592%% Effect   : Encode the Any#any.value only.
593%%------------------------------------------------------------
594codec_encode_value(Version, #any{typecode = TC, value = Val}) ->
595    %% Encode ByteOrder
596    {Bytes, Len} = cdr_encode:enc_type('tk_octet', Version, 0, [], 0),
597    {Bytes2, _Len2} = cdr_encode:enc_type(TC, Version, Val, Bytes, Len),
598    list_to_binary(lists:reverse(Bytes2));
599codec_encode_value(_Version, _NotAnAny) ->
600    corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).
601
602%%------------------------------------------------------------
603%% function : codec_decode
604%% Arguments: Version - GIOP version
605%%            Bytes - CORBA::OctetSeq
606%% Returns  : Any - #any{}
607%% Exception:
608%% Effect   :
609%%------------------------------------------------------------
610codec_decode(Version, Bytes) when is_binary(Bytes) ->
611    {ByteOrder, Rest} = cdr_decode:dec_byte_order(Bytes),
612    case catch cdr_decode:dec_type('tk_any', Version, Rest, 0, ByteOrder) of
613	{Any, [], _} ->
614	    Any;
615	_->
616	    corba:raise(#'IOP_N_Codec_FormatMismatch'{})
617    end;
618codec_decode(_Version, _Any) ->
619    corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).
620
621%%------------------------------------------------------------
622%% function : codec_decode_value
623%% Arguments: Version - GIOP version
624%%            Bytes - CORBA::OctetSeq
625%%            TypeCode - CORBA::TypeCode
626%% Returns  : Any - #any{}
627%% Exception:
628%% Effect   :
629%%------------------------------------------------------------
630codec_decode_value(Version, Bytes, TypeCode) when is_binary(Bytes) ->
631    {ByteOrder, Rest} = cdr_decode:dec_byte_order(Bytes),
632    case catch cdr_decode:dec_type(TypeCode, Version, Rest, 0, ByteOrder) of
633	{Val, [], _} ->
634	    #any{typecode = TypeCode, value = Val};
635	_->
636	    corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO})
637    end;
638codec_decode_value(_Version, _Bytes, _TypeCode) ->
639    corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).
640
641
642%%------------------------------------------------------------
643%%------------- SERVER SIDE FUNCTIONS ------------------------
644%%------------------------------------------------------------
645%% To make a long story short, you find an conceptual description
646%% of how, and in which order, the different functions is
647%% supposed to be invoked.
648%%
649%%request_from_iiop(Bytes) ->
650%%    Reply =
651%%	case receive_service_contexts(ServerRequestInfo) of
652%%	    SYSTEM EXC ->
653%%		send_exception(..);
654%%	    ForwardRequest EXC ->
655%%		send_other(..);
656%%	    NoEXC ->
657%%		case receive_request(..) of
658%%		    SYSTEM EXC ->
659%%			send_exception(..);
660%%		    ForwardRequest EXC ->
661%%			send_other(..);
662%%		    No EXC ->
663%%			InvokeServer
664%%		end
665%%	end,
666%%    case Reply of
667%%	EXC ->
668%%	    send_exception(..);
669%%	No EXC, Normal Reply ->
670%%	    case send_reply(..) of
671%%		SYSTEM EXC ->
672%%		    send_exception(..);
673%%		ForwardRequest EXC ->
674%%		    send_other(..);
675%%		No Exc ->
676%%		    Done
677%%	    end;
678%%	No EXC, LOCATION_FORWARD ->
679%%	    send_other(..)
680%%    end.
681%%
682%%
683%%------------------------------------------------------------
684%% function : server_start_receive
685%% Arguments: Msg - #giop_message{}
686%%            PIs - a list of Interceptors (see 'Comments' in the module header)
687%% Returns  :
688%% Exception:
689%% Effect   :
690%%------------------------------------------------------------
691server_start_receive(PIs, Version, ReqHdr, Rest, Len, ByteOrder, Msg) ->
692    cdr_decode:dec_request_body(Version, ReqHdr, Rest, Len, ByteOrder, Msg),
693    SRI = ?createInitSRI(ReqHdr#request_header.request_id,
694			 ReqHdr#request_header.operation,
695			 ReqHdr#request_header.response_expected),
696    server_receive(receive_service_contexts, SRI, PIs, [], PIs).
697
698server_receive(receive_service_contexts, SRI, [], _Acc, PIs) ->
699    server_receive(receive_request, SRI, PIs, [], PIs);
700server_receive(receive_service_contexts, SRI, [H|T], Acc, PIs) ->
701    case catch receive_service_contexts(SRI, H) of
702	{'EXCEPTION', #'PortableInterceptor_ForwardRequest'{forward=_Obj,
703							    permanent=_Bool}} ->
704	    server_send(send_other, SRI, Acc, [], PIs);
705	{'EXCEPTION', _E} ->
706	    server_send(send_exception, SRI, Acc, [], PIs);
707	_ ->
708	    server_receive(receive_service_contexts, SRI, T, Acc, PIs)
709    end;
710server_receive(receive_request, SRI, [], _Acc, _PIs) ->
711    %% Done with receive interceptors, now we can call the server.
712    SRI;
713server_receive(receive_request, SRI, [H|T], Acc, PIs)  ->
714    case catch receive_request(SRI, H) of
715	{'EXCEPTION', #'PortableInterceptor_ForwardRequest'{forward=_Obj,
716							    permanent=_Bool}} ->
717	    server_send(send_other, SRI, Acc, [], PIs);
718	{'EXCEPTION', _E} ->
719	    server_send(send_exception, SRI, Acc, [], PIs);
720	_ ->
721	    server_receive(receive_request, SRI, T, Acc, PIs)
722    end.
723
724
725%%------------------------------------------------------------
726%% function : server_start_send
727%% Arguments: SRI - ServerRequestInfo
728%%            PIs - a list of Interceptors (see 'Comments' in the module header)
729%% Returns  :
730%% Exception:
731%% Effect   :
732%%------------------------------------------------------------
733server_start_send(PIs, SRI) ->
734    case SRI#'ServerRequestInfo'.reply_status of
735	'PortableInterceptor_SUCCESSFUL' ->
736	    server_send(send_reply, SRI, PIs, [], PIs);
737	'PortableInterceptor_SYSTEM_EXCEPTION' ->
738	    server_send(send_exception, SRI, PIs, [], PIs);
739	'PortableInterceptor_USER_EXCEPTION' ->
740	    server_send(send_exception, SRI, PIs, [], PIs);
741	_ ->
742	    server_send(send_other, SRI, PIs, [], PIs)
743    end.
744
745server_send(_, SRI, [], _Acc, _PIs) ->
746    %% Done
747    SRI;
748server_send(send_exception, SRI, [H|T], Acc, PIs) ->
749    case catch send_exception(SRI, H) of
750	{'EXCEPTION', #'PortableInterceptor_ForwardRequest'{forward=_Obj,
751							    permanent=_Bool}} ->
752	    server_send(send_other, SRI, Acc, [], PIs);
753	{'EXCEPTION', _E} ->
754	    server_send(send_exception, SRI, Acc, [], PIs);
755	_ ->
756	    server_send(send_exception, SRI, T, Acc, PIs)
757    end;
758server_send(send_other, SRI, [H|T], Acc, PIs) ->
759    case catch send_other(SRI, H) of
760	{'EXCEPTION', #'PortableInterceptor_ForwardRequest'{forward=_Obj,
761							    permanent=_Bool}} ->
762	    server_send(send_other, SRI, T, Acc, PIs);
763	{'EXCEPTION', _E} ->
764	    server_send(send_exception, SRI, T, Acc, PIs);
765	_ ->
766	    server_send(send_other, SRI, T, Acc, PIs)
767    end;
768server_send(send_reply, SRI, [H|T], Acc, PIs) ->
769    case catch send_reply(SRI, H) of
770	{'EXCEPTION', _E} ->
771	    server_send(send_exception, SRI, T, Acc, PIs);
772	_ ->
773	    server_send(send_reply, SRI, T, Acc, PIs)
774    end.
775
776receive_request(SRI, Mod) ->
777    apply(Mod, receive_request, [SRI]).
778
779send_other(SRI, Mod) ->
780    apply(Mod, send_other, [SRI]).
781
782receive_service_contexts(SRI, Mod) ->
783    apply(Mod, receive_service_contexts, [SRI]).
784
785send_reply(SRI, Mod) ->
786    apply(Mod, send_reply, [SRI]).
787
788send_exception(SRI, Mod) ->
789    apply(Mod, send_exception, [SRI]).
790
791
792%%------------------------------------------------------------
793%%------------- CLIENT SIDE FUNCTIONS ------------------------
794%%------------------------------------------------------------
795%% To make a long story short, you find an conceptual description
796%% of how, and in which order, the different functions is
797%% supposed to be invoked.
798%%
799%%request(Data) ->
800%%    Reply =
801%%	case send_request(CRI) of
802%%	    SYSTEM EXC ->
803%%		receive_exception(..);
804%%	    ForwardRequest EXC ->
805%%		receive_other(..);
806%%	    NoEXC ->
807%%		IIOP-send
808%%	end,
809%%    case Reply of
810%%	EXC ->
811%%	    receive_exception(..); May raise system exc => receive_other(..);
812%%	No EXC, Normal Reply ->
813%%	    receive_reply(..) May raise system exc => receive_exception(..);
814%%	Non-normal reply (e.g. LOCATION_FORWARD) ->
815%%	    receive_other(..) May raise system exc => receive_exception(..);
816%%    end.
817%%------------------------------------------------------------
818%% function : client_send
819%% Arguments: CRI - ClientRequestInfo
820%%            PIs - a list of Interceptors (see 'Comments' in the module header)
821%% Returns  :
822%% Exception:
823%% Effect   :
824%%------------------------------------------------------------
825
826client_send(CRI, PIs) ->
827    client_send(send_request, CRI, PIs, [], PIs).
828
829client_send(send_request, CRI, [], _, _) ->
830    CRI;
831client_send(send_request, CRI, [H|T], Acc, PIs) ->
832    case catch send_request(CRI, H) of
833	{'EXCEPTION', #'PortableInterceptor_ForwardRequest'{forward=_Obj,
834							    permanent=_Bool}} ->
835	    client_receive(receive_other, CRI, T, [], PIs);
836	{'EXCEPTION', _E} ->
837	    client_receive(receive_exception, CRI, Acc, [], PIs);
838	_ ->
839	    client_send(send_request, CRI, T, Acc, PIs)
840    end.
841
842
843
844%%------------------------------------------------------------
845%% function : client_receive
846%% Arguments: CRI - ClientRequestInfo
847%%            PIs - a list of Interceptors (see 'Comments' in the module header)
848%% Returns  :
849%% Exception:
850%% Effect   :
851%%------------------------------------------------------------
852
853client_receive(CRI, PIs) ->
854    case CRI#'ClientRequestInfo'.reply_status of
855	'PortableInterceptor_SUCCESSFUL' ->
856	    client_receive(receive_reply, CRI, PIs, [], PIs);
857	'PortableInterceptor_SYSTEM_EXCEPTION' ->
858	    client_receive(receive_exception, CRI, PIs, [], PIs);
859	'PortableInterceptor_USER_EXCEPTION' ->
860	    client_receive(receive_exception, CRI, PIs, [], PIs);
861	_ ->
862	    client_receive(receive_other, CRI, PIs, [], PIs)
863    end.
864
865client_receive(_, CRI, [], _, _) ->
866    %% Done
867    CRI;
868client_receive(receive_reply, CRI, [H|T], Acc, PIs) ->
869    case catch receive_reply(CRI, H) of
870	{'EXCEPTION', _E} ->
871	    client_receive(receive_exception, CRI, T, [H|Acc], PIs);
872	_ ->
873	    client_receive(receive_reply, CRI, T, [H|Acc], PIs)
874    end;
875client_receive(receive_exception, CRI, [H|T], Acc, PIs) ->
876    case catch receive_exception(CRI, H) of
877	{'EXCEPTION', #'PortableInterceptor_ForwardRequest'{forward=_Obj,
878							    permanent=_Bool}} ->
879	    client_receive(receive_other, CRI, T, [], PIs);
880	{'EXCEPTION', _E} ->
881	    client_receive(receive_exception, CRI, T, [H|Acc], PIs);
882	_ ->
883	    client_receive(receive_exception, CRI, T, [H|Acc], PIs)
884    end;
885client_receive(receive_other, CRI, [H|T], Acc, PIs) ->
886    case catch receive_other(CRI, H) of
887	{'EXCEPTION', #'PortableInterceptor_ForwardRequest'{forward=_Obj,
888							    permanent=_Bool}} ->
889	    client_receive(receive_other, CRI, T, [], PIs);
890	{'EXCEPTION', _E} ->
891	    client_receive(receive_exception, CRI, T, [H|Acc], PIs);
892	_ ->
893	    client_receive(receive_other, CRI, T, [H|Acc], PIs)
894    end.
895
896
897
898send_request(CRI, Mod) ->
899    apply(Mod, send_request, [CRI]).
900
901receive_reply(CRI, Mod) ->
902    apply(Mod, receive_reply, [CRI]).
903
904receive_other(CRI, Mod) ->
905    apply(Mod, receive_other, [CRI]).
906
907receive_exception(CRI, Mod) ->
908    apply(Mod, receive_exception, [CRI]).
909
910%%------------------------------------------------------------
911%% Functions for retrieving info from RequestInfo
912%% ServerRequestInfo and ClientRequestInfo. The ones matching
913%% both ServerRequestInfo and ClientRequestInfo eq. RequestInfo.
914%% Note, RequestInfo is inherrited by the others.
915%%------------------------------------------------------------
916%%-----------------------------------------------------------%
917%% function : _get_request_id
918%% Arguments: ClientRequestInfo or ServerRequestInfo
919%% Returns  : ulong()
920%%------------------------------------------------------------
921'_get_request_id'(#'ClientRequestInfo'{request_id = ID}) ->
922    ID;
923'_get_request_id'(#'ServerRequestInfo'{request_id = ID}) ->
924    ID.
925
926%%-----------------------------------------------------------%
927%% function : _get_operation
928%% Arguments: ClientRequestInfo or ServerRequestInfo
929%% Returns  : string()
930%%------------------------------------------------------------
931'_get_operation'(#'ClientRequestInfo'{operation = Op}) ->
932    Op;
933'_get_operation'(#'ServerRequestInfo'{operation = Op}) ->
934    Op.
935
936%%-----------------------------------------------------------%
937%% function : _get_arguments
938%% Arguments: ClientRequestInfo or ServerRequestInfo
939%% Returns  : A list of #'Dynamic_Parameter'{}
940%%------------------------------------------------------------
941'_get_arguments'(#'ClientRequestInfo'{arguments = Args}) ->
942    Args;
943'_get_arguments'(#'ServerRequestInfo'{arguments = Args}) ->
944    Args.
945
946%%-----------------------------------------------------------%
947%% function : _get_exceptions
948%% Arguments: ClientRequestInfo or ServerRequestInfo
949%% Returns  : A list of CORBA::TypeCode
950%%------------------------------------------------------------
951'_get_exceptions'(#'ClientRequestInfo'{exceptions = Exc}) ->
952    Exc;
953'_get_exceptions'(#'ServerRequestInfo'{exceptions = Exc}) ->
954    Exc.
955
956%%-----------------------------------------------------------%
957%% function : _get_contexts
958%% Arguments: ClientRequestInfo or ServerRequestInfo
959%% Returns  : A list of CORBA::StringSeq
960%%------------------------------------------------------------
961'_get_contexts'(#'ClientRequestInfo'{contexts = Ctx}) ->
962    Ctx;
963'_get_contexts'(#'ServerRequestInfo'{contexts = Ctx}) ->
964    Ctx.
965
966%%-----------------------------------------------------------%
967%% function : _get_operation_context
968%% Arguments: ClientRequestInfo or ServerRequestInfo
969%% Returns  : A list of CORBA::StringSeq
970%%------------------------------------------------------------
971'_get_operation_context'(#'ClientRequestInfo'{operation_context = OpCtx}) ->
972    OpCtx;
973'_get_operation_context'(#'ServerRequestInfo'{operation_context = OpCtx}) ->
974    OpCtx.
975
976%%-----------------------------------------------------------%
977%% function : _get_result
978%% Arguments: ClientRequestInfo or ServerRequestInfo
979%% Returns  : #any{}
980%%------------------------------------------------------------
981'_get_result'(#'ClientRequestInfo'{result = Res}) ->
982    Res;
983'_get_result'(#'ServerRequestInfo'{result = Res}) ->
984    Res.
985
986%%-----------------------------------------------------------%
987%% function : _get_response_expected
988%% Arguments: ClientRequestInfo or ServerRequestInfo
989%% Returns  : boolean()
990%%------------------------------------------------------------
991'_get_response_expected'(#'ClientRequestInfo'{response_expected = Bool}) ->
992    Bool;
993'_get_response_expected'(#'ServerRequestInfo'{response_expected = Bool}) ->
994    Bool.
995
996%%-----------------------------------------------------------%
997%% function : _get_sync_scope
998%% Arguments: ClientRequestInfo or ServerRequestInfo
999%% Returns  : Messaging::SyncScoope ('SYNC_NONE', 'SYNC_WITH_TRANSPORT',
1000%%            'SYNC_WITH_SERVER', 'SYNC_WITH_TARGET')
1001%%------------------------------------------------------------
1002'_get_sync_scope'(#'ClientRequestInfo'{sync_scope = SS}) ->
1003    SS;
1004'_get_sync_scope'(#'ServerRequestInfo'{sync_scope = SS}) ->
1005    SS.
1006
1007%%-----------------------------------------------------------%
1008%% function : _get_reply_status
1009%% Arguments: ClientRequestInfo or ServerRequestInfo
1010%% Returns  : ReplyStatus (short), defined in orber_pi.hrl
1011%%------------------------------------------------------------
1012'_get_reply_status'(#'ClientRequestInfo'{reply_status = RS}) ->
1013    RS;
1014'_get_reply_status'(#'ServerRequestInfo'{reply_status = RS}) ->
1015    RS.
1016
1017%%-----------------------------------------------------------%
1018%% function : _get_forward_reference
1019%% Arguments: ClientRequestInfo or ServerRequestInfo
1020%% Returns  : Object
1021%%------------------------------------------------------------
1022'_get_forward_reference'(#'ClientRequestInfo'{forward_reference = FR}) ->
1023    FR;
1024'_get_forward_reference'(#'ServerRequestInfo'{forward_reference = FR}) ->
1025    FR.
1026
1027%%------------------------------------------------------------
1028%% function : get_slot
1029%% Arguments: ClientRequestInfo or ServerRequestInfo
1030%%            SlotId - ulong()
1031%% Returns  : {'EXCEPTION', #'PortableInterceptor_InvalidSlot'{}}
1032%%------------------------------------------------------------
1033-spec get_slot(_, _) -> no_return().
1034get_slot(_XRI, _SlotId) ->
1035    corba:raise(#'PortableInterceptor_InvalidSlot'{}).
1036
1037%%------------------------------------------------------------
1038%% function : get_request_service_context
1039%% Arguments: ClientRequestInfo or ServerRequestInfo
1040%%            ServiceId - IOP::ServiceId (defined in orber_iiop.hrl)
1041%% Returns  : IOP::ServiceContext
1042%%------------------------------------------------------------
1043get_request_service_context(#'ClientRequestInfo'{contexts = Ctx}, _ServiceId) ->
1044    Ctx;
1045get_request_service_context(#'ServerRequestInfo'{contexts = Ctx}, _ServiceId) ->
1046    Ctx.
1047
1048%%------------------------------------------------------------
1049%% function : get_reply_service_context
1050%% Arguments: ClientRequestInfo or ServerRequestInfo
1051%%            ServiceId - IOP::ServiceId (defined in orber_iiop.hrl)
1052%% Returns  :  IOP::ServiceContext
1053%%------------------------------------------------------------
1054get_reply_service_context(#'ClientRequestInfo'{contexts = Ctx}, _ServiceId) ->
1055    Ctx;
1056get_reply_service_context(#'ServerRequestInfo'{contexts = Ctx}, _ServiceId) ->
1057    Ctx.
1058
1059%%------------------------------------------------------------
1060%%-------------- ClientRequestInfo only ----------------------
1061%%-----------------------------------------------------------%
1062%% function : _get_target
1063%% Arguments: ClientRequestInfo
1064%% Returns  : Object
1065%%------------------------------------------------------------
1066'_get_target'(#'ClientRequestInfo'{target = Target}) ->
1067    Target.
1068
1069%%-----------------------------------------------------------%
1070%% function : _get_effective_target
1071%% Arguments: ClientRequestInfo
1072%% Returns  : Object
1073%%------------------------------------------------------------
1074'_get_effective_target'(#'ClientRequestInfo'{effective_target = ET}) ->
1075    ET.
1076
1077%%-----------------------------------------------------------%
1078%% function : _get_effective_profile
1079%% Arguments: ClientRequestInfo
1080%% Returns  : IOP:TaggedProfile
1081%%------------------------------------------------------------
1082'_get_effective_profile'(#'ClientRequestInfo'{effective_profile = EP}) ->
1083    EP.
1084
1085%%-----------------------------------------------------------%
1086%% function : _get_received_exception
1087%% Arguments: ClientRequestInfo
1088%% Returns  : #any{}
1089%%------------------------------------------------------------
1090'_get_received_exception'(#'ClientRequestInfo'{received_exception = RE}) ->
1091    RE.
1092
1093%%-----------------------------------------------------------%
1094%% function : _get_received_exception
1095%% Arguments: ClientRequestInfo
1096%% Returns  : CORBA::RepositoryId
1097%%------------------------------------------------------------
1098'_get_received_exception_id'(#'ClientRequestInfo'{received_exception_id = REId}) ->
1099    REId.
1100
1101%%------------------------------------------------------------
1102%% function : get_effective_component
1103%% Arguments: ClientRequestInfo
1104%% Returns  : IOR::TaggedComponent
1105%%------------------------------------------------------------
1106get_effective_component(#'ClientRequestInfo'{target = Target}, _Id) ->
1107    Target.
1108
1109%%------------------------------------------------------------
1110%% function : get_effective_components
1111%% Arguments: ClientRequestInfo
1112%%            Id -IOP::ComponentId (ulong())
1113%% Returns  : IOP_N::TaggedComponentSeq
1114%%------------------------------------------------------------
1115get_effective_components(#'ClientRequestInfo'{target = Target}, _Id) ->
1116    Target.
1117
1118%%------------------------------------------------------------
1119%% function : get_request_policy
1120%% Arguments: ClientRequestInfo
1121%%            Type - CORBA::PolicyType
1122%% Returns  : IOP_N::TaggedComponentSeq
1123%%------------------------------------------------------------
1124get_request_policy(#'ClientRequestInfo'{target = Target}, _Type) ->
1125    Target.
1126
1127%%------------------------------------------------------------
1128%% function : add_request_service_context
1129%% Arguments: ClientRequestInfo
1130%%            Ctx - IOP::ServiceContext
1131%%            Replace - boolean()
1132%% Returns  : -
1133%%------------------------------------------------------------
1134add_request_service_policy(#'ClientRequestInfo'{target = _Target},
1135			   _Ctx, _Replace) ->
1136    ok.
1137
1138%%------------------------------------------------------------
1139%%-------------- ServerRequestInfo only ----------------------
1140%%-----------------------------------------------------------%
1141%% function : _get_sending_exception
1142%% Arguments: ServerRequestInfo
1143%% Returns  : #any{}
1144%%------------------------------------------------------------
1145'_get_sending_exception'(#'ServerRequestInfo'{sending_exception = Exc}) ->
1146    Exc.
1147
1148%%-----------------------------------------------------------%
1149%% function : _get_object_id
1150%% Arguments: ServerRequestInfo
1151%% Returns  : CORBA::OctetSeq
1152%%------------------------------------------------------------
1153'_get_object_id'(#'ServerRequestInfo'{object_id = OI}) ->
1154    OI.
1155
1156%%-----------------------------------------------------------%
1157%% function : _get_adapter_id
1158%% Arguments: ServerRequestInfo
1159%% Returns  : CORBA::OctetSeq
1160%%------------------------------------------------------------
1161'_get_adapter_id'(#'ServerRequestInfo'{adapter_id = AI}) ->
1162    AI.
1163
1164%%-----------------------------------------------------------%
1165%% function : _get_target_most_derived_interface
1166%% Arguments: ServerRequestInfo
1167%% Returns  : CORBA::RepositoryId
1168%%------------------------------------------------------------
1169'_get_target_most_derived_interface'(#'ServerRequestInfo'
1170				     {target_most_derived_interface = TMDI}) ->
1171    TMDI.
1172
1173%%------------------------------------------------------------
1174%% function : get_server_policy
1175%% Arguments: ServerRequestInfo
1176%%            PolicyType - CORBA::PolicyType
1177%% Returns  : CORBA::Policy
1178%%------------------------------------------------------------
1179get_server_policy(#'ServerRequestInfo'{contexts = Ctxs}, _PolicyType) ->
1180    Ctxs.
1181
1182%%------------------------------------------------------------
1183%% function : set_slot
1184%% Arguments: ServerRequestInfo
1185%%            SlotId - ulong()
1186%%            Data - #any{}
1187%% Returns  : {'EXCEPTION', #'PortableInterceptor_InvalidSlot'{}}
1188%%------------------------------------------------------------
1189-spec set_slot(_, _, _) -> no_return().
1190set_slot(_SRI, _SlotId, _Data) ->
1191    corba:raise(#'PortableInterceptor_InvalidSlot'{}).
1192
1193%%-----------------------------------------------------------%
1194%% function : target_is_a
1195%% Arguments: ServerRequestInfo
1196%%            IFRId - CORBA::RepositoryId
1197%% Returns  : boolean()
1198%%------------------------------------------------------------
1199target_is_a(#'ServerRequestInfo'{object_id = ObjId}, IFRId) ->
1200    corba_object:is_a(ObjId, IFRId).
1201
1202%%------------------------------------------------------------
1203%% function : add_reply_service_context
1204%% Arguments: ServerRequestInfo
1205%%            Ctx - IOP::ServiceContext
1206%%            Replace - boolean()
1207%% Returns  : -
1208%%------------------------------------------------------------
1209add_reply_service_context(#'ServerRequestInfo'{contexts = Ctxs}, _Ctx, _Replace) ->
1210    Ctxs.
1211
1212
1213%%--------------- END OF MODULE ------------------------------
1214