helper function to finde the right interface for a remote IP-Address
In some cases (mgcp-gw) it is important to know the IP-Address of the interface through which a remote IP-Address is reachable. This can be done using the syscalls connect() and getsockname(). Implement a helper function in socket.c that takes a remote ip-address as input and outputs the coresponding local interface
#2 Updated by dexter almost 3 years ago
As a sidenote:
The idea is to connect (but not bind) a socket. With the connect syscall, the
kernel will make the actual decision which local interface is appropiate in
order to reach the remote address. We can then query the address of the local
interface choosen using getsockname().
The actual problem we try to solve with this is in the MGCP domain. An MGCP_GW,
that has to serves connections on two different interfaces must return the
ip addres of the interface where the remote reach it to send RTP packets. In
order to know which IP to return, we must probe with the remote IP we already
know thorugh the CRCX or MDCX. The kernel has the routing information of all
interfaces and can make the decision for us.