[OpenSER-Users] add/remove headers and append_branch

Madalina Pitis madalina.pitis at gmail.com
Mon Sep 10 12:00:25 CEST 2007


Hello,

I have a problem trying to remove a header using remove_hf() after an
append_branch(). I am using 1.2 version of OpenSer. The scenario with
the problem is as described in the folowing lines.

When I receive an INVITE I try a parallel fork (one leg towards PSTN,
the other towards IP), at which time I append a "Redirection" header.
The PSTN leg will be answered with a 486 response, due to the presence
of the "Redirection" header. When the IP leg expires, I receive a 408
response, at which time I do a serial fork, and resend the message
towards the PSTN destination, this time without the "Redirection"
header.

The problem is that I cannot seem to be able to remove (or find)  the
header. I tried everywhere (before appending the new branch, after, in
branch_route, before relaying), as you will see below.

I tried searching the mailing lists but nothing turned up. I would
greatly appreciate any help, for I am running out of ideas.

Here is a simplified version of my configuration script, containing
only the significant bits of the routing blocks:

#---------------------------------------------------
# main routing logic
#---------------------------------------------------
route {
        # check maxfwd and message lenght
        # do loose routing

        if (method=="INVITE") {
                # rewrite ruri
                rewriteuri(<PSTN destination>);
                # signal forking
                append_hf("Redirection: count=5\r\n");
                append_branch();
                revert_uri();
                t_on_failure("1");
                if (!t_relay()){
                        xlog("acc_info", "  ERROR");
                        sl_reply_error();
                }
        } else if (method=="ACK" || method=="BYE" || method=="CANCEL") {
                # default message handler
        } else {
                # forbidden message handler
        }
}

#---------------------------------------------------
# Failure route relay
#---------------------------------------------------
route[1] {
        xlog("acc_info", " Failure route relay");

        # try removing it before t_relay
        if(is_present_hf("Redirection")){
                xlog("acc_info", "  Remove before t_relay");
                remove_hf("Redirection");
        }

        if (!t_relay()){
                xlog("acc_info", "  ERROR");
                sl_reply_error();
        }
}

#---------------------------------------------------
# Failure route handling
#---------------------------------------------------
failure_route[1] {
        xlog("acc_info", " failure route handler");

        if(t_check_status("408")) {
                t_on_branch("1");
                rewriteuri(<PSTN destination>);
                # try removing it before append branch
                if(is_present_hf("Redirection")){
                        xlog("acc_info", "  Remove before append branch");
                        remove_hf("Redirection");
                }
                append_branch();
                # try removing it after append branch
                if(is_present_hf("Redirection")){
                        xlog("acc_info", "  Remove after append branch");
                        remove_hf("Redirection");
                }
                route(1);
        }
}




More information about the Users mailing list