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: '' <>
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 
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 == ""){          #condition that would 
set the flag, INVITE came from "my_IP"
                        #flag/mark dialog
                        #log call from "my_IP" was received
        If(loose_route() ){
                if (is_method("ACK")){
                                #log ACK related to "my_IP" was received
                if (is_method("CANCEL")){
                                #log CANCEL related to "my_IP" was received
                if (is_method("BYE")){
                                #log BYE related to "my_IP" was received

Then :

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

onreply_route[INCOMING] {
        #do some processing
                #log a reply related to "my_IP" was received

failure_route[INCOMING] {
        #do some processing
                #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

Reply via email to