diff options
author | Guillaume Subiron <maethor@subiron.org> | 2016-03-15 10:31:21 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-03-15 10:35:14 +0100 |
commit | 9dfbf250d2a57adea15e42eed44ae35cb32d7597 (patch) | |
tree | a5bbf8bfe64d593175cf0400fd7b2ce0fdcf4465 /slirp/tcp_output.c | |
parent | 98c63057d2144fb81681580cd84c13c93794c96e (diff) |
slirp: Generalizing and neutralizing various TCP functions before adding IPv6 stuff
Basically, this patch adds some switch in various TCP functions to
prepare them for the IPv6 case.
To have something to "switch" in tcp_input() and tcp_respond(), a new
argument is used to give them the sa_family of the addresses they are
working on.
This patch does not include the entailed reindentation, to make proofread
easier. Reindentation is adressed in the following no-op patch.
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.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/slirp/tcp_output.c b/slirp/tcp_output.c index 7fc6a87397..32201fbc41 100644 --- a/slirp/tcp_output.c +++ b/slirp/tcp_output.c @@ -61,7 +61,8 @@ tcp_output(struct tcpcb *tp) register long len, win; int off, flags, error; register struct mbuf *m; - register struct tcpiphdr *ti; + register struct tcpiphdr *ti, tcpiph_save; + struct ip *ip; u_char opt[MAX_TCPOPTLEN]; unsigned optlen, hdrlen; int idle, sendalot; @@ -447,13 +448,15 @@ send: * the template, but need a way to checksum without them. */ m->m_len = hdrlen + len; /* XXX Needed? m_len should be correct */ + tcpiph_save = *mtod(m, struct tcpiphdr *); - struct tcpiphdr tcpiph_save = *(mtod(m, struct tcpiphdr *)); + switch (so->so_ffamily) { + case AF_INET: 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 *); + ip = mtod(m, struct ip *); ip->ip_len = m->m_len; ip->ip_dst = tcpiph_save.ti_dst; @@ -464,6 +467,11 @@ send: ip->ip_tos = so->so_iptos; error = ip_output(so, m); + break; + + default: + g_assert_not_reached(); + } if (error) { out: |