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.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 7571c5a..0555e18 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -324,6 +324,9 @@ 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)
{
Slirp *slirp = so->slirp;
@@ -332,6 +335,11 @@ int tcp_fconnect(struct socket *so)
DEBUG_CALL("tcp_fconnect");
DEBUG_ARG("so = %lx", (long )so);
+ if (slirp_nooutgoing) {
+ errno = EHOSTUNREACH;
+ return -1;
+ }
+
if( (ret = so->s = qemu_socket(AF_INET,SOCK_STREAM,0)) >= 0) {
int opt, s=so->s;
struct sockaddr_in addr;
@@ -424,6 +432,11 @@ void tcp_connect(struct socket *inso)
tcp_close(sototcpcb(so)); /* This will sofree() as well */
return;
}
+ if (slirp_nooutgoing && addr.sin_addr.s_addr != slirp_nooutgoing) {
+ tcp_close(sototcpcb(so)); /* This will sofree() as well */
+ close(s);
+ return;
+ }
qemu_set_nonblock(s);
socket_set_fast_reuse(s);
opt = 1;