diff options
author | Guillaume Subiron <maethor@subiron.org> | 2016-03-15 10:31:20 +0100 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-11-29 19:49:37 -0600 |
commit | eb65f7562de1e608cff2c393f8cd97839a12391d (patch) | |
tree | ebaf2c1c392e5e0a1f54d728a8feaf7f4de53b99 /slirp/socket.c | |
parent | 25a06aeb16b30184a3bb0ddb00c5944ad24a0ab8 (diff) | |
download | hqemu-eb65f7562de1e608cff2c393f8cd97839a12391d.zip hqemu-eb65f7562de1e608cff2c393f8cd97839a12391d.tar.gz |
slirp: Factorizing tcpiphdr structure with an union
This patch factorizes the tcpiphdr structure to put the IPv4 fields in
an union, for addition of version 6 in further patch.
Using some macros, retrocompatibility of the existing code is assured.
This patch also fixes the SLIRP_MSIZE and margin computation in various
functions, and makes them compatible with the new tcpiphdr structure,
whose size will be bigger than sizeof(struct tcphdr) + sizeof(struct ip)
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>
Diffstat (limited to 'slirp/socket.c')
-rw-r--r-- | slirp/socket.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/slirp/socket.c b/slirp/socket.c index 55150f5..8df9252 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -483,7 +483,18 @@ sorecvfrom(struct socket *so) if (!m) { return; } - m->m_data += IF_MAXLINKHDR; + switch (so->so_ffamily) { + case AF_INET: + m->m_data += IF_MAXLINKHDR + sizeof(struct udpiphdr); + break; + case AF_INET6: + m->m_data += IF_MAXLINKHDR + sizeof(struct ip6) + + sizeof(struct udphdr); + break; + default: + g_assert_not_reached(); + break; + } /* * XXX Shouldn't FIONREAD packets destined for port 53, |