Examples

The following examples describe how to create an algorithm using the test references.

Match by the Caller and the Callee

The following algorithm matches two call legs if:

  • The last 6 characters of caller are equal, as found in either the From header or in the P-Asserted-Identity,

  • And the last 6 characters of the callee are equal, as found in either the To header or in the Request-URI.

(cond
    ((uri_user 6 ("from" "pai"))
        (uri_user 6 ("to" "ruri"))
    )
)
  

The following example modifies the one above to return true, if either the caller or the callee matches:

(cond
    ((uri_user 6 ("from" "pai")) #t)
    ((uri_user 6 ("to" "ruri")) #t)
)

Match by Generic Algorithm

The following algorithm is an example of a generic algorithm, which should give good results for a wide range of SIP devices.

(cond
    ((call_id 0) #t)
    ((sdp_media_ip_port) #t)
  
    ; custom header
    ((hf_equals "session-id") #t)
  
    ((time_diff 15000 2000) #f)
   
    ; Matching by from and to
    ((uri_user 6 ("from" "pai" "rpid" "ppid"))
        (cond
            ((uri_user 6 ("to" "ruri" "diversion")) #t)
            (#t #f)
        )
    )
  
    ; nothing matched, return false
    (#t #f)
)
  

The above algorithm:

  • Checks first the Call-ID. If the two call legs have the same Call-ID header, then it returns true.

  • Checks the SDP bodies. If the two call legs have the same media IP and port number, or if the session ID are equal, then it returns true.

  • Checks if the custom Session-ID header is present in both call legs, and if their values are equal, then it returns true.

  • Checks if the start time stamps of the two call legs are too far one from each other, and if so, returns false.

  • Checks if both the caller and the callee match, by comparing the URIs from several headers. If a match is found for both of them, it returns true.

If none of the above is true, it returns false.