< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index  

[reSIProcate] Setting contact field and destination host specification


Sasha Youkhananov wrote:

Try using of setOverrideHostAndPort () method of Profile class (see
Profile.cxx/hxx).
It stores your Contact header in Master profile and uses it in all
appropriate cases.

//* Set Contact's fields
Uri ContactUri;

ContactUri.scheme () = Symbols::DefaultSipScheme;
ContactUri.host () = your address
ContactUri.port () = your port
ContactUri.user () = your user
and so on

Profile->setOverrideHostAndPort (ContactUri);

Don't forget to create an instance of MasterProfile that is inherited
from UserProfile and Profile classes.

Sasha.

I have changed this according...  I assume this is MY host address
which is my Internal LAN IP address (provided I'm behind a NAT),
my port (which is usually 5060), and my username.

OK,  what about the situation where I have a destination URI
like this...

To: <sip:u218055@xxxxxxxxxxxxxx>

However, "whitephone.com" resolves to... 213.167.79.10 which is their web site and
not their server.  Their SIP server is at 213.167.79.25....

It then does the following:

resiprocate-0.9.0-5019/resiprocate/DnsResult.cxx:136 | DnsResult::lookup sip:u218055@xxxxxxxxxxxxxx resiprocate-0.9.0-5019/resiprocate/DnsResult.cxx:337 | Doing NAPTR lookup: whitephone.com resiprocate-0.9.0-5019/resiprocate/DnsResult.cxx:351 | Doing SRV lookup: _sip._udp.whitephone.com resiprocate-0.9.0-5019/resiprocate/DnsResult.cxx:330 | Doing Host (A) lookup: on-instant.com on-instant.com resolves to: 213.167.79.25 which is what I want... But, when it tries to connect, it attempts to send it to 213.167.79.10 instead of
213.167.79.25 the actual sip server.

Ok, so I looked through the DnsResult code, and traced with the source level
debugger, and learned that I can do this.....

   NameAddr to(myDestURI);
   to.param(p_maddr) = "213.167.79.25";

I do this just before I send the Invite request.

This apparently then computes the proper target address...

void
DnsResult::lookup(const Uri& uri)
{
  DebugLog (<< "DnsResult::lookup " << uri);
//assert(uri.scheme() == Symbols::Sips || uri.scheme() == Symbols::Sip); mSips = (uri.scheme() == Symbols::Sips); mTarget = (!mSips && uri.exists(p_maddr)) ? uri.param(p_maddr) : uri.host();

  << rest deleted >>

So now,  mTarget is now pointing to the actual SIP server IP
(the value of "uri.param(p_maddr).
which I previously stuffed into the "to" param space.
This apparently works,  but am I right in guessing this is
the right way to do it?

I do this just before sending the Invite request.

I asked about this earlier, but nobody addressed this yet, so I only hope I can assume this is right. But that's not to say there isn't a cleaner way to do this,
and if there is, please let me know.

There is a method in Profile called "SetoutboundProxy"....  If I set it
to my dest uri,  and use a fixed IP address for my destination proxy
server....  like this:

To: <sip:u218055@xxxxxxxxxxxxx:5060>

Would this in effect force resip to sent Invite to this IP,  and will
the "To" field be changed to look like above,  or will it just change
the transport to point to the SIP server at 213.167.79.25:5060
and leave the URI intact like this...

To: <sip:u218055@xxxxxxxxxxxxxx>

John