qemu dhcp server hack
Carl Karsten
carl at personnelware.com
Fri Jun 1 05:31:22 UTC 2007
This is a bit OT, but hopefully not to far off...
qemu has a built in dhcp server. the command line supports specifying a
hostname that will get included with the dhcp offer:
man qemu
-net user[,vlan=n][,hostname=name]
Use the user mode network stack which requires no administrator
priviledge to run. hostname=name can be used to specify the client
hostname reported by the builtin DHCP server.
Here is the code that implements it:
juser at e18:~/qemu/qemu-snapshot-2007-05-31_05$ vim slirp/bootp.c
#define RFC1533_HOSTNAME 12
if (*slirp_hostname) {
val = strlen(slirp_hostname);
*q++ = RFC1533_HOSTNAME;
*q++ = val;
memcpy(q, slirp_hostname, val);
q += val;
}
I wanted to add support for host-name (which is what feeds 'search=' in
/etc/resolve.conf, right?), but I missed something, cuz it doesn't work:
#define RFC1533_DOMAINNAME 15
if (*slirp_domainname) {
val = strlen(slirp_domainname);
*q++ = RFC1533_DOMAINNAME;
*q++ = val;
memcpy(q, slirp_domainname, val);
q += val;
}
assuming my parameter passing is OK, is there something about the way the dhcp
offer is being constructed I need to know?
Carl K
More information about the dhcp-users
mailing list