One way to implement the "simple and wrong way" is to use an outbound decorator and place the adaptor address that the SIP stack has chosen in the SDP. This address can be read from the source parameter in the decorator.
For example:
class SdpMessageDecorator : public MessageDecorator
virtual void rollbackMessage(SipMessage& msg) {} // Nothing to do
virtual MessageDecorator* clone() const { return new SdpMessageDecorator; }
};
Scott
On Mon, Jun 25, 2012 at 1:12 PM, Adam Roach <adam@xxxxxxxxxxx> wrote:
On 6/25/12 08:31, Jun 25, Karlsson
wrote:
I have a question, if the application run on a PC
which has two NICs, one is connected to the internet(A NIC),
another one connected to a LAN(B NIC), how can the application
detect the internet connection NIC IP(A NIC) and put it into SDP
automatically?
There's the simple and wrong way; and then there's the complex and
right way.
The simple and wrong way involves (if my memory serves)
creating a UDP socket; doing a "connect()" call to an address on the
internet; and then querying the socket for its locally bound address
using "getsockname()".
The correct way that works in arbitrary configurations (What if you
have three interfaces? What if you have a VPN up? What if the other
machine is on the same LAN as you? What if you're behind a NAT and
so is your partner?) is using ICE. See
http://tools.ietf.org/html/rfc5245 and
http://tools.ietf.org/html/rfc5768 for details on how ICE works.
There is an ICE implementation in the resiprocate tree under the
"nICEr" directory, although the interface appears to be a bit rough
at the moment.