slirp: Add support for stateless DHCPv6

Provide basic support for stateless DHCPv6 (see RFC 3736) so
that guests can also automatically boot via IPv6 with SLIRP
(for IPv6 network booting, see RFC 5970 for details).

Tested with:

    qemu-system-ppc64 -nographic -vga none -boot n -net nic \
        -net user,ipv6=yes,ipv4=no,tftp=/path/to/tftp,bootfile=ppc64.img

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
This commit is contained in:
Thomas Huth 2016-06-28 12:48:31 +02:00 committed by Samuel Thibault
parent e5857062a6
commit 7b143999f2
4 changed files with 244 additions and 2 deletions

View file

@ -7,6 +7,7 @@
#include "qemu-common.h"
#include "slirp.h"
#include "udp.h"
#include "dhcpv6.h"
void udp6_input(struct mbuf *m)
{
@ -61,7 +62,17 @@ void udp6_input(struct mbuf *m)
lhost.sin6_addr = ip->ip_src;
lhost.sin6_port = uh->uh_sport;
/* TODO handle DHCP/BOOTP */
/* handle DHCPv6 */
if (ntohs(uh->uh_dport) == DHCPV6_SERVER_PORT &&
(in6_equal(&ip->ip_dst, &slirp->vhost_addr6) ||
in6_equal(&ip->ip_dst, &(struct in6_addr)ALLDHCP_MULTICAST))) {
m->m_data += iphlen;
m->m_len -= iphlen;
dhcpv6_input(&lhost, m);
m->m_data -= iphlen;
m->m_len += iphlen;
goto bad;
}
/* handle TFTP */
if (ntohs(uh->uh_dport) == TFTP_SERVER &&