[pjsip] choosing an IP address -regarding
caugar at gmail.com
Thu May 8 20:03:03 EDT 2008
I am using PJSIP on a Windows Mobile device. (I am using version 0.5.3) .
This device has Wi-Fi and a 3G connection. When I connect through only one
network (either 3G or Wifi), I am able to register with my SIP server. (a
vanilla Asterisk box on the public network).
I want to be able to configure such that, for SIP messages it must go
through 3G and for RTP/media it must go through Wifi (when both interfaces
are available). I am experimenting with a media stack that is not PJMEDIA.I
am able to assign the WiFi interface IP address for RTP traffic. But for
SIP, I see the following call in many places in the code.
status = pj_gethostip(pj_in_addr in_addr);
This function gets the IP address on the default interface (it checks for
0.0.0.0 and if nothing comes up, it returns 127.0.0.1) . As kludgy as it
sounds, I went and modified everywhere this function is called and checked
to see if I had a 3G connection, use that IP instead.
in_addr.s_addr = inet_addr(char *cellular_ip_string);
My Wifi has a public IP address (18.104.22.168) and the 3G provider assigns
a private IP (10.something)
I tried to register with the Asterisk server (with both interfaces active on
my device). The phone registers but it uses the WiFi interface IP address. I
inspected the packet and I shall reproduce the REGISTER message observed on
the Asterisk server.
Internet Protocol, Src: 22.214.171.124 (126.96.36.199), Dst: 188.8.131.52 (
User Datagram Protocol, Src Port: 5060 (5060), Dst Port: 5060 (5060)
Session Initiation Protocol
Request-Line: REGISTER sip:myvoipserver:5060 SIP/2.0
Via: SIP/2.0/UDP 10.84.15.87:5060
From: <sip:1001 at myvoipserver>;tag=42710002ec722c6d1d79
To: <sip:1001 at myvoipserver>
CSeq: 38210 REGISTER
Sequence Number: 38210
As you can observe, my 3G IP address is seen in the Via and contact headers
while my Wifi IP address is seen on the IP header. I dont understand where
did the SIP stack get this IP address from ? The entire SIP message uses the
3G connection IP address. In fact, I checked within the code and I find that
wherever in_addr is used, it uses the 3G IP address.
Can anyone shed some light as to why this happens ? Is there a place where I
had neglected to change the IP address setting ?
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pjsip