Re: [SR-Users] SIP re-invite Packets

2018-07-18 Thread Ali Taher
Thank you for your reply.

 

I tried the config file shared by Alex below , but I noticed that kamailio is 
not dealing with CANCEL requests.

 

the scenario in my case is that I’m using Kamailio behind a switch to alter 
some packets (precisely 183 packets) , so I need to forward all packets coming 
from my customer to the switch , which will deal with it (send it to 
appropriate supplier).

 

So what I need is the config file that will forward all requests coming to 
Kamailio from my customer , to forward them to my switch , then reply back to 
customer the reply coming from the switch. 9after altering 183 packet to 180) , 
handling the in-dialog invites sent by my switch , which needs to be sent to 
the customer by kamailio.

 

Thanks

Ali Taher

 

From: sr-users  On Behalf Of 
y...@yu-boot.ru
Sent: Tuesday, July 17, 2018 9:41 PM
To: Kamailio (SER) - Users Mailing List 
Cc: sr-us...@lists.sip-router.org
Subject: Re: [SR-Users] SIP re-invite Packets

 

ReInvites like all in-dialog requests are processed in has_totag()/loose_route 
part. Default kamailio.cfg has almost identical part for this purpose.

Main idea is that an initial request (non in-dialog) hasn't To tag already. It 
appears only when your request "hits" remote side (called or callee, as you 
wish) and goes back to you. Simplified, but I hope you got an idea :)

--
sent from myMail for Android

вторник, 17 июля 2018г., 17:16 +03:00 от Ali Taher ata...@vanrise.com 
<mailto:ata...@vanrise.com> :




Hi Alex,

Thank you for your reply.

Does below config forward all sip requests coming from the customer to the 
supplier , and relay sip replies back to customer ?

Where re-invite packets are handled in the below config file?

Thank you 
Ali Taher

-Original Message-
From: sr-users mailto:sr-users-boun...@lists.kamailio.org> > On Behalf Of Alex Balashov
Sent: Tuesday, July 17, 2018 4:25 PM
To: Kamailio (SER) - Users Mailing List mailto:sr-users@lists.kamailio.org> >
Cc: sr-us...@lists.sip-router.org <mailto:sr-us...@lists.sip-router.org> 
Subject: Re: [SR-Users] SIP re-invite Packets

On Tue, Jul 17, 2018 at 04:21:25PM +0300, Ali Taher wrote:

> Can you please send me a simplified config that suit my case ?

Try this for a main request route:

---

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

# Maybe some sanity_check() here. 

if(has_totag()) {
if(loose_route()) {
if(!t_relay())
sl_reply_error();

exit;
} else {
if(is_method("ACK")) {
if(t_check_trans())
t_relay();
} else
sl_send_reply("403", "Forbidden");
}

exit;
}

# CANCELs / branches.

if(is_method("CANCEL")) {
if(!t_relay_cancel()) {
sl_send_reply("500", "Server Internal Error");
exit;
}

exit;
}

t_check_trans();

if(is_method("OPTIONS")) {
sl_send_reply("200", "OK");
exit;
} 

else if(is_method("INVITE")) {
# Route your calls.

exit;
}

sl_send_reply("403", "Method unsupported");
exit;
}


-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org> 
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org> 
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] SIP re-invite Packets

2018-07-17 Thread yu

ReInvites like all in-dialog requests are processed in has_totag()/loose_route 
part. Default kamailio.cfg has almost identical part for this purpose.
Main idea is that an initial request (non in-dialog) hasn't To tag already. It 
appears only when your request "hits" remote side (called or callee, as you 
wish) and goes back to you. Simplified, but I hope you got an idea :)
--
sent from myMail for Android вторник, 17 июля 2018г., 17:16 +03:00 от Ali Taher 
 ata...@vanrise.com :

>Hi Alex,
>
>Thank you for your reply.
>
>Does below config  forward all sip requests coming from the customer to the 
>supplier , and relay sip replies back to customer ?
>
>Where re-invite packets are handled in the below config file?
>
>Thank you 
>Ali Taher
>
>-Original Message-
>From: sr-users < sr-users-boun...@lists.kamailio.org> On Behalf Of Alex 
>Balashov
>Sent: Tuesday, July 17, 2018 4:25 PM
>To: Kamailio (SER) - Users Mailing List < sr-users@lists.kamailio.org>
>Cc:  sr-us...@lists.sip-router.org
>Subject: Re: [SR-Users] SIP re-invite Packets
>
>On Tue, Jul 17, 2018 at 04:21:25PM +0300, Ali Taher wrote:
>
> Can you please send me a simplified config that suit my case ?
>
>Try this for a main request route:
>
>---
>
>route {
>if(!mf_process_maxfwd_header("10")) {
>sl_send_reply("483", "Too Many Hops");
>exit;
>}
>
># Maybe some sanity_check() here. 
>
>if(has_totag()) {
>if(loose_route()) {
>if(!t_relay())
>sl_reply_error();
>
>exit;
>} else {
>if(is_method("ACK")) {
>if(t_check_trans())
>t_relay();
>} else
>sl_send_reply("403", "Forbidden");
>}
>
>exit;
>}
>
># CANCELs / branches.
>
>if(is_method("CANCEL")) {
>if(!t_relay_cancel()) {
>sl_send_reply("500", "Server Internal Error");
>exit;
>}
>
>exit;
>}
>
>t_check_trans();
>
>if(is_method("OPTIONS")) {
>sl_send_reply("200", "OK");
>exit;
>} 
>
>else if(is_method("INVITE")) {
># Route your calls.
>
>exit;
>}
>
>sl_send_reply("403", "Method unsupported");
>exit;
>}
>
>
>-- 
>Alex Balashov | Principal | Evariste Systems LLC
>
>Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
>Web:  http://www.evaristesys.com/ ,  http://www.csrpswitch.com/
>
>___
>Kamailio (SER) - Users Mailing List
>sr-users@lists.kamailio.org
>https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>
>___
>Kamailio (SER) - Users Mailing List
>sr-users@lists.kamailio.org
>https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] SIP re-invite Packets

2018-07-17 Thread Ali Taher
Hi Alex,

Thank you for your reply.

Does below config  forward all sip requests coming from the customer to the 
supplier , and relay sip replies back to customer ?

Where re-invite packets are handled in the below config file?

Thank you 
Ali Taher

-Original Message-
From: sr-users  On Behalf Of Alex Balashov
Sent: Tuesday, July 17, 2018 4:25 PM
To: Kamailio (SER) - Users Mailing List 
Cc: sr-us...@lists.sip-router.org
Subject: Re: [SR-Users] SIP re-invite Packets

On Tue, Jul 17, 2018 at 04:21:25PM +0300, Ali Taher wrote:

> Can you please send me a simplified config that suit my case ?

Try this for a main request route:

---

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

# Maybe some sanity_check() here. 

if(has_totag()) {
if(loose_route()) {
if(!t_relay())
sl_reply_error();

exit;
} else {
if(is_method("ACK")) {
if(t_check_trans())
t_relay();
} else
sl_send_reply("403", "Forbidden");
}

exit;
}

# CANCELs / branches.

if(is_method("CANCEL")) {
if(!t_relay_cancel()) {
sl_send_reply("500", "Server Internal Error");
exit;
}

exit;
}

t_check_trans();

if(is_method("OPTIONS")) {
sl_send_reply("200", "OK");
exit;
} 

else if(is_method("INVITE")) {
# Route your calls.

exit;
}

sl_send_reply("403", "Method unsupported");
exit;
}


-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] SIP re-invite Packets

2018-07-17 Thread Alex Balashov
On Tue, Jul 17, 2018 at 04:21:25PM +0300, Ali Taher wrote:

> Can you please send me a simplified config that suit my case ?

Try this for a main request route:

---

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

# Maybe some sanity_check() here. 

if(has_totag()) {
if(loose_route()) {
if(!t_relay())
sl_reply_error();

exit;
} else {
if(is_method("ACK")) {
if(t_check_trans())
t_relay();
} else
sl_send_reply("403", "Forbidden");
}

exit;
}

# CANCELs / branches.

if(is_method("CANCEL")) {
if(!t_relay_cancel()) {
sl_send_reply("500", "Server Internal Error");
exit;
}

exit;
}

t_check_trans();

if(is_method("OPTIONS")) {
sl_send_reply("200", "OK");
exit;
} 

else if(is_method("INVITE")) {
# Route your calls.

exit;
}

sl_send_reply("403", "Method unsupported");
exit;
}


-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] SIP re-invite Packets

2018-07-17 Thread Ali Taher
Hi Alex,

So loose_route() is only responsible of In-dialog requests ?

Can you please send me a simplified config that suit my case ?

Noting that I'm using Kamailio only as proxy between my customer and my 
supplier.

Much appreciated.

Ali Taher

-Original Message-
From: sr-users  On Behalf Of Alex Balashov
Sent: Tuesday, July 17, 2018 3:44 PM
To: Kamailio (SER) - Users Mailing List 
Cc: sr-us...@lists.sip-router.org
Subject: Re: [SR-Users] SIP re-invite Packets

Hi,

In-dialog requests must be handled using loose_route(). You can find the proper 
boilerplate in the stock configuration file:

https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg#L587

To note, your config is not sufficient to handle all aspects of a call between 
endpoints in an adequate way. You will want to consider the main request_route 
in the main config file and adapt its most essential aspects accordingly:

https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg#L455

-- Alex

On Tue, Jul 17, 2018 at 03:40:58PM +0300, Ali Taher wrote:

> Hello,
> 
>  
> 
> I'm using below routing logic to change the 183 reply to 180 and send 
> it back to the origination.
> 
>  
> 
> Noting that Kamailio is listening on 5065.
> 
> route{
> 
> if (is_method("INVITE")) {
> 
> xlog("L_INFO","INSIDE request route $si \n");
> 
>   insert_hf("X-AUTH-IP: $si\r\n");
> 
> }
> 
> route(FWD);
> 
> }
> 
>  
> 
> reply_route {
> 
> #xlog("L_INFO","INSDE reply \n");
> 
> if (status == "183") {
> 
> change_reply_status(180, "Ringing");
> 
> exit;
> 
> }
> 
> }
> 
>  
> 
> route[FWD] {
> 
> #xlog("L_INFO","INSIDE FWD \n");
> 
> forward(x.x.x.x,5060);
> 
> }
> 
>  
> 
>  
> 
> Below is the scenario , where the customer is sending packets to 
> Kamailio , and Kamailio is forwarding them the supplier (with IP 
> x.x.x.x) , then the supplier reply back to kamailio  and kamailio 
> relay the reply to the customer
> 
>  
> 
> Customer --> Kamailio ---> ---Supplier---
> 
>  
> 
> I have a case where the supplier sends in some cases an in-dialog 
> invite
> (Re-Invite) , which is considered I think as SIP-Request and thus as 
> per above routing logic , kamailio is sending it back to the supplier 
> , yet I need to send it to the customer.
> 
>  
> 
> How can I solve this issue?
> 
>  
> 
> Thanks
> 
> Ali Taher
> 

> ___
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


--
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] SIP re-invite Packets

2018-07-17 Thread Alex Balashov
Hi,

In-dialog requests must be handled using loose_route(). You can find the
proper boilerplate in the stock configuration file:

https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg#L587

To note, your config is not sufficient to handle all aspects of a call
between endpoints in an adequate way. You will want to consider the main
request_route in the main config file and adapt its most essential
aspects accordingly:

https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg#L455

-- Alex

On Tue, Jul 17, 2018 at 03:40:58PM +0300, Ali Taher wrote:

> Hello,
> 
>  
> 
> I'm using below routing logic to change the 183 reply to 180 and send it
> back to the origination.
> 
>  
> 
> Noting that Kamailio is listening on 5065.
> 
> route{
> 
> if (is_method("INVITE")) {
> 
> xlog("L_INFO","INSIDE request route $si \n");
> 
>   insert_hf("X-AUTH-IP: $si\r\n");
> 
> }
> 
> route(FWD);
> 
> }
> 
>  
> 
> reply_route {
> 
> #xlog("L_INFO","INSDE reply \n");
> 
> if (status == "183") {
> 
> change_reply_status(180, "Ringing");
> 
> exit;
> 
> }
> 
> }
> 
>  
> 
> route[FWD] {
> 
> #xlog("L_INFO","INSIDE FWD \n");
> 
> forward(x.x.x.x,5060);
> 
> }
> 
>  
> 
>  
> 
> Below is the scenario , where the customer is sending packets to Kamailio ,
> and Kamailio is forwarding them the supplier (with IP x.x.x.x) , then the
> supplier reply back to kamailio  and kamailio relay the reply to the
> customer 
> 
>  
> 
> Customer --> Kamailio ---> ---Supplier---
> 
>  
> 
> I have a case where the supplier sends in some cases an in-dialog invite
> (Re-Invite) , which is considered I think as SIP-Request and thus as per
> above routing logic , kamailio is sending it back to the supplier , yet I
> need to send it to the customer.
> 
>  
> 
> How can I solve this issue?
> 
>  
> 
> Thanks
> 
> Ali Taher
> 

> ___
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users