All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: Maxim Samoylov <max7255@yandex-team.ru>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC 3/4] slirp: add helpers for ipv6 hostfwd manipulation
Date: Sat, 27 Oct 2018 13:23:26 +0200	[thread overview]
Message-ID: <20181027112326.zcf4jj3teydsidyu@function> (raw)
In-Reply-To: <1540512223-21199-4-git-send-email-max7255@yandex-team.ru>

Hello,

Maxim Samoylov, le ven. 26 oct. 2018 03:03:42 +0300, a ecrit:
> +int slirp_remove_ipv6_hostfwd(Slirp *slirp, int is_udp,
> +                              struct in6_addr host_addr, int host_port)

Similarly, we'd rather share the code than duplicate it :)

Better put the existing slirp_remove_hostfwd code into a

slirp_remove_x_hostfwd(Slirp *slirp, int is_udp, struct sockaddr *addr)

by replacing the explicit ipv4 comparison with a call to a helper
which compares two struct sockaddr (starting with the so_family field,
then testing fields depending the family, and you can put it in
slirp/socket.h)

and then slirp_remove_hostfwd can be rewritten as putting its
parameters into a sockaddr_in and colling slirp_remove_x_hostfwd, and
slirp_remove_ipv6_hostfwd implemented similarly for ipv6.

> +int slirp_add_ipv6_hostfwd(Slirp *slirp, int is_udp,
> +                          struct in6_addr host_addr, int host_port,
> +                          struct in6_addr guest_addr, int guest_port)
> +{
> +    if (is_udp) {
> +        if (!udp6_listen(slirp, host_addr, htons(host_port),
> +                         guest_addr, htons(guest_port), SS_HOSTFWD))
> +            return -1;
> +    } else {
> +        if (!tcp6_listen(slirp, host_addr, htons(host_port),
> +                         guest_addr, htons(guest_port), SS_HOSTFWD))
> +            return -1;
> +    }
> +
> +    return 0;
> +}

That one can remains so :)

Samuel

  reply	other threads:[~2018-10-27 11:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26  0:03 [Qemu-devel] [PATCH RFC 0/4] slirp: support hostfwd for ipv6 addresses Maxim Samoylov
2018-10-26  0:03 ` [Qemu-devel] [PATCH RFC 1/4] slirp: add helper for tcp6 socket creation Maxim Samoylov
2018-10-27 11:11   ` Samuel Thibault
2018-10-27 11:13     ` Samuel Thibault
2018-10-30 13:58     ` Maxim Samoylov
2018-10-30 16:00       ` Samuel Thibault
2018-10-26  0:03 ` [Qemu-devel] [PATCH RFC 2/4] slirp: add helper for udp6 " Maxim Samoylov
2018-10-27 11:13   ` Samuel Thibault
2018-10-26  0:03 ` [Qemu-devel] [PATCH RFC 3/4] slirp: add helpers for ipv6 hostfwd manipulation Maxim Samoylov
2018-10-27 11:23   ` Samuel Thibault [this message]
2018-10-26  0:03 ` [Qemu-devel] [PATCH RFC 4/4] net/slirp: add ipv6-hostfwd option for user netdev type Maxim Samoylov
2018-10-26  6:14   ` Thomas Huth
2018-10-30 14:00     ` Maxim Samoylov
2018-10-27 11:38   ` Samuel Thibault
2018-11-05 23:05   ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181027112326.zcf4jj3teydsidyu@function \
    --to=samuel.thibault@gnu.org \
    --cc=max7255@yandex-team.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.