Re: [SR-Users] ways to track all messages of a dialog

2018-03-09 Thread Daniel-Constantin Mierla
If you want flags, then dialog flags, as I wrote before.

Cheers,
Daniel


On 08.03.18 15:03, Fabian Borot wrote:
> Thank you Daniel, I ended up using htables. It works fine .. I just want to 
> see if there was a light weight and ready to use "flag" that would work for 
> me.
>
>
> -Original Message-
> From: Daniel-Constantin Mierla [mailto:mico...@gmail.com] 
> Sent: Thursday, March 8, 2018 3:17 AM
> To: Kamailio (SER) - Users Mailing List ; Fabian 
> Borot 
> Subject: Re: [SR-Users] ways to track all messages of a dialog
>
> Hello,
>
> transaction flags are not the right solution here, because if you set the 
> flag for INVITE, you don't get it set for requests within dialog like ACK, 
> BYE, ...
>
> You can use dialog flags -- see dialog module docs for the functions related 
> to them. You have to call first dlg_manage() (might work also with 
> is_known_dlg()) for these requests and then test the dialog flag.
>
> Alternative, if you don't have dialog module loaded, then use htable to mark 
> the dialog -- so store in htable keys with the call ids of the calls to be 
> tracked. For first invite do:
>
> $sht(x=>$ci) = 1;
>
> And then test for the rest of requests:
>
> if($sht(x=>$ci) == 1) { ... }
>
> Cheers,
> Daniel
>
> On 14.02.18 15:12, Fabian Borot wrote:
>> Thank you , but what I need is to be used inside the script, aside from 
>> logging the processing of the messages for those call I also need to apply 
>> certain logic in the kamailio script file, that is why I need something that 
>> can be used from there.  Sipcapture or sngrep are outside the scope of what 
>> I need.
>>
>> Can somebody confirm whether the flags are suitable for this case ?
>>
>>
>> -Original Message-
>> From: Fabian Borot
>> Sent: Tuesday, February 13, 2018 5:06 PM
>> To: 'sr-users@lists.kamailio.org' 
>> Subject: ways to track all messages of a dialog
>>
>> I need to track all messages (SIP Requests, SIP Responses) for some SIP 
>> dialogs. Let's say I need to log something specific on each state for calls 
>> initiated from a certain IP (initial request, temporary replies, rejection 
>> with a negative response, call was accepted with 200, termination with BYE, 
>> termination with CANCEL  etc. ).
>> I am thinking on using flags but I am not sure after reading the tutorial  
>> on flags 
>> (http://www.kamailio.org/dokuwiki/doku.php/tutorials:openser-flag-operations)
>>  if that is going to work properly. The doc says: "They provide a very easy 
>> and fast way of keeping states during processing a request or during a 
>> transaction". I am afraid that the ACK if the call is accepted and the BYE 
>> won't be tracked properly because they are not part of the initial 
>> transaction. Also the doc does not mention if the flag is preserved among 
>> branches spawned during the processing of the call.
>>
>> The idea is for example: 
>>
>> request_route {
>>  if (is_method("INVITE")){
>>  if ($si == "192.168.168.100"){  #condition that would 
>> set the flag, INVITE came from "my_IP"
>>  #flag/mark dialog
>>  setflag(1);
>>  #log call from "my_IP" was received
>>  }
>>  route("INCOMING);
>>  }
>>  If(loose_route() ){
>>  if (is_method("ACK")){
>>  if(isflagset(1)){
>>  #log ACK related to "my_IP" was received
>>  }
>>  }
>>  if (is_method("CANCEL")){
>>  if(isflagset(1)){
>>  #log CANCEL related to "my_IP" was received
>>  }
>>  }
>>  if (is_method("BYE")){
>>  if(isflagset(1)){
>>  #log BYE related to "my_IP" was received
>>  }
>>  }
>>  }
>> }
>>
>> Then :
>>
>> route["INCOMING"] {
>>  # do some processing
>>  # do some processing
>>  
>>  t_onreply("INCOMING");
>>  t_on_failure("INCOMING");   
>>  t_relay();
>> }
>>
>> onreply_route[INCOMING] {
>>  #do some processing
>>  if(isflagset(1)){
>>  #log a reply related to "my_I

Re: [SR-Users] ways to track all messages of a dialog

2018-03-08 Thread Fabian Borot
Thank you Daniel, I ended up using htables. It works fine .. I just want to see 
if there was a light weight and ready to use "flag" that would work for me.


-Original Message-
From: Daniel-Constantin Mierla [mailto:mico...@gmail.com] 
Sent: Thursday, March 8, 2018 3:17 AM
To: Kamailio (SER) - Users Mailing List ; Fabian 
Borot 
Subject: Re: [SR-Users] ways to track all messages of a dialog

Hello,

transaction flags are not the right solution here, because if you set the flag 
for INVITE, you don't get it set for requests within dialog like ACK, BYE, ...

You can use dialog flags -- see dialog module docs for the functions related to 
them. You have to call first dlg_manage() (might work also with is_known_dlg()) 
for these requests and then test the dialog flag.

Alternative, if you don't have dialog module loaded, then use htable to mark 
the dialog -- so store in htable keys with the call ids of the calls to be 
tracked. For first invite do:

$sht(x=>$ci) = 1;

And then test for the rest of requests:

if($sht(x=>$ci) == 1) { ... }

Cheers,
Daniel

On 14.02.18 15:12, Fabian Borot wrote:
> Thank you , but what I need is to be used inside the script, aside from 
> logging the processing of the messages for those call I also need to apply 
> certain logic in the kamailio script file, that is why I need something that 
> can be used from there.  Sipcapture or sngrep are outside the scope of what I 
> need.
>
> Can somebody confirm whether the flags are suitable for this case ?
>
>
> -Original Message-
> From: Fabian Borot
> Sent: Tuesday, February 13, 2018 5:06 PM
> To: 'sr-users@lists.kamailio.org' 
> Subject: ways to track all messages of a dialog
>
> I need to track all messages (SIP Requests, SIP Responses) for some SIP 
> dialogs. Let's say I need to log something specific on each state for calls 
> initiated from a certain IP (initial request, temporary replies, rejection 
> with a negative response, call was accepted with 200, termination with BYE, 
> termination with CANCEL  etc. ).
> I am thinking on using flags but I am not sure after reading the tutorial  on 
> flags 
> (http://www.kamailio.org/dokuwiki/doku.php/tutorials:openser-flag-operations) 
> if that is going to work properly. The doc says: "They provide a very easy 
> and fast way of keeping states during processing a request or during a 
> transaction". I am afraid that the ACK if the call is accepted and the BYE 
> won't be tracked properly because they are not part of the initial 
> transaction. Also the doc does not mention if the flag is preserved among 
> branches spawned during the processing of the call.
>
> The idea is for example: 
>
> request_route {
>   if (is_method("INVITE")){
>   if ($si == "192.168.168.100"){  #condition that would 
> set the flag, INVITE came from "my_IP"
>   #flag/mark dialog
>   setflag(1);
>   #log call from "my_IP" was received
>   }
>   route("INCOMING);
>   }
>   If(loose_route() ){
>   if (is_method("ACK")){
>   if(isflagset(1)){
>   #log ACK related to "my_IP" was received
>   }
>   }
>   if (is_method("CANCEL")){
>   if(isflagset(1)){
>   #log CANCEL related to "my_IP" was received
>   }
>   }
>   if (is_method("BYE")){
>   if(isflagset(1)){
>   #log BYE related to "my_IP" was received
>   }
>   }
>   }
> }
>
> Then :
>
> route["INCOMING"] {
>   # do some processing
>   # do some processing
>   
>   t_onreply("INCOMING");
>   t_on_failure("INCOMING");   
>   t_relay();
> }
>
> onreply_route[INCOMING] {
>   #do some processing
>   if(isflagset(1)){
>   #log a reply related to "my_IP" was received
>   }
> }
>
> failure_route[INCOMING] {
>   #do some processing
>   if(isflagset(1)){
>   #log a negative reply related to "my_IP" was received
>   }
> }
>
>
> Will the flags work on this case ?
>
> My 2nd approach is to use a htable and use the call_id for my calls as the 
> key. The on each route section (reply, failure_reply, ACK processing etc.) 
> find the $ci on the htable and if it is there do the appropriate action. But 
> I ne

Re: [SR-Users] ways to track all messages of a dialog

2018-03-08 Thread Daniel-Constantin Mierla
Hello,

transaction flags are not the right solution here, because if you set
the flag for INVITE, you don't get it set for requests within dialog
like ACK, BYE, ...

You can use dialog flags -- see dialog module docs for the functions
related to them. You have to call first dlg_manage() (might work also
with is_known_dlg()) for these requests and then test the dialog flag.

Alternative, if you don't have dialog module loaded, then use htable to
mark the dialog -- so store in htable keys with the call ids of the
calls to be tracked. For first invite do:

$sht(x=>$ci) = 1;

And then test for the rest of requests:

if($sht(x=>$ci) == 1) { ... }

Cheers,
Daniel

On 14.02.18 15:12, Fabian Borot wrote:
> Thank you , but what I need is to be used inside the script, aside from 
> logging the processing of the messages for those call I also need to apply 
> certain logic in the kamailio script file, that is why I need something that 
> can be used from there.  Sipcapture or sngrep are outside the scope of what I 
> need.
>
> Can somebody confirm whether the flags are suitable for this case ?
>
>
> -Original Message-
> From: Fabian Borot 
> Sent: Tuesday, February 13, 2018 5:06 PM
> To: 'sr-users@lists.kamailio.org' 
> Subject: ways to track all messages of a dialog
>
> I need to track all messages (SIP Requests, SIP Responses) for some SIP 
> dialogs. Let's say I need to log something specific on each state for calls 
> initiated from a certain IP (initial request, temporary replies, rejection 
> with a negative response, call was accepted with 200, termination with BYE, 
> termination with CANCEL  etc. ).
> I am thinking on using flags but I am not sure after reading the tutorial  on 
> flags 
> (http://www.kamailio.org/dokuwiki/doku.php/tutorials:openser-flag-operations) 
> if that is going to work properly. The doc says: "They provide a very easy 
> and fast way of keeping states during processing a request or during a 
> transaction". I am afraid that the ACK if the call is accepted and the BYE 
> won't be tracked properly because they are not part of the initial 
> transaction. Also the doc does not mention if the flag is preserved among 
> branches spawned during the processing of the call.
>
> The idea is for example: 
>
> request_route {
>   if (is_method("INVITE")){
>   if ($si == "192.168.168.100"){  #condition that would 
> set the flag, INVITE came from "my_IP"
>   #flag/mark dialog
>   setflag(1);
>   #log call from "my_IP" was received
>   }
>   route("INCOMING);
>   }
>   If(loose_route() ){
>   if (is_method("ACK")){
>   if(isflagset(1)){
>   #log ACK related to "my_IP" was received
>   }
>   }
>   if (is_method("CANCEL")){
>   if(isflagset(1)){
>   #log CANCEL related to "my_IP" was received
>   }
>   }
>   if (is_method("BYE")){
>   if(isflagset(1)){
>   #log BYE related to "my_IP" was received
>   }
>   }
>   }
> }
>
> Then :
>
> route["INCOMING"] {
>   # do some processing
>   # do some processing
>   
>   t_onreply("INCOMING");
>   t_on_failure("INCOMING");   
>   t_relay();
> }
>
> onreply_route[INCOMING] {
>   #do some processing
>   if(isflagset(1)){
>   #log a reply related to "my_IP" was received
>   }
> }
>
> failure_route[INCOMING] {
>   #do some processing
>   if(isflagset(1)){
>   #log a negative reply related to "my_IP" was received
>   }
> }
>
>
> Will the flags work on this case ?
>
> My 2nd approach is to use a htable and use the call_id for my calls as the 
> key. The on each route section (reply, failure_reply, ACK processing etc.) 
> find the $ci on the htable and if it is there do the appropriate action. But 
> I need to delete the key:value once the call ends or leave it autoexpire with 
> a expire value bigger than the max_call_duration_time that we have in our 
> system.
>
>
>
>
> ___
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - April 16-18, 2018, Berlin - www.asipto.com
Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com


___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] ways to track all messages of a dialog

2018-02-14 Thread Fabian Borot
Thank you , but what I need is to be used inside the script, aside from logging 
the processing of the messages for those call I also need to apply certain 
logic in the kamailio script file, that is why I need something that can be 
used from there.  Sipcapture or sngrep are outside the scope of what I need.

Can somebody confirm whether the flags are suitable for this case ?


-Original Message-
From: Fabian Borot 
Sent: Tuesday, February 13, 2018 5:06 PM
To: 'sr-users@lists.kamailio.org' 
Subject: ways to track all messages of a dialog

I need to track all messages (SIP Requests, SIP Responses) for some SIP 
dialogs. Let's say I need to log something specific on each state for calls 
initiated from a certain IP (initial request, temporary replies, rejection with 
a negative response, call was accepted with 200, termination with BYE, 
termination with CANCEL  etc. ).
I am thinking on using flags but I am not sure after reading the tutorial  on 
flags 
(http://www.kamailio.org/dokuwiki/doku.php/tutorials:openser-flag-operations) 
if that is going to work properly. The doc says: "They provide a very easy and 
fast way of keeping states during processing a request or during a 
transaction". I am afraid that the ACK if the call is accepted and the BYE 
won't be tracked properly because they are not part of the initial transaction. 
Also the doc does not mention if the flag is preserved among branches spawned 
during the processing of the call.

The idea is for example: 

request_route {
if (is_method("INVITE")){
if ($si == "192.168.168.100"){  #condition that would 
set the flag, INVITE came from "my_IP"
#flag/mark dialog
setflag(1);
#log call from "my_IP" was received
}
route("INCOMING);
}
If(loose_route() ){
if (is_method("ACK")){
if(isflagset(1)){
#log ACK related to "my_IP" was received
}
}
if (is_method("CANCEL")){
if(isflagset(1)){
#log CANCEL related to "my_IP" was received
}
}
if (is_method("BYE")){
if(isflagset(1)){
#log BYE related to "my_IP" was received
}
}
}
}

Then :

route["INCOMING"] {
# do some processing
# do some processing

t_onreply("INCOMING");
t_on_failure("INCOMING");   
t_relay();
}

onreply_route[INCOMING] {
#do some processing
if(isflagset(1)){
#log a reply related to "my_IP" was received
}
}

failure_route[INCOMING] {
#do some processing
if(isflagset(1)){
#log a negative reply related to "my_IP" was received
}
}


Will the flags work on this case ?

My 2nd approach is to use a htable and use the call_id for my calls as the key. 
The on each route section (reply, failure_reply, ACK processing etc.) find the 
$ci on the htable and if it is there do the appropriate action. But I need to 
delete the key:value once the call ends or leave it autoexpire with a expire 
value bigger than the max_call_duration_time that we have in our system.




___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] ways to track all messages of a dialog

2018-02-13 Thread amar.tin...@gmail.com
Also for real time monitoring you can try sngrep tool Original Message Subject: [SR-Users] ways to track all messages of a dialogFrom: Fabian Borot To: sr-users@lists.kamailio.orgCC: I need to track all messages (SIP Requests, SIP Responses) for some SIP dialogs. Let's say I need to log something specific on each state for calls initiated from a certain IP (initial request, temporary replies, rejection with a negative response, call was accepted with 200, termination with BYE, termination with CANCEL  etc. ).I am thinking on using flags but I am not sure after reading the tutorial  on flags (http://www.kamailio.org/dokuwiki/doku.php/tutorials:openser-flag-operations) if that is going to work properly. The doc says: "They provide a very easy and fast way of keeping states during processing a request or during a transaction". I am afraid that the ACK if the call is accepted and the BYE won't be tracked properly because they are not part of the initial transaction. Also the doc does not mention if the flag is preserved among branches spawned during the processing of the call.The idea is for example: request_route {	if (is_method("INVITE")){		if ($si == "192.168.168.100"){  	#condition that would set the flag, INVITE came from "my_IP"			#flag/mark dialog			setflag(1);			#log call from "my_IP" was received		}		route("INCOMING);	}	If(loose_route() ){		if (is_method("ACK")){			if(isflagset(1)){#log ACK related to "my_IP" was received			}		}		if (is_method("CANCEL")){			if(isflagset(1)){#log CANCEL related to "my_IP" was received			}		}		if (is_method("BYE")){			if(isflagset(1)){#log BYE related to "my_IP" was received			}		}	}}Then :route["INCOMING"] {	# do some processing	# do some processing		t_onreply("INCOMING");	t_on_failure("INCOMING");		t_relay();}onreply_route[INCOMING] {	#do some processing	if(isflagset(1)){		#log a reply related to "my_IP" was received	}}failure_route[INCOMING] {	#do some processing	if(isflagset(1)){		#log a negative reply related to "my_IP" was received	}}Will the flags work on this case ?My 2nd approach is to use a htable and use the call_id for my calls as the key. The on each route section (reply, failure_reply, ACK processing etc.) find the $ci on the htable and if it is there do the appropriate action. But I need to delete the key:value once the call ends or leave it autoexpire with a expire value bigger than the max_call_duration_time that we have in our system.___Kamailio (SER) - Users Mailing Listsr-users@lists.kamailio.orghttps://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] ways to track all messages of a dialog

2018-02-13 Thread amar.tin...@gmail.com
I think you need to read about sipcapture moduleAlso you can manage to install homer server which is very important in any sip enviromentRegards Original Message Subject: [SR-Users] ways to track all messages of a dialogFrom: Fabian Borot To: sr-users@lists.kamailio.orgCC: I need to track all messages (SIP Requests, SIP Responses) for some SIP dialogs. Let's say I need to log something specific on each state for calls initiated from a certain IP (initial request, temporary replies, rejection with a negative response, call was accepted with 200, termination with BYE, termination with CANCEL  etc. ).I am thinking on using flags but I am not sure after reading the tutorial  on flags (http://www.kamailio.org/dokuwiki/doku.php/tutorials:openser-flag-operations) if that is going to work properly. The doc says: "They provide a very easy and fast way of keeping states during processing a request or during a transaction". I am afraid that the ACK if the call is accepted and the BYE won't be tracked properly because they are not part of the initial transaction. Also the doc does not mention if the flag is preserved among branches spawned during the processing of the call.The idea is for example: request_route {	if (is_method("INVITE")){		if ($si == "192.168.168.100"){  	#condition that would set the flag, INVITE came from "my_IP"			#flag/mark dialog			setflag(1);			#log call from "my_IP" was received		}		route("INCOMING);	}	If(loose_route() ){		if (is_method("ACK")){			if(isflagset(1)){#log ACK related to "my_IP" was received			}		}		if (is_method("CANCEL")){			if(isflagset(1)){#log CANCEL related to "my_IP" was received			}		}		if (is_method("BYE")){			if(isflagset(1)){#log BYE related to "my_IP" was received			}		}	}}Then :route["INCOMING"] {	# do some processing	# do some processing		t_onreply("INCOMING");	t_on_failure("INCOMING");		t_relay();}onreply_route[INCOMING] {	#do some processing	if(isflagset(1)){		#log a reply related to "my_IP" was received	}}failure_route[INCOMING] {	#do some processing	if(isflagset(1)){		#log a negative reply related to "my_IP" was received	}}Will the flags work on this case ?My 2nd approach is to use a htable and use the call_id for my calls as the key. The on each route section (reply, failure_reply, ACK processing etc.) find the $ci on the htable and if it is there do the appropriate action. But I need to delete the key:value once the call ends or leave it autoexpire with a expire value bigger than the max_call_duration_time that we have in our system.___Kamailio (SER) - Users Mailing Listsr-users@lists.kamailio.orghttps://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users