asn1: swapped fields
Bertil Karlsson
bertil.karlsson@REDACTED
Wed Jan 8 14:03:56 CET 2003
Hello,
This is definitely a bug, and it will be corrected in the next patch.
/Bertil Karlsson
"Jozsef Berces (QCZ)" wrote:
>
> Hi,
>
> I have compiled RANAP with asn1ct and the decoder erlang code produces swapped fields for ProtocolIE-FieldPair: firstValue and secondCriticality are swapped in the resulting record. Here I am posting a simplified example.
>
> If you try to compile the attached file RAB-SetupOrModifyList.asn with option per, then for the sequence
>
> ProtocolIE-FieldPair {RANAP-PROTOCOL-IES-PAIR : IEsSetParam} ::= SEQUENCE {
> id RANAP-PROTOCOL-IES-PAIR.&id ({IEsSetParam}),
> firstCriticality RANAP-PROTOCOL-IES-PAIR.&firstCriticality ({IEsSetParam}{@id}),
> firstValue RANAP-PROTOCOL-IES-PAIR.&FirstValue ({IEsSetParam}{@id}),
> secondCriticality RANAP-PROTOCOL-IES-PAIR.&secondCriticality ({IEsSetParam}{@id}),
> secondValue RANAP-PROTOCOL-IES-PAIR.&SecondValue ({IEsSetParam}{@id})
> }
>
> the erlang code will be
>
> 'dec_RAB-SetupOrModifyList_SEQOF_ProtocolIE-FieldPair'(Bytes,Telltype) ->
>
> %% attribute number 1 with type id
> {Term1,Bytes1} = ?RT_PER:decode_integer(Bytes,[{'ValueRange',{0,65535}}]),
>
> %% attribute number 2 with type firstCriticality
> {Term2,Bytes2} = ?RT_PER:decode_enumerated(Bytes1,[{'ValueRange',{0,2}}],{reject,ignore,notify}),
>
> %% attribute number 3 with type FirstValue
> {Tmpterm1, Bytes3} = ?RT_PER:decode_open_type(Bytes2, []),
>
> %% attribute number 4 with type secondCriticality
> {Term3,Bytes4} = ?RT_PER:decode_enumerated(Bytes3,[{'ValueRange',{0,2}}],{reject,ignore,notify}),
>
> %% attribute number 5 with type SecondValue
> {Tmpterm2, Bytes5} = ?RT_PER:decode_open_type(Bytes4, []),
> DecObjidTerm1 =
> 'getdec_RAB-SetupOrModifyItem-IEs'(id, Term1),
> {Term4, _} =
> case DecObjidTerm1('FirstValue', Tmpterm1, telltype,[]) of
> {'EXIT', Reason1} ->
> exit({'Type not compatible with table constraint',Reason1});
> Tmpterm3 ->
> Tmpterm3
> end,
> {Term5, _} =
> case DecObjidTerm1('SecondValue', Tmpterm2, telltype,[]) of
> {'EXIT', Reason2} ->
> exit({'Type not compatible with table constraint',Reason2});
> Tmpterm4 ->
> Tmpterm4
> end,
>
> {{'ProtocolIE-FieldPair',Term1,Term2,Term3,Term4,Term5},Bytes5}.
>
>
> It can be seen that attribute number 3 is assigned to Term4 and attribute number 4 goes to Term3. It seems that the problem is to have the 'getdec_RAB-SetupOrModifyItem-IEs'(id, Term1) call too late, so Term4 will receive attribute number 3.
>
> I attached the results for different options: per, per_bin, and ber. per and per_bin are the same but ber is even worse (however, RANAP uses PER encoding)!
>
> Could someone post a fix? Until then we have to modify the erang code manually.
>
> Thanks in advance,
> Jozsef
>
> ------------------------------------------------------------------------
>
> RAB-SetupOrModifyList.asnName: RAB-SetupOrModifyList.asn
> Type: unspecified type (application/octet-stream)
>
> Name: RAB-SetupOrModifyList.ber.erl
> RAB-SetupOrModifyList.ber.erl Type: unspecified type (application/octet-stream)
> Encoding: quoted-printable
>
> Name: RAB-SetupOrModifyList.per.erl
> RAB-SetupOrModifyList.per.erl Type: unspecified type (application/octet-stream)
> Encoding: quoted-printable
>
> Name: RAB-SetupOrModifyList.per_bin.erl
> RAB-SetupOrModifyList.per_bin.erl Type: unspecified type (application/octet-stream)
> Encoding: quoted-printable
--
/ Bertil Karlsson
More information about the erlang-questions
mailing list