summaryrefslogtreecommitdiff
path: root/slirp/tcp_subr.c
diff options
context:
space:
mode:
Diffstat (limited to 'slirp/tcp_subr.c')
-rw-r--r--slirp/tcp_subr.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index ed16e1807..b2c7a8cba 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -391,6 +391,8 @@ tcp_sockclosed(struct tcpcb *tp)
* nonblocking. Connect returns after the SYN is sent, and does
* not wait for ACK+SYN.
*/
+extern int slirp_nooutgoing;
+
int tcp_fconnect(struct socket *so, unsigned short af)
{
int ret=0;
@@ -398,6 +400,11 @@ int tcp_fconnect(struct socket *so, unsigned short af)
DEBUG_CALL("tcp_fconnect");
DEBUG_ARG("so = %p", so);
+ if (slirp_nooutgoing) {
+ errno = EHOSTUNREACH;
+ return -1;
+ }
+
ret = so->s = qemu_socket(af, SOCK_STREAM, 0);
if (ret >= 0) {
int opt, s=so->s;
@@ -478,6 +485,11 @@ void tcp_connect(struct socket *inso)
tcp_close(sototcpcb(so)); /* This will sofree() as well */
return;
}
+ if (slirp_nooutgoing && ((struct sockaddr_in *)&addr)->sin_addr.s_addr != slirp_nooutgoing) {
+ tcp_close(sototcpcb(so)); /* This will sofree() as well */
+ closesocket(s);
+ return;
+ }
qemu_set_nonblock(s);
socket_set_fast_reuse(s);
opt = 1;