[sr-dev] [tracker] Comment added: Dialog module: dlg_terminate_dlg and register_dlgcb function

sip-router bugtracker at sip-router.org
Tue Apr 2 16:58:08 CEST 2013


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

The following task has a new comment added:

FS#256 - [sr-dev] Dialog module: dlg_terminate_dlg and register_dlgcb function
User who did this - Eduardo Lejarreta (lejarreta.e)

----------
As mentioned above, the problem for acc_cdr.c accounting is that "BYE messages" are generated internally so these messages are not tracked by kamailio nor acc_cdr accounting because they are sent directly to end UAs (legs)

I propose to add a small change on "dlg_req_within.c" just to force this messages to be tracked by Kamailio changing the internal record_set of dialog just to force then to pass through REQUEST_ROUTE.

On "dlg_bye_all" function add a call to "build_route_set" function (better to isolate this small change)

int dlg_bye_all(struct dlg_cell *dlg, str *hdrs)
{
        str all_hdrs = { 0, 0 };
        int ret;

        if ((build_extra_hdr(dlg, hdrs, &all_hdrs)) != 0)
        {
                LM_ERR("failed to build dlg headers\n");
                return -1;
        }

        if ( (build_route_set(dlg)) != 0 )
        {
                LM_ERR("failed to build dlg route set\n");
                return -1;
        }

        ret = send_bye(dlg, DLG_CALLER_LEG, &all_hdrs);
        ret |= send_bye(dlg, DLG_CALLEE_LEG, &all_hdrs);

        pkg_free(all_hdrs.s);
        return ret;

}

"build_route_set" function will "trick" Kamailio to route these BYE messages as "end UA generated" allowing acc_cdr to correctly to the accounting.

static inline int build_route_set( struct dlg_cell *dlg )
{
        char *p=0;

        dlg->route_set[0].len = strlen("<sip:") + dlg->bind_addr[0]->address_str.len + strlen(";lr>");
        dlg->route_set[1].len = strlen("<sip:") + dlg->bind_addr[1]->address_str.len + strlen(";lr>");

        dlg->route_set[0].s = (char*)pkg_malloc( dlg->route_set[0].len * sizeof(char) );
        dlg->route_set[1].s = (char*)pkg_malloc( dlg->route_set[1].len * sizeof(char) );

        if ( !dlg->route_set[0].s || !dlg->route_set[1].s ){
                LM_ERR("out of pkg memory\n");
                goto error;
        }

        p = dlg->route_set[0].s;
        if ( dlg->route_set[0].len ){
                memcpy( p, "<sip:", strlen("<sip:") );
                p += strlen("<sip:");
                memcpy( p,  dlg->bind_addr[0]->address_str.s, dlg->bind_addr[0]->address_str.len);
                p += dlg->bind_addr[0]->address_str.len;
                memcpy( p, ";lr>", strlen(";lr>") );
        }

        p = dlg->route_set[1].s;
        if ( dlg->route_set[1].len ){
                memcpy( p, "<sip:", strlen("<sip:") );
                p += strlen("<sip:");
                memcpy( p,  dlg->bind_addr[1]->address_str.s, dlg->bind_addr[1]->address_str.len);
                p += dlg->bind_addr[1]->address_str.len;
                memcpy( p, ";lr>", strlen(";lr>") );
        }

        return 0;

error:
        return -1;
}

Could you please deep test this ? 

I've done several trials and everything seems to be OK. 

Any security issue idea ?

Forgive my poor programming.

Thanks and regards.

Eduardo Lejarreta.

----------

More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=256#comment817

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.



More information about the sr-dev mailing list