]> git.proxmox.com Git - mirror_qemu.git/commit - slirp/socket.c
slirp: Factorizing address translation
authorGuillaume Subiron <maethor@subiron.org>
Sat, 19 Dec 2015 21:24:59 +0000 (22:24 +0100)
committerJason Wang <jasowang@redhat.com>
Thu, 4 Feb 2016 05:22:06 +0000 (13:22 +0800)
commit5379229a2708df3a1506113315214c3ce5325859
tree3b7634e203f64ffc5497bae41b8e37f87831a801
parenteae303ff23f51259eddc8856c71453d887ffe51a
slirp: Factorizing address translation

This patch factorizes some duplicate code into a new function,
sotranslate_out(). This function perform the address translation when a
packet is transmitted to the host network. If the packet is destinated
to the host, the loopback address is used, and if the packet is
destinated to the virtual DNS, the real DNS address is used. This code
is just a copy of the existent, but factorized and ready to manage the
IPv6 case.

On the same model, the major part of udp_output() code is moved into a
new sotranslate_in(). This function is directly used in sorecvfrom(),
like sotranslate_out() in sosendto().
udp_output() becoming useless, it is removed and udp_output2() is
renamed into udp_output(). This adds consistency with the udp6_output()
function introduced by further patches.

Lastly, this factorizes some duplicate code into sotranslate_accept(), which
performs the address translation when a connection is established on the host
for port forwarding: if it comes from localhost, the host virtual address is
used instead.

This prepares for IPv6 support.

Signed-off-by: Guillaume Subiron <maethor@subiron.org>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
slirp/bootp.c
slirp/ip_icmp.c
slirp/socket.c
slirp/socket.h
slirp/tcp_subr.c
slirp/tftp.c
slirp/udp.c
slirp/udp.h