aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-05-03 19:58:17 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-05-03 19:58:17 +0000
commit8dbca8dd8a81d7f1afd6ef23b418c8f9d292b65d (patch)
treeae7373143a133db559faa9fdcf8b028f7165eb70
parent68cae3d8c10f914296dfc52cebe214264031df7d (diff)
separate alias_addr (10.0.2.2) from our_addr (Ed Swierk)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1895 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--slirp/ip_icmp.c7
-rw-r--r--slirp/main.h1
-rw-r--r--slirp/misc.c6
-rw-r--r--slirp/slirp.c3
-rw-r--r--slirp/socket.c2
-rw-r--r--slirp/tcp_subr.c4
-rw-r--r--slirp/udp.c2
7 files changed, 13 insertions, 12 deletions
diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 8bc97a0786..b67a37359f 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -114,8 +114,7 @@ icmp_input(m, hlen)
case ICMP_ECHO:
icp->icmp_type = ICMP_ECHOREPLY;
ip->ip_len += hlen; /* since ip_input subtracts this */
- if (ip->ip_dst.s_addr == our_addr.s_addr ||
- (ip->ip_dst.s_addr == (special_addr.s_addr|htonl(CTL_ALIAS))) ) {
+ if (ip->ip_dst.s_addr == alias_addr.s_addr) {
icmp_reflect(m);
} else {
struct socket *so;
@@ -161,7 +160,7 @@ icmp_input(m, hlen)
icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
udp_detach(so);
}
- } /* if ip->ip_dst.s_addr == our_addr.s_addr */
+ } /* if ip->ip_dst.s_addr == alias_addr.s_addr */
break;
case ICMP_UNREACH:
/* XXX? report error? close socket? */
@@ -311,7 +310,7 @@ icmp_error(msrc, type, code, minsize, message)
ip->ip_ttl = MAXTTL;
ip->ip_p = IPPROTO_ICMP;
ip->ip_dst = ip->ip_src; /* ip adresses */
- ip->ip_src = our_addr;
+ ip->ip_src = alias_addr;
(void ) ip_output((struct socket *)NULL, m);
diff --git a/slirp/main.h b/slirp/main.h
index 2d6f43bcc0..181b6ae88d 100644
--- a/slirp/main.h
+++ b/slirp/main.h
@@ -34,6 +34,7 @@ extern u_int curtime;
extern fd_set *global_readfds, *global_writefds, *global_xfds;
extern struct in_addr ctl_addr;
extern struct in_addr special_addr;
+extern struct in_addr alias_addr;
extern struct in_addr our_addr;
extern struct in_addr loopback_addr;
extern struct in_addr dns_addr;
diff --git a/slirp/misc.c b/slirp/misc.c
index 1cd8749737..2c42fd15b0 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -94,10 +94,8 @@ getouraddr()
he = gethostbyname(buff);
if (he)
our_addr = *(struct in_addr *)he->h_addr;
- /* If the host doesn't have a useful IP address then use the
- guest side address. */
- if (our_addr.s_addr == 0 || our_addr.s_addr == loopback_addr.s_addr)
- our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
+ if (our_addr.s_addr == 0)
+ our_addr.s_addr = loopback_addr.s_addr;
}
#if SIZEOF_CHAR_P == 8
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 1331d0ead7..e88745e8aa 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -9,6 +9,8 @@ struct in_addr loopback_addr;
/* address for slirp virtual addresses */
struct in_addr special_addr;
+/* virtual address alias for host */
+struct in_addr alias_addr;
const uint8_t special_ethaddr[6] = {
0x52, 0x54, 0x00, 0x12, 0x35, 0x00
@@ -154,6 +156,7 @@ void slirp_init(void)
}
inet_aton(CTL_SPECIAL, &special_addr);
+ alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
getouraddr();
}
diff --git a/slirp/socket.c b/slirp/socket.c
index ce6528fc45..0ae1f87011 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -596,7 +596,7 @@ solisten(port, laddr, lport, flags)
getsockname(s,(struct sockaddr *)&addr,&addrlen);
so->so_fport = addr.sin_port;
if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
- so->so_faddr = our_addr;
+ so->so_faddr = alias_addr;
else
so->so_faddr = addr.sin_addr;
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index fd3f21a69f..e66987eeae 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -504,7 +504,7 @@ tcp_connect(inso)
so->so_faddr = addr.sin_addr;
/* Translate connections from localhost to the real hostname */
if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr)
- so->so_faddr = our_addr;
+ so->so_faddr = alias_addr;
/* Close the accept() socket, set right state */
if (inso->so_state & SS_FACCEPTONCE) {
@@ -840,7 +840,7 @@ tcp_emu(so, m)
if (ns->so_faddr.s_addr == 0 ||
ns->so_faddr.s_addr == loopback_addr.s_addr)
- ns->so_faddr = our_addr;
+ ns->so_faddr = alias_addr;
ns->so_iptos = tcp_tos(ns);
tp = sototcpcb(ns);
diff --git a/slirp/udp.c b/slirp/udp.c
index be51af6790..dbccccc4fb 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -657,7 +657,7 @@ udp_listen(port, laddr, lport, flags)
getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
so->so_fport = addr.sin_port;
if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
- so->so_faddr = our_addr;
+ so->so_faddr = alias_addr;
else
so->so_faddr = addr.sin_addr;