aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1rtt_per.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_per.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_per.erl')
-rw-r--r--lib/asn1/src/asn1rtt_per.erl47
1 files changed, 2 insertions, 45 deletions
diff --git a/lib/asn1/src/asn1rtt_per.erl b/lib/asn1/src/asn1rtt_per.erl
index 2bcf459330..7194e8d127 100644
--- a/lib/asn1/src/asn1rtt_per.erl
+++ b/lib/asn1/src/asn1rtt_per.erl
@@ -26,8 +26,8 @@
encode_length/1,
encode_length/2,
encode_bit_string/3,
- encode_object_identifier/1, decode_object_identifier/1,
- encode_relative_oid/1, decode_relative_oid/1,
+ encode_object_identifier/1,
+ encode_relative_oid/1,
complete/1,
encode_open_type/1,
encode_GeneralString/2,
@@ -134,12 +134,6 @@ getoctets_as_bin(Bin,Num) when is_bitstring(Bin) ->
<<_:AlignBits,Val:Num/binary,RestBin/binary>> = Bin,
{Val,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()
@@ -977,33 +971,6 @@ e_o_e(Num) when Num < 128 ->
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
@@ -1014,16 +981,6 @@ encode_relative_oid(Val) when is_list(Val) ->
Sz = byte_size(Octets),
[encode_length(Sz)|octets_to_complete(Sz, 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}.
-
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% complete(InList) -> ByteList
%% Takes a coded list with bits and bytes and converts it to a list of bytes