<div dir="ltr">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.
<br>
<br>
<br>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).
<br>
<br>My goal initially, is to have Opensips as a transparent SIP proxy for
this.
<br>
<br>I have already got this working mostly using the mid_registrar module - just been looking at it further.<br>
<br>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).
<br>
<br>The audio works fine since at this stage I am using the RTP on the
asterisk.
<br>
<br>
<br>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.
<br>
<br>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. <div>I have been trying the AOR for in the mid_registrar request, and then using mid_registrar_lookup but not having much success.</div><div>I am using opensips 2.3.3. After some reading yesterday, there was suggestion to move to opensips 2.4 branch </div><div>I thought I would post here before proceeding too much further in case I am missing something else.<br>
<br>
<br><br>What is working:
<br>
<br>- 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)
<br>
<br>- 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
<br>
<br>- I can see the BLF/Notify and subscribe messages working from the
main registrar correctly </div><div><br></div><div><br></div><div>Questions:</div><div><br></div><div>- Some of the registered devices may be behind NAT and some may be on Public IPs. How do I best cater for this?</div><div>
<br>
<br>What I need to work:
<br>
<br>- 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.
<br>
<br><br>Here are some technical details:
<br>
<br>version: opensips 2.3.3 (x86_64/linux)
<br>flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC,
F_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
<br>ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16,
MAX_URI_SIZE 1024, BUF_SIZE 65535
<br>poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
<br>main.c compiled on 00:04:06 Jan 19 2018 with gcc 4.4.7
<br>
<br>
<br>From my opensips.cfg
<br>
<br>
<br>I have some other modules loaded -but here is the mid_registrar section:
<br>
<br>loadmodule "mid_registrar.so"
<br>modparam("mid_registrar", "mode", 1) /* 0 = mirror / 1 = ct / 2 = AoR */
<br>modparam("mid_registrar", "outgoing_expires", 900)
<br>modparam("mid_registrar", "insertion_mode", 1) /* 0 = contact; 1 =
path */
<br>modparam("mid_registrar", "received_avp", "$avp(rcv)")
<br>modparam("mid_registrar", "contact_match_param", "regid")
<br>modparam("mid_registrar", "max_contacts", 4)
<br>modparam("mid_registrar", "tcp_persistent_flag", 10)
<br>modparam("mid_registrar", "outgoing_expires", 900)
<br>
<br>
<br>Snippet from my routing section:<br><br> if (is_method("REGISTER")) {
<br> #fix_nated_register();
<br> xlog("L_INFO","Saving location to mid_registrar");
<br> mid_registrar_save("location");
<br> switch ($retcode) {
<br> case 1:
<br> xlog("forwarding REGISTER to main registrar ($$ci=$ci)\n");
<br> $ru = "sip:x.x.x.x:5060";
<br> t_relay();
<br> break;
<br> case 2:
<br> xlog("absorbing REGISTER! ($$ci=$ci)\n");
<br> break;
<br> default:
<br> xlog("failed to save registration! ($$ci=$ci)\n");
<br> }
<br> exit;
<br> }
<br><br>
<br> remove_hf("Route");
<br> # record routing
<br> if (is_method("INVITE|REFER|SUBSCRIBE|NOTIFY"))
<br> record_route();
<br>
<br> # account only INVITEs
<br> if (is_method("INVITE")) {
<br> do_accounting("log");
<br> xlog("L_INFO", "[LOG] INVITE PACKET [rm:$rm] [fu:$fu]
[ou:$ou] [ru:$ru] [si:$si]");
<br> }
<br>
<br>
<br> # initial requests from main registrar, need to look them up!
<br> if (is_method("INVITE|MESSAGE") && $si == "<proxy server public
IP>" && $sp == 5060) {
<br> xlog("looking up $ru!\n");
<br> fix_nated_register();
<br> if (!mid_registrar_lookup("location")) {
<br> xlog("looked up main registrar - not found");
<br> t_reply("404", "Not Found");
<br> exit;
<br> }
<br> xlog("L_INFO","MYLOG INVITE mid_registrar after looking up $ru
$ci");
<br> t_relay();
<br> exit;
<br> }
<br>
<br><br>
<br>
<br>route[relay] {
<br>
<br> # for INVITEs enable some additional helper routes
<br> if (is_method("INVITE|NOTIFY|SUBSCRIBE|PUBLISH")) {
<br> fix_nated_contact();
<br> t_on_branch("per_branch_ops");
<br> t_on_reply("handle_nat");
<br> t_on_failure("missed_call");
<br> }
<br>
<br> if (!t_relay()) {
<br> send_reply("500","Internal Error");
<br> };
<br> exit;
<br>}
<br>
<br><br>branch_route[per_branch_ops] {
<br> xlog("new branch at $ru\n");
<br>}
<br>
<br>
<br>onreply_route[handle_nat] {
<br> if (nat_uac_test("1")) {
<br> xlog("FIXING THE NAT!");
<br> fix_nated_contact();
<br> }
<br> xlog("incoming reply\n");
<br>}
<br>
<br>
<br>failure_route[missed_call] {
<br> if (t_was_cancelled()) {
<br> exit;
<br> }
<br>
<br> # uncomment the following lines if you want to block client
<br> # redirect based on 3xx replies.
<br> ##if (t_check_status("3[0-9][0-9]")) {
<br> ##t_reply("404","Not found");
<br> ## exit;
<br> ##}
<br>
<br>}
<br></div></div>