From e49b3c6129fc57e5adbd478f3494c66654870acf Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 23 Oct 2015 12:56:08 +0200 Subject: ROSE --- Remote-Operations-Information-Objects.erl | 291 ------------------------------ 1 file changed, 291 deletions(-) delete mode 100644 Remote-Operations-Information-Objects.erl (limited to 'Remote-Operations-Information-Objects.erl') diff --git a/Remote-Operations-Information-Objects.erl b/Remote-Operations-Information-Objects.erl deleted file mode 100644 index 2febde3..0000000 --- a/Remote-Operations-Information-Objects.erl +++ /dev/null @@ -1,291 +0,0 @@ -%% Generated by the Erlang ASN.1 BER_V2-compiler version, utilizing bit-syntax:4.0 -%% Purpose: encoder and decoder to the types in mod Remote-Operations-Information-Objects - --module('Remote-Operations-Information-Objects'). --compile(nowarn_unused_vars). --asn1_info([{vsn,'4.0'}, - {module,'Remote-Operations-Information-Objects'}, - {options,[{i,"/Users/quax/erl"}, - warnings,ber,errors, - {cwd,"/Users/quax/erl"}, - {outdir,"/Users/quax/erl"}, - {i,"."}, - {i,"/Users/quax/erl/rose"}]}]). - --export([encoding_rule/0,bit_string_format/0, - legacy_erlang_types/0]). --export(['dialyzer-suppressions'/1]). --export([ -'enc_Code'/2, -'enc_Priority'/2 -]). - --export([ -'dec_Code'/2, -'dec_Priority'/2 -]). - --export([info/0]). - - --export([encode/2,decode/2]). - -encoding_rule() -> ber. - -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 when Class =:= error; Class =:= exit -> - case Exception of - {error,Reason}=Error -> - Error; - Reason -> - {error,{asn1,Reason}} - end -end. - -decode(Type,Data) -> -try decode_disp(Type, element(1, ber_decode_nif(Data))) of - Result -> - {ok,Result} - catch - Class:Exception when Class =:= error; Class =:= exit -> - case Exception of - {error,Reason}=Error -> - Error; - Reason -> - {error,{asn1,Reason}} - end -end. - -encode_disp('Code',Data) -> 'enc_Code'(Data); -encode_disp('Priority',Data) -> 'enc_Priority'(Data); -encode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}). - - -decode_disp('Code',Data) -> 'dec_Code'(Data); -decode_disp('Priority',Data) -> 'dec_Priority'(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. - - -%%================================ -%% Code -%%================================ -'enc_Code'(Val) -> - 'enc_Code'(Val, []). - -'enc_Code'(Val, TagIn) -> - {EncBytes,EncLen} = case element(1,Val) of - local -> - encode_integer(element(2,Val), [<<2>>]); - global -> - encode_object_identifier(element(2,Val), [<<6>>]); - Else -> - exit({error,{asn1,{invalid_choice_type,Else}}}) - end, - -encode_tags(TagIn, EncBytes, EncLen). - - - - -'dec_Code'(Tlv) -> - 'dec_Code'(Tlv, []). - -'dec_Code'(Tlv, TagIn) -> -Tlv1 = match_tags(Tlv, TagIn), -case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of - -%% 'local' - {2, V1} -> - {local, decode_integer(V1, [])}; - - -%% 'global' - {6, V1} -> - {global, decode_object_identifier(V1, [])}; - - Else -> - exit({error,{asn1,{invalid_choice_tag,Else}}}) - end -. - - -%%================================ -%% Priority -%%================================ -'enc_Priority'(Val) -> - 'enc_Priority'(Val, [<<2>>]). - -'enc_Priority'(Val, TagIn) -> -encode_integer(Val, TagIn). - - -'dec_Priority'(Tlv) -> - 'dec_Priority'(Tlv, [2]). - -'dec_Priority'(Tlv, TagIn) -> -begin -Val1 = decode_integer(Tlv, TagIn), -if 0 =< Val1, Val1 =< 'MAX' -> -Val1; -true -> -exit({error,{asn1,bad_range}}) -end -end. - - -%%% -%%% Run-time functions. -%%% - -'dialyzer-suppressions'(Arg) -> - ok. - -ber_decode_nif(B) -> - asn1rt_nif:decode_ber_tlv(B). - -dec_subidentifiers(<<>>, _Av, Al) -> - lists:reverse(Al); -dec_subidentifiers(<<1:1,H:7,T/binary>>, Av, Al) -> - dec_subidentifiers(T, Av bsl 7 + H, Al); -dec_subidentifiers(<>, Av, Al) -> - dec_subidentifiers(T, 0, [Av bsl 7 + H|Al]). - -decode_integer(Tlv, TagIn) -> - Bin = match_tags(Tlv, TagIn), - Len = byte_size(Bin), - <> = Bin, - Int. - -decode_object_identifier(Tlv, Tags) -> - Val = match_tags(Tlv, Tags), - [AddedObjVal|ObjVals] = dec_subidentifiers(Val, 0, []), - {Val1,Val2} = - if - AddedObjVal < 40 -> - {0,AddedObjVal}; - AddedObjVal < 80 -> - {1,AddedObjVal - 40}; - true -> - {2,AddedObjVal - 80} - end, - list_to_tuple([Val1,Val2|ObjVals]). - -e_object_identifier({'OBJECT IDENTIFIER',V}) -> - e_object_identifier(V); -e_object_identifier(V) when is_tuple(V) -> - e_object_identifier(tuple_to_list(V)); -e_object_identifier([E1,E2|Tail]) -> - Head = 40 * E1 + E2, - {H,Lh} = mk_object_val(Head), - {R,Lr} = lists:mapfoldl(fun enc_obj_id_tail/2, 0, Tail), - {[H|R],Lh + Lr}. - -enc_obj_id_tail(H, Len) -> - {B,L} = mk_object_val(H), - {B,Len + L}. - -encode_integer(Val) -> - Bytes = - if - Val >= 0 -> - encode_integer_pos(Val, []); - true -> - encode_integer_neg(Val, []) - end, - {Bytes,length(Bytes)}. - -encode_integer(Val, Tag) when is_integer(Val) -> - encode_tags(Tag, encode_integer(Val)); -encode_integer(Val, _Tag) -> - exit({error,{asn1,{encode_integer,Val}}}). - -encode_integer_neg(- 1, [B1|_T] = L) when B1 > 127 -> - L; -encode_integer_neg(N, Acc) -> - encode_integer_neg(N bsr 8, [N band 255|Acc]). - -encode_integer_pos(0, [B|_Acc] = L) when B < 128 -> - L; -encode_integer_pos(N, Acc) -> - encode_integer_pos(N bsr 8, [N band 255|Acc]). - -encode_length(L) when L =< 127 -> - {[L],1}; -encode_length(L) -> - Oct = minimum_octets(L), - Len = length(Oct), - if - Len =< 126 -> - {[128 bor Len|Oct],Len + 1}; - true -> - exit({error,{asn1,too_long_length_oct,Len}}) - end. - -encode_object_identifier(Val, TagIn) -> - encode_tags(TagIn, e_object_identifier(Val)). - -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_tags({T,V}, [T]) -> - V; -match_tags({T,V}, [T|Tt]) -> - match_tags(V, Tt); -match_tags([{T,V}], [T|Tt]) -> - match_tags(V, Tt); -match_tags([{T,_V}|_] = Vlist, [T]) -> - Vlist; -match_tags(Tlv, []) -> - Tlv; -match_tags({Tag,_V} = Tlv, [T|_Tt]) -> - exit({error,{asn1,{wrong_tag,{{expected,T},{got,Tag,Tlv}}}}}). - -minimum_octets(0, Acc) -> - Acc; -minimum_octets(Val, Acc) -> - minimum_octets(Val bsr 8, [Val band 255|Acc]). - -minimum_octets(Val) -> - minimum_octets(Val, []). - -mk_object_val(0, Ack, Len) -> - {Ack,Len}; -mk_object_val(Val, Ack, Len) -> - mk_object_val(Val bsr 7, [Val band 127 bor 128|Ack], Len + 1). - -mk_object_val(Val) when Val =< 127 -> - {[255 band Val],1}; -mk_object_val(Val) -> - mk_object_val(Val bsr 7, [Val band 127], 1). -- cgit v1.2.3