otc icon indicating copy to clipboard operation
otc copied to clipboard

Error on encoding TCAP message with invoke component without linkedId

Open alishir opened this issue 2 years ago • 0 comments

Thanks for the great library, I've tried to encode the following tcap:map message, but I got some error. Here is the snippet:

    {ok, Arg} = file:read_file("/home/ali/arg.bin"),

    Map = #{
        operation => anyTimeInterrogation,
        component_type => invoke,
        invokeId => 0,
        opcode => {local, 71},
        argument => Arg
    },

    Tcap = #{
        protocol => tcap,
        otid => <<"000001B3">>,
        type => 'begin',
        dialogue =>
            #{
                type => dialogueRequest,
                application_context_family => map,
                user_information => undefined,
                application_context_name => 'anyTimeInfoEnquiryContext-v3',
                supported_versions => [version1]
            }
    },

    {ok, TcapBin} = otc:encode({Tcap, [Map]}),

And here is the error message:

error: {badmatch,
               {error,
                   {asn1,
                       {badarg,
                           [{erlang,element,
                                [1,absent],
                                [{error_info,#{module => erl_erts_errors}}]},
                            {'TCAP-OTC',enc_Invoke_linkedId,2,
                                [{file,
                                     "/home/ali/workspace/ehod/_build/default/lib/otc/src/TCAP-OTC.erl"},
                                 {line,787}]},
                            {'TCAP-OTC',enc_Invoke,2,
                                [{file,
                                     "/home/ali/workspace/ehod/_build/default/lib/otc/src/TCAP-OTC.erl"},
                                 {line,760}]},
                            {'TCAP-OTC',enc_ROS,2,
                                [{file,
                                     "/home/ali/workspace/ehod/_build/default/lib/otc/src/TCAP-OTC.erl"},
                                 {line,684}]},
                            {'TCAP-OTC',enc_Component,2,
                                [{file,
                                     "/home/ali/workspace/ehod/_build/default/lib/otc/src/TCAP-OTC.erl"},
                                 {line,632}]},
                            {'TCAP-OTC',enc_ComponentPortion_components,3,
                                [{file,
                                     "/home/ali/workspace/ehod/_build/default/lib/otc/src/TCAP-OTC.erl"},
                                 {line,605}]},
                            {'TCAP-OTC',enc_ComponentPortion,2,
                                [{file,
                                     "/home/ali/workspace/ehod/_build/default/lib/otc/src/TCAP-OTC.erl"},
                                 {line,598}]},
                            {'TCAP-OTC',enc_Begin,2,
                                [{file,
                                     "/home/ali/workspace/ehod/_build/default/lib/otc/src/TCAP-OTC.erl"},
                                 {line,300}]}]}}}}
    stack: [{otc_tcap,encode,1,
                      [{file,"/home/ali/workspace/ehod/_build/default/lib/otc/src/otc_tcap.erl"},
                       {line,46}]},
            {otc,enc_safe,2,
                 [{file,"/home/ali/workspace/ehod/_build/default/lib/otc/src/otc.erl"},
                  {line,192}]},
            {hlr_client,handle_continue,2,
                        [{file,"/home/ali/workspace/ehod/apps/ehod/src/hlr_client.erl"},
                         {line,208}]},
            {gen_server,try_handle_continue,3,
                        [{file,"gen_server.erl"},{line,1085}]},
            {gen_server,loop,7,[{file,"gen_server.erl"},{line,995}]},
            {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]

I've modified the compose_invoke_id function to return a tuple if linked_id is not set, but wireshark claims that the packet is malformed. Here is the change that I've made in otc_tcap.erl:

compose_invoke_id(I) when is_integer(I) ->
    {present, I};
compose_invoke_id(absent) ->
    {absent, 0}.

alishir avatar Feb 07 '24 02:02 alishir