[OpenSIPS-Users] get_dialog_info Issues

Ross Beer beer.ross at googlemail.com
Wed Sep 1 11:59:08 CEST 2010


Hi Bogdan,

Thank you for the advice, however I do call setflag(4) &
create_dialog(). Flag 4 is dialog flag.

I have included the routing script below which shows the same method
but using the dispatcher. The issue here is that the get_dialog_info
does not find the previous call. Only for the dialogue its already in,
for example in an invite that requires auth.

It's a strange one and I can't pin point where I have gone wrong :-(


	# initial sanity checks -- messages with
	# max_forwards==0, or excessively long requests
	if (!mf_process_maxfwd_header("10"))
	{
		sl_send_reply("483","Too Many Hops");
		exit;
	};

	if (msg:len >=  3072)
	{
		sl_send_reply("513", "Message too big");
		exit;
	};


	#---- NAT Detection ----#
	force_rport();
	if (nat_uac_test("19"))
	{
		#force_rport();
		if (method=="REGISTER")
		{
			fix_nated_register();
		}
		else
		{
			fix_nated_contact();
		}
		setflag(5);
	}
	
	if(has_body("application/sdp"))
	{
    		if(nat_uac_test("8"))
		{
			fix_nated_sdp("3");
		}
	}


	# we record-route all messages -- to make sure that
	# subsequent messages will go through our proxy; that's
	# particularly good if upstream and downstream entities
	# use different transport protocol
	if (!method=="REGISTER")
	{
		record_route();
	}
#
#	# subsequent messages withing a dialog should take the
#	# path determined by record-routing
	if (loose_route())
	{
		# mark routing logic in request
		xlog("Loose Route\n");
		append_hf("P-hint: rr-enforced\r\n");
		route(1);
	};

        # handle cancel and re-transmissions
	if ( is_method("CANCEL") ) {
		if ( t_check_trans() )
			t_relay();
		exit;
	}

	if(is_method("INVITE"))
	{
		setflag(4);
		create_dialog();
	}


	# Do Not Allow Publish Or Subscribe
	if( is_method("PUBLISH|SUBSCRIBE"))
    	{
    		sl_send_reply("508", "Method Not Supported");
        	exit;
    	}

	

	# if the request is for other domain use UsrLoc
	# (in case, it does not work, use the following command
	# with proper names and addresses in it)
	if (uri==myself)
	{
		if(method=="REGISTER")
		{
			# Uncomment this if you want to use digest authentication
			if (!www_authorize("", "subscriber")) {
				www_challenge("", "0");
				exit;
			};

			#---- Request is behind NAT(flag5) save with bflag 6 ----#
			#---- Use bflag 7 to start SIP pinging (Options)     ----#
			if (isflagset(5))
			{
				setbflag(6);
				#setbflag(7);
			};

			save("location", "c1f");
			exit;
		};
		
		##############################
                # HANDLE OPTIONS REPLY       #
                ##############################
         	if(is_method("OPTIONS"))
		{
			xlog("OPTIONS REPLY - FROM $fU\r\n");
            		# send reply for each options request
            		sl_send_reply("200", "ok");
            		exit();
         	}

		##############################
                # HANDLE NOTIFY              #
                ##############################
		if(is_method("NOTIFY"))
                {
			# FOR LOCAL USER
                        if (!lookup("location"))
                        {
        			if (get_dialog_info("server","$var(x)","user","$fU"))
                                {
                                         xlog("Log: Belonds to Server:
$var(x)\n");
                                         $du=$var(x);

                                        ## ADD VARIABLE TO ROUTE GATEWAY
                                        $dlg_val(server) = $var(x);
                                        $dlg_val(user) = $fU;
                                        route(1);
                                	exit;
                                }
				else
				{
			        	if(!load_balance("1","pstn"))
                                	{
                                        	sl_send_reply("500","Service full");
                                       		 exit;
                                	}
                                #t_on_failure("1");
				}
                                xlog("NOTIFY - Non SIP Client Call
Sent To $du FROM $fU\r\n");
                        }
			xlog("NOTIFY - SIP Client Call Sent To $rU FROM $fU\r\n");
			route(1);
			exit;

                }

		##############################
		# HANDLE MESSAGES	     #	
		##############################
		if (is_method("MESSAGE"))
		{
			if (!proxy_authorize("", "subscriber"))
			{
				proxy_challenge("", "1");  # Realm will be autogenerated
			};
		
		    	if (!lookup("location"))
            		{
                 		sl_send_reply("404", "Not Found");
                 		exit;
            		};

            		#xlog("Log: MESSAGE: looked up user\n");
            		route(1);
            		exit;
		}
	
		##############################
		# ROUTE CALLS TO DESTINATION #
		##############################
		if (is_method("INVITE"))
		{
			######################
			# CALL PICKUP        #
			######################
			if($rU=~"^\*%23[2-9][0-9]{2}")
			{
				route(2);
				exit;
			}

			######################
            		# GROUP CALL PICKUP  #
            		######################
            		if($rU=~"^\*0%23[2-9][0-9]{2}")
            		{
				route(2);
                		exit;
            		}

			######################
			# LOCAL DESTINATIONS #
			######################
			xlog("Method: $rm rU: $rU\r\n");
			if($rU=~"^[1-9][0-9]{4}\*[2-9][0-9]{2}")
            		{
				# FROM LOCAL GATEWAY
				# MARK GATEWAY FOR DIALOGUE
						
				# native SIP destinations are handled using our USRLOC DB
				if (!lookup("location"))
				{
					sl_send_reply("404", "Not Found");
					exit;
				}

			 	$dlg_val(server) = "sip:" + $si + ":5060";
                                $dlg_val(user) = $rU;

				xlog("Log: looked up user for $dlg_val(server) rU: $rU\n");
				append_hf("P-hint: usrloc applied\r\n");
				route(1);
				exit;
			}
			############################
            		# LOAD BALANCE TO GATEWAYS #
            		############################
			else
			{	

			       if($fU=~"^[1-9][0-9]{4}\*[2-9][0-9]{2}")
                               {
                                        xlog("fu Match: $fU\n");

                                        # IS PART OF EXISTING CALL
                                        if
(get_dialog_info("server","$var(x)","user","$fU"))
                                        {
                                                xlog("************
Log: Seen Before Call *************\n");
                                                xlog("Log: Belonds to
Server: $var(x)\n");
                                                $du=$var(x);

                                                ## ADD VARIABLE TO ROUTE GATEWAY
                                                $dlg_val(server) = $var(x);
                                                $dlg_val(user) = $fU;
                                                route(1);
                                                exit;
                                        }
					else
					{
					 	xlog("************ Log: New INVITE *************\n");	
						## LOAD BALANCE
						ds_select_dst("1", "4");
						t_on_failure("1");

						xlog("LB Sent To $avp(i:271)\n");
				
						$dlg_val(server) = $avp(i:271);
                                                $dlg_val(user) = $fU;
                                                route(1);
                                                exit;
					}
				}
               		}
				# END OF PART OF AN EXISTING CALL ROUTE TO GATEWAY
		
				## IF NOT A SIP CLIENT JUST LOAD BALANCE
				## WITHOUT LOGGING WHICH GATEWAY
				ds_select_dst("1", "4");
				t_on_failure("1");
				xlog("Not SIP Client Call Sent To $du FROM $fU\r\n");
				route(1);
				exit;
			}
#		}
	};

	route(1);
}


Any further advice would be appreciated.

Kind regards,

Ross

On 1 September 2010 10:50, Bogdan-Andrei Iancu <bogdan at voice-system.ro> wrote:
> Hi Ross,
>
> To use get_dialog_info() and dlg_val's you must create the dialog before
> (see create_dialog() function in dialog module) - otherwise all dialog
> ops are invalid.
>
> Regards,
> Bogdan
>
> Ross Beer wrote:
>> Hi,
>>
>> I am using the following piece of code to set dlg_val and then using
>> get_dialog_info to check to see if a user already has a call and if so
>> pass the new call to the same gateway for attended transfer.
>>
>> The code works perfectly if in the same dialog, i.e. when an invite is
>> sent and then requires authentication however it does not appear to
>> match any results across different dialogs. Also I can not see any
>> values in the 'vars' column in the dialog database.
>>
>> Am I using the feature correctly?
>>
>>   # IS PART OF EXISTING CALL
>> if (get_dialog_info("server","$var(x)","user","$fU"))
>> {
>>      xlog("************Log: Seen Before Call *************\n");
>>     xlog("Log: Belonds to server: $var(x)\n");
>>      $du=$var(x);
>>      ## ADD VARIABLE TO ROUTE GATEWAY
>>      $dlg_val("server") = $var(x);
>>      $dlg_val("user") = $fU;
>>       route(1);
>>       exit;
>> }
>> else
>> {
>>       xlog("************Log: New INVITE *************\n");
>>       ds_select_dst("1", "4");
>>       xlog("LB Sent To $avp(i:271)\n");
>>
>>      store_dlg_value("server","$avp(i:271)");
>>      store_dlg_value("user","$fU");
>>      #$dlg_val(server) = $avp(i:271);
>>      #$dlg_val(user) = $fU;
>>      route(1);
>>      exit;
>> }
>>
>> Kind regards,
>>
>> Ross
>>
>> PS - Sorry this is a duplicate but my gmail account doesn't seam to
>> post messages to the mailing list
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>
>
> --
> Bogdan-Andrei Iancu
> OpenSIPS Bootcamp
> 20 - 24 September 2010, Frankfurt, Germany
> www.voice-system.ro
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>



More information about the Users mailing list