[erlang-questions] erlang diameter dictionary

Anders Svensson <>
Thu Mar 21 13:59:07 CET 2013


On Thu, Mar 21, 2013 at 2:55 AM, S X <> wrote:
> Hello,
>
> Sorry, I still have some problems with sending CCR/CCA messages.  I didn't
> quite get how to configure multiple diameter applications though it seems
> clear when I read the diameter protocol.
>
> Based on the sample diameter code, I made the following changes,
> diameter_gen_base_rfc4006_cc is the dictionary generated with
> rfc4006_cc.dia:
> $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Client $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
>
> -define(SVC_NAME,     ?MODULE).
> -define(APP_ALIAS,    ?MODULE).
> -define(CALLBACK_MOD, client_cb).
> -define(DIAMETER_DICT_CCRA, diameter_gen_base_rfc4006_cc).
>
> -define(L, atom_to_list).
>
> -define(SERVICE(Name), [{'Origin-Host', ?L(Name) ++ ".example.com"},
>                         {'Origin-Realm', "example.com"},
>                         {'Vendor-Id', 0},
>                         {'Product-Name', "Client"},
>                         {'Auth-Application-Id', [?DIAMETER_APP_ID_COMMON]},
>                         {application, [{alias, ?APP_ALIAS},
>                                        {dictionary, ?DIAMETER_DICT_CCRA},
>                                        {module, ?CALLBACK_MOD}]}]).
>
>
>
> $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Server $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
>
> -define(DIAMETER_DICT_CCRA, diameter_gen_base_rfc4006_cc).
>
> init(State) ->
>     SvcName = ?MODULE,
>     SvcOpts = [{'Origin-Host', atom_to_list(SvcName) ++ ".example.com"},
>                 {'Origin-Realm', "example.com"},
>                 {'Vendor-Id', 193},
>                 {'Product-Name', "Server"},
>                 {'Auth-Application-Id', [?DIAMETER_APP_ID_COMMON]},
>                 {application, [{alias, ?MODULE},
>                                {dictionary, ?DIAMETER_DICT_CCRA},
>                                {module, server_cb}]}],
>     TransportOpts = [{transport_module, diameter_tcp},
>                         {transport_config, [{reuseaddr, true},
>                         {ip, {127,0,0,1}}, {port, 3868}]}],
>     diameter:start(),
>     diameter:start_service(SvcName, SvcOpts),
>     diameter:add_transport(SvcName, {listen, TransportOpts}),
>     erlang:display("Set up diameter server completed!"),
>     {ok, State}.
>
>
>
> I changed the callbacks client_cb and server_cb to handle CCR/CCA messages.
>
>
> However, I got the following errors "app_not_configured". It seems the
> configuration for applications is incorrect. How should I configure the
> service properly? My understanding is I want to reuse CER/CEA as default
> authorization application, but the erlang diameter doesn't explain how to do
> it. Or my understanding is incorrect at all.

The problem is a mismatch between the application and capabilities
configuration in your SvcOpts:  the 'Auth-Application-Id' tuple
specifies the Application Id's that are advertised in the outgoing
CER/CEA (that diameter itself sends) while 'applications' specifies
corresponding dictionary modules. In your case, advertising the common
application (0) during capabilities exchange but backing it up with a
dictionary that implement CC (4) is what causes things to go south.

What you want is something like this:

  {'Auth-Application-Id', [0,4]},
  {application, [{alias, cc},
                     {dictionary, diameter_gen_base_rfc4006},
                     {module, [server_cb, cc]}],
  {application, [{alias, base},
                     {dictionary, diameter_gen_base_rfc6733},
                     {module, [server_cb, base]}]}

That is, advertise both application with the Auth-Application-Id
config and configure corresponding dictionaries with 'application'
config. You might prefer two different callback modules (instead of an
extra argument) but the point is to match your advertised capabilities
with your configured dictionaries.

On a side note, you shouldn't use a diameter prefix on your own
dictionaries, so as not to collide with something diameter does in the
future.

/Anders, Erlang/OTP

>
> =ERROR REPORT==== 20-Mar-2013::21:40:50 ===
> ** Generic server <0.3841.0> terminating
> ** Last message in was {diameter,
>                            {recv,
>                                <<1,0,0,124,128,0,1,1,0,0,0,0,101,222,1,72,
>                                  101,222,1,72,0,0,1,8,64,0,0,26,99,108,105,
>                                  101,110,116,46,101,120,97,109,112,108,101,
>                                  46,99,111,109,0,0,0,0,1,40,64,0,0,19,101,
>                                  120,97,109,112,108,101,46,99,111,109,0,0,0,
>
> 1,1,64,0,0,14,0,1,127,0,0,1,0,0,0,0,1,10,64,
>                                  0,0,12,0,0,0,193,0,0,1,13,0,0,0,14,67,108,
>
> 105,101,110,116,0,0,0,0,1,2,64,0,0,12,0,0,0,
>                                  0>>}}
> ** When Server state == {state,recv_CER,accept,<0.3840.0>,<0.3842.0>,
>                             diameter_gen_base_rfc3588,
>                             {diameter_service,<0.50.0>,
>                                 {diameter_caps,"server.example.com",
>                                     "example.com",
>                                     [{127,0,0,1}],
>                                     193,"Server",[],[],
>                                     [0],
>                                     [],[],[],[],[]},
>                                 [{diameter_app,server,
>                                      diameter_gen_base_rfc4006_cc,
>                                      [server_cb],
>                                      server,4,false,
>                                      [{answer_errors,report},
>                                       {request_errors,answer_3xxx}]}]},
>                             false,exit}
> ** Reason for termination ==
> ** {{badmatch,{error,{app_not_configured,0}}},
>     [{diameter_peer_fsm,recv_CER,2,
>                         [{file,"src/diameter_peer_fsm.erl"},{line,849}]},
>      {diameter_peer_fsm,build_answer,3,
>                         [{file,"src/diameter_peer_fsm.erl"},{line,680}]},
>      {diameter_peer_fsm,send_answer,3,
>                         [{file,"src/diameter_peer_fsm.erl"},{line,647}]},
>      {diameter_peer_fsm,handle_info,2,
>                         [{file,"src/diameter_peer_fsm.erl"},{line,292}]},
>      {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,607}]},
>      {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}
>
>
> Could you give me some hints on this issue? The erlang debugger is not easy
> to use and call stack information is hard to read (when I show the trace
> window, all the buttons for step/next/continue become invisible). The
> diameter guidance explains the concept but no clear steps about
> configuration.
>
>
> Many thanks!
>
> Samuel
>
>
>
> On Tue, Mar 12, 2013 at 12:10 PM, S X <> wrote:
>>
>> Hello, Anders & Andre,
>>
>> Thanks a lot for your quick responses and suggestions, which help me start
>> to exploring Erlang world ^_^
>>
>> I was able to generate based on the file rfc4006_cc.dia under the
>> diameter/examples/dict folders. And understand a bit why and how Erlang
>> diameter protocol dictionaries are organized and maintained.
>>
>> Many thanks and talk to you later!
>>
>> Samuel
>>
>>
>> On Tue, Mar 12, 2013 at 7:44 AM, Anders Svensson <>
>> wrote:
>>>
>>> Btw, there's an RFC 4006 dictionary (and a few more) under
>>> diameter/examples/dict in the repo.
>>>
>>> /Anders, Erlang/OTP
>>>
>>> On Tue, Mar 12, 2013 at 10:32 AM, André Graf <> wrote:
>>> > Hello S(?)
>>> >
>>> > You have to come up with your own .dia file if the message types are
>>> > not covered in the .dia files provided by Erlang. Your own .dia file
>>> > will typically include the  '@inherits diameter_gen_base_rfc3588'
>>> > clause which imports the basic avp's from rfc3588. You then have to
>>> > provide the missing avp's for your CCR/CCA message types, and also
>>> > define these messages. Thanks to the format of a .dia file it is
>>> > pretty much copy-pasting from the rfc4006. Once your .dia file is
>>> > ready, you use diameterc to generate the .erl and .hrl file.
>>> >
>>> > Hope that helped!
>>> >
>>> > BR/André
>>> >
>>> >
>>> >
>>> > On 12 March 2013 04:58, S X <> wrote:
>>> >> Hello,
>>> >>
>>> >> I am new to Erlang and Diameter protocol. Wish someone could provide
>>> >> some
>>> >> suggestions on how to utilize the diameter library properly in Erlang.
>>> >>
>>> >> For example, I want to send/receive some Gx messages, like CCR (Credit
>>> >> Control Request), CCA(Credit Control Answer messages. But I notice
>>> >> that
>>> >> there are some predefined messages in erlang diameter library. As my
>>> >> understanding, should use the utility diameterc to generate erlang
>>> >> header/source files based on dia files. There are few dia files under
>>> >> otp/lib/diameter/src/dict folder, like acct_rfc6733.dia,
>>> >> base_rfc3588.dia,
>>> >> relay.dia, base_accounting.dia,  base_rfc6733.dia. Those files don't
>>> >> have
>>> >> the definitions for Gx.
>>> >>
>>> >> How should I generate or where can I obtain dia files which have
>>> >> support for
>>> >> CCR/CCA message format? Are the dia files proprietary or manufacturer
>>> >> specific? Can I generate with the 3GPP spec? What are the proper
>>> >> steps?
>>> >>
>>> >> Thanks a lot!
>>> >>
>>> >> S
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> erlang-questions mailing list
>>> >> 
>>> >> http://erlang.org/mailman/listinfo/erlang-questions
>>> >>
>>> > _______________________________________________
>>> > erlang-questions mailing list
>>> > 
>>> > http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>



More information about the erlang-questions mailing list