Commit 115defd163ff4977cfffbaa5a02e8d19d89e03d2

Authored by pbrook
1 parent ffcdb539

Set slirp client hostname.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1813 c046a42c-6fe2-441c-8c8c-71466251a162
qemu-doc.texi
@@ -262,9 +262,10 @@ Qemu can emulate several different models of network card. Valid values for @@ -262,9 +262,10 @@ Qemu can emulate several different models of network card. Valid values for
262 @code{smc91c111} and @code{lance}. Not all devices are supported on all 262 @code{smc91c111} and @code{lance}. Not all devices are supported on all
263 targets. 263 targets.
264 264
265 -@item -net user[,vlan=n] 265 +@item -net user[,vlan=n][,hostname=name]
266 Use the user mode network stack which requires no administrator 266 Use the user mode network stack which requires no administrator
267 -priviledge to run. 267 +priviledge to run. @option{hotname=name} can be used to specify the client
  268 +hostname reported by the builtin DHCP server.
268 269
269 @item -net tap[,vlan=n][,fd=h][,ifname=name][,script=file] 270 @item -net tap[,vlan=n][,fd=h][,ifname=name][,script=file]
270 Connect the host TAP network interface @var{name} to VLAN @var{n} and 271 Connect the host TAP network interface @var{name} to VLAN @var{n} and
slirp/bootp.c
@@ -228,6 +228,14 @@ static void bootp_reply(struct bootp_t *bp) @@ -228,6 +228,14 @@ static void bootp_reply(struct bootp_t *bp)
228 val = htonl(LEASE_TIME); 228 val = htonl(LEASE_TIME);
229 memcpy(q, &val, 4); 229 memcpy(q, &val, 4);
230 q += 4; 230 q += 4;
  231 +
  232 + if (*slirp_hostname) {
  233 + val = strlen(slirp_hostname);
  234 + *q++ = RFC1533_HOSTNAME;
  235 + *q++ = val;
  236 + memcpy(q, slirp_hostname, val);
  237 + q += val;
  238 + }
231 } 239 }
232 *q++ = RFC1533_END; 240 *q++ = RFC1533_END;
233 241
slirp/libslirp.h
@@ -32,6 +32,7 @@ int slirp_add_exec(int do_pty, const char *args, int addr_low_byte, @@ -32,6 +32,7 @@ int slirp_add_exec(int do_pty, const char *args, int addr_low_byte,
32 int guest_port); 32 int guest_port);
33 33
34 extern const char *tftp_prefix; 34 extern const char *tftp_prefix;
  35 +extern const char slirp_hostname[33];
35 36
36 #ifdef __cplusplus 37 #ifdef __cplusplus
37 } 38 }
slirp/slirp.c
@@ -25,6 +25,8 @@ struct ex_list *exec_list; @@ -25,6 +25,8 @@ struct ex_list *exec_list;
25 /* XXX: suppress those select globals */ 25 /* XXX: suppress those select globals */
26 fd_set *global_readfds, *global_writefds, *global_xfds; 26 fd_set *global_readfds, *global_writefds, *global_xfds;
27 27
  28 +const char slirp_hostname[33];
  29 +
28 #ifdef _WIN32 30 #ifdef _WIN32
29 31
30 static int get_dns_addr(struct in_addr *pdns_addr) 32 static int get_dns_addr(struct in_addr *pdns_addr)
@@ -3151,6 +3151,11 @@ int net_client_init(const char *str) @@ -3151,6 +3151,11 @@ int net_client_init(const char *str)
3151 } else 3151 } else
3152 #ifdef CONFIG_SLIRP 3152 #ifdef CONFIG_SLIRP
3153 if (!strcmp(device, "user")) { 3153 if (!strcmp(device, "user")) {
  3154 + if (get_param_value(buf, sizeof(buf), "hostname", p)) {
  3155 + if (strlen(buf) > 32)
  3156 + buf[32] = 0;
  3157 + strcpy(slirp_hostname, buf);
  3158 + }
3154 ret = net_slirp_init(vlan); 3159 ret = net_slirp_init(vlan);
3155 } else 3160 } else
3156 #endif 3161 #endif
@@ -4597,8 +4602,9 @@ void help(void) @@ -4597,8 +4602,9 @@ void help(void)
4597 "-net nic[,vlan=n][,macaddr=addr][,model=type]\n" 4602 "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
4598 " create a new Network Interface Card and connect it to VLAN 'n'\n" 4603 " create a new Network Interface Card and connect it to VLAN 'n'\n"
4599 #ifdef CONFIG_SLIRP 4604 #ifdef CONFIG_SLIRP
4600 - "-net user[,vlan=n]\n"  
4601 - " connect the user mode network stack to VLAN 'n'\n" 4605 + "-net user[,vlan=n][,hostname=host]\n"
  4606 + " connect the user mode network stack to VLAN 'n' and send\n"
  4607 + " hostname 'host' to DHCP clients\n"
4602 #endif 4608 #endif
4603 #ifdef _WIN32 4609 #ifdef _WIN32
4604 "-net tap[,vlan=n],ifname=name\n" 4610 "-net tap[,vlan=n],ifname=name\n"