slirp: Rework internal configuration

The user mode IP stack is currently only minimally configurable /wrt to
its virtual IP addresses. This is unfortunate if some guest has a fixed
idea of which IP addresses to use.

Therefore this patch prepares the stack for fully configurable IP
addresses and masks. The user interface and default addresses remain
untouched in this step, they will be enhanced in the following patch.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Jan Kiszka 2009-06-24 14:42:28 +02:00 committed by Anthony Liguori
parent ad196a9d0c
commit a13a4126c8
13 changed files with 148 additions and 141 deletions

View file

@ -555,16 +555,13 @@ sosendto(struct socket *so, struct mbuf *m)
DEBUG_ARG("m = %lx", (long)m);
addr.sin_family = AF_INET;
if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) {
if ((so->so_faddr.s_addr & vnetwork_mask.s_addr) ==
vnetwork_addr.s_addr) {
/* It's an alias */
switch(ntohl(so->so_faddr.s_addr) & 0xff) {
case CTL_DNS:
if (so->so_faddr.s_addr == vnameserver_addr.s_addr) {
addr.sin_addr = dns_addr;
break;
case CTL_ALIAS:
default:
} else {
addr.sin_addr = loopback_addr;
break;
}
} else
addr.sin_addr = so->so_faddr;
@ -652,7 +649,7 @@ solisten(u_int port, u_int32_t laddr, u_int lport, int 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 = alias_addr;
so->so_faddr = vhost_addr;
else
so->so_faddr = addr.sin_addr;