From 9dfbf250d2a57adea15e42eed44ae35cb32d7597 Mon Sep 17 00:00:00 2001 From: Guillaume Subiron Date: Tue, 15 Mar 2016 10:31:21 +0100 Subject: 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 Signed-off-by: Samuel Thibault Reviewed-by: Thomas Huth --- slirp/tcp_output.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'slirp/tcp_output.c') diff --git a/slirp/tcp_output.c b/slirp/tcp_output.c index 7fc6a87..32201fb 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: -- cgit v1.1