diff options
author | 5eraph <bcervenka@protonmail.com> | 2020-02-12 18:52:23 +0100 |
---|---|---|
committer | 5eraph <bcervenka@protonmail.com> | 2020-03-02 20:17:27 +0100 |
commit | 5eb4fc45dc87717fc9c2e26afb602119006d5dd4 (patch) | |
tree | 25a8e89ede65d0e3de0b6f3915235732e06747b0 /src/tcp_subr.c | |
parent | 296faab4cfd1955bc37fff885985a5b2c0a1fc40 (diff) | |
download | slirp-5eb4fc45dc87717fc9c2e26afb602119006d5dd4.zip slirp-5eb4fc45dc87717fc9c2e26afb602119006d5dd4.tar.gz slirp-5eb4fc45dc87717fc9c2e26afb602119006d5dd4.tar.bz2 |
Use specific outbound IP address
Fixes #14
Signed-off-by: 5eraph <bcervenka@protonmail.com>
Diffstat (limited to 'src/tcp_subr.c')
-rw-r--r-- | src/tcp_subr.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tcp_subr.c b/src/tcp_subr.c index 9dc541a..a1016d9 100644 --- a/src/tcp_subr.c +++ b/src/tcp_subr.c @@ -407,6 +407,16 @@ int tcp_fconnect(struct socket *so, unsigned short af) ret = so->s = slirp_socket(af, SOCK_STREAM, 0); if (ret >= 0) { + ret = slirp_bind_outbound(so, af); + if (ret < 0) { + // bind failed - close socket + closesocket(so->s); + so->s = -1; + return (ret); + } + } + + if (ret >= 0) { int opt, s = so->s; struct sockaddr_storage addr; |