Can anybody give me example how to frame a MAP message

Sean Hinde <>
Thu Aug 9 19:03:38 CEST 2001

The ASN.1 compiler suppiled with Erlang doesn't support the Macro notation
used in MAP. (it is not even in the current ASN.1 standard. I remember
reading somewhere that this is because it was deemed too expressive for
tools to correctly handle in its full form).
I fact you don't need the Macros. All they do for MAP (pretty much) is say
which messages are commands and which ones should be received as replies
(i.e. success or error). The actual ASN.1 of a location update request for
example is simply that of :
TCAP Begin
    Transaction ID
    App Context
    TCAP Component portion
        TCAP Invoke
            Location Update
This immediately follows the SCCP wrapper.
There follows a bit of code I once wrote to decode generic ASN.1 so if you
have some MAP messages you can easily peer inside.
%% Decode asn1 coded binary into parse tree
%% Handles indefinite length if re-assembly has already been
%% done - should be easy to allow for segmented though
%% as we keep a count of unrequited indefinite length
%% constructor tags.
asn1_decode(Bin) ->
    asn1_decode(Bin, 0).
asn1_decode(<<>>, 0) ->
asn1_decode(Bin, N0) ->
    {Class, Form, Tag, Rest, N} = get_tag(Bin, N0),
    case tag_type(Class, Form, Tag) of
 indefinite_end ->
     asn1_decode(Rest, N);
 Constructor when Constructor == set;
    Constructor == seq;
    Constructor == constructor ->
     case get_length(Rest) of
  {indefinite, Rest1} ->
      [{{Constructor, indef, Class, Tag}, asn1_decode(Rest1, N+1)}];
  {Len, Rest1} ->
      {Data, Rest2} = get_content(Len, Rest1),
      [{{Constructor, Class, Tag}, asn1_decode(Data, 0)}|
       asn1_decode(Rest2, N)]
 tag ->
     {Len, Rest1} = get_length(Rest),       
     {Data, Rest2} = get_content(Len, Rest1),
     [{{tag, fmt_class(Class), Tag}, Data}|asn1_decode(Rest2, N)]
%% Get tag data
get_tag(<<0:1, 0:15, Rest/binary>>, 0) ->
get_tag(<<0:1, 0:15, Rest/binary>>, N) ->
    {indefinite_end, 0, 0, Rest, N-1};
get_tag(<<Class:2, Form:1, Tag:5, Rest/binary>>, N) ->
    {Tag1, Rest1} = get_tag1(Tag, Rest),
    {Class, Form, Tag1, Rest1, N}.
%% Handle extension parts of the tag field
get_tag1(31, <<0:1, Tag:7, Rest/binary>>) ->
    {Tag, Rest};
get_tag1(31, <<1:1, Msb:7, _:1, Lsb:7, Rest/binary>>) ->
    {Msb*128+Lsb, Rest};
get_tag1(Tag, Rest) ->
    {Tag, Rest}.
% Do short and long definite length forms
% And *now*... indefinite length!
get_length(<<0:1, Len:7, Rest/binary>>) ->
    {Len, Rest};
get_length(<<1:1, 0:7, Rest/binary>>) ->
    {indefinite, Rest};
get_length(<<1:1, Len_len:7, Rest/binary>>) ->
%    io:format("Len_len:~p~n",[Len_len]),
    <<Len:Len_len/unit:8, Rest1/binary>> = Rest,
    {Len, Rest1}.
% Get actual content of field
get_content(Len, Rest) ->
    <<Data:Len/binary, Rest1/binary>> = Rest,
    {Data, Rest1}.
% tag_type(Class, Form, Tag) -> tag|seq|set|constructor
tag_type(indefinite_end, _, _) -> indefinite_end;
tag_type(Class, 0, Tag) -> tag;
tag_type(0, 1, 16)       -> seq;
tag_type(0, 1, 17)       -> set;
tag_type(Class, 1, Els) -> constructor.
fmt_class(0) -> univ;
fmt_class(1) -> app;
fmt_class(2) -> context;
fmt_class(3) -> priv.

-----Original Message-----
From: Jasdeep [mailto:]
Sent: 09 August 2001 16:42
To: ''
Subject: Can anybody give me example how to frame a MAP message

 Well  i am using map ASN  which i picked from 3GPP specs, but whatever is
there in Macros in specs, the object is not created. So can anybody tell me
how to use Macros to frame the Message.
Please can you tell me some links how to make MAP message.
Thanks in Advance
Jasdeep Randhawa
Software Engineer(ll)
104,Industrial Estate, 
5th Block, Kormangala,
ph-5521937-40 ext:230

This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.

More information about the erlang-questions mailing list