aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1rtt_uper.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-01-23 06:56:14 +0100
committerBjörn Gustavsson <[email protected]>2013-01-23 15:22:57 +0100
commit13694772383b66b6fad2ba8e17662a0e71b05110 (patch)
tree518a3479c94e223cceffef825aa8a47bf42cd5e7 /lib/asn1/src/asn1rtt_uper.erl
parentf16f43446a04c459486356c0b4ad517cc9201895 (diff)
downloadotp-13694772383b66b6fad2ba8e17662a0e71b05110.tar.gz
otp-13694772383b66b6fad2ba8e17662a0e71b05110.tar.bz2
otp-13694772383b66b6fad2ba8e17662a0e71b05110.zip
Simplify the functions for decoding lengths
Now that the decoding of all types are generated inline, we can take out most of the code for decoding lengths.
Diffstat (limited to 'lib/asn1/src/asn1rtt_uper.erl')
-rw-r--r--lib/asn1/src/asn1rtt_uper.erl36
1 files changed, 6 insertions, 30 deletions
diff --git a/lib/asn1/src/asn1rtt_uper.erl b/lib/asn1/src/asn1rtt_uper.erl
index d78116cc92..b5e8a3c3bb 100644
--- a/lib/asn1/src/asn1rtt_uper.erl
+++ b/lib/asn1/src/asn1rtt_uper.erl
@@ -113,7 +113,7 @@ skipextensions(Bytes0, Nr, ExtensionBitstr) when is_bitstring(ExtensionBitstr) -
Prev = Nr - 1,
case ExtensionBitstr of
<<_:Prev,1:1,_/bitstring>> ->
- {Len,Bytes1} = decode_length(Bytes0, undefined),
+ {Len,Bytes1} = decode_length(Bytes0),
<<_:Len/binary,Bytes2/bitstring>> = Bytes1,
skipextensions(Bytes2, Nr+1, ExtensionBitstr);
<<_:Prev,0:1,_/bitstring>> ->
@@ -290,7 +290,7 @@ encode_semi_constrained_number(Lb, Val) ->
end.
decode_semi_constrained_number(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes, undefined),
+ {Len,Bytes2} = decode_length(Bytes),
{V,Bytes3} = getoctets(Bytes2,Len),
{V,Bytes3}.
@@ -416,36 +416,12 @@ encode_small_length(Len) ->
%% un-constrained
-decode_length(<<0:1,Oct:7,Rest/bitstring>>,undefined) ->
+decode_length(<<0:1,Oct:7,Rest/bitstring>>) ->
{Oct,Rest};
-decode_length(<<2:2,Val:14,Rest/bitstring>>,undefined) ->
+decode_length(<<2:2,Val:14,Rest/bitstring>>) ->
{Val,Rest};
-decode_length(<<3:2,_:14,_Rest/bitstring>>,undefined) ->
- exit({error,{asn1,{decode_length,{nyi,above_16k}}}});
-
-decode_length(Buffer,{Lb,Ub}) when Ub =< 65535, Lb >= 0 -> % constrained
- decode_constrained_number(Buffer,{Lb,Ub});
-decode_length(Buffer,{Lb,_}) when is_integer(Lb), Lb >= 0 -> % Ub > 65535
- decode_length(Buffer,undefined);
-decode_length(Buffer,{VR={_Lb,_Ub},Ext}) when is_list(Ext) ->
- {0,Buffer2} = getbit(Buffer),
- decode_length(Buffer2, VR);
-
-
-%When does this case occur with {_,_Lb,Ub} ??
-% X.691:10.9.3.5
-decode_length(Bin,{_,_Lb,_Ub}) -> %when Len =< 127 -> % Unconstrained or large Ub NOTE! this case does not cover case when Ub > 65535
- case Bin of
- <<0:1,Val:7,Rest/bitstring>> ->
- {Val,Rest};
- <<2:2,Val:14,Rest/bitstring>> ->
- {Val,Rest};
- <<3:2,_:14,_Rest/bitstring>> ->
- exit({error,{asn1,{decode_length,{nyi,length_above_64K}}}})
- end;
-decode_length(Buffer,SingleValue) when is_integer(SingleValue) ->
- {SingleValue,Buffer}.
-
+decode_length(<<3:2,_:14,_Rest/bitstring>>) ->
+ exit({error,{asn1,{decode_length,{nyi,above_16k}}}}).
% X.691:11
encode_boolean(true) ->