%% Generated by the Erlang ASN.1 BER-compiler version:1.4 %% Purpose: encoder and decoder to the types in mod RAB-SetupOrModifyList -module('RAB-SetupOrModifyList'). -include("RAB-SetupOrModifyList.hrl"). -define('RT_BER',asn1rt_ber_bin). -export([encoding_rule/0]). -export([ 'enc_Criticality'/2, 'enc_Presence'/2, 'enc_ProtocolIE-ID'/2, 'enc_RAB-SetupOrModifyList'/2, 'enc_RAB-SetupOrModifyItemFirst'/2, 'enc_RAB-SetupOrModifyItemSecond'/2 ]). -export([ 'dec_Criticality'/2, 'dec_Presence'/2, 'dec_ProtocolIE-ID'/2, 'dec_RAB-SetupOrModifyList'/2, 'dec_RAB-SetupOrModifyItemFirst'/2, 'dec_RAB-SetupOrModifyItemSecond'/2 ]). -export([ 'dec_Criticality'/3, 'dec_Presence'/3, 'dec_ProtocolIE-ID'/3, 'dec_RAB-SetupOrModifyList'/3, 'dec_RAB-SetupOrModifyItemFirst'/3, 'dec_RAB-SetupOrModifyItemSecond'/3 ]). -export([ 'id-RAB-SetupOrModifyItem'/0, 'maxProtocolIEs'/0, 'maxNrOfRABs'/0 ]). -export([ 'getenc_RAB-SetupOrModifyItem-IEs'/2 ]). -export([ 'getdec_RAB-SetupOrModifyItem-IEs'/2 ]). -export([info/0]). -export([encode/2,decode/2,encode_disp/2,decode_disp/2]). encoding_rule() -> ber. 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)}; Bytes -> {ok,wrap_encode(Bytes)} 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} end. encode_disp('Criticality',Data) -> 'enc_Criticality'(Data,[]); encode_disp('Presence',Data) -> 'enc_Presence'(Data,[]); encode_disp('ProtocolIE-ID',Data) -> 'enc_ProtocolIE-ID'(Data,[]); encode_disp('RAB-SetupOrModifyList',Data) -> 'enc_RAB-SetupOrModifyList'(Data,[]); encode_disp('RAB-SetupOrModifyItemFirst',Data) -> 'enc_RAB-SetupOrModifyItemFirst'(Data,[]); encode_disp('RAB-SetupOrModifyItemSecond',Data) -> 'enc_RAB-SetupOrModifyItemSecond'(Data,[]); encode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}). decode_disp('Criticality',Data) -> 'dec_Criticality'(Data,mandatory); decode_disp('Presence',Data) -> 'dec_Presence'(Data,mandatory); decode_disp('ProtocolIE-ID',Data) -> 'dec_ProtocolIE-ID'(Data,mandatory); decode_disp('RAB-SetupOrModifyList',Data) -> 'dec_RAB-SetupOrModifyList'(Data,mandatory); decode_disp('RAB-SetupOrModifyItemFirst',Data) -> 'dec_RAB-SetupOrModifyItemFirst'(Data,mandatory); decode_disp('RAB-SetupOrModifyItemSecond',Data) -> 'dec_RAB-SetupOrModifyItemSecond'(Data,mandatory); decode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}). wrap_encode(Bytes) when list(Bytes) -> binary_to_list(list_to_binary(Bytes)); wrap_encode(Bytes) when binary(Bytes) -> binary_to_list(Bytes); wrap_encode(Bytes) -> Bytes. wrap_decode(Bytes) when list(Bytes) -> list_to_binary(Bytes); wrap_decode(Bytes) -> Bytes. info() -> [{vsn,'1.4'}, {module,'RAB-SetupOrModifyList'}, {options,[ber]}]. %%================================ %% Criticality %%================================ 'enc_Criticality'({'Criticality',Val}, TagIn) -> 'enc_Criticality'(Val, TagIn); 'enc_Criticality'(Val, TagIn) -> case (case Val of {_,_}->element(2,Val);_->Val end) of reject -> ?RT_BER:encode_enumerated(0,TagIn ++ []); ignore -> ?RT_BER:encode_enumerated(1,TagIn ++ []); notify -> ?RT_BER:encode_enumerated(2,TagIn ++ []); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. 'dec_Criticality'(Bytes, OptOrMand) -> 'dec_Criticality'(Bytes, OptOrMand, []). 'dec_Criticality'(Bytes, OptOrMand, TagIn) -> ?RT_BER:decode_enumerated(Bytes,[],[{reject,0},{ignore,1},{notify,2}],TagIn++[], OptOrMand). %%================================ %% Presence %%================================ 'enc_Presence'({'Presence',Val}, TagIn) -> 'enc_Presence'(Val, TagIn); 'enc_Presence'(Val, TagIn) -> case (case Val of {_,_}->element(2,Val);_->Val end) of optional -> ?RT_BER:encode_enumerated(0,TagIn ++ []); conditional -> ?RT_BER:encode_enumerated(1,TagIn ++ []); mandatory -> ?RT_BER:encode_enumerated(2,TagIn ++ []); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. 'dec_Presence'(Bytes, OptOrMand) -> 'dec_Presence'(Bytes, OptOrMand, []). 'dec_Presence'(Bytes, OptOrMand, TagIn) -> ?RT_BER:decode_enumerated(Bytes,[],[{optional,0},{conditional,1},{mandatory,2}],TagIn++[], OptOrMand). %%================================ %% ProtocolIE-ID %%================================ 'enc_ProtocolIE-ID'({'ProtocolIE-ID',Val}, TagIn) -> 'enc_ProtocolIE-ID'(Val, TagIn); 'enc_ProtocolIE-ID'(Val, TagIn) -> ?RT_BER:encode_integer([], Val, TagIn ++ []). 'dec_ProtocolIE-ID'(Bytes, OptOrMand) -> 'dec_ProtocolIE-ID'(Bytes, OptOrMand, []). 'dec_ProtocolIE-ID'(Bytes, OptOrMand, TagIn) -> ?RT_BER:decode_integer(Bytes,{0,65535},TagIn++[], OptOrMand). %%================================ %% RAB-SetupOrModifyList %%================================ 'enc_RAB-SetupOrModifyList'({'RAB-SetupOrModifyList',Val}, TagIn) -> 'enc_RAB-SetupOrModifyList'(Val, TagIn); 'enc_RAB-SetupOrModifyList'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_RAB-SetupOrModifyList_components'(Val,[],0), ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen). 'enc_RAB-SetupOrModifyList_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_RAB-SetupOrModifyList_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_RAB-SetupOrModifyList_SEQOF'(H, []), 'enc_RAB-SetupOrModifyList_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% RAB-SetupOrModifyList_SEQOF %%================================ 'enc_RAB-SetupOrModifyList_SEQOF'({'RAB-SetupOrModifyList_SEQOF',Val}, TagIn) -> 'enc_RAB-SetupOrModifyList_SEQOF'(Val, TagIn); 'enc_RAB-SetupOrModifyList_SEQOF'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_RAB-SetupOrModifyList_SEQOF_components'(Val,[],0), ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen). 'enc_RAB-SetupOrModifyList_SEQOF_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_RAB-SetupOrModifyList_SEQOF_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_RAB-SetupOrModifyList_SEQOF_ProtocolIE-FieldPair'(H, []), 'enc_RAB-SetupOrModifyList_SEQOF_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% RAB-SetupOrModifyList_SEQOF_ProtocolIE-FieldPair %%================================ 'enc_RAB-SetupOrModifyList_SEQOF_ProtocolIE-FieldPair'(Val, TagIn) -> Objid = 'getenc_RAB-SetupOrModifyItem-IEs'(id, ?RT_BER:cindex(2, Val,id)), %%------------------------------------------------- %% attribute number 1 with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,id), [{tag,128,0,'IMPLICIT',0}]), %%------------------------------------------------- %% attribute number 2 with type ENUMERATED %%------------------------------------------------- {EncBytes2,EncLen2} = case (case ?RT_BER:cindex(3,Val,firstCriticality) of {_,_}->element(2,?RT_BER:cindex(3,Val,firstCriticality));_->?RT_BER:cindex(3,Val,firstCriticality) end) of reject -> ?RT_BER:encode_enumerated(0,[{tag,128,1,'IMPLICIT',0}]); ignore -> ?RT_BER:encode_enumerated(1,[{tag,128,1,'IMPLICIT',0}]); notify -> ?RT_BER:encode_enumerated(2,[{tag,128,1,'IMPLICIT',0}]); Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}}) end, %%------------------------------------------------- %% attribute number 3 with type FirstValue %%------------------------------------------------- {TmpBytes1,_} = Objid('FirstValue', ?RT_BER:cindex(4,Val,firstValue), [], []), {EncBytes3, EncLen3} = ?RT_BER:encode_open_type(TmpBytes1,[{tag,128,2,'EXPLICIT',32}]), %%------------------------------------------------- %% attribute number 4 with type ENUMERATED %%------------------------------------------------- {EncBytes4,EncLen4} = case (case ?RT_BER:cindex(5,Val,secondCriticality) of {_,_}->element(2,?RT_BER:cindex(5,Val,secondCriticality));_->?RT_BER:cindex(5,Val,secondCriticality) end) of reject -> ?RT_BER:encode_enumerated(0,[{tag,128,3,'IMPLICIT',0}]); ignore -> ?RT_BER:encode_enumerated(1,[{tag,128,3,'IMPLICIT',0}]); notify -> ?RT_BER:encode_enumerated(2,[{tag,128,3,'IMPLICIT',0}]); Enumval3 -> exit({error,{asn1, {enumerated_not_in_range,Enumval3}}}) end, %%------------------------------------------------- %% attribute number 5 with type SecondValue %%------------------------------------------------- {TmpBytes2,_} = Objid('SecondValue', ?RT_BER:cindex(6,Val,secondValue), [], []), {EncBytes5, EncLen5} = ?RT_BER:encode_open_type(TmpBytes2,[{tag,128,4,'EXPLICIT',32}]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5, {TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar). 'dec_RAB-SetupOrModifyList_SEQOF_ProtocolIE-FieldPair'(Bytes, OptOrMand, 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), %%------------------------------------------------- %% attribute number 1 with type fixedtypevaluefieldidtypeINTEGERValueRange065535 %%------------------------------------------------- {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,65535},[{tag,128,0,'IMPLICIT',0}], mandatory), %%------------------------------------------------- %% attribute number 2 with type fixedtypevaluefieldfirstCriticalitytypeENUMERATEDreject0ignore1notify2 %%------------------------------------------------- {Term2,Bytes4,Rb3} = ?RT_BER:decode_enumerated(Bytes3,[],[{reject,0},{ignore,1},{notify,2}],[{tag,128,1,'IMPLICIT',0}], mandatory), %%------------------------------------------------- %% attribute number 3 with type typefieldFirstValue %%------------------------------------------------- {Tmpterm1, Bytes5,Rb4} = ?RT_BER:decode_open_type(Bytes4,[{tag,128,2,'EXPLICIT',32}]), %%------------------------------------------------- %% attribute number 4 with type fixedtypevaluefieldsecondCriticalitytypeENUMERATEDreject0ignore1notify2 %%------------------------------------------------- {Term3,Bytes6,Rb5} = ?RT_BER:decode_enumerated(Bytes5,[],[{reject,0},{ignore,1},{notify,2}],[{tag,128,3,'IMPLICIT',0}], mandatory), %%------------------------------------------------- %% attribute number 5 with type typefieldSecondValue %%------------------------------------------------- {Tmpterm2, Bytes7,Rb6} = ?RT_BER:decode_open_type(Bytes6,[{tag,128,4,'EXPLICIT',32}]), DecObjidTerm1 = 'getdec_RAB-SetupOrModifyItem-IEs'(id, Term1), {Term4, _, _} = case (catch DecObjidTerm1('SecondValue', Tmpterm2, [], [])) of {'EXIT', Reason1} -> exit({'Type not compatible with table constraint',Reason1}); Tmpterm3 -> Tmpterm3 end, {Term5, _, _} = case (catch DecObjidTerm1('FirstValue', Tmpterm1, [], [])) of {'EXIT', Reason2} -> exit({'Type not compatible with table constraint',Reason2}); Tmpterm4 -> Tmpterm4 end, {Bytes8,Rb7} = ?RT_BER:restbytes2(RemBytes, Bytes7,noext), {{'ProtocolIE-FieldPair', Term1, Term2, Term3, Term4, Term5}, Bytes8, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7}. 'dec_RAB-SetupOrModifyList_SEQOF'(Bytes, OptOrMand, 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_RAB-SetupOrModifyList_SEQOF_ProtocolIE-FieldPair'/3, [], []). 'dec_RAB-SetupOrModifyList'(Bytes, OptOrMand) -> 'dec_RAB-SetupOrModifyList'(Bytes, OptOrMand, []). 'dec_RAB-SetupOrModifyList'(Bytes, OptOrMand, 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_RAB-SetupOrModifyList_SEQOF'/3, [], []). %%================================ %% RAB-SetupOrModifyItemFirst %%================================ 'enc_RAB-SetupOrModifyItemFirst'({'RAB-SetupOrModifyItemFirst',Val}, TagIn) -> 'enc_RAB-SetupOrModifyItemFirst'(Val, TagIn); 'enc_RAB-SetupOrModifyItemFirst'(Val, TagIn) -> ?RT_BER:encode_integer([], Val, TagIn ++ []). 'dec_RAB-SetupOrModifyItemFirst'(Bytes, OptOrMand) -> 'dec_RAB-SetupOrModifyItemFirst'(Bytes, OptOrMand, []). 'dec_RAB-SetupOrModifyItemFirst'(Bytes, OptOrMand, TagIn) -> ?RT_BER:decode_integer(Bytes,{0,31},TagIn++[], OptOrMand). %%================================ %% RAB-SetupOrModifyItemSecond %%================================ 'enc_RAB-SetupOrModifyItemSecond'({'RAB-SetupOrModifyItemSecond',Val}, TagIn) -> 'enc_RAB-SetupOrModifyItemSecond'(Val, TagIn); 'enc_RAB-SetupOrModifyItemSecond'(Val, TagIn) -> ?RT_BER:encode_integer([], Val, TagIn ++ []). 'dec_RAB-SetupOrModifyItemSecond'(Bytes, OptOrMand) -> 'dec_RAB-SetupOrModifyItemSecond'(Bytes, OptOrMand, []). 'dec_RAB-SetupOrModifyItemSecond'(Bytes, OptOrMand, TagIn) -> ?RT_BER:decode_integer(Bytes,{0,31},TagIn++[], OptOrMand). 'id-RAB-SetupOrModifyItem'() -> 53. 'maxProtocolIEs'() -> 65535. 'maxNrOfRABs'() -> 256. %%================================ %% RAB-SetupOrModifyItem-IEs %%================================ 'getenc_RAB-SetupOrModifyItem-IEs'(id,53) -> fun(Type, Val, TagIn, RestPrimFieldName) -> case Type of 'FirstValue' -> 'enc_RAB-SetupOrModifyItemFirst'(Val, TagIn ++ []); 'SecondValue' -> 'enc_RAB-SetupOrModifyItemSecond'(Val, TagIn ++ []) end end; 'getenc_RAB-SetupOrModifyItem-IEs'(Any1, Any2) -> fun(Attr, Val, TagIn, RestPrimFieldName) -> Len = case Val of Bin when binary(Bin) -> size(Bin); _ -> length(Val) end, {Val,Len} end. 'getdec_RAB-SetupOrModifyItem-IEs'(id,53) -> fun(Type, Bytes, TagIn, RestPrimFieldName) -> case Type of 'FirstValue' -> 'dec_RAB-SetupOrModifyItemFirst'(Bytes, mandatory, TagIn ++ []); 'SecondValue' -> 'dec_RAB-SetupOrModifyItemSecond'(Bytes, mandatory, TagIn ++ []) end end; 'getdec_RAB-SetupOrModifyItem-IEs'(Any1, Any2) -> fun(Attr1, Bytes, Tag, RestPrimFieldName) -> Len = case Bytes of Bin when binary(Bin) -> size(Bin); _ -> length(Bytes) end, {Bytes,[],Len} end.