Also, t_relay_to_tcp() is not necessarily the way forward. Be mindful of the 
possibility of manipulating $fs to select an outgoing (TCP) listener socket, 
and of the need to add or strip ;transport=tcp R-URI attributes depending on 
whether the request is going to a TCP destination.

Putting it all together:

route[ANI_ATTESTATION_QUERY] {
        t_on_branch('ANI_ATTESTATION_QUERY_BRANCH');
        t_on_failure('ANI_ATTESTATION_QUERY_CATCH');

        if(!t_relay())
                sl_reply_error();

        exit;
}

branch_route[ANI_ATTESTATION_QUERY_BRANCH] {
        uac_replace_from("", "sip:$avp(trans_ani)@$fd"); 
        $ru = 'sip:' + $rU + '@' + ANI_ATTESTATION_GW; 
}

failure_route[ANI_ATTESTATION_QUERY_CATCH] {
        if(t_is_canceled()) {
                #xlog(...)
                exit;
        }

        if(t_branch_timeout()) {
                #xlog(...)
                route(OUTBOUND_ROUTE_CONTINUE); # Proceed as normal, w/o 
Identity header.
                exit;
        }

        # Received response, but not 302.
        if($T_rpl($rs) != 302) {
                #xlog(...) - unexpected reply
                route(OUTBOUND_ROUTE_CONTINUE);
                exit;
        }

        # Received 302, but no Identity header.
        if($T_rpl($hdr(Identity)) == $null) {
                route(OUTBOUND_ROUTE_CONTINUE);
                exit;
        }

        # Intermediate storage required because $hdr(...) value is not
        # constant.
        $avp(attest_hdr) = "Identity: " + $T_rpl($hdr(Identity));

        route(OUTBOUND_ROUTE_CONTINUE); # t_relay() etc.
}

> On May 19, 2025, at 4:11 PM, Alex Balashov <[email protected]> wrote:
> 
> Since the redirect response is 3xx+, you should catch it in a 
> failure_route[], which is armed with t_on_failure(). 
> 
> In the failure_route, you can check if the failure_route was invoked because 
> of a timeout with if(t_branch_timeout()), and if it was not, extract the 
> reply code with $T_rpl($rs).
> 
> Then, you modify the R-URI ($ru) to proceed to the original destination and 
> call t_relay() again.
> 
> -- Alex
> 
>> On May 19, 2025, at 3:45 PM, JR Richardson via sr-users 
>> <[email protected]> wrote:
>> 
>> Hey Folks,
>> 
>> I'm integrating STIR/SHAKEN using kamailio, but not using self hosted certs 
>> with the secsipid module, just using a redirect from clearip on the SIP 
>> Calls. I've got the basic connection to clearip using t_relay_to_tcp for 
>> testing, but I'm struggling with the checks and timeouts. I have call 
>> progress past the initial request where I need to wait for a response. 
>> Should I put the clearip invite in its own route block use return? Has 
>> anyone successfully integrated the redirect method with kamailio to clearip 
>> and can give me some example route checks in the kamailio configs?
>> 
>> Thanks.
>> JR
>> 
>> __________________________________________________________
>> Kamailio - Users Mailing List - Non Commercial Discussions -- 
>> [email protected]
>> To unsubscribe send an email to [email protected]
>> Important: keep the mailing list in the recipients, do not reply only to the 
>> sender!
> 
> -- 
> Alex Balashov
> Principal Consultant
> Evariste Systems LLC
> Web: https://evaristesys.com
> Tel: +1-706-510-6800
> 

-- 
Alex Balashov
Principal Consultant
Evariste Systems LLC
Web: https://evaristesys.com
Tel: +1-706-510-6800

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- 
[email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to