aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1rtt_uper.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-01-22 17:25:09 +0100
committerBjörn Gustavsson <[email protected]>2013-01-23 15:22:56 +0100
commitf16f43446a04c459486356c0b4ad517cc9201895 (patch)
tree62f35292fab66f098f1b288418429a4c17010eef /lib/asn1/src/asn1rtt_uper.erl
parentdc17110cd88153a74900d71d35df608f5d58c0f3 (diff)
downloadotp-f16f43446a04c459486356c0b4ad517cc9201895.tar.gz
otp-f16f43446a04c459486356c0b4ad517cc9201895.tar.bz2
otp-f16f43446a04c459486356c0b4ad517cc9201895.zip
per,uper: Optimize decoding of the remaining data types
Diffstat (limited to 'lib/asn1/src/asn1rtt_uper.erl')
-rw-r--r--lib/asn1/src/asn1rtt_uper.erl51
1 files changed, 2 insertions, 49 deletions
diff --git a/lib/asn1/src/asn1rtt_uper.erl b/lib/asn1/src/asn1rtt_uper.erl
index fa4f08363b..d78116cc92 100644
--- a/lib/asn1/src/asn1rtt_uper.erl
+++ b/lib/asn1/src/asn1rtt_uper.erl
@@ -28,8 +28,8 @@
encode_length/1, encode_length/2,
encode_bit_string/3]).
-export([encode_octet_string/1,encode_octet_string/2,
- encode_relative_oid/1, decode_relative_oid/1,
- encode_object_identifier/1, decode_object_identifier/1,
+ encode_relative_oid/1,
+ encode_object_identifier/1,
complete/1, complete_NFP/1]).
-export([encode_open_type/1]).
@@ -146,17 +146,6 @@ getoctets(Buffer, Num) when is_bitstring(Buffer) ->
<<Val:Num/integer-unit:8,RestBitStr/bitstring>> = Buffer,
{Val,RestBitStr}.
-%% Pick the first Num octets.
-%% Returns octets as a binary
-getoctets_as_bin(Bin,Num) when is_bitstring(Bin) ->
- <<Octets:Num/binary,RestBin/bitstring>> = Bin,
- {Octets,RestBin}.
-
-%% same as above but returns octets as a List
-getoctets_as_list(Buffer,Num) ->
- {Bin,Buffer2} = getoctets_as_bin(Buffer, Num),
- {binary_to_list(Bin),Buffer2}.
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% set_choice(Alt,Choices,Altnum) -> ListofBitSettings
%% Alt = atom()
@@ -1014,32 +1003,6 @@ e_o_e(Num) ->
[e_o_e(Num bsr 7)|[(Num band 2#1111111) bor 2#10000000]].
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% decode_object_identifier(Bytes) -> {ObjId,RemainingBytes}
-%% ObjId -> {integer(),integer(),...} % at least 2 integers
-%% RemainingBytes -> [integer()] when integer() (0..255)
-decode_object_identifier(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- {Octs,Bytes3} = getoctets_as_list(Bytes2,Len),
- [First|Rest] = dec_subidentifiers(Octs,0,[]),
- Idlist = if
- First < 40 ->
- [0,First|Rest];
- First < 80 ->
- [1,First - 40|Rest];
- true ->
- [2,First - 80|Rest]
- end,
- {list_to_tuple(Idlist),Bytes3}.
-
-dec_subidentifiers([H|T],Av,Al) when H >=16#80 ->
- dec_subidentifiers(T, (Av bsl 7) + (H band 16#7F),Al);
-dec_subidentifiers([H|T],Av,Al) ->
- dec_subidentifiers(T,0, [(Av bsl 7) + H |Al]);
-dec_subidentifiers([],_Av,Al) ->
- lists:reverse(Al).
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% encode_relative_oid(Val) -> CompleteList
%% encode_relative_oid({Name,Val}) -> CompleteList
@@ -1050,16 +1013,6 @@ encode_relative_oid(Val) when is_list(Val) ->
[encode_length(byte_size(Octets)),Octets].
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% decode_relative_oid(Val) -> CompleteList
-%% decode_relative_oid({Name,Val}) -> CompleteList
-decode_relative_oid(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- {Octs,Bytes3} = getoctets_as_list(Bytes2,Len),
- ObjVals = dec_subidentifiers(Octs,0,[]),
- {list_to_tuple(ObjVals),Bytes3}.
-
-
get_constraint([{Key,V}],Key) ->
V;
get_constraint([],_Key) ->