iop_ior.erl
来自「OTP是开放电信平台的简称」· ERL 代码 · 共 1,532 行 · 第 1/5 页
ERL
1,532 行
%%--------------------------------------------------------------------%% ``The contents of this file are subject to the Erlang Public License,%% Version 1.1, (the "License"); you may not use this file except in%% compliance with the License. You should have received a copy of the%% Erlang Public License along with this software. If not, it can be%% retrieved via the world wide web at http://www.erlang.org/.%% %% Software distributed under the License is distributed on an "AS IS"%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See%% the License for the specific language governing rights and limitations%% under the License.%% %% The Initial Developer of the Original Code is Ericsson Utvecklings AB.%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings%% AB. All Rights Reserved.''%% %% $Id$%%%%-----------------------------------------------------------------%% File: iop_ior.erl%% Description:%% This file contains the IOP::IOR handling%%%% Creation date: 970327%%%%------------------------------------------------------------------module(iop_ior).-include_lib("orber/include/corba.hrl").-include_lib("orber/src/orber_iiop.hrl").%%-----------------------------------------------------------------%% External exports%%------------------------------------------------------------------export([code/4, decode/4, string_decode/1, string_code/1, string_code/2, string_code/3, string_code/4, get_key/1, get_key/2, get_typeID/1, create/9, get_objkey/1, check_nil/1, get_privfield/1, set_privfield/2, get_orbfield/1, set_orbfield/2, get_flagfield/1, set_flagfield/2, create_external/5, create_external/6, print/1, print/2, get_alt_addr/1, add_component/2, get_peerdata/1]).%%-----------------------------------------------------------------%% Internal exports%%-----------------------------------------------------------------%%-----------------------------------------------------------------%% Macros%%------------------------------------------------------------------define(DEBUG_LEVEL, 6).%%-----------------------------------------------------------------%% External interface functions%%-----------------------------------------------------------------%%-----------------------------------------------------------------%% Func: create/5/6%%-----------------------------------------------------------------%% There are a few restrictions if a certain IIOP-version may contain certain components%% and contexts The ones we currently, and the ones we perhaps will, support is:%% %% Feature 1.0 1.1 1.2%% TransactionService Service Context yes yes yes%% CodeSets Service Context yes yes%% Object by Value Service Context yes%% Bi-Directional IIOP Service Context yes%% IOR components in IIOP profile yes yes%% TAG_ORB_TYPE yes yes%% TAG_CODE_SETS yes yes%% TAG_ALTERNATE_IIOP_ADDRESS yes%% TAG_SSL_SEC_TRANS yes yes%% Extended IDL data types yes yes%% Bi-Directional GIOP Features yes%% Value types and Abstract Interfaces yes%%%% CSIv2:%% A target that supports unprotected IIOP invocations shall specify in the %% corresponding TAG_INTERNET_IOP profile a nonzero port number at which the %% target will accept unprotected invocations.9 A target that supports only%% protected IIOP invocations shall specify a port number of 0 (zero) in the%% corresponding TAG_INTERNET_IOP profile.%%-----------------------------------------------------------------create({1, 0}, TypeID, Hosts, IIOPPort, _, Objkey, _, _, _) -> Template = #'IIOP_ProfileBody_1_0'{iiop_version = #'IIOP_Version'{major=1, minor=0}, port = IIOPPort, object_key = Objkey}, #'IOP_IOR'{type_id=TypeID, profiles=duplicate_1_0_profiles(Hosts, Template, [])};create({1, Minor}, TypeID, Hosts, IIOPPort, -1, Objkey, MC, _, _) -> Template = #'IIOP_ProfileBody_1_1'{iiop_version = #'IIOP_Version'{major=1, minor=Minor}, port = IIOPPort, object_key = Objkey, components = MC}, #'IOP_IOR'{type_id=TypeID, profiles=duplicate_1_1_profiles(Hosts, Template, [])}; create({1, Minor}, TypeID, Hosts, IIOPPort, SSLPort, Objkey, MC, Flags, EnvFlags) -> V=#'IIOP_Version'{major=1, minor=Minor}, UseCSIv2 = ?ORB_FLAG_TEST(EnvFlags, ?ORB_ENV_USE_CSIV2), Template = case ?ORB_FLAG_TEST(Flags, ?ORB_NO_SECURITY) of true -> #'IIOP_ProfileBody_1_1'{iiop_version = V, port = IIOPPort, object_key = Objkey, components = MC}; false when UseCSIv2 == false -> #'IIOP_ProfileBody_1_1'{iiop_version=V, port=IIOPPort, object_key=Objkey, components= [#'IOP_TaggedComponent' {tag=?TAG_SSL_SEC_TRANS, component_data=#'SSLIOP_SSL'{target_supports = 2, target_requires = 2, port = SSLPort}}|MC]}; false when UseCSIv2 == true -> #'IIOP_ProfileBody_1_1' {iiop_version=V, port=0, object_key=Objkey, components= [#'IOP_TaggedComponent' {tag = ?TAG_CSI_SEC_MECH_LIST, component_data = #'CSIIOP_CompoundSecMechList' {stateful = false, mechanism_list = [#'CSIIOP_CompoundSecMech' {target_requires = 6, transport_mech = #'IOP_TaggedComponent' {tag=?TAG_TLS_SEC_TRANS, component_data=#'CSIIOP_TLS_SEC_TRANS' {target_supports = 7, target_requires = 8, addresses = [#'CSIIOP_TransportAddress'{host_name = "Host", port = SSLPort}]}}, as_context_mech = #'CSIIOP_AS_ContextSec' {target_supports = 9, target_requires = 10, client_authentication_mech = [1, 255], target_name = [2,255]}, sas_context_mech = #'CSIIOP_SAS_ContextSec' {target_supports = 11, target_requires = 12, privilege_authorities = [#'CSIIOP_ServiceConfiguration' {syntax = ?ULONGMAX, name = [3,255]}], supported_naming_mechanisms = [[4,255],[5,255]], supported_identity_types = ?ULONGMAX}}]}}|MC]} end, #'IOP_IOR'{type_id=TypeID, profiles=duplicate_1_1_profiles(Hosts, Template, [])};create(Version, TypeID, Host, IIOPPort, SSLPort, Objkey, MC, _, _) -> orber:dbg("[~p] iop_ior:create(~p, ~p, ~p, ~p, ~p, ~p, ~p);~n" "Unsupported IIOP-version.", [?LINE, Version, TypeID, Host, IIOPPort, SSLPort, Objkey, MC], ?DEBUG_LEVEL), corba:raise(#'INV_OBJREF'{completion_status=?COMPLETED_NO}).duplicate_1_1_profiles([], _, Profiles) -> Profiles;duplicate_1_1_profiles([H|T], Template, Profiles) -> duplicate_1_1_profiles(T, Template, [#'IOP_TaggedProfile' {tag=?TAG_INTERNET_IOP, profile_data = Template#'IIOP_ProfileBody_1_1'{host = H}}|Profiles]). duplicate_1_0_profiles([], _, Profiles) -> Profiles;duplicate_1_0_profiles([H|T], Template, Profiles) -> duplicate_1_0_profiles(T, Template, [#'IOP_TaggedProfile' {tag=?TAG_INTERNET_IOP, profile_data = Template#'IIOP_ProfileBody_1_0'{host = H}}|Profiles]). %%-----------------------------------------------------------------%% Func: create_external/5/6%%-----------------------------------------------------------------create_external(Version, TypeID, Host, IIOP_port, Objkey) -> create_external(Version, TypeID, Host, IIOP_port, Objkey, []).create_external({1, 0}, TypeID, Host, IIOP_port, Objkey, _MC) -> V=#'IIOP_Version'{major=1, minor=0}, PB=#'IIOP_ProfileBody_1_0'{iiop_version=V, host=Host, port=IIOP_port, object_key=Objkey}, #'IOP_IOR'{type_id=TypeID, profiles=[#'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}]};create_external({1, 1}, TypeID, Host, IIOP_port, Objkey, Components) -> V=#'IIOP_Version'{major=1, minor=1}, PB=#'IIOP_ProfileBody_1_1'{iiop_version=V, host=Host, port=IIOP_port, object_key=Objkey, components=Components}, #'IOP_IOR'{type_id=TypeID, profiles=[#'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}]};create_external({1, 2}, TypeID, Host, IIOP_port, Objkey, Components) -> V=#'IIOP_Version'{major=1, minor=2}, PB=#'IIOP_ProfileBody_1_1'{iiop_version=V, host=Host, port=IIOP_port, object_key=Objkey, components=Components}, #'IOP_IOR'{type_id=TypeID, profiles=[#'IOP_TaggedProfile'{tag=?TAG_INTERNET_IOP, profile_data=PB}]};create_external(Version, TypeID, Host, IIOP_port, Objkey, MC) -> orber:dbg("[~p] iop_ior:create_external(~p, ~p, ~p, ~p, ~p, ~p);~n" "Unsupported IIOP-version.", [?LINE, Version, TypeID, Host, IIOP_port, Objkey, MC], ?DEBUG_LEVEL), corba:raise(#'INV_OBJREF'{completion_status=?COMPLETED_NO}). %%-----------------------------------------------------------------%% Func: get_peerdata/1%%-----------------------------------------------------------------%% Probably an external IOR.get_peerdata(#'IOP_IOR'{} = IOR) -> get_peerdata(get_key(IOR), IOR, [], []);%% Local object reference.get_peerdata(_) -> [].%% "Plain" TCP/IP.get_peerdata({'external', {Host, Port, _InitObjkey, Index, TaggedProfile, #host_data{protocol = normal, csiv2_mech = undefined}}}, IOR, Acc, Indexes) -> Alts = get_alt_addr(TaggedProfile), get_peerdata(get_key(IOR, [Index|Indexes]), IOR, [{Host, Port}|Alts] ++ Acc, [Index|Indexes]);%% "Plain" SSLget_peerdata({'external', {Host, _Port, _InitObjkey, Index, TaggedProfile, #host_data{protocol = ssl, ssl_data = #'SSLIOP_SSL'{port = Port}, csiv2_mech = undefined}}}, IOR, Acc, Indexes) -> Alts = get_alt_addr(TaggedProfile), get_peerdata(get_key(IOR, [Index|Indexes]), IOR, [{Host, Port}|Alts] ++ Acc, [Index|Indexes]);%% TEMPORARY FIX TO SKIP CSIv2 DATA.get_peerdata({'external', {Host, _Port, _InitObjkey, Index, TaggedProfile, #host_data{protocol = ssl, ssl_data = #'SSLIOP_SSL'{port = Port}}}}, IOR, Acc, Indexes) -> Alts = get_alt_addr(TaggedProfile), get_peerdata(get_key(IOR, [Index|Indexes]), IOR, [{Host, Port}|Alts] ++ Acc, [Index|Indexes]);%% CSIv2 over SSL (TAG_TLS_SEC_TRANS) using the SAS protocol. Note port must equal 0.get_peerdata({'external', {_Host, 0, _InitObjkey, Index, TaggedProfile, #host_data{protocol = ssl, csiv2_mech = #'CSIIOP_CompoundSecMech'{target_requires = _TR} = _Mech, csiv2_addresses = Addresses}}}, IOR, Acc, Indexes) -> Alts = get_alt_addr(TaggedProfile), get_peerdata(get_key(IOR, [Index|Indexes]), IOR, Addresses ++ Alts ++ Acc, [Index|Indexes]);%% CSIv2 over SSL (TAG_NULL_TAG) using the SAS protocol.get_peerdata({'external', {Host, _Port, _InitObjkey, Index, TaggedProfile, #host_data{protocol = ssl, ssl_data = #'SSLIOP_SSL'{port = Port}, csiv2_mech = Mech}}}, IOR, Acc, Indexes) when record(Mech, 'CSIIOP_CompoundSecMech') -> Alts = get_alt_addr(TaggedProfile), get_peerdata(get_key(IOR, [Index|Indexes]), IOR, [{Host, Port}|Alts] ++ Acc, [Index|Indexes]);%% CSIv2 over TCP (TAG_NULL_TAG) using the SAS protocol.get_peerdata({'external', {Host, Port, _InitObjkey, Index, TaggedProfile, #host_data{protocol = normal, csiv2_mech = Mech}}}, IOR, Acc, Indexes) when record(Mech, 'CSIIOP_CompoundSecMech') -> Alts = get_alt_addr(TaggedProfile), get_peerdata(get_key(IOR, [Index|Indexes]), IOR, [{Host, Port}|Alts] ++ Acc, [Index|Indexes]);get_peerdata(undefined, _IOR, Acc, _Indexes) -> Acc;%% Local object reference.get_peerdata(_, _, _, _) -> [].%%-----------------------------------------------------------------%% Func: get_key/1%%-----------------------------------------------------------------get_key(#'IOP_IOR'{profiles=P}) -> get_key_1(P, false, 0, undefined, #host_data{});get_key({Module, Type, Key, _UserDef, OrberDef, Flags}) -> if binary(Key) ->
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?