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
This commit is contained in:
parent
bbeb7b5cbd
commit
f4e15b4b4b
15
slirp/misc.c
15
slirp/misc.c
|
@ -88,15 +88,16 @@ void
|
||||||
getouraddr()
|
getouraddr()
|
||||||
{
|
{
|
||||||
char buff[256];
|
char buff[256];
|
||||||
struct hostent *he;
|
struct hostent *he = NULL;
|
||||||
|
|
||||||
if (gethostname(buff,256) < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((he = gethostbyname(buff)) == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
if (gethostname(buff,256) == 0)
|
||||||
|
he = gethostbyname(buff);
|
||||||
|
if (he)
|
||||||
our_addr = *(struct in_addr *)he->h_addr;
|
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
|
#if SIZEOF_CHAR_P == 8
|
||||||
|
|
|
@ -146,7 +146,6 @@ void slirp_init(void)
|
||||||
m_init();
|
m_init();
|
||||||
|
|
||||||
/* set default addresses */
|
/* set default addresses */
|
||||||
getouraddr();
|
|
||||||
inet_aton("127.0.0.1", &loopback_addr);
|
inet_aton("127.0.0.1", &loopback_addr);
|
||||||
|
|
||||||
if (get_dns_addr(&dns_addr) < 0) {
|
if (get_dns_addr(&dns_addr) < 0) {
|
||||||
|
@ -155,6 +154,7 @@ void slirp_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
inet_aton(CTL_SPECIAL, &special_addr);
|
inet_aton(CTL_SPECIAL, &special_addr);
|
||||||
|
getouraddr();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CONN_CANFSEND(so) (((so)->so_state & (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
|
#define CONN_CANFSEND(so) (((so)->so_state & (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
|
||||||
|
|
Loading…
Reference in a new issue