aboutsummaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2006-04-23 19:41:17 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2006-04-23 19:41:17 +0000
commite171f0e936f1b10bdc63bc1d61a8cabcdaea38bb (patch)
treedc3e2ae321a576b8e409bd280e8483adad99dc86 /misc.c
parentc69826039a6eba8fa077a6852e88e8ed8076d714 (diff)
downloadslirp-e171f0e936f1b10bdc63bc1d61a8cabcdaea38bb.zip
slirp-e171f0e936f1b10bdc63bc1d61a8cabcdaea38bb.tar.gz
slirp-e171f0e936f1b10bdc63bc1d61a8cabcdaea38bb.tar.bz2
Fix slirp redirection on systems without a useful host IP address.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1837 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/misc.c b/misc.c
index 0fc53d3..3f467ab 100644
--- a/misc.c
+++ b/misc.c
@@ -85,15 +85,16 @@ struct in_addr *ia;
void getouraddr()
{
char buff[256];
- struct hostent *he;
-
- if (gethostname(buff, 256) < 0)
- return;
-
- if ((he = gethostbyname(buff)) == NULL)
- return;
-
- our_addr = *(struct in_addr *)he->h_addr;
+ struct hostent *he = NULL;
+
+ if (gethostname(buff, 256) == 0)
+ 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 SIZEOF_CHAR_P == 8