[Kamailio-Devel] Patch: dialog module / is_known_dlg().

Klaus Darilion klaus.mailinglists at pernau.at
Thu Nov 13 09:53:43 CET 2008



Jerome Martin schrieb:
> On Wed, 2008-11-12 at 18:22 -0500, Alex Balashov wrote:
>> Jerome Martin wrote:
>>> Alex,
>>>
>>> On Wed, 2008-11-12 at 12:32 -0500, Alex Balashov wrote:
>>>> Hello,
>>>>
>>>> I have attached a very simple patch to provide a new exported function 
>>>> from the dialog module - is_known_dlg().  This can be used from script 
>>>> to determine if the message being processed is part of an existing 
>>>> dialog tracked by the dialog module, irrespective of the use of profiles.
>>>>
>>>> Because the dialog module is plugged into the RR / TMCB event loop it is 
>>>> aware of all dialogs regardless of whether profiles are used.  Thus, 
>>> I think this needs double checking, because the callback as registered
>>> in the dialog module might not make dialog matching available before
>>> t_relay or loose_route / record route is called ... I am saying this
>>> from memory because I had to patch my dialog module in-house at some
>>> point to make the dialog matching available upon entering the script
>>> config (thus registering an other callback like this:
>>> register_script_cb( dlg_onreqprescript, PRE_SCRIPT_CB|REQ_TYPE_CB,0)).
>>> This is counter intuitive because the tmcb TMCB_REQUEST_IN, dlg_onreq
>>> event, if I remember correctly, happens a bit later than what
>>> intuitively expected, aka after t_relay I think. Again I haven't checked
>>> this recently and might be wrong, just quoting from memory. 
>> Even if that's so, I don't know that this really injures the usefulness 
>> of the patch in most conceivable use cases.  I don't have dialogs that 
>> aren't RR'd and t_relay()'d out.  
> 
> Sure, but surely there are use cases where you need to know if the SIP
> request belongs to a dialog BEFORE t_relaying it :-)

AFAIK the dialog is created during t_relay() (of course only if the 
dlg_flag is set) via TM callback and check with RR callback.

Thus, for out-of-dialog requests (has_totag == 0) it makes no sense to 
call is_known_dlg() at all. For in-dialog requests (has_totag == 1), 
after loose_route() the dialog module is aware if a matching dialog was 
found. Now it depends what is_known_dlg() does - does it searches for 
the dialog just like the RR callback? Then you could have this function 
even before loose_route() as it does all the work by itself. Of course 
it would be smarter if the dialog module remembers the result of the 
lookup and for example exports it into a pseudo variable, e.g.
    in dialog modules RR callback function:
      is_known = 0;
      if (search for dialog == 1)
         is_known=1;
         ..

    in dialog moduel export this variable ....

and as I think about it I checked the dialog module for exported pseudo 
variables ---> $DLG_status
http://www.kamailio.org/docs/modules/devel/dialog.html#id2507513

I think that should be sufficient.

klaus



More information about the Devel mailing list