Dear all,

My use case is :

I defined a username = 112 (for emergency call)
This username doesn't exist in subscribers table and unavailable in location table.
The idea is when Sopftphone1 call the group = 112 then Kamailio will forward the call to a group using SERIAL FORKING.

=> Softphone 1 -> Sends INVITE to 112 -> Kamailio -> FORWARD TO SERIAL FORKING (4x softphone all registered and in location table). The q priority could be hybrid that means 2x softphone could have same priority.

My issues :
- the q priority forced for each softphone is not taking into account.
- the first branch created when send INVITE to 112 is still available.


My setup

Kamailio is behind a NAT.

Kamailio version :

sipsecure@kamailio:/$ kamailio -version
version: kamailio 5.5.4 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 10.2.1


Kamailio.cfg

# ----- tm params -----
# auto-discard branches from previous serial forking leg
modparam("tm", "failure_reply_mode", 3)
# default retransmission timeout: 5sec
modparam("tm", "fr_timer", 5000)
# default invite retransmission timeout after 1xx: 10sec
modparam("tm", "fr_inv_timer", 10000)
# This is the name of an XAVP that the t_load_contacts() function uses to store contacts of the destination set and that t_next_contacts() function uses to restore those contacts.
modparam("tm", "contacts_avp", "tm_contacts")
modparam("tm", "contact_flows_avp", "tm_contact_flows")

# modparam("tm|usrloc", "xavp_contact", "tm_contacts")

# ----- rr params -----
# set next param to 1 to add value to ;lr param (helps with some UAs)
modparam("rr", "enable_full_lr", 0)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)

 
route[INVITE]{
    route(THREAD_CHECK);
    route(AUTH);
    route(RECORD_ROUTE);
    setflag(FLT_ACC);

    switch($tU)
    {
        case "112":
            xlog("MY_SEVERITY"," -- Calling Group Serial");
            route(FORK_SERIAL);
        break;

        case "113":
            xlog("MY_SEVERITY"," -- Calling Group Parralelle");
            route(FORK_PARALLEL);
        break;

        default:
            xlog("MY_SEVERITY"," -- Calling Someone");
            route(LOCATION);
            route(RELAY);
        break;
    }
    exit;
}
 
route[FORK_SERIAL]{

    t_on_reply("MANAGE_REPLY");

    #!ifndef WITH_BRIDGE_ON_FAIL
        setbflag(FLB_BRIDGE);
    #!endif
    route(IPV4V6);
    route(NATMANAGE);

    $var(uri1)="sip:9919995@192.168.1.41";
    $var(uri2)="sip:9919994@192.168.1.41";    
    $var(uri3)="sip:9919991@192.168.1.41";
    $var(uri4)="sip:9919997@192.168.1.41";

    lookup("location","$var(uri4)");
    append_branch("$ru","0.2");

    lookup("location","$var(uri1)");
    append_branch("$ru","0.8");

    lookup("location","$var(uri2)");
    append_branch("$ru","0.5");

    lookup("location","$var(uri3)");
    append_branch("$ru","0.5");

    t_load_contacts();

    t_next_contacts();

    t_on_failure("SERIAL");

    #!ifdef WITH_SIPSECURE_DEBUG
        xlog("MY_SEVERITY","    ROUTE_SERIAL : Relaying \n");
    #!endif
    #Relay (aka Forward) the request
    t_relay();
    break;
}

failure_route[SERIAL]{

        xlog("MY_SEVERITY","At failure route - Trying next destination");

            if (!t_next_contacts()) {
                send_reply("408","Nobody available");
                exit;
            }

        t_on_failure("SERIAL");
    
        t_relay();
}
Any highlight will be welcome.

Best Regards,
--
Youssef