Packages

MAIL Simple Message Delivery Protocol

Current section

Files

Jump to
mail420 src IPMSFileTransferBodyPartType.erl
Raw

src/IPMSFileTransferBodyPartType.erl

%% Generated by the Erlang ASN.1 BER compiler. Version: 5.1
%% Purpose: Encoding and decoding of the types in IPMSFileTransferBodyPartType.
-module('IPMSFileTransferBodyPartType').
-compile(nowarn_unused_vars).
-dialyzer(no_improper_lists).
-dialyzer(no_match).
-include("IPMSFileTransferBodyPartType.hrl").
-asn1_info([{vsn,'5.1'},
{module,'IPMSFileTransferBodyPartType'},
{options,[warnings,ber,errors,
{cwd,"/Users/maxim/depot/synrc/mail/priv/mhs"},
{outdir,"/Users/maxim/depot/synrc/mail/priv/mhs"},
{i,"."},
{i,"/Users/maxim/depot/synrc/mail/priv/mhs"}]}]).
-export([encoding_rule/0,maps/0,bit_string_format/0,
legacy_erlang_types/0]).
-export(['dialyzer-suppressions'/1]).
-export([
enc_FileTransferParameters/2,
enc_FileTransferData/2,
enc_RelatedStoredFile/2,
enc_FileIdentifier/2,
enc_PathnameandVersion/2,
enc_CrossReference/2,
enc_MessageReference/2,
enc_Relationship/2,
enc_ExplicitRelationship/2,
enc_ContentsTypeParameter/2,
'enc_Contents-Type-Attribute'/2,
'enc_Document-Type-Name'/2,
'enc_Constraint-Set-Name'/2,
'enc_Abstract-Syntax-Name'/2,
enc_EnvironmentParameter/2,
enc_GeneralIdentifier/2,
enc_CompressionParameter/2,
enc_FileAttributes/2,
'enc_Pathname-Attribute'/2,
'enc_Account-Attribute'/2,
enc_Account/2,
'enc_User-Identity-Attribute'/2,
'enc_User-Identity'/2,
'enc_Access-Control-Attribute'/2,
'enc_Access-Control-Element'/2,
'enc_Access-Request'/2,
'enc_Access-Passwords'/2,
enc_Password/2,
'enc_Pass-Passwords'/2,
'enc_Application-Entity-Title'/2,
enc_EXTERNAL/2
]).
-export([
dec_FileTransferParameters/2,
dec_FileTransferData/2,
dec_RelatedStoredFile/2,
dec_FileIdentifier/2,
dec_PathnameandVersion/2,
dec_CrossReference/2,
dec_MessageReference/2,
dec_Relationship/2,
dec_ExplicitRelationship/2,
dec_ContentsTypeParameter/2,
'dec_Contents-Type-Attribute'/2,
'dec_Document-Type-Name'/2,
'dec_Constraint-Set-Name'/2,
'dec_Abstract-Syntax-Name'/2,
dec_EnvironmentParameter/2,
dec_GeneralIdentifier/2,
dec_CompressionParameter/2,
dec_FileAttributes/2,
'dec_Pathname-Attribute'/2,
'dec_Account-Attribute'/2,
dec_Account/2,
'dec_User-Identity-Attribute'/2,
'dec_User-Identity'/2,
'dec_Access-Control-Attribute'/2,
'dec_Access-Control-Element'/2,
'dec_Access-Request'/2,
'dec_Access-Passwords'/2,
dec_Password/2,
'dec_Pass-Passwords'/2,
'dec_Application-Entity-Title'/2,
dec_EXTERNAL/2
]).
-export([
'enc_file-transfer-body-part'/3,
'enc_file-transfer-body-part_parameters'/3,
'enc_file-transfer-body-part_data'/3
]).
-export([
'dec_file-transfer-body-part'/3,
'dec_file-transfer-body-part_parameters'/3,
'dec_file-transfer-body-part_data'/3
]).
-export([
getenc_CompressionAlgorithmTable/1
]).
-export([
getdec_CompressionAlgorithmTable/1
]).
-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('FileTransferParameters', Data) -> enc_FileTransferParameters(Data);
encode_disp('FileTransferData', Data) -> enc_FileTransferData(Data);
encode_disp('RelatedStoredFile', Data) -> enc_RelatedStoredFile(Data);
encode_disp('FileIdentifier', Data) -> enc_FileIdentifier(Data);
encode_disp('PathnameandVersion', Data) -> enc_PathnameandVersion(Data);
encode_disp('CrossReference', Data) -> enc_CrossReference(Data);
encode_disp('MessageReference', Data) -> enc_MessageReference(Data);
encode_disp('Relationship', Data) -> enc_Relationship(Data);
encode_disp('ExplicitRelationship', Data) -> enc_ExplicitRelationship(Data);
encode_disp('ContentsTypeParameter', Data) -> enc_ContentsTypeParameter(Data);
encode_disp('Contents-Type-Attribute', Data) -> 'enc_Contents-Type-Attribute'(Data);
encode_disp('Document-Type-Name', Data) -> 'enc_Document-Type-Name'(Data);
encode_disp('Constraint-Set-Name', Data) -> 'enc_Constraint-Set-Name'(Data);
encode_disp('Abstract-Syntax-Name', Data) -> 'enc_Abstract-Syntax-Name'(Data);
encode_disp('EnvironmentParameter', Data) -> enc_EnvironmentParameter(Data);
encode_disp('GeneralIdentifier', Data) -> enc_GeneralIdentifier(Data);
encode_disp('CompressionParameter', Data) -> enc_CompressionParameter(Data);
encode_disp('FileAttributes', Data) -> enc_FileAttributes(Data);
encode_disp('Pathname-Attribute', Data) -> 'enc_Pathname-Attribute'(Data);
encode_disp('Account-Attribute', Data) -> 'enc_Account-Attribute'(Data);
encode_disp('Account', Data) -> enc_Account(Data);
encode_disp('User-Identity-Attribute', Data) -> 'enc_User-Identity-Attribute'(Data);
encode_disp('User-Identity', Data) -> 'enc_User-Identity'(Data);
encode_disp('Access-Control-Attribute', Data) -> 'enc_Access-Control-Attribute'(Data);
encode_disp('Access-Control-Element', Data) -> 'enc_Access-Control-Element'(Data);
encode_disp('Access-Request', Data) -> 'enc_Access-Request'(Data);
encode_disp('Access-Passwords', Data) -> 'enc_Access-Passwords'(Data);
encode_disp('Password', Data) -> enc_Password(Data);
encode_disp('Pass-Passwords', Data) -> 'enc_Pass-Passwords'(Data);
encode_disp('Application-Entity-Title', Data) -> 'enc_Application-Entity-Title'(Data);
encode_disp('EXTERNAL', Data) -> enc_EXTERNAL(Data);
encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}).
decode_disp('FileTransferParameters', Data) -> dec_FileTransferParameters(Data);
decode_disp('FileTransferData', Data) -> dec_FileTransferData(Data);
decode_disp('RelatedStoredFile', Data) -> dec_RelatedStoredFile(Data);
decode_disp('FileIdentifier', Data) -> dec_FileIdentifier(Data);
decode_disp('PathnameandVersion', Data) -> dec_PathnameandVersion(Data);
decode_disp('CrossReference', Data) -> dec_CrossReference(Data);
decode_disp('MessageReference', Data) -> dec_MessageReference(Data);
decode_disp('Relationship', Data) -> dec_Relationship(Data);
decode_disp('ExplicitRelationship', Data) -> dec_ExplicitRelationship(Data);
decode_disp('ContentsTypeParameter', Data) -> dec_ContentsTypeParameter(Data);
decode_disp('Contents-Type-Attribute', Data) -> 'dec_Contents-Type-Attribute'(Data);
decode_disp('Document-Type-Name', Data) -> 'dec_Document-Type-Name'(Data);
decode_disp('Constraint-Set-Name', Data) -> 'dec_Constraint-Set-Name'(Data);
decode_disp('Abstract-Syntax-Name', Data) -> 'dec_Abstract-Syntax-Name'(Data);
decode_disp('EnvironmentParameter', Data) -> dec_EnvironmentParameter(Data);
decode_disp('GeneralIdentifier', Data) -> dec_GeneralIdentifier(Data);
decode_disp('CompressionParameter', Data) -> dec_CompressionParameter(Data);
decode_disp('FileAttributes', Data) -> dec_FileAttributes(Data);
decode_disp('Pathname-Attribute', Data) -> 'dec_Pathname-Attribute'(Data);
decode_disp('Account-Attribute', Data) -> 'dec_Account-Attribute'(Data);
decode_disp('Account', Data) -> dec_Account(Data);
decode_disp('User-Identity-Attribute', Data) -> 'dec_User-Identity-Attribute'(Data);
decode_disp('User-Identity', Data) -> 'dec_User-Identity'(Data);
decode_disp('Access-Control-Attribute', Data) -> 'dec_Access-Control-Attribute'(Data);
decode_disp('Access-Control-Element', Data) -> 'dec_Access-Control-Element'(Data);
decode_disp('Access-Request', Data) -> 'dec_Access-Request'(Data);
decode_disp('Access-Passwords', Data) -> 'dec_Access-Passwords'(Data);
decode_disp('Password', Data) -> dec_Password(Data);
decode_disp('Pass-Passwords', Data) -> 'dec_Pass-Passwords'(Data);
decode_disp('Application-Entity-Title', Data) -> 'dec_Application-Entity-Title'(Data);
decode_disp('EXTERNAL', Data) -> dec_EXTERNAL(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.
%%================================
%% FileTransferParameters
%%================================
enc_FileTransferParameters(Val) ->
enc_FileTransferParameters(Val, [<<48>>]).
enc_FileTransferParameters(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6} = Val,
%%-------------------------------------------------
%% attribute related-stored-file(1) External IPMSFileTransferBodyPartType:RelatedStoredFile OPTIONAL
%%-------------------------------------------------
{EncBytes1,EncLen1} = case Cindex1 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_RelatedStoredFile'(Cindex1, [<<160>>])
end,
%%-------------------------------------------------
%% attribute contents-type(2) External IPMSFileTransferBodyPartType:ContentsTypeParameter DEFAULT = {'document-type',{'Contents-Type-Attribute_document-type',{1,0,8571,5,3},asn1_NOVALUE}}
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_DEFAULT ->
{<<>>,0};
_ when Cindex2 =:= {'document-type',{'Contents-Type-Attribute_document-type',{1,0,8571,5,3},asn1_NOVALUE}} ->
{<<>>,0};
_ ->
'enc_ContentsTypeParameter'(Cindex2, [<<161>>])
end,
%%-------------------------------------------------
%% attribute environment(3) External IPMSFileTransferBodyPartType:EnvironmentParameter OPTIONAL
%%-------------------------------------------------
{EncBytes3,EncLen3} = case Cindex3 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_EnvironmentParameter'(Cindex3, [<<162>>])
end,
%%-------------------------------------------------
%% attribute compression(4) External IPMSFileTransferBodyPartType:CompressionParameter OPTIONAL
%%-------------------------------------------------
{EncBytes4,EncLen4} = case Cindex4 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_CompressionParameter'(Cindex4, [<<163>>])
end,
%%-------------------------------------------------
%% attribute file-attributes(5) External IPMSFileTransferBodyPartType:FileAttributes OPTIONAL
%%-------------------------------------------------
{EncBytes5,EncLen5} = case Cindex5 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_FileAttributes'(Cindex5, [<<164>>])
end,
%%-------------------------------------------------
%% attribute extensions(6) External IPMSInformationObjects:ExtensionsField OPTIONAL
%%-------------------------------------------------
{EncBytes6,EncLen6} = case Cindex6 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'IPMSInformationObjects':'enc_ExtensionsField'(Cindex6, [<<165>>])
end,
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6],
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_FileTransferParameters(Tlv) ->
dec_FileTransferParameters(Tlv, [16]).
dec_FileTransferParameters(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute related-stored-file(1) External IPMSFileTransferBodyPartType:RelatedStoredFile OPTIONAL
%%-------------------------------------------------
{Term1,Tlv2} = case Tlv1 of
[{131072,V1}|TempTlv2] ->
{'dec_RelatedStoredFile'(V1, []), TempTlv2};
_ ->
{ asn1_NOVALUE, Tlv1}
end,
%%-------------------------------------------------
%% attribute contents-type(2) External IPMSFileTransferBodyPartType:ContentsTypeParameter DEFAULT = {'document-type',{'Contents-Type-Attribute_document-type',{1,0,8571,5,3},asn1_NOVALUE}}
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{131073,V2}|TempTlv3] ->
{'dec_ContentsTypeParameter'(V2, []), TempTlv3};
_ ->
{{'document-type',{'Contents-Type-Attribute_document-type',{1,0,8571,5,3},asn1_NOVALUE}},Tlv2}
end,
%%-------------------------------------------------
%% attribute environment(3) External IPMSFileTransferBodyPartType:EnvironmentParameter OPTIONAL
%%-------------------------------------------------
{Term3,Tlv4} = case Tlv3 of
[{131074,V3}|TempTlv4] ->
{'dec_EnvironmentParameter'(V3, []), TempTlv4};
_ ->
{ asn1_NOVALUE, Tlv3}
end,
%%-------------------------------------------------
%% attribute compression(4) External IPMSFileTransferBodyPartType:CompressionParameter OPTIONAL
%%-------------------------------------------------
{Term4,Tlv5} = case Tlv4 of
[{131075,V4}|TempTlv5] ->
{'dec_CompressionParameter'(V4, []), TempTlv5};
_ ->
{ asn1_NOVALUE, Tlv4}
end,
%%-------------------------------------------------
%% attribute file-attributes(5) External IPMSFileTransferBodyPartType:FileAttributes OPTIONAL
%%-------------------------------------------------
{Term5,Tlv6} = case Tlv5 of
[{131076,V5}|TempTlv6] ->
{'dec_FileAttributes'(V5, []), TempTlv6};
_ ->
{ asn1_NOVALUE, Tlv5}
end,
%%-------------------------------------------------
%% attribute extensions(6) External IPMSInformationObjects:ExtensionsField OPTIONAL
%%-------------------------------------------------
{Term6,Tlv7} = case Tlv6 of
[{131077,V6}|TempTlv7] ->
{'IPMSInformationObjects':'dec_ExtensionsField'(V6, []), TempTlv7};
_ ->
{ asn1_NOVALUE, Tlv6}
end,
case Tlv7 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowed
end,
Res1 = {'FileTransferParameters',Term1,Term2,Term3,Term4,Term5,Term6},
Res1.
%%================================
%% FileTransferData
%%================================
enc_FileTransferData(Val) ->
enc_FileTransferData(Val, [<<48>>]).
enc_FileTransferData(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_FileTransferData_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_FileTransferData_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_FileTransferData_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = 'enc_EXTERNAL'(H, [<<40>>]),
'enc_FileTransferData_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
dec_FileTransferData(Tlv) ->
dec_FileTransferData(Tlv, [16]).
dec_FileTransferData(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
['dec_EXTERNAL'(V1, [8]) || V1 <- Tlv1].
%%================================
%% RelatedStoredFile
%%================================
enc_RelatedStoredFile(Val) ->
enc_RelatedStoredFile(Val, [<<49>>]).
enc_RelatedStoredFile(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_RelatedStoredFile_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_RelatedStoredFile_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_RelatedStoredFile_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = 'enc_RelatedStoredFile_SETOF'(H, [<<48>>]),
'enc_RelatedStoredFile_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
%%================================
%% RelatedStoredFile_SETOF
%%================================
enc_RelatedStoredFile_SETOF(Val, TagIn) ->
{_,Cindex1,Cindex2} = Val,
%%-------------------------------------------------
%% attribute file-identifier(1) External IPMSFileTransferBodyPartType:FileIdentifier
%%-------------------------------------------------
{EncBytes1,EncLen1} = 'enc_FileIdentifier'(Cindex1, []),
%%-------------------------------------------------
%% attribute relationship(2) External IPMSFileTransferBodyPartType:Relationship DEFAULT = {'explicit-relationship',0}
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_DEFAULT ->
{<<>>,0};
_ when Cindex2 =:= {'explicit-relationship',0} ->
{<<>>,0};
_ ->
'enc_Relationship'(Cindex2, [])
end,
BytesSoFar = [EncBytes1, EncBytes2],
LenSoFar = EncLen1 + EncLen2,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_RelatedStoredFile(Tlv) ->
dec_RelatedStoredFile(Tlv, [17]).
dec_RelatedStoredFile(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
['dec_RelatedStoredFile_SETOF'(V1, [16]) || V1 <- Tlv1].
'dec_RelatedStoredFile_SETOF'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute file-identifier(1) External IPMSFileTransferBodyPartType:FileIdentifier
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = 'dec_FileIdentifier'(V1, []),
%%-------------------------------------------------
%% attribute relationship(2) External IPMSFileTransferBodyPartType:Relationship DEFAULT = {'explicit-relationship',0}
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[V2 = {131072,_}|TempTlv3] ->
{'dec_Relationship'(V2, []), TempTlv3};
[V2 = {131073,_}|TempTlv3] ->
{'dec_Relationship'(V2, []), TempTlv3};
_ ->
{{'explicit-relationship',0},Tlv2}
end,
case Tlv3 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
end,
Res1 = {'RelatedStoredFile_SETOF',Term1,Term2},
Res1.
%%================================
%% FileIdentifier
%%================================
enc_FileIdentifier(Val) ->
enc_FileIdentifier(Val, []).
enc_FileIdentifier(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'pathname-and-version' ->
'enc_PathnameandVersion'(element(2,Val), [<<160>>]);
'cross-reference' ->
'enc_CrossReference'(element(2,Val), [<<161>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
dec_FileIdentifier(Tlv) ->
dec_FileIdentifier(Tlv, []).
dec_FileIdentifier(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'pathname-and-version'
{131072, V1} ->
{'pathname-and-version', 'dec_PathnameandVersion'(V1, [])};
%% 'cross-reference'
{131073, V1} ->
{'cross-reference', 'dec_CrossReference'(V1, [])};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
%%================================
%% PathnameandVersion
%%================================
enc_PathnameandVersion(Val) ->
enc_PathnameandVersion(Val, [<<48>>]).
enc_PathnameandVersion(Val, TagIn) ->
{_,Cindex1,Cindex2} = Val,
%%-------------------------------------------------
%% attribute pathname(1) External IPMSFileTransferBodyPartType:Pathname-Attribute
%%-------------------------------------------------
{EncBytes1,EncLen1} = 'enc_Pathname-Attribute'(Cindex1, [<<160>>]),
%%-------------------------------------------------
%% attribute file-version(2) with type GraphicString OPTIONAL
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_restricted_string(Cindex2, [<<129>>])
end,
BytesSoFar = [EncBytes1, EncBytes2],
LenSoFar = EncLen1 + EncLen2,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_PathnameandVersion(Tlv) ->
dec_PathnameandVersion(Tlv, [16]).
dec_PathnameandVersion(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute pathname(1) External IPMSFileTransferBodyPartType:Pathname-Attribute
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = 'dec_Pathname-Attribute'(V1, [131072]),
%%-------------------------------------------------
%% attribute file-version(2) with type GraphicString OPTIONAL
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{131073,V2}|TempTlv3] ->
{begin
binary_to_list(decode_restricted_string(V2, []))
end
, TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
case Tlv3 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
end,
Res1 = {'PathnameandVersion',Term1,Term2},
Res1.
%%================================
%% CrossReference
%%================================
enc_CrossReference(Val) ->
enc_CrossReference(Val, [<<48>>]).
enc_CrossReference(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3} = Val,
%%-------------------------------------------------
%% attribute application-cross-reference(1) with type OCTET STRING
%%-------------------------------------------------
{EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<128>>]),
%%-------------------------------------------------
%% attribute message-reference(2) External IPMSFileTransferBodyPartType:MessageReference OPTIONAL
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_MessageReference'(Cindex2, [<<161>>])
end,
%%-------------------------------------------------
%% attribute body-part-reference(3) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes3,EncLen3} = case Cindex3 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex3, [<<130>>])
end,
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
LenSoFar = EncLen1 + EncLen2 + EncLen3,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_CrossReference(Tlv) ->
dec_CrossReference(Tlv, [16]).
dec_CrossReference(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute application-cross-reference(1) with type OCTET STRING
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = decode_octet_string(V1, [131072]),
%%-------------------------------------------------
%% attribute message-reference(2) External IPMSFileTransferBodyPartType:MessageReference OPTIONAL
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{131073,V2}|TempTlv3] ->
{'dec_MessageReference'(V2, []), TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
%%-------------------------------------------------
%% attribute body-part-reference(3) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term3,Tlv4} = case Tlv3 of
[{131074,V3}|TempTlv4] ->
{decode_integer(V3, []), TempTlv4};
_ ->
{ asn1_NOVALUE, Tlv3}
end,
case Tlv4 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed
end,
Res1 = {'CrossReference',Term1,Term2,Term3},
Res1.
%%================================
%% MessageReference
%%================================
enc_MessageReference(Val) ->
enc_MessageReference(Val, [<<49>>]).
enc_MessageReference(Val, TagIn) ->
{_,Cindex1,Cindex2} = Val,
%%-------------------------------------------------
%% attribute user(1) External MTSAbstractService:ORName OPTIONAL
%%-------------------------------------------------
{EncBytes1,EncLen1} = case Cindex1 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'MTSAbstractService':'enc_ORName'(Cindex1, [<<160>>])
end,
%%-------------------------------------------------
%% attribute user-relative-identifier(2) with type PrintableString
%%-------------------------------------------------
{EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<129>>]),
BytesSoFar = [EncBytes1, EncBytes2],
LenSoFar = EncLen1 + EncLen2,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_MessageReference(Tlv) ->
dec_MessageReference(Tlv, [17]).
dec_MessageReference(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
SetFun = fun(FunTlv) ->
case FunTlv of
%user
TTlv = {131072,_} ->
{1, TTlv};
%user-relative-identifier
TTlv = {131073,_} ->
{2, TTlv};
Else ->
{3, Else}
end
end,
PositionList = [SetFun(TempTlv)|| TempTlv <- Tlv1],
Tlv2 = [Stlv || {_,Stlv} <- lists:sort(PositionList)],
%%-------------------------------------------------
%% attribute user(1) External MTSAbstractService:ORName OPTIONAL
%%-------------------------------------------------
{Term1,Tlv3} = case Tlv2 of
[{131072,V1}|TempTlv3] ->
{'MTSAbstractService':'dec_ORName'(V1, []), TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
%%-------------------------------------------------
%% attribute user-relative-identifier(2) with type PrintableString
%%-------------------------------------------------
[V2|Tlv4] = Tlv3,
Term2 = begin
binary_to_list(decode_restricted_string(V2, [131073]))
end
,
case Tlv4 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed
end,
Res1 = {'MessageReference',Term1,Term2},
Res1.
%%================================
%% Relationship
%%================================
enc_Relationship(Val) ->
enc_Relationship(Val, []).
enc_Relationship(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'explicit-relationship' ->
encode_integer(element(2,Val), [{unspecified,0},{'new-file',1},{replacement,2},{extension,3}], [<<128>>]);
'descriptive-relationship' ->
encode_restricted_string(element(2,Val), [<<129>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
dec_Relationship(Tlv) ->
dec_Relationship(Tlv, []).
dec_Relationship(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'explicit-relationship'
{131072, V1} ->
{'explicit-relationship', begin
Val1 = decode_integer(V1, []),
number2name(Val1, [{unspecified,0},{'new-file',1},{replacement,2},{extension,3}])
end
};
%% 'descriptive-relationship'
{131073, V1} ->
{'descriptive-relationship', begin
binary_to_list(decode_restricted_string(V1, []))
end
};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
%%================================
%% ExplicitRelationship
%%================================
enc_ExplicitRelationship(Val) ->
enc_ExplicitRelationship(Val, [<<2>>]).
enc_ExplicitRelationship(Val, TagIn) ->
encode_integer(Val, [{unspecified,0},{'new-file',1},{replacement,2},{extension,3}], TagIn).
dec_ExplicitRelationship(Tlv) ->
dec_ExplicitRelationship(Tlv, [2]).
dec_ExplicitRelationship(Tlv, TagIn) ->
begin
Val1 = decode_integer(Tlv, TagIn),
number2name(Val1, [{unspecified,0},{'new-file',1},{replacement,2},{extension,3}])
end
.
%%================================
%% ContentsTypeParameter
%%================================
enc_ContentsTypeParameter(Val) ->
enc_ContentsTypeParameter(Val, []).
enc_ContentsTypeParameter(Val, TagIn) ->
'enc_Contents-Type-Attribute'(Val, TagIn).
dec_ContentsTypeParameter(Tlv) ->
dec_ContentsTypeParameter(Tlv, []).
dec_ContentsTypeParameter(Tlv, TagIn) ->
'dec_Contents-Type-Attribute'(Tlv, TagIn).
%%================================
%% Contents-Type-Attribute
%%================================
'enc_Contents-Type-Attribute'(Val) ->
'enc_Contents-Type-Attribute'(Val, []).
'enc_Contents-Type-Attribute'(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'document-type' ->
'enc_Contents-Type-Attribute_document-type'(element(2,Val), [<<160>>]);
'constraint-set-and-abstract-syntax' ->
'enc_Contents-Type-Attribute_constraint-set-and-abstract-syntax'(element(2,Val), [<<161>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
%%================================
%% Contents-Type-Attribute_document-type
%%================================
'enc_Contents-Type-Attribute_document-type'(Val, TagIn) ->
{_,Cindex1,Cindex2} = Val,
%%-------------------------------------------------
%% attribute document-type-name(1) with type OBJECT IDENTIFIER
%%-------------------------------------------------
{EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]),
%%-------------------------------------------------
%% attribute parameter(2) with type ASN1_OPEN_TYPE OPTIONAL
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_open_type(Cindex2, [<<160>>])
end,
BytesSoFar = [EncBytes1, EncBytes2],
LenSoFar = EncLen1 + EncLen2,
encode_tags(TagIn, BytesSoFar, LenSoFar).
%%================================
%% Contents-Type-Attribute_constraint-set-and-abstract-syntax
%%================================
'enc_Contents-Type-Attribute_constraint-set-and-abstract-syntax'(Val, TagIn) ->
{_,Cindex1,Cindex2} = Val,
%%-------------------------------------------------
%% attribute constraint-set-name(1) with type OBJECT IDENTIFIER
%%-------------------------------------------------
{EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]),
%%-------------------------------------------------
%% attribute abstract-syntax-name(2) with type OBJECT IDENTIFIER
%%-------------------------------------------------
{EncBytes2,EncLen2} = encode_object_identifier(Cindex2, [<<6>>]),
BytesSoFar = [EncBytes1, EncBytes2],
LenSoFar = EncLen1 + EncLen2,
encode_tags(TagIn, BytesSoFar, LenSoFar).
'dec_Contents-Type-Attribute'(Tlv) ->
'dec_Contents-Type-Attribute'(Tlv, []).
'dec_Contents-Type-Attribute'(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'document-type'
{131072, V1} ->
{'document-type', 'dec_Contents-Type-Attribute_document-type'(V1, [])};
%% 'constraint-set-and-abstract-syntax'
{131073, V1} ->
{'constraint-set-and-abstract-syntax', 'dec_Contents-Type-Attribute_constraint-set-and-abstract-syntax'(V1, [])};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
'dec_Contents-Type-Attribute_document-type'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute document-type-name(1) with type OBJECT IDENTIFIER
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = decode_object_identifier(V1, [6]),
%%-------------------------------------------------
%% attribute parameter(2) with type ASN1_OPEN_TYPE OPTIONAL
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{131072,V2}|TempTlv3] ->
{decode_open_type_as_binary(V2, []), TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
case Tlv3 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
end,
Res1 = {'Contents-Type-Attribute_document-type',Term1,Term2},
Res1.
'dec_Contents-Type-Attribute_constraint-set-and-abstract-syntax'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute constraint-set-name(1) with type OBJECT IDENTIFIER
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = decode_object_identifier(V1, [6]),
%%-------------------------------------------------
%% attribute abstract-syntax-name(2) with type OBJECT IDENTIFIER
%%-------------------------------------------------
[V2|Tlv3] = Tlv2,
Term2 = decode_object_identifier(V2, [6]),
case Tlv3 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
end,
Res1 = {'Contents-Type-Attribute_constraint-set-and-abstract-syntax',Term1,Term2},
Res1.
%%================================
%% Document-Type-Name
%%================================
'enc_Document-Type-Name'(Val) ->
'enc_Document-Type-Name'(Val, [<<6>>]).
'enc_Document-Type-Name'(Val, TagIn) ->
encode_object_identifier(Val, TagIn).
'dec_Document-Type-Name'(Tlv) ->
'dec_Document-Type-Name'(Tlv, [6]).
'dec_Document-Type-Name'(Tlv, TagIn) ->
decode_object_identifier(Tlv, TagIn).
%%================================
%% Constraint-Set-Name
%%================================
'enc_Constraint-Set-Name'(Val) ->
'enc_Constraint-Set-Name'(Val, [<<6>>]).
'enc_Constraint-Set-Name'(Val, TagIn) ->
encode_object_identifier(Val, TagIn).
'dec_Constraint-Set-Name'(Tlv) ->
'dec_Constraint-Set-Name'(Tlv, [6]).
'dec_Constraint-Set-Name'(Tlv, TagIn) ->
decode_object_identifier(Tlv, TagIn).
%%================================
%% Abstract-Syntax-Name
%%================================
'enc_Abstract-Syntax-Name'(Val) ->
'enc_Abstract-Syntax-Name'(Val, [<<6>>]).
'enc_Abstract-Syntax-Name'(Val, TagIn) ->
encode_object_identifier(Val, TagIn).
'dec_Abstract-Syntax-Name'(Tlv) ->
'dec_Abstract-Syntax-Name'(Tlv, [6]).
'dec_Abstract-Syntax-Name'(Tlv, TagIn) ->
decode_object_identifier(Tlv, TagIn).
%%================================
%% EnvironmentParameter
%%================================
enc_EnvironmentParameter(Val) ->
enc_EnvironmentParameter(Val, [<<48>>]).
enc_EnvironmentParameter(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3,Cindex4} = Val,
%%-------------------------------------------------
%% attribute application-reference(1) External IPMSFileTransferBodyPartType:GeneralIdentifier OPTIONAL
%%-------------------------------------------------
{EncBytes1,EncLen1} = case Cindex1 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_GeneralIdentifier'(Cindex1, [<<160>>])
end,
%%-------------------------------------------------
%% attribute machine(2) External IPMSFileTransferBodyPartType:GeneralIdentifier OPTIONAL
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_GeneralIdentifier'(Cindex2, [<<161>>])
end,
%%-------------------------------------------------
%% attribute operating-system(3) with type OBJECT IDENTIFIER OPTIONAL
%%-------------------------------------------------
{EncBytes3,EncLen3} = case Cindex3 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_object_identifier(Cindex3, [<<130>>])
end,
%%-------------------------------------------------
%% attribute user-visible-string(4) with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
{EncBytes4,EncLen4} = case Cindex4 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_EnvironmentParameter_user-visible-string'(Cindex4, [<<163>>])
end,
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
encode_tags(TagIn, BytesSoFar, LenSoFar).
%%================================
%% EnvironmentParameter_user-visible-string
%%================================
'enc_EnvironmentParameter_user-visible-string'(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_EnvironmentParameter_user-visible-string_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_EnvironmentParameter_user-visible-string_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_EnvironmentParameter_user-visible-string_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = encode_restricted_string(H, [<<25>>]),
'enc_EnvironmentParameter_user-visible-string_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
dec_EnvironmentParameter(Tlv) ->
dec_EnvironmentParameter(Tlv, [16]).
dec_EnvironmentParameter(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute application-reference(1) External IPMSFileTransferBodyPartType:GeneralIdentifier OPTIONAL
%%-------------------------------------------------
{Term1,Tlv2} = case Tlv1 of
[{131072,V1}|TempTlv2] ->
{'dec_GeneralIdentifier'(V1, []), TempTlv2};
_ ->
{ asn1_NOVALUE, Tlv1}
end,
%%-------------------------------------------------
%% attribute machine(2) External IPMSFileTransferBodyPartType:GeneralIdentifier OPTIONAL
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{131073,V2}|TempTlv3] ->
{'dec_GeneralIdentifier'(V2, []), TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
%%-------------------------------------------------
%% attribute operating-system(3) with type OBJECT IDENTIFIER OPTIONAL
%%-------------------------------------------------
{Term3,Tlv4} = case Tlv3 of
[{131074,V3}|TempTlv4] ->
{decode_object_identifier(V3, []), TempTlv4};
_ ->
{ asn1_NOVALUE, Tlv3}
end,
%%-------------------------------------------------
%% attribute user-visible-string(4) with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
{Term4,Tlv5} = case Tlv4 of
[{131075,V4}|TempTlv5] ->
{'dec_EnvironmentParameter_user-visible-string'(V4, []), TempTlv5};
_ ->
{ asn1_NOVALUE, Tlv4}
end,
case Tlv5 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed
end,
Res1 = {'EnvironmentParameter',Term1,Term2,Term3,Term4},
Res1.
'dec_EnvironmentParameter_user-visible-string'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
[begin
binary_to_list(decode_restricted_string(V1, [25]))
end
|| V1 <- Tlv1].
%%================================
%% GeneralIdentifier
%%================================
enc_GeneralIdentifier(Val) ->
enc_GeneralIdentifier(Val, []).
enc_GeneralIdentifier(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'registered-identifier' ->
encode_object_identifier(element(2,Val), [<<128>>]);
'descriptive-identifier' ->
'enc_GeneralIdentifier_descriptive-identifier'(element(2,Val), [<<161>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
%%================================
%% GeneralIdentifier_descriptive-identifier
%%================================
'enc_GeneralIdentifier_descriptive-identifier'(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_GeneralIdentifier_descriptive-identifier_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_GeneralIdentifier_descriptive-identifier_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_GeneralIdentifier_descriptive-identifier_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = encode_restricted_string(H, [<<25>>]),
'enc_GeneralIdentifier_descriptive-identifier_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
dec_GeneralIdentifier(Tlv) ->
dec_GeneralIdentifier(Tlv, []).
dec_GeneralIdentifier(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'registered-identifier'
{131072, V1} ->
{'registered-identifier', decode_object_identifier(V1, [])};
%% 'descriptive-identifier'
{131073, V1} ->
{'descriptive-identifier', 'dec_GeneralIdentifier_descriptive-identifier'(V1, [])};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
'dec_GeneralIdentifier_descriptive-identifier'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
[begin
binary_to_list(decode_restricted_string(V1, [25]))
end
|| V1 <- Tlv1].
%%================================
%% CompressionParameter
%%================================
enc_CompressionParameter(Val) ->
enc_CompressionParameter(Val, [<<48>>]).
enc_CompressionParameter(Val, TagIn) ->
{_,Cindex1,Cindex2} = Val,
Objcompression_algorithm_id =
'IPMSFileTransferBodyPartType':'getenc_CompressionAlgorithmTable'( Cindex1),
%%-------------------------------------------------
%% attribute compression-algorithm-id(1) with type OBJECT IDENTIFIER
%%-------------------------------------------------
{EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<128>>]),
%%-------------------------------------------------
%% attribute compression-algorithm-param(2) with type typefieldType
%%-------------------------------------------------
{TmpBytes2,_} = Objcompression_algorithm_id('Type', Cindex2, []),
{EncBytes2,EncLen2} = encode_open_type(TmpBytes2, [<<161>>])
,
BytesSoFar = [EncBytes1, EncBytes2],
LenSoFar = EncLen1 + EncLen2,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_CompressionParameter(Tlv) ->
dec_CompressionParameter(Tlv, [16]).
dec_CompressionParameter(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute compression-algorithm-id(1) with type OBJECT IDENTIFIER
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = decode_object_identifier(V1, [131072]),
%%-------------------------------------------------
%% attribute compression-algorithm-param(2) with type typefieldType
%%-------------------------------------------------
[V2|Tlv3] = Tlv2,
Tmpterm1 = decode_open_type(V2, [131073]),
DecObjcompression_algorithm_idTerm1 =
'IPMSFileTransferBodyPartType':'getdec_CompressionAlgorithmTable'(Term1),
Term2 =
case (catch DecObjcompression_algorithm_idTerm1('Type', Tmpterm1, [])) of
{'EXIT', Reason1} ->
exit({'Type not compatible with table constraint',Reason1});
Tmpterm2 ->
Tmpterm2
end,
case Tlv3 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
end,
Res1 = {'CompressionParameter',Term1,Term2},
Res1.
%%================================
%% FileAttributes
%%================================
enc_FileAttributes(Val) ->
enc_FileAttributes(Val, [<<48>>]).
enc_FileAttributes(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12,Cindex13,Cindex14,Cindex15,Cindex16,Cindex17,Cindex18} = Val,
%%-------------------------------------------------
%% attribute pathname(1) External IPMSFileTransferBodyPartType:Pathname-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes1,EncLen1} = case Cindex1 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_Pathname-Attribute'(Cindex1, [])
end,
%%-------------------------------------------------
%% attribute permitted-actions(2) with type BIT STRING OPTIONAL
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_named_bit_string(Cindex2, [{read,0},{insert,1},{replace,2},{extend,3},{erase,4},{'read-attribute',5},{'change-attribute',6},{'delete-Object',7},{traversal,8},{'reverse-traversal',9},{'random-Order',10},{pass,11},{link,12}], [<<129>>])
end,
%%-------------------------------------------------
%% attribute storage-account(3) External IPMSFileTransferBodyPartType:Account-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes3,EncLen3} = case Cindex3 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_Account-Attribute'(Cindex3, [<<163>>])
end,
%%-------------------------------------------------
%% attribute date-and-time-of-creation(4) External ISO8571-FTAM:Date-and-Time-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes4,EncLen4} = case Cindex4 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Date-and-Time-Attribute'(Cindex4, [<<164>>])
end,
%%-------------------------------------------------
%% attribute date-and-time-of-last-modification(5) External ISO8571-FTAM:Date-and-Time-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes5,EncLen5} = case Cindex5 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Date-and-Time-Attribute'(Cindex5, [<<165>>])
end,
%%-------------------------------------------------
%% attribute date-and-time-of-last-read-access(6) External ISO8571-FTAM:Date-and-Time-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes6,EncLen6} = case Cindex6 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Date-and-Time-Attribute'(Cindex6, [<<166>>])
end,
%%-------------------------------------------------
%% attribute date-and-time-of-last-attribute-modification(7) External ISO8571-FTAM:Date-and-Time-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes7,EncLen7} = case Cindex7 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Date-and-Time-Attribute'(Cindex7, [<<167>>])
end,
%%-------------------------------------------------
%% attribute identity-of-creator(8) External IPMSFileTransferBodyPartType:User-Identity-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes8,EncLen8} = case Cindex8 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_User-Identity-Attribute'(Cindex8, [<<168>>])
end,
%%-------------------------------------------------
%% attribute identity-of-last-modifier(9) External IPMSFileTransferBodyPartType:User-Identity-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes9,EncLen9} = case Cindex9 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_User-Identity-Attribute'(Cindex9, [<<169>>])
end,
%%-------------------------------------------------
%% attribute identity-of-last-reader(10) External IPMSFileTransferBodyPartType:User-Identity-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes10,EncLen10} = case Cindex10 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_User-Identity-Attribute'(Cindex10, [<<170>>])
end,
%%-------------------------------------------------
%% attribute identity-of-last-attribute-modifier(11) External IPMSFileTransferBodyPartType:User-Identity-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes11,EncLen11} = case Cindex11 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_User-Identity-Attribute'(Cindex11, [<<171>>])
end,
%%-------------------------------------------------
%% attribute object-availability(12) External ISO8571-FTAM:Object-Availability-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes12,EncLen12} = case Cindex12 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Object-Availability-Attribute'(Cindex12, [<<172>>])
end,
%%-------------------------------------------------
%% attribute object-size(13) External ISO8571-FTAM:Object-Size-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes13,EncLen13} = case Cindex13 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Object-Size-Attribute'(Cindex13, [<<173>>])
end,
%%-------------------------------------------------
%% attribute future-object-size(14) External ISO8571-FTAM:Object-Size-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes14,EncLen14} = case Cindex14 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Object-Size-Attribute'(Cindex14, [<<174>>])
end,
%%-------------------------------------------------
%% attribute access-control(15) External IPMSFileTransferBodyPartType:Access-Control-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes15,EncLen15} = case Cindex15 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_Access-Control-Attribute'(Cindex15, [<<175>>])
end,
%%-------------------------------------------------
%% attribute legal-qualifications(16) External ISO8571-FTAM:Legal-Qualification-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes16,EncLen16} = case Cindex16 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Legal-Qualification-Attribute'(Cindex16, [<<176>>])
end,
%%-------------------------------------------------
%% attribute private-use(17) External ISO8571-FTAM:Private-Use-Attribute OPTIONAL
%%-------------------------------------------------
{EncBytes17,EncLen17} = case Cindex17 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Private-Use-Attribute'(Cindex17, [<<177>>])
end,
%%-------------------------------------------------
%% attribute attribute-extensions(18) External ISO8571-FTAM:Attribute-Extensions OPTIONAL
%%-------------------------------------------------
{EncBytes18,EncLen18} = case Cindex18 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Attribute-Extensions'(Cindex18, [<<182>>])
end,
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13, EncBytes14, EncBytes15, EncBytes16, EncBytes17, EncBytes18],
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13 + EncLen14 + EncLen15 + EncLen16 + EncLen17 + EncLen18,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_FileAttributes(Tlv) ->
dec_FileAttributes(Tlv, [16]).
dec_FileAttributes(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute pathname(1) External IPMSFileTransferBodyPartType:Pathname-Attribute OPTIONAL
%%-------------------------------------------------
{Term1,Tlv2} = case Tlv1 of
[V1 = {131072,_}|TempTlv2] ->
{'dec_Pathname-Attribute'(V1, []), TempTlv2};
[V1 = {131095,_}|TempTlv2] ->
{'dec_Pathname-Attribute'(V1, []), TempTlv2};
_ ->
{ asn1_NOVALUE, Tlv1}
end,
%%-------------------------------------------------
%% attribute permitted-actions(2) with type BIT STRING OPTIONAL
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{131073,V2}|TempTlv3] ->
{decode_named_bit_string(V2, [{read,0},{insert,1},{replace,2},{extend,3},{erase,4},{'read-attribute',5},{'change-attribute',6},{'delete-Object',7},{traversal,8},{'reverse-traversal',9},{'random-Order',10},{pass,11},{link,12}], []), TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
%%-------------------------------------------------
%% attribute storage-account(3) External IPMSFileTransferBodyPartType:Account-Attribute OPTIONAL
%%-------------------------------------------------
{Term3,Tlv4} = case Tlv3 of
[{131075,V3}|TempTlv4] ->
{'dec_Account-Attribute'(V3, []), TempTlv4};
_ ->
{ asn1_NOVALUE, Tlv3}
end,
%%-------------------------------------------------
%% attribute date-and-time-of-creation(4) External ISO8571-FTAM:Date-and-Time-Attribute OPTIONAL
%%-------------------------------------------------
{Term4,Tlv5} = case Tlv4 of
[{131076,V4}|TempTlv5] ->
{'ISO8571-FTAM':'dec_Date-and-Time-Attribute'(V4, []), TempTlv5};
_ ->
{ asn1_NOVALUE, Tlv4}
end,
%%-------------------------------------------------
%% attribute date-and-time-of-last-modification(5) External ISO8571-FTAM:Date-and-Time-Attribute OPTIONAL
%%-------------------------------------------------
{Term5,Tlv6} = case Tlv5 of
[{131077,V5}|TempTlv6] ->
{'ISO8571-FTAM':'dec_Date-and-Time-Attribute'(V5, []), TempTlv6};
_ ->
{ asn1_NOVALUE, Tlv5}
end,
%%-------------------------------------------------
%% attribute date-and-time-of-last-read-access(6) External ISO8571-FTAM:Date-and-Time-Attribute OPTIONAL
%%-------------------------------------------------
{Term6,Tlv7} = case Tlv6 of
[{131078,V6}|TempTlv7] ->
{'ISO8571-FTAM':'dec_Date-and-Time-Attribute'(V6, []), TempTlv7};
_ ->
{ asn1_NOVALUE, Tlv6}
end,
%%-------------------------------------------------
%% attribute date-and-time-of-last-attribute-modification(7) External ISO8571-FTAM:Date-and-Time-Attribute OPTIONAL
%%-------------------------------------------------
{Term7,Tlv8} = case Tlv7 of
[{131079,V7}|TempTlv8] ->
{'ISO8571-FTAM':'dec_Date-and-Time-Attribute'(V7, []), TempTlv8};
_ ->
{ asn1_NOVALUE, Tlv7}
end,
%%-------------------------------------------------
%% attribute identity-of-creator(8) External IPMSFileTransferBodyPartType:User-Identity-Attribute OPTIONAL
%%-------------------------------------------------
{Term8,Tlv9} = case Tlv8 of
[{131080,V8}|TempTlv9] ->
{'dec_User-Identity-Attribute'(V8, []), TempTlv9};
_ ->
{ asn1_NOVALUE, Tlv8}
end,
%%-------------------------------------------------
%% attribute identity-of-last-modifier(9) External IPMSFileTransferBodyPartType:User-Identity-Attribute OPTIONAL
%%-------------------------------------------------
{Term9,Tlv10} = case Tlv9 of
[{131081,V9}|TempTlv10] ->
{'dec_User-Identity-Attribute'(V9, []), TempTlv10};
_ ->
{ asn1_NOVALUE, Tlv9}
end,
%%-------------------------------------------------
%% attribute identity-of-last-reader(10) External IPMSFileTransferBodyPartType:User-Identity-Attribute OPTIONAL
%%-------------------------------------------------
{Term10,Tlv11} = case Tlv10 of
[{131082,V10}|TempTlv11] ->
{'dec_User-Identity-Attribute'(V10, []), TempTlv11};
_ ->
{ asn1_NOVALUE, Tlv10}
end,
%%-------------------------------------------------
%% attribute identity-of-last-attribute-modifier(11) External IPMSFileTransferBodyPartType:User-Identity-Attribute OPTIONAL
%%-------------------------------------------------
{Term11,Tlv12} = case Tlv11 of
[{131083,V11}|TempTlv12] ->
{'dec_User-Identity-Attribute'(V11, []), TempTlv12};
_ ->
{ asn1_NOVALUE, Tlv11}
end,
%%-------------------------------------------------
%% attribute object-availability(12) External ISO8571-FTAM:Object-Availability-Attribute OPTIONAL
%%-------------------------------------------------
{Term12,Tlv13} = case Tlv12 of
[{131084,V12}|TempTlv13] ->
{'ISO8571-FTAM':'dec_Object-Availability-Attribute'(V12, []), TempTlv13};
_ ->
{ asn1_NOVALUE, Tlv12}
end,
%%-------------------------------------------------
%% attribute object-size(13) External ISO8571-FTAM:Object-Size-Attribute OPTIONAL
%%-------------------------------------------------
{Term13,Tlv14} = case Tlv13 of
[{131085,V13}|TempTlv14] ->
{'ISO8571-FTAM':'dec_Object-Size-Attribute'(V13, []), TempTlv14};
_ ->
{ asn1_NOVALUE, Tlv13}
end,
%%-------------------------------------------------
%% attribute future-object-size(14) External ISO8571-FTAM:Object-Size-Attribute OPTIONAL
%%-------------------------------------------------
{Term14,Tlv15} = case Tlv14 of
[{131086,V14}|TempTlv15] ->
{'ISO8571-FTAM':'dec_Object-Size-Attribute'(V14, []), TempTlv15};
_ ->
{ asn1_NOVALUE, Tlv14}
end,
%%-------------------------------------------------
%% attribute access-control(15) External IPMSFileTransferBodyPartType:Access-Control-Attribute OPTIONAL
%%-------------------------------------------------
{Term15,Tlv16} = case Tlv15 of
[{131087,V15}|TempTlv16] ->
{'dec_Access-Control-Attribute'(V15, []), TempTlv16};
_ ->
{ asn1_NOVALUE, Tlv15}
end,
%%-------------------------------------------------
%% attribute legal-qualifications(16) External ISO8571-FTAM:Legal-Qualification-Attribute OPTIONAL
%%-------------------------------------------------
{Term16,Tlv17} = case Tlv16 of
[{131088,V16}|TempTlv17] ->
{'ISO8571-FTAM':'dec_Legal-Qualification-Attribute'(V16, []), TempTlv17};
_ ->
{ asn1_NOVALUE, Tlv16}
end,
%%-------------------------------------------------
%% attribute private-use(17) External ISO8571-FTAM:Private-Use-Attribute OPTIONAL
%%-------------------------------------------------
{Term17,Tlv18} = case Tlv17 of
[{131089,V17}|TempTlv18] ->
{'ISO8571-FTAM':'dec_Private-Use-Attribute'(V17, []), TempTlv18};
_ ->
{ asn1_NOVALUE, Tlv17}
end,
%%-------------------------------------------------
%% attribute attribute-extensions(18) External ISO8571-FTAM:Attribute-Extensions OPTIONAL
%%-------------------------------------------------
{Term18,Tlv19} = case Tlv18 of
[{131094,V18}|TempTlv19] ->
{'ISO8571-FTAM':'dec_Attribute-Extensions'(V18, []), TempTlv19};
_ ->
{ asn1_NOVALUE, Tlv18}
end,
case Tlv19 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv19}}}) % extra fields not allowed
end,
Res1 = {'FileAttributes',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12,Term13,Term14,Term15,Term16,Term17,Term18},
Res1.
%%================================
%% Pathname-Attribute
%%================================
'enc_Pathname-Attribute'(Val) ->
'enc_Pathname-Attribute'(Val, []).
'enc_Pathname-Attribute'(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'incomplete-pathname' ->
'ISO8571-FTAM':'enc_Pathname'(element(2,Val), [<<160>>]);
'complete-pathname' ->
'ISO8571-FTAM':'enc_Pathname'(element(2,Val), [<<183>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
'dec_Pathname-Attribute'(Tlv) ->
'dec_Pathname-Attribute'(Tlv, []).
'dec_Pathname-Attribute'(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'incomplete-pathname'
{131072, V1} ->
{'incomplete-pathname', 'ISO8571-FTAM':'dec_Pathname'(V1, [])};
%% 'complete-pathname'
{131095, V1} ->
{'complete-pathname', 'ISO8571-FTAM':'dec_Pathname'(V1, [])};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
%%================================
%% Account-Attribute
%%================================
'enc_Account-Attribute'(Val) ->
'enc_Account-Attribute'(Val, []).
'enc_Account-Attribute'(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'no-value-available' ->
encode_null(element(2,Val), [<<128>>]);
'actual-values' ->
encode_restricted_string(element(2,Val), [<<25>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
'dec_Account-Attribute'(Tlv) ->
'dec_Account-Attribute'(Tlv, []).
'dec_Account-Attribute'(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'no-value-available'
{131072, V1} ->
{'no-value-available', decode_null(V1, [])};
%% 'actual-values'
{25, V1} ->
{'actual-values', begin
binary_to_list(decode_restricted_string(V1, []))
end
};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
%%================================
%% Account
%%================================
enc_Account(Val) ->
enc_Account(Val, [<<25>>]).
enc_Account(Val, TagIn) ->
encode_restricted_string(Val, TagIn).
dec_Account(Tlv) ->
dec_Account(Tlv, [25]).
dec_Account(Tlv, TagIn) ->
begin
binary_to_list(decode_restricted_string(Tlv, TagIn))
end
.
%%================================
%% User-Identity-Attribute
%%================================
'enc_User-Identity-Attribute'(Val) ->
'enc_User-Identity-Attribute'(Val, []).
'enc_User-Identity-Attribute'(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'no-value-available' ->
encode_null(element(2,Val), [<<128>>]);
'actual-values' ->
encode_restricted_string(element(2,Val), [<<25>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
'dec_User-Identity-Attribute'(Tlv) ->
'dec_User-Identity-Attribute'(Tlv, []).
'dec_User-Identity-Attribute'(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'no-value-available'
{131072, V1} ->
{'no-value-available', decode_null(V1, [])};
%% 'actual-values'
{25, V1} ->
{'actual-values', begin
binary_to_list(decode_restricted_string(V1, []))
end
};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
%%================================
%% User-Identity
%%================================
'enc_User-Identity'(Val) ->
'enc_User-Identity'(Val, [<<25>>]).
'enc_User-Identity'(Val, TagIn) ->
encode_restricted_string(Val, TagIn).
'dec_User-Identity'(Tlv) ->
'dec_User-Identity'(Tlv, [25]).
'dec_User-Identity'(Tlv, TagIn) ->
begin
binary_to_list(decode_restricted_string(Tlv, TagIn))
end
.
%%================================
%% Access-Control-Attribute
%%================================
'enc_Access-Control-Attribute'(Val) ->
'enc_Access-Control-Attribute'(Val, []).
'enc_Access-Control-Attribute'(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'no-value-available' ->
encode_null(element(2,Val), [<<128>>]);
'actual-values' ->
'enc_Access-Control-Attribute_actual-values'(element(2,Val), [<<161>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
%%================================
%% Access-Control-Attribute_actual-values
%%================================
'enc_Access-Control-Attribute_actual-values'(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_Access-Control-Attribute_actual-values_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_Access-Control-Attribute_actual-values_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_Access-Control-Attribute_actual-values_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = 'enc_Access-Control-Element'(H, [<<48>>]),
'enc_Access-Control-Attribute_actual-values_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
'dec_Access-Control-Attribute'(Tlv) ->
'dec_Access-Control-Attribute'(Tlv, []).
'dec_Access-Control-Attribute'(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'no-value-available'
{131072, V1} ->
{'no-value-available', decode_null(V1, [])};
%% 'actual-values'
{131073, V1} ->
{'actual-values', 'dec_Access-Control-Attribute_actual-values'(V1, [])};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
'dec_Access-Control-Attribute_actual-values'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
['dec_Access-Control-Element'(V1, [16]) || V1 <- Tlv1].
%%================================
%% Access-Control-Element
%%================================
'enc_Access-Control-Element'(Val) ->
'enc_Access-Control-Element'(Val, [<<48>>]).
'enc_Access-Control-Element'(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5} = Val,
%%-------------------------------------------------
%% attribute action-list(1) with type BIT STRING
%%-------------------------------------------------
{EncBytes1,EncLen1} = encode_named_bit_string(Cindex1, [{read,0},{insert,1},{replace,2},{extend,3},{erase,4},{'read-attribute',5},{'change-attribute',6},{'delete-object',7}], [<<128>>]),
%%-------------------------------------------------
%% attribute concurrency-access(2) External ISO8571-FTAM:Concurrency-Access OPTIONAL
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'ISO8571-FTAM':'enc_Concurrency-Access'(Cindex2, [<<161>>])
end,
%%-------------------------------------------------
%% attribute identity(3) with type GraphicString OPTIONAL
%%-------------------------------------------------
{EncBytes3,EncLen3} = case Cindex3 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_restricted_string(Cindex3, [<<130>>])
end,
%%-------------------------------------------------
%% attribute passwords(4) External IPMSFileTransferBodyPartType:Access-Passwords OPTIONAL
%%-------------------------------------------------
{EncBytes4,EncLen4} = case Cindex4 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_Access-Passwords'(Cindex4, [<<163>>])
end,
%%-------------------------------------------------
%% attribute location(5) External IPMSFileTransferBodyPartType:Application-Entity-Title OPTIONAL
%%-------------------------------------------------
{EncBytes5,EncLen5} = case Cindex5 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_Application-Entity-Title'(Cindex5, [<<164>>])
end,
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
encode_tags(TagIn, BytesSoFar, LenSoFar).
'dec_Access-Control-Element'(Tlv) ->
'dec_Access-Control-Element'(Tlv, [16]).
'dec_Access-Control-Element'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute action-list(1) with type BIT STRING
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = decode_named_bit_string(V1, [{read,0},{insert,1},{replace,2},{extend,3},{erase,4},{'read-attribute',5},{'change-attribute',6},{'delete-object',7}], [131072]),
%%-------------------------------------------------
%% attribute concurrency-access(2) External ISO8571-FTAM:Concurrency-Access OPTIONAL
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{131073,V2}|TempTlv3] ->
{'ISO8571-FTAM':'dec_Concurrency-Access'(V2, []), TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
%%-------------------------------------------------
%% attribute identity(3) with type GraphicString OPTIONAL
%%-------------------------------------------------
{Term3,Tlv4} = case Tlv3 of
[{131074,V3}|TempTlv4] ->
{begin
binary_to_list(decode_restricted_string(V3, []))
end
, TempTlv4};
_ ->
{ asn1_NOVALUE, Tlv3}
end,
%%-------------------------------------------------
%% attribute passwords(4) External IPMSFileTransferBodyPartType:Access-Passwords OPTIONAL
%%-------------------------------------------------
{Term4,Tlv5} = case Tlv4 of
[{131075,V4}|TempTlv5] ->
{'dec_Access-Passwords'(V4, []), TempTlv5};
_ ->
{ asn1_NOVALUE, Tlv4}
end,
%%-------------------------------------------------
%% attribute location(5) External IPMSFileTransferBodyPartType:Application-Entity-Title OPTIONAL
%%-------------------------------------------------
{Term5,Tlv6} = case Tlv5 of
[{131076,V5}|TempTlv6] ->
{'dec_Application-Entity-Title'(V5, []), TempTlv6};
_ ->
{ asn1_NOVALUE, Tlv5}
end,
case Tlv6 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowed
end,
Res1 = {'Access-Control-Element',Term1,Term2,Term3,Term4,Term5},
Res1.
%%================================
%% Access-Request
%%================================
'enc_Access-Request'(Val) ->
'enc_Access-Request'(Val, [<<3>>]).
'enc_Access-Request'(Val, TagIn) ->
encode_named_bit_string(Val, [{read,0},{insert,1},{replace,2},{extend,3},{erase,4},{'read-attribute',5},{'change-attribute',6},{'delete-object',7}], TagIn).
'dec_Access-Request'(Tlv) ->
'dec_Access-Request'(Tlv, [3]).
'dec_Access-Request'(Tlv, TagIn) ->
decode_named_bit_string(Tlv, [{read,0},{insert,1},{replace,2},{extend,3},{erase,4},{'read-attribute',5},{'change-attribute',6},{'delete-object',7}], TagIn).
%%================================
%% Access-Passwords
%%================================
'enc_Access-Passwords'(Val) ->
'enc_Access-Passwords'(Val, [<<48>>]).
'enc_Access-Passwords'(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10} = Val,
%%-------------------------------------------------
%% attribute read-password(1) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes1,EncLen1} = 'enc_Password'(Cindex1, [<<160>>]),
%%-------------------------------------------------
%% attribute insert-password(2) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes2,EncLen2} = 'enc_Password'(Cindex2, [<<161>>]),
%%-------------------------------------------------
%% attribute replace-password(3) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes3,EncLen3} = 'enc_Password'(Cindex3, [<<162>>]),
%%-------------------------------------------------
%% attribute extend-password(4) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes4,EncLen4} = 'enc_Password'(Cindex4, [<<163>>]),
%%-------------------------------------------------
%% attribute erase-password(5) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes5,EncLen5} = 'enc_Password'(Cindex5, [<<164>>]),
%%-------------------------------------------------
%% attribute read-attribute-password(6) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes6,EncLen6} = 'enc_Password'(Cindex6, [<<165>>]),
%%-------------------------------------------------
%% attribute change-attribute-password(7) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes7,EncLen7} = 'enc_Password'(Cindex7, [<<166>>]),
%%-------------------------------------------------
%% attribute delete-password(8) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes8,EncLen8} = 'enc_Password'(Cindex8, [<<167>>]),
%%-------------------------------------------------
%% attribute pass-passwords(9) External IPMSFileTransferBodyPartType:Pass-Passwords
%%-------------------------------------------------
{EncBytes9,EncLen9} = 'enc_Pass-Passwords'(Cindex9, [<<168>>]),
%%-------------------------------------------------
%% attribute link-password(10) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
{EncBytes10,EncLen10} = 'enc_Password'(Cindex10, [<<169>>]),
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_Access-Passwords'(Tlv) ->
'dec_Access-Passwords'(Tlv, [16]).
'dec_Access-Passwords'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute read-password(1) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = 'dec_Password'(V1, [131072]),
%%-------------------------------------------------
%% attribute insert-password(2) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V2|Tlv3] = Tlv2,
Term2 = 'dec_Password'(V2, [131073]),
%%-------------------------------------------------
%% attribute replace-password(3) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V3|Tlv4] = Tlv3,
Term3 = 'dec_Password'(V3, [131074]),
%%-------------------------------------------------
%% attribute extend-password(4) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V4|Tlv5] = Tlv4,
Term4 = 'dec_Password'(V4, [131075]),
%%-------------------------------------------------
%% attribute erase-password(5) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V5|Tlv6] = Tlv5,
Term5 = 'dec_Password'(V5, [131076]),
%%-------------------------------------------------
%% attribute read-attribute-password(6) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V6|Tlv7] = Tlv6,
Term6 = 'dec_Password'(V6, [131077]),
%%-------------------------------------------------
%% attribute change-attribute-password(7) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V7|Tlv8] = Tlv7,
Term7 = 'dec_Password'(V7, [131078]),
%%-------------------------------------------------
%% attribute delete-password(8) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V8|Tlv9] = Tlv8,
Term8 = 'dec_Password'(V8, [131079]),
%%-------------------------------------------------
%% attribute pass-passwords(9) External IPMSFileTransferBodyPartType:Pass-Passwords
%%-------------------------------------------------
[V9|Tlv10] = Tlv9,
Term9 = 'dec_Pass-Passwords'(V9, [131080]),
%%-------------------------------------------------
%% attribute link-password(10) External IPMSFileTransferBodyPartType:Password
%%-------------------------------------------------
[V10|Tlv11] = Tlv10,
Term10 = 'dec_Password'(V10, [131081]),
case Tlv11 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv11}}}) % extra fields not allowed
end,
Res1 = {'Access-Passwords',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10},
Res1.
%%================================
%% Password
%%================================
enc_Password(Val) ->
enc_Password(Val, []).
enc_Password(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'graphic-string' ->
encode_restricted_string(element(2,Val), [<<25>>]);
'octet-string' ->
encode_restricted_string(element(2,Val), [<<4>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
dec_Password(Tlv) ->
dec_Password(Tlv, []).
dec_Password(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'graphic-string'
{25, V1} ->
{'graphic-string', begin
binary_to_list(decode_restricted_string(V1, []))
end
};
%% 'octet-string'
{4, V1} ->
{'octet-string', decode_octet_string(V1, [])};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
%%================================
%% Pass-Passwords
%%================================
'enc_Pass-Passwords'(Val) ->
'enc_Pass-Passwords'(Val, [<<48>>]).
'enc_Pass-Passwords'(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_Pass-Passwords_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_Pass-Passwords_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_Pass-Passwords_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = 'enc_Password'(H, []),
'enc_Pass-Passwords_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
'dec_Pass-Passwords'(Tlv) ->
'dec_Pass-Passwords'(Tlv, [16]).
'dec_Pass-Passwords'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
['dec_Password'(V1, []) || V1 <- Tlv1].
%%================================
%% Application-Entity-Title
%%================================
'enc_Application-Entity-Title'(Val) ->
'enc_Application-Entity-Title'(Val, [<<48>>]).
'enc_Application-Entity-Title'(Val, TagIn) ->
{_,Cindex1,Cindex2} = Val,
%%-------------------------------------------------
%% attribute ap-title(1) External ACSE-1:AP-title
%%-------------------------------------------------
{EncBytes1,EncLen1} = 'ACSE-1':'enc_AP-title'(Cindex1, []),
%%-------------------------------------------------
%% attribute ae-qualifier(2) External ACSE-1:AE-qualifier
%%-------------------------------------------------
{EncBytes2,EncLen2} = 'ACSE-1':'enc_AE-qualifier'(Cindex2, []),
BytesSoFar = [EncBytes1, EncBytes2],
LenSoFar = EncLen1 + EncLen2,
encode_tags(TagIn, BytesSoFar, LenSoFar).
'dec_Application-Entity-Title'(Tlv) ->
'dec_Application-Entity-Title'(Tlv, [16]).
'dec_Application-Entity-Title'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute ap-title(1) External ACSE-1:AP-title
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = 'ACSE-1':'dec_AP-title'(V1, []),
%%-------------------------------------------------
%% attribute ae-qualifier(2) External ACSE-1:AE-qualifier
%%-------------------------------------------------
[V2|Tlv3] = Tlv2,
Term2 = 'ACSE-1':'dec_AE-qualifier'(V2, []),
case Tlv3 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
end,
Res1 = {'Application-Entity-Title',Term1,Term2},
Res1.
%%================================
%% EXTERNAL
%%================================
enc_EXTERNAL(Val) ->
enc_EXTERNAL(Val, [<<40>>]).
enc_EXTERNAL(Val, TagIn) ->
NewVal = transform_to_EXTERNAL1990(Val),
{_,Cindex1,Cindex2,Cindex3,Cindex4} = NewVal,
%%-------------------------------------------------
%% attribute direct-reference(1) with type OBJECT IDENTIFIER OPTIONAL
%%-------------------------------------------------
{EncBytes1,EncLen1} = case Cindex1 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_object_identifier(Cindex1, [<<6>>])
end,
%%-------------------------------------------------
%% attribute indirect-reference(2) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex2, [<<2>>])
end,
%%-------------------------------------------------
%% attribute data-value-descriptor(3) with type ObjectDescriptor OPTIONAL
%%-------------------------------------------------
{EncBytes3,EncLen3} = case Cindex3 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_restricted_string(Cindex3, [<<7>>])
end,
%%-------------------------------------------------
%% attribute encoding(4) with type CHOICE
%%-------------------------------------------------
{EncBytes4,EncLen4} = 'enc_EXTERNAL_encoding'(Cindex4, []),
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
encode_tags(TagIn, BytesSoFar, LenSoFar).
%%================================
%% EXTERNAL_encoding
%%================================
enc_EXTERNAL_encoding(Val, TagIn) ->
{EncBytes,EncLen} = case element(1,Val) of
'single-ASN1-type' ->
encode_open_type(element(2,Val), [<<160>>]);
'octet-aligned' ->
encode_restricted_string(element(2,Val), [<<129>>]);
arbitrary ->
encode_unnamed_bit_string(element(2,Val), [<<130>>]);
Else ->
exit({error,{asn1,{invalid_choice_type,Else}}})
end,
encode_tags(TagIn, EncBytes, EncLen).
dec_EXTERNAL(Tlv) ->
dec_EXTERNAL(Tlv, [8]).
dec_EXTERNAL(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute direct-reference(1) with type OBJECT IDENTIFIER OPTIONAL
%%-------------------------------------------------
{Term1,Tlv2} = case Tlv1 of
[{6,V1}|TempTlv2] ->
{decode_object_identifier(V1, []), TempTlv2};
_ ->
{ asn1_NOVALUE, Tlv1}
end,
%%-------------------------------------------------
%% attribute indirect-reference(2) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{2,V2}|TempTlv3] ->
{decode_integer(V2, []), TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
%%-------------------------------------------------
%% attribute data-value-descriptor(3) with type ObjectDescriptor OPTIONAL
%%-------------------------------------------------
{Term3,Tlv4} = case Tlv3 of
[{7,V3}|TempTlv4] ->
{begin
binary_to_list(decode_restricted_string(V3, []))
end
, TempTlv4};
_ ->
{ asn1_NOVALUE, Tlv3}
end,
%%-------------------------------------------------
%% attribute encoding(4) with type CHOICE
%%-------------------------------------------------
[V4|Tlv5] = Tlv4,
Term4 = 'dec_EXTERNAL_encoding'(V4, []),
case Tlv5 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed
end,
OldFormat={'EXTERNAL',Term1,Term2,Term3,Term4},
transform_to_EXTERNAL1994(OldFormat).
'dec_EXTERNAL_encoding'(Tlv, TagIn) ->
Tlv1 = match_tags(Tlv, TagIn),
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
%% 'single-ASN1-type'
{131072, V1} ->
{'single-ASN1-type', decode_open_type_as_binary(V1, [])};
%% 'octet-aligned'
{131073, V1} ->
{'octet-aligned', decode_octet_string(V1, [])};
%% 'arbitrary'
{131074, V1} ->
{arbitrary, decode_native_bit_string(V1, [])};
Else ->
exit({error,{asn1,{invalid_choice_tag,Else}}})
end
.
%%================================
%% file-transfer-body-part
%%================================
'enc_file-transfer-body-part'(parameters, Val, [H|T]) ->
'enc_file-transfer-body-part_parameters'(H, Val, T);
'enc_file-transfer-body-part'(data, Val, [H|T]) ->
'enc_file-transfer-body-part_data'(H, Val, T).
'dec_file-transfer-body-part'(parameters, Bytes,[H|T]) ->
'dec_file-transfer-body-part_parameters'(H, Bytes, T);
'dec_file-transfer-body-part'(data, Bytes,[H|T]) ->
'dec_file-transfer-body-part_data'(H, Bytes, T).
%%================================
%% file-transfer-body-part_parameters
%%================================
'enc_file-transfer-body-part_parameters'('Type', Val, _RestPrimFieldName) ->
enc_FileTransferParameters(Val, [<<48>>]).
'dec_file-transfer-body-part_parameters'('Type', Bytes,_) ->
Tlv = tlv_format(Bytes),
dec_FileTransferParameters(Tlv, [16]).
tlv_format(Bytes) when is_binary(Bytes) ->
{Tlv,_} = ber_decode_nif(Bytes),
Tlv;
tlv_format(Bytes) ->
Bytes.
%%================================
%% file-transfer-body-part_data
%%================================
'enc_file-transfer-body-part_data'('Type', Val, _RestPrimFieldName) ->
enc_FileTransferData(Val, [<<48>>]).
'dec_file-transfer-body-part_data'('Type', Bytes,_) ->
Tlv = tlv_format(Bytes),
dec_FileTransferData(Tlv, [16]).
%%================================
%% CompressionAlgorithmTable
%%================================
getenc_CompressionAlgorithmTable(_) ->
fun(_, Val, _RestPrimFieldName) ->
case Val of
{asn1_OPENTYPE,Bin} when is_binary(Bin) ->
{Bin,byte_size(Bin)}
end
end.
getdec_CompressionAlgorithmTable(_) ->
fun(_,Bytes, _RestPrimFieldName) ->
case Bytes of
Bin when is_binary(Bin) ->
{asn1_OPENTYPE,Bin};
_ ->
{asn1_OPENTYPE,ber_encode(Bytes)}
end
end.
%%%
%%% Run-time functions.
%%%
'dialyzer-suppressions'(Arg) ->
ok.
ber_decode_nif(B) ->
asn1rt_nif:decode_ber_tlv(B).
ber_encode([Tlv]) ->
ber_encode(Tlv);
ber_encode(Tlv) when is_binary(Tlv) ->
Tlv;
ber_encode(Tlv) ->
asn1rt_nif:encode_ber_tlv(Tlv).
collect_parts(TlvList) ->
collect_parts(TlvList, []).
collect_parts([{_, L} | Rest], Acc) when is_list(L) ->
collect_parts(Rest, [collect_parts(L) | Acc]);
collect_parts([{3, <<Unused,Bits/binary>>} | 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, <<Unused,Bits/binary>>} | 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(<<H,T/binary>>, Av, Al) ->
dec_subidentifiers(T, 0, [Av bsl 7 + H | Al]).
decode_bitstring2(1, Unused,
<<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1,_/binary>>) ->
lists:sublist([B7, B6, B5, B4, B3, B2, B1, B0], 8 - Unused);
decode_bitstring2(Len, Unused,
<<B7:1,
B6:1,
B5:1,
B4:1,
B3:1,
B2:1,
B1:1,
B0:1,
Buffer/binary>>) ->
[B7, B6, B5, B4, B3, B2, B1, B0 |
decode_bitstring2(Len - 1, Unused, Buffer)].
decode_bitstring_NNL(BitList, NamedNumberList) ->
decode_bitstring_NNL(BitList, NamedNumberList, 0, []).
decode_bitstring_NNL([], _, _No, Result) ->
lists:reverse(Result);
decode_bitstring_NNL([B | BitList],
[{Name, No} | NamedNumberList],
No, Result) ->
if
B =:= 0 ->
decode_bitstring_NNL(BitList, NamedNumberList,
No + 1,
Result);
true ->
decode_bitstring_NNL(BitList, NamedNumberList,
No + 1,
[Name | Result])
end;
decode_bitstring_NNL([1 | BitList], NamedNumberList, No, Result) ->
decode_bitstring_NNL(BitList, NamedNumberList,
No + 1,
[{bit, No} | Result]);
decode_bitstring_NNL([0 | BitList], NamedNumberList, No, Result) ->
decode_bitstring_NNL(BitList, NamedNumberList, No + 1, Result).
decode_integer(Tlv, TagIn) ->
Bin = match_tags(Tlv, TagIn),
Len = byte_size(Bin),
<<Int:Len/signed-unit:8>> = Bin,
Int.
decode_named_bit_string(Buffer, NamedNumberList, Tags) ->
case match_and_collect(Buffer, Tags) of
<<0>> ->
[];
<<Unused,Bits/binary>> ->
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>> ->
<<>>;
<<Unused,Bits/binary>> ->
Size = bit_size(Bits) - Unused,
<<Val:Size/bitstring,_:Unused/bitstring>> = 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_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 = <<Unused,Bits/bitstring,0:Unused>>,
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.
transform_to_EXTERNAL1990(['EXTERNAL' | Rest], Acc) ->
transform_to_EXTERNAL1990(Rest, ['EXTERNAL' | Acc]);
transform_to_EXTERNAL1990([{syntax, Syntax} | Rest], Acc) ->
transform_to_EXTERNAL1990(Rest, [asn1_NOVALUE, Syntax | Acc]);
transform_to_EXTERNAL1990([{'presentation-context-id', PCid} | Rest],
Acc) ->
transform_to_EXTERNAL1990(Rest, [PCid, asn1_NOVALUE | Acc]);
transform_to_EXTERNAL1990([{'context-negotiation', Context_negot} |
Rest],
Acc) ->
{_, Presentation_Cid, Transfer_syntax} = Context_negot,
transform_to_EXTERNAL1990(Rest,
[Presentation_Cid, Transfer_syntax | Acc]);
transform_to_EXTERNAL1990([asn1_NOVALUE | Rest], Acc) ->
transform_to_EXTERNAL1990(Rest, [asn1_NOVALUE | Acc]);
transform_to_EXTERNAL1990([Data_val_desc, Data_value], Acc)
when is_list(Data_value); is_binary(Data_value) ->
list_to_tuple(lists:reverse([{'octet-aligned', Data_value},
Data_val_desc | Acc]));
transform_to_EXTERNAL1990([Data_val_desc, Data_value], Acc)
when is_binary(Data_value) ->
list_to_tuple(lists:reverse([{'single-ASN1-type', Data_value},
Data_val_desc | Acc]));
transform_to_EXTERNAL1990([Data_value], Acc)
when is_list(Data_value); is_binary(Data_value) ->
list_to_tuple(lists:reverse([{'octet-aligned', Data_value} | Acc])).
transform_to_EXTERNAL1990({_, _, _, _} = Val) ->
transform_to_EXTERNAL1990(tuple_to_list(Val), []);
transform_to_EXTERNAL1990(Val) when is_tuple(Val) ->
Val.
transform_to_EXTERNAL1994({'EXTERNAL', DRef, IndRef, Data_v_desc,
Encoding} =
V) ->
Identification =
case {DRef, IndRef} of
{DRef, asn1_NOVALUE} ->
{syntax, DRef};
{asn1_NOVALUE, IndRef} ->
{'presentation-context-id', IndRef};
_ ->
{'context-negotiation',
{'EXTERNAL_identification_context-negotiation', IndRef,
DRef}}
end,
case Encoding of
{'octet-aligned', Val} when is_list(Val); is_binary(Val) ->
{'EXTERNAL', Identification, Data_v_desc, Val};
_ ->
V
end.
unused_bitlist([], Trail, Ack) ->
{Trail + 1, Ack};
unused_bitlist([Bit | Rest], Trail, Ack) ->
unused_bitlist(Rest, Trail - 1, Bit bsl Trail bor Ack).