2009/3/3 Geir O. Jensen geir.o.jensen@uninett.no:
I think maybe there's some misunderstanding here. We don't modify RURI in the looseroute, it's quite simply
if looseroute t_relay()
The RURI of the ACK (INVITe-200) is different when it arrives to Kamailio and when it leaves it, so "something" is modifying it. Of course Kamailio doesn't do that for itself.
And apparently OpenSER (our script?) doesn't know how to handle this when it comes to looseroute so it looks at the To: header instead (which is the original unmodified header i.e. To: number@sip.domain.no
No, OpenSer *never* routes based on To header, never. It would be really pathetic ;)
From our Gateway the contact field is Contact: sip:number@gateway.net
To which the phone replies ACK sip:number@gateway.net SIP/2.0
And seems to be more to OpenSERs (our scripts?) liking as it then just relays it to the correct address.
That's not what I see in the capture:
- The ACK sent by the SNOM phone is correct since the RURI matches the Contact URI received in the 200 Ok:
U 2009/03/03 11:03:58.968311 192.168.10.10:5060 -> 192.168.10.1:5060 ACK sip:192.168.20.1 SIP/2.0
- When the ACK leaves OpenSer it has the RURI *obviously* modified, and it resolves to OpenSER's address (so we have a loop):
U 2009/03/03 11:03:58.972547 192.168.10.1:5060 -> 192.168.10.1:5060 ACK sip:domain.net SIP/2.0
Again *obviously* your script is modifying the ACK RURI and it MUST NOT do it.
Is using rewritehost() the WRONG way to go about forwarding the INVITEs to the right Gateway?
It's fully correct, but onlye initial request may have the RURI modified by OpenSer, never an in-dialog request (ACK for INVITE-200).
Please, believe me: your script is wrong since it's replacing the ACK RURI, that's all.