]> Git Repo - qemu.git/blobdiff - slirp/tcp_output.c
target/i386: Don't use x86_cpu_load_def() on "max" CPU model
[qemu.git] / slirp / tcp_output.c
index fafca58a0a1efe5c8fe45c8d72ec31805b29f0d3..90b5c376f785c031febe314f088c1e48e3ebb37e 100644 (file)
@@ -38,7 +38,8 @@
  * terms and conditions of the copyright.
  */
 
-#include <slirp.h>
+#include "qemu/osdep.h"
+#include "slirp.h"
 
 static const u_char  tcp_outflags[TCP_NSTATES] = {
        TH_RST|TH_ACK, 0,      TH_SYN,        TH_SYN|TH_ACK,
@@ -60,7 +61,9 @@ 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;
+       struct ip6 *ip6;
        u_char opt[MAX_TCPOPTLEN];
        unsigned optlen, hdrlen;
        int idle, sendalot;
@@ -85,7 +88,7 @@ tcp_output(struct tcpcb *tp)
 again:
        sendalot = 0;
        off = tp->snd_nxt - tp->snd_una;
-       win = min(tp->snd_wnd, tp->snd_cwnd);
+        win = MIN(tp->snd_wnd, tp->snd_cwnd);
 
        flags = tcp_outflags[tp->t_state];
 
@@ -124,7 +127,7 @@ again:
                }
        }
 
-       len = min(so->so_snd.sb_cc, win) - off;
+        len = MIN(so->so_snd.sb_cc, win) - off;
 
        if (len < 0) {
                /*
@@ -190,7 +193,7 @@ again:
                 * taking into account that we are limited by
                 * TCP_MAXWIN << tp->rcv_scale.
                 */
-               long adv = min(win, (long)TCP_MAXWIN << tp->rcv_scale) -
+                long adv = MIN(win, (long)TCP_MAXWIN << tp->rcv_scale) -
                        (tp->rcv_adv - tp->rcv_nxt);
 
                if (adv >= (long) (2 * tp->t_maxseg))
@@ -446,16 +449,45 @@ 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 *);
+
+       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);
+           ip = mtod(m, struct ip *);
+
+           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;
+
+           ip->ip_ttl = IPDEFTTL;
+           ip->ip_tos = so->so_iptos;
+           error = ip_output(so, m);
+           break;
+
+       case AF_INET6:
+           m->m_data += sizeof(struct tcpiphdr) - sizeof(struct tcphdr)
+                                                - sizeof(struct ip6);
+           m->m_len  -= sizeof(struct tcpiphdr) - sizeof(struct tcphdr)
+                                                - sizeof(struct ip6);
+           ip6 = mtod(m, struct ip6 *);
+
+           ip6->ip_pl = tcpiph_save.ti_len;
+           ip6->ip_dst = tcpiph_save.ti_dst6;
+           ip6->ip_src = tcpiph_save.ti_src6;
+           ip6->ip_nh = tcpiph_save.ti_nh6;
+
+           error = ip6_output(so, m, 0);
+           break;
+
+       default:
+           g_assert_not_reached();
+       }
 
-    {
-
-       ((struct ip *)ti)->ip_len = m->m_len;
-
-       ((struct ip *)ti)->ip_ttl = IPDEFTTL;
-       ((struct ip *)ti)->ip_tos = so->so_iptos;
-
-       error = ip_output(so, m);
-    }
        if (error) {
 out:
                return (error);
This page took 0.037827 seconds and 4 git commands to generate.