From 078a3a2ffc64572dc6483cc00c9e772c268e103e Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 23 Oct 2015 10:27:10 +0200 Subject: Recompile with a new version (18) --- ACSE-1.erl | 2394 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 1417 insertions(+), 977 deletions(-) (limited to 'ACSE-1.erl') diff --git a/ACSE-1.erl b/ACSE-1.erl index 86fec8b..f543e7f 100644 --- a/ACSE-1.erl +++ b/ACSE-1.erl @@ -1,14 +1,22 @@ -%% Generated by the Erlang ASN.1 BER-compiler version:1.7 +%% Generated by the Erlang ASN.1 BER_V2-compiler version, utilizing bit-syntax:4.0 %% Purpose: encoder and decoder to the types in mod ACSE-1 -module('ACSE-1'). +-compile(nowarn_unused_vars). -include("ACSE-1.hrl"). --define('RT_BER',asn1rt_ber_bin). --asn1_info([{vsn,'1.7'}, +-asn1_info([{vsn,'4.0'}, {module,'ACSE-1'}, - {options,[{i,[47,104,111,109,101,47,113,117,97,120,47,101,114,108,47,97,115,110]},warnings,ber,errors,{cwd,[47,104,111,109,101,47,113,117,97,120,47,101,114,108,47,97,115,110]},{outdir,[47,104,111,109,101,47,113,117,97,120,47,101,114,108,47,97,115,110]},{i,[46]},{i,[47,104,111,109,101,47,113,117,97,120,47,101,114,108,47,97,115,110,47,97,99,115,101]}]}]). - --export([encoding_rule/0]). + {options,[{i,"/Users/quax/erl"}, + warnings,ber,errors, + {cwd,"/Users/quax/erl"}, + {outdir,"/Users/quax/erl"}, + {i,"/Users/quax/erl/acse"}, + {i,"/Users/quax/erl/csta"}, + {i,"."}]}]). + +-export([encoding_rule/0,bit_string_format/0, + legacy_erlang_types/0]). +-export(['dialyzer-suppressions'/1]). -export([ 'enc_ACSE-apdu'/2, 'enc_AARQ-apdu'/2, @@ -77,1142 +85,1166 @@ 'dec_EXTERNAL'/2 ]). --export([ -'dec_ACSE-apdu'/3, -'dec_AARQ-apdu'/3, -'dec_AARE-apdu'/3, -'dec_RLRQ-apdu'/3, -'dec_RLRE-apdu'/3, -'dec_ABRT-apdu'/3, -'dec_ABRT-diagnostic'/3, -'dec_ABRT-source'/3, -'dec_ACSE-requirements'/3, -'dec_Application-context-name-list'/3, -'dec_Application-context-name'/3, -'dec_AP-title'/3, -'dec_AE-qualifier'/3, -'dec_AP-title-form1'/3, -'dec_AE-qualifier-form1'/3, -'dec_AP-title-form2'/3, -'dec_AE-qualifier-form2'/3, -'dec_AE-title'/3, -'dec_AE-title-form1'/3, -'dec_AE-title-form2'/3, -'dec_AE-invocation-identifier'/3, -'dec_AP-invocation-identifier'/3, -'dec_Associate-result'/3, -'dec_Associate-source-diagnostic'/3, -'dec_Association-information'/3, -'dec_Authentication-value'/3, -'dec_Implementation-data'/3, -'dec_Mechanism-name'/3, -'dec_Release-request-reason'/3, -'dec_Release-response-reason'/3, -'dec_EXTERNAL'/3 -]). - -export([ 'acse-as-id'/0, 'aCSE-id'/0 ]). -export([ -'getenc_ObjectSet'/2 +'getenc_ObjectSet'/1 ]). -export([ -'getdec_ObjectSet'/2 +'getdec_ObjectSet'/1 ]). -export([info/0]). --export([encode/2,decode/2,encode_disp/2,decode_disp/2]). +-export([encode/2,decode/2]). + +encoding_rule() -> ber. -encoding_rule() -> - ber. +bit_string_format() -> bitstring. -encode(Type,Data) -> -case catch encode_disp(Type,Data) of - {'EXIT',{error,Reason}} -> - {error,Reason}; - {'EXIT',Reason} -> - {error,{asn1,Reason}}; - {Bytes,_Len} -> - {ok,wrap_encode(Bytes)}; +legacy_erlang_types() -> false. + +encode(Type, Data) -> +try iolist_to_binary(element(1, encode_disp(Type, Data))) of Bytes -> - {ok,wrap_encode(Bytes)} + {ok,Bytes} + catch + Class:Exception when Class =:= error; Class =:= exit -> + case Exception of + {error,Reason}=Error -> + Error; + Reason -> + {error,{asn1,Reason}} + end end. decode(Type,Data) -> -case catch decode_disp(Type,wrap_decode(Data)) of - {'EXIT',{error,Reason}} -> - {error,Reason}; - {'EXIT',Reason} -> - {error,{asn1,Reason}}; - {X,_Rest} -> - {ok,X}; - {X,_Rest,_Len} -> - {ok,X} +try decode_disp(Type, element(1, ber_decode_nif(Data))) of + Result -> + {ok,Result} + catch + Class:Exception when Class =:= error; Class =:= exit -> + case Exception of + {error,Reason}=Error -> + Error; + Reason -> + {error,{asn1,Reason}} + end end. -encode_disp('ACSE-apdu',Data) -> 'enc_ACSE-apdu'(Data,[]); -encode_disp('AARQ-apdu',Data) -> 'enc_AARQ-apdu'(Data,[]); -encode_disp('AARE-apdu',Data) -> 'enc_AARE-apdu'(Data,[]); -encode_disp('RLRQ-apdu',Data) -> 'enc_RLRQ-apdu'(Data,[]); -encode_disp('RLRE-apdu',Data) -> 'enc_RLRE-apdu'(Data,[]); -encode_disp('ABRT-apdu',Data) -> 'enc_ABRT-apdu'(Data,[]); -encode_disp('ABRT-diagnostic',Data) -> 'enc_ABRT-diagnostic'(Data,[]); -encode_disp('ABRT-source',Data) -> 'enc_ABRT-source'(Data,[]); -encode_disp('ACSE-requirements',Data) -> 'enc_ACSE-requirements'(Data,[]); -encode_disp('Application-context-name-list',Data) -> 'enc_Application-context-name-list'(Data,[]); -encode_disp('Application-context-name',Data) -> 'enc_Application-context-name'(Data,[]); -encode_disp('AP-title',Data) -> 'enc_AP-title'(Data,[]); -encode_disp('AE-qualifier',Data) -> 'enc_AE-qualifier'(Data,[]); -encode_disp('AP-title-form1',Data) -> 'enc_AP-title-form1'(Data,[]); -encode_disp('AE-qualifier-form1',Data) -> 'enc_AE-qualifier-form1'(Data,[]); -encode_disp('AP-title-form2',Data) -> 'enc_AP-title-form2'(Data,[]); -encode_disp('AE-qualifier-form2',Data) -> 'enc_AE-qualifier-form2'(Data,[]); -encode_disp('AE-title',Data) -> 'enc_AE-title'(Data,[]); -encode_disp('AE-title-form1',Data) -> 'enc_AE-title-form1'(Data,[]); -encode_disp('AE-title-form2',Data) -> 'enc_AE-title-form2'(Data,[]); -encode_disp('AE-invocation-identifier',Data) -> 'enc_AE-invocation-identifier'(Data,[]); -encode_disp('AP-invocation-identifier',Data) -> 'enc_AP-invocation-identifier'(Data,[]); -encode_disp('Associate-result',Data) -> 'enc_Associate-result'(Data,[]); -encode_disp('Associate-source-diagnostic',Data) -> 'enc_Associate-source-diagnostic'(Data,[]); -encode_disp('Association-information',Data) -> 'enc_Association-information'(Data,[]); -encode_disp('Authentication-value',Data) -> 'enc_Authentication-value'(Data,[]); -encode_disp('Implementation-data',Data) -> 'enc_Implementation-data'(Data,[]); -encode_disp('Mechanism-name',Data) -> 'enc_Mechanism-name'(Data,[]); -encode_disp('Release-request-reason',Data) -> 'enc_Release-request-reason'(Data,[]); -encode_disp('Release-response-reason',Data) -> 'enc_Release-response-reason'(Data,[]); -encode_disp('EXTERNAL',Data) -> 'enc_EXTERNAL'(Data,[]); +encode_disp('ACSE-apdu',Data) -> 'enc_ACSE-apdu'(Data); +encode_disp('AARQ-apdu',Data) -> 'enc_AARQ-apdu'(Data); +encode_disp('AARE-apdu',Data) -> 'enc_AARE-apdu'(Data); +encode_disp('RLRQ-apdu',Data) -> 'enc_RLRQ-apdu'(Data); +encode_disp('RLRE-apdu',Data) -> 'enc_RLRE-apdu'(Data); +encode_disp('ABRT-apdu',Data) -> 'enc_ABRT-apdu'(Data); +encode_disp('ABRT-diagnostic',Data) -> 'enc_ABRT-diagnostic'(Data); +encode_disp('ABRT-source',Data) -> 'enc_ABRT-source'(Data); +encode_disp('ACSE-requirements',Data) -> 'enc_ACSE-requirements'(Data); +encode_disp('Application-context-name-list',Data) -> 'enc_Application-context-name-list'(Data); +encode_disp('Application-context-name',Data) -> 'enc_Application-context-name'(Data); +encode_disp('AP-title',Data) -> 'enc_AP-title'(Data); +encode_disp('AE-qualifier',Data) -> 'enc_AE-qualifier'(Data); +encode_disp('AP-title-form1',Data) -> 'enc_AP-title-form1'(Data); +encode_disp('AE-qualifier-form1',Data) -> 'enc_AE-qualifier-form1'(Data); +encode_disp('AP-title-form2',Data) -> 'enc_AP-title-form2'(Data); +encode_disp('AE-qualifier-form2',Data) -> 'enc_AE-qualifier-form2'(Data); +encode_disp('AE-title',Data) -> 'enc_AE-title'(Data); +encode_disp('AE-title-form1',Data) -> 'enc_AE-title-form1'(Data); +encode_disp('AE-title-form2',Data) -> 'enc_AE-title-form2'(Data); +encode_disp('AE-invocation-identifier',Data) -> 'enc_AE-invocation-identifier'(Data); +encode_disp('AP-invocation-identifier',Data) -> 'enc_AP-invocation-identifier'(Data); +encode_disp('Associate-result',Data) -> 'enc_Associate-result'(Data); +encode_disp('Associate-source-diagnostic',Data) -> 'enc_Associate-source-diagnostic'(Data); +encode_disp('Association-information',Data) -> 'enc_Association-information'(Data); +encode_disp('Authentication-value',Data) -> 'enc_Authentication-value'(Data); +encode_disp('Implementation-data',Data) -> 'enc_Implementation-data'(Data); +encode_disp('Mechanism-name',Data) -> 'enc_Mechanism-name'(Data); +encode_disp('Release-request-reason',Data) -> 'enc_Release-request-reason'(Data); +encode_disp('Release-response-reason',Data) -> 'enc_Release-response-reason'(Data); +encode_disp('EXTERNAL',Data) -> 'enc_EXTERNAL'(Data); encode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}). -decode_disp('ACSE-apdu',Data) -> 'dec_ACSE-apdu'(Data,mandatory); -decode_disp('AARQ-apdu',Data) -> 'dec_AARQ-apdu'(Data,mandatory); -decode_disp('AARE-apdu',Data) -> 'dec_AARE-apdu'(Data,mandatory); -decode_disp('RLRQ-apdu',Data) -> 'dec_RLRQ-apdu'(Data,mandatory); -decode_disp('RLRE-apdu',Data) -> 'dec_RLRE-apdu'(Data,mandatory); -decode_disp('ABRT-apdu',Data) -> 'dec_ABRT-apdu'(Data,mandatory); -decode_disp('ABRT-diagnostic',Data) -> 'dec_ABRT-diagnostic'(Data,mandatory); -decode_disp('ABRT-source',Data) -> 'dec_ABRT-source'(Data,mandatory); -decode_disp('ACSE-requirements',Data) -> 'dec_ACSE-requirements'(Data,mandatory); -decode_disp('Application-context-name-list',Data) -> 'dec_Application-context-name-list'(Data,mandatory); -decode_disp('Application-context-name',Data) -> 'dec_Application-context-name'(Data,mandatory); -decode_disp('AP-title',Data) -> 'dec_AP-title'(Data,mandatory); -decode_disp('AE-qualifier',Data) -> 'dec_AE-qualifier'(Data,mandatory); -decode_disp('AP-title-form1',Data) -> 'dec_AP-title-form1'(Data,mandatory); -decode_disp('AE-qualifier-form1',Data) -> 'dec_AE-qualifier-form1'(Data,mandatory); -decode_disp('AP-title-form2',Data) -> 'dec_AP-title-form2'(Data,mandatory); -decode_disp('AE-qualifier-form2',Data) -> 'dec_AE-qualifier-form2'(Data,mandatory); -decode_disp('AE-title',Data) -> 'dec_AE-title'(Data,mandatory); -decode_disp('AE-title-form1',Data) -> 'dec_AE-title-form1'(Data,mandatory); -decode_disp('AE-title-form2',Data) -> 'dec_AE-title-form2'(Data,mandatory); -decode_disp('AE-invocation-identifier',Data) -> 'dec_AE-invocation-identifier'(Data,mandatory); -decode_disp('AP-invocation-identifier',Data) -> 'dec_AP-invocation-identifier'(Data,mandatory); -decode_disp('Associate-result',Data) -> 'dec_Associate-result'(Data,mandatory); -decode_disp('Associate-source-diagnostic',Data) -> 'dec_Associate-source-diagnostic'(Data,mandatory); -decode_disp('Association-information',Data) -> 'dec_Association-information'(Data,mandatory); -decode_disp('Authentication-value',Data) -> 'dec_Authentication-value'(Data,mandatory); -decode_disp('Implementation-data',Data) -> 'dec_Implementation-data'(Data,mandatory); -decode_disp('Mechanism-name',Data) -> 'dec_Mechanism-name'(Data,mandatory); -decode_disp('Release-request-reason',Data) -> 'dec_Release-request-reason'(Data,mandatory); -decode_disp('Release-response-reason',Data) -> 'dec_Release-response-reason'(Data,mandatory); -decode_disp('EXTERNAL',Data) -> 'dec_EXTERNAL'(Data,mandatory); +decode_disp('ACSE-apdu',Data) -> 'dec_ACSE-apdu'(Data); +decode_disp('AARQ-apdu',Data) -> 'dec_AARQ-apdu'(Data); +decode_disp('AARE-apdu',Data) -> 'dec_AARE-apdu'(Data); +decode_disp('RLRQ-apdu',Data) -> 'dec_RLRQ-apdu'(Data); +decode_disp('RLRE-apdu',Data) -> 'dec_RLRE-apdu'(Data); +decode_disp('ABRT-apdu',Data) -> 'dec_ABRT-apdu'(Data); +decode_disp('ABRT-diagnostic',Data) -> 'dec_ABRT-diagnostic'(Data); +decode_disp('ABRT-source',Data) -> 'dec_ABRT-source'(Data); +decode_disp('ACSE-requirements',Data) -> 'dec_ACSE-requirements'(Data); +decode_disp('Application-context-name-list',Data) -> 'dec_Application-context-name-list'(Data); +decode_disp('Application-context-name',Data) -> 'dec_Application-context-name'(Data); +decode_disp('AP-title',Data) -> 'dec_AP-title'(Data); +decode_disp('AE-qualifier',Data) -> 'dec_AE-qualifier'(Data); +decode_disp('AP-title-form1',Data) -> 'dec_AP-title-form1'(Data); +decode_disp('AE-qualifier-form1',Data) -> 'dec_AE-qualifier-form1'(Data); +decode_disp('AP-title-form2',Data) -> 'dec_AP-title-form2'(Data); +decode_disp('AE-qualifier-form2',Data) -> 'dec_AE-qualifier-form2'(Data); +decode_disp('AE-title',Data) -> 'dec_AE-title'(Data); +decode_disp('AE-title-form1',Data) -> 'dec_AE-title-form1'(Data); +decode_disp('AE-title-form2',Data) -> 'dec_AE-title-form2'(Data); +decode_disp('AE-invocation-identifier',Data) -> 'dec_AE-invocation-identifier'(Data); +decode_disp('AP-invocation-identifier',Data) -> 'dec_AP-invocation-identifier'(Data); +decode_disp('Associate-result',Data) -> 'dec_Associate-result'(Data); +decode_disp('Associate-source-diagnostic',Data) -> 'dec_Associate-source-diagnostic'(Data); +decode_disp('Association-information',Data) -> 'dec_Association-information'(Data); +decode_disp('Authentication-value',Data) -> 'dec_Authentication-value'(Data); +decode_disp('Implementation-data',Data) -> 'dec_Implementation-data'(Data); +decode_disp('Mechanism-name',Data) -> 'dec_Mechanism-name'(Data); +decode_disp('Release-request-reason',Data) -> 'dec_Release-request-reason'(Data); +decode_disp('Release-response-reason',Data) -> 'dec_Release-response-reason'(Data); +decode_disp('EXTERNAL',Data) -> 'dec_EXTERNAL'(Data); decode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}). -wrap_encode(Bytes) when is_list(Bytes) -> - binary_to_list(list_to_binary(Bytes)); -wrap_encode(Bytes) when is_binary(Bytes) -> - binary_to_list(Bytes); -wrap_encode(Bytes) -> Bytes. - -wrap_decode(Bytes) when is_list(Bytes) -> - list_to_binary(Bytes); -wrap_decode(Bytes) -> Bytes. - info() -> - case ?MODULE:module_info() of - MI when is_list(MI) -> - case lists:keysearch(attributes,1,MI) of - {value,{_,Attributes}} when is_list(Attributes) -> - case lists:keysearch(asn1_info,1,Attributes) of - {value,{_,Info}} when is_list(Info) -> - Info; - _ -> - [] - end; - _ -> - [] - end + case ?MODULE:module_info(attributes) of + Attributes when is_list(Attributes) -> + case lists:keyfind(asn1_info, 1, Attributes) of + {_,Info} when is_list(Info) -> + Info; + _ -> + [] + end; + _ -> + [] end. %%================================ %% ACSE-apdu %%================================ - -'enc_ACSE-apdu'({'ACSE-apdu',Val}, TagIn) -> - 'enc_ACSE-apdu'(Val, TagIn); +'enc_ACSE-apdu'(Val) -> + 'enc_ACSE-apdu'(Val, []). 'enc_ACSE-apdu'(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of aarq -> - 'enc_AARQ-apdu'(element(2,Val), []); + 'enc_AARQ-apdu'(element(2,Val), [<<96>>]); aare -> - 'enc_AARE-apdu'(element(2,Val), []); + 'enc_AARE-apdu'(element(2,Val), [<<97>>]); rlrq -> - 'enc_RLRQ-apdu'(element(2,Val), []); + 'enc_RLRQ-apdu'(element(2,Val), [<<98>>]); rlre -> - 'enc_RLRE-apdu'(element(2,Val), []); + 'enc_RLRE-apdu'(element(2,Val), [<<99>>]); abrt -> - 'enc_ABRT-apdu'(element(2,Val), []); + 'enc_ABRT-apdu'(element(2,Val), [<<100>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, -?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen). +encode_tags(TagIn, EncBytes, EncLen). -'dec_ACSE-apdu'(Bytes, OptOrMand) -> - 'dec_ACSE-apdu'(Bytes, OptOrMand, []). +'dec_ACSE-apdu'(Tlv) -> + 'dec_ACSE-apdu'(Tlv, []). -'dec_ACSE-apdu'(Bytes, OptOrMand, TagIn) -> - {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand), - IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end, - IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end, - case Bytes1 of +'dec_ACSE-apdu'(Tlv, TagIn) -> +Tlv1 = match_tags(Tlv, TagIn), +case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'aarq' - <<1:2,_:1,0:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_AARQ-apdu'(Bytes1, mandatory, []), - {{aarq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {65536, V1} -> + {aarq, 'dec_AARQ-apdu'(V1, [])}; %% 'aare' - <<1:2,_:1,1:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_AARE-apdu'(Bytes1, mandatory, []), - {{aare, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {65537, V1} -> + {aare, 'dec_AARE-apdu'(V1, [])}; %% 'rlrq' - <<1:2,_:1,2:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_RLRQ-apdu'(Bytes1, mandatory, []), - {{rlrq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {65538, V1} -> + {rlrq, 'dec_RLRQ-apdu'(V1, [])}; %% 'rlre' - <<1:2,_:1,3:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_RLRE-apdu'(Bytes1, mandatory, []), - {{rlre, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {65539, V1} -> + {rlre, 'dec_RLRE-apdu'(V1, [])}; %% 'abrt' - <<1:2,_:1,4:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_ABRT-apdu'(Bytes1, mandatory, []), - {{abrt, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {65540, V1} -> + {abrt, 'dec_ABRT-apdu'(V1, [])}; - _ -> - {{asn1_ExtAlt,Bytes1},<<>>, RbExp} - end. + Else -> + {asn1_ExtAlt,ber_encode(Else)} + end +. %%================================ %% AARQ-apdu %%================================ +'enc_AARQ-apdu'(Val) -> + 'enc_AARQ-apdu'(Val, [<<96>>]). + 'enc_AARQ-apdu'(Val, TagIn) -> +{_,Cindex1, Cindex2, Cindex3, Cindex4, Cindex5, Cindex6, Cindex7, Cindex8, Cindex9, Cindex10, Cindex11, Cindex12, Cindex13, Cindex14, Cindex15, Cindex16} = Val, %%------------------------------------------------- -%% attribute number 1 with type BIT STRING DEFAULT = [version1] +%% attribute protocol-version(1) with type BIT STRING DEFAULT = [version1] %%------------------------------------------------- - {EncBytes1,EncLen1} = case ?RT_BER:cindex(2,Val,'protocol-version') of + {EncBytes1,EncLen1} = case Cindex1 of asn1_DEFAULT -> {<<>>,0}; [version1] -> {<<>>,0}; _ -> - ?RT_BER:encode_bit_string([], ?RT_BER:cindex(2,Val,'protocol-version'), [{version1,0}], [{tag,128,0,'IMPLICIT',32}]) + encode_named_bit_string(Cindex1, [{version1,0}], [<<128>>]) end, %%------------------------------------------------- -%% attribute number 2 with type OBJECT IDENTIFIER +%% attribute application-context-name(2) with type OBJECT IDENTIFIER %%------------------------------------------------- - {EncBytes2,EncLen2} = ?RT_BER:encode_object_identifier(?RT_BER:cindex(3,Val,'application-context-name'), [{tag,128,1,'EXPLICIT',32}]), + {EncBytes2,EncLen2} = encode_object_identifier(Cindex2, [<<6>>,<<161>>]), %%------------------------------------------------- -%% attribute number 3 External ACSE-1:AP-title OPTIONAL +%% attribute called-AP-title(3) External ACSE-1:AP-title OPTIONAL %%------------------------------------------------- - {EncBytes3,EncLen3} = case ?RT_BER:cindex(4,Val,'called-AP-title') of + {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_AP-title'(?RT_BER:cindex(4,Val,'called-AP-title'), [{tag,128,2,'EXPLICIT',32}]) + 'enc_AP-title'(Cindex3, [<<162>>]) end, %%------------------------------------------------- -%% attribute number 4 External ACSE-1:AE-qualifier OPTIONAL +%% attribute called-AE-qualifier(4) External ACSE-1:AE-qualifier OPTIONAL %%------------------------------------------------- - {EncBytes4,EncLen4} = case ?RT_BER:cindex(5,Val,'called-AE-qualifier') of + {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_AE-qualifier'(?RT_BER:cindex(5,Val,'called-AE-qualifier'), [{tag,128,3,'EXPLICIT',32}]) + 'enc_AE-qualifier'(Cindex4, [<<163>>]) end, %%------------------------------------------------- -%% attribute number 5 with type INTEGER OPTIONAL +%% attribute called-AP-invocation-identifier(5) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes5,EncLen5} = case ?RT_BER:cindex(6,Val,'called-AP-invocation-identifier') of + {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(6,Val,'called-AP-invocation-identifier'), [{tag,128,4,'EXPLICIT',32}]) + encode_integer(Cindex5, [<<2>>,<<164>>]) end, %%------------------------------------------------- -%% attribute number 6 with type INTEGER OPTIONAL +%% attribute called-AE-invocation-identifier(6) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes6,EncLen6} = case ?RT_BER:cindex(7,Val,'called-AE-invocation-identifier') of + {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(7,Val,'called-AE-invocation-identifier'), [{tag,128,5,'EXPLICIT',32}]) + encode_integer(Cindex6, [<<2>>,<<165>>]) end, %%------------------------------------------------- -%% attribute number 7 External ACSE-1:AP-title OPTIONAL +%% attribute calling-AP-title(7) External ACSE-1:AP-title OPTIONAL %%------------------------------------------------- - {EncBytes7,EncLen7} = case ?RT_BER:cindex(8,Val,'calling-AP-title') of + {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_AP-title'(?RT_BER:cindex(8,Val,'calling-AP-title'), [{tag,128,6,'EXPLICIT',32}]) + 'enc_AP-title'(Cindex7, [<<166>>]) end, %%------------------------------------------------- -%% attribute number 8 External ACSE-1:AE-qualifier OPTIONAL +%% attribute calling-AE-qualifier(8) External ACSE-1:AE-qualifier OPTIONAL %%------------------------------------------------- - {EncBytes8,EncLen8} = case ?RT_BER:cindex(9,Val,'calling-AE-qualifier') of + {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_AE-qualifier'(?RT_BER:cindex(9,Val,'calling-AE-qualifier'), [{tag,128,7,'EXPLICIT',32}]) + 'enc_AE-qualifier'(Cindex8, [<<167>>]) end, %%------------------------------------------------- -%% attribute number 9 with type INTEGER OPTIONAL +%% attribute calling-AP-invocation-identifier(9) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes9,EncLen9} = case ?RT_BER:cindex(10,Val,'calling-AP-invocation-identifier') of + {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(10,Val,'calling-AP-invocation-identifier'), [{tag,128,8,'EXPLICIT',32}]) + encode_integer(Cindex9, [<<2>>,<<168>>]) end, %%------------------------------------------------- -%% attribute number 10 with type INTEGER OPTIONAL +%% attribute calling-AE-invocation-identifier(10) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes10,EncLen10} = case ?RT_BER:cindex(11,Val,'calling-AE-invocation-identifier') of + {EncBytes10,EncLen10} = case Cindex10 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(11,Val,'calling-AE-invocation-identifier'), [{tag,128,9,'EXPLICIT',32}]) + encode_integer(Cindex10, [<<2>>,<<169>>]) end, %%------------------------------------------------- -%% attribute number 11 with type BIT STRING OPTIONAL +%% attribute sender-acse-requirements(11) with type BIT STRING OPTIONAL %%------------------------------------------------- - {EncBytes11,EncLen11} = case ?RT_BER:cindex(12,Val,'sender-acse-requirements') of + {EncBytes11,EncLen11} = case Cindex11 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_bit_string([], ?RT_BER:cindex(12,Val,'sender-acse-requirements'), [{authentication,0},{'application-context-negotiation',1}], [{tag,128,10,'IMPLICIT',32}]) + encode_named_bit_string(Cindex11, [{authentication,0},{'application-context-negotiation',1}], [<<138>>]) end, %%------------------------------------------------- -%% attribute number 12 with type OBJECT IDENTIFIER OPTIONAL +%% attribute mechanism-name(12) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- - {EncBytes12,EncLen12} = case ?RT_BER:cindex(13,Val,'mechanism-name') of + {EncBytes12,EncLen12} = case Cindex12 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_object_identifier(?RT_BER:cindex(13,Val,'mechanism-name'), [{tag,128,11,'IMPLICIT',32}]) + encode_object_identifier(Cindex12, [<<139>>]) end, %%------------------------------------------------- -%% attribute number 13 External ACSE-1:Authentication-value OPTIONAL +%% attribute calling-authentication-value(13) External ACSE-1:Authentication-value OPTIONAL %%------------------------------------------------- - {EncBytes13,EncLen13} = case ?RT_BER:cindex(14,Val,'calling-authentication-value') of + {EncBytes13,EncLen13} = case Cindex13 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Authentication-value'(?RT_BER:cindex(14,Val,'calling-authentication-value'), [{tag,128,12,'EXPLICIT',32}]) + 'enc_Authentication-value'(Cindex13, [<<172>>]) end, %%------------------------------------------------- -%% attribute number 14 External ACSE-1:Application-context-name-list OPTIONAL +%% attribute application-context-name-list(14) External ACSE-1:Application-context-name-list OPTIONAL %%------------------------------------------------- - {EncBytes14,EncLen14} = case ?RT_BER:cindex(15,Val,'application-context-name-list') of + {EncBytes14,EncLen14} = case Cindex14 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Application-context-name-list'(?RT_BER:cindex(15,Val,'application-context-name-list'), [{tag,128,13,'IMPLICIT',32}]) + 'enc_Application-context-name-list'(Cindex14, [<<173>>]) end, %%------------------------------------------------- -%% attribute number 15 with type GraphicString OPTIONAL +%% attribute implementation-information(15) with type GraphicString OPTIONAL %%------------------------------------------------- - {EncBytes15,EncLen15} = case ?RT_BER:cindex(16,Val,'implementation-information') of + {EncBytes15,EncLen15} = case Cindex15 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(16,Val,'implementation-information'), 25, [{tag,128,29,'IMPLICIT',32}]) + encode_restricted_string(Cindex15, [<<157>>]) end, %%------------------------------------------------- -%% attribute number 16 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(16) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {EncBytes16,EncLen16} = case ?RT_BER:cindex(17,Val,'user-information') of + {EncBytes16,EncLen16} = case Cindex16 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Association-information'(?RT_BER:cindex(17,Val,'user-information'), [{tag,128,30,'IMPLICIT',32}]) + 'enc_Association-information'(Cindex16, [<<190>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13, EncBytes14, EncBytes15, EncBytes16], - LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13 + EncLen14 + EncLen15 + EncLen16, - ?RT_BER:encode_tags(TagIn ++ [{tag,64,0,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar). +LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13 + EncLen14 + EncLen15 + EncLen16, +encode_tags(TagIn, BytesSoFar, LenSoFar). -'dec_AARQ-apdu'(Bytes, OptOrMand) -> - 'dec_AARQ-apdu'(Bytes, OptOrMand, []). +'dec_AARQ-apdu'(Tlv) -> + 'dec_AARQ-apdu'(Tlv, [65536]). -'dec_AARQ-apdu'(Bytes, OptOrMand, TagIn) -> +'dec_AARQ-apdu'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,0,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), -{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len), +Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- -%% attribute number 1 with type BIT STRING DEFAULT = [version1] +%% attribute protocol-version(1) with type BIT STRING DEFAULT = [version1] %%------------------------------------------------- - {Term1,Bytes3,Rb2} = case Bytes2 of -<<2:2,_:1,0:5,_/binary>> -> -?RT_BER:decode_bit_string(Bytes2,[],[{version1,0}],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory); -_ -> -{[version1],Bytes2, 0 } +{Term1,Tlv2} = case Tlv1 of +[{131072,V1}|TempTlv2] -> + {decode_named_bit_string(V1, [{version1,0}], []), TempTlv2}; + _ -> + {[version1],Tlv1} end, %%------------------------------------------------- -%% attribute number 2 with type OBJECT IDENTIFIER +%% attribute application-context-name(2) with type OBJECT IDENTIFIER %%------------------------------------------------- - {Term2,Bytes4,Rb3} = ?RT_BER:decode_object_identifier(Bytes3,[{tag,128,1,'EXPLICIT',32}], mandatory), +[V2|Tlv3] = Tlv2, +Term2 = decode_object_identifier(V2, [131073,6]), %%------------------------------------------------- -%% attribute number 3 External ACSE-1:AP-title OPTIONAL +%% attribute called-AP-title(3) External ACSE-1:AP-title OPTIONAL %%------------------------------------------------- - {Term3,Bytes5,Rb4} = case Bytes4 of -<<2:2,_:1,2:5,_/binary>> -> -'dec_AP-title'(Bytes4, opt_or_default, [{tag,128,2,'EXPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes4, 0 } +{Term3,Tlv4} = case Tlv3 of +[{131074,V3}|TempTlv4] -> + {'dec_AP-title'(V3, []), TempTlv4}; + _ -> + { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- -%% attribute number 4 External ACSE-1:AE-qualifier OPTIONAL +%% attribute called-AE-qualifier(4) External ACSE-1:AE-qualifier OPTIONAL %%------------------------------------------------- - {Term4,Bytes6,Rb5} = case Bytes5 of -<<2:2,_:1,3:5,_/binary>> -> -'dec_AE-qualifier'(Bytes5, opt_or_default, [{tag,128,3,'EXPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes5, 0 } +{Term4,Tlv5} = case Tlv4 of +[{131075,V4}|TempTlv5] -> + {'dec_AE-qualifier'(V4, []), TempTlv5}; + _ -> + { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- -%% attribute number 5 with type INTEGER OPTIONAL +%% attribute called-AP-invocation-identifier(5) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term5,Bytes7,Rb6} = case Bytes6 of -<<2:2,_:1,4:5,_/binary>> -> -?RT_BER:decode_integer(Bytes6,[],[{tag,128,4,'EXPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes6, 0 } +{Term5,Tlv6} = case Tlv5 of +[{131076,V5}|TempTlv6] -> + {decode_integer(V5, [2]), TempTlv6}; + _ -> + { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- -%% attribute number 6 with type INTEGER OPTIONAL +%% attribute called-AE-invocation-identifier(6) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term6,Bytes8,Rb7} = case Bytes7 of -<<2:2,_:1,5:5,_/binary>> -> -?RT_BER:decode_integer(Bytes7,[],[{tag,128,5,'EXPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes7, 0 } +{Term6,Tlv7} = case Tlv6 of +[{131077,V6}|TempTlv7] -> + {decode_integer(V6, [2]), TempTlv7}; + _ -> + { asn1_NOVALUE, Tlv6} end, %%------------------------------------------------- -%% attribute number 7 External ACSE-1:AP-title OPTIONAL +%% attribute calling-AP-title(7) External ACSE-1:AP-title OPTIONAL %%------------------------------------------------- - {Term7,Bytes9,Rb8} = case Bytes8 of -<<2:2,_:1,6:5,_/binary>> -> -'dec_AP-title'(Bytes8, opt_or_default, [{tag,128,6,'EXPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes8, 0 } +{Term7,Tlv8} = case Tlv7 of +[{131078,V7}|TempTlv8] -> + {'dec_AP-title'(V7, []), TempTlv8}; + _ -> + { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- -%% attribute number 8 External ACSE-1:AE-qualifier OPTIONAL +%% attribute calling-AE-qualifier(8) External ACSE-1:AE-qualifier OPTIONAL %%------------------------------------------------- - {Term8,Bytes10,Rb9} = case Bytes9 of -<<2:2,_:1,7:5,_/binary>> -> -'dec_AE-qualifier'(Bytes9, opt_or_default, [{tag,128,7,'EXPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes9, 0 } +{Term8,Tlv9} = case Tlv8 of +[{131079,V8}|TempTlv9] -> + {'dec_AE-qualifier'(V8, []), TempTlv9}; + _ -> + { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- -%% attribute number 9 with type INTEGER OPTIONAL +%% attribute calling-AP-invocation-identifier(9) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term9,Bytes11,Rb10} = case Bytes10 of -<<2:2,_:1,8:5,_/binary>> -> -?RT_BER:decode_integer(Bytes10,[],[{tag,128,8,'EXPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes10, 0 } +{Term9,Tlv10} = case Tlv9 of +[{131080,V9}|TempTlv10] -> + {decode_integer(V9, [2]), TempTlv10}; + _ -> + { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- -%% attribute number 10 with type INTEGER OPTIONAL +%% attribute calling-AE-invocation-identifier(10) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term10,Bytes12,Rb11} = case Bytes11 of -<<2:2,_:1,9:5,_/binary>> -> -?RT_BER:decode_integer(Bytes11,[],[{tag,128,9,'EXPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes11, 0 } +{Term10,Tlv11} = case Tlv10 of +[{131081,V10}|TempTlv11] -> + {decode_integer(V10, [2]), TempTlv11}; + _ -> + { asn1_NOVALUE, Tlv10} end, %%------------------------------------------------- -%% attribute number 11 with type BIT STRING OPTIONAL +%% attribute sender-acse-requirements(11) with type BIT STRING OPTIONAL %%------------------------------------------------- - {Term11,Bytes13,Rb12} = case Bytes12 of -<<2:2,_:1,10:5,_/binary>> -> -?RT_BER:decode_bit_string(Bytes12,[],[{authentication,0},{'application-context-negotiation',1}],[{tag,128,10,'IMPLICIT',32}], no_length, mandatory); -_ -> -{ asn1_NOVALUE, Bytes12, 0 } +{Term11,Tlv12} = case Tlv11 of +[{131082,V11}|TempTlv12] -> + {decode_named_bit_string(V11, [{authentication,0},{'application-context-negotiation',1}], []), TempTlv12}; + _ -> + { asn1_NOVALUE, Tlv11} end, %%------------------------------------------------- -%% attribute number 12 with type OBJECT IDENTIFIER OPTIONAL +%% attribute mechanism-name(12) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- - {Term12,Bytes14,Rb13} = case Bytes13 of -<<2:2,_:1,11:5,_/binary>> -> -?RT_BER:decode_object_identifier(Bytes13,[{tag,128,11,'IMPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes13, 0 } +{Term12,Tlv13} = case Tlv12 of +[{131083,V12}|TempTlv13] -> + {decode_object_identifier(V12, []), TempTlv13}; + _ -> + { asn1_NOVALUE, Tlv12} end, %%------------------------------------------------- -%% attribute number 13 External ACSE-1:Authentication-value OPTIONAL +%% attribute calling-authentication-value(13) External ACSE-1:Authentication-value OPTIONAL %%------------------------------------------------- - {Term13,Bytes15,Rb14} = case Bytes14 of -<<2:2,_:1,12:5,_/binary>> -> -'dec_Authentication-value'(Bytes14, opt_or_default, [{tag,128,12,'EXPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes14, 0 } +{Term13,Tlv14} = case Tlv13 of +[{131084,V13}|TempTlv14] -> + {'dec_Authentication-value'(V13, []), TempTlv14}; + _ -> + { asn1_NOVALUE, Tlv13} end, %%------------------------------------------------- -%% attribute number 14 External ACSE-1:Application-context-name-list OPTIONAL +%% attribute application-context-name-list(14) External ACSE-1:Application-context-name-list OPTIONAL %%------------------------------------------------- - {Term14,Bytes16,Rb15} = case Bytes15 of -<<2:2,_:1,13:5,_/binary>> -> -'dec_Application-context-name-list'(Bytes15, opt_or_default, [{tag,128,13,'IMPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes15, 0 } +{Term14,Tlv15} = case Tlv14 of +[{131085,V14}|TempTlv15] -> + {'dec_Application-context-name-list'(V14, []), TempTlv15}; + _ -> + { asn1_NOVALUE, Tlv14} end, %%------------------------------------------------- -%% attribute number 15 with type GraphicString OPTIONAL +%% attribute implementation-information(15) with type GraphicString OPTIONAL %%------------------------------------------------- - {Term15,Bytes17,Rb16} = case Bytes16 of -<<2:2,_:1,29:5,_/binary>> -> -?RT_BER:decode_restricted_string(Bytes16,[],25,[{tag,128,29,'IMPLICIT',32}], no_length, mandatory); -_ -> -{ asn1_NOVALUE, Bytes16, 0 } +{Term15,Tlv16} = case Tlv15 of +[{131101,V15}|TempTlv16] -> + {begin +binary_to_list(decode_restricted_string(V15, [])) +end +, TempTlv16}; + _ -> + { asn1_NOVALUE, Tlv15} end, - {Bytes18, Rb17} = ?RT_BER:skip_ExtensionAdditions(Bytes17, [{tag,128,30,'IMPLICIT',32}]), +Tlv17 = skip_ExtensionAdditions(Tlv16, [131102]), %%------------------------------------------------- -%% attribute number 15 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(15) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {Term16,Bytes19,Rb18} = case Bytes18 of -<<2:2,_:1,30:5,_/binary>> -> -'dec_Association-information'(Bytes18, opt_or_default, [{tag,128,30,'IMPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes18, 0 } +{Term16,Tlv18} = case Tlv17 of +[{131102,V16}|TempTlv18] -> + {'dec_Association-information'(V16, []), TempTlv18}; + _ -> + { asn1_NOVALUE, Tlv17} +end, + +case Tlv18 of +[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv18}}}) % extra fields not allowed end, + {'AARQ-apdu', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8, Term9, Term10, Term11, Term12, Term13, Term14, Term15, Term16}. - {Bytes20,Rb19} = ?RT_BER:restbytes2(RemBytes, Bytes19,noext), - {{'AARQ-apdu', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8, Term9, Term10, Term11, Term12, Term13, Term14, Term15, Term16}, Bytes20, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8+Rb9+Rb10+Rb11+Rb12+Rb13+Rb14+Rb15+Rb16+Rb17+Rb18+Rb19}. %%================================ %% AARE-apdu %%================================ +'enc_AARE-apdu'(Val) -> + 'enc_AARE-apdu'(Val, [<<97>>]). + 'enc_AARE-apdu'(Val, TagIn) -> +{_,Cindex1, Cindex2, Cindex3, Cindex4, Cindex5, Cindex6, Cindex7, Cindex8, Cindex9, Cindex10, Cindex11, Cindex12, Cindex13, Cindex14} = Val, %%------------------------------------------------- -%% attribute number 1 with type BIT STRING DEFAULT = [version1] +%% attribute protocol-version(1) with type BIT STRING DEFAULT = [version1] %%------------------------------------------------- - {EncBytes1,EncLen1} = case ?RT_BER:cindex(2,Val,'protocol-version') of + {EncBytes1,EncLen1} = case Cindex1 of asn1_DEFAULT -> {<<>>,0}; [version1] -> {<<>>,0}; _ -> - ?RT_BER:encode_bit_string([], ?RT_BER:cindex(2,Val,'protocol-version'), [{version1,0}], [{tag,128,0,'IMPLICIT',32}]) + encode_named_bit_string(Cindex1, [{version1,0}], [<<128>>]) end, %%------------------------------------------------- -%% attribute number 2 with type OBJECT IDENTIFIER +%% attribute application-context-name(2) with type OBJECT IDENTIFIER %%------------------------------------------------- - {EncBytes2,EncLen2} = ?RT_BER:encode_object_identifier(?RT_BER:cindex(3,Val,'application-context-name'), [{tag,128,1,'EXPLICIT',32}]), + {EncBytes2,EncLen2} = encode_object_identifier(Cindex2, [<<6>>,<<161>>]), %%------------------------------------------------- -%% attribute number 3 with type INTEGER +%% attribute result(3) with type INTEGER %%------------------------------------------------- - {EncBytes3,EncLen3} = ?RT_BER:encode_integer([], ?RT_BER:cindex(4,Val,result), [{accepted,0},{'rejected-permanent',1},{'rejected-transient',2}], [{tag,128,2,'EXPLICIT',32}]), + {EncBytes3,EncLen3} = encode_integer(Cindex3, [{accepted,0},{'rejected-permanent',1},{'rejected-transient',2}], [<<2>>,<<162>>]), %%------------------------------------------------- -%% attribute number 4 External ACSE-1:Associate-source-diagnostic +%% attribute result-source-diagnostic(4) External ACSE-1:Associate-source-diagnostic %%------------------------------------------------- - {EncBytes4,EncLen4} = 'enc_Associate-source-diagnostic'(?RT_BER:cindex(5,Val,'result-source-diagnostic'), [{tag,128,3,'EXPLICIT',32}]), + {EncBytes4,EncLen4} = 'enc_Associate-source-diagnostic'(Cindex4, [<<163>>]), %%------------------------------------------------- -%% attribute number 5 External ACSE-1:AP-title OPTIONAL +%% attribute responding-AP-title(5) External ACSE-1:AP-title OPTIONAL %%------------------------------------------------- - {EncBytes5,EncLen5} = case ?RT_BER:cindex(6,Val,'responding-AP-title') of + {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_AP-title'(?RT_BER:cindex(6,Val,'responding-AP-title'), [{tag,128,4,'EXPLICIT',32}]) + 'enc_AP-title'(Cindex5, [<<164>>]) end, %%------------------------------------------------- -%% attribute number 6 External ACSE-1:AE-qualifier OPTIONAL +%% attribute responding-AE-qualifier(6) External ACSE-1:AE-qualifier OPTIONAL %%------------------------------------------------- - {EncBytes6,EncLen6} = case ?RT_BER:cindex(7,Val,'responding-AE-qualifier') of + {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_AE-qualifier'(?RT_BER:cindex(7,Val,'responding-AE-qualifier'), [{tag,128,5,'EXPLICIT',32}]) + 'enc_AE-qualifier'(Cindex6, [<<165>>]) end, %%------------------------------------------------- -%% attribute number 7 with type INTEGER OPTIONAL +%% attribute responding-AP-invocation-identifier(7) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes7,EncLen7} = case ?RT_BER:cindex(8,Val,'responding-AP-invocation-identifier') of + {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(8,Val,'responding-AP-invocation-identifier'), [{tag,128,6,'EXPLICIT',32}]) + encode_integer(Cindex7, [<<2>>,<<166>>]) end, %%------------------------------------------------- -%% attribute number 8 with type INTEGER OPTIONAL +%% attribute responding-AE-invocation-identifier(8) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes8,EncLen8} = case ?RT_BER:cindex(9,Val,'responding-AE-invocation-identifier') of + {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(9,Val,'responding-AE-invocation-identifier'), [{tag,128,7,'EXPLICIT',32}]) + encode_integer(Cindex8, [<<2>>,<<167>>]) end, %%------------------------------------------------- -%% attribute number 9 with type BIT STRING OPTIONAL +%% attribute responder-acse-requirements(9) with type BIT STRING OPTIONAL %%------------------------------------------------- - {EncBytes9,EncLen9} = case ?RT_BER:cindex(10,Val,'responder-acse-requirements') of + {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_bit_string([], ?RT_BER:cindex(10,Val,'responder-acse-requirements'), [{authentication,0},{'application-context-negotiation',1}], [{tag,128,8,'IMPLICIT',32}]) + encode_named_bit_string(Cindex9, [{authentication,0},{'application-context-negotiation',1}], [<<136>>]) end, %%------------------------------------------------- -%% attribute number 10 with type OBJECT IDENTIFIER OPTIONAL +%% attribute mechanism-name(10) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- - {EncBytes10,EncLen10} = case ?RT_BER:cindex(11,Val,'mechanism-name') of + {EncBytes10,EncLen10} = case Cindex10 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_object_identifier(?RT_BER:cindex(11,Val,'mechanism-name'), [{tag,128,9,'IMPLICIT',32}]) + encode_object_identifier(Cindex10, [<<137>>]) end, %%------------------------------------------------- -%% attribute number 11 External ACSE-1:Authentication-value OPTIONAL +%% attribute responding-authentication-value(11) External ACSE-1:Authentication-value OPTIONAL %%------------------------------------------------- - {EncBytes11,EncLen11} = case ?RT_BER:cindex(12,Val,'responding-authentication-value') of + {EncBytes11,EncLen11} = case Cindex11 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Authentication-value'(?RT_BER:cindex(12,Val,'responding-authentication-value'), [{tag,128,10,'EXPLICIT',32}]) + 'enc_Authentication-value'(Cindex11, [<<170>>]) end, %%------------------------------------------------- -%% attribute number 12 External ACSE-1:Application-context-name-list OPTIONAL +%% attribute application-context-name-list(12) External ACSE-1:Application-context-name-list OPTIONAL %%------------------------------------------------- - {EncBytes12,EncLen12} = case ?RT_BER:cindex(13,Val,'application-context-name-list') of + {EncBytes12,EncLen12} = case Cindex12 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Application-context-name-list'(?RT_BER:cindex(13,Val,'application-context-name-list'), [{tag,128,11,'IMPLICIT',32}]) + 'enc_Application-context-name-list'(Cindex12, [<<171>>]) end, %%------------------------------------------------- -%% attribute number 13 with type GraphicString OPTIONAL +%% attribute implementation-information(13) with type GraphicString OPTIONAL %%------------------------------------------------- - {EncBytes13,EncLen13} = case ?RT_BER:cindex(14,Val,'implementation-information') of + {EncBytes13,EncLen13} = case Cindex13 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(14,Val,'implementation-information'), 25, [{tag,128,29,'IMPLICIT',32}]) + encode_restricted_string(Cindex13, [<<157>>]) end, %%------------------------------------------------- -%% attribute number 14 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(14) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {EncBytes14,EncLen14} = case ?RT_BER:cindex(15,Val,'user-information') of + {EncBytes14,EncLen14} = case Cindex14 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Association-information'(?RT_BER:cindex(15,Val,'user-information'), [{tag,128,30,'IMPLICIT',32}]) + 'enc_Association-information'(Cindex14, [<<190>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13, EncBytes14], - LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13 + EncLen14, - ?RT_BER:encode_tags(TagIn ++ [{tag,64,1,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar). +LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13 + EncLen14, +encode_tags(TagIn, BytesSoFar, LenSoFar). -'dec_AARE-apdu'(Bytes, OptOrMand) -> - 'dec_AARE-apdu'(Bytes, OptOrMand, []). +'dec_AARE-apdu'(Tlv) -> + 'dec_AARE-apdu'(Tlv, [65537]). -'dec_AARE-apdu'(Bytes, OptOrMand, TagIn) -> +'dec_AARE-apdu'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,1,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), -{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len), +Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- -%% attribute number 1 with type BIT STRING DEFAULT = [version1] +%% attribute protocol-version(1) with type BIT STRING DEFAULT = [version1] %%------------------------------------------------- - {Term1,Bytes3,Rb2} = case Bytes2 of -<<2:2,_:1,0:5,_/binary>> -> -?RT_BER:decode_bit_string(Bytes2,[],[{version1,0}],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory); -_ -> -{[version1],Bytes2, 0 } +{Term1,Tlv2} = case Tlv1 of +[{131072,V1}|TempTlv2] -> + {decode_named_bit_string(V1, [{version1,0}], []), TempTlv2}; + _ -> + {[version1],Tlv1} end, %%------------------------------------------------- -%% attribute number 2 with type OBJECT IDENTIFIER +%% attribute application-context-name(2) with type OBJECT IDENTIFIER %%------------------------------------------------- - {Term2,Bytes4,Rb3} = ?RT_BER:decode_object_identifier(Bytes3,[{tag,128,1,'EXPLICIT',32}], mandatory), +[V2|Tlv3] = Tlv2, +Term2 = decode_object_identifier(V2, [131073,6]), %%------------------------------------------------- -%% attribute number 3 with type INTEGER +%% attribute result(3) with type INTEGER %%------------------------------------------------- - {Term3,Bytes5,Rb4} = ?RT_BER:decode_integer(Bytes4,[],[{accepted,0},{'rejected-permanent',1},{'rejected-transient',2}],[{tag,128,2,'EXPLICIT',32}], mandatory), +[V3|Tlv4] = Tlv3, +Term3 = begin +Val1 = decode_integer(V3, [131074,2]), +number2name(Val1, [{accepted,0},{'rejected-permanent',1},{'rejected-transient',2}]) +end +, %%------------------------------------------------- -%% attribute number 4 External ACSE-1:Associate-source-diagnostic +%% attribute result-source-diagnostic(4) External ACSE-1:Associate-source-diagnostic %%------------------------------------------------- - {Term4,Bytes6,Rb5} = 'dec_Associate-source-diagnostic'(Bytes5, mandatory, [{tag,128,3,'EXPLICIT',32}]), +[V4|Tlv5] = Tlv4, +Term4 = 'dec_Associate-source-diagnostic'(V4, [131075]), %%------------------------------------------------- -%% attribute number 5 External ACSE-1:AP-title OPTIONAL +%% attribute responding-AP-title(5) External ACSE-1:AP-title OPTIONAL %%------------------------------------------------- - {Term5,Bytes7,Rb6} = case Bytes6 of -<<2:2,_:1,4:5,_/binary>> -> -'dec_AP-title'(Bytes6, opt_or_default, [{tag,128,4,'EXPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes6, 0 } +{Term5,Tlv6} = case Tlv5 of +[{131076,V5}|TempTlv6] -> + {'dec_AP-title'(V5, []), TempTlv6}; + _ -> + { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- -%% attribute number 6 External ACSE-1:AE-qualifier OPTIONAL +%% attribute responding-AE-qualifier(6) External ACSE-1:AE-qualifier OPTIONAL %%------------------------------------------------- - {Term6,Bytes8,Rb7} = case Bytes7 of -<<2:2,_:1,5:5,_/binary>> -> -'dec_AE-qualifier'(Bytes7, opt_or_default, [{tag,128,5,'EXPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes7, 0 } +{Term6,Tlv7} = case Tlv6 of +[{131077,V6}|TempTlv7] -> + {'dec_AE-qualifier'(V6, []), TempTlv7}; + _ -> + { asn1_NOVALUE, Tlv6} end, %%------------------------------------------------- -%% attribute number 7 with type INTEGER OPTIONAL +%% attribute responding-AP-invocation-identifier(7) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term7,Bytes9,Rb8} = case Bytes8 of -<<2:2,_:1,6:5,_/binary>> -> -?RT_BER:decode_integer(Bytes8,[],[{tag,128,6,'EXPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes8, 0 } +{Term7,Tlv8} = case Tlv7 of +[{131078,V7}|TempTlv8] -> + {decode_integer(V7, [2]), TempTlv8}; + _ -> + { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- -%% attribute number 8 with type INTEGER OPTIONAL +%% attribute responding-AE-invocation-identifier(8) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term8,Bytes10,Rb9} = case Bytes9 of -<<2:2,_:1,7:5,_/binary>> -> -?RT_BER:decode_integer(Bytes9,[],[{tag,128,7,'EXPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes9, 0 } +{Term8,Tlv9} = case Tlv8 of +[{131079,V8}|TempTlv9] -> + {decode_integer(V8, [2]), TempTlv9}; + _ -> + { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- -%% attribute number 9 with type BIT STRING OPTIONAL +%% attribute responder-acse-requirements(9) with type BIT STRING OPTIONAL %%------------------------------------------------- - {Term9,Bytes11,Rb10} = case Bytes10 of -<<2:2,_:1,8:5,_/binary>> -> -?RT_BER:decode_bit_string(Bytes10,[],[{authentication,0},{'application-context-negotiation',1}],[{tag,128,8,'IMPLICIT',32}], no_length, mandatory); -_ -> -{ asn1_NOVALUE, Bytes10, 0 } +{Term9,Tlv10} = case Tlv9 of +[{131080,V9}|TempTlv10] -> + {decode_named_bit_string(V9, [{authentication,0},{'application-context-negotiation',1}], []), TempTlv10}; + _ -> + { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- -%% attribute number 10 with type OBJECT IDENTIFIER OPTIONAL +%% attribute mechanism-name(10) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- - {Term10,Bytes12,Rb11} = case Bytes11 of -<<2:2,_:1,9:5,_/binary>> -> -?RT_BER:decode_object_identifier(Bytes11,[{tag,128,9,'IMPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes11, 0 } +{Term10,Tlv11} = case Tlv10 of +[{131081,V10}|TempTlv11] -> + {decode_object_identifier(V10, []), TempTlv11}; + _ -> + { asn1_NOVALUE, Tlv10} end, %%------------------------------------------------- -%% attribute number 11 External ACSE-1:Authentication-value OPTIONAL +%% attribute responding-authentication-value(11) External ACSE-1:Authentication-value OPTIONAL %%------------------------------------------------- - {Term11,Bytes13,Rb12} = case Bytes12 of -<<2:2,_:1,10:5,_/binary>> -> -'dec_Authentication-value'(Bytes12, opt_or_default, [{tag,128,10,'EXPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes12, 0 } +{Term11,Tlv12} = case Tlv11 of +[{131082,V11}|TempTlv12] -> + {'dec_Authentication-value'(V11, []), TempTlv12}; + _ -> + { asn1_NOVALUE, Tlv11} end, %%------------------------------------------------- -%% attribute number 12 External ACSE-1:Application-context-name-list OPTIONAL +%% attribute application-context-name-list(12) External ACSE-1:Application-context-name-list OPTIONAL %%------------------------------------------------- - {Term12,Bytes14,Rb13} = case Bytes13 of -<<2:2,_:1,11:5,_/binary>> -> -'dec_Application-context-name-list'(Bytes13, opt_or_default, [{tag,128,11,'IMPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes13, 0 } +{Term12,Tlv13} = case Tlv12 of +[{131083,V12}|TempTlv13] -> + {'dec_Application-context-name-list'(V12, []), TempTlv13}; + _ -> + { asn1_NOVALUE, Tlv12} end, %%------------------------------------------------- -%% attribute number 13 with type GraphicString OPTIONAL +%% attribute implementation-information(13) with type GraphicString OPTIONAL %%------------------------------------------------- - {Term13,Bytes15,Rb14} = case Bytes14 of -<<2:2,_:1,29:5,_/binary>> -> -?RT_BER:decode_restricted_string(Bytes14,[],25,[{tag,128,29,'IMPLICIT',32}], no_length, mandatory); -_ -> -{ asn1_NOVALUE, Bytes14, 0 } +{Term13,Tlv14} = case Tlv13 of +[{131101,V13}|TempTlv14] -> + {begin +binary_to_list(decode_restricted_string(V13, [])) +end +, TempTlv14}; + _ -> + { asn1_NOVALUE, Tlv13} end, - {Bytes16, Rb15} = ?RT_BER:skip_ExtensionAdditions(Bytes15, [{tag,128,30,'IMPLICIT',32}]), +Tlv15 = skip_ExtensionAdditions(Tlv14, [131102]), %%------------------------------------------------- -%% attribute number 13 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(13) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {Term14,Bytes17,Rb16} = case Bytes16 of -<<2:2,_:1,30:5,_/binary>> -> -'dec_Association-information'(Bytes16, opt_or_default, [{tag,128,30,'IMPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes16, 0 } +{Term14,Tlv16} = case Tlv15 of +[{131102,V14}|TempTlv16] -> + {'dec_Association-information'(V14, []), TempTlv16}; + _ -> + { asn1_NOVALUE, Tlv15} end, - {Bytes18,Rb17} = ?RT_BER:restbytes2(RemBytes, Bytes17,noext), - {{'AARE-apdu', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8, Term9, Term10, Term11, Term12, Term13, Term14}, Bytes18, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8+Rb9+Rb10+Rb11+Rb12+Rb13+Rb14+Rb15+Rb16+Rb17}. +case Tlv16 of +[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv16}}}) % extra fields not allowed +end, + {'AARE-apdu', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8, Term9, Term10, Term11, Term12, Term13, Term14}. + %%================================ %% RLRQ-apdu %%================================ +'enc_RLRQ-apdu'(Val) -> + 'enc_RLRQ-apdu'(Val, [<<98>>]). + 'enc_RLRQ-apdu'(Val, TagIn) -> +{_,Cindex1, Cindex2} = Val, %%------------------------------------------------- -%% attribute number 1 with type INTEGER OPTIONAL +%% attribute reason(1) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes1,EncLen1} = case ?RT_BER:cindex(2,Val,reason) of + {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,reason), [{normal,0},{urgent,1},{'user-defined',30}], [{tag,128,0,'IMPLICIT',32}]) + encode_integer(Cindex1, [{normal,0},{urgent,1},{'user-defined',30}], [<<128>>]) end, %%------------------------------------------------- -%% attribute number 2 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(2) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {EncBytes2,EncLen2} = case ?RT_BER:cindex(3,Val,'user-information') of + {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Association-information'(?RT_BER:cindex(3,Val,'user-information'), [{tag,128,30,'IMPLICIT',32}]) + 'enc_Association-information'(Cindex2, [<<190>>]) end, BytesSoFar = [EncBytes1, EncBytes2], - LenSoFar = EncLen1 + EncLen2, - ?RT_BER:encode_tags(TagIn ++ [{tag,64,2,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar). +LenSoFar = EncLen1 + EncLen2, +encode_tags(TagIn, BytesSoFar, LenSoFar). -'dec_RLRQ-apdu'(Bytes, OptOrMand) -> - 'dec_RLRQ-apdu'(Bytes, OptOrMand, []). +'dec_RLRQ-apdu'(Tlv) -> + 'dec_RLRQ-apdu'(Tlv, [65538]). -'dec_RLRQ-apdu'(Bytes, OptOrMand, TagIn) -> +'dec_RLRQ-apdu'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,2,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), -{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len), +Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- -%% attribute number 1 with type INTEGER OPTIONAL +%% attribute reason(1) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term1,Bytes3,Rb2} = case Bytes2 of -<<2:2,_:1,0:5,_/binary>> -> -?RT_BER:decode_integer(Bytes2,[],[{normal,0},{urgent,1},{'user-defined',30}],[{tag,128,0,'IMPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes2, 0 } +{Term1,Tlv2} = case Tlv1 of +[{131072,V1}|TempTlv2] -> + {begin +Val1 = decode_integer(V1, []), +number2name(Val1, [{normal,0},{urgent,1},{'user-defined',30}]) +end +, TempTlv2}; + _ -> + { asn1_NOVALUE, Tlv1} end, - {Bytes4, Rb3} = ?RT_BER:skip_ExtensionAdditions(Bytes3, [{tag,128,30,'IMPLICIT',32}]), +Tlv3 = skip_ExtensionAdditions(Tlv2, [131102]), %%------------------------------------------------- -%% attribute number 1 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(1) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {Term2,Bytes5,Rb4} = case Bytes4 of -<<2:2,_:1,30:5,_/binary>> -> -'dec_Association-information'(Bytes4, opt_or_default, [{tag,128,30,'IMPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes4, 0 } +{Term2,Tlv4} = case Tlv3 of +[{131102,V2}|TempTlv4] -> + {'dec_Association-information'(V2, []), TempTlv4}; + _ -> + { asn1_NOVALUE, Tlv3} +end, + +case Tlv4 of +[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, + {'RLRQ-apdu', Term1, Term2}. - {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext), - {{'RLRQ-apdu', Term1, Term2}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}. %%================================ %% RLRE-apdu %%================================ +'enc_RLRE-apdu'(Val) -> + 'enc_RLRE-apdu'(Val, [<<99>>]). + 'enc_RLRE-apdu'(Val, TagIn) -> +{_,Cindex1, Cindex2} = Val, %%------------------------------------------------- -%% attribute number 1 with type INTEGER OPTIONAL +%% attribute reason(1) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes1,EncLen1} = case ?RT_BER:cindex(2,Val,reason) of + {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,reason), [{normal,0},{'not-finished',1},{'user-defined',30}], [{tag,128,0,'IMPLICIT',32}]) + encode_integer(Cindex1, [{normal,0},{'not-finished',1},{'user-defined',30}], [<<128>>]) end, %%------------------------------------------------- -%% attribute number 2 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(2) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {EncBytes2,EncLen2} = case ?RT_BER:cindex(3,Val,'user-information') of + {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Association-information'(?RT_BER:cindex(3,Val,'user-information'), [{tag,128,30,'IMPLICIT',32}]) + 'enc_Association-information'(Cindex2, [<<190>>]) end, BytesSoFar = [EncBytes1, EncBytes2], - LenSoFar = EncLen1 + EncLen2, - ?RT_BER:encode_tags(TagIn ++ [{tag,64,3,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar). +LenSoFar = EncLen1 + EncLen2, +encode_tags(TagIn, BytesSoFar, LenSoFar). -'dec_RLRE-apdu'(Bytes, OptOrMand) -> - 'dec_RLRE-apdu'(Bytes, OptOrMand, []). +'dec_RLRE-apdu'(Tlv) -> + 'dec_RLRE-apdu'(Tlv, [65539]). -'dec_RLRE-apdu'(Bytes, OptOrMand, TagIn) -> +'dec_RLRE-apdu'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,3,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), -{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len), +Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- -%% attribute number 1 with type INTEGER OPTIONAL +%% attribute reason(1) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term1,Bytes3,Rb2} = case Bytes2 of -<<2:2,_:1,0:5,_/binary>> -> -?RT_BER:decode_integer(Bytes2,[],[{normal,0},{'not-finished',1},{'user-defined',30}],[{tag,128,0,'IMPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes2, 0 } +{Term1,Tlv2} = case Tlv1 of +[{131072,V1}|TempTlv2] -> + {begin +Val1 = decode_integer(V1, []), +number2name(Val1, [{normal,0},{'not-finished',1},{'user-defined',30}]) +end +, TempTlv2}; + _ -> + { asn1_NOVALUE, Tlv1} end, - {Bytes4, Rb3} = ?RT_BER:skip_ExtensionAdditions(Bytes3, [{tag,128,30,'IMPLICIT',32}]), +Tlv3 = skip_ExtensionAdditions(Tlv2, [131102]), %%------------------------------------------------- -%% attribute number 1 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(1) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {Term2,Bytes5,Rb4} = case Bytes4 of -<<2:2,_:1,30:5,_/binary>> -> -'dec_Association-information'(Bytes4, opt_or_default, [{tag,128,30,'IMPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes4, 0 } +{Term2,Tlv4} = case Tlv3 of +[{131102,V2}|TempTlv4] -> + {'dec_Association-information'(V2, []), TempTlv4}; + _ -> + { asn1_NOVALUE, Tlv3} +end, + +case Tlv4 of +[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, + {'RLRE-apdu', Term1, Term2}. - {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext), - {{'RLRE-apdu', Term1, Term2}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}. %%================================ %% ABRT-apdu %%================================ +'enc_ABRT-apdu'(Val) -> + 'enc_ABRT-apdu'(Val, [<<100>>]). + 'enc_ABRT-apdu'(Val, TagIn) -> +{_,Cindex1, Cindex2, Cindex3} = Val, %%------------------------------------------------- -%% attribute number 1 with type INTEGER +%% attribute abort-source(1) with type INTEGER %%------------------------------------------------- - {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,'abort-source'), [{'acse-service-user',0},{'acse-service-provider',1}], [{tag,128,0,'IMPLICIT',32}]), + {EncBytes1,EncLen1} = encode_integer(Cindex1, [{'acse-service-user',0},{'acse-service-provider',1}], [<<128>>]), %%------------------------------------------------- -%% attribute number 2 with type ENUMERATED OPTIONAL +%% attribute abort-diagnostic(2) with type ENUMERATED OPTIONAL %%------------------------------------------------- - {EncBytes2,EncLen2} = case ?RT_BER:cindex(3,Val,'abort-diagnostic') of + {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> - case (case ?RT_BER:cindex(3,Val,'abort-diagnostic') of {_,Enumval2}->Enumval2;_->?RT_BER:cindex(3,Val,'abort-diagnostic') end) of -'no-reason-given' -> ?RT_BER:encode_enumerated(1,[{tag,128,1,'IMPLICIT',32}]); -'protocol-error' -> ?RT_BER:encode_enumerated(2,[{tag,128,1,'IMPLICIT',32}]); -'authentication-mechanism-name-not-recognized' -> ?RT_BER:encode_enumerated(3,[{tag,128,1,'IMPLICIT',32}]); -'authentication-mechanism-name-required' -> ?RT_BER:encode_enumerated(4,[{tag,128,1,'IMPLICIT',32}]); -'authentication-failure' -> ?RT_BER:encode_enumerated(5,[{tag,128,1,'IMPLICIT',32}]); -'authentication-required' -> ?RT_BER:encode_enumerated(6,[{tag,128,1,'IMPLICIT',32}]); -Enumval3 -> exit({error,{asn1, {enumerated_not_in_range,Enumval3}}}) + case Cindex2 of +'no-reason-given' -> encode_tags([<<129>>], [1], 1); +'protocol-error' -> encode_tags([<<129>>], [2], 1); +'authentication-mechanism-name-not-recognized' -> encode_tags([<<129>>], [3], 1); +'authentication-mechanism-name-required' -> encode_tags([<<129>>], [4], 1); +'authentication-failure' -> encode_tags([<<129>>], [5], 1); +'authentication-required' -> encode_tags([<<129>>], [6], 1); +Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}}) end end, %%------------------------------------------------- -%% attribute number 3 External ACSE-1:Association-information OPTIONAL +%% attribute user-information(3) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {EncBytes3,EncLen3} = case ?RT_BER:cindex(4,Val,'user-information') of + {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> - 'enc_Association-information'(?RT_BER:cindex(4,Val,'user-information'), [{tag,128,30,'IMPLICIT',32}]) + 'enc_Association-information'(Cindex3, [<<190>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], - LenSoFar = EncLen1 + EncLen2 + EncLen3, - ?RT_BER:encode_tags(TagIn ++ [{tag,64,4,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar). +LenSoFar = EncLen1 + EncLen2 + EncLen3, +encode_tags(TagIn, BytesSoFar, LenSoFar). -'dec_ABRT-apdu'(Bytes, OptOrMand) -> - 'dec_ABRT-apdu'(Bytes, OptOrMand, []). +'dec_ABRT-apdu'(Tlv) -> + 'dec_ABRT-apdu'(Tlv, [65540]). -'dec_ABRT-apdu'(Bytes, OptOrMand, TagIn) -> +'dec_ABRT-apdu'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,4,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), -{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len), +Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- -%% attribute number 1 with type INTEGER +%% attribute abort-source(1) with type INTEGER %%------------------------------------------------- - {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,[],[{'acse-service-user',0},{'acse-service-provider',1}],[{tag,128,0,'IMPLICIT',32}], mandatory), +[V1|Tlv2] = Tlv1, +Term1 = begin +Val1 = decode_integer(V1, [131072]), +number2name(Val1, [{'acse-service-user',0},{'acse-service-provider',1}]) +end +, + +%%------------------------------------------------- +%% attribute abort-diagnostic(2) with type ENUMERATED OPTIONAL +%%------------------------------------------------- +{Term2,Tlv3} = case Tlv2 of +[{131073,V2}|TempTlv3] -> + {case decode_integer(V2, []) of +1 -> 'no-reason-given'; +2 -> 'protocol-error'; +3 -> 'authentication-mechanism-name-not-recognized'; +4 -> 'authentication-mechanism-name-required'; +5 -> 'authentication-failure'; +6 -> 'authentication-required'; +Default1 -> {asn1_enum,Default1} +end, TempTlv3}; + _ -> + { asn1_NOVALUE, Tlv2} +end, +Tlv4 = skip_ExtensionAdditions(Tlv3, [131102]), %%------------------------------------------------- -%% attribute number 2 with type ENUMERATED OPTIONAL +%% attribute user-information(2) External ACSE-1:Association-information OPTIONAL %%------------------------------------------------- - {Term2,Bytes4,Rb3} = case Bytes3 of -<<2:2,_:1,1:5,_/binary>> -> -?RT_BER:decode_enumerated(Bytes3,[],{[{'no-reason-given',1},{'protocol-error',2},{'authentication-mechanism-name-not-recognized',3},{'authentication-mechanism-name-required',4},{'authentication-failure',5},{'authentication-required',6}],[]},[{tag,128,1,'IMPLICIT',32}], mandatory); -_ -> -{ asn1_NOVALUE, Bytes3, 0 } +{Term3,Tlv5} = case Tlv4 of +[{131102,V3}|TempTlv5] -> + {'dec_Association-information'(V3, []), TempTlv5}; + _ -> + { asn1_NOVALUE, Tlv4} end, - {Bytes5, Rb4} = ?RT_BER:skip_ExtensionAdditions(Bytes4, [{tag,128,30,'IMPLICIT',32}]), -%%------------------------------------------------- -%% attribute number 2 External ACSE-1:Association-information OPTIONAL -%%------------------------------------------------- - {Term3,Bytes6,Rb5} = case Bytes5 of -<<2:2,_:1,30:5,_/binary>> -> -'dec_Association-information'(Bytes5, opt_or_default, [{tag,128,30,'IMPLICIT',32}]); -_ -> -{ asn1_NOVALUE, Bytes5, 0 } +case Tlv5 of +[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, + {'ABRT-apdu', Term1, Term2, Term3}. - {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext), - {{'ABRT-apdu', Term1, Term2, Term3}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}. %%================================ %% ABRT-diagnostic %%================================ - -'enc_ABRT-diagnostic'({'ABRT-diagnostic',Val}, TagIn) -> - 'enc_ABRT-diagnostic'(Val, TagIn); +'enc_ABRT-diagnostic'(Val) -> + 'enc_ABRT-diagnostic'(Val, [<<10>>]). 'enc_ABRT-diagnostic'(Val, TagIn) -> -case (case Val of {_,Enumval1}->Enumval1;_->Val end) of -'no-reason-given' -> ?RT_BER:encode_enumerated(1,TagIn ++ []); -'protocol-error' -> ?RT_BER:encode_enumerated(2,TagIn ++ []); -'authentication-mechanism-name-not-recognized' -> ?RT_BER:encode_enumerated(3,TagIn ++ []); -'authentication-mechanism-name-required' -> ?RT_BER:encode_enumerated(4,TagIn ++ []); -'authentication-failure' -> ?RT_BER:encode_enumerated(5,TagIn ++ []); -'authentication-required' -> ?RT_BER:encode_enumerated(6,TagIn ++ []); -Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}}) +case Val of +'no-reason-given' -> encode_tags(TagIn, [1], 1); +'protocol-error' -> encode_tags(TagIn, [2], 1); +'authentication-mechanism-name-not-recognized' -> encode_tags(TagIn, [3], 1); +'authentication-mechanism-name-required' -> encode_tags(TagIn, [4], 1); +'authentication-failure' -> encode_tags(TagIn, [5], 1); +'authentication-required' -> encode_tags(TagIn, [6], 1); +Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. -'dec_ABRT-diagnostic'(Bytes, OptOrMand) -> - 'dec_ABRT-diagnostic'(Bytes, OptOrMand, []). +'dec_ABRT-diagnostic'(Tlv) -> + 'dec_ABRT-diagnostic'(Tlv, [10]). -'dec_ABRT-diagnostic'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_enumerated(Bytes,[],{[{'no-reason-given',1},{'protocol-error',2},{'authentication-mechanism-name-not-recognized',3},{'authentication-mechanism-name-required',4},{'authentication-failure',5},{'authentication-required',6}],[]},TagIn++[], OptOrMand). +'dec_ABRT-diagnostic'(Tlv, TagIn) -> +case decode_integer(Tlv, TagIn) of +1 -> 'no-reason-given'; +2 -> 'protocol-error'; +3 -> 'authentication-mechanism-name-not-recognized'; +4 -> 'authentication-mechanism-name-required'; +5 -> 'authentication-failure'; +6 -> 'authentication-required'; +Default1 -> {asn1_enum,Default1} +end. %%================================ %% ABRT-source %%================================ - -'enc_ABRT-source'({'ABRT-source',Val}, TagIn) -> - 'enc_ABRT-source'(Val, TagIn); +'enc_ABRT-source'(Val) -> + 'enc_ABRT-source'(Val, [<<2>>]). 'enc_ABRT-source'(Val, TagIn) -> -?RT_BER:encode_integer([], Val, [{'acse-service-user',0},{'acse-service-provider',1}], TagIn ++ []). +encode_integer(Val, [{'acse-service-user',0},{'acse-service-provider',1}], TagIn). -'dec_ABRT-source'(Bytes, OptOrMand) -> - 'dec_ABRT-source'(Bytes, OptOrMand, []). +'dec_ABRT-source'(Tlv) -> + 'dec_ABRT-source'(Tlv, [2]). -'dec_ABRT-source'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_integer(Bytes,[],[{'acse-service-user',0},{'acse-service-provider',1}],TagIn++[], OptOrMand). +'dec_ABRT-source'(Tlv, TagIn) -> +begin +Val1 = decode_integer(Tlv, TagIn), +number2name(Val1, [{'acse-service-user',0},{'acse-service-provider',1}]) +end +. %%================================ %% ACSE-requirements %%================================ - -'enc_ACSE-requirements'({'ACSE-requirements',Val}, TagIn) -> - 'enc_ACSE-requirements'(Val, TagIn); +'enc_ACSE-requirements'(Val) -> + 'enc_ACSE-requirements'(Val, [<<3>>]). 'enc_ACSE-requirements'(Val, TagIn) -> -?RT_BER:encode_bit_string([], Val, [{authentication,0},{'application-context-negotiation',1}], TagIn ++ []). +encode_named_bit_string(Val, [{authentication,0},{'application-context-negotiation',1}], TagIn). -'dec_ACSE-requirements'(Bytes, OptOrMand) -> - 'dec_ACSE-requirements'(Bytes, OptOrMand, []). +'dec_ACSE-requirements'(Tlv) -> + 'dec_ACSE-requirements'(Tlv, [3]). -'dec_ACSE-requirements'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_bit_string(Bytes,[],[{authentication,0},{'application-context-negotiation',1}],TagIn++[], no_length, OptOrMand). +'dec_ACSE-requirements'(Tlv, TagIn) -> +decode_named_bit_string(Tlv, [{authentication,0},{'application-context-negotiation',1}], TagIn). %%================================ %% Application-context-name-list %%================================ - -'enc_Application-context-name-list'({'Application-context-name-list',Val}, TagIn) -> - 'enc_Application-context-name-list'(Val, TagIn); +'enc_Application-context-name-list'(Val) -> + 'enc_Application-context-name-list'(Val, [<<48>>]). 'enc_Application-context-name-list'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Application-context-name-list_components'(Val,[],0), - ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen). + encode_tags(TagIn, EncBytes, EncLen). 'enc_Application-context-name-list_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Application-context-name-list_components'([H|T],AccBytes, AccLen) -> - {EncBytes,EncLen} = ?RT_BER:encode_object_identifier(H, []), + {EncBytes,EncLen} = encode_object_identifier(H, [<<6>>]), 'enc_Application-context-name-list_components'(T,[EncBytes|AccBytes], AccLen + EncLen). -'dec_Application-context-name-list'(Bytes, OptOrMand) -> - 'dec_Application-context-name-list'(Bytes, OptOrMand, []). +'dec_Application-context-name-list'(Tlv) -> + 'dec_Application-context-name-list'(Tlv, [16]). -'dec_Application-context-name-list'(Bytes, OptOrMand, TagIn) -> +'dec_Application-context-name-list'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), - ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)-> -?RT_BER:decode_object_identifier(FBytes,[], mandatory) -end, [], []). +Tlv1 = match_tags(Tlv, TagIn), +[decode_object_identifier(V1, [6]) || V1 <- Tlv1]. @@ -1220,413 +1252,395 @@ end, [], []). %%================================ %% Application-context-name %%================================ - -'enc_Application-context-name'({'Application-context-name',Val}, TagIn) -> - 'enc_Application-context-name'(Val, TagIn); +'enc_Application-context-name'(Val) -> + 'enc_Application-context-name'(Val, [<<6>>]). 'enc_Application-context-name'(Val, TagIn) -> -?RT_BER:encode_object_identifier(Val, TagIn ++ []). +encode_object_identifier(Val, TagIn). -'dec_Application-context-name'(Bytes, OptOrMand) -> - 'dec_Application-context-name'(Bytes, OptOrMand, []). +'dec_Application-context-name'(Tlv) -> + 'dec_Application-context-name'(Tlv, [6]). -'dec_Application-context-name'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_object_identifier(Bytes,TagIn++[], OptOrMand). +'dec_Application-context-name'(Tlv, TagIn) -> +decode_object_identifier(Tlv, TagIn). %%================================ %% AP-title %%================================ - -'enc_AP-title'({'AP-title',Val}, TagIn) -> - 'enc_AP-title'(Val, TagIn); +'enc_AP-title'(Val) -> + 'enc_AP-title'(Val, []). 'enc_AP-title'(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of 'ap-title-form1' -> 'enc_AP-title-form1'(element(2,Val), []); 'ap-title-form2' -> - ?RT_BER:encode_object_identifier(element(2,Val), []); + encode_object_identifier(element(2,Val), [<<6>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, -?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen). +encode_tags(TagIn, EncBytes, EncLen). -'dec_AP-title'(Bytes, OptOrMand) -> - 'dec_AP-title'(Bytes, OptOrMand, []). +'dec_AP-title'(Tlv) -> + 'dec_AP-title'(Tlv, []). -'dec_AP-title'(Bytes, OptOrMand, TagIn) -> - {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand), - IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end, - IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end, - case Bytes1 of +'dec_AP-title'(Tlv, TagIn) -> +Tlv1 = match_tags(Tlv, TagIn), +case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'ap-title-form1' - <<0:2,_:1,16:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_AP-title-form1'(Bytes1, mandatory, []), - {{'ap-title-form1', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + V1 = {16,_} -> + {'ap-title-form1', 'dec_AP-title-form1'(V1, [])}; %% 'ap-title-form2' - <<0:2,_:1,6:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_object_identifier(Bytes1,[], mandatory), - {{'ap-title-form2', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {6, V1} -> + {'ap-title-form2', decode_object_identifier(V1, [])}; - _ -> - {{asn1_ExtAlt,Bytes1},<<>>, RbExp} - end. + Else -> + {asn1_ExtAlt,ber_encode(Else)} + end +. %%================================ %% AE-qualifier %%================================ - -'enc_AE-qualifier'({'AE-qualifier',Val}, TagIn) -> - 'enc_AE-qualifier'(Val, TagIn); +'enc_AE-qualifier'(Val) -> + 'enc_AE-qualifier'(Val, []). 'enc_AE-qualifier'(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of 'ae-qualifier-form1' -> - 'enc_AE-qualifier-form1'(element(2,Val), []); + 'enc_AE-qualifier-form1'(element(2,Val), [<<49>>]); 'ae-qualifier-form2' -> - ?RT_BER:encode_integer([], element(2,Val), []); + encode_integer(element(2,Val), [<<2>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, -?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen). +encode_tags(TagIn, EncBytes, EncLen). -'dec_AE-qualifier'(Bytes, OptOrMand) -> - 'dec_AE-qualifier'(Bytes, OptOrMand, []). +'dec_AE-qualifier'(Tlv) -> + 'dec_AE-qualifier'(Tlv, []). -'dec_AE-qualifier'(Bytes, OptOrMand, TagIn) -> - {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand), - IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end, - IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end, - case Bytes1 of +'dec_AE-qualifier'(Tlv, TagIn) -> +Tlv1 = match_tags(Tlv, TagIn), +case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'ae-qualifier-form1' - <<0:2,_:1,17:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_AE-qualifier-form1'(Bytes1, mandatory, []), - {{'ae-qualifier-form1', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {17, V1} -> + {'ae-qualifier-form1', 'dec_AE-qualifier-form1'(V1, [])}; %% 'ae-qualifier-form2' - <<0:2,_:1,2:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_integer(Bytes1,[],[], mandatory), - {{'ae-qualifier-form2', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {2, V1} -> + {'ae-qualifier-form2', decode_integer(V1, [])}; - _ -> - {{asn1_ExtAlt,Bytes1},<<>>, RbExp} - end. + Else -> + {asn1_ExtAlt,ber_encode(Else)} + end +. %%================================ %% AP-title-form1 %%================================ - -'enc_AP-title-form1'({'AP-title-form1',Val}, TagIn) -> - 'enc_AP-title-form1'(Val, TagIn); +'enc_AP-title-form1'(Val) -> + 'enc_AP-title-form1'(Val, []). 'enc_AP-title-form1'(Val, TagIn) -> - 'InformationFramework':'enc_Name'(Val, TagIn ++ []). + 'InformationFramework':'enc_Name'(Val, TagIn). -'dec_AP-title-form1'(Bytes, OptOrMand) -> - 'dec_AP-title-form1'(Bytes, OptOrMand, []). +'dec_AP-title-form1'(Tlv) -> + 'dec_AP-title-form1'(Tlv, []). -'dec_AP-title-form1'(Bytes, OptOrMand, TagIn) -> -'InformationFramework':'dec_Name'(Bytes, OptOrMand, TagIn++[]). +'dec_AP-title-form1'(Tlv, TagIn) -> +'InformationFramework':'dec_Name'(Tlv, TagIn). %%================================ %% AE-qualifier-form1 %%================================ - -'enc_AE-qualifier-form1'({'AE-qualifier-form1',Val}, TagIn) -> - 'enc_AE-qualifier-form1'(Val, TagIn); +'enc_AE-qualifier-form1'(Val) -> + 'enc_AE-qualifier-form1'(Val, [<<49>>]). 'enc_AE-qualifier-form1'(Val, TagIn) -> - 'InformationFramework':'enc_RelativeDistinguishedName'(Val, TagIn ++ []). + 'InformationFramework':'enc_RelativeDistinguishedName'(Val, TagIn). -'dec_AE-qualifier-form1'(Bytes, OptOrMand) -> - 'dec_AE-qualifier-form1'(Bytes, OptOrMand, []). +'dec_AE-qualifier-form1'(Tlv) -> + 'dec_AE-qualifier-form1'(Tlv, [17]). -'dec_AE-qualifier-form1'(Bytes, OptOrMand, TagIn) -> -'InformationFramework':'dec_RelativeDistinguishedName'(Bytes, OptOrMand, TagIn++[]). +'dec_AE-qualifier-form1'(Tlv, TagIn) -> +'InformationFramework':'dec_RelativeDistinguishedName'(Tlv, TagIn). %%================================ %% AP-title-form2 %%================================ - -'enc_AP-title-form2'({'AP-title-form2',Val}, TagIn) -> - 'enc_AP-title-form2'(Val, TagIn); +'enc_AP-title-form2'(Val) -> + 'enc_AP-title-form2'(Val, [<<6>>]). 'enc_AP-title-form2'(Val, TagIn) -> -?RT_BER:encode_object_identifier(Val, TagIn ++ []). +encode_object_identifier(Val, TagIn). -'dec_AP-title-form2'(Bytes, OptOrMand) -> - 'dec_AP-title-form2'(Bytes, OptOrMand, []). +'dec_AP-title-form2'(Tlv) -> + 'dec_AP-title-form2'(Tlv, [6]). -'dec_AP-title-form2'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_object_identifier(Bytes,TagIn++[], OptOrMand). +'dec_AP-title-form2'(Tlv, TagIn) -> +decode_object_identifier(Tlv, TagIn). %%================================ %% AE-qualifier-form2 %%================================ - -'enc_AE-qualifier-form2'({'AE-qualifier-form2',Val}, TagIn) -> - 'enc_AE-qualifier-form2'(Val, TagIn); +'enc_AE-qualifier-form2'(Val) -> + 'enc_AE-qualifier-form2'(Val, [<<2>>]). 'enc_AE-qualifier-form2'(Val, TagIn) -> -?RT_BER:encode_integer([], Val, TagIn ++ []). +encode_integer(Val, TagIn). -'dec_AE-qualifier-form2'(Bytes, OptOrMand) -> - 'dec_AE-qualifier-form2'(Bytes, OptOrMand, []). +'dec_AE-qualifier-form2'(Tlv) -> + 'dec_AE-qualifier-form2'(Tlv, [2]). -'dec_AE-qualifier-form2'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_integer(Bytes,[],TagIn++[], OptOrMand). +'dec_AE-qualifier-form2'(Tlv, TagIn) -> +decode_integer(Tlv, TagIn). %%================================ %% AE-title %%================================ - -'enc_AE-title'({'AE-title',Val}, TagIn) -> - 'enc_AE-title'(Val, TagIn); +'enc_AE-title'(Val) -> + 'enc_AE-title'(Val, []). 'enc_AE-title'(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of 'ae-title-form1' -> 'enc_AE-title-form1'(element(2,Val), []); 'ae-title-form2' -> - ?RT_BER:encode_object_identifier(element(2,Val), []); + encode_object_identifier(element(2,Val), [<<6>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, -?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen). +encode_tags(TagIn, EncBytes, EncLen). -'dec_AE-title'(Bytes, OptOrMand) -> - 'dec_AE-title'(Bytes, OptOrMand, []). +'dec_AE-title'(Tlv) -> + 'dec_AE-title'(Tlv, []). -'dec_AE-title'(Bytes, OptOrMand, TagIn) -> - {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand), - IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end, - IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end, - case Bytes1 of +'dec_AE-title'(Tlv, TagIn) -> +Tlv1 = match_tags(Tlv, TagIn), +case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'ae-title-form1' - <<0:2,_:1,16:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_AE-title-form1'(Bytes1, mandatory, []), - {{'ae-title-form1', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + V1 = {16,_} -> + {'ae-title-form1', 'dec_AE-title-form1'(V1, [])}; %% 'ae-title-form2' - <<0:2,_:1,6:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_object_identifier(Bytes1,[], mandatory), - {{'ae-title-form2', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {6, V1} -> + {'ae-title-form2', decode_object_identifier(V1, [])}; - _ -> - {{asn1_ExtAlt,Bytes1},<<>>, RbExp} - end. + Else -> + {asn1_ExtAlt,ber_encode(Else)} + end +. %%================================ %% AE-title-form1 %%================================ - -'enc_AE-title-form1'({'AE-title-form1',Val}, TagIn) -> - 'enc_AE-title-form1'(Val, TagIn); +'enc_AE-title-form1'(Val) -> + 'enc_AE-title-form1'(Val, []). 'enc_AE-title-form1'(Val, TagIn) -> - 'InformationFramework':'enc_Name'(Val, TagIn ++ []). + 'InformationFramework':'enc_Name'(Val, TagIn). -'dec_AE-title-form1'(Bytes, OptOrMand) -> - 'dec_AE-title-form1'(Bytes, OptOrMand, []). +'dec_AE-title-form1'(Tlv) -> + 'dec_AE-title-form1'(Tlv, []). -'dec_AE-title-form1'(Bytes, OptOrMand, TagIn) -> -'InformationFramework':'dec_Name'(Bytes, OptOrMand, TagIn++[]). +'dec_AE-title-form1'(Tlv, TagIn) -> +'InformationFramework':'dec_Name'(Tlv, TagIn). %%================================ %% AE-title-form2 %%================================ - -'enc_AE-title-form2'({'AE-title-form2',Val}, TagIn) -> - 'enc_AE-title-form2'(Val, TagIn); +'enc_AE-title-form2'(Val) -> + 'enc_AE-title-form2'(Val, [<<6>>]). 'enc_AE-title-form2'(Val, TagIn) -> -?RT_BER:encode_object_identifier(Val, TagIn ++ []). +encode_object_identifier(Val, TagIn). -'dec_AE-title-form2'(Bytes, OptOrMand) -> - 'dec_AE-title-form2'(Bytes, OptOrMand, []). +'dec_AE-title-form2'(Tlv) -> + 'dec_AE-title-form2'(Tlv, [6]). -'dec_AE-title-form2'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_object_identifier(Bytes,TagIn++[], OptOrMand). +'dec_AE-title-form2'(Tlv, TagIn) -> +decode_object_identifier(Tlv, TagIn). %%================================ %% AE-invocation-identifier %%================================ - -'enc_AE-invocation-identifier'({'AE-invocation-identifier',Val}, TagIn) -> - 'enc_AE-invocation-identifier'(Val, TagIn); +'enc_AE-invocation-identifier'(Val) -> + 'enc_AE-invocation-identifier'(Val, [<<2>>]). 'enc_AE-invocation-identifier'(Val, TagIn) -> -?RT_BER:encode_integer([], Val, TagIn ++ []). +encode_integer(Val, TagIn). -'dec_AE-invocation-identifier'(Bytes, OptOrMand) -> - 'dec_AE-invocation-identifier'(Bytes, OptOrMand, []). +'dec_AE-invocation-identifier'(Tlv) -> + 'dec_AE-invocation-identifier'(Tlv, [2]). -'dec_AE-invocation-identifier'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_integer(Bytes,[],TagIn++[], OptOrMand). +'dec_AE-invocation-identifier'(Tlv, TagIn) -> +decode_integer(Tlv, TagIn). %%================================ %% AP-invocation-identifier %%================================ - -'enc_AP-invocation-identifier'({'AP-invocation-identifier',Val}, TagIn) -> - 'enc_AP-invocation-identifier'(Val, TagIn); +'enc_AP-invocation-identifier'(Val) -> + 'enc_AP-invocation-identifier'(Val, [<<2>>]). 'enc_AP-invocation-identifier'(Val, TagIn) -> -?RT_BER:encode_integer([], Val, TagIn ++ []). +encode_integer(Val, TagIn). -'dec_AP-invocation-identifier'(Bytes, OptOrMand) -> - 'dec_AP-invocation-identifier'(Bytes, OptOrMand, []). +'dec_AP-invocation-identifier'(Tlv) -> + 'dec_AP-invocation-identifier'(Tlv, [2]). -'dec_AP-invocation-identifier'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_integer(Bytes,[],TagIn++[], OptOrMand). +'dec_AP-invocation-identifier'(Tlv, TagIn) -> +decode_integer(Tlv, TagIn). %%================================ %% Associate-result %%================================ - -'enc_Associate-result'({'Associate-result',Val}, TagIn) -> - 'enc_Associate-result'(Val, TagIn); +'enc_Associate-result'(Val) -> + 'enc_Associate-result'(Val, [<<2>>]). 'enc_Associate-result'(Val, TagIn) -> -?RT_BER:encode_integer([], Val, [{accepted,0},{'rejected-permanent',1},{'rejected-transient',2}], TagIn ++ []). +encode_integer(Val, [{accepted,0},{'rejected-permanent',1},{'rejected-transient',2}], TagIn). -'dec_Associate-result'(Bytes, OptOrMand) -> - 'dec_Associate-result'(Bytes, OptOrMand, []). +'dec_Associate-result'(Tlv) -> + 'dec_Associate-result'(Tlv, [2]). -'dec_Associate-result'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_integer(Bytes,[],[{accepted,0},{'rejected-permanent',1},{'rejected-transient',2}],TagIn++[], OptOrMand). +'dec_Associate-result'(Tlv, TagIn) -> +begin +Val1 = decode_integer(Tlv, TagIn), +number2name(Val1, [{accepted,0},{'rejected-permanent',1},{'rejected-transient',2}]) +end +. %%================================ %% Associate-source-diagnostic %%================================ - -'enc_Associate-source-diagnostic'({'Associate-source-diagnostic',Val}, TagIn) -> - 'enc_Associate-source-diagnostic'(Val, TagIn); +'enc_Associate-source-diagnostic'(Val) -> + 'enc_Associate-source-diagnostic'(Val, []). 'enc_Associate-source-diagnostic'(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of 'acse-service-user' -> - ?RT_BER:encode_integer([], element(2,Val), [{null,0},{'no-reason-given',1},{'application-context-name-not-supported',2},{'calling-AP-title-not-recognized',3},{'calling-AP-invocation-identifier-not-recognized',4},{'calling-AE-qualifier-not-recognized',5},{'calling-AE-invocation-identifier-not-recognized',6},{'called-AP-title-not-recognized',7},{'called-AP-invocation-identifier-not-recognized',8},{'called-AE-qualifier-not-recognized',9},{'called-AE-invocation-identifier-not-recognized',10},{'authentication-mechanism-name-not-recognized',11},{'authentication-mechanism-name-required',12},{'authentication-failure',13},{'authentication-required',14}], [{tag,128,1,'EXPLICIT',32}]); + encode_integer(element(2,Val), [{null,0},{'no-reason-given',1},{'application-context-name-not-supported',2},{'calling-AP-title-not-recognized',3},{'calling-AP-invocation-identifier-not-recognized',4},{'calling-AE-qualifier-not-recognized',5},{'calling-AE-invocation-identifier-not-recognized',6},{'called-AP-title-not-recognized',7},{'called-AP-invocation-identifier-not-recognized',8},{'called-AE-qualifier-not-recognized',9},{'called-AE-invocation-identifier-not-recognized',10},{'authentication-mechanism-name-not-recognized',11},{'authentication-mechanism-name-required',12},{'authentication-failure',13},{'authentication-required',14}], [<<2>>,<<161>>]); 'acse-service-provider' -> - ?RT_BER:encode_integer([], element(2,Val), [{null,0},{'no-reason-given',1},{'no-common-acse-version',2}], [{tag,128,2,'EXPLICIT',32}]); + encode_integer(element(2,Val), [{null,0},{'no-reason-given',1},{'no-common-acse-version',2}], [<<2>>,<<162>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, -?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen). +encode_tags(TagIn, EncBytes, EncLen). -'dec_Associate-source-diagnostic'(Bytes, OptOrMand) -> - 'dec_Associate-source-diagnostic'(Bytes, OptOrMand, []). +'dec_Associate-source-diagnostic'(Tlv) -> + 'dec_Associate-source-diagnostic'(Tlv, []). -'dec_Associate-source-diagnostic'(Bytes, OptOrMand, TagIn) -> - {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand), - IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end, - IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end, - case Bytes1 of +'dec_Associate-source-diagnostic'(Tlv, TagIn) -> +Tlv1 = match_tags(Tlv, TagIn), +case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'acse-service-user' - <<2:2,_:1,1:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_integer(Bytes1,[],[{null,0},{'no-reason-given',1},{'application-context-name-not-supported',2},{'calling-AP-title-not-recognized',3},{'calling-AP-invocation-identifier-not-recognized',4},{'calling-AE-qualifier-not-recognized',5},{'calling-AE-invocation-identifier-not-recognized',6},{'called-AP-title-not-recognized',7},{'called-AP-invocation-identifier-not-recognized',8},{'called-AE-qualifier-not-recognized',9},{'called-AE-invocation-identifier-not-recognized',10},{'authentication-mechanism-name-not-recognized',11},{'authentication-mechanism-name-required',12},{'authentication-failure',13},{'authentication-required',14}],[{tag,128,1,'EXPLICIT',32}], mandatory), - {{'acse-service-user', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {131073, V1} -> + {'acse-service-user', begin +Val1 = decode_integer(V1, [2]), +number2name(Val1, [{null,0},{'no-reason-given',1},{'application-context-name-not-supported',2},{'calling-AP-title-not-recognized',3},{'calling-AP-invocation-identifier-not-recognized',4},{'calling-AE-qualifier-not-recognized',5},{'calling-AE-invocation-identifier-not-recognized',6},{'called-AP-title-not-recognized',7},{'called-AP-invocation-identifier-not-recognized',8},{'called-AE-qualifier-not-recognized',9},{'called-AE-invocation-identifier-not-recognized',10},{'authentication-mechanism-name-not-recognized',11},{'authentication-mechanism-name-required',12},{'authentication-failure',13},{'authentication-required',14}]) +end +}; %% 'acse-service-provider' - <<2:2,_:1,2:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_integer(Bytes1,[],[{null,0},{'no-reason-given',1},{'no-common-acse-version',2}],[{tag,128,2,'EXPLICIT',32}], mandatory), - {{'acse-service-provider', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; + {131074, V1} -> + {'acse-service-provider', begin +Val2 = decode_integer(V1, [2]), +number2name(Val2, [{null,0},{'no-reason-given',1},{'no-common-acse-version',2}]) +end +}; Else -> - case OptOrMand of - mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}}); - _ ->exit({error,{asn1,{no_optional_tag,Else}}}) - end - end. + exit({error,{asn1,{invalid_choice_tag,Else}}}) + end +. %%================================ %% Association-information %%================================ - -'enc_Association-information'({'Association-information',Val}, TagIn) -> - 'enc_Association-information'(Val, TagIn); +'enc_Association-information'(Val) -> + 'enc_Association-information'(Val, [<<48>>]). 'enc_Association-information'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Association-information_components'(Val,[],0), - ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen). + encode_tags(TagIn, EncBytes, EncLen). 'enc_Association-information_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Association-information_components'([H|T],AccBytes, AccLen) -> - {EncBytes,EncLen} = 'enc_EXTERNAL'(H, []), + {EncBytes,EncLen} = 'enc_EXTERNAL'(H, [<<40>>]), 'enc_Association-information_components'(T,[EncBytes|AccBytes], AccLen + EncLen). -'dec_Association-information'(Bytes, OptOrMand) -> - 'dec_Association-information'(Bytes, OptOrMand, []). +'dec_Association-information'(Tlv) -> + 'dec_Association-information'(Tlv, [16]). -'dec_Association-information'(Bytes, OptOrMand, TagIn) -> +'dec_Association-information'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), - ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_EXTERNAL'/3, [], []). +Tlv1 = match_tags(Tlv, TagIn), +['dec_EXTERNAL'(V1, [8]) || V1 <- Tlv1]. @@ -1634,25 +1648,24 @@ end, [], []). %%================================ %% Authentication-value %%================================ - -'enc_Authentication-value'({'Authentication-value',Val}, TagIn) -> - 'enc_Authentication-value'(Val, TagIn); +'enc_Authentication-value'(Val) -> + 'enc_Authentication-value'(Val, []). 'enc_Authentication-value'(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of charstring -> - ?RT_BER:encode_restricted_string([], element(2,Val), 25, [{tag,128,0,'IMPLICIT',32}]); + encode_restricted_string(element(2,Val), [<<128>>]); bitstring -> - ?RT_BER:encode_bit_string([], element(2,Val), [], [{tag,128,1,'IMPLICIT',32}]); + encode_unnamed_bit_string(element(2,Val), [<<129>>]); external -> - 'enc_EXTERNAL'(element(2,Val), [{tag,128,2,'IMPLICIT',32}]); + 'enc_EXTERNAL'(element(2,Val), [<<162>>]); other -> - 'enc_Authentication-value_other'(element(2,Val), [{tag,128,3,'IMPLICIT',32}]); + 'enc_Authentication-value_other'(element(2,Val), [<<163>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, -?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen). +encode_tags(TagIn, EncBytes, EncLen). @@ -1662,327 +1675,322 @@ end, [], []). %% Authentication-value_other %%================================ 'enc_Authentication-value_other'(Val, TagIn) -> - Objother_mechanism_name = - 'ACSE-1':'getenc_ObjectSet'(id, - value_match([],?RT_BER:cindex(2,Val,'other-mechanism-name'))), + {_,Cindex1, Cindex2} = Val, +Objother_mechanism_name = + 'ACSE-1':'getenc_ObjectSet'( Cindex1), %%------------------------------------------------- -%% attribute number 1 with type fixedtypevaluefieldidtypeOBJECT IDENTIFIERno +%% attribute other-mechanism-name(1) with type OBJECT IDENTIFIER %%------------------------------------------------- - {EncBytes1,EncLen1} = ?RT_BER:encode_object_identifier(?RT_BER:cindex(2,Val,'other-mechanism-name'), []), + {EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]), %%------------------------------------------------- -%% attribute number 2 with type typefieldType +%% attribute other-mechanism-value(2) with type typefieldType %%------------------------------------------------- - {TmpBytes1,_} = Objother_mechanism_name('Type', ?RT_BER:cindex(3,Val,'other-mechanism-value'), [], []), - {EncBytes2, EncLen2} = ?RT_BER:encode_open_type(TmpBytes1,[]), + {TmpBytes2,_} = Objother_mechanism_name('Type', Cindex2, []), + {EncBytes2,EncLen2} = encode_open_type(TmpBytes2, []) +, BytesSoFar = [EncBytes1, EncBytes2], - LenSoFar = EncLen1 + EncLen2, - ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar). -'dec_Authentication-value_other'(Bytes, OptOrMand, TagIn) -> +LenSoFar = EncLen1 + EncLen2, +encode_tags(TagIn, BytesSoFar, LenSoFar). + + +'dec_Authentication-value'(Tlv) -> + 'dec_Authentication-value'(Tlv, []). + +'dec_Authentication-value'(Tlv, TagIn) -> +Tlv1 = match_tags(Tlv, TagIn), +case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of + +%% 'charstring' + {131072, V1} -> + {charstring, begin +binary_to_list(decode_restricted_string(V1, [])) +end +}; + + +%% 'bitstring' + {131073, V1} -> + {bitstring, decode_native_bit_string(V1, [])}; + + +%% 'external' + {131074, V1} -> + {external, 'dec_EXTERNAL'(V1, [])}; + + +%% 'other' + {131075, V1} -> + {other, 'dec_Authentication-value_other'(V1, [])}; + + Else -> + exit({error,{asn1,{invalid_choice_tag,Else}}}) + end +. +'dec_Authentication-value_other'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), -{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len), +Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- -%% attribute number 1 with type fixedtypevaluefieldidtypeOBJECT IDENTIFIERno +%% attribute other-mechanism-name(1) with type OBJECT IDENTIFIER %%------------------------------------------------- - {Term1,Bytes3,Rb2} = ?RT_BER:decode_object_identifier(Bytes2,[], mandatory), +[V1|Tlv2] = Tlv1, +Term1 = decode_object_identifier(V1, [6]), %%------------------------------------------------- -%% attribute number 2 with type typefieldType +%% attribute other-mechanism-value(2) with type typefieldType %%------------------------------------------------- - {Tmpterm1, Bytes4,Rb3} = ?RT_BER:decode_open_type(Bytes3,[]), +[V2|Tlv3] = Tlv2, + + Tmpterm1 = decode_open_type(V2, []), DecObjother_mechanism_nameTerm1 = - 'ACSE-1':'getdec_ObjectSet'(id, Term1), -{Term2, _, _} = - case (catch DecObjother_mechanism_nameTerm1('Type', Tmpterm1, [], [])) of + 'ACSE-1':'getdec_ObjectSet'(Term1), +Term2 = + case (catch DecObjother_mechanism_nameTerm1('Type', Tmpterm1, [])) of {'EXIT', Reason1} -> exit({'Type not compatible with table constraint',Reason1}); Tmpterm2 -> Tmpterm2 end, - {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext), - {{'Authentication-value_other', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}. - - -'dec_Authentication-value'(Bytes, OptOrMand) -> - 'dec_Authentication-value'(Bytes, OptOrMand, []). - -'dec_Authentication-value'(Bytes, OptOrMand, TagIn) -> - {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand), - IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end, - IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end, - case Bytes1 of - -%% 'charstring' - <<2:2,_:1,0:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_restricted_string(Bytes1,[],25,[{tag,128,0,'IMPLICIT',32}], no_length, mandatory), - {{charstring, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; - - -%% 'bitstring' - <<2:2,_:1,1:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_bit_string(Bytes1,[],[],[{tag,128,1,'IMPLICIT',32}], no_length, mandatory), - {{bitstring, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; - - -%% 'external' - <<2:2,_:1,2:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_EXTERNAL'(Bytes1, mandatory, [{tag,128,2,'IMPLICIT',32}]), - {{external, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; - - -%% 'other' - <<2:2,_:1,3:5,_/binary>> -> - {Dec, Rest, RbCho} = 'dec_Authentication-value_other'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',32}]), - {{other, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; +case Tlv3 of +[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed +end, + {'Authentication-value_other', Term1, Term2}. - Else -> - case OptOrMand of - mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}}); - _ ->exit({error,{asn1,{no_optional_tag,Else}}}) - end - end. %%================================ %% Implementation-data %%================================ - -'enc_Implementation-data'({'Implementation-data',Val}, TagIn) -> - 'enc_Implementation-data'(Val, TagIn); +'enc_Implementation-data'(Val) -> + 'enc_Implementation-data'(Val, [<<25>>]). 'enc_Implementation-data'(Val, TagIn) -> -?RT_BER:encode_restricted_string([], Val, 25, TagIn ++ []). +encode_restricted_string(Val, TagIn). -'dec_Implementation-data'(Bytes, OptOrMand) -> - 'dec_Implementation-data'(Bytes, OptOrMand, []). +'dec_Implementation-data'(Tlv) -> + 'dec_Implementation-data'(Tlv, [25]). -'dec_Implementation-data'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_restricted_string(Bytes,[],25,TagIn++[], no_length, OptOrMand). +'dec_Implementation-data'(Tlv, TagIn) -> +begin +binary_to_list(decode_restricted_string(Tlv, TagIn)) +end +. %%================================ %% Mechanism-name %%================================ - -'enc_Mechanism-name'({'Mechanism-name',Val}, TagIn) -> - 'enc_Mechanism-name'(Val, TagIn); +'enc_Mechanism-name'(Val) -> + 'enc_Mechanism-name'(Val, [<<6>>]). 'enc_Mechanism-name'(Val, TagIn) -> -?RT_BER:encode_object_identifier(Val, TagIn ++ []). +encode_object_identifier(Val, TagIn). -'dec_Mechanism-name'(Bytes, OptOrMand) -> - 'dec_Mechanism-name'(Bytes, OptOrMand, []). +'dec_Mechanism-name'(Tlv) -> + 'dec_Mechanism-name'(Tlv, [6]). -'dec_Mechanism-name'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_object_identifier(Bytes,TagIn++[], OptOrMand). +'dec_Mechanism-name'(Tlv, TagIn) -> +decode_object_identifier(Tlv, TagIn). %%================================ %% Release-request-reason %%================================ - -'enc_Release-request-reason'({'Release-request-reason',Val}, TagIn) -> - 'enc_Release-request-reason'(Val, TagIn); +'enc_Release-request-reason'(Val) -> + 'enc_Release-request-reason'(Val, [<<2>>]). 'enc_Release-request-reason'(Val, TagIn) -> -?RT_BER:encode_integer([], Val, [{normal,0},{urgent,1},{'user-defined',30}], TagIn ++ []). +encode_integer(Val, [{normal,0},{urgent,1},{'user-defined',30}], TagIn). -'dec_Release-request-reason'(Bytes, OptOrMand) -> - 'dec_Release-request-reason'(Bytes, OptOrMand, []). +'dec_Release-request-reason'(Tlv) -> + 'dec_Release-request-reason'(Tlv, [2]). -'dec_Release-request-reason'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_integer(Bytes,[],[{normal,0},{urgent,1},{'user-defined',30}],TagIn++[], OptOrMand). +'dec_Release-request-reason'(Tlv, TagIn) -> +begin +Val1 = decode_integer(Tlv, TagIn), +number2name(Val1, [{normal,0},{urgent,1},{'user-defined',30}]) +end +. %%================================ %% Release-response-reason %%================================ - -'enc_Release-response-reason'({'Release-response-reason',Val}, TagIn) -> - 'enc_Release-response-reason'(Val, TagIn); +'enc_Release-response-reason'(Val) -> + 'enc_Release-response-reason'(Val, [<<2>>]). 'enc_Release-response-reason'(Val, TagIn) -> -?RT_BER:encode_integer([], Val, [{normal,0},{'not-finished',1},{'user-defined',30}], TagIn ++ []). +encode_integer(Val, [{normal,0},{'not-finished',1},{'user-defined',30}], TagIn). -'dec_Release-response-reason'(Bytes, OptOrMand) -> - 'dec_Release-response-reason'(Bytes, OptOrMand, []). +'dec_Release-response-reason'(Tlv) -> + 'dec_Release-response-reason'(Tlv, [2]). -'dec_Release-response-reason'(Bytes, OptOrMand, TagIn) -> -?RT_BER:decode_integer(Bytes,[],[{normal,0},{'not-finished',1},{'user-defined',30}],TagIn++[], OptOrMand). +'dec_Release-response-reason'(Tlv, TagIn) -> +begin +Val1 = decode_integer(Tlv, TagIn), +number2name(Val1, [{normal,0},{'not-finished',1},{'user-defined',30}]) +end +. %%================================ %% EXTERNAL %%================================ +'enc_EXTERNAL'(Val) -> + 'enc_EXTERNAL'(Val, [<<40>>]). + 'enc_EXTERNAL'(Val, TagIn) -> - NewVal = asn1rt_check:transform_to_EXTERNAL1990(Val), + NewVal = transform_to_EXTERNAL1990(Val), +{_,Cindex1, Cindex2, Cindex3, Cindex4} = NewVal, %%------------------------------------------------- -%% attribute number 1 with type OBJECT IDENTIFIER OPTIONAL +%% attribute direct-reference(1) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- - {EncBytes1,EncLen1} = case ?RT_BER:cindex(2,NewVal,'direct-reference') of + {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_object_identifier(?RT_BER:cindex(2,NewVal,'direct-reference'), []) + encode_object_identifier(Cindex1, [<<6>>]) end, %%------------------------------------------------- -%% attribute number 2 with type INTEGER OPTIONAL +%% attribute indirect-reference(2) with type INTEGER OPTIONAL %%------------------------------------------------- - {EncBytes2,EncLen2} = case ?RT_BER:cindex(3,NewVal,'indirect-reference') of + {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_integer([], ?RT_BER:cindex(3,NewVal,'indirect-reference'), []) + encode_integer(Cindex2, [<<2>>]) end, %%------------------------------------------------- -%% attribute number 3 with type ObjectDescriptor OPTIONAL +%% attribute data-value-descriptor(3) with type ObjectDescriptor OPTIONAL %%------------------------------------------------- - {EncBytes3,EncLen3} = case ?RT_BER:cindex(4,NewVal,'data-value-descriptor') of + {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> - ?RT_BER:encode_restricted_string([], ?RT_BER:cindex(4,NewVal,'data-value-descriptor'), 7, []) + encode_restricted_string(Cindex3, [<<7>>]) end, %%------------------------------------------------- -%% attribute number 4 with type CHOICE +%% attribute encoding(4) with type CHOICE %%------------------------------------------------- - {EncBytes4,EncLen4} = 'enc_EXTERNAL_encoding'(?RT_BER:cindex(5,NewVal,encoding), []), + {EncBytes4,EncLen4} = 'enc_EXTERNAL_encoding'(Cindex4, []), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], - LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, - ?RT_BER:encode_tags(TagIn ++ [{tag,0,8,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar). +LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, +encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% EXTERNAL_encoding %%================================ - -'enc_EXTERNAL_encoding'({'EXTERNAL_encoding',Val}, TagIn) -> - 'enc_EXTERNAL_encoding'(Val, TagIn); - 'enc_EXTERNAL_encoding'(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of 'single-ASN1-type' -> - ?RT_BER:encode_open_type(element(2,Val), [{tag,128,0,'EXPLICIT',32}]); + encode_open_type(element(2,Val), [<<160>>]); 'octet-aligned' -> - ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,1,'IMPLICIT',0}]); + encode_restricted_string(element(2,Val), [<<129>>]); arbitrary -> - ?RT_BER:encode_bit_string([], element(2,Val), [], [{tag,128,2,'IMPLICIT',0}]); + encode_unnamed_bit_string(element(2,Val), [<<130>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, -?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen). - - -'dec_EXTERNAL_encoding'(Bytes, OptOrMand, TagIn) -> - {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand), - IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end, - IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end, - case Bytes1 of - -%% 'single-ASN1-type' - <<2:2,_:1,0:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_open_type(ber,Bytes1,[{tag,128,0,'EXPLICIT',32}]), - {{'single-ASN1-type', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; +encode_tags(TagIn, EncBytes, EncLen). -%% 'octet-aligned' - <<2:2,_:1,1:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,1,'IMPLICIT',0}], no_length, mandatory), - {{'octet-aligned', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; -%% 'arbitrary' - <<2:2,_:1,2:5,_/binary>> -> - {Dec, Rest, RbCho} = ?RT_BER:decode_bit_string(Bytes1,[],[],[{tag,128,2,'IMPLICIT',0}], no_length, mandatory), - {{arbitrary, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)}; +'dec_EXTERNAL'(Tlv) -> + 'dec_EXTERNAL'(Tlv, [8]). - Else -> - case OptOrMand of - mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}}); - _ ->exit({error,{asn1,{no_optional_tag,Else}}}) - end - end. - - -'dec_EXTERNAL'(Bytes, OptOrMand) -> - 'dec_EXTERNAL'(Bytes, OptOrMand, []). - -'dec_EXTERNAL'(Bytes, OptOrMand, TagIn) -> +'dec_EXTERNAL'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- - {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,8,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), -{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len), +Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- -%% attribute number 1 with type OBJECT IDENTIFIER OPTIONAL +%% attribute direct-reference(1) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- - {Term1,Bytes3,Rb2} = case Bytes2 of -<<0:2,_:1,6:5,_/binary>> -> -?RT_BER:decode_object_identifier(Bytes2,[], mandatory); -_ -> -{ asn1_NOVALUE, Bytes2, 0 } +{Term1,Tlv2} = case Tlv1 of +[{6,V1}|TempTlv2] -> + {decode_object_identifier(V1, []), TempTlv2}; + _ -> + { asn1_NOVALUE, Tlv1} end, %%------------------------------------------------- -%% attribute number 2 with type INTEGER OPTIONAL +%% attribute indirect-reference(2) with type INTEGER OPTIONAL %%------------------------------------------------- - {Term2,Bytes4,Rb3} = case Bytes3 of -<<0:2,_:1,2:5,_/binary>> -> -?RT_BER:decode_integer(Bytes3,[],[], mandatory); -_ -> -{ asn1_NOVALUE, Bytes3, 0 } +{Term2,Tlv3} = case Tlv2 of +[{2,V2}|TempTlv3] -> + {decode_integer(V2, []), TempTlv3}; + _ -> + { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- -%% attribute number 3 with type ObjectDescriptor OPTIONAL +%% attribute data-value-descriptor(3) with type ObjectDescriptor OPTIONAL %%------------------------------------------------- - {Term3,Bytes5,Rb4} = case Bytes4 of -<<0:2,_:1,7:5,_/binary>> -> -?RT_BER:decode_restricted_string(Bytes4,[],7,[], no_length, mandatory); -_ -> -{ asn1_NOVALUE, Bytes4, 0 } +{Term3,Tlv4} = case Tlv3 of +[{7,V3}|TempTlv4] -> + {begin +binary_to_list(decode_restricted_string(V3, [])) +end +, TempTlv4}; + _ -> + { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- -%% attribute number 4 with type CHOICE +%% attribute encoding(4) with type CHOICE %%------------------------------------------------- - {Term4,Bytes6,Rb5} = 'dec_EXTERNAL_encoding'(Bytes5, mandatory, []), +[V4|Tlv5] = Tlv4, +Term4 = 'dec_EXTERNAL_encoding'(V4, []), - {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext), +case Tlv5 of +[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed +end, OldFormat={'EXTERNAL', Term1, Term2, Term3, Term4}, - ASN11994Format = - asn1rt_check:transform_to_EXTERNAL1994(OldFormat), - {ASN11994Format,Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}. -value_match([{Index,Cname}|Rest],Value) -> - Value2 = - case element(Index,Value) of - {Cname,Val2} -> Val2; - X -> X - end, - value_match(Rest,Value2); -value_match([],Value) -> - Value. + transform_to_EXTERNAL1994(OldFormat). +'dec_EXTERNAL_encoding'(Tlv, TagIn) -> +Tlv1 = match_tags(Tlv, TagIn), +case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of + +%% 'single-ASN1-type' + {131072, V1} -> + {'single-ASN1-type', decode_open_type_as_binary(V1, [])}; + + +%% 'octet-aligned' + {131073, V1} -> + {'octet-aligned', decode_octet_string(V1, [])}; + + +%% 'arbitrary' + {131074, V1} -> + {arbitrary, decode_native_bit_string(V1, [])}; + + Else -> + exit({error,{asn1,{invalid_choice_tag,Else}}}) + end +. 'acse-as-id'() -> {2,2,1,0,1}. @@ -1995,20 +2003,452 @@ value_match([],Value) -> %%================================ %% ObjectSet %%================================ -'getenc_ObjectSet'(_, _) -> - fun(_Attr, Val, _TagIn, _RestPrimFieldName) -> - Len = case Val of - Bin when is_binary(Bin) -> size(Bin); - _ -> length(Val) - end, {Val,Len} - end. - -'getdec_ObjectSet'(_, _) -> - fun(_, Bytes, _, _) -> - Len = case Bytes of - Bin when is_binary(Bin) -> size(Bin); - _ -> length(Bytes) - end, {Bytes,[],Len} - end. - - +'getenc_ObjectSet'(_) -> + fun(_, Val, _RestPrimFieldName) -> + case Val of + {asn1_OPENTYPE,Bin} when is_binary(Bin) -> + {Bin,byte_size(Bin)} + end + end. + +'getdec_ObjectSet'(_) -> + fun(_,Bytes, _RestPrimFieldName) -> + case Bytes of + Bin when is_binary(Bin) -> + {asn1_OPENTYPE,Bin}; + _ -> + {asn1_OPENTYPE,ber_encode(Bytes)} + end + end. + + + +%%% +%%% Run-time functions. +%%% + +'dialyzer-suppressions'(Arg) -> + ok. + +ber_decode_nif(B) -> + asn1rt_nif:decode_ber_tlv(B). + +ber_encode([Tlv]) -> + ber_encode(Tlv); +ber_encode(Tlv) when is_binary(Tlv) -> + Tlv; +ber_encode(Tlv) -> + asn1rt_nif:encode_ber_tlv(Tlv). + +collect_parts(TlvList) -> + collect_parts(TlvList, []). + +collect_parts([{_,L}|Rest], Acc) when is_list(L) -> + collect_parts(Rest, [collect_parts(L)|Acc]); +collect_parts([{3,<>}|Rest], _Acc) -> + collect_parts_bit(Rest, [Bits], Unused); +collect_parts([{_T,V}|Rest], Acc) -> + collect_parts(Rest, [V|Acc]); +collect_parts([], Acc) -> + list_to_binary(lists:reverse(Acc)). + +collect_parts_bit([{3,<>}|Rest], Acc, Uacc) -> + collect_parts_bit(Rest, [Bits|Acc], Unused + Uacc); +collect_parts_bit([], Acc, Uacc) -> + list_to_binary([Uacc|lists:reverse(Acc)]). + +dec_subidentifiers(<<>>, _Av, Al) -> + lists:reverse(Al); +dec_subidentifiers(<<1:1,H:7,T/binary>>, Av, Al) -> + dec_subidentifiers(T, Av bsl 7 + H, Al); +dec_subidentifiers(<>, Av, Al) -> + dec_subidentifiers(T, 0, [Av bsl 7 + H|Al]). + +decode_bitstring2(1, + Unused, + <>) -> + lists:sublist([B7,B6,B5,B4,B3,B2,B1,B0], 8 - Unused); +decode_bitstring2(Len, + Unused, + <>) -> + [B7,B6,B5,B4,B3,B2,B1,B0|decode_bitstring2(Len - 1, Unused, Buffer)]. + +decode_bitstring_NNL(BitList, NamedNumberList) -> + decode_bitstring_NNL(BitList, NamedNumberList, 0, []). + +decode_bitstring_NNL([], _, _No, Result) -> + lists:reverse(Result); +decode_bitstring_NNL([B|BitList], + [{Name,No}|NamedNumberList], + No, + Result) -> + if + B =:= 0 -> + decode_bitstring_NNL(BitList, + NamedNumberList, + No + 1, + Result); + true -> + decode_bitstring_NNL(BitList, + NamedNumberList, + No + 1, + [Name|Result]) + end; +decode_bitstring_NNL([1|BitList], NamedNumberList, No, Result) -> + decode_bitstring_NNL(BitList, + NamedNumberList, + No + 1, + [{bit,No}|Result]); +decode_bitstring_NNL([0|BitList], NamedNumberList, No, Result) -> + decode_bitstring_NNL(BitList, NamedNumberList, No + 1, Result). + +decode_integer(Tlv, TagIn) -> + Bin = match_tags(Tlv, TagIn), + Len = byte_size(Bin), + <> = Bin, + Int. + +decode_named_bit_string(Buffer, NamedNumberList, Tags) -> + case match_and_collect(Buffer, Tags) of + <<0>> -> + []; + <> -> + BitString = decode_bitstring2(byte_size(Bits), Unused, Bits), + decode_bitstring_NNL(BitString, NamedNumberList) + end. + +decode_native_bit_string(Buffer, Tags) -> + case match_and_collect(Buffer, Tags) of + <<0>> -> + <<>>; + <> -> + Size = bit_size(Bits) - Unused, + <> = Bits, + Val + end. + +decode_object_identifier(Tlv, Tags) -> + Val = match_tags(Tlv, Tags), + [AddedObjVal|ObjVals] = dec_subidentifiers(Val, 0, []), + {Val1,Val2} = + if + AddedObjVal < 40 -> + {0,AddedObjVal}; + AddedObjVal < 80 -> + {1,AddedObjVal - 40}; + true -> + {2,AddedObjVal - 80} + end, + list_to_tuple([Val1,Val2|ObjVals]). + +decode_octet_string(Tlv, TagsIn) -> + Bin = match_and_collect(Tlv, TagsIn), + binary:copy(Bin). + +decode_open_type(Tlv, TagIn) -> + case match_tags(Tlv, TagIn) of + Bin when is_binary(Bin) -> + {InnerTlv,_} = ber_decode_nif(Bin), + InnerTlv; + TlvBytes -> + TlvBytes + end. + +decode_open_type_as_binary(Tlv, TagIn) -> + ber_encode(match_tags(Tlv, TagIn)). + +decode_restricted_string(Tlv, TagsIn) -> + match_and_collect(Tlv, TagsIn). + +do_encode_named_bit_string([FirstVal|RestVal], NamedBitList, TagIn) -> + ToSetPos = get_all_bitposes([FirstVal|RestVal], NamedBitList, []), + Size = lists:max(ToSetPos) + 1, + BitList = make_and_set_list(Size, ToSetPos, 0), + {Len,Unused,OctetList} = encode_bitstring(BitList), + encode_tags(TagIn, [Unused|OctetList], Len + 1). + +e_object_identifier({'OBJECT IDENTIFIER',V}) -> + e_object_identifier(V); +e_object_identifier(V) when is_tuple(V) -> + e_object_identifier(tuple_to_list(V)); +e_object_identifier([E1,E2|Tail]) -> + Head = 40 * E1 + E2, + {H,Lh} = mk_object_val(Head), + {R,Lr} = lists:mapfoldl(fun enc_obj_id_tail/2, 0, Tail), + {[H|R],Lh + Lr}. + +enc_obj_id_tail(H, Len) -> + {B,L} = mk_object_val(H), + {B,Len + L}. + +encode_bitstring([B8,B7,B6,B5,B4,B3,B2,B1|Rest]) -> + Val = + B8 bsl 7 bor (B7 bsl 6) bor (B6 bsl 5) bor (B5 bsl 4) + bor + (B4 bsl 3) + bor + (B3 bsl 2) + bor + (B2 bsl 1) + bor + B1, + encode_bitstring(Rest, [Val], 1); +encode_bitstring(Val) -> + {Unused,Octet} = unused_bitlist(Val, 7, 0), + {1,Unused,[Octet]}. + +encode_bitstring([B8,B7,B6,B5,B4,B3,B2,B1|Rest], Ack, Len) -> + Val = + B8 bsl 7 bor (B7 bsl 6) bor (B6 bsl 5) bor (B5 bsl 4) + bor + (B4 bsl 3) + bor + (B3 bsl 2) + bor + (B2 bsl 1) + bor + B1, + encode_bitstring(Rest, [Ack,Val], Len + 1); +encode_bitstring([], Ack, Len) -> + {Len,0,Ack}; +encode_bitstring(Rest, Ack, Len) -> + {Unused,Val} = unused_bitlist(Rest, 7, 0), + {Len + 1,Unused,[Ack,Val]}. + +encode_integer(Val) -> + Bytes = + if + Val >= 0 -> + encode_integer_pos(Val, []); + true -> + encode_integer_neg(Val, []) + end, + {Bytes,length(Bytes)}. + +encode_integer(Val, NamedNumberList, Tag) when is_atom(Val) -> + case lists:keyfind(Val, 1, NamedNumberList) of + {_,NewVal} -> + encode_tags(Tag, encode_integer(NewVal)); + _ -> + exit({error,{asn1,{encode_integer_namednumber,Val}}}) + end; +encode_integer(Val, _NamedNumberList, Tag) -> + encode_tags(Tag, encode_integer(Val)). + +encode_integer(Val, Tag) when is_integer(Val) -> + encode_tags(Tag, encode_integer(Val)); +encode_integer(Val, _Tag) -> + exit({error,{asn1,{encode_integer,Val}}}). + +encode_integer_neg(- 1, [B1|_T] = L) when B1 > 127 -> + L; +encode_integer_neg(N, Acc) -> + encode_integer_neg(N bsr 8, [N band 255|Acc]). + +encode_integer_pos(0, [B|_Acc] = L) when B < 128 -> + L; +encode_integer_pos(N, Acc) -> + encode_integer_pos(N bsr 8, [N band 255|Acc]). + +encode_length(L) when L =< 127 -> + {[L],1}; +encode_length(L) -> + Oct = minimum_octets(L), + Len = length(Oct), + if + Len =< 126 -> + {[128 bor Len|Oct],Len + 1}; + true -> + exit({error,{asn1,too_long_length_oct,Len}}) + end. + +encode_named_bit_string([H|_] = Bits, NamedBitList, TagIn) + when is_atom(H) -> + do_encode_named_bit_string(Bits, NamedBitList, TagIn); +encode_named_bit_string([{bit,_}|_] = Bits, NamedBitList, TagIn) -> + do_encode_named_bit_string(Bits, NamedBitList, TagIn); +encode_named_bit_string(Bits, _NamedBitList, TagIn) + when is_bitstring(Bits) -> + encode_unnamed_bit_string(Bits, TagIn). + +encode_object_identifier(Val, TagIn) -> + encode_tags(TagIn, e_object_identifier(Val)). + +encode_open_type(Val, T) when is_list(Val) -> + encode_open_type(list_to_binary(Val), T); +encode_open_type(Val, Tag) -> + encode_tags(Tag, Val, byte_size(Val)). + +encode_restricted_string(OctetList, TagIn) when is_binary(OctetList) -> + encode_tags(TagIn, OctetList, byte_size(OctetList)); +encode_restricted_string(OctetList, TagIn) when is_list(OctetList) -> + encode_tags(TagIn, OctetList, length(OctetList)). + +encode_tags(TagIn, {BytesSoFar,LenSoFar}) -> + encode_tags(TagIn, BytesSoFar, LenSoFar). + +encode_tags([Tag|Trest], BytesSoFar, LenSoFar) -> + {Bytes2,L2} = encode_length(LenSoFar), + encode_tags(Trest, + [Tag,Bytes2|BytesSoFar], + LenSoFar + byte_size(Tag) + L2); +encode_tags([], BytesSoFar, LenSoFar) -> + {BytesSoFar,LenSoFar}. + +encode_unnamed_bit_string(Bits, TagIn) -> + Unused = (8 - bit_size(Bits) band 7) band 7, + Bin = <>, + encode_tags(TagIn, Bin, byte_size(Bin)). + +get_all_bitposes([{bit,ValPos}|Rest], NamedBitList, Ack) -> + get_all_bitposes(Rest, NamedBitList, [ValPos|Ack]); +get_all_bitposes([Val|Rest], NamedBitList, Ack) when is_atom(Val) -> + case lists:keyfind(Val, 1, NamedBitList) of + {_ValName,ValPos} -> + get_all_bitposes(Rest, NamedBitList, [ValPos|Ack]); + _ -> + exit({error,{asn1,{bitstring_namedbit,Val}}}) + end; +get_all_bitposes([], _NamedBitList, Ack) -> + lists:sort(Ack). + +make_and_set_list(0, [], _) -> + []; +make_and_set_list(0, _, _) -> + exit({error,{asn1,bitstring_sizeconstraint}}); +make_and_set_list(Len, [XPos|SetPos], XPos) -> + [1|make_and_set_list(Len - 1, SetPos, XPos + 1)]; +make_and_set_list(Len, [Pos|SetPos], XPos) -> + [0|make_and_set_list(Len - 1, [Pos|SetPos], XPos + 1)]; +make_and_set_list(Len, [], XPos) -> + [0|make_and_set_list(Len - 1, [], XPos + 1)]. + +match_and_collect(Tlv, TagsIn) -> + Val = match_tags(Tlv, TagsIn), + case Val of + [_|_] = PartList -> + collect_parts(PartList); + Bin when is_binary(Bin) -> + Bin + end. + +match_tags({T,V}, [T]) -> + V; +match_tags({T,V}, [T|Tt]) -> + match_tags(V, Tt); +match_tags([{T,V}], [T|Tt]) -> + match_tags(V, Tt); +match_tags([{T,_V}|_] = Vlist, [T]) -> + Vlist; +match_tags(Tlv, []) -> + Tlv; +match_tags({Tag,_V} = Tlv, [T|_Tt]) -> + exit({error,{asn1,{wrong_tag,{{expected,T},{got,Tag,Tlv}}}}}). + +minimum_octets(0, Acc) -> + Acc; +minimum_octets(Val, Acc) -> + minimum_octets(Val bsr 8, [Val band 255|Acc]). + +minimum_octets(Val) -> + minimum_octets(Val, []). + +mk_object_val(0, Ack, Len) -> + {Ack,Len}; +mk_object_val(Val, Ack, Len) -> + mk_object_val(Val bsr 7, [Val band 127 bor 128|Ack], Len + 1). + +mk_object_val(Val) when Val =< 127 -> + {[255 band Val],1}; +mk_object_val(Val) -> + mk_object_val(Val bsr 7, [Val band 127], 1). + +number2name(Int, NamedNumberList) -> + case lists:keyfind(Int, 2, NamedNumberList) of + {NamedVal,_} -> + NamedVal; + _ -> + Int + end. + +skip_ExtensionAdditions([], _Tags) -> + []; +skip_ExtensionAdditions([{Tag,_}|Rest] = TLV, Tags) -> + case + [ + X || + X = T <- Tags, + T =:= Tag + ] + of + [] -> + skip_ExtensionAdditions(Rest, Tags); + _ -> + TLV + end. + +transform_to_EXTERNAL1990(['EXTERNAL'|Rest], Acc) -> + transform_to_EXTERNAL1990(Rest, ['EXTERNAL'|Acc]); +transform_to_EXTERNAL1990([{syntax,Syntax}|Rest], Acc) -> + transform_to_EXTERNAL1990(Rest, [asn1_NOVALUE,Syntax|Acc]); +transform_to_EXTERNAL1990([{'presentation-context-id',PCid}|Rest], Acc) -> + transform_to_EXTERNAL1990(Rest, [PCid,asn1_NOVALUE|Acc]); +transform_to_EXTERNAL1990([{'context-negotiation',Context_negot}|Rest], + Acc) -> + {_,Presentation_Cid,Transfer_syntax} = Context_negot, + transform_to_EXTERNAL1990(Rest, + [Presentation_Cid,Transfer_syntax|Acc]); +transform_to_EXTERNAL1990([asn1_NOVALUE|Rest], Acc) -> + transform_to_EXTERNAL1990(Rest, [asn1_NOVALUE|Acc]); +transform_to_EXTERNAL1990([Data_val_desc,Data_value], Acc) + when is_list(Data_value); is_binary(Data_value) -> + list_to_tuple(lists:reverse([{'octet-aligned',Data_value}, + Data_val_desc| + Acc])); +transform_to_EXTERNAL1990([Data_val_desc,Data_value], Acc) + when is_binary(Data_value) -> + list_to_tuple(lists:reverse([{'single-ASN1-type',Data_value}, + Data_val_desc| + Acc])); +transform_to_EXTERNAL1990([Data_value], Acc) + when is_list(Data_value); is_binary(Data_value) -> + list_to_tuple(lists:reverse([{'octet-aligned',Data_value}|Acc])). + +transform_to_EXTERNAL1990({_,_,_,_} = Val) -> + transform_to_EXTERNAL1990(tuple_to_list(Val), []); +transform_to_EXTERNAL1990(Val) when is_tuple(Val) -> + Val. + +transform_to_EXTERNAL1994({'EXTERNAL',DRef,IndRef,Data_v_desc,Encoding} = + V) -> + Identification = + case {DRef,IndRef} of + {DRef,asn1_NOVALUE} -> + {syntax,DRef}; + {asn1_NOVALUE,IndRef} -> + {'presentation-context-id',IndRef}; + _ -> + {'context-negotiation', + {'EXTERNAL_identification_context-negotiation', + IndRef, + DRef}} + end, + case Encoding of + {'octet-aligned',Val} when is_list(Val); is_binary(Val) -> + {'EXTERNAL',Identification,Data_v_desc,Val}; + _ -> + V + end. + +unused_bitlist([], Trail, Ack) -> + {Trail + 1,Ack}; +unused_bitlist([Bit|Rest], Trail, Ack) -> + unused_bitlist(Rest, Trail - 1, Bit bsl Trail bor Ack). -- cgit v1.2.3