OpenSIPS 2.1 trunking between two different desktop IP phones

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

OpenSIPS 2.1 trunking between two different desktop IP phones

ahmeddd
Hi,

I'm trying to establish a voice call between two IP phones over opensips 2.2 as a server.

I have two IP phones and I have already installed opensips in my VM, and I want to route calls between those two IP phones.
that mean how to enable the trunk between two different IP
phones and a simple softphone which should be registered to my opensips proxy !! should I do
somethig special to register them ! or should I specify the domain :( VM1 :
x.x.13.87 and VM2 x.x.13.82 ) and for my opensips server (x.x.15.18) ! or
it's the same domain as x.x.15.18 !!
I have defined one domain which is the opensips server domain (x.x.15.18)
and I created the two local users ( VM1: test1@10.42.15.18 ==> 666, VM2 : test2@10.42.15.18 ==>9000 )
When I try to call from a softphone one of the ip phones, it doesn't work..

can any one help me !
I got always 404 user not found and even not reachable!!
below the routing config :


route{


                setflag(22);
                sip_trace();

        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }


        if (has_totag()) {

                # sequential request withing a dialog should
                # take the path determined by record-routing
                if (loose_route()) {
                        # validate the sequential request against dialog
                        if ( $DLG_status!=NULL && !validate_dialog() ) {
                                xlog("In-Dialog $rm from $si (callid=$ci) is not valid according to dialog\n");
                                xlog("this is the source IP $si and this is the  SIP request's method $rm : \n " );
                                ## exit;
                        }

                      if (is_method("BYE")) {
                               setflag(ACC_DO); # do accounting ...
                               setflag(ACC_FAILED); # ... even if the transaction fails
                       } else if (is_method("INVITE")) {
                              # even if in most of the cases is useless, do RR for
                               # re-INVITEs alos, as some buggy clients do change route set
                               # during the dialog.
                                record_route();
                        }


                     # route it out to whatever destination was set by loose_route()
                     # in $du (destination URI).
                     route(relay);
              }  else if ( is_method("ACK") ) {
                                if ( t_check_trans() ) {
                                      # non loose-route, but stateful ACK; must be an ACK after
                                      # a 487 or e.g. 404 from upstream server
                                      t_relay();
                                      exit;
                               } else {
                                       # ACK without matching transaction ->
                                       # ignore and discard
                                       exit;
                               }

                        sl_send_reply("404","Not here");
               }
                exit;
      }


 # preloaded route checking
        if (loose_route()) {
                xlog("L_ERR",
                "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
                if (!is_method("ACK"))
                        sl_send_reply("403","Preload Route denied");
                exit;
        }


        if (!uri==myself) {
                append_hf("P-hint: outbound\r\n");

                route(1);
        }

        # requests for my domain

        if (is_method("PUBLISH|SUBSCRIBE"))
        {
                sl_send_reply("503", "Service Unavailable");
                exit;
        }



      #Register Method
        if (is_method("REGISTER"))
           xlog("**'********  REGISTER  ********************");
                xlog("request URI ===> $ruri");
                xlog("source IP $si  \n " );
                xlog("destination URI = $du  \n");
                xlog("calling user:   $tU \n");
                xlog("reference to  URI of 'To' header  ====>  $tu");
                xlog("reference to domain in URI of 'To' header  ====>  $td");
                xlog("request user rU =  $rU \n");
                xlog("from  value =  $from \n");
                xlog("To header:  $tu \n");
                xlog("requested direction =  $rd");
                xlog("requested port =  $rp ");
                xlog("user ::  $avp(aor) registered the a new contact");

               #if (   0 ) setflag(7);

                if (!save("location"))
                    sl_reply_error();

               #save location added
               save("location");
               exit;
        }


        if ($rU==NULL) {
                # request with no Username in RURI
                sl_send_reply("484","Address Incomplete");
                exit;
        }


        # do lookup with method filtering
        if (!lookup("location","m")) {

                t_newtran();
                t_reply("404", "Not Found");
                exit;
        }


        xlog("*******************************************   SIP TRUNKING ********************************************************");

      # If requested URI is one of the two VMs : 666 or 9000
        if ($tU=~"666") {
          xlog("Detecting destination from number 666: to test8s2");
          $du = "sip:10.42.13.82:5060";
          #replace the domain part of RURI to point to test8s2 or test8s7
          rewriteuri("sip:666@10.42.13.82:5060");
          xlog("request user rU =  $rU \n");
          rewritehostport("10.42.13.82:5060");
          # route the call out based on RURI

                        route(1);
        }


   # all numbers starting with 90 number are to be sent to test8s2 and test8s7
         if ($tU=~"9000"){
            xlog("Detecting destination from number: to test8s7");
           #replace the domain part of RURI to point to test8s2 or test8s7
            strip(1);
           $du="sip:10.42.13.87:5060";
           rewritehostport("10.42.13.87:5060");
           #route the call out based on RURI
           route(1);
        }




        # CANCEL processing
        if (is_method("CANCEL"))
        {
                if (t_check_trans())
                        t_relay();
                exit;
        }

        t_check_trans();



        # load balancing detect resources and do balancing
        if ($tU=~"666" || $ruri=~"sip:10.42.15.18;Transport=TCP") {
        #        xlog(" $rm from $si ,    ruri=$ru", "me");

                forward("10.42.13.82:5060");
                rewriteuri("sip:test8s2@10.42.13.82");
                xlog("requested URI = $rU ");
                # looks like a call to test8s2
                load_balance("2","VM");
                xlog("load balancing destination URI verified : $du");
                route(1);
        }
        else if ($tU=~"9000" || $ruri=~"sip:10.42.15.18;Transport=TCP") {
                forward("10.42.13.87:5060");
                rewriteuri("sip:test8s7@10.42.13.87");
                # looks like a call to test8s7
                 load_balance("2","VM");
                xlog("load balancing: dest Uri = $du");

                route(1);
         }

 # for non-REGISTER requests

       if ( !(is_method("REGISTER")  ) ) {
                if (from_uri==myself){
                    } else {
                        # if caller is not local, then called number must be local
                        # here we nust route the call !!!!!!!
                       if (!uri==myself) {
                                send_reply("403","Rely forbidden");
                                exit;
                        }
                }
            save("location");
            #save any message even it is not a register request
                   }


        # preloaded route checking
        if (loose_route()) {
                xlog("L_ERR",
                "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
                if (!is_method("ACK"))
                        sl_send_reply("403","Preload Route denied");
                exit;

        }


        # record routing
        if (!is_method("REGISTER|MESSAGE"))
                record_route();



        # account only INVITEs
        if (is_method("INVITE")) {
                xlog("***********    INVITE    *********** " ) ;
                xlog("source IP $si  \n " );
                xlog("destination URI = $du  \n");
                xlog("calling user:   $tU \n");
                xlog("reference to  URI of 'To' header  ====>  $tu");
                xlog("reference to domain in URI of 'To' header  ====>  $td");
                xlog("request user rU =  $rU \n");
                xlog("from  value =  $from \n");
                xlog("To header:  $tu \n");
                xlog("requested direction =  $rd");
                xlog("requested port =  $rp ");
                xlog("user ::  $avp(aor) registered the a new contact");

        ยด      if (!lookup("location")) {
                sl_send_reply("404", "User not found");
                exit;
                 }

         # create dialog with timeout
               create_dialog();
               setflag(ACC_DO); # do accounting
       }




        # requests for my domain
        if (is_method("PUBLISH|SUBSCRIBE"))
        {
                sl_send_reply("503", "Service Unavailable");
                #method save location added
                exit;
        }

        # when routing via usrloc, log the missed calls also
        setflag(ACC_MISSED);
        route(relay);

        t_relay();

route(1);

}





route[relay] {

         # for INVITEs enable some additional helper routes
         if (!t_relay()){
                send_reply("500","Internal Error");
        };
        exit;
}

onreply_route[2] {

        xlog("incoming reply\n");
}



route[1] {

        xlog("following route 1 ::: forwarding according to URI");
        # forward according to uri
        forward();


        # for INVITEs enable some additional helper routes
        if (!t_relay()) {
                sl_reply_error();
        };
        exit;
}



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


onreply_route[handle_nat] {

        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;
        ##}


}



local_route {
        if (is_method("BYE") && $DLG_dir=="UPSTREAM") {

                acc_db_request("200 Dialog Timeout", "acc");

        }


Loading...