localize header files
[unix-history] / usr / src / sys / netinet / tcp_output.c
index 29bd18d..b166b98 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_output.c    4.41    82/06/12        */
+/*     tcp_output.c    4.46    82/10/09        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -6,34 +6,28 @@
 #include "../h/protosw.h"
 #include "../h/socket.h"
 #include "../h/socketvar.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
 #include "../h/socketvar.h"
-#include "../net/in.h"
+#include "../netinet/in.h"
 #include "../net/route.h"
 #include "../net/route.h"
-#include "../net/in_pcb.h"
-#include "../net/in_systm.h"
-#include "../net/ip.h"
-#include "../net/ip_var.h"
-#include "../net/tcp.h"
+#include "../netinet/in_pcb.h"
+#include "../netinet/in_systm.h"
+#include "../netinet/ip.h"
+#include "../netinet/ip_var.h"
+#include "../netinet/tcp.h"
 #define        TCPOUTFLAGS
 #define        TCPOUTFLAGS
-#include "../net/tcp_fsm.h"
-#include "../net/tcp_seq.h"
-#include "../net/tcp_timer.h"
-#include "../net/tcp_var.h"
-#include "../net/tcpip.h"
-#include "../net/tcp_debug.h"
+#include "../netinet/tcp_fsm.h"
+#include "../netinet/tcp_seq.h"
+#include "../netinet/tcp_timer.h"
+#include "../netinet/tcp_var.h"
+#include "../netinet/tcpip.h"
+#include "../netinet/tcp_debug.h"
 #include <errno.h>
 
 char *tcpstates[]; /* XXX */
 
 /*
 #include <errno.h>
 
 char *tcpstates[]; /* XXX */
 
 /*
- * Initial options: indicate max segment length 1/2 of space
- * allocated for receive; if TCPTRUEOOB is defined, indicate
- * willingness to do true out-of-band.
+ * Initial options.
  */
  */
-#ifndef TCPTRUEOOB
 u_char tcp_initopt[4] = { TCPOPT_MAXSEG, 4, 0x0, 0x0, };
 u_char tcp_initopt[4] = { TCPOPT_MAXSEG, 4, 0x0, 0x0, };
-#else
-u_char tcp_initopt[6] = { TCPOPT_MAXSEG, 4, 0x0, 0x0, TCPOPT_WILLOOB, 2 };
-#endif
 
 /*
  * Tcp output routine: figure out what should be sent and send it.
 
 /*
  * Tcp output routine: figure out what should be sent and send it.
@@ -51,7 +45,6 @@ tcp_output(tp)
        unsigned optlen = 0;
        int sendalot;
 
        unsigned optlen = 0;
        int sendalot;
 
-COUNT(TCP_OUTPUT);
 
        /*
         * Determine length of data that should be transmitted,
 
        /*
         * Determine length of data that should be transmitted,
@@ -98,13 +91,6 @@ again:
        if (tp->t_flags&TF_ACKNOW)
                goto send;
 
        if (tp->t_flags&TF_ACKNOW)
                goto send;
 
-#ifdef TCPTRUEOOB
-       /*
-        * Send if an out of band data or ack should be transmitted.
-        */
-       if (tp->t_oobflags&(TCPOOB_OWEACK|TCPOOB_NEEDACK)))
-               goto send;
-#endif
 
        /*
         * Calculate available window in i, and also amount
 
        /*
         * Calculate available window in i, and also amount
@@ -189,7 +175,7 @@ send:
                        goto noopt;
                opt = tcp_initopt;
                optlen = sizeof (tcp_initopt);
                        goto noopt;
                opt = tcp_initopt;
                optlen = sizeof (tcp_initopt);
-               *(u_short *)(opt + 2) = so->so_rcv.sb_hiwat / 2;
+               *(u_short *)(opt + 2) = MIN(so->so_rcv.sb_hiwat / 2, 1024);
 #if vax
                *(u_short *)(opt + 2) = htons(*(u_short *)(opt + 2));
 #endif
 #if vax
                *(u_short *)(opt + 2) = htons(*(u_short *)(opt + 2));
 #endif
@@ -199,12 +185,7 @@ send:
                opt = mtod(tp->t_tcpopt, u_char *);
                optlen = tp->t_tcpopt->m_len;
        }
                opt = mtod(tp->t_tcpopt, u_char *);
                optlen = tp->t_tcpopt->m_len;
        }
-#ifndef TCPTRUEOOB
-       if (opt)
-#else
-       if (opt || (tp->t_oobflags&(TCPOOB_OWEACK|TCPOOB_NEEDACK)))
-#endif
-       {
+       if (opt) {
                m0 = m->m_next;
                m->m_next = m_get(M_DONTWAIT);
                if (m->m_next == 0) {
                m0 = m->m_next;
                m->m_next = m_get(M_DONTWAIT);
                if (m->m_next == 0) {
@@ -214,35 +195,9 @@ send:
                }
                m->m_next->m_next = m0;
                m0 = m->m_next;
                }
                m->m_next->m_next = m0;
                m0 = m->m_next;
-               m0->m_off = MMINOFF;
                m0->m_len = optlen;
                bcopy((caddr_t)opt, mtod(m0, caddr_t), optlen);
                opt = (u_char *)(mtod(m0, caddr_t) + optlen);
                m0->m_len = optlen;
                bcopy((caddr_t)opt, mtod(m0, caddr_t), optlen);
                opt = (u_char *)(mtod(m0, caddr_t) + optlen);
-#ifdef TCPTRUEOOB
-               if (tp->t_oobflags&TCPOOB_OWEACK) {
-printf("tp %x send OOBACK for %x\n", tp->t_iobseq);
-                       *opt++ = TCPOPT_OOBACK;
-                       *opt++ = 3;
-                       *opt++ = tp->t_iobseq;
-                       m0->m_len += 3;
-                       tp->t_oobflags &= ~TCPOOB_OWEACK;
-                       /* sender should rexmt oob to force ack repeat */
-               }
-               if (tp->t_oobflags&TCPOOB_NEEDACK) {
-printf("tp %x send OOBDATA seq %x data %x\n", tp->t_oobseq, tp->t_oobc);
-                       *opt++ = TCPOPT_OOBDATA;
-                       *opt++ = 8;
-                       *opt++ = tp->t_oobseq;
-                       *opt++ = tp->t_oobc;
-                       *(tcp_seq *)opt = tp->t_oobmark - tp->snd_nxt;
-#ifdef vax
-                       *(tcp_seq *)opt = htonl((unsigned)*(tcp_seq *)opt);
-#endif
-                       m0->m_len += 8;
-                       TCPT_RANGESET(tp->t_timer[TCPT_OOBREXMT],
-                           tcp_beta * tp->t_srtt, TCPTV_MIN, TCPTV_MAX);
-               }
-#endif
                while (m0->m_len & 0x3) {
                        *opt++ = TCPOPT_EOL;
                        m0->m_len++;
                while (m0->m_len & 0x3) {
                        *opt++ = TCPOPT_EOL;
                        m0->m_len++;
@@ -275,7 +230,13 @@ noopt:
                 * number wraparound.
                 */
                tp->snd_up = tp->snd_una;               /* drag it along */
                 * number wraparound.
                 */
                tp->snd_up = tp->snd_una;               /* drag it along */
-       /* PUSH */
+       /*
+        * If anything to send and we can send it all, set PUSH.
+        * (This will keep happy those implementations which only
+        * give data to the user when a buffer fills or a PUSH comes in.
+        */
+       if (len && off+len == so->so_snd.sb_cc)
+               ti->ti_flags |= TH_PUSH;
 
        /*
         * Put TCP length in extended header, and then
 
        /*
         * Put TCP length in extended header, and then