[OSKITTCP]
[reactos.git] / reactos / lib / drivers / oskittcp / oskittcp / tcp_input.c
index f796f8a..ed2759a 100644 (file)
@@ -486,7 +486,7 @@ findpcb:
         * else do it below (after getting remote address).
         */
        if (tp->t_state != TCPS_LISTEN)
-               tcp_dooptions(tp, optp, optlen, ti, &to);
+               tcp_dooptions(tp, (u_char *)optp, optlen, ti, &to);
 
        /*
         * Header prediction: check for the two common cases
@@ -687,7 +687,7 @@ findpcb:
                        taop = &tao_noncached;
                        bzero(taop, sizeof(*taop));
                }
-               tcp_dooptions(tp, optp, optlen, ti, &to);
+               tcp_dooptions(tp, (u_char *)optp, optlen, ti, &to);
                if (iss)
                        tp->iss = iss;
                else
@@ -1974,7 +1974,7 @@ tcp_mss(tp, offer)
        int offer;
 {
        register struct rtentry *rt;
-       struct ifnet *ifp;
+       struct ifnet *ifp = NULL;
        register int rtt, mss;
        u_long bufsize;
        struct inpcb *inp;
@@ -1984,7 +1984,14 @@ tcp_mss(tp, offer)
 
        inp = tp->t_inpcb;
        if ((rt = tcp_rtlookup(inp)) == NULL) {
+#ifndef __REACTOS__
                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__
@@ -2139,15 +2146,20 @@ int
 tcp_mssopt(tp)
        struct tcpcb *tp;
 {
+#ifndef __REACTOS__
        struct rtentry *rt;
 
        rt = tcp_rtlookup(tp->t_inpcb);
        if (rt == NULL)
                return tcp_mssdflt;
-#ifndef __REACTOS__
+
        return rt->rt_ifp->if_mtu - sizeof(struct tcpiphdr);
 #else
-       return tcp_mssdflt;
+       struct ifaddr *ifa = ifa_ifwithnet((struct sockaddr *)&tp->t_inpcb->inp_faddr);
+       if (ifa == NULL)
+               return tcp_mssdflt;
+
+       return ifa->ifa_mtu - sizeof(struct tcpiphdr);
 #endif
 }
 #endif /* TUBA_INCLUDE */