%% Generated by the Erlang ASN.1 BER compiler. Version: 5.1 %% Purpose: Encoding and decoding of the types in CHAT. -module('CHAT'). -compile(nowarn_unused_vars). -dialyzer(no_improper_lists). -dialyzer(no_match). -include_lib("chat/include/CHAT.hrl"). -asn1_info([{vsn,'5.1'}, {module,'CHAT'}, {options,[warnings,ber,errors, {cwd,"/Users/maxim/depot/synrc/chat/priv/proto"}, {outdir,"/Users/maxim/depot/synrc/chat/priv/proto"}, {i,"."}, {i,"/Users/maxim/depot/synrc/chat/priv/proto"}]}]). -export([encoding_rule/0,maps/0,bit_string_format/0, legacy_erlang_types/0]). -export(['dialyzer-suppressions'/1]). -export([ enc_IO/2, enc_OK/2, enc_ERROR/2, enc_P2P/2, enc_MUC/2, enc_Feature/2, enc_ServiceType/2, enc_ServiceStatus/2, enc_Service/2, enc_Register/2, enc_PresenceType/2, enc_Presence/2, enc_ContactStatus/2, enc_Contact/2, enc_RosterStatus/2, enc_Roster/2, enc_MessageType/2, enc_MessageStatus/2, enc_MessageFeed/2, enc_CHATString/2, enc_Message/2, enc_MemberStatus/2, enc_Member/2, enc_RoomType/2, enc_RoomStatus/2, enc_Room/2, enc_Server/2, enc_Profile/2, enc_OS/2, enc_AuthType/2, enc_Ack/2, enc_FileDesc/2, enc_Auth/2, enc_SearchStatus/2, enc_Criteria/2, enc_Scope/2, enc_Search/2, enc_Typing/2, enc_Friendship/2, enc_Friend/2, enc_HistoryStatus/2, enc_History/2, enc_CHATProtocol/2, enc_CHATMessage/2 ]). -export([ dec_IO/2, dec_OK/2, dec_ERROR/2, dec_P2P/2, dec_MUC/2, dec_Feature/2, dec_ServiceType/2, dec_ServiceStatus/2, dec_Service/2, dec_Register/2, dec_PresenceType/2, dec_Presence/2, dec_ContactStatus/2, dec_Contact/2, dec_RosterStatus/2, dec_Roster/2, dec_MessageType/2, dec_MessageStatus/2, dec_MessageFeed/2, dec_CHATString/2, dec_Message/2, dec_MemberStatus/2, dec_Member/2, dec_RoomType/2, dec_RoomStatus/2, dec_Room/2, dec_Server/2, dec_Profile/2, dec_OS/2, dec_AuthType/2, dec_Ack/2, dec_FileDesc/2, dec_Auth/2, dec_SearchStatus/2, dec_Criteria/2, dec_Scope/2, dec_Search/2, dec_Typing/2, dec_Friendship/2, dec_Friend/2, dec_HistoryStatus/2, dec_History/2, dec_CHATProtocol/2, dec_CHATMessage/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('IO', Data) -> enc_IO(Data); encode_disp('OK', Data) -> enc_OK(Data); encode_disp('ERROR', Data) -> enc_ERROR(Data); encode_disp('P2P', Data) -> enc_P2P(Data); encode_disp('MUC', Data) -> enc_MUC(Data); encode_disp('Feature', Data) -> enc_Feature(Data); encode_disp('ServiceType', Data) -> enc_ServiceType(Data); encode_disp('ServiceStatus', Data) -> enc_ServiceStatus(Data); encode_disp('Service', Data) -> enc_Service(Data); encode_disp('Register', Data) -> enc_Register(Data); encode_disp('PresenceType', Data) -> enc_PresenceType(Data); encode_disp('Presence', Data) -> enc_Presence(Data); encode_disp('ContactStatus', Data) -> enc_ContactStatus(Data); encode_disp('Contact', Data) -> enc_Contact(Data); encode_disp('RosterStatus', Data) -> enc_RosterStatus(Data); encode_disp('Roster', Data) -> enc_Roster(Data); encode_disp('MessageType', Data) -> enc_MessageType(Data); encode_disp('MessageStatus', Data) -> enc_MessageStatus(Data); encode_disp('MessageFeed', Data) -> enc_MessageFeed(Data); encode_disp('CHATString', Data) -> enc_CHATString(Data); encode_disp('Message', Data) -> enc_Message(Data); encode_disp('MemberStatus', Data) -> enc_MemberStatus(Data); encode_disp('Member', Data) -> enc_Member(Data); encode_disp('RoomType', Data) -> enc_RoomType(Data); encode_disp('RoomStatus', Data) -> enc_RoomStatus(Data); encode_disp('Room', Data) -> enc_Room(Data); encode_disp('Server', Data) -> enc_Server(Data); encode_disp('Profile', Data) -> enc_Profile(Data); encode_disp('OS', Data) -> enc_OS(Data); encode_disp('AuthType', Data) -> enc_AuthType(Data); encode_disp('Ack', Data) -> enc_Ack(Data); encode_disp('FileDesc', Data) -> enc_FileDesc(Data); encode_disp('Auth', Data) -> enc_Auth(Data); encode_disp('SearchStatus', Data) -> enc_SearchStatus(Data); encode_disp('Criteria', Data) -> enc_Criteria(Data); encode_disp('Scope', Data) -> enc_Scope(Data); encode_disp('Search', Data) -> enc_Search(Data); encode_disp('Typing', Data) -> enc_Typing(Data); encode_disp('Friendship', Data) -> enc_Friendship(Data); encode_disp('Friend', Data) -> enc_Friend(Data); encode_disp('HistoryStatus', Data) -> enc_HistoryStatus(Data); encode_disp('History', Data) -> enc_History(Data); encode_disp('CHATProtocol', Data) -> enc_CHATProtocol(Data); encode_disp('CHATMessage', Data) -> enc_CHATMessage(Data); encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}). decode_disp('IO', Data) -> dec_IO(Data); decode_disp('OK', Data) -> dec_OK(Data); decode_disp('ERROR', Data) -> dec_ERROR(Data); decode_disp('P2P', Data) -> dec_P2P(Data); decode_disp('MUC', Data) -> dec_MUC(Data); decode_disp('Feature', Data) -> dec_Feature(Data); decode_disp('ServiceType', Data) -> dec_ServiceType(Data); decode_disp('ServiceStatus', Data) -> dec_ServiceStatus(Data); decode_disp('Service', Data) -> dec_Service(Data); decode_disp('Register', Data) -> dec_Register(Data); decode_disp('PresenceType', Data) -> dec_PresenceType(Data); decode_disp('Presence', Data) -> dec_Presence(Data); decode_disp('ContactStatus', Data) -> dec_ContactStatus(Data); decode_disp('Contact', Data) -> dec_Contact(Data); decode_disp('RosterStatus', Data) -> dec_RosterStatus(Data); decode_disp('Roster', Data) -> dec_Roster(Data); decode_disp('MessageType', Data) -> dec_MessageType(Data); decode_disp('MessageStatus', Data) -> dec_MessageStatus(Data); decode_disp('MessageFeed', Data) -> dec_MessageFeed(Data); decode_disp('CHATString', Data) -> dec_CHATString(Data); decode_disp('Message', Data) -> dec_Message(Data); decode_disp('MemberStatus', Data) -> dec_MemberStatus(Data); decode_disp('Member', Data) -> dec_Member(Data); decode_disp('RoomType', Data) -> dec_RoomType(Data); decode_disp('RoomStatus', Data) -> dec_RoomStatus(Data); decode_disp('Room', Data) -> dec_Room(Data); decode_disp('Server', Data) -> dec_Server(Data); decode_disp('Profile', Data) -> dec_Profile(Data); decode_disp('OS', Data) -> dec_OS(Data); decode_disp('AuthType', Data) -> dec_AuthType(Data); decode_disp('Ack', Data) -> dec_Ack(Data); decode_disp('FileDesc', Data) -> dec_FileDesc(Data); decode_disp('Auth', Data) -> dec_Auth(Data); decode_disp('SearchStatus', Data) -> dec_SearchStatus(Data); decode_disp('Criteria', Data) -> dec_Criteria(Data); decode_disp('Scope', Data) -> dec_Scope(Data); decode_disp('Search', Data) -> dec_Search(Data); decode_disp('Typing', Data) -> dec_Typing(Data); decode_disp('Friendship', Data) -> dec_Friendship(Data); decode_disp('Friend', Data) -> dec_Friend(Data); decode_disp('HistoryStatus', Data) -> dec_HistoryStatus(Data); decode_disp('History', Data) -> dec_History(Data); decode_disp('CHATProtocol', Data) -> dec_CHATProtocol(Data); decode_disp('CHATMessage', Data) -> dec_CHATMessage(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. %%================================ %% IO %%================================ enc_IO(Val) -> enc_IO(Val, [<<48>>]). enc_IO(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute data(1) with type UniversalString %%------------------------------------------------- {EncBytes1,EncLen1} = encode_universal_string(Cindex1, [<<28>>]), %%------------------------------------------------- %% attribute code(2) with type UniversalString %%------------------------------------------------- {EncBytes2,EncLen2} = encode_universal_string(Cindex2, [<<28>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_IO(Tlv) -> dec_IO(Tlv, [16]). dec_IO(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute data(1) with type UniversalString %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_universal_string(V1, [28]), %%------------------------------------------------- %% attribute code(2) with type UniversalString %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_universal_string(V2, [28]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'IO',Term1,Term2}, Res1. %%================================ %% OK %%================================ enc_OK(Val) -> enc_OK(Val, [<<48>>]). enc_OK(Val, TagIn) -> {_,Cindex1} = Val, %%------------------------------------------------- %% attribute data(1) with type UniversalString %%------------------------------------------------- {EncBytes1,EncLen1} = encode_universal_string(Cindex1, [<<28>>]), BytesSoFar = [EncBytes1], LenSoFar = EncLen1, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_OK(Tlv) -> dec_OK(Tlv, [16]). dec_OK(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute data(1) with type UniversalString %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_universal_string(V1, [28]), case Tlv2 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv2}}}) % extra fields not allowed end, Res1 = {'OK',Term1}, Res1. %%================================ %% ERROR %%================================ enc_ERROR(Val) -> enc_ERROR(Val, [<<48>>]). enc_ERROR(Val, TagIn) -> {_,Cindex1} = Val, %%------------------------------------------------- %% attribute code(1) with type UniversalString %%------------------------------------------------- {EncBytes1,EncLen1} = encode_universal_string(Cindex1, [<<28>>]), BytesSoFar = [EncBytes1], LenSoFar = EncLen1, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_ERROR(Tlv) -> dec_ERROR(Tlv, [16]). dec_ERROR(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute code(1) with type UniversalString %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_universal_string(V1, [28]), case Tlv2 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv2}}}) % extra fields not allowed end, Res1 = {'ERROR',Term1}, Res1. %%================================ %% P2P %%================================ enc_P2P(Val) -> enc_P2P(Val, [<<48>>]). enc_P2P(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute from(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute to(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_P2P(Tlv) -> dec_P2P(Tlv, [16]). dec_P2P(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute from(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute to(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'P2P',Term1,Term2}, Res1. %%================================ %% MUC %%================================ enc_MUC(Val) -> enc_MUC(Val, [<<48>>]). enc_MUC(Val, TagIn) -> {_,Cindex1} = Val, %%------------------------------------------------- %% attribute room(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), BytesSoFar = [EncBytes1], LenSoFar = EncLen1, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_MUC(Tlv) -> dec_MUC(Tlv, [16]). dec_MUC(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute room(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), case Tlv2 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv2}}}) % extra fields not allowed end, Res1 = {'MUC',Term1}, Res1. %%================================ %% Feature %%================================ enc_Feature(Val) -> enc_Feature(Val, [<<48>>]). enc_Feature(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute key(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute value(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute group(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Feature(Tlv) -> dec_Feature(Tlv, [16]). dec_Feature(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute key(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute value(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute group(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'Feature',Term1,Term2,Term3,Term4}, Res1. %%================================ %% ServiceType %%================================ enc_ServiceType(Val) -> enc_ServiceType(Val, [<<10>>]). enc_ServiceType(Val, TagIn) -> case Val of synrc -> encode_tags(TagIn, [0], 1); aws -> encode_tags(TagIn, [1], 1); gcp -> encode_tags(TagIn, [2], 1); azure -> encode_tags(TagIn, [3], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_ServiceType(Tlv) -> dec_ServiceType(Tlv, [10]). dec_ServiceType(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 0 -> synrc; 1 -> aws; 2 -> gcp; 3 -> azure; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% ServiceStatus %%================================ enc_ServiceStatus(Val) -> enc_ServiceStatus(Val, [<<10>>]). enc_ServiceStatus(Val, TagIn) -> case Val of verified -> encode_tags(TagIn, [0], 1); added -> encode_tags(TagIn, [1], 1); add -> encode_tags(TagIn, [2], 1); remove -> encode_tags(TagIn, [3], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_ServiceStatus(Tlv) -> dec_ServiceStatus(Tlv, [10]). dec_ServiceStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 0 -> verified; 1 -> added; 2 -> add; 3 -> remove; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Service %%================================ enc_Service(Val) -> enc_Service(Val, [<<48>>]). enc_Service(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute type(2) with type ENUMERATED %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of synrc -> encode_tags([<<10>>], [0], 1); aws -> encode_tags([<<10>>], [1], 1); gcp -> encode_tags([<<10>>], [2], 1); azure -> encode_tags([<<10>>], [3], 1); Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}}) end, %%------------------------------------------------- %% attribute data(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute login(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute password(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute expiration(6) with type INTEGER %%------------------------------------------------- {EncBytes6,EncLen6} = encode_integer(Cindex6, [<<2>>]), %%------------------------------------------------- %% attribute status(7) with type ENUMERATED %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of verified -> encode_tags([<<10>>], [0], 1); added -> encode_tags([<<10>>], [1], 1); add -> encode_tags([<<10>>], [2], 1); remove -> encode_tags([<<10>>], [3], 1); Enumval7 -> exit({error,{asn1, {enumerated_not_in_range,Enumval7}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Service(Tlv) -> dec_Service(Tlv, [16]). dec_Service(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute type(2) with type ENUMERATED %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = case decode_integer(V2, [10]) of 0 -> synrc; 1 -> aws; 2 -> gcp; 3 -> azure; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute data(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute login(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute password(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute expiration(6) with type INTEGER %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = decode_integer(V6, [2]), %%------------------------------------------------- %% attribute status(7) with type ENUMERATED %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = case decode_integer(V7, [10]) of 0 -> verified; 1 -> added; 2 -> add; 3 -> remove; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, case Tlv8 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv8}}}) % extra fields not allowed end, Res1 = {'Service',Term1,Term2,Term3,Term4,Term5,Term6,Term7}, Res1. %%================================ %% Register %%================================ enc_Register(Val) -> enc_Register(Val, [<<48>>]). enc_Register(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute csr(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute password(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Register(Tlv) -> dec_Register(Tlv, [16]). dec_Register(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute csr(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute password(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'Register',Term1,Term2,Term3}, Res1. %%================================ %% PresenceType %%================================ enc_PresenceType(Val) -> enc_PresenceType(Val, [<<10>>]). enc_PresenceType(Val, TagIn) -> case Val of offline -> encode_tags(TagIn, [1], 1); online -> encode_tags(TagIn, [2], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_PresenceType(Tlv) -> dec_PresenceType(Tlv, [10]). dec_PresenceType(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> offline; 2 -> online; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Presence %%================================ enc_Presence(Val) -> enc_Presence(Val, [<<48>>]). enc_Presence(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute status(2) with type ENUMERATED %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of offline -> encode_tags([<<10>>], [1], 1); online -> encode_tags([<<10>>], [2], 1); Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}}) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Presence(Tlv) -> dec_Presence(Tlv, [16]). dec_Presence(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute status(2) with type ENUMERATED %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = case decode_integer(V2, [10]) of 1 -> offline; 2 -> online; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'Presence',Term1,Term2}, Res1. %%================================ %% ContactStatus %%================================ enc_ContactStatus(Val) -> enc_ContactStatus(Val, [<<10>>]). enc_ContactStatus(Val, TagIn) -> case Val of request -> encode_tags(TagIn, [1], 1); authorization -> encode_tags(TagIn, [2], 1); ignore -> encode_tags(TagIn, [3], 1); internal -> encode_tags(TagIn, [4], 1); friend -> encode_tags(TagIn, [5], 1); lastmsg -> encode_tags(TagIn, [6], 1); ban -> encode_tags(TagIn, [7], 1); banned -> encode_tags(TagIn, [8], 1); deleted -> encode_tags(TagIn, [9], 1); nonexised -> encode_tags(TagIn, [10], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_ContactStatus(Tlv) -> dec_ContactStatus(Tlv, [10]). dec_ContactStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> request; 2 -> authorization; 3 -> ignore; 4 -> internal; 5 -> friend; 6 -> lastmsg; 7 -> ban; 8 -> banned; 9 -> deleted; 10 -> nonexised; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Contact %%================================ enc_Contact(Val) -> enc_Contact(Val, [<<48>>]). enc_Contact(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12} = Val, %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute avatar(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute names(3) with type SEQUENCE OF %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_Contact_names'(Cindex3, [<<48>>]), %%------------------------------------------------- %% attribute phone(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute surnames(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_Contact_surnames'(Cindex5, [<<48>>]), %%------------------------------------------------- %% attribute lastmsg(6) External CHAT:Message %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Message'(Cindex6, [<<48>>]), %%------------------------------------------------- %% attribute presence(7) with type ENUMERATED %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of offline -> encode_tags([<<10>>], [1], 1); online -> encode_tags([<<10>>], [2], 1); Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}}) end, %%------------------------------------------------- %% attribute update(8) with type INTEGER %%------------------------------------------------- {EncBytes8,EncLen8} = encode_integer(Cindex8, [<<2>>]), %%------------------------------------------------- %% attribute created(9) with type INTEGER %%------------------------------------------------- {EncBytes9,EncLen9} = encode_integer(Cindex9, [<<2>>]), %%------------------------------------------------- %% attribute settings(10) with type SEQUENCE OF %%------------------------------------------------- {EncBytes10,EncLen10} = 'enc_Contact_settings'(Cindex10, [<<48>>]), %%------------------------------------------------- %% attribute services(11) with type SEQUENCE OF %%------------------------------------------------- {EncBytes11,EncLen11} = 'enc_Contact_services'(Cindex11, [<<48>>]), %%------------------------------------------------- %% attribute status(12) with type ENUMERATED %%------------------------------------------------- {EncBytes12,EncLen12} = case Cindex12 of request -> encode_tags([<<10>>], [1], 1); authorization -> encode_tags([<<10>>], [2], 1); ignore -> encode_tags([<<10>>], [3], 1); internal -> encode_tags([<<10>>], [4], 1); friend -> encode_tags([<<10>>], [5], 1); lastmsg -> encode_tags([<<10>>], [6], 1); ban -> encode_tags([<<10>>], [7], 1); banned -> encode_tags([<<10>>], [8], 1); deleted -> encode_tags([<<10>>], [9], 1); nonexised -> encode_tags([<<10>>], [10], 1); Enumval7 -> exit({error,{asn1, {enumerated_not_in_range,Enumval7}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Contact_names %%================================ enc_Contact_names(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Contact_names_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Contact_names_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Contact_names_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Contact_names_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Contact_surnames %%================================ enc_Contact_surnames(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Contact_surnames_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Contact_surnames_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Contact_surnames_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Contact_surnames_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Contact_settings %%================================ enc_Contact_settings(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Contact_settings_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Contact_settings_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Contact_settings_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_Contact_settings_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Contact_services %%================================ enc_Contact_services(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Contact_services_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Contact_services_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Contact_services_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Service'(H, [<<48>>]), 'enc_Contact_services_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Contact(Tlv) -> dec_Contact(Tlv, [16]). dec_Contact(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute avatar(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute names(3) with type SEQUENCE OF %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_Contact_names'(V3, [16]), %%------------------------------------------------- %% attribute phone(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute surnames(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_Contact_surnames'(V5, [16]), %%------------------------------------------------- %% attribute lastmsg(6) External CHAT:Message %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Message'(V6, [16]), %%------------------------------------------------- %% attribute presence(7) with type ENUMERATED %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = case decode_integer(V7, [10]) of 1 -> offline; 2 -> online; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute update(8) with type INTEGER %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = decode_integer(V8, [2]), %%------------------------------------------------- %% attribute created(9) with type INTEGER %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = decode_integer(V9, [2]), %%------------------------------------------------- %% attribute settings(10) with type SEQUENCE OF %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = 'dec_Contact_settings'(V10, [16]), %%------------------------------------------------- %% attribute services(11) with type SEQUENCE OF %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = 'dec_Contact_services'(V11, [16]), %%------------------------------------------------- %% attribute status(12) with type ENUMERATED %%------------------------------------------------- [V12|Tlv13] = Tlv12, Term12 = case decode_integer(V12, [10]) of 1 -> request; 2 -> authorization; 3 -> ignore; 4 -> internal; 5 -> friend; 6 -> lastmsg; 7 -> ban; 8 -> banned; 9 -> deleted; 10 -> nonexised; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, case Tlv13 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv13}}}) % extra fields not allowed end, Res1 = {'Contact',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12}, Res1. 'dec_Contact_names'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Contact_surnames'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Contact_settings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || V1 <- Tlv1]. 'dec_Contact_services'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Service'(V1, [16]) || V1 <- Tlv1]. %%================================ %% RosterStatus %%================================ enc_RosterStatus(Val) -> enc_RosterStatus(Val, [<<10>>]). enc_RosterStatus(Val, TagIn) -> case Val of get -> encode_tags(TagIn, [1], 1); create -> encode_tags(TagIn, [2], 1); del -> encode_tags(TagIn, [3], 1); remove -> encode_tags(TagIn, [4], 1); nick -> encode_tags(TagIn, [5], 1); search -> encode_tags(TagIn, [6], 1); contact -> encode_tags(TagIn, [7], 1); add -> encode_tags(TagIn, [8], 1); update -> encode_tags(TagIn, [9], 1); list -> encode_tags(TagIn, [10], 1); patch -> encode_tags(TagIn, [11], 1); lastmsg -> encode_tags(TagIn, [12], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_RosterStatus(Tlv) -> dec_RosterStatus(Tlv, [10]). dec_RosterStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> get; 2 -> create; 3 -> del; 4 -> remove; 5 -> nick; 6 -> search; 7 -> contact; 8 -> add; 9 -> update; 10 -> list; 11 -> patch; 12 -> lastmsg; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Roster %%================================ enc_Roster(Val) -> enc_Roster(Val, [<<48>>]). enc_Roster(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute nickname(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute update(3) with type INTEGER %%------------------------------------------------- {EncBytes3,EncLen3} = encode_integer(Cindex3, [<<2>>]), %%------------------------------------------------- %% attribute contacts(4) with type SEQUENCE OF %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_Roster_contacts'(Cindex4, [<<48>>]), %%------------------------------------------------- %% attribute topics(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_Roster_topics'(Cindex5, [<<48>>]), %%------------------------------------------------- %% attribute status(6) with type ENUMERATED %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of get -> encode_tags([<<10>>], [1], 1); create -> encode_tags([<<10>>], [2], 1); del -> encode_tags([<<10>>], [3], 1); remove -> encode_tags([<<10>>], [4], 1); nick -> encode_tags([<<10>>], [5], 1); search -> encode_tags([<<10>>], [6], 1); contact -> encode_tags([<<10>>], [7], 1); add -> encode_tags([<<10>>], [8], 1); update -> encode_tags([<<10>>], [9], 1); list -> encode_tags([<<10>>], [10], 1); patch -> encode_tags([<<10>>], [11], 1); lastmsg -> encode_tags([<<10>>], [12], 1); Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Roster_contacts %%================================ enc_Roster_contacts(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Roster_contacts_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Roster_contacts_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Roster_contacts_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Contact'(H, [<<48>>]), 'enc_Roster_contacts_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Roster_topics %%================================ enc_Roster_topics(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Roster_topics_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Roster_topics_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Roster_topics_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Room'(H, [<<48>>]), 'enc_Roster_topics_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Roster(Tlv) -> dec_Roster(Tlv, [16]). dec_Roster(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute nickname(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute update(3) with type INTEGER %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_integer(V3, [2]), %%------------------------------------------------- %% attribute contacts(4) with type SEQUENCE OF %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_Roster_contacts'(V4, [16]), %%------------------------------------------------- %% attribute topics(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_Roster_topics'(V5, [16]), %%------------------------------------------------- %% attribute status(6) with type ENUMERATED %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = case decode_integer(V6, [10]) of 1 -> get; 2 -> create; 3 -> del; 4 -> remove; 5 -> nick; 6 -> search; 7 -> contact; 8 -> add; 9 -> update; 10 -> list; 11 -> patch; 12 -> lastmsg; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, case Tlv7 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowed end, Res1 = {'Roster',Term1,Term2,Term3,Term4,Term5,Term6}, Res1. 'dec_Roster_contacts'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Contact'(V1, [16]) || V1 <- Tlv1]. 'dec_Roster_topics'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Room'(V1, [16]) || V1 <- Tlv1]. %%================================ %% MessageType %%================================ enc_MessageType(Val) -> enc_MessageType(Val, [<<10>>]). enc_MessageType(Val, TagIn) -> case Val of sys -> encode_tags(TagIn, [1], 1); reply -> encode_tags(TagIn, [2], 1); forward -> encode_tags(TagIn, [3], 1); read -> encode_tags(TagIn, [4], 1); edited -> encode_tags(TagIn, [5], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_MessageType(Tlv) -> dec_MessageType(Tlv, [10]). dec_MessageType(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> sys; 2 -> reply; 3 -> forward; 4 -> read; 5 -> edited; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% MessageStatus %%================================ enc_MessageStatus(Val) -> enc_MessageStatus(Val, [<<10>>]). enc_MessageStatus(Val, TagIn) -> case Val of async -> encode_tags(TagIn, [1], 1); delete -> encode_tags(TagIn, [2], 1); clear -> encode_tags(TagIn, [3], 1); update -> encode_tags(TagIn, [4], 1); edit -> encode_tags(TagIn, [5], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_MessageStatus(Tlv) -> dec_MessageStatus(Tlv, [10]). dec_MessageStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> async; 2 -> delete; 3 -> clear; 4 -> update; 5 -> edit; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% MessageFeed %%================================ enc_MessageFeed(Val) -> enc_MessageFeed(Val, []). enc_MessageFeed(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of p2p -> 'enc_P2P'(element(2,Val), [<<160>>]); muc -> 'enc_MUC'(element(2,Val), [<<161>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). dec_MessageFeed(Tlv) -> dec_MessageFeed(Tlv, []). dec_MessageFeed(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'p2p' {131072, V1} -> {p2p, 'dec_P2P'(V1, [])}; %% 'muc' {131073, V1} -> {muc, 'dec_MUC'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . %%================================ %% CHATString %%================================ enc_CHATString(Val) -> enc_CHATString(Val, [<<4>>]). enc_CHATString(Val, TagIn) -> encode_restricted_string(Val, TagIn). dec_CHATString(Tlv) -> dec_CHATString(Tlv, [4]). dec_CHATString(Tlv, TagIn) -> decode_octet_string(Tlv, TagIn). %%================================ %% Message %%================================ enc_Message(Val) -> enc_Message(Val, [<<48>>]). enc_Message(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12,Cindex13} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute feed(2) External CHAT:MessageFeed %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_MessageFeed'(Cindex2, []), %%------------------------------------------------- %% attribute signature(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute from(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute to(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute created(6) with type INTEGER %%------------------------------------------------- {EncBytes6,EncLen6} = encode_integer(Cindex6, [<<2>>]), %%------------------------------------------------- %% attribute files(7) with type SEQUENCE OF %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_Message_files'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute type(8) with type ENUMERATED %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of sys -> encode_tags([<<10>>], [1], 1); reply -> encode_tags([<<10>>], [2], 1); forward -> encode_tags([<<10>>], [3], 1); read -> encode_tags([<<10>>], [4], 1); edited -> encode_tags([<<10>>], [5], 1); Enumval6 -> exit({error,{asn1, {enumerated_not_in_range,Enumval6}}}) end, %%------------------------------------------------- %% attribute link(9) with type CHOICE %%------------------------------------------------- {EncBytes9,EncLen9} = 'enc_Message_link'(Cindex9, []), %%------------------------------------------------- %% attribute seenby(10) with type OCTET STRING %%------------------------------------------------- {EncBytes10,EncLen10} = encode_restricted_string(Cindex10, [<<4>>]), %%------------------------------------------------- %% attribute repliedby(11) with type OCTET STRING %%------------------------------------------------- {EncBytes11,EncLen11} = encode_restricted_string(Cindex11, [<<4>>]), %%------------------------------------------------- %% attribute mentioned(12) with type SEQUENCE OF %%------------------------------------------------- {EncBytes12,EncLen12} = 'enc_Message_mentioned'(Cindex12, [<<48>>]), %%------------------------------------------------- %% attribute status(13) with type ENUMERATED DEFAULT = clear %%------------------------------------------------- {EncBytes13,EncLen13} = case Cindex13 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex13 =:= clear -> {<<>>,0}; _ -> case Cindex13 of async -> encode_tags([<<10>>], [1], 1); delete -> encode_tags([<<10>>], [2], 1); clear -> encode_tags([<<10>>], [3], 1); update -> encode_tags([<<10>>], [4], 1); edit -> encode_tags([<<10>>], [5], 1); Enumval9 -> exit({error,{asn1, {enumerated_not_in_range,Enumval9}}}) end end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Message_files %%================================ enc_Message_files(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Message_files_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Message_files_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Message_files_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_FileDesc'(H, [<<48>>]), 'enc_Message_files_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Message_link %%================================ enc_Message_link(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of empty -> encode_null(element(2,Val), [<<129>>]); message -> 'enc_Message'(element(2,Val), [<<162>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% Message_mentioned %%================================ enc_Message_mentioned(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Message_mentioned_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Message_mentioned_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Message_mentioned_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Message_mentioned_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Message(Tlv) -> dec_Message(Tlv, [16]). dec_Message(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute feed(2) External CHAT:MessageFeed %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_MessageFeed'(V2, []), %%------------------------------------------------- %% attribute signature(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute from(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute to(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute created(6) with type INTEGER %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = decode_integer(V6, [2]), %%------------------------------------------------- %% attribute files(7) with type SEQUENCE OF %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_Message_files'(V7, [16]), %%------------------------------------------------- %% attribute type(8) with type ENUMERATED %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = case decode_integer(V8, [10]) of 1 -> sys; 2 -> reply; 3 -> forward; 4 -> read; 5 -> edited; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute link(9) with type CHOICE %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = 'dec_Message_link'(V9, []), %%------------------------------------------------- %% attribute seenby(10) with type OCTET STRING %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = decode_octet_string(V10, [4]), %%------------------------------------------------- %% attribute repliedby(11) with type OCTET STRING %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = decode_octet_string(V11, [4]), %%------------------------------------------------- %% attribute mentioned(12) with type SEQUENCE OF %%------------------------------------------------- [V12|Tlv13] = Tlv12, Term12 = 'dec_Message_mentioned'(V12, [16]), %%------------------------------------------------- %% attribute status(13) with type ENUMERATED DEFAULT = clear %%------------------------------------------------- {Term13,Tlv14} = case Tlv13 of [{10,V13}|TempTlv14] -> {case decode_integer(V13, []) of 1 -> async; 2 -> delete; 3 -> clear; 4 -> update; 5 -> edit; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, TempTlv14}; _ -> {clear,Tlv13} end, case Tlv14 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv14}}}) % extra fields not allowed end, Res1 = {'Message',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12,Term13}, Res1. 'dec_Message_files'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_FileDesc'(V1, [16]) || V1 <- Tlv1]. 'dec_Message_link'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'empty' {131073, V1} -> {empty, decode_null(V1, [])}; %% 'message' {131074, V1} -> {message, 'dec_Message'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_Message_mentioned'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. %%================================ %% MemberStatus %%================================ enc_MemberStatus(Val) -> enc_MemberStatus(Val, [<<10>>]). enc_MemberStatus(Val, TagIn) -> case Val of admin -> encode_tags(TagIn, [1], 1); member -> encode_tags(TagIn, [2], 1); removed -> encode_tags(TagIn, [3], 1); patch -> encode_tags(TagIn, [4], 1); owner -> encode_tags(TagIn, [5], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_MemberStatus(Tlv) -> dec_MemberStatus(Tlv, [10]). dec_MemberStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> admin; 2 -> member; 3 -> removed; 4 -> patch; 5 -> owner; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Member %%================================ enc_Member(Val) -> enc_Member(Val, [<<48>>]). enc_Member(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12,Cindex13} = Val, %%------------------------------------------------- %% attribute id(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>]), %%------------------------------------------------- %% attribute feed(2) with type CHOICE %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_Member_feed'(Cindex2, []), %%------------------------------------------------- %% attribute feeds(3) with type SEQUENCE OF %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_Member_feeds'(Cindex3, [<<48>>]), %%------------------------------------------------- %% attribute phone(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute avatar(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute names(6) with type SEQUENCE OF %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Member_names'(Cindex6, [<<48>>]), %%------------------------------------------------- %% attribute surnames(7) with type SEQUENCE OF %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_Member_surnames'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute alias(8) with type OCTET STRING %%------------------------------------------------- {EncBytes8,EncLen8} = encode_restricted_string(Cindex8, [<<4>>]), %%------------------------------------------------- %% attribute update(9) with type INTEGER %%------------------------------------------------- {EncBytes9,EncLen9} = encode_integer(Cindex9, [<<2>>]), %%------------------------------------------------- %% attribute settings(10) with type SEQUENCE OF %%------------------------------------------------- {EncBytes10,EncLen10} = 'enc_Member_settings'(Cindex10, [<<48>>]), %%------------------------------------------------- %% attribute services(11) with type SEQUENCE OF %%------------------------------------------------- {EncBytes11,EncLen11} = 'enc_Member_services'(Cindex11, [<<48>>]), %%------------------------------------------------- %% attribute presence(12) with type ENUMERATED %%------------------------------------------------- {EncBytes12,EncLen12} = case Cindex12 of offline -> encode_tags([<<10>>], [1], 1); online -> encode_tags([<<10>>], [2], 1); Enumval6 -> exit({error,{asn1, {enumerated_not_in_range,Enumval6}}}) end, %%------------------------------------------------- %% attribute status(13) with type ENUMERATED %%------------------------------------------------- {EncBytes13,EncLen13} = case Cindex13 of admin -> encode_tags([<<10>>], [1], 1); member -> encode_tags([<<10>>], [2], 1); removed -> encode_tags([<<10>>], [3], 1); patch -> encode_tags([<<10>>], [4], 1); owner -> encode_tags([<<10>>], [5], 1); Enumval7 -> exit({error,{asn1, {enumerated_not_in_range,Enumval7}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Member_feed %%================================ enc_Member_feed(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of p2p -> 'enc_P2P'(element(2,Val), [<<160>>]); muc -> 'enc_MUC'(element(2,Val), [<<161>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% Member_feeds %%================================ enc_Member_feeds(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Member_feeds_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Member_feeds_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Member_feeds_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Member_feeds_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Member_names %%================================ enc_Member_names(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Member_names_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Member_names_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Member_names_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Member_names_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Member_surnames %%================================ enc_Member_surnames(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Member_surnames_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Member_surnames_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Member_surnames_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Member_surnames_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Member_settings %%================================ enc_Member_settings(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Member_settings_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Member_settings_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Member_settings_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_Member_settings_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Member_services %%================================ enc_Member_services(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Member_services_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Member_services_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Member_services_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Service'(H, [<<48>>]), 'enc_Member_services_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Member(Tlv) -> dec_Member(Tlv, [16]). dec_Member(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute id(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_integer(V1, [2]), %%------------------------------------------------- %% attribute feed(2) with type CHOICE %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_Member_feed'(V2, []), %%------------------------------------------------- %% attribute feeds(3) with type SEQUENCE OF %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_Member_feeds'(V3, [16]), %%------------------------------------------------- %% attribute phone(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute avatar(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute names(6) with type SEQUENCE OF %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Member_names'(V6, [16]), %%------------------------------------------------- %% attribute surnames(7) with type SEQUENCE OF %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_Member_surnames'(V7, [16]), %%------------------------------------------------- %% attribute alias(8) with type OCTET STRING %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = decode_octet_string(V8, [4]), %%------------------------------------------------- %% attribute update(9) with type INTEGER %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = decode_integer(V9, [2]), %%------------------------------------------------- %% attribute settings(10) with type SEQUENCE OF %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = 'dec_Member_settings'(V10, [16]), %%------------------------------------------------- %% attribute services(11) with type SEQUENCE OF %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = 'dec_Member_services'(V11, [16]), %%------------------------------------------------- %% attribute presence(12) with type ENUMERATED %%------------------------------------------------- [V12|Tlv13] = Tlv12, Term12 = case decode_integer(V12, [10]) of 1 -> offline; 2 -> online; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute status(13) with type ENUMERATED %%------------------------------------------------- [V13|Tlv14] = Tlv13, Term13 = case decode_integer(V13, [10]) of 1 -> admin; 2 -> member; 3 -> removed; 4 -> patch; 5 -> owner; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, case Tlv14 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv14}}}) % extra fields not allowed end, Res1 = {'Member',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12,Term13}, Res1. 'dec_Member_feed'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'p2p' {131072, V1} -> {p2p, 'dec_P2P'(V1, [])}; %% 'muc' {131073, V1} -> {muc, 'dec_MUC'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_Member_feeds'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Member_names'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Member_surnames'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Member_settings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || V1 <- Tlv1]. 'dec_Member_services'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Service'(V1, [16]) || V1 <- Tlv1]. %%================================ %% RoomType %%================================ enc_RoomType(Val) -> enc_RoomType(Val, [<<10>>]). enc_RoomType(Val, TagIn) -> case Val of group -> encode_tags(TagIn, [1], 1); channel -> encode_tags(TagIn, [2], 1); call -> encode_tags(TagIn, [3], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_RoomType(Tlv) -> dec_RoomType(Tlv, [10]). dec_RoomType(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> group; 2 -> channel; 3 -> call; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% RoomStatus %%================================ enc_RoomStatus(Val) -> enc_RoomStatus(Val, [<<10>>]). enc_RoomStatus(Val, TagIn) -> case Val of create -> encode_tags(TagIn, [1], 1); leave -> encode_tags(TagIn, [2], 1); add -> encode_tags(TagIn, [3], 1); remove -> encode_tags(TagIn, [4], 1); removed -> encode_tags(TagIn, [5], 1); join -> encode_tags(TagIn, [6], 1); joined -> encode_tags(TagIn, [7], 1); info -> encode_tags(TagIn, [8], 1); patch -> encode_tags(TagIn, [9], 1); get -> encode_tags(TagIn, [10], 1); delete -> encode_tags(TagIn, [11], 1); lastmsg -> encode_tags(TagIn, [12], 1); mute -> encode_tags(TagIn, [13], 1); unmute -> encode_tags(TagIn, [14], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_RoomStatus(Tlv) -> dec_RoomStatus(Tlv, [10]). dec_RoomStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> create; 2 -> leave; 3 -> add; 4 -> remove; 5 -> removed; 6 -> join; 7 -> joined; 8 -> info; 9 -> patch; 10 -> get; 11 -> delete; 12 -> lastmsg; 13 -> mute; 14 -> unmute; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Room %%================================ enc_Room(Val) -> enc_Room(Val, [<<48>>]). enc_Room(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12,Cindex13,Cindex14,Cindex15,Cindex16,Cindex17} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute name(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute links(3) with type SEQUENCE OF %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_Room_links'(Cindex3, [<<48>>]), %%------------------------------------------------- %% attribute description(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute settings(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_Room_settings'(Cindex5, [<<48>>]), %%------------------------------------------------- %% attribute members(6) with type SEQUENCE OF %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Room_members'(Cindex6, [<<48>>]), %%------------------------------------------------- %% attribute admins(7) with type SEQUENCE OF %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_Room_admins'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute data(8) with type SEQUENCE OF %%------------------------------------------------- {EncBytes8,EncLen8} = 'enc_Room_data'(Cindex8, [<<48>>]), %%------------------------------------------------- %% attribute type(9) with type ENUMERATED %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of group -> encode_tags([<<10>>], [1], 1); channel -> encode_tags([<<10>>], [2], 1); call -> encode_tags([<<10>>], [3], 1); Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}}) end, %%------------------------------------------------- %% attribute tos(10) with type OCTET STRING %%------------------------------------------------- {EncBytes10,EncLen10} = encode_restricted_string(Cindex10, [<<4>>]), %%------------------------------------------------- %% attribute tosupdate(11) with type INTEGER %%------------------------------------------------- {EncBytes11,EncLen11} = encode_integer(Cindex11, [<<2>>]), %%------------------------------------------------- %% attribute unread(12) with type INTEGER %%------------------------------------------------- {EncBytes12,EncLen12} = encode_integer(Cindex12, [<<2>>]), %%------------------------------------------------- %% attribute mentions(13) with type SEQUENCE OF %%------------------------------------------------- {EncBytes13,EncLen13} = 'enc_Room_mentions'(Cindex13, [<<48>>]), %%------------------------------------------------- %% attribute lastmsg(14) External CHAT:Message %%------------------------------------------------- {EncBytes14,EncLen14} = 'enc_Message'(Cindex14, [<<48>>]), %%------------------------------------------------- %% attribute update(15) with type INTEGER %%------------------------------------------------- {EncBytes15,EncLen15} = encode_integer(Cindex15, [<<2>>]), %%------------------------------------------------- %% attribute created(16) with type INTEGER %%------------------------------------------------- {EncBytes16,EncLen16} = encode_integer(Cindex16, [<<2>>]), %%------------------------------------------------- %% attribute status(17) with type ENUMERATED %%------------------------------------------------- {EncBytes17,EncLen17} = case Cindex17 of create -> encode_tags([<<10>>], [1], 1); leave -> encode_tags([<<10>>], [2], 1); add -> encode_tags([<<10>>], [3], 1); remove -> encode_tags([<<10>>], [4], 1); removed -> encode_tags([<<10>>], [5], 1); join -> encode_tags([<<10>>], [6], 1); joined -> encode_tags([<<10>>], [7], 1); info -> encode_tags([<<10>>], [8], 1); patch -> encode_tags([<<10>>], [9], 1); get -> encode_tags([<<10>>], [10], 1); delete -> encode_tags([<<10>>], [11], 1); lastmsg -> encode_tags([<<10>>], [12], 1); mute -> encode_tags([<<10>>], [13], 1); unmute -> encode_tags([<<10>>], [14], 1); Enumval10 -> exit({error,{asn1, {enumerated_not_in_range,Enumval10}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13, EncBytes14, EncBytes15, EncBytes16, EncBytes17], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13 + EncLen14 + EncLen15 + EncLen16 + EncLen17, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Room_links %%================================ enc_Room_links(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Room_links_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Room_links_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Room_links_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Room_links_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Room_settings %%================================ enc_Room_settings(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Room_settings_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Room_settings_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Room_settings_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_Room_settings_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Room_members %%================================ enc_Room_members(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Room_members_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Room_members_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Room_members_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Member'(H, [<<48>>]), 'enc_Room_members_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Room_admins %%================================ enc_Room_admins(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Room_admins_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Room_admins_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Room_admins_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Member'(H, [<<48>>]), 'enc_Room_admins_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Room_data %%================================ enc_Room_data(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Room_data_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Room_data_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Room_data_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_FileDesc'(H, [<<48>>]), 'enc_Room_data_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Room_mentions %%================================ enc_Room_mentions(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Room_mentions_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Room_mentions_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Room_mentions_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_integer(H, [<<2>>]), 'enc_Room_mentions_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Room(Tlv) -> dec_Room(Tlv, [16]). dec_Room(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute name(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute links(3) with type SEQUENCE OF %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_Room_links'(V3, [16]), %%------------------------------------------------- %% attribute description(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute settings(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_Room_settings'(V5, [16]), %%------------------------------------------------- %% attribute members(6) with type SEQUENCE OF %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Room_members'(V6, [16]), %%------------------------------------------------- %% attribute admins(7) with type SEQUENCE OF %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_Room_admins'(V7, [16]), %%------------------------------------------------- %% attribute data(8) with type SEQUENCE OF %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = 'dec_Room_data'(V8, [16]), %%------------------------------------------------- %% attribute type(9) with type ENUMERATED %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = case decode_integer(V9, [10]) of 1 -> group; 2 -> channel; 3 -> call; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute tos(10) with type OCTET STRING %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = decode_octet_string(V10, [4]), %%------------------------------------------------- %% attribute tosupdate(11) with type INTEGER %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = decode_integer(V11, [2]), %%------------------------------------------------- %% attribute unread(12) with type INTEGER %%------------------------------------------------- [V12|Tlv13] = Tlv12, Term12 = decode_integer(V12, [2]), %%------------------------------------------------- %% attribute mentions(13) with type SEQUENCE OF %%------------------------------------------------- [V13|Tlv14] = Tlv13, Term13 = 'dec_Room_mentions'(V13, [16]), %%------------------------------------------------- %% attribute lastmsg(14) External CHAT:Message %%------------------------------------------------- [V14|Tlv15] = Tlv14, Term14 = 'dec_Message'(V14, [16]), %%------------------------------------------------- %% attribute update(15) with type INTEGER %%------------------------------------------------- [V15|Tlv16] = Tlv15, Term15 = decode_integer(V15, [2]), %%------------------------------------------------- %% attribute created(16) with type INTEGER %%------------------------------------------------- [V16|Tlv17] = Tlv16, Term16 = decode_integer(V16, [2]), %%------------------------------------------------- %% attribute status(17) with type ENUMERATED %%------------------------------------------------- [V17|Tlv18] = Tlv17, Term17 = case decode_integer(V17, [10]) of 1 -> create; 2 -> leave; 3 -> add; 4 -> remove; 5 -> removed; 6 -> join; 7 -> joined; 8 -> info; 9 -> patch; 10 -> get; 11 -> delete; 12 -> lastmsg; 13 -> mute; 14 -> unmute; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, case Tlv18 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv18}}}) % extra fields not allowed end, Res1 = {'Room',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12,Term13,Term14,Term15,Term16,Term17}, Res1. 'dec_Room_links'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Room_settings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || V1 <- Tlv1]. 'dec_Room_members'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Member'(V1, [16]) || V1 <- Tlv1]. 'dec_Room_admins'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Member'(V1, [16]) || V1 <- Tlv1]. 'dec_Room_data'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_FileDesc'(V1, [16]) || V1 <- Tlv1]. 'dec_Room_mentions'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_integer(V1, [2]) || V1 <- Tlv1]. %%================================ %% Server %%================================ enc_Server(Val) -> enc_Server(Val, [<<48>>]). enc_Server(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute service(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute port(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>]), %%------------------------------------------------- %% attribute host(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Server(Tlv) -> dec_Server(Tlv, [16]). dec_Server(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute service(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute port(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_integer(V2, [2]), %%------------------------------------------------- %% attribute host(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'Server',Term1,Term2,Term3}, Res1. %%================================ %% Profile %%================================ enc_Profile(Val) -> enc_Profile(Val, [<<48>>]). enc_Profile(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11} = Val, %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute phone(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute chats(4) with type SEQUENCE OF %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_Profile_chats'(Cindex4, [<<48>>]), %%------------------------------------------------- %% attribute contacts(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_Profile_contacts'(Cindex5, [<<48>>]), %%------------------------------------------------- %% attribute keys(6) with type SEQUENCE OF %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Profile_keys'(Cindex6, [<<48>>]), %%------------------------------------------------- %% attribute servers(7) with type SEQUENCE OF %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_Profile_servers'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute settings(8) with type SEQUENCE OF %%------------------------------------------------- {EncBytes8,EncLen8} = 'enc_Profile_settings'(Cindex8, [<<48>>]), %%------------------------------------------------- %% attribute update(9) with type INTEGER %%------------------------------------------------- {EncBytes9,EncLen9} = encode_integer(Cindex9, [<<2>>]), %%------------------------------------------------- %% attribute status(10) with type INTEGER %%------------------------------------------------- {EncBytes10,EncLen10} = encode_integer(Cindex10, [<<2>>]), %%------------------------------------------------- %% attribute roster(11) External CHAT:Roster %%------------------------------------------------- {EncBytes11,EncLen11} = 'enc_Roster'(Cindex11, [<<48>>]), 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). %%================================ %% Profile_chats %%================================ enc_Profile_chats(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Profile_chats_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Profile_chats_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Profile_chats_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Contact'(H, [<<48>>]), 'enc_Profile_chats_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Profile_contacts %%================================ enc_Profile_contacts(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Profile_contacts_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Profile_contacts_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Profile_contacts_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Contact'(H, [<<48>>]), 'enc_Profile_contacts_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Profile_keys %%================================ enc_Profile_keys(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Profile_keys_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Profile_keys_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Profile_keys_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Profile_keys_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Profile_servers %%================================ enc_Profile_servers(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Profile_servers_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Profile_servers_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Profile_servers_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Server'(H, [<<48>>]), 'enc_Profile_servers_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Profile_settings %%================================ enc_Profile_settings(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Profile_settings_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Profile_settings_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Profile_settings_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_Profile_settings_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Profile(Tlv) -> dec_Profile(Tlv, [16]). dec_Profile(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute phone(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute chats(4) with type SEQUENCE OF %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_Profile_chats'(V4, [16]), %%------------------------------------------------- %% attribute contacts(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_Profile_contacts'(V5, [16]), %%------------------------------------------------- %% attribute keys(6) with type SEQUENCE OF %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Profile_keys'(V6, [16]), %%------------------------------------------------- %% attribute servers(7) with type SEQUENCE OF %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_Profile_servers'(V7, [16]), %%------------------------------------------------- %% attribute settings(8) with type SEQUENCE OF %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = 'dec_Profile_settings'(V8, [16]), %%------------------------------------------------- %% attribute update(9) with type INTEGER %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = decode_integer(V9, [2]), %%------------------------------------------------- %% attribute status(10) with type INTEGER %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = decode_integer(V10, [2]), %%------------------------------------------------- %% attribute roster(11) External CHAT:Roster %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = 'dec_Roster'(V11, [16]), case Tlv12 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv12}}}) % extra fields not allowed end, Res1 = {'Profile',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11}, Res1. 'dec_Profile_chats'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Contact'(V1, [16]) || V1 <- Tlv1]. 'dec_Profile_contacts'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Contact'(V1, [16]) || V1 <- Tlv1]. 'dec_Profile_keys'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Profile_servers'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Server'(V1, [16]) || V1 <- Tlv1]. 'dec_Profile_settings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || V1 <- Tlv1]. %%================================ %% OS %%================================ enc_OS(Val) -> enc_OS(Val, [<<10>>]). enc_OS(Val, TagIn) -> case Val of apple -> encode_tags(TagIn, [1], 1); microsoft -> encode_tags(TagIn, [2], 1); google -> encode_tags(TagIn, [3], 1); ericsson -> encode_tags(TagIn, [4], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_OS(Tlv) -> dec_OS(Tlv, [10]). dec_OS(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> apple; 2 -> microsoft; 3 -> google; 4 -> ericsson; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% AuthType %%================================ enc_AuthType(Val) -> enc_AuthType(Val, [<<10>>]). enc_AuthType(Val, TagIn) -> case Val of reg -> encode_tags(TagIn, [1], 1); auth -> encode_tags(TagIn, [2], 1); forget -> encode_tags(TagIn, [3], 1); renew -> encode_tags(TagIn, [4], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_AuthType(Tlv) -> dec_AuthType(Tlv, [10]). dec_AuthType(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> reg; 2 -> auth; 3 -> forget; 4 -> renew; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Ack %%================================ enc_Ack(Val) -> enc_Ack(Val, [<<48>>]). enc_Ack(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute table(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute id(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Ack(Tlv) -> dec_Ack(Tlv, [16]). dec_Ack(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute table(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute id(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'Ack',Term1,Term2}, Res1. %%================================ %% FileDesc %%================================ enc_FileDesc(Val) -> enc_FileDesc(Val, [<<48>>]). enc_FileDesc(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute mime(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute payload(3) with type ASN1_OPEN_TYPE %%------------------------------------------------- {EncBytes3,EncLen3} = encode_open_type(Cindex3, []), %%------------------------------------------------- %% attribute parentid(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute data(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_FileDesc_data'(Cindex5, [<<48>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% FileDesc_data %%================================ enc_FileDesc_data(Val, TagIn) -> {EncBytes,EncLen} = 'enc_FileDesc_data_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_FileDesc_data_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_FileDesc_data_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_FileDesc_data_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_FileDesc(Tlv) -> dec_FileDesc(Tlv, [16]). dec_FileDesc(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute mime(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute payload(3) with type ASN1_OPEN_TYPE %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_open_type_as_binary(V3, []), %%------------------------------------------------- %% attribute parentid(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute data(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_FileDesc_data'(V5, [16]), case Tlv6 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowed end, Res1 = {'FileDesc',Term1,Term2,Term3,Term4,Term5}, Res1. 'dec_FileDesc_data'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || V1 <- Tlv1]. %%================================ %% Auth %%================================ enc_Auth(Val) -> enc_Auth(Val, [<<48>>]). enc_Auth(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11} = Val, %%------------------------------------------------- %% attribute session(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute type(2) with type ENUMERATED %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of reg -> encode_tags([<<10>>], [1], 1); auth -> encode_tags([<<10>>], [2], 1); forget -> encode_tags([<<10>>], [3], 1); renew -> encode_tags([<<10>>], [4], 1); Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}}) end, %%------------------------------------------------- %% attribute cert(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute challange(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute push(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute os(6) with type ENUMERATED %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of apple -> encode_tags([<<10>>], [1], 1); microsoft -> encode_tags([<<10>>], [2], 1); google -> encode_tags([<<10>>], [3], 1); ericsson -> encode_tags([<<10>>], [4], 1); Enumval6 -> exit({error,{asn1, {enumerated_not_in_range,Enumval6}}}) end, %%------------------------------------------------- %% attribute nickname(7) with type OCTET STRING %%------------------------------------------------- {EncBytes7,EncLen7} = encode_restricted_string(Cindex7, [<<4>>]), %%------------------------------------------------- %% attribute settings(8) with type SEQUENCE OF %%------------------------------------------------- {EncBytes8,EncLen8} = 'enc_Auth_settings'(Cindex8, [<<48>>]), %%------------------------------------------------- %% attribute token(9) with type OCTET STRING %%------------------------------------------------- {EncBytes9,EncLen9} = encode_restricted_string(Cindex9, [<<4>>]), %%------------------------------------------------- %% attribute devkey(10) with type OCTET STRING %%------------------------------------------------- {EncBytes10,EncLen10} = encode_restricted_string(Cindex10, [<<4>>]), %%------------------------------------------------- %% attribute phone(11) with type OCTET STRING %%------------------------------------------------- {EncBytes11,EncLen11} = encode_restricted_string(Cindex11, [<<4>>]), 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). %%================================ %% Auth_settings %%================================ enc_Auth_settings(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Auth_settings_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Auth_settings_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Auth_settings_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_Auth_settings_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Auth(Tlv) -> dec_Auth(Tlv, [16]). dec_Auth(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute session(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute type(2) with type ENUMERATED %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = case decode_integer(V2, [10]) of 1 -> reg; 2 -> auth; 3 -> forget; 4 -> renew; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute cert(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute challange(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute push(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute os(6) with type ENUMERATED %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = case decode_integer(V6, [10]) of 1 -> apple; 2 -> microsoft; 3 -> google; 4 -> ericsson; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, %%------------------------------------------------- %% attribute nickname(7) with type OCTET STRING %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = decode_octet_string(V7, [4]), %%------------------------------------------------- %% attribute settings(8) with type SEQUENCE OF %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = 'dec_Auth_settings'(V8, [16]), %%------------------------------------------------- %% attribute token(9) with type OCTET STRING %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = decode_octet_string(V9, [4]), %%------------------------------------------------- %% attribute devkey(10) with type OCTET STRING %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = decode_octet_string(V10, [4]), %%------------------------------------------------- %% attribute phone(11) with type OCTET STRING %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = decode_octet_string(V11, [4]), case Tlv12 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv12}}}) % extra fields not allowed end, Res1 = {'Auth',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11}, Res1. 'dec_Auth_settings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || V1 <- Tlv1]. %%================================ %% SearchStatus %%================================ enc_SearchStatus(Val) -> enc_SearchStatus(Val, [<<10>>]). enc_SearchStatus(Val, TagIn) -> case Val of ok -> encode_tags(TagIn, [0], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_SearchStatus(Tlv) -> dec_SearchStatus(Tlv, [10]). dec_SearchStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 0 -> ok; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Criteria %%================================ enc_Criteria(Val) -> enc_Criteria(Val, [<<10>>]). enc_Criteria(Val, TagIn) -> case Val of equal -> encode_tags(TagIn, [0], 1); notequal -> encode_tags(TagIn, [1], 1); like -> encode_tags(TagIn, [2], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_Criteria(Tlv) -> dec_Criteria(Tlv, [10]). dec_Criteria(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 0 -> equal; 1 -> notequal; 2 -> like; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Scope %%================================ enc_Scope(Val) -> enc_Scope(Val, [<<10>>]). enc_Scope(Val, TagIn) -> case Val of profile -> encode_tags(TagIn, [0], 1); folder -> encode_tags(TagIn, [1], 1); contact -> encode_tags(TagIn, [2], 1); member -> encode_tags(TagIn, [3], 1); room -> encode_tags(TagIn, [4], 1); chat -> encode_tags(TagIn, [5], 1); message -> encode_tags(TagIn, [6], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_Scope(Tlv) -> dec_Scope(Tlv, [10]). dec_Scope(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 0 -> profile; 1 -> folder; 2 -> contact; 3 -> member; 4 -> room; 5 -> chat; 6 -> message; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Search %%================================ enc_Search(Val) -> enc_Search(Val, [<<48>>]). enc_Search(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7} = Val, %%------------------------------------------------- %% attribute dn(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute id(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute field(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute value(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute criteria(5) with type ENUMERATED %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of equal -> encode_tags([<<10>>], [0], 1); notequal -> encode_tags([<<10>>], [1], 1); like -> encode_tags([<<10>>], [2], 1); Enumval5 -> exit({error,{asn1, {enumerated_not_in_range,Enumval5}}}) end, %%------------------------------------------------- %% attribute type(6) with type ENUMERATED %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of profile -> encode_tags([<<10>>], [0], 1); folder -> encode_tags([<<10>>], [1], 1); contact -> encode_tags([<<10>>], [2], 1); member -> encode_tags([<<10>>], [3], 1); room -> encode_tags([<<10>>], [4], 1); chat -> encode_tags([<<10>>], [5], 1); message -> encode_tags([<<10>>], [6], 1); Enumval6 -> exit({error,{asn1, {enumerated_not_in_range,Enumval6}}}) end, %%------------------------------------------------- %% attribute status(7) with type ENUMERATED %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of ok -> encode_tags([<<10>>], [0], 1); Enumval7 -> exit({error,{asn1, {enumerated_not_in_range,Enumval7}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Search(Tlv) -> dec_Search(Tlv, [16]). dec_Search(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute dn(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute id(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute field(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute value(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute criteria(5) with type ENUMERATED %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = case decode_integer(V5, [10]) of 0 -> equal; 1 -> notequal; 2 -> like; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute type(6) with type ENUMERATED %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = case decode_integer(V6, [10]) of 0 -> profile; 1 -> folder; 2 -> contact; 3 -> member; 4 -> room; 5 -> chat; 6 -> message; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, %%------------------------------------------------- %% attribute status(7) with type ENUMERATED %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = case decode_integer(V7, [10]) of 0 -> ok; Default3 -> exit({error,{asn1,{illegal_enumerated,Default3}}}) end, case Tlv8 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv8}}}) % extra fields not allowed end, Res1 = {'Search',Term1,Term2,Term3,Term4,Term5,Term6,Term7}, Res1. %%================================ %% Typing %%================================ enc_Typing(Val) -> enc_Typing(Val, [<<48>>]). enc_Typing(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute session(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute nickname(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute comments(3) with type SEQUENCE OF %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_Typing_comments'(Cindex3, [<<48>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Typing_comments %%================================ enc_Typing_comments(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Typing_comments_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Typing_comments_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Typing_comments_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Typing_comments_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Typing(Tlv) -> dec_Typing(Tlv, [16]). dec_Typing(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute session(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute nickname(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute comments(3) with type SEQUENCE OF %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_Typing_comments'(V3, [16]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'Typing',Term1,Term2,Term3}, Res1. 'dec_Typing_comments'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. %%================================ %% Friendship %%================================ enc_Friendship(Val) -> enc_Friendship(Val, [<<10>>]). enc_Friendship(Val, TagIn) -> case Val of request -> encode_tags(TagIn, [1], 1); confirm -> encode_tags(TagIn, [2], 1); update -> encode_tags(TagIn, [3], 1); ignore -> encode_tags(TagIn, [4], 1); ban -> encode_tags(TagIn, [5], 1); unban -> encode_tags(TagIn, [6], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_Friendship(Tlv) -> dec_Friendship(Tlv, [10]). dec_Friendship(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> request; 2 -> confirm; 3 -> update; 4 -> ignore; 5 -> ban; 6 -> unban; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Friend %%================================ enc_Friend(Val) -> enc_Friend(Val, [<<48>>]). enc_Friend(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute friend(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute type(3) with type ENUMERATED %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of request -> encode_tags([<<10>>], [1], 1); confirm -> encode_tags([<<10>>], [2], 1); update -> encode_tags([<<10>>], [3], 1); ignore -> encode_tags([<<10>>], [4], 1); ban -> encode_tags([<<10>>], [5], 1); unban -> encode_tags([<<10>>], [6], 1); Enumval3 -> exit({error,{asn1, {enumerated_not_in_range,Enumval3}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Friend(Tlv) -> dec_Friend(Tlv, [16]). dec_Friend(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute friend(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute type(3) with type ENUMERATED %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = case decode_integer(V3, [10]) of 1 -> request; 2 -> confirm; 3 -> update; 4 -> ignore; 5 -> ban; 6 -> unban; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'Friend',Term1,Term2,Term3}, Res1. %%================================ %% HistoryStatus %%================================ enc_HistoryStatus(Val) -> enc_HistoryStatus(Val, [<<10>>]). enc_HistoryStatus(Val, TagIn) -> case Val of updated -> encode_tags(TagIn, [1], 1); get -> encode_tags(TagIn, [2], 1); update -> encode_tags(TagIn, [3], 1); lastloaded -> encode_tags(TagIn, [4], 1); lastmsg -> encode_tags(TagIn, [5], 1); getreply -> encode_tags(TagIn, [6], 1); doubleget -> encode_tags(TagIn, [7], 1); delete -> encode_tags(TagIn, [8], 1); image -> encode_tags(TagIn, [9], 1); video -> encode_tags(TagIn, [10], 1); file -> encode_tags(TagIn, [11], 1); link -> encode_tags(TagIn, [12], 1); audio -> encode_tags(TagIn, [13], 1); contact -> encode_tags(TagIn, [14], 1); location -> encode_tags(TagIn, [15], 1); text -> encode_tags(TagIn, [16], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_HistoryStatus(Tlv) -> dec_HistoryStatus(Tlv, [10]). dec_HistoryStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> updated; 2 -> get; 3 -> update; 4 -> lastloaded; 5 -> lastmsg; 6 -> getreply; 7 -> doubleget; 8 -> delete; 9 -> image; 10 -> video; 11 -> file; 12 -> link; 13 -> audio; 14 -> contact; 15 -> location; 16 -> text; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% History %%================================ enc_History(Val) -> enc_History(Val, [<<48>>]). enc_History(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7} = Val, %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute feed(2) with type CHOICE %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_History_feed'(Cindex2, []), %%------------------------------------------------- %% attribute size(3) with type INTEGER %%------------------------------------------------- {EncBytes3,EncLen3} = encode_integer(Cindex3, [<<2>>]), %%------------------------------------------------- %% attribute entity(4) with type INTEGER %%------------------------------------------------- {EncBytes4,EncLen4} = encode_integer(Cindex4, [<<2>>]), %%------------------------------------------------- %% attribute data(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_History_data'(Cindex5, [<<48>>]), %%------------------------------------------------- %% attribute roster(6) with type UniversalString %%------------------------------------------------- {EncBytes6,EncLen6} = encode_universal_string(Cindex6, [<<28>>]), %%------------------------------------------------- %% attribute status(7) with type ENUMERATED %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of updated -> encode_tags([<<10>>], [1], 1); get -> encode_tags([<<10>>], [2], 1); update -> encode_tags([<<10>>], [3], 1); lastloaded -> encode_tags([<<10>>], [4], 1); lastmsg -> encode_tags([<<10>>], [5], 1); getreply -> encode_tags([<<10>>], [6], 1); doubleget -> encode_tags([<<10>>], [7], 1); delete -> encode_tags([<<10>>], [8], 1); image -> encode_tags([<<10>>], [9], 1); video -> encode_tags([<<10>>], [10], 1); file -> encode_tags([<<10>>], [11], 1); link -> encode_tags([<<10>>], [12], 1); audio -> encode_tags([<<10>>], [13], 1); contact -> encode_tags([<<10>>], [14], 1); location -> encode_tags([<<10>>], [15], 1); text -> encode_tags([<<10>>], [16], 1); Enumval5 -> exit({error,{asn1, {enumerated_not_in_range,Enumval5}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% History_feed %%================================ enc_History_feed(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of p2p -> 'enc_P2P'(element(2,Val), [<<160>>]); muc -> 'enc_MUC'(element(2,Val), [<<161>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% History_data %%================================ enc_History_data(Val, TagIn) -> {EncBytes,EncLen} = 'enc_History_data_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_History_data_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_History_data_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Message'(H, [<<48>>]), 'enc_History_data_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_History(Tlv) -> dec_History(Tlv, [16]). dec_History(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute nickname(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [4]), %%------------------------------------------------- %% attribute feed(2) with type CHOICE %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_History_feed'(V2, []), %%------------------------------------------------- %% attribute size(3) with type INTEGER %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_integer(V3, [2]), %%------------------------------------------------- %% attribute entity(4) with type INTEGER %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_integer(V4, [2]), %%------------------------------------------------- %% attribute data(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_History_data'(V5, [16]), %%------------------------------------------------- %% attribute roster(6) with type UniversalString %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = decode_universal_string(V6, [28]), %%------------------------------------------------- %% attribute status(7) with type ENUMERATED %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = case decode_integer(V7, [10]) of 1 -> updated; 2 -> get; 3 -> update; 4 -> lastloaded; 5 -> lastmsg; 6 -> getreply; 7 -> doubleget; 8 -> delete; 9 -> image; 10 -> video; 11 -> file; 12 -> link; 13 -> audio; 14 -> contact; 15 -> location; 16 -> text; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, case Tlv8 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv8}}}) % extra fields not allowed end, Res1 = {'History',Term1,Term2,Term3,Term4,Term5,Term6,Term7}, Res1. 'dec_History_feed'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'p2p' {131072, V1} -> {p2p, 'dec_P2P'(V1, [])}; %% 'muc' {131073, V1} -> {muc, 'dec_MUC'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_History_data'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Message'(V1, [16]) || V1 <- Tlv1]. %%================================ %% CHATProtocol %%================================ enc_CHATProtocol(Val) -> enc_CHATProtocol(Val, []). enc_CHATProtocol(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of register -> 'enc_Register'(element(2,Val), [<<160>>]); auth -> 'enc_Auth'(element(2,Val), [<<161>>]); feature -> 'enc_Feature'(element(2,Val), [<<162>>]); service -> 'enc_Service'(element(2,Val), [<<163>>]); message -> 'enc_Message'(element(2,Val), [<<164>>]); profile -> 'enc_Profile'(element(2,Val), [<<165>>]); room -> 'enc_Room'(element(2,Val), [<<166>>]); member -> 'enc_Member'(element(2,Val), [<<167>>]); search -> 'enc_Search'(element(2,Val), [<<168>>]); file -> 'enc_FileDesc'(element(2,Val), [<<169>>]); typing -> 'enc_Typing'(element(2,Val), [<<170>>]); friend -> 'enc_Friend'(element(2,Val), [<<171>>]); presence -> 'enc_Presence'(element(2,Val), [<<172>>]); history -> 'enc_History'(element(2,Val), [<<173>>]); roster -> 'enc_Roster'(element(2,Val), [<<174>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). dec_CHATProtocol(Tlv) -> dec_CHATProtocol(Tlv, []). dec_CHATProtocol(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'register' {131072, V1} -> {register, 'dec_Register'(V1, [])}; %% 'auth' {131073, V1} -> {auth, 'dec_Auth'(V1, [])}; %% 'feature' {131074, V1} -> {feature, 'dec_Feature'(V1, [])}; %% 'service' {131075, V1} -> {service, 'dec_Service'(V1, [])}; %% 'message' {131076, V1} -> {message, 'dec_Message'(V1, [])}; %% 'profile' {131077, V1} -> {profile, 'dec_Profile'(V1, [])}; %% 'room' {131078, V1} -> {room, 'dec_Room'(V1, [])}; %% 'member' {131079, V1} -> {member, 'dec_Member'(V1, [])}; %% 'search' {131080, V1} -> {search, 'dec_Search'(V1, [])}; %% 'file' {131081, V1} -> {file, 'dec_FileDesc'(V1, [])}; %% 'typing' {131082, V1} -> {typing, 'dec_Typing'(V1, [])}; %% 'friend' {131083, V1} -> {friend, 'dec_Friend'(V1, [])}; %% 'presence' {131084, V1} -> {presence, 'dec_Presence'(V1, [])}; %% 'history' {131085, V1} -> {history, 'dec_History'(V1, [])}; %% 'roster' {131086, V1} -> {roster, 'dec_Roster'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . %%================================ %% CHATMessage %%================================ enc_CHATMessage(Val) -> enc_CHATMessage(Val, [<<48>>]). enc_CHATMessage(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute no(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>]), %%------------------------------------------------- %% attribute headers(2) with type SEQUENCE OF %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_CHATMessage_headers'(Cindex2, [<<48>>]), %%------------------------------------------------- %% attribute body(3) External CHAT:CHATProtocol %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_CHATProtocol'(Cindex3, []), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% CHATMessage_headers %%================================ enc_CHATMessage_headers(Val, TagIn) -> {EncBytes,EncLen} = 'enc_CHATMessage_headers_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_CHATMessage_headers_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_CHATMessage_headers_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_CHATMessage_headers_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_CHATMessage(Tlv) -> dec_CHATMessage(Tlv, [16]). dec_CHATMessage(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute no(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_integer(V1, [2]), %%------------------------------------------------- %% attribute headers(2) with type SEQUENCE OF %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_CHATMessage_headers'(V2, [16]), %%------------------------------------------------- %% attribute body(3) External CHAT:CHATProtocol %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_CHATProtocol'(V3, []), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'CHATMessage',Term1,Term2,Term3}, Res1. 'dec_CHATMessage_headers'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. %%% %%% 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)]). decode_integer(Tlv, TagIn) -> Bin = match_tags(Tlv, TagIn), Len = byte_size(Bin), <> = Bin, Int. decode_null(Tlv, Tags) -> Val = match_tags(Tlv, Tags), case Val of <<>> -> 'NULL'; _ -> exit({error, {asn1, {decode_null, Val}}}) end. decode_octet_string(Tlv, TagsIn) -> Bin = match_and_collect(Tlv, TagsIn), binary:copy(Bin). decode_open_type_as_binary(Tlv, TagIn) -> ber_encode(match_tags(Tlv, TagIn)). decode_universal_string(Buffer, Tags) -> Bin = match_and_collect(Buffer, Tags), mk_universal_string(binary_to_list(Bin)). encode_integer(Val) -> Bytes = if Val >= 0 -> encode_integer_pos(Val, []); true -> encode_integer_neg(Val, []) end, {Bytes, length(Bytes)}. 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_null(_Val, TagIn) -> encode_tags(TagIn, [], 0). 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_universal_string(Universal, TagIn) -> OctetList = mk_uni_list(Universal), encode_tags(TagIn, OctetList, length(OctetList)). 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_uni_list(In) -> mk_uni_list(In, []). mk_uni_list([], List) -> lists:reverse(List); mk_uni_list([{A, B, C, D} | T], List) -> mk_uni_list(T, [D, C, B, A | List]); mk_uni_list([H | T], List) -> mk_uni_list(T, [H, 0, 0, 0 | List]). mk_universal_string(In) -> mk_universal_string(In, []). mk_universal_string([], Acc) -> lists:reverse(Acc); mk_universal_string([0, 0, 0, D | T], Acc) -> mk_universal_string(T, [D | Acc]); mk_universal_string([A, B, C, D | T], Acc) -> mk_universal_string(T, [{A, B, C, D} | Acc]).