[erlang-questions] asn1rt decode of 3GPP RANAP-PDU
Kenneth Lundin
kenneth.lundin@REDACTED
Wed Oct 21 10:52:01 CEST 2009
On Thu, Oct 15, 2009 at 7:39 AM, Mark Wallis <markjwallis@REDACTED> wrote:
> Dear Forum
>
> I have compiled the ASN.1 for 3GPP RANAP using the following options
>
> %% Generated by the Erlang ASN.1 BER-compiler version, utilizing
> bit-syntax:1.6.10
> %% Purpose: encoder and decoder to the types in mod RANAP
>
> -module('RANAP').
> -include("RANAP.hrl").
> -define('RT_PER',asn1rt_per_bin).
> -asn1_info([{vsn,'1.6.10'},
> {module,'RANAP'},
> {options,[per_bin,undec_rest,{i,[46]}]}]).
>
>
> When I pass a RANAP-PDU through the deocder it decodes successfully but only
> prints 'ProtocolIE-Field',x and not the Protocol IE name (see below). Is
> this expected behaviour as I can see all the ids being declared in the
> <module name>.erl file?
Yes this is the expected behaviour.
The Id's of the Protocol-IEs are plain integers declared in the ASN.1 spec as
e.g.:
id-AreaIdentity INTEGER ::= 0
id-CN-BroadcastInformationPiece INTEGER ::= 1
These value declarations are represented in the generated .erl file as
functions which return the integer value. You can use them
when you are creating data on the Erlang side.
When you decode data representing a Protocol-IE the id is just an
integer which is represented as an integer in the Erlang internal
representation as well. It is not possible to convert an integer with
value 0 to the symbol id-AreaIdentity because there could be
lots of other value definitions with integer value 0.
For the symbolic representation to work you would need another type of
declaration for the Id's and I don't know if that would be practical
and anyway that is not used in the RANAp standard.
I think something like the below example will do the trick and let you
handle the ID's for IEs as atoms and it should be no
change on the line (if you are encoding as BER). If PER is used it
might have impact on the encoding.
Protocol-IE-ID ::= INTEGER {arealIdentity(0),
cN-BroadcastInformationPiece(1), ...
id-AreaIdentity Protocol-IE-ID ::= arealIdentity
id-CN-BroadcastInformationPiece Protocol-IE-ID cn-BroadcastInformationPiece
/Kenneth Erlang/OTP , Ericsson
>
> Regards
>
> Mark.
>
> 'RANAP':decode('RANAP-PDU',
> list_to_binary([0,19,64,74,0,0,6,0,3,64,1,0,0,15,64,6,0,50,244,149,0,4,0,58
> ,64,8,0,50,244,149,0,4,0,4,0,16,64,24,23,5,8,0,50,244,149,0,133,79,8,57,1,87,0,0,0,4,40,51,3,79,24,160
> ,0,79,64,3,48,0,15,0,86,64,5,50,244,149,0,1])).
> {ok,{initiatingMessage,
> {'InitiatingMessage',19,ignore,
> {'InitialUE-Message',
> [{'ProtocolIE-Field',3,ignore,'cs-domain'},
> {'ProtocolIE-Field',15,ignore,
> {'LAI',[50,244,149],[0,4],asn1_NOVALUE}},
> {'ProtocolIE-Field',58,ignore,
> {'SAI',[50,244,149],[0,4],[0,4],asn1_NOVALUE}},
> {'ProtocolIE-Field',16,ignore,
> [5,8,0,50,244,149,0,133,79,8,57|...]},
> {'ProtocolIE-Field',79,ignore,[0,0,1,1,0,0,0,0,0,0|...]},
> {'ProtocolIE-Field',86,ignore,
> {'GlobalRNC-ID',[50,244,149],1}}],
> asn1_NOVALUE}}},
> <<>>}
>
More information about the erlang-questions
mailing list