Use specific outgoing IP
Hi, I would like to be able to set IP address SLIRP binds to - to enforce specific outgoing IP.
I was able to test this with TCP with added specific IP after socket creation here. Like this:
ret = so->s = slirp_socket(af, SOCK_STREAM, 0);
struct sockaddr_in localaddr;
localaddr.sin_family = AF_INET;
localaddr.sin_addr.s_addr = inet_addr("XXX.XXX.XXX.XXX");
localaddr.sin_port = 0;
bind(so->s, (struct sockaddr *)&localaddr, sizeof(localaddr));
This change is of course required for icmp, udp as well...
IP should be part of slirp configuration and so my question is, should I adjust slirp_socket to take argument specifying the address, e.g.:
struct slirp_socket_address {
sin_family...
s_addr...
}
It would have to be passed to functions using the slirp_socket - tcp_fconnect, icmp_send and udp_attach. Or should I implement it that slirp_socket binding will be specified only in specific methods which requires it - tcp_fconnect, icmp_send and udp_attach? (This would be close to similar to above mentioned test)