[OSKITTCP]
authorCameron Gutman <aicommander@gmail.com>
Fri, 27 Aug 2010 04:46:04 +0000 (04:46 +0000)
committerCameron Gutman <aicommander@gmail.com>
Fri, 27 Aug 2010 04:46:04 +0000 (04:46 +0000)
- Only tell the caller how much we sent/received if it completed successfully
- Set SO_DONTROUTE on accepted sockets too
- Disable the core routing code
- Make our MSS calculation much better by sharing the existing code

svn path=/trunk/; revision=48628

reactos/lib/drivers/oskittcp/oskittcp/interface.c
reactos/lib/drivers/oskittcp/oskittcp/route.c
reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c

index db0b3a8..1959e67 100644 (file)
@@ -114,6 +114,12 @@ void OskitDumpBuffer( OSK_PCHAR Data, OSK_UINT Len )
                DbgPrint ( line );
 }
 
+void InitializeSocketFlags(struct socket *so)
+{
+    so->so_state |= SS_NBIO;
+    so->so_options |= SO_DONTROUTE;
+}
+
 /* From uipc_syscalls.c */
 
 int OskitTCPSocket( void *context,
@@ -128,8 +134,7 @@ int OskitTCPSocket( void *context,
     int error = socreate(domain, &so, type, proto);
     if( !error ) {
        so->so_connection = context;
-       so->so_state |= SS_NBIO;
-    so->so_options |= SO_DONTROUTE;
+    InitializeSocketFlags(so);
        *aso = so;
     }
     OSKUnlock();
@@ -171,7 +176,7 @@ int OskitTCPRecv( void *connection,
                       &tcp_flags );
     OSKUnlock();
 
-    *OutLen = Len - uio.uio_resid;
+    if (error == 0) *OutLen = Len - uio.uio_resid;
 
     return error;
 }
@@ -318,7 +323,7 @@ int OskitTCPSend( void *socket, OSK_PCHAR Data, OSK_UINT Len,
     error = sosend( socket, NULL, &uio, NULL, NULL, 0 );
     OSKUnlock();
 
-    *OutLen = Len - uio.uio_resid;
+    if (error == 0) *OutLen = Len - uio.uio_resid;
 
     return error;
 }
@@ -400,7 +405,8 @@ int OskitTCPAccept( void *socket,
         if (error)
             goto out;
 
-       so->so_state |= SS_NBIO | SS_ISCONNECTED;
+        InitializeSocketFlags(so);
+        so->so_state |= SS_ISCONNECTED;
         so->so_q = so->so_q0 = NULL;
         so->so_qlen = so->so_q0len = 0;
         so->so_head = 0;
index 8ba57da..59311a4 100644 (file)
@@ -106,6 +106,7 @@ rtalloc1(dst, report, ignflags)
        int report;
        u_long ignflags;
 {
+#ifndef __REACTOS__
        register struct radix_node_head *rnh = rt_tables[dst->sa_family];
        register struct rtentry *rt;
        register struct radix_node *rn;
@@ -142,6 +143,9 @@ rtalloc1(dst, report, ignflags)
        }
        splx(s);
        return (newrt);
+#else
+    return NULL;
+#endif
 }
 
 void
index ed2759a..39116ab 100644 (file)
@@ -1973,31 +1973,26 @@ tcp_mss(tp, offer)
        struct tcpcb *tp;
        int offer;
 {
+#ifndef __REACTOS__
        register struct rtentry *rt;
        struct ifnet *ifp = NULL;
-       register int rtt, mss;
+    struct rmxp_tao *taop;
+    register int rtt;
+#endif
+       register int mss;
        u_long bufsize;
        struct inpcb *inp;
        struct socket *so;
-       struct rmxp_tao *taop;
        int origoffer = offer;
 
        inp = tp->t_inpcb;
-       if ((rt = tcp_rtlookup(inp)) == NULL) {
+    so = inp->inp_socket;
 #ifndef __REACTOS__
+       if ((rt = tcp_rtlookup(inp)) == NULL) {
                tp->t_maxopd = tp->t_maxseg = tcp_mssdflt;
-#else
-               if (offer < tcp_mssdflt)
-                       tp->t_maxopd = tp->t_maxseg = tcp_mssdflt;
-               else
-                       tp->t_maxopd = tp->t_maxseg = min(offer, tcp_mssopt(tp));
-#endif
                return;
        }
-#ifndef __REACTOS__
        ifp = rt->rt_ifp;
-#endif
-       so = inp->inp_socket;
 
        taop = rmx_taop(rt->rt_rmx);
        /*
@@ -2006,6 +2001,7 @@ tcp_mss(tp, offer)
         */
        if (offer == -1)
                offer = taop->tao_mssopt;
+#endif
        /*
         * Offer == 0 means that there was no MSS on the SYN segment,
         * in this case we use tcp_mssdflt.
@@ -2020,6 +2016,7 @@ tcp_mss(tp, offer)
                 * funny things may happen in tcp_output.
                 */
                offer = max(offer, 64);
+#ifndef __REACTOS__
        taop->tao_mssopt = offer;
 
        /*
@@ -2060,6 +2057,10 @@ tcp_mss(tp, offer)
                if (!in_localaddr(inp->inp_faddr))
                        mss = min(mss, tcp_mssdflt);
        }
+#else
+    mss = tcp_mssopt(tp);
+    mss = min(mss, tcp_mssdflt);
+#endif
        mss = min(mss, offer);
        /*
         * maxopd stores the maximum length of data AND options
@@ -2097,7 +2098,7 @@ tcp_mss(tp, offer)
         * number of mss units; if the mss is larger than
         * the socket buffer, decrease the mss.
         */
-#ifdef RTV_SPIPE
+#if defined(RTV_SPIPE) && !defined(__REACTOS__)
        if ((bufsize = rt->rt_rmx.rmx_sendpipe) == 0)
 #endif
                bufsize = so->so_snd.sb_hiwat;
@@ -2111,7 +2112,7 @@ tcp_mss(tp, offer)
        }
        tp->t_maxseg = mss;
 
-#ifdef RTV_RPIPE
+#if defined(RTV_RPIPE) && !defined(__REACTOS__)
        if ((bufsize = rt->rt_rmx.rmx_recvpipe) == 0)
 #endif
                bufsize = so->so_rcv.sb_hiwat;
@@ -2121,12 +2122,15 @@ tcp_mss(tp, offer)
                        bufsize = sb_max;
                (void)sbreserve(&so->so_rcv, bufsize);
        }
+#ifndef __REACTOS__
        /*
         * Don't force slow-start on local network.
         */
        if (!in_localaddr(inp->inp_faddr))
+#endif
                tp->snd_cwnd = mss;
 
+#ifndef __REACTOS__
        if (rt->rt_rmx.rmx_ssthresh) {
                /*
                 * There's some sort of gateway or interface
@@ -2137,6 +2141,7 @@ tcp_mss(tp, offer)
                tp->snd_ssthresh = max(2 * mss, rt->rt_rmx.rmx_ssthresh);
                tcpstat.tcps_usedssthresh++;
        }
+#endif
 }
 
 /*