aboutsummaryrefslogtreecommitdiff
path: root/slirp/tcp_output.c
diff options
context:
space:
mode:
authorGuillaume Subiron <maethor@subiron.org>2016-03-15 10:31:20 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-03-15 10:35:11 +0100
commit98c63057d2144fb81681580cd84c13c93794c96e (patch)
tree6f8ae513422d915b55210f4bf350c3a051daf1c4 /slirp/tcp_output.c
parent15d62af4b6068d1bac1806ca4625b6d4c475eb09 (diff)
downloadqemu-98c63057d2144fb81681580cd84c13c93794c96e.zip
qemu-98c63057d2144fb81681580cd84c13c93794c96e.tar.gz
qemu-98c63057d2144fb81681580cd84c13c93794c96e.tar.bz2
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/tcp_output.c')
-rw-r--r--slirp/tcp_output.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/slirp/tcp_output.c b/slirp/tcp_output.c
index 34e4d2e..7fc6a87 100644
--- a/slirp/tcp_output.c
+++ b/slirp/tcp_output.c
@@ -448,15 +448,23 @@ send:
*/
m->m_len = hdrlen + len; /* XXX Needed? m_len should be correct */
- {
+ struct tcpiphdr tcpiph_save = *(mtod(m, struct tcpiphdr *));
+ m->m_data += sizeof(struct tcpiphdr) - sizeof(struct tcphdr)
+ - sizeof(struct ip);
+ m->m_len -= sizeof(struct tcpiphdr) - sizeof(struct tcphdr)
+ - sizeof(struct ip);
+ struct ip *ip = mtod(m, struct ip *);
- ((struct ip *)ti)->ip_len = m->m_len;
+ ip->ip_len = m->m_len;
+ ip->ip_dst = tcpiph_save.ti_dst;
+ ip->ip_src = tcpiph_save.ti_src;
+ ip->ip_p = tcpiph_save.ti_pr;
- ((struct ip *)ti)->ip_ttl = IPDEFTTL;
- ((struct ip *)ti)->ip_tos = so->so_iptos;
+ ip->ip_ttl = IPDEFTTL;
+ ip->ip_tos = so->so_iptos;
error = ip_output(so, m);
- }
+
if (error) {
out:
return (error);