%% Generated by the Erlang ASN.1 BER compiler. Version: 5.0.9 %% Purpose: Encoding and decoding of the types in DirectoryAbstractService. -module('DirectoryAbstractService'). -compile(nowarn_unused_vars). -dialyzer(no_improper_lists). -include("DirectoryAbstractService.hrl"). -asn1_info([{vsn,'5.0.9'}, {module,'DirectoryAbstractService'}, {options,[{i,"src"},noobj,{outdir,"src"},{i,"."},{i,"priv/kep"}]}]). -export([encoding_rule/0,maps/0,bit_string_format/0, legacy_erlang_types/0]). -export(['dialyzer-suppressions'/1]). -export([ enc_AgreementID/2, enc_Code/2, enc_OperationProgress/2, enc_ReferenceType/2, enc_CommonArguments/2, enc_FamilyGrouping/2, enc_CommonResults/2, enc_CommonResultsSeq/2, enc_ServiceControls/2, enc_ServiceControlOptions/2, enc_EntryInformationSelection/2, enc_ContextSelection/2, enc_TypeAndContextAssertion/2, enc_FamilyReturn/2, enc_FamilyEntries/2, enc_FamilyEntry/2, enc_EntryInformation/2, enc_Filter/2, enc_FilterItem/2, enc_MatchingRuleAssertion/2, enc_PagedResultsRequest/2, enc_SortKey/2, enc_SecurityParameters/2, enc_HierarchySelections/2, enc_SearchControlOptions/2, enc_ProtectionRequest/2, enc_Time/2, enc_ErrorProtectionRequest/2 ]). -export([ dec_AgreementID/2, dec_Code/2, dec_OperationProgress/2, dec_ReferenceType/2, dec_CommonArguments/2, dec_FamilyGrouping/2, dec_CommonResults/2, dec_CommonResultsSeq/2, dec_ServiceControls/2, dec_ServiceControlOptions/2, dec_EntryInformationSelection/2, dec_ContextSelection/2, dec_TypeAndContextAssertion/2, dec_FamilyReturn/2, dec_FamilyEntries/2, dec_FamilyEntry/2, dec_EntryInformation/2, dec_Filter/2, dec_FilterItem/2, dec_MatchingRuleAssertion/2, dec_PagedResultsRequest/2, dec_SortKey/2, dec_SecurityParameters/2, dec_HierarchySelections/2, dec_SearchControlOptions/2, dec_ProtectionRequest/2, dec_Time/2, dec_ErrorProtectionRequest/2 ]). -export([info/0]). -export([encode/2,decode/2]). encoding_rule() -> ber. maps() -> false. bit_string_format() -> bitstring. legacy_erlang_types() -> false. encode(Type, Data) -> try iolist_to_binary(element(1, encode_disp(Type, Data))) of Bytes -> {ok,Bytes} catch Class:Exception:Stk when Class =:= error; Class =:= exit -> case Exception of {error,{asn1,Reason}} -> {error,{asn1,{Reason,Stk}}}; Reason -> {error,{asn1,{Reason,Stk}}} end end. decode(Type, Data) -> try Result = decode_disp(Type, element(1, ber_decode_nif(Data))), {ok,Result} catch Class:Exception:Stk when Class =:= error; Class =:= exit -> case Exception of {error,{asn1,Reason}} -> {error,{asn1,{Reason,Stk}}}; Reason -> {error,{asn1,{Reason,Stk}}} end end. encode_disp('AgreementID', Data) -> enc_AgreementID(Data); encode_disp('Code', Data) -> enc_Code(Data); encode_disp('OperationProgress', Data) -> enc_OperationProgress(Data); encode_disp('ReferenceType', Data) -> enc_ReferenceType(Data); encode_disp('CommonArguments', Data) -> enc_CommonArguments(Data); encode_disp('FamilyGrouping', Data) -> enc_FamilyGrouping(Data); encode_disp('CommonResults', Data) -> enc_CommonResults(Data); encode_disp('CommonResultsSeq', Data) -> enc_CommonResultsSeq(Data); encode_disp('ServiceControls', Data) -> enc_ServiceControls(Data); encode_disp('ServiceControlOptions', Data) -> enc_ServiceControlOptions(Data); encode_disp('EntryInformationSelection', Data) -> enc_EntryInformationSelection(Data); encode_disp('ContextSelection', Data) -> enc_ContextSelection(Data); encode_disp('TypeAndContextAssertion', Data) -> enc_TypeAndContextAssertion(Data); encode_disp('FamilyReturn', Data) -> enc_FamilyReturn(Data); encode_disp('FamilyEntries', Data) -> enc_FamilyEntries(Data); encode_disp('FamilyEntry', Data) -> enc_FamilyEntry(Data); encode_disp('EntryInformation', Data) -> enc_EntryInformation(Data); encode_disp('Filter', Data) -> enc_Filter(Data); encode_disp('FilterItem', Data) -> enc_FilterItem(Data); encode_disp('MatchingRuleAssertion', Data) -> enc_MatchingRuleAssertion(Data); encode_disp('PagedResultsRequest', Data) -> enc_PagedResultsRequest(Data); encode_disp('SortKey', Data) -> enc_SortKey(Data); encode_disp('SecurityParameters', Data) -> enc_SecurityParameters(Data); encode_disp('HierarchySelections', Data) -> enc_HierarchySelections(Data); encode_disp('SearchControlOptions', Data) -> enc_SearchControlOptions(Data); encode_disp('ProtectionRequest', Data) -> enc_ProtectionRequest(Data); encode_disp('Time', Data) -> enc_Time(Data); encode_disp('ErrorProtectionRequest', Data) -> enc_ErrorProtectionRequest(Data); encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}). decode_disp('AgreementID', Data) -> dec_AgreementID(Data); decode_disp('Code', Data) -> dec_Code(Data); decode_disp('OperationProgress', Data) -> dec_OperationProgress(Data); decode_disp('ReferenceType', Data) -> dec_ReferenceType(Data); decode_disp('CommonArguments', Data) -> dec_CommonArguments(Data); decode_disp('FamilyGrouping', Data) -> dec_FamilyGrouping(Data); decode_disp('CommonResults', Data) -> dec_CommonResults(Data); decode_disp('CommonResultsSeq', Data) -> dec_CommonResultsSeq(Data); decode_disp('ServiceControls', Data) -> dec_ServiceControls(Data); decode_disp('ServiceControlOptions', Data) -> dec_ServiceControlOptions(Data); decode_disp('EntryInformationSelection', Data) -> dec_EntryInformationSelection(Data); decode_disp('ContextSelection', Data) -> dec_ContextSelection(Data); decode_disp('TypeAndContextAssertion', Data) -> dec_TypeAndContextAssertion(Data); decode_disp('FamilyReturn', Data) -> dec_FamilyReturn(Data); decode_disp('FamilyEntries', Data) -> dec_FamilyEntries(Data); decode_disp('FamilyEntry', Data) -> dec_FamilyEntry(Data); decode_disp('EntryInformation', Data) -> dec_EntryInformation(Data); decode_disp('Filter', Data) -> dec_Filter(Data); decode_disp('FilterItem', Data) -> dec_FilterItem(Data); decode_disp('MatchingRuleAssertion', Data) -> dec_MatchingRuleAssertion(Data); decode_disp('PagedResultsRequest', Data) -> dec_PagedResultsRequest(Data); decode_disp('SortKey', Data) -> dec_SortKey(Data); decode_disp('SecurityParameters', Data) -> dec_SecurityParameters(Data); decode_disp('HierarchySelections', Data) -> dec_HierarchySelections(Data); decode_disp('SearchControlOptions', Data) -> dec_SearchControlOptions(Data); decode_disp('ProtectionRequest', Data) -> dec_ProtectionRequest(Data); decode_disp('Time', Data) -> dec_Time(Data); decode_disp('ErrorProtectionRequest', Data) -> dec_ErrorProtectionRequest(Data); decode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}). info() -> 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. %%================================ %% AgreementID %%================================ enc_AgreementID(Val) -> enc_AgreementID(Val, [<<48>>]). enc_AgreementID(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute identifier(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>]), %%------------------------------------------------- %% attribute version(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_AgreementID(Tlv) -> dec_AgreementID(Tlv, [16]). dec_AgreementID(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute identifier(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_integer(V1, [2]), %%------------------------------------------------- %% attribute version(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_integer(V2, [2]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'AgreementID',Term1,Term2}, Res1. %%================================ %% Code %%================================ enc_Code(Val) -> enc_Code(Val, []). enc_Code(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of local -> encode_integer(element(2,Val), [<<2>>]); global -> encode_object_identifier(element(2,Val), [<<6>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). dec_Code(Tlv) -> dec_Code(Tlv, []). dec_Code(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'local' {2, V1} -> {local, decode_integer(V1, [])}; %% 'global' {6, V1} -> {global, decode_object_identifier(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . %%================================ %% OperationProgress %%================================ enc_OperationProgress(Val) -> enc_OperationProgress(Val, [<<49>>]). enc_OperationProgress(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute nameResolutionPhase(1) with type ENUMERATED %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of notStarted -> encode_tags([<<10>>,<<160>>], [1], 1); proceeding -> encode_tags([<<10>>,<<160>>], [2], 1); completed -> encode_tags([<<10>>,<<160>>], [3], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end, %%------------------------------------------------- %% attribute nextRDNToBeResolved(2) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex2, [<<2>>,<<161>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_OperationProgress(Tlv) -> dec_OperationProgress(Tlv, [17]). dec_OperationProgress(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), SetFun = fun(FunTlv) -> case FunTlv of %nameResolutionPhase TTlv = {131072,_} -> {1, TTlv}; %nextRDNToBeResolved TTlv = {131073,_} -> {2, TTlv}; Else -> {3, Else} end end, PositionList = [SetFun(TempTlv)|| TempTlv <- Tlv1], Tlv2 = [Stlv || {_,Stlv} <- lists:sort(PositionList)], %%------------------------------------------------- %% attribute nameResolutionPhase(1) with type ENUMERATED %%------------------------------------------------- [V1|Tlv3] = Tlv2, Term1 = case decode_integer(V1, [131072,10]) of 1 -> notStarted; 2 -> proceeding; 3 -> completed; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute nextRDNToBeResolved(2) with type INTEGER OPTIONAL %%------------------------------------------------- {Term2,Tlv4} = case Tlv3 of [{131073,V2}|TempTlv4] -> {decode_integer(V2, [2]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'OperationProgress',Term1,Term2}, Res1. %%================================ %% ReferenceType %%================================ enc_ReferenceType(Val) -> enc_ReferenceType(Val, [<<10>>]). enc_ReferenceType(Val, TagIn) -> case Val of superior -> encode_tags(TagIn, [1], 1); subordinate -> encode_tags(TagIn, [2], 1); cross -> encode_tags(TagIn, [3], 1); nonSpecificSubordinate -> encode_tags(TagIn, [4], 1); supplier -> encode_tags(TagIn, [5], 1); master -> encode_tags(TagIn, [6], 1); immediateSuperior -> encode_tags(TagIn, [7], 1); self -> encode_tags(TagIn, [8], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_ReferenceType(Tlv) -> dec_ReferenceType(Tlv, [10]). dec_ReferenceType(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> superior; 2 -> subordinate; 3 -> cross; 4 -> nonSpecificSubordinate; 5 -> supplier; 6 -> master; 7 -> immediateSuperior; 8 -> self; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% CommonArguments %%================================ enc_CommonArguments(Val) -> enc_CommonArguments(Val, [<<49>>]). enc_CommonArguments(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11} = Val, %%------------------------------------------------- %% attribute serviceControls(1) External DirectoryAbstractService:ServiceControls DEFAULT = {'ServiceControls',[],1,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE} %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex1 =:= {'ServiceControls',[],1,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE} -> {<<>>,0}; _ -> 'enc_ServiceControls'(Cindex1, [<<49>>,<<190>>]) end, %%------------------------------------------------- %% attribute securityParameters(2) External DirectoryAbstractService:SecurityParameters OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_SecurityParameters'(Cindex2, [<<49>>,<<189>>]) end, %%------------------------------------------------- %% attribute requestor(3) External InformationFramework:DistinguishedName OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'InformationFramework':'enc_DistinguishedName'(Cindex3, [<<48>>,<<188>>]) end, %%------------------------------------------------- %% attribute operationProgress(4) External DirectoryAbstractService:OperationProgress DEFAULT = {'OperationProgress',notStarted,asn1_NOVALUE} %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex4 =:= {'OperationProgress',notStarted,asn1_NOVALUE} -> {<<>>,0}; _ -> 'enc_OperationProgress'(Cindex4, [<<49>>,<<187>>]) end, %%------------------------------------------------- %% attribute aliasedRDNs(5) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex5, [<<2>>,<<186>>]) end, %%------------------------------------------------- %% attribute criticalExtensions(6) with type BIT STRING OPTIONAL %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_unnamed_bit_string(Cindex6, [<<3>>,<<185>>]) end, %%------------------------------------------------- %% attribute referenceType(7) with type ENUMERATED OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> case Cindex7 of superior -> encode_tags([<<10>>,<<184>>], [1], 1); subordinate -> encode_tags([<<10>>,<<184>>], [2], 1); cross -> encode_tags([<<10>>,<<184>>], [3], 1); nonSpecificSubordinate -> encode_tags([<<10>>,<<184>>], [4], 1); supplier -> encode_tags([<<10>>,<<184>>], [5], 1); master -> encode_tags([<<10>>,<<184>>], [6], 1); immediateSuperior -> encode_tags([<<10>>,<<184>>], [7], 1); self -> encode_tags([<<10>>,<<184>>], [8], 1); Enumval3 -> exit({error,{asn1, {enumerated_not_in_range,Enumval3}}}) end end, %%------------------------------------------------- %% attribute entryOnly(8) with type BOOLEAN DEFAULT = true %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex8 =:= true -> {<<>>,0}; _ -> encode_boolean(Cindex8, [<<1>>,<<183>>]) end, %%------------------------------------------------- %% attribute nameResolveOnMaste(9) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex9 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex9, [<<1>>,<<181>>]) end, %%------------------------------------------------- %% attribute operationContexts(10) External DirectoryAbstractService:ContextSelection OPTIONAL %%------------------------------------------------- {EncBytes10,EncLen10} = case Cindex10 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_ContextSelection'(Cindex10, [<<180>>]) end, %%------------------------------------------------- %% attribute familyGrouping(11) with type ENUMERATED DEFAULT = entryOnly %%------------------------------------------------- {EncBytes11,EncLen11} = case Cindex11 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex11 =:= entryOnly -> {<<>>,0}; _ -> case Cindex11 of entryOnly -> encode_tags([<<10>>,<<179>>], [1], 1); compoundEntry -> encode_tags([<<10>>,<<179>>], [2], 1); strands -> encode_tags([<<10>>,<<179>>], [3], 1); multiStrand -> encode_tags([<<10>>,<<179>>], [4], 1); Enumval6 -> exit({error,{asn1, {enumerated_not_in_range,Enumval6}}}) end end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_CommonArguments(Tlv) -> dec_CommonArguments(Tlv, [17]). dec_CommonArguments(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), SetFun = fun(FunTlv) -> case FunTlv of %serviceControls TTlv = {131102,_} -> {1, TTlv}; %securityParameters TTlv = {131101,_} -> {2, TTlv}; %requestor TTlv = {131100,_} -> {3, TTlv}; %operationProgress TTlv = {131099,_} -> {4, TTlv}; %aliasedRDNs TTlv = {131098,_} -> {5, TTlv}; %criticalExtensions TTlv = {131097,_} -> {6, TTlv}; %referenceType TTlv = {131096,_} -> {7, TTlv}; %entryOnly TTlv = {131095,_} -> {8, TTlv}; %nameResolveOnMaste TTlv = {131093,_} -> {9, TTlv}; %operationContexts TTlv = {131092,_} -> {10, TTlv}; %familyGrouping TTlv = {131091,_} -> {11, TTlv}; Else -> {12, Else} end end, PositionList = [SetFun(TempTlv)|| TempTlv <- Tlv1], Tlv2 = [Stlv || {_,Stlv} <- lists:sort(PositionList)], %%------------------------------------------------- %% attribute serviceControls(1) External DirectoryAbstractService:ServiceControls DEFAULT = {'ServiceControls',[],1,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE} %%------------------------------------------------- {Term1,Tlv3} = case Tlv2 of [{131102,V1}|TempTlv3] -> {'dec_ServiceControls'(V1, [17]), TempTlv3}; _ -> {{'ServiceControls',[],1,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE},Tlv2} end, %%------------------------------------------------- %% attribute securityParameters(2) External DirectoryAbstractService:SecurityParameters OPTIONAL %%------------------------------------------------- {Term2,Tlv4} = case Tlv3 of [{131101,V2}|TempTlv4] -> {'dec_SecurityParameters'(V2, [17]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute requestor(3) External InformationFramework:DistinguishedName OPTIONAL %%------------------------------------------------- {Term3,Tlv5} = case Tlv4 of [{131100,V3}|TempTlv5] -> {'InformationFramework':'dec_DistinguishedName'(V3, [16]), TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute operationProgress(4) External DirectoryAbstractService:OperationProgress DEFAULT = {'OperationProgress',notStarted,asn1_NOVALUE} %%------------------------------------------------- {Term4,Tlv6} = case Tlv5 of [{131099,V4}|TempTlv6] -> {'dec_OperationProgress'(V4, [17]), TempTlv6}; _ -> {{'OperationProgress',notStarted,asn1_NOVALUE},Tlv5} end, %%------------------------------------------------- %% attribute aliasedRDNs(5) with type INTEGER OPTIONAL %%------------------------------------------------- {Term5,Tlv7} = case Tlv6 of [{131098,V5}|TempTlv7] -> {decode_integer(V5, [2]), TempTlv7}; _ -> { asn1_NOVALUE, Tlv6} end, %%------------------------------------------------- %% attribute criticalExtensions(6) with type BIT STRING OPTIONAL %%------------------------------------------------- {Term6,Tlv8} = case Tlv7 of [{131097,V6}|TempTlv8] -> {decode_native_bit_string(V6, [3]), TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- %% attribute referenceType(7) with type ENUMERATED OPTIONAL %%------------------------------------------------- {Term7,Tlv9} = case Tlv8 of [{131096,V7}|TempTlv9] -> {case decode_integer(V7, [10]) of 1 -> superior; 2 -> subordinate; 3 -> cross; 4 -> nonSpecificSubordinate; 5 -> supplier; 6 -> master; 7 -> immediateSuperior; 8 -> self; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, TempTlv9}; _ -> { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- %% attribute entryOnly(8) with type BOOLEAN DEFAULT = true %%------------------------------------------------- {Term8,Tlv10} = case Tlv9 of [{131095,V8}|TempTlv10] -> {decode_boolean(V8, [1]), TempTlv10}; _ -> {true,Tlv9} end, %%------------------------------------------------- %% attribute nameResolveOnMaste(9) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term9,Tlv11} = case Tlv10 of [{131093,V9}|TempTlv11] -> {decode_boolean(V9, [1]), TempTlv11}; _ -> {false,Tlv10} end, %%------------------------------------------------- %% attribute operationContexts(10) External DirectoryAbstractService:ContextSelection OPTIONAL %%------------------------------------------------- {Term10,Tlv12} = case Tlv11 of [{131092,V10}|TempTlv12] -> {'dec_ContextSelection'(V10, []), TempTlv12}; _ -> { asn1_NOVALUE, Tlv11} end, %%------------------------------------------------- %% attribute familyGrouping(11) with type ENUMERATED DEFAULT = entryOnly %%------------------------------------------------- {Term11,Tlv13} = case Tlv12 of [{131091,V11}|TempTlv13] -> {case decode_integer(V11, [10]) of 1 -> entryOnly; 2 -> compoundEntry; 3 -> strands; 4 -> multiStrand; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, TempTlv13}; _ -> {entryOnly,Tlv12} end, case Tlv13 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv13}}}) % extra fields not allowed end, Res1 = {'CommonArguments',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11}, Res1. %%================================ %% FamilyGrouping %%================================ enc_FamilyGrouping(Val) -> enc_FamilyGrouping(Val, [<<10>>]). enc_FamilyGrouping(Val, TagIn) -> case Val of entryOnly -> encode_tags(TagIn, [1], 1); compoundEntry -> encode_tags(TagIn, [2], 1); strands -> encode_tags(TagIn, [3], 1); multiStrand -> encode_tags(TagIn, [4], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_FamilyGrouping(Tlv) -> dec_FamilyGrouping(Tlv, [10]). dec_FamilyGrouping(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> entryOnly; 2 -> compoundEntry; 3 -> strands; 4 -> multiStrand; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% CommonResults %%================================ enc_CommonResults(Val) -> enc_CommonResults(Val, [<<49>>]). enc_CommonResults(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute securityParameters(1) External DirectoryAbstractService:SecurityParameters OPTIONAL %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_SecurityParameters'(Cindex1, [<<49>>,<<190>>]) end, %%------------------------------------------------- %% attribute performer(2) External InformationFramework:DistinguishedName OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'InformationFramework':'enc_DistinguishedName'(Cindex2, [<<48>>,<<189>>]) end, %%------------------------------------------------- %% attribute aliasDereferenced(3) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex3 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex3, [<<1>>,<<188>>]) end, %%------------------------------------------------- %% attribute notification(4) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_CommonResults_notification'(Cindex4, [<<48>>,<<187>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% CommonResults_notification %%================================ enc_CommonResults_notification(Val, TagIn) -> {EncBytes,EncLen} = 'enc_CommonResults_notification_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_CommonResults_notification_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_CommonResults_notification_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'InformationFramework':'enc_Attribute'(H, [<<48>>]), 'enc_CommonResults_notification_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_CommonResults(Tlv) -> dec_CommonResults(Tlv, [17]). dec_CommonResults(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), SetFun = fun(FunTlv) -> case FunTlv of %securityParameters TTlv = {131102,_} -> {1, TTlv}; %performer TTlv = {131101,_} -> {2, TTlv}; %aliasDereferenced TTlv = {131100,_} -> {3, TTlv}; %notification TTlv = {131099,_} -> {4, TTlv}; Else -> {5, Else} end end, PositionList = [SetFun(TempTlv)|| TempTlv <- Tlv1], Tlv2 = [Stlv || {_,Stlv} <- lists:sort(PositionList)], %%------------------------------------------------- %% attribute securityParameters(1) External DirectoryAbstractService:SecurityParameters OPTIONAL %%------------------------------------------------- {Term1,Tlv3} = case Tlv2 of [{131102,V1}|TempTlv3] -> {'dec_SecurityParameters'(V1, [17]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute performer(2) External InformationFramework:DistinguishedName OPTIONAL %%------------------------------------------------- {Term2,Tlv4} = case Tlv3 of [{131101,V2}|TempTlv4] -> {'InformationFramework':'dec_DistinguishedName'(V2, [16]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute aliasDereferenced(3) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term3,Tlv5} = case Tlv4 of [{131100,V3}|TempTlv5] -> {decode_boolean(V3, [1]), TempTlv5}; _ -> {false,Tlv4} end, %%------------------------------------------------- %% attribute notification(4) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term4,Tlv6} = case Tlv5 of [{131099,V4}|TempTlv6] -> {'dec_CommonResults_notification'(V4, [16]), TempTlv6}; _ -> { asn1_NOVALUE, Tlv5} end, case Tlv6 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowed end, Res1 = {'CommonResults',Term1,Term2,Term3,Term4}, Res1. 'dec_CommonResults_notification'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['InformationFramework':'dec_Attribute'(V1, [16]) || V1 <- Tlv1]. %%================================ %% CommonResultsSeq %%================================ enc_CommonResultsSeq(Val) -> enc_CommonResultsSeq(Val, [<<48>>]). enc_CommonResultsSeq(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute securityParameters(1) External DirectoryAbstractService:SecurityParameters OPTIONAL %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_SecurityParameters'(Cindex1, [<<49>>,<<190>>]) end, %%------------------------------------------------- %% attribute performer(2) External InformationFramework:DistinguishedName OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'InformationFramework':'enc_DistinguishedName'(Cindex2, [<<48>>,<<189>>]) end, %%------------------------------------------------- %% attribute aliasDereferenced(3) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex3 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex3, [<<1>>,<<188>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_CommonResultsSeq(Tlv) -> dec_CommonResultsSeq(Tlv, [16]). dec_CommonResultsSeq(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute securityParameters(1) External DirectoryAbstractService:SecurityParameters OPTIONAL %%------------------------------------------------- {Term1,Tlv2} = case Tlv1 of [{131102,V1}|TempTlv2] -> {'dec_SecurityParameters'(V1, [17]), TempTlv2}; _ -> { asn1_NOVALUE, Tlv1} end, %%------------------------------------------------- %% attribute performer(2) External InformationFramework:DistinguishedName OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131101,V2}|TempTlv3] -> {'InformationFramework':'dec_DistinguishedName'(V2, [16]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute aliasDereferenced(3) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131100,V3}|TempTlv4] -> {decode_boolean(V3, [1]), TempTlv4}; _ -> {false,Tlv3} end, case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'CommonResultsSeq',Term1,Term2,Term3}, Res1. %%================================ %% ServiceControls %%================================ enc_ServiceControls(Val) -> enc_ServiceControls(Val, [<<49>>]). enc_ServiceControls(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9} = Val, %%------------------------------------------------- %% attribute options(1) with type BIT STRING DEFAULT = [] %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex1 =:= [] -> {<<>>,0}; _ -> encode_named_bit_string(Cindex1, [{preferChaining,0},{chainingProhibited,1},{localScope,2},{dontUseCopy,3},{dontDereferenceAliases,4},{subentries,5},{copyShallDo,6},{partialNameResolution,7},{manageDSAIT,8},{noSubtypeMatch,9},{noSubtypeSelection,10},{countFamily,11}], [<<3>>,<<160>>]) end, %%------------------------------------------------- %% attribute priority(2) with type INTEGER DEFAULT = 1 %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex2 =:= 1 -> {<<>>,0}; _ -> encode_integer(Cindex2, [{low,0},{medium,1},{high,2}], [<<2>>,<<161>>]) end, %%------------------------------------------------- %% attribute timeLimit(3) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex3, [<<2>>,<<162>>]) end, %%------------------------------------------------- %% attribute sizeLimit(4) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex4, [<<2>>,<<163>>]) end, %%------------------------------------------------- %% attribute scopeOfReferral(5) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex5, [{dmd,0},{country,1}], [<<2>>,<<164>>]) end, %%------------------------------------------------- %% attribute attributeSizeLimit(6) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex6, [<<2>>,<<165>>]) end, %%------------------------------------------------- %% attribute manageDSAITPlaneRef(7) with type SEQUENCE OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_ServiceControls_manageDSAITPlaneRef'(Cindex7, [<<48>>,<<166>>]) end, %%------------------------------------------------- %% attribute serviceType(8) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_object_identifier(Cindex8, [<<6>>,<<167>>]) end, %%------------------------------------------------- %% attribute userClass(9) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex9, [<<2>>,<<168>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% ServiceControls_manageDSAITPlaneRef %%================================ enc_ServiceControls_manageDSAITPlaneRef(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute dsaName(1) External InformationFramework:Name %%------------------------------------------------- {EncBytes1,EncLen1} = 'InformationFramework':'enc_Name'(Cindex1, []), %%------------------------------------------------- %% attribute agreementID(2) External DirectoryAbstractService:AgreementID %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_AgreementID'(Cindex2, [<<48>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_ServiceControls(Tlv) -> dec_ServiceControls(Tlv, [17]). dec_ServiceControls(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), SetFun = fun(FunTlv) -> case FunTlv of %options TTlv = {131072,_} -> {1, TTlv}; %priority TTlv = {131073,_} -> {2, TTlv}; %timeLimit TTlv = {131074,_} -> {3, TTlv}; %sizeLimit TTlv = {131075,_} -> {4, TTlv}; %scopeOfReferral TTlv = {131076,_} -> {5, TTlv}; %attributeSizeLimit TTlv = {131077,_} -> {6, TTlv}; %manageDSAITPlaneRef TTlv = {131078,_} -> {7, TTlv}; %serviceType TTlv = {131079,_} -> {8, TTlv}; %userClass TTlv = {131080,_} -> {9, TTlv}; Else -> {10, Else} end end, PositionList = [SetFun(TempTlv)|| TempTlv <- Tlv1], Tlv2 = [Stlv || {_,Stlv} <- lists:sort(PositionList)], %%------------------------------------------------- %% attribute options(1) with type BIT STRING DEFAULT = [] %%------------------------------------------------- {Term1,Tlv3} = case Tlv2 of [{131072,V1}|TempTlv3] -> {decode_named_bit_string(V1, [{preferChaining,0},{chainingProhibited,1},{localScope,2},{dontUseCopy,3},{dontDereferenceAliases,4},{subentries,5},{copyShallDo,6},{partialNameResolution,7},{manageDSAIT,8},{noSubtypeMatch,9},{noSubtypeSelection,10},{countFamily,11}], [3]), TempTlv3}; _ -> {[],Tlv2} end, %%------------------------------------------------- %% attribute priority(2) with type INTEGER DEFAULT = 1 %%------------------------------------------------- {Term2,Tlv4} = case Tlv3 of [{131073,V2}|TempTlv4] -> {begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{low,0},{medium,1},{high,2}]) end , TempTlv4}; _ -> {1,Tlv3} end, %%------------------------------------------------- %% attribute timeLimit(3) with type INTEGER OPTIONAL %%------------------------------------------------- {Term3,Tlv5} = case Tlv4 of [{131074,V3}|TempTlv5] -> {decode_integer(V3, [2]), TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute sizeLimit(4) with type INTEGER OPTIONAL %%------------------------------------------------- {Term4,Tlv6} = case Tlv5 of [{131075,V4}|TempTlv6] -> {decode_integer(V4, [2]), TempTlv6}; _ -> { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- %% attribute scopeOfReferral(5) with type INTEGER OPTIONAL %%------------------------------------------------- {Term5,Tlv7} = case Tlv6 of [{131076,V5}|TempTlv7] -> {begin Val2 = decode_integer(V5, [2]), number2name(Val2, [{dmd,0},{country,1}]) end , TempTlv7}; _ -> { asn1_NOVALUE, Tlv6} end, %%------------------------------------------------- %% attribute attributeSizeLimit(6) with type INTEGER OPTIONAL %%------------------------------------------------- {Term6,Tlv8} = case Tlv7 of [{131077,V6}|TempTlv8] -> {decode_integer(V6, [2]), TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- %% attribute manageDSAITPlaneRef(7) with type SEQUENCE OPTIONAL %%------------------------------------------------- {Term7,Tlv9} = case Tlv8 of [{131078,V7}|TempTlv9] -> {'dec_ServiceControls_manageDSAITPlaneRef'(V7, [16]), TempTlv9}; _ -> { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- %% attribute serviceType(8) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- {Term8,Tlv10} = case Tlv9 of [{131079,V8}|TempTlv10] -> {decode_object_identifier(V8, [6]), TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- %% attribute userClass(9) with type INTEGER OPTIONAL %%------------------------------------------------- {Term9,Tlv11} = case Tlv10 of [{131080,V9}|TempTlv11] -> {decode_integer(V9, [2]), TempTlv11}; _ -> { asn1_NOVALUE, Tlv10} end, case Tlv11 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv11}}}) % extra fields not allowed end, Res1 = {'ServiceControls',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9}, Res1. 'dec_ServiceControls_manageDSAITPlaneRef'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute dsaName(1) External InformationFramework:Name %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'InformationFramework':'dec_Name'(V1, []), %%------------------------------------------------- %% attribute agreementID(2) External DirectoryAbstractService:AgreementID %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_AgreementID'(V2, [16]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'ServiceControls_manageDSAITPlaneRef',Term1,Term2}, Res1. %%================================ %% ServiceControlOptions %%================================ enc_ServiceControlOptions(Val) -> enc_ServiceControlOptions(Val, [<<3>>]). enc_ServiceControlOptions(Val, TagIn) -> encode_named_bit_string(Val, [{preferChaining,0},{chainingProhibited,1},{localScope,2},{dontUseCopy,3},{dontDereferenceAliases,4},{subentries,5},{copyShallDo,6},{partialNameResolution,7},{manageDSAIT,8},{noSubtypeMatch,9},{noSubtypeSelection,10},{countFamily,11}], TagIn). dec_ServiceControlOptions(Tlv) -> dec_ServiceControlOptions(Tlv, [3]). dec_ServiceControlOptions(Tlv, TagIn) -> decode_named_bit_string(Tlv, [{preferChaining,0},{chainingProhibited,1},{localScope,2},{dontUseCopy,3},{dontDereferenceAliases,4},{subentries,5},{copyShallDo,6},{partialNameResolution,7},{manageDSAIT,8},{noSubtypeMatch,9},{noSubtypeSelection,10},{countFamily,11}], TagIn). %%================================ %% EntryInformationSelection %%================================ enc_EntryInformationSelection(Val) -> enc_EntryInformationSelection(Val, [<<49>>]). enc_EntryInformationSelection(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6} = Val, %%------------------------------------------------- %% attribute attributes(1) with type CHOICE DEFAULT = {allUserAttributes,'NULL'} %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex1 =:= {allUserAttributes,'NULL'} -> {<<>>,0}; _ -> 'enc_EntryInformationSelection_attributes'(Cindex1, []) end, %%------------------------------------------------- %% attribute infoTypes(2) with type INTEGER DEFAULT = 1 %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex2 =:= 1 -> {<<>>,0}; _ -> encode_integer(Cindex2, [{attributeTypesOnly,0},{attributeTypesAndValues,1}], [<<2>>,<<162>>]) end, %%------------------------------------------------- %% attribute extraAttributes(3) with type CHOICE OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_EntryInformationSelection_extraAttributes'(Cindex3, []) end, %%------------------------------------------------- %% attribute contextSelection(4) External DirectoryAbstractService:ContextSelection OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_ContextSelection'(Cindex4, []) end, %%------------------------------------------------- %% attribute returnContexts(5) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex5 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex5, [<<1>>]) end, %%------------------------------------------------- %% attribute familyReturn(6) External DirectoryAbstractService:FamilyReturn DEFAULT = {'FamilyReturn',contributingEntriesOnly,asn1_NOVALUE} %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex6 =:= {'FamilyReturn',contributingEntriesOnly,asn1_NOVALUE} -> {<<>>,0}; _ -> 'enc_FamilyReturn'(Cindex6, [<<48>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% EntryInformationSelection_attributes %%================================ enc_EntryInformationSelection_attributes(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of allUserAttributes -> encode_null(element(2,Val), [<<5>>,<<160>>]); select -> 'enc_EntryInformationSelection_attributes_select'(element(2,Val), [<<49>>,<<161>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% EntryInformationSelection_attributes_select %%================================ enc_EntryInformationSelection_attributes_select(Val, TagIn) -> {EncBytes,EncLen} = 'enc_EntryInformationSelection_attributes_select_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_EntryInformationSelection_attributes_select_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_EntryInformationSelection_attributes_select_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_object_identifier(H, [<<6>>]), 'enc_EntryInformationSelection_attributes_select_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% EntryInformationSelection_extraAttributes %%================================ enc_EntryInformationSelection_extraAttributes(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of allOperationalAttributes -> encode_null(element(2,Val), [<<5>>,<<163>>]); select -> 'enc_EntryInformationSelection_extraAttributes_select'(element(2,Val), [<<49>>,<<164>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% EntryInformationSelection_extraAttributes_select %%================================ enc_EntryInformationSelection_extraAttributes_select(Val, TagIn) -> {EncBytes,EncLen} = 'enc_EntryInformationSelection_extraAttributes_select_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_EntryInformationSelection_extraAttributes_select_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_EntryInformationSelection_extraAttributes_select_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_object_identifier(H, [<<6>>]), 'enc_EntryInformationSelection_extraAttributes_select_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_EntryInformationSelection(Tlv) -> dec_EntryInformationSelection(Tlv, [17]). dec_EntryInformationSelection(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), SetFun = fun(FunTlv) -> case FunTlv of %attributes TTlv = {131072,_} -> {1, TTlv}; TTlv = {131073,_} -> {1, TTlv}; %infoTypes TTlv = {131074,_} -> {2, TTlv}; %extraAttributes TTlv = {131075,_} -> {3, TTlv}; TTlv = {131076,_} -> {3, TTlv}; %contextSelection TTlv = {5,_} -> {4, TTlv}; TTlv = {17,_} -> {4, TTlv}; %returnContexts TTlv = {1,_} -> {5, TTlv}; %familyReturn TTlv = {16,_} -> {6, TTlv}; Else -> {7, Else} end end, PositionList = [SetFun(TempTlv)|| TempTlv <- Tlv1], Tlv2 = [Stlv || {_,Stlv} <- lists:sort(PositionList)], %%------------------------------------------------- %% attribute attributes(1) with type CHOICE DEFAULT = {allUserAttributes,'NULL'} %%------------------------------------------------- {Term1,Tlv3} = case Tlv2 of [V1 = {131072,_}|TempTlv3] -> {'dec_EntryInformationSelection_attributes'(V1, []), TempTlv3}; [V1 = {131073,_}|TempTlv3] -> {'dec_EntryInformationSelection_attributes'(V1, []), TempTlv3}; _ -> {{allUserAttributes,'NULL'},Tlv2} end, %%------------------------------------------------- %% attribute infoTypes(2) with type INTEGER DEFAULT = 1 %%------------------------------------------------- {Term2,Tlv4} = case Tlv3 of [{131074,V2}|TempTlv4] -> {begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{attributeTypesOnly,0},{attributeTypesAndValues,1}]) end , TempTlv4}; _ -> {1,Tlv3} end, %%------------------------------------------------- %% attribute extraAttributes(3) with type CHOICE OPTIONAL %%------------------------------------------------- {Term3,Tlv5} = case Tlv4 of [V3 = {131075,_}|TempTlv5] -> {'dec_EntryInformationSelection_extraAttributes'(V3, []), TempTlv5}; [V3 = {131076,_}|TempTlv5] -> {'dec_EntryInformationSelection_extraAttributes'(V3, []), TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute contextSelection(4) External DirectoryAbstractService:ContextSelection OPTIONAL %%------------------------------------------------- {Term4,Tlv6} = case Tlv5 of [V4 = {5,_}|TempTlv6] -> {'dec_ContextSelection'(V4, []), TempTlv6}; [V4 = {17,_}|TempTlv6] -> {'dec_ContextSelection'(V4, []), TempTlv6}; _ -> { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- %% attribute returnContexts(5) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term5,Tlv7} = case Tlv6 of [{1,V5}|TempTlv7] -> {decode_boolean(V5, []), TempTlv7}; _ -> {false,Tlv6} end, %%------------------------------------------------- %% attribute familyReturn(6) External DirectoryAbstractService:FamilyReturn DEFAULT = {'FamilyReturn',contributingEntriesOnly,asn1_NOVALUE} %%------------------------------------------------- {Term6,Tlv8} = case Tlv7 of [{16,V6}|TempTlv8] -> {'dec_FamilyReturn'(V6, []), TempTlv8}; _ -> {{'FamilyReturn',contributingEntriesOnly,asn1_NOVALUE},Tlv7} end, case Tlv8 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv8}}}) % extra fields not allowed end, Res1 = {'EntryInformationSelection',Term1,Term2,Term3,Term4,Term5,Term6}, Res1. 'dec_EntryInformationSelection_attributes'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'allUserAttributes' {131072, V1} -> {allUserAttributes, decode_null(V1, [5])}; %% 'select' {131073, V1} -> {select, 'dec_EntryInformationSelection_attributes_select'(V1, [17])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_EntryInformationSelection_attributes_select'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_object_identifier(V1, [6]) || V1 <- Tlv1]. 'dec_EntryInformationSelection_extraAttributes'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'allOperationalAttributes' {131075, V1} -> {allOperationalAttributes, decode_null(V1, [5])}; %% 'select' {131076, V1} -> {select, 'dec_EntryInformationSelection_extraAttributes_select'(V1, [17])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_EntryInformationSelection_extraAttributes_select'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_object_identifier(V1, [6]) || V1 <- Tlv1]. %%================================ %% ContextSelection %%================================ enc_ContextSelection(Val) -> enc_ContextSelection(Val, []). enc_ContextSelection(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of allContexts -> encode_null(element(2,Val), [<<5>>]); selectedContexts -> 'enc_ContextSelection_selectedContexts'(element(2,Val), [<<49>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% ContextSelection_selectedContexts %%================================ enc_ContextSelection_selectedContexts(Val, TagIn) -> {EncBytes,EncLen} = 'enc_ContextSelection_selectedContexts_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_ContextSelection_selectedContexts_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_ContextSelection_selectedContexts_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_TypeAndContextAssertion'(H, [<<48>>]), 'enc_ContextSelection_selectedContexts_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_ContextSelection(Tlv) -> dec_ContextSelection(Tlv, []). dec_ContextSelection(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'allContexts' {5, V1} -> {allContexts, decode_null(V1, [])}; %% 'selectedContexts' {17, V1} -> {selectedContexts, 'dec_ContextSelection_selectedContexts'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_ContextSelection_selectedContexts'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_TypeAndContextAssertion'(V1, [16]) || V1 <- Tlv1]. %%================================ %% TypeAndContextAssertion %%================================ enc_TypeAndContextAssertion(Val) -> enc_TypeAndContextAssertion(Val, [<<48>>]). enc_TypeAndContextAssertion(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute type(1) with type OBJECT IDENTIFIER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]), %%------------------------------------------------- %% attribute contextAssertions(2) with type CHOICE %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_TypeAndContextAssertion_contextAssertions'(Cindex2, []), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% TypeAndContextAssertion_contextAssertions %%================================ enc_TypeAndContextAssertion_contextAssertions(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of preference -> 'enc_TypeAndContextAssertion_contextAssertions_preference'(element(2,Val), [<<48>>]); all -> 'enc_TypeAndContextAssertion_contextAssertions_all'(element(2,Val), [<<49>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% TypeAndContextAssertion_contextAssertions_preference %%================================ enc_TypeAndContextAssertion_contextAssertions_preference(Val, TagIn) -> {EncBytes,EncLen} = 'enc_TypeAndContextAssertion_contextAssertions_preference_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_TypeAndContextAssertion_contextAssertions_preference_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_TypeAndContextAssertion_contextAssertions_preference_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'InformationFramework':'enc_ContextAssertion'(H, [<<48>>]), 'enc_TypeAndContextAssertion_contextAssertions_preference_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% TypeAndContextAssertion_contextAssertions_all %%================================ enc_TypeAndContextAssertion_contextAssertions_all(Val, TagIn) -> {EncBytes,EncLen} = 'enc_TypeAndContextAssertion_contextAssertions_all_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_TypeAndContextAssertion_contextAssertions_all_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_TypeAndContextAssertion_contextAssertions_all_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'InformationFramework':'enc_ContextAssertion'(H, [<<48>>]), 'enc_TypeAndContextAssertion_contextAssertions_all_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_TypeAndContextAssertion(Tlv) -> dec_TypeAndContextAssertion(Tlv, [16]). dec_TypeAndContextAssertion(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute type(1) with type OBJECT IDENTIFIER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_object_identifier(V1, [6]), %%------------------------------------------------- %% attribute contextAssertions(2) with type CHOICE %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_TypeAndContextAssertion_contextAssertions'(V2, []), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'TypeAndContextAssertion',Term1,Term2}, Res1. 'dec_TypeAndContextAssertion_contextAssertions'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'preference' {16, V1} -> {preference, 'dec_TypeAndContextAssertion_contextAssertions_preference'(V1, [])}; %% 'all' {17, V1} -> {all, 'dec_TypeAndContextAssertion_contextAssertions_all'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_TypeAndContextAssertion_contextAssertions_preference'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['InformationFramework':'dec_ContextAssertion'(V1, [16]) || V1 <- Tlv1]. 'dec_TypeAndContextAssertion_contextAssertions_all'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['InformationFramework':'dec_ContextAssertion'(V1, [16]) || V1 <- Tlv1]. %%================================ %% FamilyReturn %%================================ enc_FamilyReturn(Val) -> enc_FamilyReturn(Val, [<<48>>]). enc_FamilyReturn(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute memberSelect(1) with type ENUMERATED %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of contributingEntriesOnly -> encode_tags([<<10>>], [1], 1); participatingEntriesOnly -> encode_tags([<<10>>], [2], 1); compoundEntry -> encode_tags([<<10>>], [3], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end, %%------------------------------------------------- %% attribute familySelect(2) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_FamilyReturn_familySelect'(Cindex2, [<<48>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% FamilyReturn_familySelect %%================================ enc_FamilyReturn_familySelect(Val, TagIn) -> {EncBytes,EncLen} = 'enc_FamilyReturn_familySelect_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_FamilyReturn_familySelect_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_FamilyReturn_familySelect_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_object_identifier(H, [<<6>>]), 'enc_FamilyReturn_familySelect_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_FamilyReturn(Tlv) -> dec_FamilyReturn(Tlv, [16]). dec_FamilyReturn(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute memberSelect(1) with type ENUMERATED %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = case decode_integer(V1, [10]) of 1 -> contributingEntriesOnly; 2 -> participatingEntriesOnly; 3 -> compoundEntry; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute familySelect(2) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{16,V2}|TempTlv3] -> {'dec_FamilyReturn_familySelect'(V2, []), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'FamilyReturn',Term1,Term2}, Res1. 'dec_FamilyReturn_familySelect'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_object_identifier(V1, [6]) || V1 <- Tlv1]. %%================================ %% FamilyEntries %%================================ enc_FamilyEntries(Val) -> enc_FamilyEntries(Val, [<<48>>]). enc_FamilyEntries(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute family-class(1) with type OBJECT IDENTIFIER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]), %%------------------------------------------------- %% attribute familyEntries(2) with type SEQUENCE OF %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_FamilyEntries_familyEntries'(Cindex2, [<<48>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% FamilyEntries_familyEntries %%================================ enc_FamilyEntries_familyEntries(Val, TagIn) -> {EncBytes,EncLen} = 'enc_FamilyEntries_familyEntries_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_FamilyEntries_familyEntries_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_FamilyEntries_familyEntries_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_FamilyEntry'(H, [<<48>>]), 'enc_FamilyEntries_familyEntries_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_FamilyEntries(Tlv) -> dec_FamilyEntries(Tlv, [16]). dec_FamilyEntries(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute family-class(1) with type OBJECT IDENTIFIER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_object_identifier(V1, [6]), %%------------------------------------------------- %% attribute familyEntries(2) with type SEQUENCE OF %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_FamilyEntries_familyEntries'(V2, [16]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'FamilyEntries',Term1,Term2}, Res1. 'dec_FamilyEntries_familyEntries'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_FamilyEntry'(V1, [16]) || V1 <- Tlv1]. %%================================ %% FamilyEntry %%================================ enc_FamilyEntry(Val) -> enc_FamilyEntry(Val, [<<48>>]). enc_FamilyEntry(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute rdn(1) External InformationFramework:RelativeDistinguishedName %%------------------------------------------------- {EncBytes1,EncLen1} = 'InformationFramework':'enc_RelativeDistinguishedName'(Cindex1, [<<49>>]), %%------------------------------------------------- %% attribute information(2) with type SEQUENCE OF %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_FamilyEntry_information'(Cindex2, [<<48>>]), %%------------------------------------------------- %% attribute family-info(3) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_FamilyEntry_family-info'(Cindex3, [<<48>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% FamilyEntry_information %%================================ enc_FamilyEntry_information(Val, TagIn) -> {EncBytes,EncLen} = 'enc_FamilyEntry_information_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_FamilyEntry_information_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_FamilyEntry_information_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_FamilyEntry_information_SEQOF'(H, []), 'enc_FamilyEntry_information_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% FamilyEntry_information_SEQOF %%================================ enc_FamilyEntry_information_SEQOF(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of attributeType -> encode_object_identifier(element(2,Val), [<<6>>]); attribute -> 'InformationFramework':'enc_Attribute'(element(2,Val), [<<48>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% FamilyEntry_family-info %%================================ 'enc_FamilyEntry_family-info'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_FamilyEntry_family-info_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_FamilyEntry_family-info_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_FamilyEntry_family-info_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_FamilyEntries'(H, [<<48>>]), 'enc_FamilyEntry_family-info_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_FamilyEntry(Tlv) -> dec_FamilyEntry(Tlv, [16]). dec_FamilyEntry(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute rdn(1) External InformationFramework:RelativeDistinguishedName %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'InformationFramework':'dec_RelativeDistinguishedName'(V1, [17]), %%------------------------------------------------- %% attribute information(2) with type SEQUENCE OF %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_FamilyEntry_information'(V2, [16]), %%------------------------------------------------- %% attribute family-info(3) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{16,V3}|TempTlv4] -> {'dec_FamilyEntry_family-info'(V3, []), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'FamilyEntry',Term1,Term2,Term3}, Res1. 'dec_FamilyEntry_information'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_FamilyEntry_information_SEQOF'(V1, []) || V1 <- Tlv1]. 'dec_FamilyEntry_information_SEQOF'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'attributeType' {6, V1} -> {attributeType, decode_object_identifier(V1, [])}; %% 'attribute' {16, V1} -> {attribute, 'InformationFramework':'dec_Attribute'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_FamilyEntry_family-info'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_FamilyEntries'(V1, [16]) || V1 <- Tlv1]. %%================================ %% EntryInformation %%================================ enc_EntryInformation(Val) -> enc_EntryInformation(Val, [<<48>>]). enc_EntryInformation(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5} = Val, %%------------------------------------------------- %% attribute name(1) External InformationFramework:Name %%------------------------------------------------- {EncBytes1,EncLen1} = 'InformationFramework':'enc_Name'(Cindex1, []), %%------------------------------------------------- %% attribute fromEntry(2) with type BOOLEAN DEFAULT = true %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex2 =:= true -> {<<>>,0}; _ -> encode_boolean(Cindex2, [<<1>>]) end, %%------------------------------------------------- %% attribute information(3) with type SET OF OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_EntryInformation_information'(Cindex3, [<<49>>]) end, %%------------------------------------------------- %% attribute incompleteEntry(4) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex4 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex4, [<<1>>,<<163>>]) end, %%------------------------------------------------- %% attribute partialNameResolution(5) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex5 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex5, [<<1>>,<<164>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% EntryInformation_information %%================================ enc_EntryInformation_information(Val, TagIn) -> {EncBytes,EncLen} = 'enc_EntryInformation_information_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_EntryInformation_information_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_EntryInformation_information_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_EntryInformation_information_SETOF'(H, []), 'enc_EntryInformation_information_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% EntryInformation_information_SETOF %%================================ enc_EntryInformation_information_SETOF(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of attributeType -> encode_object_identifier(element(2,Val), [<<6>>]); attribute -> 'InformationFramework':'enc_Attribute'(element(2,Val), [<<48>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). dec_EntryInformation(Tlv) -> dec_EntryInformation(Tlv, [16]). dec_EntryInformation(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute name(1) External InformationFramework:Name %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'InformationFramework':'dec_Name'(V1, []), %%------------------------------------------------- %% attribute fromEntry(2) with type BOOLEAN DEFAULT = true %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{1,V2}|TempTlv3] -> {decode_boolean(V2, []), TempTlv3}; _ -> {true,Tlv2} end, %%------------------------------------------------- %% attribute information(3) with type SET OF OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{17,V3}|TempTlv4] -> {'dec_EntryInformation_information'(V3, []), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute incompleteEntry(4) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {decode_boolean(V4, [1]), TempTlv5}; _ -> {false,Tlv4} end, %%------------------------------------------------- %% attribute partialNameResolution(5) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term5,Tlv6} = case Tlv5 of [{131076,V5}|TempTlv6] -> {decode_boolean(V5, [1]), TempTlv6}; _ -> {false,Tlv5} end, case Tlv6 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowed end, Res1 = {'EntryInformation',Term1,Term2,Term3,Term4,Term5}, Res1. 'dec_EntryInformation_information'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_EntryInformation_information_SETOF'(V1, []) || V1 <- Tlv1]. 'dec_EntryInformation_information_SETOF'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'attributeType' {6, V1} -> {attributeType, decode_object_identifier(V1, [])}; %% 'attribute' {16, V1} -> {attribute, 'InformationFramework':'dec_Attribute'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . %%================================ %% Filter %%================================ enc_Filter(Val) -> enc_Filter(Val, []). enc_Filter(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of item -> 'enc_FilterItem'(element(2,Val), [<<160>>]); 'and' -> 'enc_Filter_and'(element(2,Val), [<<49>>,<<161>>]); 'or' -> 'enc_Filter_or'(element(2,Val), [<<49>>,<<162>>]); 'not' -> 'enc_Filter'(element(2,Val), [<<163>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% Filter_and %%================================ enc_Filter_and(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Filter_and_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Filter_and_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Filter_and_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Filter'(H, []), 'enc_Filter_and_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Filter_or %%================================ enc_Filter_or(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Filter_or_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Filter_or_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Filter_or_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Filter'(H, []), 'enc_Filter_or_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Filter(Tlv) -> dec_Filter(Tlv, []). dec_Filter(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'item' {131072, V1} -> {item, 'dec_FilterItem'(V1, [])}; %% 'and' {131073, V1} -> {'and', 'dec_Filter_and'(V1, [17])}; %% 'or' {131074, V1} -> {'or', 'dec_Filter_or'(V1, [17])}; %% 'not' {131075, V1} -> {'not', 'dec_Filter'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_Filter_and'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Filter'(V1, []) || V1 <- Tlv1]. 'dec_Filter_or'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Filter'(V1, []) || V1 <- Tlv1]. %%================================ %% FilterItem %%================================ enc_FilterItem(Val) -> enc_FilterItem(Val, []). enc_FilterItem(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of equality -> 'InformationFramework':'enc_AttributeValueAssertion'(element(2,Val), [<<48>>,<<160>>]); substrings -> 'enc_FilterItem_substrings'(element(2,Val), [<<48>>,<<161>>]); greaterOrEqual -> 'InformationFramework':'enc_AttributeValueAssertion'(element(2,Val), [<<48>>,<<162>>]); lessOrEqual -> 'InformationFramework':'enc_AttributeValueAssertion'(element(2,Val), [<<48>>,<<163>>]); present -> encode_object_identifier(element(2,Val), [<<6>>,<<164>>]); approximateMatch -> 'InformationFramework':'enc_AttributeValueAssertion'(element(2,Val), [<<48>>,<<165>>]); extensibleMatch -> 'enc_MatchingRuleAssertion'(element(2,Val), [<<48>>,<<166>>]); contextPresent -> 'InformationFramework':'enc_AttributeTypeAssertion'(element(2,Val), [<<48>>,<<167>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% FilterItem_substrings %%================================ enc_FilterItem_substrings(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, Objtype = 'InformationFramework':'getenc_SupportedAttributes'( Cindex1), %%------------------------------------------------- %% attribute type(1) with type OBJECT IDENTIFIER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]), %%------------------------------------------------- %% attribute strings(2) with type SEQUENCE OF %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_FilterItem_substrings_strings'(Cindex2, [<<48>>], Objtype), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% FilterItem_substrings_strings %%================================ enc_FilterItem_substrings_strings(Val, TagIn, ObjFun) -> {EncBytes,EncLen} = 'enc_FilterItem_substrings_strings_components'(Val, ObjFun,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_FilterItem_substrings_strings_components'([], _, AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_FilterItem_substrings_strings_components'([H|T], ObjFun,AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_FilterItem_substrings_strings_SEQOF'(H, [], ObjFun), 'enc_FilterItem_substrings_strings_components'(T, ObjFun,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% FilterItem_substrings_strings_SEQOF %%================================ enc_FilterItem_substrings_strings_SEQOF(Val, TagIn, ObjFun) -> {EncBytes,EncLen} = case element(1,Val) of initial -> {TmpBytes1, _} = ObjFun('Type', element(2,Val), []), {EncBytes1,EncLen1} = encode_open_type(TmpBytes1, [<<160>>]) , {EncBytes1, EncLen1}; any -> {TmpBytes2, _} = ObjFun('Type', element(2,Val), []), {EncBytes2,EncLen2} = encode_open_type(TmpBytes2, [<<161>>]) , {EncBytes2, EncLen2}; final -> {TmpBytes3, _} = ObjFun('Type', element(2,Val), []), {EncBytes3,EncLen3} = encode_open_type(TmpBytes3, [<<162>>]) , {EncBytes3, EncLen3}; control -> 'InformationFramework':'enc_Attribute'(element(2,Val), [<<48>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). dec_FilterItem(Tlv) -> dec_FilterItem(Tlv, []). dec_FilterItem(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'equality' {131072, V1} -> {equality, 'InformationFramework':'dec_AttributeValueAssertion'(V1, [16])}; %% 'substrings' {131073, V1} -> {substrings, 'dec_FilterItem_substrings'(V1, [16])}; %% 'greaterOrEqual' {131074, V1} -> {greaterOrEqual, 'InformationFramework':'dec_AttributeValueAssertion'(V1, [16])}; %% 'lessOrEqual' {131075, V1} -> {lessOrEqual, 'InformationFramework':'dec_AttributeValueAssertion'(V1, [16])}; %% 'present' {131076, V1} -> {present, decode_object_identifier(V1, [6])}; %% 'approximateMatch' {131077, V1} -> {approximateMatch, 'InformationFramework':'dec_AttributeValueAssertion'(V1, [16])}; %% 'extensibleMatch' {131078, V1} -> {extensibleMatch, 'dec_MatchingRuleAssertion'(V1, [16])}; %% 'contextPresent' {131079, V1} -> {contextPresent, 'InformationFramework':'dec_AttributeTypeAssertion'(V1, [16])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_FilterItem_substrings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute type(1) with type OBJECT IDENTIFIER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_object_identifier(V1, [6]), ObjFun = 'InformationFramework':'getdec_SupportedAttributes'(Term1), %%------------------------------------------------- %% attribute strings(2) with type SEQUENCE OF %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_FilterItem_substrings_strings'(V2, [16], ObjFun), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'FilterItem_substrings',Term1,Term2}, Res1. 'dec_FilterItem_substrings_strings'(Tlv, TagIn, ObjFun) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_FilterItem_substrings_strings_SEQOF'(V1, [], ObjFun) || V1 <- Tlv1]. 'dec_FilterItem_substrings_strings_SEQOF'(Tlv, TagIn, ObjFun) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'initial' {131072, V1} -> {initial, begin Tmptlv1 = decode_open_type(V1, []), case (catch ObjFun('Type', Tmptlv1, [])) of {'EXIT',Reason1} -> exit({'Type not compatible with table constraint', Reason1}); Tmpterm1 -> Tmpterm1 end end }; %% 'any' {131073, V1} -> {any, begin Tmptlv2 = decode_open_type(V1, []), case (catch ObjFun('Type', Tmptlv2, [])) of {'EXIT',Reason2} -> exit({'Type not compatible with table constraint', Reason2}); Tmpterm2 -> Tmpterm2 end end }; %% 'final' {131074, V1} -> {final, begin Tmptlv3 = decode_open_type(V1, []), case (catch ObjFun('Type', Tmptlv3, [])) of {'EXIT',Reason3} -> exit({'Type not compatible with table constraint', Reason3}); Tmpterm3 -> Tmpterm3 end end }; %% 'control' {16, V1} -> {control, 'InformationFramework':'dec_Attribute'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . %%================================ %% MatchingRuleAssertion %%================================ enc_MatchingRuleAssertion(Val) -> enc_MatchingRuleAssertion(Val, [<<48>>]). enc_MatchingRuleAssertion(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute matchingRule(1) with type SET OF %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_MatchingRuleAssertion_matchingRule'(Cindex1, [<<49>>,<<161>>]), %%------------------------------------------------- %% attribute type(2) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_object_identifier(Cindex2, [<<6>>,<<162>>]) end, %%------------------------------------------------- %% attribute matchValue(3) with type ASN1_OPEN_TYPE %%------------------------------------------------- {EncBytes3,EncLen3} = encode_open_type(Cindex3, [<<163>>]), %%------------------------------------------------- %% attribute dnAttributes(4) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex4 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex4, [<<1>>,<<164>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% MatchingRuleAssertion_matchingRule %%================================ enc_MatchingRuleAssertion_matchingRule(Val, TagIn) -> {EncBytes,EncLen} = 'enc_MatchingRuleAssertion_matchingRule_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_MatchingRuleAssertion_matchingRule_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_MatchingRuleAssertion_matchingRule_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_object_identifier(H, [<<6>>]), 'enc_MatchingRuleAssertion_matchingRule_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_MatchingRuleAssertion(Tlv) -> dec_MatchingRuleAssertion(Tlv, [16]). dec_MatchingRuleAssertion(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute matchingRule(1) with type SET OF %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_MatchingRuleAssertion_matchingRule'(V1, [131073,17]), %%------------------------------------------------- %% attribute type(2) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131074,V2}|TempTlv3] -> {decode_object_identifier(V2, [6]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute matchValue(3) with type ASN1_OPEN_TYPE %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_open_type_as_binary(V3, [131075]), %%------------------------------------------------- %% attribute dnAttributes(4) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131076,V4}|TempTlv5] -> {decode_boolean(V4, [1]), TempTlv5}; _ -> {false,Tlv4} end, case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'MatchingRuleAssertion',Term1,Term2,Term3,Term4}, Res1. 'dec_MatchingRuleAssertion_matchingRule'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_object_identifier(V1, [6]) || V1 <- Tlv1]. %%================================ %% PagedResultsRequest %%================================ enc_PagedResultsRequest(Val) -> enc_PagedResultsRequest(Val, []). enc_PagedResultsRequest(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of newRequest -> 'enc_PagedResultsRequest_newRequest'(element(2,Val), [<<48>>]); queryReference -> encode_restricted_string(element(2,Val), [<<4>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% PagedResultsRequest_newRequest %%================================ enc_PagedResultsRequest_newRequest(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute pageSize(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>]), %%------------------------------------------------- %% attribute sortKeys(2) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_PagedResultsRequest_newRequest_sortKeys'(Cindex2, [<<48>>]) end, %%------------------------------------------------- %% attribute reverse(3) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex3 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex3, [<<1>>,<<161>>]) end, %%------------------------------------------------- %% attribute unmerged(4) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex4 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex4, [<<1>>,<<162>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% PagedResultsRequest_newRequest_sortKeys %%================================ enc_PagedResultsRequest_newRequest_sortKeys(Val, TagIn) -> {EncBytes,EncLen} = 'enc_PagedResultsRequest_newRequest_sortKeys_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_PagedResultsRequest_newRequest_sortKeys_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_PagedResultsRequest_newRequest_sortKeys_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_SortKey'(H, [<<48>>]), 'enc_PagedResultsRequest_newRequest_sortKeys_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_PagedResultsRequest(Tlv) -> dec_PagedResultsRequest(Tlv, []). dec_PagedResultsRequest(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'newRequest' {16, V1} -> {newRequest, 'dec_PagedResultsRequest_newRequest'(V1, [])}; %% 'queryReference' {4, V1} -> {queryReference, decode_octet_string(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_PagedResultsRequest_newRequest'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pageSize(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_integer(V1, [2]), %%------------------------------------------------- %% attribute sortKeys(2) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{16,V2}|TempTlv3] -> {'dec_PagedResultsRequest_newRequest_sortKeys'(V2, []), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute reverse(3) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131073,V3}|TempTlv4] -> {decode_boolean(V3, [1]), TempTlv4}; _ -> {false,Tlv3} end, %%------------------------------------------------- %% attribute unmerged(4) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131074,V4}|TempTlv5] -> {decode_boolean(V4, [1]), TempTlv5}; _ -> {false,Tlv4} end, case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'PagedResultsRequest_newRequest',Term1,Term2,Term3,Term4}, Res1. 'dec_PagedResultsRequest_newRequest_sortKeys'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_SortKey'(V1, [16]) || V1 <- Tlv1]. %%================================ %% SortKey %%================================ enc_SortKey(Val) -> enc_SortKey(Val, [<<48>>]). enc_SortKey(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute type(1) with type OBJECT IDENTIFIER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]), %%------------------------------------------------- %% attribute orderingRule(2) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_object_identifier(Cindex2, [<<6>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_SortKey(Tlv) -> dec_SortKey(Tlv, [16]). dec_SortKey(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute type(1) with type OBJECT IDENTIFIER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_object_identifier(V1, [6]), %%------------------------------------------------- %% attribute orderingRule(2) with type OBJECT IDENTIFIER OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{6,V2}|TempTlv3] -> {decode_object_identifier(V2, []), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'SortKey',Term1,Term2}, Res1. %%================================ %% SecurityParameters %%================================ enc_SecurityParameters(Val) -> enc_SecurityParameters(Val, [<<49>>]). enc_SecurityParameters(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10} = Val, %%------------------------------------------------- %% attribute certification-path(1) External AuthenticationFramework:CertificationPath OPTIONAL %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> 'AuthenticationFramework':'enc_CertificationPath'(Cindex1, [<<48>>,<<160>>]) end, %%------------------------------------------------- %% attribute name(2) External InformationFramework:DistinguishedName OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'InformationFramework':'enc_DistinguishedName'(Cindex2, [<<48>>,<<161>>]) end, %%------------------------------------------------- %% attribute time(3) External DirectoryAbstractService:Time OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Time'(Cindex3, [<<162>>]) end, %%------------------------------------------------- %% attribute random(4) with type BIT STRING OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_unnamed_bit_string(Cindex4, [<<3>>,<<163>>]) end, %%------------------------------------------------- %% attribute target(5) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex5, [{none,0},{signed,1},{encrypted,2},{'signed-encrypted',3}], [<<2>>,<<164>>]) end, %%------------------------------------------------- %% attribute response(6) with type BIT STRING OPTIONAL %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_unnamed_bit_string(Cindex6, [<<3>>,<<165>>]) end, %%------------------------------------------------- %% attribute operationCode(7) External DirectoryAbstractService:Code OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Code'(Cindex7, [<<166>>]) end, %%------------------------------------------------- %% attribute attributeCertificationPath(8) External AuthenticationFramework:AttributeCertificationPath OPTIONAL %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> 'AuthenticationFramework':'enc_AttributeCertificationPath'(Cindex8, [<<48>>,<<167>>]) end, %%------------------------------------------------- %% attribute errorProtection(9) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex9, [{none,0},{signed,1},{encrypted,2},{'signed-encrypted',3}], [<<2>>,<<168>>]) end, %%------------------------------------------------- %% attribute errorCode(10) External DirectoryAbstractService:Code OPTIONAL %%------------------------------------------------- {EncBytes10,EncLen10} = case Cindex10 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Code'(Cindex10, [<<169>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_SecurityParameters(Tlv) -> dec_SecurityParameters(Tlv, [17]). dec_SecurityParameters(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), SetFun = fun(FunTlv) -> case FunTlv of %certification-path TTlv = {131072,_} -> {1, TTlv}; %name TTlv = {131073,_} -> {2, TTlv}; %time TTlv = {131074,_} -> {3, TTlv}; %random TTlv = {131075,_} -> {4, TTlv}; %target TTlv = {131076,_} -> {5, TTlv}; %response TTlv = {131077,_} -> {6, TTlv}; %operationCode TTlv = {131078,_} -> {7, TTlv}; %attributeCertificationPath TTlv = {131079,_} -> {8, TTlv}; %errorProtection TTlv = {131080,_} -> {9, TTlv}; %errorCode TTlv = {131081,_} -> {10, TTlv}; Else -> {11, Else} end end, PositionList = [SetFun(TempTlv)|| TempTlv <- Tlv1], Tlv2 = [Stlv || {_,Stlv} <- lists:sort(PositionList)], %%------------------------------------------------- %% attribute certification-path(1) External AuthenticationFramework:CertificationPath OPTIONAL %%------------------------------------------------- {Term1,Tlv3} = case Tlv2 of [{131072,V1}|TempTlv3] -> {'AuthenticationFramework':'dec_CertificationPath'(V1, [16]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute name(2) External InformationFramework:DistinguishedName OPTIONAL %%------------------------------------------------- {Term2,Tlv4} = case Tlv3 of [{131073,V2}|TempTlv4] -> {'InformationFramework':'dec_DistinguishedName'(V2, [16]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute time(3) External DirectoryAbstractService:Time OPTIONAL %%------------------------------------------------- {Term3,Tlv5} = case Tlv4 of [{131074,V3}|TempTlv5] -> {'dec_Time'(V3, []), TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute random(4) with type BIT STRING OPTIONAL %%------------------------------------------------- {Term4,Tlv6} = case Tlv5 of [{131075,V4}|TempTlv6] -> {decode_native_bit_string(V4, [3]), TempTlv6}; _ -> { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- %% attribute target(5) with type INTEGER OPTIONAL %%------------------------------------------------- {Term5,Tlv7} = case Tlv6 of [{131076,V5}|TempTlv7] -> {begin Val1 = decode_integer(V5, [2]), number2name(Val1, [{none,0},{signed,1},{encrypted,2},{'signed-encrypted',3}]) end , TempTlv7}; _ -> { asn1_NOVALUE, Tlv6} end, %%------------------------------------------------- %% attribute response(6) with type BIT STRING OPTIONAL %%------------------------------------------------- {Term6,Tlv8} = case Tlv7 of [{131077,V6}|TempTlv8] -> {decode_native_bit_string(V6, [3]), TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- %% attribute operationCode(7) External DirectoryAbstractService:Code OPTIONAL %%------------------------------------------------- {Term7,Tlv9} = case Tlv8 of [{131078,V7}|TempTlv9] -> {'dec_Code'(V7, []), TempTlv9}; _ -> { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- %% attribute attributeCertificationPath(8) External AuthenticationFramework:AttributeCertificationPath OPTIONAL %%------------------------------------------------- {Term8,Tlv10} = case Tlv9 of [{131079,V8}|TempTlv10] -> {'AuthenticationFramework':'dec_AttributeCertificationPath'(V8, [16]), TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- %% attribute errorProtection(9) with type INTEGER OPTIONAL %%------------------------------------------------- {Term9,Tlv11} = case Tlv10 of [{131080,V9}|TempTlv11] -> {begin Val2 = decode_integer(V9, [2]), number2name(Val2, [{none,0},{signed,1},{encrypted,2},{'signed-encrypted',3}]) end , TempTlv11}; _ -> { asn1_NOVALUE, Tlv10} end, %%------------------------------------------------- %% attribute errorCode(10) External DirectoryAbstractService:Code OPTIONAL %%------------------------------------------------- {Term10,Tlv12} = case Tlv11 of [{131081,V10}|TempTlv12] -> {'dec_Code'(V10, []), TempTlv12}; _ -> { asn1_NOVALUE, Tlv11} end, case Tlv12 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv12}}}) % extra fields not allowed end, Res1 = {'SecurityParameters',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10}, Res1. %%================================ %% HierarchySelections %%================================ enc_HierarchySelections(Val) -> enc_HierarchySelections(Val, [<<3>>]). enc_HierarchySelections(Val, TagIn) -> encode_named_bit_string(Val, [{self,0},{children,1},{parent,2},{hierarchy,3},{top,4},{subtree,5},{siblings,6},{siblingChildren,7},{siblingSubtree,8},{all,9}], TagIn). dec_HierarchySelections(Tlv) -> dec_HierarchySelections(Tlv, [3]). dec_HierarchySelections(Tlv, TagIn) -> decode_named_bit_string(Tlv, [{self,0},{children,1},{parent,2},{hierarchy,3},{top,4},{subtree,5},{siblings,6},{siblingChildren,7},{siblingSubtree,8},{all,9}], TagIn). %%================================ %% SearchControlOptions %%================================ enc_SearchControlOptions(Val) -> enc_SearchControlOptions(Val, [<<3>>]). enc_SearchControlOptions(Val, TagIn) -> encode_named_bit_string(Val, [{searchAliases,0},{matchedValuesOnly,1},{checkOverspecified,2},{performExactly,3},{includeAllAreas,4},{noSystemRelaxation,5},{dnAttribute,6},{matchOnResidualName,7},{entryCount,8},{useSubset,9},{separateFamilyMembers,10},{searchFamily,11}], TagIn). dec_SearchControlOptions(Tlv) -> dec_SearchControlOptions(Tlv, [3]). dec_SearchControlOptions(Tlv, TagIn) -> decode_named_bit_string(Tlv, [{searchAliases,0},{matchedValuesOnly,1},{checkOverspecified,2},{performExactly,3},{includeAllAreas,4},{noSystemRelaxation,5},{dnAttribute,6},{matchOnResidualName,7},{entryCount,8},{useSubset,9},{separateFamilyMembers,10},{searchFamily,11}], TagIn). %%================================ %% ProtectionRequest %%================================ enc_ProtectionRequest(Val) -> enc_ProtectionRequest(Val, [<<2>>]). enc_ProtectionRequest(Val, TagIn) -> encode_integer(Val, [{none,0},{signed,1},{encrypted,2},{'signed-encrypted',3}], TagIn). dec_ProtectionRequest(Tlv) -> dec_ProtectionRequest(Tlv, [2]). dec_ProtectionRequest(Tlv, TagIn) -> begin Val1 = decode_integer(Tlv, TagIn), number2name(Val1, [{none,0},{signed,1},{encrypted,2},{'signed-encrypted',3}]) end . %%================================ %% Time %%================================ enc_Time(Val) -> enc_Time(Val, []). enc_Time(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of utcTime -> encode_restricted_string(element(2,Val), [<<23>>]); generalizedTime -> encode_restricted_string(element(2,Val), [<<24>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). dec_Time(Tlv) -> dec_Time(Tlv, []). dec_Time(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'utcTime' {23, V1} -> {utcTime, begin binary_to_list(decode_restricted_string(V1, [])) end }; %% 'generalizedTime' {24, V1} -> {generalizedTime, begin binary_to_list(decode_restricted_string(V1, [])) end }; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . %%================================ %% ErrorProtectionRequest %%================================ enc_ErrorProtectionRequest(Val) -> enc_ErrorProtectionRequest(Val, [<<2>>]). enc_ErrorProtectionRequest(Val, TagIn) -> encode_integer(Val, [{none,0},{signed,1},{encrypted,2},{'signed-encrypted',3}], TagIn). dec_ErrorProtectionRequest(Tlv) -> dec_ErrorProtectionRequest(Tlv, [2]). dec_ErrorProtectionRequest(Tlv, TagIn) -> begin Val1 = decode_integer(Tlv, TagIn), number2name(Val1, [{none,0},{signed,1},{encrypted,2},{'signed-encrypted',3}]) 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_boolean(Tlv, TagIn) -> Val = match_tags(Tlv, TagIn), case Val of <<0:8>> -> false; <<_:8>> -> true; _ -> exit({error, {asn1, {decode_boolean, Val}}}) end. 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_null(Tlv, Tags) -> Val = match_tags(Tlv, Tags), case Val of <<>> -> 'NULL'; _ -> exit({error, {asn1, {decode_null, 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_boolean(true, TagIn) -> encode_tags(TagIn, [255], 1); encode_boolean(false, TagIn) -> encode_tags(TagIn, [0], 1); encode_boolean(X, _) -> exit({error, {asn1, {encode_boolean, X}}}). 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([], _NamedBitList, TagIn) -> encode_unnamed_bit_string(<<>>, TagIn); encode_named_bit_string(Bits, _NamedBitList, TagIn) when is_bitstring(Bits) -> encode_unnamed_bit_string(Bits, TagIn). encode_null(_Val, TagIn) -> encode_tags(TagIn, [], 0). 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. unused_bitlist([], Trail, Ack) -> {Trail + 1, Ack}; unused_bitlist([Bit | Rest], Trail, Ack) -> unused_bitlist(Rest, Trail - 1, Bit bsl Trail bor Ack).