summaryrefslogtreecommitdiff
path: root/slirp/udp.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2009-06-24 14:42:28 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-29 08:52:45 -0500
commita13a4126c8b94355bbe43e47275b97ce5bef003c (patch)
treebe9f257c4e3956047481cbb2756813be3d023a94 /slirp/udp.c
parentad196a9d0c14f681f010bb4b979030ec125ba976 (diff)
downloadqemu-a13a4126c8b94355bbe43e47275b97ce5bef003c.tar.gz
qemu-a13a4126c8b94355bbe43e47275b97ce5bef003c.tar.bz2
qemu-a13a4126c8b94355bbe43e47275b97ce5bef003c.zip
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>
Diffstat (limited to 'slirp/udp.c')
-rw-r--r--slirp/udp.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/slirp/udp.c b/slirp/udp.c
index ba9d5c92ba..ff3a39fb21 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -312,12 +312,14 @@ int udp_output(struct socket *so, struct mbuf *m,
struct sockaddr_in saddr, daddr;
saddr = *addr;
- if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) {
- if ((so->so_faddr.s_addr & htonl(0x000000ff)) == htonl(0xff))
- saddr.sin_addr.s_addr = alias_addr.s_addr;
- else if (addr->sin_addr.s_addr == loopback_addr.s_addr ||
- (ntohl(so->so_faddr.s_addr) & 0xff) != CTL_ALIAS)
- saddr.sin_addr.s_addr = so->so_faddr.s_addr;
+ if ((so->so_faddr.s_addr & vnetwork_mask.s_addr) == vnetwork_addr.s_addr) {
+ if ((so->so_faddr.s_addr & ~vnetwork_mask.s_addr) ==
+ ~vnetwork_mask.s_addr) {
+ saddr.sin_addr = vhost_addr;
+ } else if (addr->sin_addr.s_addr == loopback_addr.s_addr ||
+ so->so_faddr.s_addr != vhost_addr.s_addr) {
+ saddr.sin_addr = so->so_faddr;
+ }
}
daddr.sin_addr = so->so_laddr;
daddr.sin_port = so->so_lport;
@@ -652,11 +654,12 @@ udp_listen(u_int port, u_int32_t laddr, u_int lport, int 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 = alias_addr;
- else
+ if (addr.sin_addr.s_addr == 0 ||
+ addr.sin_addr.s_addr == loopback_addr.s_addr) {
+ so->so_faddr = vhost_addr;
+ } else {
so->so_faddr = addr.sin_addr;
-
+ }
so->so_lport = lport;
so->so_laddr.s_addr = laddr;
if (flags != SS_FACCEPTONCE)