On 14.02.2016 18:47, Samuel Thibault wrote:
> From: Guillaume Subiron <maet...@subiron.org>
> 
> This adds the sin6 case in the fhost and lhost unions and related macros.
> It adds udp6_input() and udp6_output().
> It adds the IPv6 case in sorecvfrom().
> Finally, udp_input() is called by ip6_input().
> 
> Signed-off-by: Guillaume Subiron <maet...@subiron.org>
> Signed-off-by: Samuel Thibault <samuel.thiba...@ens-lyon.org>
> ---
>  slirp/Makefile.objs |   2 +-
>  slirp/ip6_input.c   |   2 +-
>  slirp/socket.c      |   5 ++
>  slirp/socket.h      |   6 ++
>  slirp/udp.h         |   5 ++
>  slirp/udp6.c        | 156 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 174 insertions(+), 2 deletions(-)
>  create mode 100644 slirp/udp6.c
...
> diff --git a/slirp/udp6.c b/slirp/udp6.c
> new file mode 100644
> index 0000000..6c0d55f
> --- /dev/null
> +++ b/slirp/udp6.c
...
> +int udp6_output(struct socket *so, struct mbuf *m,
> +        struct sockaddr_in6 *saddr, struct sockaddr_in6 *daddr)
> +{
> +    struct ip6 *ip;
> +    struct udphdr *uh;
> +
> +    DEBUG_CALL("udp6_output");
> +    DEBUG_ARG("so = %lx", (long)so);
> +    DEBUG_ARG("m = %lx", (long)m);
> +
> +    /* adjust for header */
> +    m->m_data -= sizeof(struct udphdr);
> +    m->m_len += sizeof(struct udphdr);
> +    uh = mtod(m, struct udphdr *);
> +    m->m_data -= sizeof(struct ip6);
> +    m->m_len += sizeof(struct ip6);
> +    ip = mtod(m, struct ip6 *);
> +
> +    /* Build IP header */
> +    ip->ip_pl = htons(m->m_len - sizeof(struct ip6));
> +    ip->ip_nh = IPPROTO_UDP;
> +    ip->ip_src = saddr->sin6_addr;
> +    ip->ip_dst = daddr->sin6_addr;
> +
> +    /* Build UDP header */
> +    uh->uh_sport = saddr->sin6_port;
> +    uh->uh_dport = daddr->sin6_port;
> +    uh->uh_ulen = ip->ip_pl;
> +    uh->uh_sum = 0;
> +    uh->uh_sum = ip6_cksum(m);
> +    if (uh->uh_sum == 0)
> +        uh->uh_sum = 0xffff;

Nit: QEMU coding style requires braces for all if-statements.

> +    return ip6_output(so, m, 0);
> +}

When you've fixed the small nit, feel free to add my:

Reviewed-by: Thomas Huth <th...@redhat.com>



Reply via email to