[OpenSIPS-Users] Parallel forking - use mid_registrar module question

Tiaki Cadre cadre5000 at gmail.com
Thu Feb 22 15:35:55 EST 2018


I have been using Opensips now for a few years, and in the last month or so
I needed to use Opensips for another application.


We need to put Opensips in front of our Asterisk servers to handle better
the register, notify, invite and subscribe messages (basically the SIP
messaging).

My goal initially, is to have Opensips as a transparent SIP proxy for this.

I have already got this working mostly using the mid_registrar module -
just been looking at it further.

I can send and receive calls from a device that is using the proxy and the
SIP is sent to the main registrar (the asterisk).

The audio works fine since at this stage I am using the RTP on the
asterisk.


The issue I need to solve is multiple registered devices being able to be
called when a user on asterisk makes a call. Outbound calls from the
extension via the proxy work with no issue. Also the notify (BLF) works ok.

I am working on how to get the branch/forking working correctly and the
single call to ring all the contacts in that have "registered" via the
mid_registrar.
I have been trying the AOR for in the mid_registrar request, and then using
mid_registrar_lookup but not having much success.
I am using opensips 2.3.3. After some reading yesterday, there was
suggestion to move to opensips 2.4 branch
I thought I would post here before proceeding too much further in case I am
missing something else.



What is working:

- I can make a call from a phone that is registered to the main registrar
fyi the proxy to an external number (handled by the main registrar)

- I can make a call between phones that are registered to the main
registrar fyi the proxy or that are registered directly to the main
registrar

- I can see the BLF/Notify and subscribe messages working from the main
registrar correctly


Questions:

- Some of the registered devices may be behind NAT and some may be on
Public IPs. How do I best cater for this?


What I need to work:

- When a phone, or incoming call from the main registrar to the proxy
occurs, I need the proxy to ring all phones that are registered through it.


Here are some technical details:

version: opensips 2.3.3 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, F_MALLOC,
FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16,
MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
main.c compiled on 00:04:06 Jan 19 2018 with gcc 4.4.7


>From my opensips.cfg


I have some other modules loaded -but here is the mid_registrar section:

loadmodule "mid_registrar.so"
modparam("mid_registrar", "mode", 1) /* 0 = mirror / 1 = ct / 2 = AoR */
modparam("mid_registrar", "outgoing_expires", 900)
modparam("mid_registrar", "insertion_mode", 1) /* 0 = contact; 1 = path */
modparam("mid_registrar", "received_avp", "$avp(rcv)")
modparam("mid_registrar", "contact_match_param", "regid")
modparam("mid_registrar", "max_contacts", 4)
modparam("mid_registrar", "tcp_persistent_flag", 10)
modparam("mid_registrar", "outgoing_expires", 900)


Snippet from my routing section:

    if (is_method("REGISTER")) {
                #fix_nated_register();
        xlog("L_INFO","Saving location to mid_registrar");
        mid_registrar_save("location");
        switch ($retcode) {
        case 1:
            xlog("forwarding REGISTER to main registrar ($$ci=$ci)\n");
            $ru = "sip:x.x.x.x:5060";
            t_relay();
            break;
        case 2:
            xlog("absorbing REGISTER! ($$ci=$ci)\n");
            break;
        default:
            xlog("failed to save registration! ($$ci=$ci)\n");
        }
        exit;
    }


    remove_hf("Route");
    # record routing
    if (is_method("INVITE|REFER|SUBSCRIBE|NOTIFY"))
        record_route();

    # account only INVITEs
    if (is_method("INVITE")) {
        do_accounting("log");
        xlog("L_INFO", "[LOG] INVITE PACKET  [rm:$rm] [fu:$fu] [ou:$ou]
[ru:$ru] [si:$si]");
    }


    # initial requests from main registrar, need to look them up!
    if (is_method("INVITE|MESSAGE") && $si == "<proxy server public IP>" &&
$sp == 5060) {
        xlog("looking up $ru!\n");
            fix_nated_register();
        if (!mid_registrar_lookup("location")) {
            xlog("looked up main registrar - not found");
            t_reply("404", "Not Found");
            exit;
        }
        xlog("L_INFO","MYLOG INVITE mid_registrar after looking up $ru
$ci");
        t_relay();
        exit;
    }




route[relay] {

    # for INVITEs enable some additional helper routes
    if (is_method("INVITE|NOTIFY|SUBSCRIBE|PUBLISH")) {
                fix_nated_contact();
        t_on_branch("per_branch_ops");
        t_on_reply("handle_nat");
        t_on_failure("missed_call");
    }

    if (!t_relay()) {
        send_reply("500","Internal Error");
    };
    exit;
}


branch_route[per_branch_ops] {
    xlog("new branch at $ru\n");
}


onreply_route[handle_nat] {
    if (nat_uac_test("1")) {
        xlog("FIXING THE NAT!");
        fix_nated_contact();
    }
    xlog("incoming reply\n");
}


failure_route[missed_call] {
    if (t_was_cancelled()) {
        exit;
    }

    # uncomment the following lines if you want to block client
    # redirect based on 3xx replies.
    ##if (t_check_status("3[0-9][0-9]")) {
    ##t_reply("404","Not found");
    ##    exit;
    ##}

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20180223/45330e5c/attachment-0001.html>


More information about the Users mailing list