summaryrefslogtreecommitdiff
path: root/slirp/bootp.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/bootp.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/bootp.c')
-rw-r--r--slirp/bootp.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/slirp/bootp.c b/slirp/bootp.c
index a2fd734cd4..97c2811fbf 100644
--- a/slirp/bootp.c
+++ b/slirp/bootp.c
@@ -27,8 +27,6 @@
#define NB_ADDR 16
-#define START_ADDR 15
-
#define LEASE_TIME (24 * 3600)
typedef struct {
@@ -64,7 +62,7 @@ static BOOTPClient *get_new_addr(struct in_addr *paddr,
found:
bc = &bootp_clients[i];
bc->allocated = 1;
- paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR));
+ paddr->s_addr = vdhcp_startaddr.s_addr + htonl(i);
return bc;
}
@@ -72,12 +70,12 @@ static BOOTPClient *request_addr(const struct in_addr *paddr,
const uint8_t *macaddr)
{
uint32_t req_addr = ntohl(paddr->s_addr);
- uint32_t spec_addr = ntohl(special_addr.s_addr);
+ uint32_t dhcp_addr = ntohl(vdhcp_startaddr.s_addr);
BOOTPClient *bc;
- if (req_addr >= (spec_addr | START_ADDR) &&
- req_addr < (spec_addr | (NB_ADDR + START_ADDR))) {
- bc = &bootp_clients[(req_addr & 0xff) - START_ADDR];
+ if (req_addr >= dhcp_addr &&
+ req_addr < (dhcp_addr + NB_ADDR)) {
+ bc = &bootp_clients[req_addr - dhcp_addr];
if (!bc->allocated || !memcmp(macaddr, bc->macaddr, 6)) {
bc->allocated = 1;
return bc;
@@ -99,7 +97,7 @@ static BOOTPClient *find_addr(struct in_addr *paddr, const uint8_t *macaddr)
found:
bc = &bootp_clients[i];
bc->allocated = 1;
- paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR));
+ paddr->s_addr = vdhcp_startaddr.s_addr + htonl(i);
return bc;
}
@@ -156,7 +154,6 @@ static void bootp_reply(const struct bootp_t *bp)
struct mbuf *m;
struct bootp_t *rbp;
struct sockaddr_in saddr, daddr;
- struct in_addr dns_addr;
const struct in_addr *preq_addr;
int dhcp_msg_type, val;
uint8_t *q;
@@ -218,7 +215,7 @@ static void bootp_reply(const struct bootp_t *bp)
}
}
- saddr.sin_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS);
+ saddr.sin_addr = vhost_addr;
saddr.sin_port = htons(BOOTP_SERVER);
daddr.sin_port = htons(BOOTP_CLIENT);
@@ -262,10 +259,8 @@ static void bootp_reply(const struct bootp_t *bp)
*q++ = RFC1533_NETMASK;
*q++ = 4;
- *q++ = 0xff;
- *q++ = 0xff;
- *q++ = 0xff;
- *q++ = 0x00;
+ memcpy(q, &vnetwork_mask, 4);
+ q += 4;
if (!slirp_restrict) {
*q++ = RFC1533_GATEWAY;
@@ -275,8 +270,7 @@ static void bootp_reply(const struct bootp_t *bp)
*q++ = RFC1533_DNS;
*q++ = 4;
- dns_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_DNS);
- memcpy(q, &dns_addr, 4);
+ memcpy(q, &vnameserver_addr, 4);
q += 4;
}