aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1rt_ber_bin_v2.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1/src/asn1rt_ber_bin_v2.erl')
-rw-r--r--lib/asn1/src/asn1rt_ber_bin_v2.erl30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/asn1/src/asn1rt_ber_bin_v2.erl b/lib/asn1/src/asn1rt_ber_bin_v2.erl
index 16b7556d72..bef2216091 100644
--- a/lib/asn1/src/asn1rt_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1rt_ber_bin_v2.erl
@@ -21,7 +21,7 @@
%% encoding / decoding of BER
--export([decode/1, decode/2, match_tags/2, encode/1]).
+-export([decode/1, decode/2, match_tags/2, encode/1, encode/2]).
-export([fixoptionals/2, cindex/3,
list_to_record/2,
encode_tag_val/1,
@@ -50,7 +50,8 @@
-export([encode_open_type/1,encode_open_type/2,
decode_open_type/2,decode_open_type/3,
- decode_open_type_as_binary/2]).
+ decode_open_type_as_binary/2,
+ decode_open_type_as_binary/3]).
-export([decode_primitive_incomplete/2,decode_selective/2]).
@@ -128,20 +129,23 @@
% encode(Tlv) ->
% encode_constructed(Tlv).
-encode(Tlv) when is_binary(Tlv) ->
- Tlv;
-encode([Tlv]) ->
- encode(Tlv);
encode(Tlv) ->
+ encode(Tlv,erlang).
+
+encode(Tlv,_) when is_binary(Tlv) ->
+ Tlv;
+encode([Tlv],Method) ->
+ encode(Tlv,Method);
+encode(Tlv, nif) ->
case is_nif_loadable() of
true ->
asn1rt_nif:encode_ber_tlv(Tlv);
false ->
encode_erl(Tlv)
- end.
+ end;
+encode(Tlv, _) ->
+ encode_erl(Tlv).
-encode_erl([Tlv]) ->
- encode_erl(Tlv);
encode_erl({TlvTag,TlvVal}) when is_list(TlvVal) ->
%% constructed form of value
encode_tlv(TlvTag,TlvVal,?CONSTRUCTED);
@@ -800,12 +804,14 @@ decode_open_type(Tlv, TagIn, Method) ->
end.
-decode_open_type_as_binary(Tlv,TagIn)->
+decode_open_type_as_binary(Tlv, TagIn) ->
+ decode_open_type_as_binary(Tlv, TagIn, erlang).
+decode_open_type_as_binary(Tlv,TagIn, Method)->
case match_tags(Tlv,TagIn) of
V when is_binary(V) ->
V;
- [Tlv2] -> encode(Tlv2);
- Tlv2 -> encode(Tlv2)
+ [Tlv2] -> encode(Tlv2, Method);
+ Tlv2 -> encode(Tlv2, Method)
end.
%%===============================================================================