[Kamailio-Users] SIP Re-Routing using Private Header

Daniel-Constantin Mierla miconda at gmail.com
Sun Mar 8 19:49:20 CET 2009


Hello,

On 03/07/2009 06:13 PM, Geoffrey Mina wrote:
> Hello,
> I have a problem which I am not sure the best way to solve with
> Kamailio.  I have many asterisk servers which use Kamailio as their
> outbound gateway to route calls to the PSTN.  This works great, I use
> the LCR engine to control routing.
>
> What I want to do is have the ability to dial a random SIP URI from my
> asterisk servers, but route the call through my Kamailio server for
> accounting and security purposes.  My asterisk servers are not allowed
> SIP messaging from anything other than my Kamailio gateway.  What I am
> considering doing is something like this:
>
> Since asterisk is fairly limited in your ability to route calls, I
> need to do a little magic to make the call route through a proxy.
> Maybe I'm wrong, but I haven't yet been able to figure it out.  My
> theory is that I will add a special header at the asterisk level and
> send the invite to Kamailio.
>
> [test]
> exten => 1,1,SipAddHeader("P-Forward-URI: bob at somedomain.com")
> exten => 1,n,Dial(SIP/forward at kamailio,30)
>
>
> [From Asterisk To Kamailio]
> INVITE sip:forward at 10.1.1.1 SIP/2.0
> Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds
> Max-Forwards: 70
> To: <sip:forward at 10.1.1.1>
> From: "" <sip:5555551212 at pc33.atlanta.com>;tag=1928301774
> Call-ID: a84b4c76e66710 at pc33.atlanta.com
> CSeq: 314159 INVITE
> Contact: <sip:5555551212 at pc33.atlanta.com>
> Content-Type: application/sdp
> Content-Length: 142
> P-Forward-URL: bob at somedomain.com
>
>
> if(is_present_hf("P-Forward-URL")){
>    //what do i do here to rewrite the To and INVITE parts before doing
> record_route() and t_relay()
> }
>
>
> Maybe I'm totally off track here, but this is all I have come up with
> so far!  Perhaps there is a mechanism in SIP which already allows me
> to do this, and I don't know about it... I don't know what I don't
> know :)
>
>   
IIRC, Asterisk has a mechanism to specify the outbound proxy.

Anyhow, what you do is ok and you can take the uri from the particular 
header, add it to R-RUI and remove the header. The problem is in 
rewriting the To, but you should not need this if the callee is RFC3261. 
Rewriting To header must be avoided as much as possible.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://www.asipto.com





More information about the sr-users mailing list