0
votes

I'm ahmed and I'm working on opensips. Actually, I sow your questions on the forum and I have a problem that I think you have the answer.

Actually, I did a simple senario to route calls between users registered in opensips server, but when it comes to real IP phones( that each one has its own ip address ), it doasn't work. ( trunk ). for example: my opensips address: 10.42.15.18 and my IP phone address is : 10.42.13.82 it is all about sip trunk I think.

I am blocked in this part and searched a lot for a solution, maybe there is a detail that I have missed. which function is responsible for handling requests and responses with an IP phone ?

I used this code :

account only INVITEs

  if ($rU=="49894614950666"){
                        $rU = $tU;
                        rewritehostport("10.42.13.82:5060");
                        $du = "sip:[email protected];user=phone";
                        t_relay();
                        xlog("reference to  URI of 'To' header  ====>  $tu");
                        xlog("reference to domain in URI of 'TO' header  ====>  $td");
                        # route the call out based on RURI
                        route(3);
                        }



route[3]{

         seturi("sip:[email protected];user=phone");
         $du = "sip:[email protected];user=phone";
         rewriteuri("sip:[email protected];user=phone");
         xlog("route 2 :   forwarding to $tU  \n   $ruri  \n");
         xlog("Received $rm from $fu (callid: $ci)\n");
         forward();



                if (is_method("INVITE")) {
                t_on_branch("2");
                t_on_reply("2");
                t_on_failure("1");
        }



        if (!t_relay()) {
                sl_reply_error();
        };
        exit;
}

When calling from a soft phone the requested number, the server sends a request INVITE as follow :

INVITE sip:[email protected];transport=TCP SIP/2.0 
Via: SIP/2.0/TCP 10.42.15.12:5060;branch=z9hG4bK-524287-1---dedd27ee7475c0f1
Max-Forwards: 70 
Contact: <sip:[email protected]:5060;transport=tcp> 
To: <sip:[email protected];transport=TCP> 
From: <sip:[email protected];transport=TCP>;tag=2f025b44 
Call-ID: tdO14DnlADH9Okx6Sr0p4A.. 
CSeq: 1 INVITE 
Content-Type: application/sdp 
User-Agent: Z 3.15.40006 rv2.8.20 
Allow-Events: presence, kpml, talk 
Content-Length: 237 

and the target VM resend an INVITE request to Opensips server, but then, the server start to send to himself messages and not responding the target machine...

I wonder that the "To" field in the INVITE message is false ! opensips only sends a invite to the IP phone and ignore messages coming from it, does not respond after with any ack. what should I add or modify ? thank you a lot.

1
any one can help !lamiri ahmed

1 Answers

0
votes

Why just not using lookup function ? It intended exactly for cases like your and will do all duty work in rewriting URI's automatically.

Something like that :

                    if (lookup("location","m")) {
                             xlog("[INCOMINGCALL][$rU @ $si:$sp ] Forward call call to <$ru> via <$du>\n");
                             if (!t_relay()) {
                                     send_reply("503","Internal Error");
                             };
                             exit;
                     }

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

The advantage of this technique you will be able to change locations at run time using 'opensipsctl address' command