Alex,

The simpler way to do it is to set the static dialog reference to the dialog before calling the TM ....more efficient as you do not have to find a dialog you already know...

Try the attached patch.

Regards,
Bogdan

Alex Massover wrote:
Hi!

Here's a patch that worked for me (for 1.5.3). Probably there're better ways to 
do it.

--
Best Regards,
Alex Massover
VoIP R&D TL
Jajah Inc.
-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Bogdan-Andrei Iancu
Sent: Sunday, September 27, 2009 10:09 PM
To: OpenSIPS devel mailling list
Subject: Re: [OpenSIPS-Devel] Using dialog module functions from LOCAL_ROUTE

Hi Alex,

Alex Massover wrote:
It fails in dialog.c in w_fetch_dlg_value () here:

if ( (dlg=get_current_dialog())==NULL ) {
                return -1;

get_current_dialog() doesn't return a dialog :(

[Alex]

get_current_dialog() looks to work either for initial requests or for 
established transactions.
I switched to get_dlg() that receives sip_msg.
The following works for me:

        unsigned int dir;
        if ( ((dlg=get_current_dialog())==NULL) && 
((dlg=get_dlg(&(msg->callid->body),&(get_from(msg)->tag_value),&(get_to(msg)->tag_value),&dir))==NULL)
 ) {
                return -1;
        }

Why not to enable something like this in the version?
The only obstacle I can think of is a race condition (dialog can be destroyed) 
- but the same can happen in any other type or route as well.

There is no race as the dialog module is based on a mechanism of
referencing the dialog - as time the dialog is refed, it cannot be
deleted ... as said, let me have a look into this...

Regards,
Bogdan


--
Sincerely yours,
Alex Massover
VoIP R&D TL
Jajah Inc.



-----Original Message-----
From: [email protected] [mailto:devel-
[email protected]] On Behalf Of Alex Massover
Sent: Sunday, September 27, 2009 1:10 PM
To: OpenSIPS devel mailling list
Subject: Re: [OpenSIPS-Devel] Using dialog module functions from
LOCAL_ROUTE

Hi!

It's a BYE request generated by dlg_end_dlg(). I need to
fetch_dlg_value() to get variables stored on the dialog to send them
with accounting extra headers.

This is what I have in opensips.cfg:

modparam("acc", "radius_extra", "Connect-Info=$avp(s:info);....... ")
...
...
...
local_route
{
         if(is_method("BYE"))
         {
                fetch_dlg_value("internal_callid","$avp(s:info)");
                acc_rad_request("200");
         }
}

This works for me for regular BYEs, but not with locally generated
BYEs, even with the hack below.


--
Sincerely yours,
Alex Massover
VoIP R&D TL
Jajah Inc.


-----Original Message-----
From: [email protected] [mailto:devel-
[email protected]] On Behalf Of Bogdan-Andrei Iancu
Sent: Sunday, September 27, 2009 1:32 PM
To: OpenSIPS devel mailling list
Subject: Re: [OpenSIPS-Devel] Using dialog module functions from
LOCAL_ROUTE

Hi Alex,

for what kind of requests (from LOCAL route) you try to use the dlg
stuff?

Regards,
Bogdan

Alex Massover wrote:

Hi!

I'm looking for a way to use fetch_dlg_value() inside

LOCAL_ROUTE.

I

edited dialog.c to to enable it:

{"fetch_dlg_value",(cmd_function)w_fetch_dlg_value,

2,fixup_dlg_fval,

0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE |
LOCAL_ROUTE },

Now I can write fetch_dlg_value() inside the LOCAL_ROUTE, but I'm
getting NULLs always.

Can anybody point me what else do I need to hack to have access

to

dialog variables from LOCAL_ROUTE?

Also what is the reason not to enable all dialog functions from
LOCAL_ROUTE?




_______________________________________________
Devel mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

This mail was received via Mail-SeCure System.




This mail was sent via Mail-SeCure System.


------------------------------------------------------------------------

_______________________________________________
Devel mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

Index: modules/dialog/dlg_req_within.c
===================================================================
--- modules/dialog/dlg_req_within.c	(revision 6194)
+++ modules/dialog/dlg_req_within.c	(working copy)
@@ -240,6 +240,7 @@
 														str *extra_hdrs)
 {
 	dlg_t* dialog_info;
+	struct dlg_cell *old_cell;
 	str met = {"BYE", 3};
 	int result;
 
@@ -253,6 +254,9 @@
 
 	ref_dlg(cell, 1);
 
+	old_cell = current_dlg_pointer;
+	current_dlg_pointer = cell;
+
 	result = d_tmb.t_request_within
 		(&met,         /* method*/
 		extra_hdrs,    /* extra headers*/
@@ -262,6 +266,8 @@
 		(void*)cell,   /* callback parameter*/
 		NULL);         /* release function*/
 
+	current_dlg_pointer = old_cell;
+
 	if(result < 0){
 		LM_ERR("failed to send the BYE request\n");
 		goto err1;
Index: modules/dialog/dialog.c
===================================================================
--- modules/dialog/dialog.c	(revision 6194)
+++ modules/dialog/dialog.c	(working copy)
@@ -149,21 +149,29 @@
 	{"unset_dlg_profile", (cmd_function)w_unset_dlg_profile,2,fixup_profile,
 			0, FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
 	{"is_in_profile", (cmd_function)w_is_in_profile,      1,fixup_profile,
-			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
+			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE |
+			BRANCH_ROUTE | LOCAL_ROUTE },
 	{"is_in_profile", (cmd_function)w_is_in_profile,      2,fixup_profile,
-			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
+			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE |
+			BRANCH_ROUTE | LOCAL_ROUTE },
 	{"get_profile_size",(cmd_function)w_get_profile_size, 2,fixup_get_profile2,
-			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
+			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE |
+			BRANCH_ROUTE | LOCAL_ROUTE },
 	{"get_profile_size",(cmd_function)w_get_profile_size, 3,fixup_get_profile3,
-			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
+			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE |
+			BRANCH_ROUTE | LOCAL_ROUTE},
 	{"set_dlg_flag",(cmd_function)w_set_dlg_flag,         1,fixup_dlg_flag,
-			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
+			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE |
+			BRANCH_ROUTE | LOCAL_ROUTE},
 	{"reset_dlg_flag",(cmd_function)w_reset_dlg_flag,     1,fixup_dlg_flag,
-			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
+			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE |
+			BRANCH_ROUTE | LOCAL_ROUTE },
 	{"is_dlg_flag_set",(cmd_function)w_is_dlg_flag_set,   1,fixup_dlg_flag,
-			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
+			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE |
+			BRANCH_ROUTE | LOCAL_ROUTE },
 	{"store_dlg_value",(cmd_function)w_store_dlg_value,   2,fixup_dlg_sval,
-			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
+			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE |
+			BRANCH_ROUTE | LOCAL_ROUTE },
 	{"fetch_dlg_value",(cmd_function)w_fetch_dlg_value,   2,fixup_dlg_fval,
 			0, REQUEST_ROUTE| FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE },
 	{"validate_dialog",(cmd_function)w_validate_dialog,      0,         NULL,
Index: modules/dialog/dlg_hash.c
===================================================================
--- modules/dialog/dlg_hash.c	(revision 6194)
+++ modules/dialog/dlg_hash.c	(working copy)
@@ -88,7 +88,7 @@
 {
 	struct cell *trans;
 
-	if (route_type==REQUEST_ROUTE) {
+	if (route_type==REQUEST_ROUTE || route_type==LOCAL_ROUTE) {
 		/* use the per-process static holder */
 		return current_dlg_pointer;
 	} else {
_______________________________________________
Devel mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

Reply via email to