remove /usr/include dependencies
[unix-history] / usr / src / sys / netinet / tcp_subr.c
index 0995957..952dd41 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_subr.c      4.36    82/12/14        */
+/*     tcp_subr.c      4.40    83/02/10        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -6,11 +6,14 @@
 #include "../h/socket.h"
 #include "../h/socketvar.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
 #include "../h/socketvar.h"
 #include "../h/protosw.h"
-#include "../netinet/in.h"
+#include "../h/errno.h"
+
 #include "../net/route.h"
 #include "../net/route.h"
+#include "../net/if.h"
+
+#include "../netinet/in.h"
 #include "../netinet/in_pcb.h"
 #include "../netinet/in_systm.h"
 #include "../netinet/in_pcb.h"
 #include "../netinet/in_systm.h"
-#include "../net/if.h"
 #include "../netinet/ip.h"
 #include "../netinet/ip_var.h"
 #include "../netinet/ip_icmp.h"
 #include "../netinet/ip.h"
 #include "../netinet/ip_var.h"
 #include "../netinet/ip_icmp.h"
@@ -20,7 +23,6 @@
 #include "../netinet/tcp_timer.h"
 #include "../netinet/tcp_var.h"
 #include "../netinet/tcpip.h"
 #include "../netinet/tcp_timer.h"
 #include "../netinet/tcp_var.h"
 #include "../netinet/tcpip.h"
-#include <errno.h>
 
 /*
  * Tcp initialization
 
 /*
  * Tcp initialization
@@ -49,7 +51,7 @@ tcp_template(tp)
        register struct tcpiphdr *n;
 
        m = m_get(M_WAIT, MT_HEADER);
        register struct tcpiphdr *n;
 
        m = m_get(M_WAIT, MT_HEADER);
-       if (m == 0)
+       if (m == NULL)
                return (0);
        m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
        m->m_len = sizeof (struct tcpiphdr);
                return (0);
        m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
        m->m_len = sizeof (struct tcpiphdr);
@@ -102,7 +104,7 @@ tcp_respond(tp, ti, ack, seq, flags)
        }
        if (flags == 0) {
                m = m_get(M_DONTWAIT, MT_HEADER);
        }
        if (flags == 0) {
                m = m_get(M_DONTWAIT, MT_HEADER);
-               if (m == 0)
+               if (m == NULL)
                        return;
                m->m_len = sizeof (struct tcpiphdr) + 1;
                *mtod(m, struct tcpiphdr *) = *ti;
                        return;
                m->m_len = sizeof (struct tcpiphdr) + 1;
                *mtod(m, struct tcpiphdr *) = *ti;
@@ -149,11 +151,18 @@ tcp_newtcpcb(inp)
        struct mbuf *m = m_getclr(M_DONTWAIT, MT_PCB);
        register struct tcpcb *tp;
 
        struct mbuf *m = m_getclr(M_DONTWAIT, MT_PCB);
        register struct tcpcb *tp;
 
-       if (m == 0)
-               return (0);
+       if (m == NULL)
+               return ((struct tcpcb *)0);
        tp = mtod(m, struct tcpcb *);
        tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
        tp = mtod(m, struct tcpcb *);
        tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
-       tp->t_maxseg = 576;             /* satisfy the rest of the world */
+       /*
+        * If the default maximum IP packet size is 576 bytes
+        * and a standard IP header is 20 bytes, with a TCP
+        * header of 20 bytes plus the options necessary to
+        * upgrade it to something higher, then initialize the
+        * maximum segment size to 576 - (20 + 20 + 8 + slop).
+        */
+       tp->t_maxseg = 512;             /* satisfy the rest of the world */
        tp->t_flags = 0;                /* sends options! */
        tp->t_inpcb = inp;
        inp->inp_ppcb = (caddr_t)tp;
        tp->t_flags = 0;                /* sends options! */
        tp->t_inpcb = inp;
        inp->inp_ppcb = (caddr_t)tp;
@@ -165,8 +174,9 @@ tcp_newtcpcb(inp)
  * the specified error.  If connection is synchronized,
  * then send a RST to peer.
  */
  * the specified error.  If connection is synchronized,
  * then send a RST to peer.
  */
+struct tcpcb *
 tcp_drop(tp, errno)
 tcp_drop(tp, errno)
-       struct tcpcb *tp;
+       register struct tcpcb *tp;
        int errno;
 {
        struct socket *so = tp->t_inpcb->inp_socket;
        int errno;
 {
        struct socket *so = tp->t_inpcb->inp_socket;
@@ -176,14 +186,14 @@ tcp_drop(tp, errno)
                (void) tcp_output(tp);
        }
        so->so_error = errno;
                (void) tcp_output(tp);
        }
        so->so_error = errno;
-       tcp_close(tp);
+       return (tcp_close(tp));
 }
 
 tcp_abort(inp)
        struct inpcb *inp;
 {
 
 }
 
 tcp_abort(inp)
        struct inpcb *inp;
 {
 
-       tcp_close((struct tcpcb *)inp->inp_ppcb);
+       (void) tcp_close((struct tcpcb *)inp->inp_ppcb);
 }
 
 /*
 }
 
 /*
@@ -192,6 +202,7 @@ tcp_abort(inp)
  *     discard internet protocol block
  *     wake up any sleepers
  */
  *     discard internet protocol block
  *     wake up any sleepers
  */
+struct tcpcb *
 tcp_close(tp)
        register struct tcpcb *tp;
 {
 tcp_close(tp)
        register struct tcpcb *tp;
 {
@@ -212,6 +223,7 @@ tcp_close(tp)
        inp->inp_ppcb = 0;
        soisdisconnected(so);
        in_pcbdetach(inp);
        inp->inp_ppcb = 0;
        soisdisconnected(so);
        in_pcbdetach(inp);
+       return ((struct tcpcb *)0);
 }
 
 tcp_drain()
 }
 
 tcp_drain()