aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2006-04-16 11:06:58 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2006-04-16 11:06:58 +0000
commit115defd163ff4977cfffbaa5a02e8d19d89e03d2 (patch)
tree88076d7b335285e1bedf19f71ddbd3c54a1c01cf
parentffcdb539debe426e75290cb76f73e5c7b4fc645d (diff)
Set slirp client hostname.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1813 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--qemu-doc.texi5
-rw-r--r--slirp/bootp.c8
-rw-r--r--slirp/libslirp.h1
-rw-r--r--slirp/slirp.c2
-rw-r--r--vl.c10
5 files changed, 22 insertions, 4 deletions
diff --git a/qemu-doc.texi b/qemu-doc.texi
index 7ab0520624..e97e51a99d 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -262,9 +262,10 @@ Qemu can emulate several different models of network card. Valid values for
@code{smc91c111} and @code{lance}. Not all devices are supported on all
targets.
-@item -net user[,vlan=n]
+@item -net user[,vlan=n][,hostname=name]
Use the user mode network stack which requires no administrator
-priviledge to run.
+priviledge to run. @option{hotname=name} can be used to specify the client
+hostname reported by the builtin DHCP server.
@item -net tap[,vlan=n][,fd=h][,ifname=name][,script=file]
Connect the host TAP network interface @var{name} to VLAN @var{n} and
diff --git a/slirp/bootp.c b/slirp/bootp.c
index 9f0652fd63..62cbcfd8f3 100644
--- a/slirp/bootp.c
+++ b/slirp/bootp.c
@@ -228,6 +228,14 @@ static void bootp_reply(struct bootp_t *bp)
val = htonl(LEASE_TIME);
memcpy(q, &val, 4);
q += 4;
+
+ if (*slirp_hostname) {
+ val = strlen(slirp_hostname);
+ *q++ = RFC1533_HOSTNAME;
+ *q++ = val;
+ memcpy(q, slirp_hostname, val);
+ q += val;
+ }
}
*q++ = RFC1533_END;
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index cff159e791..36c8ec21fd 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -32,6 +32,7 @@ int slirp_add_exec(int do_pty, const char *args, int addr_low_byte,
int guest_port);
extern const char *tftp_prefix;
+extern const char slirp_hostname[33];
#ifdef __cplusplus
}
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 404cce8f76..28b8c887a4 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -25,6 +25,8 @@ struct ex_list *exec_list;
/* XXX: suppress those select globals */
fd_set *global_readfds, *global_writefds, *global_xfds;
+const char slirp_hostname[33];
+
#ifdef _WIN32
static int get_dns_addr(struct in_addr *pdns_addr)
diff --git a/vl.c b/vl.c
index 8fba6e76ee..4f9b8c8548 100644
--- a/vl.c
+++ b/vl.c
@@ -3151,6 +3151,11 @@ int net_client_init(const char *str)
} else
#ifdef CONFIG_SLIRP
if (!strcmp(device, "user")) {
+ if (get_param_value(buf, sizeof(buf), "hostname", p)) {
+ if (strlen(buf) > 32)
+ buf[32] = 0;
+ strcpy(slirp_hostname, buf);
+ }
ret = net_slirp_init(vlan);
} else
#endif
@@ -4597,8 +4602,9 @@ void help(void)
"-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
" create a new Network Interface Card and connect it to VLAN 'n'\n"
#ifdef CONFIG_SLIRP
- "-net user[,vlan=n]\n"
- " connect the user mode network stack to VLAN 'n'\n"
+ "-net user[,vlan=n][,hostname=host]\n"
+ " connect the user mode network stack to VLAN 'n' and send\n"
+ " hostname 'host' to DHCP clients\n"
#endif
#ifdef _WIN32
"-net tap[,vlan=n],ifname=name\n"