diff options
author | Björn Gustavsson <[email protected]> | 2012-12-21 15:08:59 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-01-22 19:20:13 +0100 |
commit | 2e57d4603575f492f54409e8235806ee6702944c (patch) | |
tree | a94fcbb5292e042aa5b0c15bca237da643022fd7 /lib/asn1/src/asn1rtt_uper.erl | |
parent | 3f8be66021a5b3ce764181a2f9685ed7bfc81607 (diff) | |
download | otp-2e57d4603575f492f54409e8235806ee6702944c.tar.gz otp-2e57d4603575f492f54409e8235806ee6702944c.tar.bz2 otp-2e57d4603575f492f54409e8235806ee6702944c.zip |
uper: Look up some SizeConstraints at compile-time
Diffstat (limited to 'lib/asn1/src/asn1rtt_uper.erl')
-rw-r--r-- | lib/asn1/src/asn1rtt_uper.erl | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/asn1/src/asn1rtt_uper.erl b/lib/asn1/src/asn1rtt_uper.erl index 34971f09e3..a9479471eb 100644 --- a/lib/asn1/src/asn1rtt_uper.erl +++ b/lib/asn1/src/asn1rtt_uper.erl @@ -27,7 +27,7 @@ encode_boolean/1, encode_length/1, encode_length/2, encode_bit_string/3]). --export([encode_octet_string/2, +-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, complete/1, complete_NFP/1]). @@ -496,10 +496,10 @@ encode_boolean(Val) -> encode_bit_string(C, {Unused,BinBits}=Bin, NamedBitList) when is_integer(Unused), is_binary(BinBits) -> - encode_bin_bit_string(get_constraint(C,'SizeConstraint'),Bin,NamedBitList); + encode_bin_bit_string(C, Bin, NamedBitList); encode_bit_string(C, BitListVal, NamedBitList) -> - encode_bit_string1(get_constraint(C, 'SizeConstraint'), BitListVal, NamedBitList). + encode_bit_string1(C, BitListVal, NamedBitList). %% when the value is a list of named bits encode_bit_string1(C, [FirstVal|_RestVal]=LoNB, NamedBitList) @@ -704,13 +704,20 @@ make_and_set_list([], _) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% X.691:16 -%% encode_octet_string(Constraint,Val) +%% encode_octet_string(Val) +%% encode_octet_string(Constraint, Val) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -encode_octet_string(C,Val) -> - case get_constraint(C,'SizeConstraint') of - 0 -> - <<>>; +encode_octet_string(Val) -> + try + [encode_length(length(Val)),list_to_binary(Val)] + catch + error:{error,{asn1,{encode_length,_}}} -> + encode_fragmented_octet_string(Val) + end. + +encode_octet_string(C, Val) -> + case C of 1 -> list_to_binary(Val); 2 -> @@ -736,16 +743,10 @@ encode_octet_string(C,Val) -> catch error:{error,{asn1,{encode_length,_}}} -> encode_fragmented_octet_string(Val) - end; - no -> - try - [encode_length(length(Val)),list_to_binary(Val)] - catch - error:{error,{asn1,{encode_length,_}}} -> - encode_fragmented_octet_string(Val) end end. + encode_fragmented_octet_string(Val) -> Bin = list_to_binary(Val), efos_1(Bin). |