clean some stuff up and purge some crud
[unix-history] / usr / src / sys / netinet / tcp_subr.c
index f3b7542..ed9e379 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_subr.c      4.34    82/10/30        */
+/*     tcp_subr.c      4.38    83/01/04        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -48,8 +48,8 @@ tcp_template(tp)
        register struct mbuf *m;
        register struct tcpiphdr *n;
 
        register struct mbuf *m;
        register struct tcpiphdr *n;
 
-       m = m_get(M_WAIT);
-       if (m == 0)
+       m = m_get(M_WAIT, MT_HEADER);
+       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);
@@ -101,8 +101,8 @@ tcp_respond(tp, ti, ack, seq, flags)
                ro = &tp->t_inpcb->inp_route;
        }
        if (flags == 0) {
                ro = &tp->t_inpcb->inp_route;
        }
        if (flags == 0) {
-               m = m_get(M_DONTWAIT);
-               if (m == 0)
+               m = m_get(M_DONTWAIT, MT_HEADER);
+               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;
@@ -123,13 +123,13 @@ tcp_respond(tp, ti, ack, seq, flags)
        }
        ti->ti_next = ti->ti_prev = 0;
        ti->ti_x1 = 0;
        }
        ti->ti_next = ti->ti_prev = 0;
        ti->ti_x1 = 0;
-       ti->ti_len = htons(sizeof (struct tcphdr) + tlen);
+       ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
        ti->ti_seq = htonl(seq);
        ti->ti_ack = htonl(ack);
        ti->ti_x2 = 0;
        ti->ti_off = sizeof (struct tcphdr) >> 2;
        ti->ti_flags = flags;
        ti->ti_seq = htonl(seq);
        ti->ti_ack = htonl(ack);
        ti->ti_x2 = 0;
        ti->ti_off = sizeof (struct tcphdr) >> 2;
        ti->ti_flags = flags;
-       ti->ti_win = htons(win);
+       ti->ti_win = htons((u_short)win);
        ti->ti_urp = 0;
        ti->ti_sum = in_cksum(m, sizeof (struct tcpiphdr) + tlen);
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + tlen;
        ti->ti_urp = 0;
        ti->ti_sum = in_cksum(m, sizeof (struct tcpiphdr) + tlen);
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + tlen;
@@ -146,14 +146,21 @@ struct tcpcb *
 tcp_newtcpcb(inp)
        struct inpcb *inp;
 {
 tcp_newtcpcb(inp)
        struct inpcb *inp;
 {
-       struct mbuf *m = m_getclr(M_DONTWAIT);
+       struct mbuf *m = m_getclr(M_DONTWAIT, MT_PCB);
        register struct tcpcb *tp;
 
        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;