One follow up question here:

Can you point me to the location of the source code that unpacks the request uri/from uri and sticks them into the $ru/$fu pseudo vars please.

I already have confirmed (via testing) that $ru won't have a defaulted port set to it if no port exists in the request uri.

I want to confirm within the code that $fu behaves the same.   That is, no default port is going to get set if no port exists in the from uri.  Confirming via code will help me put this issue; provide confidence that i am using the right variables here.

I did confirm via code (thank to your help) that the variable "from_uri" will have a default port set just like the "uri" variable.

Thanks,

Karthik


On Fri, Jul 20, 2018 at 10:26 AM, Karthik Srinivasan <ksriniva2002@gmail.com> wrote:
Yes, i see it defaulting there.  Thanks again for the help.

Karthik

On Fri, Jul 20, 2018 at 7:57 AM, Daniel-Constantin Mierla <miconda@gmail.com> wrote:

The evaluation for uri==myself condition is done inside src/core/route.c starting with line 1817. I see there that it takes default SIP port if none is set in the r-uri.

Cheers,
Daniel


On 20.07.18 06:48, Karthik Srinivasan wrote:
So, i think i have determined the root cause of my issue:

Background info:
 - I have a request URI of an INVITE that contains no port number.
 - My application is not listening on the default port of 5060  

The is_myself(...) function handles a 'no port in request uri' differently than uri==myself.

By that i mean, is_myself(...) does not default the port to 5060 when looking up aliases/(which ip addresses and ports the process is bound to); it simply does not take port number into account (if no port exists in request uri) when searching the alias list.  BUT,  uri==myself does default to 5060 and hence tries to find an alias binding to 5060.

So, is_myself("$ru") passes in my case;  uri==myself fails.  

Can you point me to the place in the source code where 5060 is being set as default to the uri variable when request uri has no port number please?

I don't intend to change this defaulting behavior; I am just curious where it is set.

Thanks,

Karthik

On Thu, Jul 19, 2018 at 3:37 PM, Karthik Srinivasan <ksriniva2002@gmail.com> wrote:
standby,  i have the debug mode spitting out tons of logs now.  

time for me to review. 

will let you know if i need help.

thanks,

karthik

On Thu, Jul 19, 2018 at 3:15 PM, Karthik Srinivasan <ksriniva2002@gmail.com> wrote:
Unfortunately same result as before:

 $var(myself) = 0;
   if (uri =~ "<regex string to match>" || uri == myself){
      $var(myself) = 1;
      xlog("L_INFO", "[$ci] in uri == myself check: var myself = $var(myself)");
   }

   if (uri =~ "<regex string to match>" || is_myself("$ru")){
      $var(myself) = 1;
      xlog("L_INFO", "[$ci] in is_myself check: var myself = $var(myself)");
   }

The only log that prints out is the one that says 'in is_myself check ...'(the second if statement.)

I have verified that if there's a regular expression match then both log writes print.  Regular expression match happens when a SIP REGISTER request comes across the pipe.

Something odd is going on with the computation of  uri == myself vs is_myself("$ru").

Is there a way i can inspect what myself and uri have in them?   

Karthik




On Thu, Jul 19, 2018 at 2:18 PM, Daniel-Constantin Mierla <miconda@gmail.com> wrote:

Hello,

things are different that one may expect from evaluation of an expression compared with other established scripting/programming languages. One thing to be sure you are aware of are the return code evaluation:

  - https://www.kamailio.org/wiki/tutorials/faq/main#how_is_the_function_return_cod

To be sure of proper behaviour, you should do:

if(uri =~ "<regex string to match>" || uri == myself) {

$var(myself) =1;

} else {

$var(myself) = 0;

}

Same with is_myself("$ru") instead of uri == myself.

Try and see if you get different values for $var(myself).

Cheers,
Daniel

On 19.07.18 19:09, Karthik Srinivasan wrote:
Yes, they are used at the very same place. here is a code snippet of where i added it for testing purposes:


route[INIT_VARS] {

$var(myself) = uri =~ "<regex string to match>" || uri == myself;
//if i print $var(myself) it prints 0 
$var(myself) = uri =~ "<regex string to match>" || is_myself("$ru");
//if i print $var(myself) it prints 1 

// in both cases above the regex part isn't supposed to match and hence correctly returns false.
...

}

route{

   route(INIT_VARS);

...
}

Thanks,

Karthik

On Thu, Jul 19, 2018 at 11:46 AM, Daniel-Constantin Mierla <miconda@gmail.com> wrote:
Hello,


On 19.07.18 18:32, Karthik Srinivasan wrote:
> Hello,
>
> Can someone explain to me why statement A returns True and statement B
> returns False.
>
> Statement A:
> is_myself("$ru")
>
> Statement B:
> uri == myself
>
>
> Isn't uri and $ru referencing the same data?   
>
> With my current config i am expecting the is_myself to return True;  i
> was expecting the same for Statement B but unfortunately it is
> returning False.
>
they are supposed to be the same in this case.

Are they used at the same place in config? Note that $ru can be changed
by different functions such as those from registrar, dispatcher, lcr, ...

Cheers,
Daniel

--
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com



-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com




-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com