%% Generated by the Erlang ASN.1 BER compiler. Version: 5.4.1 %% Purpose: Encoding and decoding of the types in CHAT-v2. -module('CHAT-v2'). -moduledoc false. -compile(nowarn_unused_vars). -dialyzer(no_improper_lists). -dialyzer(no_match). -include_lib("chat/include/CHAT-v2.hrl"). -asn1_info([{vsn,'5.4.1'}, {module,'CHAT-v2'}, {options,[warnings,ber,errors, {cwd,"/Users/5ht/depot/synrc/chat/priv/v2"}, {outdir,"/Users/5ht/depot/synrc/chat/priv/v2"}, {i,"."}, {i,"/Users/5ht/depot/synrc/chat/priv/v2"}]}]). -export([encoding_rule/0,maps/0,bit_string_format/0, legacy_erlang_types/0]). -export(['dialyzer-suppressions'/1]). -export([ enc_Version/2, enc_OS/2, enc_Feature/2, enc_AuthorityMethod/2, enc_Authority/2, enc_File/2, enc_MessageType/2, enc_MessageStatus/2, enc_MessageFeed/2, enc_Message/2, enc_Privatebox/2, enc_Streambox/2, enc_Groupbox/2, enc_Mailbox/2, enc_InboxMethod/2, enc_Inbox/2, enc_Ack/2, enc_Activity/2, enc_SearchStatus/2, enc_Criteria/2, enc_Scope/2, enc_Search/2, enc_SubscriptionPresence/2, enc_SubscriptionStatus/2, enc_Subscription/2, enc_PersonStatus/2, enc_Person/2, enc_Server/2, enc_RosterStatus/2, enc_Roster/2, enc_MemberStatus/2, enc_Member/2, enc_ConferenceType/2, enc_ConferenceStatus/2, enc_Conference/2, enc_CHATProtocol/2, enc_CHATMessage/2 ]). -export([ dec_Version/2, dec_OS/2, dec_Feature/2, dec_AuthorityMethod/2, dec_Authority/2, dec_File/2, dec_MessageType/2, dec_MessageStatus/2, dec_MessageFeed/2, dec_Message/2, dec_Privatebox/2, dec_Streambox/2, dec_Groupbox/2, dec_Mailbox/2, dec_InboxMethod/2, dec_Inbox/2, dec_Ack/2, dec_Activity/2, dec_SearchStatus/2, dec_Criteria/2, dec_Scope/2, dec_Search/2, dec_SubscriptionPresence/2, dec_SubscriptionStatus/2, dec_Subscription/2, dec_PersonStatus/2, dec_Person/2, dec_Server/2, dec_RosterStatus/2, dec_Roster/2, dec_MemberStatus/2, dec_Member/2, dec_ConferenceType/2, dec_ConferenceStatus/2, dec_Conference/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('Version', Data) -> enc_Version(Data); encode_disp('OS', Data) -> enc_OS(Data); encode_disp('Feature', Data) -> enc_Feature(Data); encode_disp('AuthorityMethod', Data) -> enc_AuthorityMethod(Data); encode_disp('Authority', Data) -> enc_Authority(Data); encode_disp('File', Data) -> enc_File(Data); encode_disp('MessageType', Data) -> enc_MessageType(Data); encode_disp('MessageStatus', Data) -> enc_MessageStatus(Data); encode_disp('MessageFeed', Data) -> enc_MessageFeed(Data); encode_disp('Message', Data) -> enc_Message(Data); encode_disp('Privatebox', Data) -> enc_Privatebox(Data); encode_disp('Streambox', Data) -> enc_Streambox(Data); encode_disp('Groupbox', Data) -> enc_Groupbox(Data); encode_disp('Mailbox', Data) -> enc_Mailbox(Data); encode_disp('InboxMethod', Data) -> enc_InboxMethod(Data); encode_disp('Inbox', Data) -> enc_Inbox(Data); encode_disp('Ack', Data) -> enc_Ack(Data); encode_disp('Activity', Data) -> enc_Activity(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('SubscriptionPresence', Data) -> enc_SubscriptionPresence(Data); encode_disp('SubscriptionStatus', Data) -> enc_SubscriptionStatus(Data); encode_disp('Subscription', Data) -> enc_Subscription(Data); encode_disp('PersonStatus', Data) -> enc_PersonStatus(Data); encode_disp('Person', Data) -> enc_Person(Data); encode_disp('Server', Data) -> enc_Server(Data); encode_disp('RosterStatus', Data) -> enc_RosterStatus(Data); encode_disp('Roster', Data) -> enc_Roster(Data); encode_disp('MemberStatus', Data) -> enc_MemberStatus(Data); encode_disp('Member', Data) -> enc_Member(Data); encode_disp('ConferenceType', Data) -> enc_ConferenceType(Data); encode_disp('ConferenceStatus', Data) -> enc_ConferenceStatus(Data); encode_disp('Conference', Data) -> enc_Conference(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('Version', Data) -> dec_Version(Data); decode_disp('OS', Data) -> dec_OS(Data); decode_disp('Feature', Data) -> dec_Feature(Data); decode_disp('AuthorityMethod', Data) -> dec_AuthorityMethod(Data); decode_disp('Authority', Data) -> dec_Authority(Data); decode_disp('File', Data) -> dec_File(Data); decode_disp('MessageType', Data) -> dec_MessageType(Data); decode_disp('MessageStatus', Data) -> dec_MessageStatus(Data); decode_disp('MessageFeed', Data) -> dec_MessageFeed(Data); decode_disp('Message', Data) -> dec_Message(Data); decode_disp('Privatebox', Data) -> dec_Privatebox(Data); decode_disp('Streambox', Data) -> dec_Streambox(Data); decode_disp('Groupbox', Data) -> dec_Groupbox(Data); decode_disp('Mailbox', Data) -> dec_Mailbox(Data); decode_disp('InboxMethod', Data) -> dec_InboxMethod(Data); decode_disp('Inbox', Data) -> dec_Inbox(Data); decode_disp('Ack', Data) -> dec_Ack(Data); decode_disp('Activity', Data) -> dec_Activity(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('SubscriptionPresence', Data) -> dec_SubscriptionPresence(Data); decode_disp('SubscriptionStatus', Data) -> dec_SubscriptionStatus(Data); decode_disp('Subscription', Data) -> dec_Subscription(Data); decode_disp('PersonStatus', Data) -> dec_PersonStatus(Data); decode_disp('Person', Data) -> dec_Person(Data); decode_disp('Server', Data) -> dec_Server(Data); decode_disp('RosterStatus', Data) -> dec_RosterStatus(Data); decode_disp('Roster', Data) -> dec_Roster(Data); decode_disp('MemberStatus', Data) -> dec_MemberStatus(Data); decode_disp('Member', Data) -> dec_Member(Data); decode_disp('ConferenceType', Data) -> dec_ConferenceType(Data); decode_disp('ConferenceStatus', Data) -> dec_ConferenceStatus(Data); decode_disp('Conference', Data) -> dec_Conference(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. %%================================ %% Version %%================================ enc_Version(Val) -> enc_Version(Val, [<<2>>]). enc_Version(Val, TagIn) -> encode_integer(Val, [{v0,0},{v1,1},{v2,2},{v3,3}], TagIn). dec_Version(Tlv) -> dec_Version(Tlv, [2]). dec_Version(Tlv, TagIn) -> begin Val1 = decode_integer(Tlv, TagIn), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end . %%================================ %% 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); nokia -> encode_tags(TagIn, [5], 1); cisco -> encode_tags(TagIn, [6], 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; 5 -> nokia; 6 -> cisco; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% 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. %%================================ %% AuthorityMethod %%================================ enc_AuthorityMethod(Val) -> enc_AuthorityMethod(Val, [<<10>>]). enc_AuthorityMethod(Val, TagIn) -> case Val of announce -> encode_tags(TagIn, [0], 1); enroll -> encode_tags(TagIn, [1], 1); authenticate -> encode_tags(TagIn, [2], 1); revoke -> encode_tags(TagIn, [3], 1); renew -> encode_tags(TagIn, [4], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_AuthorityMethod(Tlv) -> dec_AuthorityMethod(Tlv, [10]). dec_AuthorityMethod(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 0 -> announce; 1 -> enroll; 2 -> authenticate; 3 -> revoke; 4 -> renew; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Authority %%================================ enc_Authority(Val) -> enc_Authority(Val, [<<48>>]). enc_Authority(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute vsn(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute type(4) with type ENUMERATED %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of announce -> encode_tags([<<10>>], [0], 1); enroll -> encode_tags([<<10>>], [1], 1); authenticate -> encode_tags([<<10>>], [2], 1); revoke -> encode_tags([<<10>>], [3], 1); renew -> encode_tags([<<10>>], [4], 1); Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}}) end, %%------------------------------------------------- %% attribute cert(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute settings(6) with type SEQUENCE OF %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Authority_settings'(Cindex6, [<<48>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Authority_settings %%================================ enc_Authority_settings(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Authority_settings_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Authority_settings_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Authority_settings_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_Authority_settings_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Authority(Tlv) -> dec_Authority(Tlv, [16]). dec_Authority(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 vsn(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute type(4) with type ENUMERATED %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = case decode_integer(V4, [10]) of 0 -> announce; 1 -> enroll; 2 -> authenticate; 3 -> revoke; 4 -> renew; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute cert(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute settings(6) with type SEQUENCE OF %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Authority_settings'(V6, [16]), case Tlv7 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowed end, Res1 = {'Authority',Term1,Term2,Term3,Term4,Term5,Term6}, Res1. 'dec_Authority_settings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || V1 <- Tlv1]. %%================================ %% File %%================================ enc_File(Val) -> enc_File(Val, [<<48>>]). enc_File(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = 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>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_File(Tlv) -> dec_File(Tlv, [16]). dec_File(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]), case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'File',Term1,Term2,Term3,Term4}, Res1. %%================================ %% 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 private -> 'enc_Privatebox'(element(2,Val), [<<161>>]); chan -> 'enc_Streambox'(element(2,Val), [<<162>>]); mailbox -> 'enc_Mailbox'(element(2,Val), [<<164>>]); group -> 'enc_Groupbox'(element(2,Val), [<<168>>]); 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 %% 'private' {131073, V1} -> {private, 'dec_Privatebox'(V1, [])}; %% 'chan' {131074, V1} -> {chan, 'dec_Streambox'(V1, [])}; %% 'mailbox' {131076, V1} -> {mailbox, 'dec_Mailbox'(V1, [])}; %% 'group' {131080, V1} -> {group, 'dec_Groupbox'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . %%================================ %% 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 vsn(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute inbox(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute from(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute to(6) External CHAT-v2:MessageFeed %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_MessageFeed'(Cindex6, []), %%------------------------------------------------- %% 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_File'(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 vsn(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute inbox(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute from(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute to(6) External CHAT-v2:MessageFeed %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_MessageFeed'(V6, []), %%------------------------------------------------- %% 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_File'(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]. %%================================ %% Privatebox %%================================ enc_Privatebox(Val) -> enc_Privatebox(Val, [<<48>>]). enc_Privatebox(Val, TagIn) -> {_,Cindex1} = Val, %%------------------------------------------------- %% attribute address(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), BytesSoFar = [EncBytes1], LenSoFar = EncLen1, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Privatebox(Tlv) -> dec_Privatebox(Tlv, [16]). dec_Privatebox(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute address(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 = {'Privatebox',Term1}, Res1. %%================================ %% Streambox %%================================ enc_Streambox(Val) -> enc_Streambox(Val, [<<48>>]). enc_Streambox(Val, TagIn) -> {_,Cindex1} = Val, %%------------------------------------------------- %% attribute channel(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), BytesSoFar = [EncBytes1], LenSoFar = EncLen1, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Streambox(Tlv) -> dec_Streambox(Tlv, [16]). dec_Streambox(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute channel(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 = {'Streambox',Term1}, Res1. %%================================ %% Groupbox %%================================ enc_Groupbox(Val) -> enc_Groupbox(Val, [<<48>>]). enc_Groupbox(Val, TagIn) -> {_,Cindex1} = Val, %%------------------------------------------------- %% attribute channel(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), BytesSoFar = [EncBytes1], LenSoFar = EncLen1, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Groupbox(Tlv) -> dec_Groupbox(Tlv, [16]). dec_Groupbox(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute channel(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 = {'Groupbox',Term1}, Res1. %%================================ %% Mailbox %%================================ enc_Mailbox(Val) -> enc_Mailbox(Val, [<<48>>]). enc_Mailbox(Val, TagIn) -> {_,Cindex1} = Val, %%------------------------------------------------- %% attribute channel(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), BytesSoFar = [EncBytes1], LenSoFar = EncLen1, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Mailbox(Tlv) -> dec_Mailbox(Tlv, [16]). dec_Mailbox(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute channel(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 = {'Mailbox',Term1}, Res1. %%================================ %% InboxMethod %%================================ enc_InboxMethod(Val) -> enc_InboxMethod(Val, [<<10>>]). enc_InboxMethod(Val, TagIn) -> case Val of get -> encode_tags(TagIn, [1], 1); erase -> encode_tags(TagIn, [2], 1); Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}}) end. dec_InboxMethod(Tlv) -> dec_InboxMethod(Tlv, [10]). dec_InboxMethod(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> get; 2 -> erase; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Inbox %%================================ enc_Inbox(Val) -> enc_Inbox(Val, [<<48>>]). enc_Inbox(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute vsn(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute type(4) with type ENUMERATED %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of get -> encode_tags([<<10>>], [1], 1); erase -> encode_tags([<<10>>], [2], 1); Enumval4 -> exit({error,{asn1, {enumerated_not_in_range,Enumval4}}}) end, %%------------------------------------------------- %% attribute feed(5) External CHAT-v2:MessageFeed %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_MessageFeed'(Cindex5, []), %%------------------------------------------------- %% attribute messages(6) with type SEQUENCE OF %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Inbox_messages'(Cindex6, [<<48>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Inbox_messages %%================================ enc_Inbox_messages(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Inbox_messages_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Inbox_messages_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Inbox_messages_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Message'(H, [<<48>>]), 'enc_Inbox_messages_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Inbox(Tlv) -> dec_Inbox(Tlv, [16]). dec_Inbox(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 vsn(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute type(4) with type ENUMERATED %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = case decode_integer(V4, [10]) of 1 -> get; 2 -> erase; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute feed(5) External CHAT-v2:MessageFeed %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_MessageFeed'(V5, []), %%------------------------------------------------- %% attribute messages(6) with type SEQUENCE OF %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Inbox_messages'(V6, [16]), case Tlv7 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowed end, Res1 = {'Inbox',Term1,Term2,Term3,Term4,Term5,Term6}, Res1. 'dec_Inbox_messages'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Message'(V1, [16]) || V1 <- Tlv1]. %%================================ %% Ack %%================================ enc_Ack(Val) -> enc_Ack(Val, [<<48>>]). enc_Ack(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute vsn(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute id(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute primary(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute secondary(4) with type OCTET STRING OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex4, [<<4>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, 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 vsn(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute id(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [4]), %%------------------------------------------------- %% attribute primary(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute secondary(4) with type OCTET STRING OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{4,V4}|TempTlv5] -> {decode_octet_string(V4, []), TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'Ack',Term1,Term2,Term3,Term4}, Res1. %%================================ %% Activity %%================================ enc_Activity(Val) -> enc_Activity(Val, [<<48>>]). enc_Activity(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute vsn(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute nickname(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute comments(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_Activity_comments'(Cindex5, [<<48>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Activity_comments %%================================ enc_Activity_comments(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Activity_comments_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Activity_comments_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Activity_comments_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Activity_comments_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Activity(Tlv) -> dec_Activity(Tlv, [16]). dec_Activity(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 vsn(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute nickname(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute comments(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_Activity_comments'(V5, [16]), case Tlv6 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowed end, Res1 = {'Activity',Term1,Term2,Term3,Term4,Term5}, Res1. 'dec_Activity_comments'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || 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,Cindex8,Cindex9} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute vsn(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute dn(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute field(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute value(6) with type OCTET STRING %%------------------------------------------------- {EncBytes6,EncLen6} = encode_restricted_string(Cindex6, [<<4>>]), %%------------------------------------------------- %% attribute criteria(7) with type ENUMERATED %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of equal -> encode_tags([<<10>>], [0], 1); notequal -> encode_tags([<<10>>], [1], 1); like -> encode_tags([<<10>>], [2], 1); Enumval7 -> exit({error,{asn1, {enumerated_not_in_range,Enumval7}}}) end, %%------------------------------------------------- %% attribute type(8) with type ENUMERATED %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 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); Enumval8 -> exit({error,{asn1, {enumerated_not_in_range,Enumval8}}}) end, %%------------------------------------------------- %% attribute status(9) with type ENUMERATED %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of ok -> encode_tags([<<10>>], [0], 1); Enumval9 -> exit({error,{asn1, {enumerated_not_in_range,Enumval9}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Search(Tlv) -> dec_Search(Tlv, [16]). dec_Search(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 vsn(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute dn(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute field(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute value(6) with type OCTET STRING %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = decode_octet_string(V6, [4]), %%------------------------------------------------- %% attribute criteria(7) with type ENUMERATED %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = case decode_integer(V7, [10]) of 0 -> equal; 1 -> notequal; 2 -> like; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute type(8) with type ENUMERATED %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = case decode_integer(V8, [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(9) with type ENUMERATED %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = case decode_integer(V9, [10]) of 0 -> ok; Default3 -> exit({error,{asn1,{illegal_enumerated,Default3}}}) end, case Tlv10 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv10}}}) % extra fields not allowed end, Res1 = {'Search',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9}, Res1. %%================================ %% SubscriptionPresence %%================================ enc_SubscriptionPresence(Val) -> enc_SubscriptionPresence(Val, [<<10>>]). enc_SubscriptionPresence(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_SubscriptionPresence(Tlv) -> dec_SubscriptionPresence(Tlv, [10]). dec_SubscriptionPresence(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> offline; 2 -> online; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% SubscriptionStatus %%================================ enc_SubscriptionStatus(Val) -> enc_SubscriptionStatus(Val, [<<10>>]). enc_SubscriptionStatus(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_SubscriptionStatus(Tlv) -> dec_SubscriptionStatus(Tlv, [10]). dec_SubscriptionStatus(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. %%================================ %% Subscription %%================================ enc_Subscription(Val) -> enc_Subscription(Val, [<<48>>]). enc_Subscription(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 vsn(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute nickname(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute friend(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute status(6) with type ENUMERATED %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of offline -> encode_tags([<<10>>], [1], 1); online -> encode_tags([<<10>>], [2], 1); Enumval6 -> exit({error,{asn1, {enumerated_not_in_range,Enumval6}}}) end, %%------------------------------------------------- %% attribute type(7) with type ENUMERATED %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 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); 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_Subscription(Tlv) -> dec_Subscription(Tlv, [16]). dec_Subscription(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 vsn(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute nickname(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute friend(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute status(6) with type ENUMERATED %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = case decode_integer(V6, [10]) of 1 -> offline; 2 -> online; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute type(7) with type ENUMERATED %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = case decode_integer(V7, [10]) of 1 -> request; 2 -> confirm; 3 -> update; 4 -> ignore; 5 -> ban; 6 -> unban; Default2 -> exit({error,{asn1,{illegal_enumerated,Default2}}}) end, case Tlv8 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv8}}}) % extra fields not allowed end, Res1 = {'Subscription',Term1,Term2,Term3,Term4,Term5,Term6,Term7}, Res1. %%================================ %% PersonStatus %%================================ enc_PersonStatus(Val) -> enc_PersonStatus(Val, [<<10>>]). enc_PersonStatus(Val, TagIn) -> case Val of req -> encode_tags(TagIn, [1], 1); auth -> 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_PersonStatus(Tlv) -> dec_PersonStatus(Tlv, [10]). dec_PersonStatus(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> req; 2 -> auth; 3 -> ignore; 4 -> internal; 5 -> friend; 6 -> lastmsg; 7 -> ban; 8 -> banned; 9 -> deleted; 10 -> nonexised; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% Person %%================================ enc_Person(Val) -> enc_Person(Val, [<<48>>]). enc_Person(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12} = 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 avatar(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute names(4) with type SEQUENCE OF %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_Person_names'(Cindex4, [<<48>>]), %%------------------------------------------------- %% attribute phone(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute surnames(6) with type SEQUENCE OF %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Person_surnames'(Cindex6, [<<48>>]), %%------------------------------------------------- %% attribute lastmsg(7) External CHAT-v2:Message %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_Message'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute presence(8) with type ENUMERATED %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of offline -> encode_tags([<<10>>], [1], 1); online -> encode_tags([<<10>>], [2], 1); Enumval5 -> exit({error,{asn1, {enumerated_not_in_range,Enumval5}}}) end, %%------------------------------------------------- %% attribute update(9) with type INTEGER %%------------------------------------------------- {EncBytes9,EncLen9} = encode_integer(Cindex9, [<<2>>]), %%------------------------------------------------- %% attribute created(10) with type INTEGER %%------------------------------------------------- {EncBytes10,EncLen10} = encode_integer(Cindex10, [<<2>>]), %%------------------------------------------------- %% attribute settings(11) with type SEQUENCE OF %%------------------------------------------------- {EncBytes11,EncLen11} = 'enc_Person_settings'(Cindex11, [<<48>>]), %%------------------------------------------------- %% attribute status(12) with type ENUMERATED %%------------------------------------------------- {EncBytes12,EncLen12} = case Cindex12 of req -> encode_tags([<<10>>], [1], 1); auth -> 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); Enumval8 -> exit({error,{asn1, {enumerated_not_in_range,Enumval8}}}) 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). %%================================ %% Person_names %%================================ enc_Person_names(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Person_names_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Person_names_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Person_names_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Person_names_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Person_surnames %%================================ enc_Person_surnames(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Person_surnames_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Person_surnames_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Person_surnames_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Person_surnames_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Person_settings %%================================ enc_Person_settings(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Person_settings_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Person_settings_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Person_settings_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_Person_settings_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Person(Tlv) -> dec_Person(Tlv, [16]). dec_Person(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 avatar(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute names(4) with type SEQUENCE OF %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_Person_names'(V4, [16]), %%------------------------------------------------- %% attribute phone(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute surnames(6) with type SEQUENCE OF %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Person_surnames'(V6, [16]), %%------------------------------------------------- %% attribute lastmsg(7) External CHAT-v2:Message %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_Message'(V7, [16]), %%------------------------------------------------- %% attribute presence(8) with type ENUMERATED %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = case decode_integer(V8, [10]) of 1 -> offline; 2 -> online; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute update(9) with type INTEGER %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = decode_integer(V9, [2]), %%------------------------------------------------- %% attribute created(10) with type INTEGER %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = decode_integer(V10, [2]), %%------------------------------------------------- %% attribute settings(11) with type SEQUENCE OF %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = 'dec_Person_settings'(V11, [16]), %%------------------------------------------------- %% attribute status(12) with type ENUMERATED %%------------------------------------------------- [V12|Tlv13] = Tlv12, Term12 = case decode_integer(V12, [10]) of 1 -> req; 2 -> auth; 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 = {'Person',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12}, Res1. 'dec_Person_names'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Person_surnames'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Person_settings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || 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. %%================================ %% 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,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute vsn(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute nickname(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute keys(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_Roster_keys'(Cindex5, [<<48>>]), %%------------------------------------------------- %% attribute people(6) with type SEQUENCE OF %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Roster_people'(Cindex6, [<<48>>]), %%------------------------------------------------- %% attribute topics(7) with type SEQUENCE OF %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_Roster_topics'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute channels(8) with type SEQUENCE OF %%------------------------------------------------- {EncBytes8,EncLen8} = 'enc_Roster_channels'(Cindex8, [<<48>>]), %%------------------------------------------------- %% attribute servers(9) with type SEQUENCE OF %%------------------------------------------------- {EncBytes9,EncLen9} = 'enc_Roster_servers'(Cindex9, [<<48>>]), %%------------------------------------------------- %% attribute update(10) with type INTEGER %%------------------------------------------------- {EncBytes10,EncLen10} = encode_integer(Cindex10, [<<2>>]), %%------------------------------------------------- %% attribute status(11) with type ENUMERATED %%------------------------------------------------- {EncBytes11,EncLen11} = case Cindex11 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); Enumval6 -> exit({error,{asn1, {enumerated_not_in_range,Enumval6}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Roster_keys %%================================ enc_Roster_keys(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Roster_keys_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Roster_keys_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Roster_keys_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Roster_keys_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Roster_people %%================================ enc_Roster_people(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Roster_people_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Roster_people_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Roster_people_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Person'(H, [<<48>>]), 'enc_Roster_people_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_Conference'(H, [<<48>>]), 'enc_Roster_topics_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Roster_channels %%================================ enc_Roster_channels(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Roster_channels_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Roster_channels_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Roster_channels_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Conference'(H, [<<48>>]), 'enc_Roster_channels_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Roster_servers %%================================ enc_Roster_servers(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Roster_servers_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Roster_servers_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Roster_servers_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Server'(H, [<<48>>]), 'enc_Roster_servers_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 vsn(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute nickname(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute keys(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_Roster_keys'(V5, [16]), %%------------------------------------------------- %% attribute people(6) with type SEQUENCE OF %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Roster_people'(V6, [16]), %%------------------------------------------------- %% attribute topics(7) with type SEQUENCE OF %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_Roster_topics'(V7, [16]), %%------------------------------------------------- %% attribute channels(8) with type SEQUENCE OF %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = 'dec_Roster_channels'(V8, [16]), %%------------------------------------------------- %% attribute servers(9) with type SEQUENCE OF %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = 'dec_Roster_servers'(V9, [16]), %%------------------------------------------------- %% attribute update(10) with type INTEGER %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = decode_integer(V10, [2]), %%------------------------------------------------- %% attribute status(11) with type ENUMERATED %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = case decode_integer(V11, [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 Tlv12 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv12}}}) % extra fields not allowed end, Res1 = {'Roster',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11}, Res1. 'dec_Roster_keys'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Roster_people'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Person'(V1, [16]) || V1 <- Tlv1]. 'dec_Roster_topics'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Conference'(V1, [16]) || V1 <- Tlv1]. 'dec_Roster_channels'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Conference'(V1, [16]) || V1 <- Tlv1]. 'dec_Roster_servers'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Server'(V1, [16]) || 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 OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute nickname(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]), %%------------------------------------------------- %% attribute feed(3) External CHAT-v2:MessageFeed %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_MessageFeed'(Cindex3, []), %%------------------------------------------------- %% attribute feeds(4) with type SEQUENCE OF %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_Member_feeds'(Cindex4, [<<48>>]), %%------------------------------------------------- %% attribute phone(5) with type OCTET STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<4>>]), %%------------------------------------------------- %% attribute avatar(6) with type OCTET STRING %%------------------------------------------------- {EncBytes6,EncLen6} = encode_restricted_string(Cindex6, [<<4>>]), %%------------------------------------------------- %% attribute names(7) with type SEQUENCE OF %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_Member_names'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute surnames(8) with type SEQUENCE OF %%------------------------------------------------- {EncBytes8,EncLen8} = 'enc_Member_surnames'(Cindex8, [<<48>>]), %%------------------------------------------------- %% attribute alias(9) with type OCTET STRING %%------------------------------------------------- {EncBytes9,EncLen9} = encode_restricted_string(Cindex9, [<<4>>]), %%------------------------------------------------- %% attribute update(10) with type INTEGER %%------------------------------------------------- {EncBytes10,EncLen10} = encode_integer(Cindex10, [<<2>>]), %%------------------------------------------------- %% attribute settings(11) with type SEQUENCE OF %%------------------------------------------------- {EncBytes11,EncLen11} = 'enc_Member_settings'(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); Enumval7 -> exit({error,{asn1, {enumerated_not_in_range,Enumval7}}}) 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); Enumval8 -> exit({error,{asn1, {enumerated_not_in_range,Enumval8}}}) 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_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). 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 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 feed(3) External CHAT-v2:MessageFeed %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_MessageFeed'(V3, []), %%------------------------------------------------- %% attribute feeds(4) with type SEQUENCE OF %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_Member_feeds'(V4, [16]), %%------------------------------------------------- %% attribute phone(5) with type OCTET STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_octet_string(V5, [4]), %%------------------------------------------------- %% attribute avatar(6) with type OCTET STRING %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = decode_octet_string(V6, [4]), %%------------------------------------------------- %% attribute names(7) with type SEQUENCE OF %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_Member_names'(V7, [16]), %%------------------------------------------------- %% attribute surnames(8) with type SEQUENCE OF %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = 'dec_Member_surnames'(V8, [16]), %%------------------------------------------------- %% attribute alias(9) with type OCTET STRING %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = decode_octet_string(V9, [4]), %%------------------------------------------------- %% attribute update(10) with type INTEGER %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = decode_integer(V10, [2]), %%------------------------------------------------- %% attribute settings(11) with type SEQUENCE OF %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = 'dec_Member_settings'(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_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]. %%================================ %% ConferenceType %%================================ enc_ConferenceType(Val) -> enc_ConferenceType(Val, [<<10>>]). enc_ConferenceType(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_ConferenceType(Tlv) -> dec_ConferenceType(Tlv, [10]). dec_ConferenceType(Tlv, TagIn) -> case decode_integer(Tlv, TagIn) of 1 -> group; 2 -> channel; 3 -> call; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end. %%================================ %% ConferenceStatus %%================================ enc_ConferenceStatus(Val) -> enc_ConferenceStatus(Val, [<<10>>]). enc_ConferenceStatus(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_ConferenceStatus(Tlv) -> dec_ConferenceStatus(Tlv, [10]). dec_ConferenceStatus(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. %%================================ %% Conference %%================================ enc_Conference(Val) -> enc_Conference(Val, [<<48>>]). enc_Conference(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12,Cindex13,Cindex14,Cindex15,Cindex16,Cindex17,Cindex18} = Val, %%------------------------------------------------- %% attribute id(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]), %%------------------------------------------------- %% attribute vsn(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [{v0,0},{v1,1},{v2,2},{v3,3}], [<<2>>]), %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), %%------------------------------------------------- %% attribute name(4) with type OCTET STRING %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<4>>]), %%------------------------------------------------- %% attribute links(5) with type SEQUENCE OF %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_Conference_links'(Cindex5, [<<48>>]), %%------------------------------------------------- %% attribute description(6) with type OCTET STRING %%------------------------------------------------- {EncBytes6,EncLen6} = encode_restricted_string(Cindex6, [<<4>>]), %%------------------------------------------------- %% attribute settings(7) with type SEQUENCE OF %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_Conference_settings'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute members(8) with type SEQUENCE OF %%------------------------------------------------- {EncBytes8,EncLen8} = 'enc_Conference_members'(Cindex8, [<<48>>]), %%------------------------------------------------- %% attribute admins(9) with type SEQUENCE OF %%------------------------------------------------- {EncBytes9,EncLen9} = 'enc_Conference_admins'(Cindex9, [<<48>>]), %%------------------------------------------------- %% attribute data(10) with type SEQUENCE OF %%------------------------------------------------- {EncBytes10,EncLen10} = 'enc_Conference_data'(Cindex10, [<<48>>]), %%------------------------------------------------- %% attribute type(11) with type ENUMERATED %%------------------------------------------------- {EncBytes11,EncLen11} = case Cindex11 of group -> encode_tags([<<10>>], [1], 1); channel -> encode_tags([<<10>>], [2], 1); call -> encode_tags([<<10>>], [3], 1); Enumval6 -> exit({error,{asn1, {enumerated_not_in_range,Enumval6}}}) end, %%------------------------------------------------- %% attribute tos(12) with type OCTET STRING %%------------------------------------------------- {EncBytes12,EncLen12} = encode_restricted_string(Cindex12, [<<4>>]), %%------------------------------------------------- %% attribute unread(13) with type INTEGER %%------------------------------------------------- {EncBytes13,EncLen13} = encode_integer(Cindex13, [<<2>>]), %%------------------------------------------------- %% attribute mentions(14) with type SEQUENCE OF %%------------------------------------------------- {EncBytes14,EncLen14} = 'enc_Conference_mentions'(Cindex14, [<<48>>]), %%------------------------------------------------- %% attribute lastmsg(15) External CHAT-v2:Message %%------------------------------------------------- {EncBytes15,EncLen15} = 'enc_Message'(Cindex15, [<<48>>]), %%------------------------------------------------- %% attribute update(16) with type INTEGER %%------------------------------------------------- {EncBytes16,EncLen16} = encode_integer(Cindex16, [<<2>>]), %%------------------------------------------------- %% attribute created(17) with type INTEGER %%------------------------------------------------- {EncBytes17,EncLen17} = encode_integer(Cindex17, [<<2>>]), %%------------------------------------------------- %% attribute status(18) with type ENUMERATED %%------------------------------------------------- {EncBytes18,EncLen18} = case Cindex18 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); Enumval11 -> exit({error,{asn1, {enumerated_not_in_range,Enumval11}}}) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13, EncBytes14, EncBytes15, EncBytes16, EncBytes17, EncBytes18], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13 + EncLen14 + EncLen15 + EncLen16 + EncLen17 + EncLen18, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Conference_links %%================================ enc_Conference_links(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Conference_links_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Conference_links_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Conference_links_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]), 'enc_Conference_links_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Conference_settings %%================================ enc_Conference_settings(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Conference_settings_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Conference_settings_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Conference_settings_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Feature'(H, [<<48>>]), 'enc_Conference_settings_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Conference_members %%================================ enc_Conference_members(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Conference_members_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Conference_members_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Conference_members_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Member'(H, [<<48>>]), 'enc_Conference_members_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Conference_admins %%================================ enc_Conference_admins(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Conference_admins_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Conference_admins_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Conference_admins_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Member'(H, [<<48>>]), 'enc_Conference_admins_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Conference_data %%================================ enc_Conference_data(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Conference_data_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Conference_data_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Conference_data_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_File'(H, [<<48>>]), 'enc_Conference_data_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% Conference_mentions %%================================ enc_Conference_mentions(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Conference_mentions_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Conference_mentions_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Conference_mentions_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_integer(H, [<<2>>]), 'enc_Conference_mentions_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Conference(Tlv) -> dec_Conference(Tlv, [16]). dec_Conference(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 vsn(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [2]), number2name(Val1, [{v0,0},{v1,1},{v2,2},{v3,3}]) end , %%------------------------------------------------- %% attribute session(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), %%------------------------------------------------- %% attribute name(4) with type OCTET STRING %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = decode_octet_string(V4, [4]), %%------------------------------------------------- %% attribute links(5) with type SEQUENCE OF %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_Conference_links'(V5, [16]), %%------------------------------------------------- %% attribute description(6) with type OCTET STRING %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = decode_octet_string(V6, [4]), %%------------------------------------------------- %% attribute settings(7) with type SEQUENCE OF %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_Conference_settings'(V7, [16]), %%------------------------------------------------- %% attribute members(8) with type SEQUENCE OF %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = 'dec_Conference_members'(V8, [16]), %%------------------------------------------------- %% attribute admins(9) with type SEQUENCE OF %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = 'dec_Conference_admins'(V9, [16]), %%------------------------------------------------- %% attribute data(10) with type SEQUENCE OF %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = 'dec_Conference_data'(V10, [16]), %%------------------------------------------------- %% attribute type(11) with type ENUMERATED %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = case decode_integer(V11, [10]) of 1 -> group; 2 -> channel; 3 -> call; Default1 -> exit({error,{asn1,{illegal_enumerated,Default1}}}) end, %%------------------------------------------------- %% attribute tos(12) with type OCTET STRING %%------------------------------------------------- [V12|Tlv13] = Tlv12, Term12 = decode_octet_string(V12, [4]), %%------------------------------------------------- %% attribute unread(13) with type INTEGER %%------------------------------------------------- [V13|Tlv14] = Tlv13, Term13 = decode_integer(V13, [2]), %%------------------------------------------------- %% attribute mentions(14) with type SEQUENCE OF %%------------------------------------------------- [V14|Tlv15] = Tlv14, Term14 = 'dec_Conference_mentions'(V14, [16]), %%------------------------------------------------- %% attribute lastmsg(15) External CHAT-v2:Message %%------------------------------------------------- [V15|Tlv16] = Tlv15, Term15 = 'dec_Message'(V15, [16]), %%------------------------------------------------- %% attribute update(16) with type INTEGER %%------------------------------------------------- [V16|Tlv17] = Tlv16, Term16 = decode_integer(V16, [2]), %%------------------------------------------------- %% attribute created(17) with type INTEGER %%------------------------------------------------- [V17|Tlv18] = Tlv17, Term17 = decode_integer(V17, [2]), %%------------------------------------------------- %% attribute status(18) with type ENUMERATED %%------------------------------------------------- [V18|Tlv19] = Tlv18, Term18 = case decode_integer(V18, [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 Tlv19 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv19}}}) % extra fields not allowed end, Res1 = {'Conference',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12,Term13,Term14,Term15,Term16,Term17,Term18}, Res1. 'dec_Conference_links'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_octet_string(V1, [4]) || V1 <- Tlv1]. 'dec_Conference_settings'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Feature'(V1, [16]) || V1 <- Tlv1]. 'dec_Conference_members'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Member'(V1, [16]) || V1 <- Tlv1]. 'dec_Conference_admins'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Member'(V1, [16]) || V1 <- Tlv1]. 'dec_Conference_data'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_File'(V1, [16]) || V1 <- Tlv1]. 'dec_Conference_mentions'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_integer(V1, [2]) || V1 <- Tlv1]. %%================================ %% CHATProtocol %%================================ enc_CHATProtocol(Val) -> enc_CHATProtocol(Val, []). enc_CHATProtocol(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of authority -> 'enc_Authority'(element(2,Val), [<<161>>]); message -> 'enc_Message'(element(2,Val), [<<162>>]); inbox -> 'enc_Inbox'(element(2,Val), [<<163>>]); ack -> 'enc_Ack'(element(2,Val), [<<164>>]); activity -> 'enc_Activity'(element(2,Val), [<<165>>]); subscription -> 'enc_Subscription'(element(2,Val), [<<166>>]); search -> 'enc_Search'(element(2,Val), [<<167>>]); roster -> 'enc_Roster'(element(2,Val), [<<168>>]); conference -> 'enc_Conference'(element(2,Val), [<<169>>]); 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 %% 'authority' {131073, V1} -> {authority, 'dec_Authority'(V1, [])}; %% 'message' {131074, V1} -> {message, 'dec_Message'(V1, [])}; %% 'inbox' {131075, V1} -> {inbox, 'dec_Inbox'(V1, [])}; %% 'ack' {131076, V1} -> {ack, 'dec_Ack'(V1, [])}; %% 'activity' {131077, V1} -> {activity, 'dec_Activity'(V1, [])}; %% 'subscription' {131078, V1} -> {subscription, 'dec_Subscription'(V1, [])}; %% 'search' {131079, V1} -> {search, 'dec_Search'(V1, [])}; %% 'roster' {131080, V1} -> {roster, 'dec_Roster'(V1, [])}; %% 'conference' {131081, V1} -> {conference, 'dec_Conference'(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-v2: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-v2: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)). encode_integer(Val) -> Bytes = if Val >= 0 -> encode_integer_pos(Val, []); true -> encode_integer_neg(Val, []) end, {Bytes, length(Bytes)}. encode_integer(Val, NamedNumberList, Tag) when is_atom(Val) -> case lists:keyfind(Val, 1, NamedNumberList) of {_, NewVal} -> encode_tags(Tag, encode_integer(NewVal)); _ -> exit({error, {asn1, {encode_integer_namednumber, Val}}}) end; encode_integer(Val, _NamedNumberList, Tag) -> encode_tags(Tag, encode_integer(Val)). encode_integer(Val, Tag) when is_integer(Val) -> encode_tags(Tag, encode_integer(Val)); encode_integer(Val, _Tag) -> exit({error, {asn1, {encode_integer, Val}}}). encode_integer_neg(-1, [B1 | _T] = L) when B1 > 127 -> L; encode_integer_neg(N, Acc) -> encode_integer_neg(N bsr 8, [N band 255 | Acc]). encode_integer_pos(0, [B | _Acc] = L) when B < 128 -> L; encode_integer_pos(N, Acc) -> encode_integer_pos(N bsr 8, [N band 255 | Acc]). encode_length(L) when L =< 127 -> {[L], 1}; encode_length(L) -> Oct = minimum_octets(L), Len = length(Oct), if Len =< 126 -> {[128 bor Len | Oct], Len + 1}; true -> exit({error, {asn1, too_long_length_oct, Len}}) end. encode_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}. 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, []). number2name(Int, NamedNumberList) -> case lists:keyfind(Int, 2, NamedNumberList) of {NamedVal, _} -> NamedVal; _ -> Int end.