Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorng committed Oct 24, 2023
1 parent 78ac7fd commit 2f536be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
9 changes: 4 additions & 5 deletions lib/asn1/src/asn1ct_partial_decode.erl
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,14 @@ get_tag_command(#type{}, ?SKIP) ->
?SKIP;
get_tag_command(#type{tag=Tags}, ?SKIP_OPTIONAL) ->
Tag = hd(Tags),
[?SKIP_OPTIONAL,
{?SKIP_OPTIONAL,
?ASN1CT_GEN_BER:encode_tag_val(?ASN1CT_GEN_BER:decode_class(Tag#tag.class),
Tag#tag.form, Tag#tag.number)];
Tag#tag.form, Tag#tag.number)};
get_tag_command(#type{tag=[Tag]}, Command) ->
%% encode the tag according to BER
[Command,
{Command,
?ASN1CT_GEN_BER:encode_tag_val(?ASN1CT_GEN_BER:decode_class(Tag#tag.class),
Tag#tag.form,
Tag#tag.number)];
Tag#tag.number)};
get_tag_command(T=#type{tag=[Tag|Tags]},Command) ->
TC = get_tag_command(T#type{tag=[Tag]}, Command),
TCs = get_tag_command(T#type{tag=Tags}, Command),
Expand Down
44 changes: 22 additions & 22 deletions lib/asn1/src/asn1rtt_ber.erl
Original file line number Diff line number Diff line change
Expand Up @@ -352,35 +352,35 @@ incomplete_choice_alt(_,[]) ->
%% Returns {ok,Value} or {error,Reason}
%% Value is a binary that in turn must be decoded to get the decoded
%% value.
decode_selective([],Binary) ->
decode_selective([], Binary) ->
{ok,Binary};
decode_selective([skip|RestPattern],Binary)->
{ok,RestBinary}=skip_tag(Binary),
{ok,RestBinary2}=skip_length_and_value(RestBinary),
decode_selective(RestPattern,RestBinary2);
decode_selective([[skip_optional,Tag]|RestPattern],Binary) ->
case skip_optional_tag(Tag,Binary) of
{ok,RestBinary} ->
{ok,RestBinary2}=skip_length_and_value(RestBinary),
decode_selective(RestPattern,RestBinary2);
missing ->
decode_selective(RestPattern,Binary)
decode_selective([skip|RestPattern], Binary)->
{ok,RestBinary} = skip_tag(Binary),
{ok,RestBinary2} = skip_length_and_value(RestBinary),
decode_selective(RestPattern, RestBinary2);
decode_selective([{skip_optional,Tag}|RestPattern], Binary) ->
case skip_optional_tag(Tag, Binary) of
{ok,RestBinary} ->
{ok,RestBinary2} = skip_length_and_value(RestBinary),
decode_selective(RestPattern, RestBinary2);
missing ->
decode_selective(RestPattern, Binary)
end;
decode_selective([[chosen,Tag]],Binary) ->
return_value(Tag,Binary);
decode_selective([[chosen,Tag]|RestPattern],Binary) ->
case skip_optional_tag(Tag,Binary) of
{ok,RestBinary} ->
{ok,Value} = get_value(RestBinary),
decode_selective(RestPattern,Value);
missing ->
{ok,<<>>}
decode_selective([{chosen,Tag}], Binary) ->
return_value(Tag, Binary);
decode_selective([{chosen,Tag}|RestPattern], Binary) ->
case skip_optional_tag(Tag, Binary) of
{ok,RestBinary} ->
{ok,Value} = get_value(RestBinary),
decode_selective(RestPattern,Value);
missing ->
{ok,<<>>}
end;
decode_selective(P,_) ->
{error,{asn1,{partial_decode,"bad pattern",P}}}.

return_value(Tag,Binary) ->
{ok,{Tag,RestBinary}}=get_tag(Binary),
{ok,{Tag,RestBinary}} = get_tag(Binary),
{ok,{LenVal,_RestBinary2}} = get_length_and_value(RestBinary),
{ok,<<Tag/binary,LenVal/binary>>}.

Expand Down

0 comments on commit 2f536be

Please sign in to comment.