BSD 4_4_Lite2 release
[unix-history] / usr / src / sys / netns / spp_usrreq.c
index 5eec70a..7ce6723 100644 (file)
@@ -1,41 +1,61 @@
 /*
 /*
- * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1984, 1985, 1986, 1987, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *      @(#)spp_usrreq.c       7.5 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)spp_usrreq.c        8.2 (Berkeley) 1/9/95
  */
 
  */
 
-#include "param.h"
-#include "systm.h"
-#include "dir.h"
-#include "user.h"
-#include "mbuf.h"
-#include "protosw.h"
-#include "socket.h"
-#include "socketvar.h"
-#include "errno.h"
-
-#include "../net/if.h"
-#include "../net/route.h"
-#include "../netinet/tcp_fsm.h"
-#include "../netinet/tcp_timer.h"
-
-#include "ns.h"
-#include "ns_pcb.h"
-#include "idp.h"
-#include "idp_var.h"
-#include "ns_error.h"
-#include "sp.h"
-#include "spidp.h"
-#include "spp_var.h"
-#include "spp_debug.h"
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/protosw.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/errno.h>
+
+#include <net/if.h>
+#include <net/route.h>
+#include <netinet/tcp_fsm.h>
+
+#include <netns/ns.h>
+#include <netns/ns_pcb.h>
+#include <netns/idp.h>
+#include <netns/idp_var.h>
+#include <netns/ns_error.h>
+#include <netns/sp.h>
+#include <netns/spidp.h>
+#include <netns/spp_timer.h>
+#include <netns/spp_var.h>
+#include <netns/spp_debug.h>
 
 /*
  * SP protocol implementation.
 
 /*
  * SP protocol implementation.
@@ -50,12 +70,12 @@ int traceallspps = 0;
 extern int sppconsdebug;
 int spp_hardnosed;
 int spp_use_delack = 0;
 extern int sppconsdebug;
 int spp_hardnosed;
 int spp_use_delack = 0;
+u_short spp_newchecks[50];
 
 /*ARGSUSED*/
 
 /*ARGSUSED*/
-spp_input(m, nsp, ifp)
+spp_input(m, nsp)
        register struct mbuf *m;
        register struct nspcb *nsp;
        register struct mbuf *m;
        register struct nspcb *nsp;
-       struct ifnet *ifp;
 {
        register struct sppcb *cb;
        register struct spidp *si = mtod(m, struct spidp *);
 {
        register struct sppcb *cb;
        register struct spidp *si = mtod(m, struct spidp *);
@@ -91,8 +111,8 @@ spp_input(m, nsp, ifp)
        }
        if (so->so_options & SO_ACCEPTCONN) {
                struct sppcb *ocb = cb;
        }
        if (so->so_options & SO_ACCEPTCONN) {
                struct sppcb *ocb = cb;
-               struct socket *oso = so;
-               so = sonewconn(so);
+
+               so = sonewconn(so, 0);
                if (so == 0) {
                        goto drop;
                }
                if (so == 0) {
                        goto drop;
                }
@@ -113,10 +133,7 @@ spp_input(m, nsp, ifp)
                cb = nstosppcb(nsp);
                cb->s_mtu = ocb->s_mtu;         /* preserve sockopts */
                cb->s_flags = ocb->s_flags;     /* preserve sockopts */
                cb = nstosppcb(nsp);
                cb->s_mtu = ocb->s_mtu;         /* preserve sockopts */
                cb->s_flags = ocb->s_flags;     /* preserve sockopts */
-               if (so->so_snd.sb_hiwat != oso->so_snd.sb_hiwat) /*XXX*/
-                       sbreserve(&so->so_snd, oso->so_snd.sb_hiwat);
-               if (so->so_rcv.sb_hiwat != oso->so_rcv.sb_hiwat) /*XXX*/
-                       sbreserve(&so->so_rcv, oso->so_rcv.sb_hiwat);
+               cb->s_flags2 = ocb->s_flags2;   /* preserve sockopts */
                cb->s_state = TCPS_LISTEN;
        }
 
                cb->s_state = TCPS_LISTEN;
        }
 
@@ -125,7 +142,7 @@ spp_input(m, nsp, ifp)
         * reset idle time and keep-alive timer;
         */
        cb->s_idle = 0;
         * reset idle time and keep-alive timer;
         */
        cb->s_idle = 0;
-       cb->s_timer[TCPT_KEEP] = TCPTV_KEEP;
+       cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
 
        switch (cb->s_state) {
 
 
        switch (cb->s_state) {
 
@@ -148,6 +165,7 @@ spp_input(m, nsp, ifp)
                        goto drop;
                am->m_len = sizeof (struct sockaddr_ns);
                sns = mtod(am, struct sockaddr_ns *);
                        goto drop;
                am->m_len = sizeof (struct sockaddr_ns);
                sns = mtod(am, struct sockaddr_ns *);
+               sns->sns_len = sizeof(*sns);
                sns->sns_family = AF_NS;
                sns->sns_addr = si->si_sna;
                laddr = nsp->nsp_laddr;
                sns->sns_family = AF_NS;
                sns->sns_addr = si->si_sna;
                laddr = nsp->nsp_laddr;
@@ -168,9 +186,9 @@ spp_input(m, nsp, ifp)
 #define THREEWAYSHAKE
 #ifdef THREEWAYSHAKE
                cb->s_state = TCPS_SYN_RECEIVED;
 #define THREEWAYSHAKE
 #ifdef THREEWAYSHAKE
                cb->s_state = TCPS_SYN_RECEIVED;
-               cb->s_force = 1 + TCPT_KEEP;
+               cb->s_force = 1 + SPPT_KEEP;
                sppstat.spps_accepts++;
                sppstat.spps_accepts++;
-               cb->s_timer[TCPT_KEEP] = TCPTV_KEEP;
+               cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
                }
                break;
        /*
                }
                break;
        /*
@@ -186,8 +204,8 @@ spp_input(m, nsp, ifp)
                }
 #endif
                nsp->nsp_fport =  si->si_sport;
                }
 #endif
                nsp->nsp_fport =  si->si_sport;
-               cb->s_timer[TCPT_REXMT] = 0;
-               cb->s_timer[TCPT_KEEP] = TCPTV_KEEP;
+               cb->s_timer[SPPT_REXMT] = 0;
+               cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
                soisconnected(so);
                cb->s_state = TCPS_ESTABLISHED;
                sppstat.spps_accepts++;
                soisconnected(so);
                cb->s_state = TCPS_ESTABLISHED;
                sppstat.spps_accepts++;
@@ -213,7 +231,7 @@ spp_input(m, nsp, ifp)
                cb->s_rack = si->si_ack;
                cb->s_ralo = si->si_alo;
                cb->s_dport = nsp->nsp_fport =  si->si_sport;
                cb->s_rack = si->si_ack;
                cb->s_ralo = si->si_alo;
                cb->s_dport = nsp->nsp_fport =  si->si_sport;
-               cb->s_timer[TCPT_REXMT] = 0;
+               cb->s_timer[SPPT_REXMT] = 0;
                cb->s_flags |= SF_ACKNOW;
                soisconnected(so);
                cb->s_state = TCPS_ESTABLISHED;
                cb->s_flags |= SF_ACKNOW;
                soisconnected(so);
                cb->s_state = TCPS_ESTABLISHED;
@@ -221,9 +239,9 @@ spp_input(m, nsp, ifp)
                if (cb->s_rtt) {
                        cb->s_srtt = cb->s_rtt << 3;
                        cb->s_rttvar = cb->s_rtt << 1;
                if (cb->s_rtt) {
                        cb->s_srtt = cb->s_rtt << 3;
                        cb->s_rttvar = cb->s_rtt << 1;
-                       TCPT_RANGESET(cb->s_rxtcur,
+                       SPPT_RANGESET(cb->s_rxtcur,
                            ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
                            ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
-                           TCPTV_MIN, TCPTV_REXMTMAX);
+                           SPPTV_MIN, SPPTV_REXMTMAX);
                            cb->s_rtt = 0;
                }
        }
                            cb->s_rtt = 0;
                }
        }
@@ -231,7 +249,8 @@ spp_input(m, nsp, ifp)
                spp_trace(SA_INPUT, (u_char)ostate, cb, &spp_savesi, 0);
 
        m->m_len -= sizeof (struct idp);
                spp_trace(SA_INPUT, (u_char)ostate, cb, &spp_savesi, 0);
 
        m->m_len -= sizeof (struct idp);
-       m->m_off += sizeof (struct idp);
+       m->m_pkthdr.len -= sizeof (struct idp);
+       m->m_data += sizeof (struct idp);
 
        if (spp_reass(cb, si)) {
                (void) m_freem(m);
 
        if (spp_reass(cb, si)) {
                (void) m_freem(m);
@@ -305,9 +324,9 @@ register struct spidp *si;
 
                                cb->s_snxt = si->si_ack;
                                cb->s_cwnd = CUNIT;
 
                                cb->s_snxt = si->si_ack;
                                cb->s_cwnd = CUNIT;
-                               cb->s_force = 1 + TCPT_REXMT;
+                               cb->s_force = 1 + SPPT_REXMT;
                                (void) spp_output(cb, (struct mbuf *)0);
                                (void) spp_output(cb, (struct mbuf *)0);
-                               cb->s_timer[TCPT_REXMT] = cb->s_rxtcur;
+                               cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
                                cb->s_rtt = 0;
                                if (cwnd >= 4 * CUNIT)
                                        cb->s_cwnd = cwnd / 2;
                                cb->s_rtt = 0;
                                if (cwnd >= 4 * CUNIT)
                                        cb->s_cwnd = cwnd / 2;
@@ -356,9 +375,9 @@ register struct spidp *si;
                }
                cb->s_rtt = 0;
                cb->s_rxtshift = 0;
                }
                cb->s_rtt = 0;
                cb->s_rxtshift = 0;
-               TCPT_RANGESET(cb->s_rxtcur,
+               SPPT_RANGESET(cb->s_rxtcur,
                        ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
                        ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
-                       TCPTV_MIN, TCPTV_REXMTMAX);
+                       SPPTV_MIN, SPPTV_REXMTMAX);
        }
        /*
         * If all outstanding data is acked, stop retransmit
        }
        /*
         * If all outstanding data is acked, stop retransmit
@@ -367,10 +386,10 @@ register struct spidp *si;
         * timer, using current (possibly backed-off) value;
         */
        if (si->si_ack == cb->s_smax + 1) {
         * timer, using current (possibly backed-off) value;
         */
        if (si->si_ack == cb->s_smax + 1) {
-               cb->s_timer[TCPT_REXMT] = 0;
+               cb->s_timer[SPPT_REXMT] = 0;
                cb->s_flags |= SF_RXT;
                cb->s_flags |= SF_RXT;
-       } else if (cb->s_timer[TCPT_PERSIST] == 0)
-               cb->s_timer[TCPT_REXMT] = cb->s_rxtcur;
+       } else if (cb->s_timer[SPPT_PERSIST] == 0)
+               cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
        /*
         * When new data is acked, open the congestion window.
         * If the window gives us less than ssthresh packets
        /*
         * When new data is acked, open the congestion window.
         * If the window gives us less than ssthresh packets
@@ -379,8 +398,8 @@ register struct spidp *si;
         */
        incr = CUNIT;
        if (cb->s_cwnd > cb->s_ssthresh)
         */
        incr = CUNIT;
        if (cb->s_cwnd > cb->s_ssthresh)
-               incr = MAX(incr * incr / cb->s_cwnd, 1);
-       cb->s_cwnd = MIN(cb->s_cwnd + incr, cb->s_cwmx);
+               incr = max(incr * incr / cb->s_cwnd, 1);
+       cb->s_cwnd = min(cb->s_cwnd + incr, cb->s_cwmx);
        /*
         * Trim Acked data from output queue.
         */
        /*
         * Trim Acked data from output queue.
         */
@@ -390,8 +409,7 @@ register struct spidp *si;
                else
                        break;
        }
                else
                        break;
        }
-       if ((so->so_snd.sb_flags & SB_WAIT) || so->so_snd.sb_sel)
-                sowwakeup(so);
+       sowwakeup(so);
        cb->s_rack = si->si_ack;
 update_window:
        if (SSEQ_LT(cb->s_snxt, cb->s_rack))
        cb->s_rack = si->si_ack;
 update_window:
        if (SSEQ_LT(cb->s_snxt, cb->s_rack))
@@ -502,12 +520,51 @@ present:
                        remque(q->si_next);
                        wakeup = 1;
                        sppstat.spps_rcvpack++;
                        remque(q->si_next);
                        wakeup = 1;
                        sppstat.spps_rcvpack++;
+#ifdef SF_NEWCALL
+                       if (cb->s_flags2 & SF_NEWCALL) {
+                               struct sphdr *sp = mtod(m, struct sphdr *);
+                               u_char dt = sp->sp_dt;
+                               spp_newchecks[4]++;
+                               if (dt != cb->s_rhdr.sp_dt) {
+                                       struct mbuf *mm =
+                                          m_getclr(M_DONTWAIT, MT_CONTROL);
+                                       spp_newchecks[0]++;
+                                       if (mm != NULL) {
+                                               u_short *s =
+                                                       mtod(mm, u_short *);
+                                               cb->s_rhdr.sp_dt = dt;
+                                               mm->m_len = 5; /*XXX*/
+                                               s[0] = 5;
+                                               s[1] = 1;
+                                               *(u_char *)(&s[2]) = dt;
+                                               sbappend(&so->so_rcv, mm);
+                                       }
+                               }
+                               if (sp->sp_cc & SP_OB) {
+                                       MCHTYPE(m, MT_OOBDATA);
+                                       spp_newchecks[1]++;
+                                       so->so_oobmark = 0;
+                                       so->so_state &= ~SS_RCVATMARK;
+                               }
+                               if (packetp == 0) {
+                                       m->m_data += SPINC;
+                                       m->m_len -= SPINC;
+                                       m->m_pkthdr.len -= SPINC;
+                               }
+                               if ((sp->sp_cc & SP_EM) || packetp) {
+                                       sbappendrecord(&so->so_rcv, m);
+                                       spp_newchecks[9]++;
+                               } else
+                                       sbappend(&so->so_rcv, m);
+                       } else
+#endif
                        if (packetp) {
                                sbappendrecord(&so->so_rcv, m);
                        } else {
                                cb->s_rhdr = *mtod(m, struct sphdr *);
                        if (packetp) {
                                sbappendrecord(&so->so_rcv, m);
                        } else {
                                cb->s_rhdr = *mtod(m, struct sphdr *);
-                               m->m_off += SPINC;
+                               m->m_data += SPINC;
                                m->m_len -= SPINC;
                                m->m_len -= SPINC;
+                               m->m_pkthdr.len -= SPINC;
                                sbappend(&so->so_rcv, m);
                        }
                  } else
                                sbappend(&so->so_rcv, m);
                        }
                  } else
@@ -648,9 +705,12 @@ spp_output(cb, m0)
        register struct spidp *si = (struct spidp *) 0;
        register struct sockbuf *sb = &so->so_snd;
        int len = 0, win, rcv_win;
        register struct spidp *si = (struct spidp *) 0;
        register struct sockbuf *sb = &so->so_snd;
        int len = 0, win, rcv_win;
-       short span, off;
+       short span, off, recordp = 0;
        u_short alo;
        u_short alo;
-       int error = 0, idle, sendalot;
+       int error = 0, sendalot;
+#ifdef notdef
+       int idle;
+#endif
        struct mbuf *mprev;
        extern int idpcksum;
 
        struct mbuf *mprev;
        extern int idpcksum;
 
@@ -663,6 +723,8 @@ spp_output(cb, m0)
                for (m = m0; m ; m = m->m_next) {
                        mprev = m;
                        len += m->m_len;
                for (m = m0; m ; m = m->m_next) {
                        mprev = m;
                        len += m->m_len;
+                       if (m->m_flags & M_EOR)
+                               recordp = 1;
                }
                datalen = (cb->s_flags & SF_HO) ?
                                len - sizeof (struct sphdr) : len;
                }
                datalen = (cb->s_flags & SF_HO) ?
                                len - sizeof (struct sphdr) : len;
@@ -675,14 +737,22 @@ spp_output(cb, m0)
 
                                cb->s_cc &= ~SP_EM;
                                while (len > mtu) {
 
                                cb->s_cc &= ~SP_EM;
                                while (len > mtu) {
-                                       m = m_copy(m0, 0, mtu);
-                                       if (m == NULL) {
-                                               error = ENOBUFS;
-                                               goto bad_copy;
+                                       /*
+                                        * Here we are only being called
+                                        * from usrreq(), so it is OK to
+                                        * block.
+                                        */
+                                       m = m_copym(m0, 0, mtu, M_WAIT);
+                                       if (cb->s_flags & SF_NEWCALL) {
+                                           struct mbuf *mm = m;
+                                           spp_newchecks[7]++;
+                                           while (mm) {
+                                               mm->m_flags &= ~M_EOR;
+                                               mm = mm->m_next;
+                                           }
                                        }
                                        error = spp_output(cb, m);
                                        if (error) {
                                        }
                                        error = spp_output(cb, m);
                                        if (error) {
-                                       bad_copy:
                                                cb->s_cc |= oldEM;
                                                m_freem(m0);
                                                return(error);
                                                cb->s_cc |= oldEM;
                                                m_freem(m0);
                                                return(error);
@@ -699,7 +769,7 @@ spp_output(cb, m0)
                 */
                if (len & 1) {
                        m = mprev;
                 */
                if (len & 1) {
                        m = mprev;
-                       if (m->m_len + m->m_off < MMAXOFF)
+                       if (M_TRAILINGSPACE(m) >= 1)
                                m->m_len++;
                        else {
                                struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);
                                m->m_len++;
                        else {
                                struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);
@@ -709,11 +779,11 @@ spp_output(cb, m0)
                                        return (ENOBUFS);
                                }
                                m1->m_len = 1;
                                        return (ENOBUFS);
                                }
                                m1->m_len = 1;
-                               m1->m_off = MMAXOFF - 1;
+                               *(mtod(m1, u_char *)) = 0;
                                m->m_next = m1;
                        }
                }
                                m->m_next = m1;
                        }
                }
-               m = m_get(M_DONTWAIT, MT_HEADER);
+               m = m_gethdr(M_DONTWAIT, MT_HEADER);
                if (m == 0) {
                        m_freem(m0);
                        return (ENOBUFS);
                if (m == 0) {
                        m_freem(m0);
                        return (ENOBUFS);
@@ -721,9 +791,8 @@ spp_output(cb, m0)
                /*
                 * Fill in mbuf with extended SP header
                 * and addresses and length put into network format.
                /*
                 * Fill in mbuf with extended SP header
                 * and addresses and length put into network format.
-                * Long align so prepended ip headers will work on Gould.
                 */
                 */
-               m->m_off = MMAXOFF - sizeof (struct spidp) - 2;
+               MH_ALIGN(m, sizeof (struct spidp));
                m->m_len = sizeof (struct spidp);
                m->m_next = m0;
                si = mtod(m, struct spidp *);
                m->m_len = sizeof (struct spidp);
                m->m_next = m0;
                si = mtod(m, struct spidp *);
@@ -743,10 +812,14 @@ spp_output(cb, m0)
                        si->si_dt = sh->sp_dt;
                        si->si_cc |= sh->sp_cc & SP_EM;
                        m0->m_len -= sizeof (*sh);
                        si->si_dt = sh->sp_dt;
                        si->si_cc |= sh->sp_cc & SP_EM;
                        m0->m_len -= sizeof (*sh);
-                       m0->m_off += sizeof (*sh);
+                       m0->m_data += sizeof (*sh);
                        len -= sizeof (*sh);
                }
                len += sizeof(*si);
                        len -= sizeof (*sh);
                }
                len += sizeof(*si);
+               if ((cb->s_flags2 & SF_NEWCALL) && recordp) {
+                       si->si_cc  |= SP_EM;
+                       spp_newchecks[8]++;
+               }
                if (cb->s_oobflags & SF_SOOB) {
                        /*
                         * Per jqj@cornell:
                if (cb->s_oobflags & SF_SOOB) {
                        /*
                         * Per jqj@cornell:
@@ -762,17 +835,20 @@ spp_output(cb, m0)
                        }
                }
                si->si_len = htons((u_short)len);
                        }
                }
                si->si_len = htons((u_short)len);
+               m->m_pkthdr.len = ((len - 1) | 1) + 1;
                /*
                 * queue stuff up for output
                 */
                sbappendrecord(sb, m);
                cb->s_seq++;
        }
                /*
                 * queue stuff up for output
                 */
                sbappendrecord(sb, m);
                cb->s_seq++;
        }
+#ifdef notdef
        idle = (cb->s_smax == (cb->s_rack - 1));
        idle = (cb->s_smax == (cb->s_rack - 1));
+#endif
 again:
        sendalot = 0;
        off = cb->s_snxt - cb->s_rack;
 again:
        sendalot = 0;
        off = cb->s_snxt - cb->s_rack;
-       win = MIN(cb->s_swnd, (cb->s_cwnd/CUNIT));
+       win = min(cb->s_swnd, (cb->s_cwnd/CUNIT));
 
        /*
         * If in persist timeout with window of 0, send a probe.
 
        /*
         * If in persist timeout with window of 0, send a probe.
@@ -780,14 +856,14 @@ again:
         * and timer expired, send what we can and go into
         * transmit state.
         */
         * and timer expired, send what we can and go into
         * transmit state.
         */
-       if (cb->s_force == 1 + TCPT_PERSIST) {
+       if (cb->s_force == 1 + SPPT_PERSIST) {
                if (win != 0) {
                if (win != 0) {
-                       cb->s_timer[TCPT_PERSIST] = 0;
+                       cb->s_timer[SPPT_PERSIST] = 0;
                        cb->s_rxtshift = 0;
                }
        }
        span = cb->s_seq - cb->s_rack;
                        cb->s_rxtshift = 0;
                }
        }
        span = cb->s_seq - cb->s_rack;
-       len = MIN(span, win) - off;
+       len = min(span, win) - off;
 
        if (len < 0) {
                /*
 
        if (len < 0) {
                /*
@@ -800,7 +876,7 @@ again:
                 */
                len = 0;
                if (win == 0) {
                 */
                len = 0;
                if (win == 0) {
-                       cb->s_timer[TCPT_REXMT] = 0;
+                       cb->s_timer[SPPT_REXMT] = 0;
                        cb->s_snxt = cb->s_rack;
                }
        }
                        cb->s_snxt = cb->s_rack;
                }
        }
@@ -858,8 +934,8 @@ again:
         * if window is nonzero, transmit what we can,
         * otherwise send a probe.
         */
         * if window is nonzero, transmit what we can,
         * otherwise send a probe.
         */
-       if (so->so_snd.sb_cc && cb->s_timer[TCPT_REXMT] == 0 &&
-               cb->s_timer[TCPT_PERSIST] == 0) {
+       if (so->so_snd.sb_cc && cb->s_timer[SPPT_REXMT] == 0 &&
+               cb->s_timer[SPPT_PERSIST] == 0) {
                        cb->s_rxtshift = 0;
                        spp_setpersist(cb);
        }
                        cb->s_rxtshift = 0;
                        spp_setpersist(cb);
        }
@@ -907,7 +983,6 @@ send:
                if (m == NULL) {
                        return (ENOBUFS);
                }
                if (m == NULL) {
                        return (ENOBUFS);
                }
-               m0 = m;
                si = mtod(m, struct spidp *);
                if (SSEQ_LT(si->si_seq, cb->s_smax))
                        sppstat.spps_sndrexmitpack++;
                si = mtod(m, struct spidp *);
                if (SSEQ_LT(si->si_seq, cb->s_smax))
                        sppstat.spps_sndrexmitpack++;
@@ -921,19 +996,16 @@ send:
                        sppstat.spps_sndprobe++;
                if (cb->s_flags & SF_ACKNOW)
                        sppstat.spps_sndacks++;
                        sppstat.spps_sndprobe++;
                if (cb->s_flags & SF_ACKNOW)
                        sppstat.spps_sndacks++;
-               m = m_get(M_DONTWAIT, MT_HEADER);
-               if (m == 0) {
+               m = m_gethdr(M_DONTWAIT, MT_HEADER);
+               if (m == 0)
                        return (ENOBUFS);
                        return (ENOBUFS);
-               }
                /*
                 * Fill in mbuf with extended SP header
                 * and addresses and length put into network format.
                /*
                 * Fill in mbuf with extended SP header
                 * and addresses and length put into network format.
-                * Allign beginning of packet to long to prepend
-                * ifp's on loopback, or NSIP encaspulation for fussy cpu's.
                 */
                 */
-               m->m_off = MMAXOFF - sizeof (struct spidp) - 2;
+               MH_ALIGN(m, sizeof (struct spidp));
                m->m_len = sizeof (*si);
                m->m_len = sizeof (*si);
-               m->m_next = 0;
+               m->m_pkthdr.len = sizeof (*si);
                si = mtod(m, struct spidp *);
                si->si_i = *cb->s_idp;
                si->si_s = cb->s_shdr;
                si = mtod(m, struct spidp *);
                si->si_i = *cb->s_idp;
                si->si_s = cb->s_shdr;
@@ -950,8 +1022,8 @@ send:
         * Stuff checksum and output datagram.
         */
        if ((si->si_cc & SP_SP) == 0) {
         * Stuff checksum and output datagram.
         */
        if ((si->si_cc & SP_SP) == 0) {
-               if (cb->s_force != (1 + TCPT_PERSIST) ||
-                   cb->s_timer[TCPT_PERSIST] == 0) {
+               if (cb->s_force != (1 + SPPT_PERSIST) ||
+                   cb->s_timer[SPPT_PERSIST] == 0) {
                        /*
                         * If this is a new packet and we are not currently 
                         * timing anything, time this one.
                        /*
                         * If this is a new packet and we are not currently 
                         * timing anything, time this one.
@@ -971,11 +1043,11 @@ send:
                         * Initialize shift counter which is used for backoff
                         * of retransmit time.
                         */
                         * Initialize shift counter which is used for backoff
                         * of retransmit time.
                         */
-                       if (cb->s_timer[TCPT_REXMT] == 0 &&
+                       if (cb->s_timer[SPPT_REXMT] == 0 &&
                            cb->s_snxt != cb->s_rack) {
                            cb->s_snxt != cb->s_rack) {
-                               cb->s_timer[TCPT_REXMT] = cb->s_rxtcur;
-                               if (cb->s_timer[TCPT_PERSIST]) {
-                                       cb->s_timer[TCPT_PERSIST] = 0;
+                               cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
+                               if (cb->s_timer[SPPT_PERSIST]) {
+                                       cb->s_timer[SPPT_PERSIST] = 0;
                                        cb->s_rxtshift = 0;
                                }
                        }
                                        cb->s_rxtshift = 0;
                                }
                        }
@@ -985,8 +1057,8 @@ send:
        } else if (cb->s_state < TCPS_ESTABLISHED) {
                if (cb->s_rtt == 0)
                        cb->s_rtt = 1; /* Time initial handshake */
        } else if (cb->s_state < TCPS_ESTABLISHED) {
                if (cb->s_rtt == 0)
                        cb->s_rtt = 1; /* Time initial handshake */
-               if (cb->s_timer[TCPT_REXMT] == 0)
-                       cb->s_timer[TCPT_REXMT] = cb->s_rxtcur;
+               if (cb->s_timer[SPPT_REXMT] == 0)
+                       cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
        }
        {
                /*
        }
        {
                /*
@@ -1004,7 +1076,7 @@ send:
                        len = ntohs(si->si_len);
                        if (len & 1)
                                len++;
                        len = ntohs(si->si_len);
                        if (len & 1)
                                len++;
-                       si->si_sum = ns_cksum(dtom(si), len);
+                       si->si_sum = ns_cksum(m, len);
                } else
                        si->si_sum = 0xffff;
 
                } else
                        si->si_sum = 0xffff;
 
@@ -1045,15 +1117,15 @@ spp_setpersist(cb)
        register t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
        extern int spp_backoff[];
 
        register t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
        extern int spp_backoff[];
 
-       if (cb->s_timer[TCPT_REXMT] && spp_do_persist_panics)
+       if (cb->s_timer[SPPT_REXMT] && spp_do_persist_panics)
                panic("spp_output REXMT");
        /*
         * Start/restart persistance timer.
         */
                panic("spp_output REXMT");
        /*
         * Start/restart persistance timer.
         */
-       TCPT_RANGESET(cb->s_timer[TCPT_PERSIST],
+       SPPT_RANGESET(cb->s_timer[SPPT_PERSIST],
            t*spp_backoff[cb->s_rxtshift],
            t*spp_backoff[cb->s_rxtshift],
-           TCPTV_PERSMIN, TCPTV_PERSMAX);
-       if (cb->s_rxtshift < TCP_MAXRXTSHIFT)
+           SPPTV_PERSMIN, SPPTV_PERSMAX);
+       if (cb->s_rxtshift < SPP_MAXRXTSHIFT)
                cb->s_rxtshift++;
 }
 /*ARGSUSED*/
                cb->s_rxtshift++;
 }
 /*ARGSUSED*/
@@ -1097,25 +1169,21 @@ spp_ctloutput(req, so, level, name, value)
                        mask = SF_HO;
                get_flags:
                        m->m_len = sizeof(short);
                        mask = SF_HO;
                get_flags:
                        m->m_len = sizeof(short);
-                       m->m_off = MMAXOFF - sizeof(short);
                        *mtod(m, short *) = cb->s_flags & mask;
                        break;
 
                case SO_MTU:
                        m->m_len = sizeof(u_short);
                        *mtod(m, short *) = cb->s_flags & mask;
                        break;
 
                case SO_MTU:
                        m->m_len = sizeof(u_short);
-                       m->m_off = MMAXOFF - sizeof(short);
                        *mtod(m, short *) = cb->s_mtu;
                        break;
 
                case SO_LAST_HEADER:
                        m->m_len = sizeof(struct sphdr);
                        *mtod(m, short *) = cb->s_mtu;
                        break;
 
                case SO_LAST_HEADER:
                        m->m_len = sizeof(struct sphdr);
-                       m->m_off = MMAXOFF - sizeof(struct sphdr);
                        *mtod(m, struct sphdr *) = cb->s_rhdr;
                        break;
 
                case SO_DEFAULT_HEADERS:
                        m->m_len = sizeof(struct spidp);
                        *mtod(m, struct sphdr *) = cb->s_rhdr;
                        break;
 
                case SO_DEFAULT_HEADERS:
                        m->m_len = sizeof(struct spidp);
-                       m->m_off = MMAXOFF - sizeof(struct sphdr);
                        *mtod(m, struct sphdr *) = cb->s_shdr;
                        break;
 
                        *mtod(m, struct sphdr *) = cb->s_shdr;
                        break;
 
@@ -1153,6 +1221,19 @@ spp_ctloutput(req, so, level, name, value)
                        cb->s_mtu = *(mtod(*value, u_short *));
                        break;
 
                        cb->s_mtu = *(mtod(*value, u_short *));
                        break;
 
+#ifdef SF_NEWCALL
+               case SO_NEWCALL:
+                       ok = mtod(*value, int *);
+                       if (*ok) {
+                               cb->s_flags2 |= SF_NEWCALL;
+                               spp_newchecks[5]++;
+                       } else {
+                               cb->s_flags2 &= ~SF_NEWCALL;
+                               spp_newchecks[6]++;
+                       }
+                       break;
+#endif
+
                case SO_DEFAULT_HEADERS:
                        {
                                register struct sphdr *sp
                case SO_DEFAULT_HEADERS:
                        {
                                register struct sphdr *sp
@@ -1173,10 +1254,10 @@ spp_ctloutput(req, so, level, name, value)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-spp_usrreq(so, req, m, nam, rights)
+spp_usrreq(so, req, m, nam, controlp)
        struct socket *so;
        int req;
        struct socket *so;
        int req;
-       struct mbuf *m, *nam, *rights;
+       struct mbuf *m, *nam, *controlp;
 {
        struct nspcb *nsp = sotonspcb(so);
        register struct sppcb *cb;
 {
        struct nspcb *nsp = sotonspcb(so);
        register struct sppcb *cb;
@@ -1186,12 +1267,8 @@ spp_usrreq(so, req, m, nam, rights)
        register struct sockbuf *sb;
 
        if (req == PRU_CONTROL)
        register struct sockbuf *sb;
 
        if (req == PRU_CONTROL)
-                return (ns_control(so, (int)m, (caddr_t)nam,
-                       (struct ifnet *)rights));
-       if (rights && rights->m_len) {
-               error = EINVAL;
-               goto release;
-       }
+                return (ns_control(so, m, (caddr_t)nam,
+                       (struct ifnet *)controlp));
        if (nsp == NULL) {
                if (req != PRU_ATTACH) {
                        error = EINVAL;
        if (nsp == NULL) {
                if (req != PRU_ATTACH) {
                        error = EINVAL;
@@ -1212,9 +1289,11 @@ spp_usrreq(so, req, m, nam, rights)
                error = ns_pcballoc(so, &nspcb);
                if (error)
                        break;
                error = ns_pcballoc(so, &nspcb);
                if (error)
                        break;
-               error = soreserve(so, 3072, 3072);
-               if (error)
-                       break;
+               if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
+                       error = soreserve(so, (u_long) 3072, (u_long) 3072);
+                       if (error)
+                               break;
+               }
                nsp = sotonspcb(so);
 
                mm = m_getclr(M_DONTWAIT, MT_PCB);
                nsp = sotonspcb(so);
 
                mm = m_getclr(M_DONTWAIT, MT_PCB);
@@ -1227,7 +1306,7 @@ spp_usrreq(so, req, m, nam, rights)
                cb = mtod(mm, struct sppcb *);
                mm = m_getclr(M_DONTWAIT, MT_HEADER);
                if (mm == NULL) {
                cb = mtod(mm, struct sppcb *);
                mm = m_getclr(M_DONTWAIT, MT_HEADER);
                if (mm == NULL) {
-                       m_free(dtom(m));
+                       (void) m_free(dtom(m));
                        error = ENOBUFS;
                        break;
                }
                        error = ENOBUFS;
                        break;
                }
@@ -1240,15 +1319,15 @@ spp_usrreq(so, req, m, nam, rights)
                cb->s_mtu = 576 - sizeof (struct spidp);
                cb->s_cwnd = sbspace(sb) * CUNIT / cb->s_mtu;
                cb->s_ssthresh = cb->s_cwnd;
                cb->s_mtu = 576 - sizeof (struct spidp);
                cb->s_cwnd = sbspace(sb) * CUNIT / cb->s_mtu;
                cb->s_ssthresh = cb->s_cwnd;
-               cb->s_cwmx = sb->sb_mbmax * CUNIT /
+               cb->s_cwmx = sbspace(sb) * CUNIT /
                                (2 * sizeof (struct spidp));
                /* Above is recomputed when connecting to account
                   for changed buffering or mtu's */
                                (2 * sizeof (struct spidp));
                /* Above is recomputed when connecting to account
                   for changed buffering or mtu's */
-               cb->s_rtt = TCPTV_SRTTBASE;
-               cb->s_rttvar = TCPTV_SRTTDFLT << 2;
-               TCPT_RANGESET(cb->s_rxtcur,
-                   ((TCPTV_SRTTBASE >> 2) + (TCPTV_SRTTDFLT << 2)) >> 1,
-                   TCPTV_MIN, TCPTV_REXMTMAX);
+               cb->s_rtt = SPPTV_SRTTBASE;
+               cb->s_rttvar = SPPTV_SRTTDFLT << 2;
+               SPPT_RANGESET(cb->s_rxtcur,
+                   ((SPPTV_SRTTBASE >> 2) + (SPPTV_SRTTDFLT << 2)) >> 1,
+                   SPPTV_MIN, SPPTV_REXMTMAX);
                nsp->nsp_pcb = (caddr_t) cb; 
                break;
 
                nsp->nsp_pcb = (caddr_t) cb; 
                break;
 
@@ -1294,8 +1373,8 @@ spp_usrreq(so, req, m, nam, rights)
                cb->s_state = TCPS_SYN_SENT;
                cb->s_did = 0;
                spp_template(cb);
                cb->s_state = TCPS_SYN_SENT;
                cb->s_did = 0;
                spp_template(cb);
-               cb->s_timer[TCPT_KEEP] = TCPTV_KEEP;
-               cb->s_force = 1 + TCPTV_KEEP;
+               cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
+               cb->s_force = 1 + SPPTV_KEEP;
                /*
                 * Other party is required to respond to
                 * the port I send from, but he is not
                /*
                 * Other party is required to respond to
                 * the port I send from, but he is not
@@ -1380,6 +1459,16 @@ spp_usrreq(so, req, m, nam, rights)
                cb->s_oobflags |= SF_SOOB;
                /* fall into */
        case PRU_SEND:
                cb->s_oobflags |= SF_SOOB;
                /* fall into */
        case PRU_SEND:
+               if (controlp) {
+                       u_short *p = mtod(controlp, u_short *);
+                       spp_newchecks[2]++;
+                       if ((p[0] == 5) && p[1] == 1) { /* XXXX, for testing */
+                               cb->s_shdr.sp_dt = *(u_char *)(&p[2]);
+                               spp_newchecks[3]++;
+                       }
+                       m_freem(controlp);
+               }
+               controlp = NULL;
                error = spp_output(cb, m);
                m = NULL;
                break;
                error = spp_output(cb, m);
                m = NULL;
                break;
@@ -1409,18 +1498,20 @@ spp_usrreq(so, req, m, nam, rights)
        if (cb && (so->so_options & SO_DEBUG || traceallspps))
                spp_trace(SA_USER, (u_char)ostate, cb, (struct spidp *)0, req);
 release:
        if (cb && (so->so_options & SO_DEBUG || traceallspps))
                spp_trace(SA_USER, (u_char)ostate, cb, (struct spidp *)0, req);
 release:
+       if (controlp != NULL)
+               m_freem(controlp);
        if (m != NULL)
                m_freem(m);
        splx(s);
        return (error);
 }
 
        if (m != NULL)
                m_freem(m);
        splx(s);
        return (error);
 }
 
-spp_usrreq_sp(so, req, m, nam, rights)
+spp_usrreq_sp(so, req, m, nam, controlp)
        struct socket *so;
        int req;
        struct socket *so;
        int req;
-       struct mbuf *m, *nam, *rights;
+       struct mbuf *m, *nam, *controlp;
 {
 {
-       int error = spp_usrreq(so, req, m, nam, rights);
+       int error = spp_usrreq(so, req, m, nam, controlp);
 
        if (req == PRU_ATTACH && error == 0) {
                struct nspcb *nsp = sotonspcb(so);
 
        if (req == PRU_ATTACH && error == 0) {
                struct nspcb *nsp = sotonspcb(so);
@@ -1452,8 +1543,8 @@ spp_template(cb)
        cb->s_cwnd = (sbspace(sb) * CUNIT) / cb->s_mtu;
        cb->s_ssthresh = cb->s_cwnd; /* Try to expand fast to full complement
                                        of large packets */
        cb->s_cwnd = (sbspace(sb) * CUNIT) / cb->s_mtu;
        cb->s_ssthresh = cb->s_cwnd; /* Try to expand fast to full complement
                                        of large packets */
-       cb->s_cwmx = (sb->sb_mbmax * CUNIT) / (2 * sizeof(struct spidp));
-       cb->s_cwmx = MAX(cb->s_cwmx, cb->s_cwnd);
+       cb->s_cwmx = (sbspace(sb) * CUNIT) / (2 * sizeof(struct spidp));
+       cb->s_cwmx = max(cb->s_cwmx, cb->s_cwnd);
                /* But allow for lots of little packets as well */
 }
 
                /* But allow for lots of little packets as well */
 }
 
@@ -1537,7 +1628,7 @@ spp_abort(nsp)
        (void) spp_close((struct sppcb *)nsp->nsp_pcb);
 }
 
        (void) spp_close((struct sppcb *)nsp->nsp_pcb);
 }
 
-int    spp_backoff[TCP_MAXRXTSHIFT+1] =
+int    spp_backoff[SPP_MAXRXTSHIFT+1] =
     { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
 /*
  * Fast timeout routine for processing delayed acks
     { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
 /*
  * Fast timeout routine for processing delayed acks
@@ -1586,11 +1677,12 @@ spp_slowtimo()
                ipnxt = ip->nsp_next;
                if (cb == 0)
                        goto tpgone;
                ipnxt = ip->nsp_next;
                if (cb == 0)
                        goto tpgone;
-               for (i = 0; i < TCPT_NTIMERS; i++) {
+               for (i = 0; i < SPPT_NTIMERS; i++) {
                        if (cb->s_timer[i] && --cb->s_timer[i] == 0) {
                                (void) spp_usrreq(cb->s_nspcb->nsp_socket,
                                    PRU_SLOWTIMO, (struct mbuf *)0,
                        if (cb->s_timer[i] && --cb->s_timer[i] == 0) {
                                (void) spp_usrreq(cb->s_nspcb->nsp_socket,
                                    PRU_SLOWTIMO, (struct mbuf *)0,
-                                   (struct mbuf *)i, (struct mbuf *)0);
+                                   (struct mbuf *)i, (struct mbuf *)0,
+                                   (struct mbuf *)0);
                                if (ipnxt->nsp_prev != ip)
                                        goto tpgone;
                        }
                                if (ipnxt->nsp_prev != ip)
                                        goto tpgone;
                        }
@@ -1622,8 +1714,8 @@ spp_timers(cb, timer)
         * 2 MSL timeout in shutdown went off.  TCP deletes connection
         * control block.
         */
         * 2 MSL timeout in shutdown went off.  TCP deletes connection
         * control block.
         */
-       case TCPT_2MSL:
-               printf("spp: TCPT_2MSL went off for no reason\n");
+       case SPPT_2MSL:
+               printf("spp: SPPT_2MSL went off for no reason\n");
                cb->s_timer[timer] = 0;
                break;
 
                cb->s_timer[timer] = 0;
                break;
 
@@ -1632,9 +1724,9 @@ spp_timers(cb, timer)
         * been acked within retransmit interval.  Back off
         * to a longer retransmit interval and retransmit one packet.
         */
         * been acked within retransmit interval.  Back off
         * to a longer retransmit interval and retransmit one packet.
         */
-       case TCPT_REXMT:
-               if (++cb->s_rxtshift > TCP_MAXRXTSHIFT) {
-                       cb->s_rxtshift = TCP_MAXRXTSHIFT;
+       case SPPT_REXMT:
+               if (++cb->s_rxtshift > SPP_MAXRXTSHIFT) {
+                       cb->s_rxtshift = SPP_MAXRXTSHIFT;
                        sppstat.spps_timeoutdrop++;
                        cb = spp_drop(cb, ETIMEDOUT);
                        break;
                        sppstat.spps_timeoutdrop++;
                        cb = spp_drop(cb, ETIMEDOUT);
                        break;
@@ -1642,8 +1734,8 @@ spp_timers(cb, timer)
                sppstat.spps_rexmttimeo++;
                rexmt = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
                rexmt *= spp_backoff[cb->s_rxtshift];
                sppstat.spps_rexmttimeo++;
                rexmt = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
                rexmt *= spp_backoff[cb->s_rxtshift];
-               TCPT_RANGESET(cb->s_rxtcur, rexmt, TCPTV_MIN, TCPTV_REXMTMAX);
-               cb->s_timer[TCPT_REXMT] = cb->s_rxtcur;
+               SPPT_RANGESET(cb->s_rxtcur, rexmt, SPPTV_MIN, SPPTV_REXMTMAX);
+               cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
                /*
                 * If we have backed off fairly far, our srtt
                 * estimate is probably bogus.  Clobber it
                /*
                 * If we have backed off fairly far, our srtt
                 * estimate is probably bogus.  Clobber it
@@ -1651,7 +1743,7 @@ spp_timers(cb, timer)
                 * move the current srtt into rttvar to keep the current
                 * retransmit times until then.
                 */
                 * move the current srtt into rttvar to keep the current
                 * retransmit times until then.
                 */
-               if (cb->s_rxtshift > TCP_MAXRXTSHIFT / 4 ) {
+               if (cb->s_rxtshift > SPP_MAXRXTSHIFT / 4 ) {
                        cb->s_rttvar += (cb->s_srtt >> 2);
                        cb->s_srtt = 0;
                }
                        cb->s_rttvar += (cb->s_srtt >> 2);
                        cb->s_srtt = 0;
                }
@@ -1664,7 +1756,7 @@ spp_timers(cb, timer)
                 * See very long discussion in tcp_timer.c about congestion
                 * window and sstrhesh
                 */
                 * See very long discussion in tcp_timer.c about congestion
                 * window and sstrhesh
                 */
-               win = MIN(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2;
+               win = min(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2;
                if (win < 2)
                        win = 2;
                cb->s_cwnd = CUNIT;
                if (win < 2)
                        win = 2;
                cb->s_cwnd = CUNIT;
@@ -1676,7 +1768,7 @@ spp_timers(cb, timer)
         * Persistance timer into zero window.
         * Force a probe to be sent.
         */
         * Persistance timer into zero window.
         * Force a probe to be sent.
         */
-       case TCPT_PERSIST:
+       case SPPT_PERSIST:
                sppstat.spps_persisttimeo++;
                spp_setpersist(cb);
                (void) spp_output(cb, (struct mbuf *) 0);
                sppstat.spps_persisttimeo++;
                spp_setpersist(cb);
                (void) spp_output(cb, (struct mbuf *) 0);
@@ -1686,18 +1778,18 @@ spp_timers(cb, timer)
         * Keep-alive timer went off; send something
         * or drop connection if idle for too long.
         */
         * Keep-alive timer went off; send something
         * or drop connection if idle for too long.
         */
-       case TCPT_KEEP:
+       case SPPT_KEEP:
                sppstat.spps_keeptimeo++;
                if (cb->s_state < TCPS_ESTABLISHED)
                        goto dropit;
                if (cb->s_nspcb->nsp_socket->so_options & SO_KEEPALIVE) {
                sppstat.spps_keeptimeo++;
                if (cb->s_state < TCPS_ESTABLISHED)
                        goto dropit;
                if (cb->s_nspcb->nsp_socket->so_options & SO_KEEPALIVE) {
-                       if (cb->s_idle >= TCPTV_MAXIDLE)
+                       if (cb->s_idle >= SPPTV_MAXIDLE)
                                goto dropit;
                        sppstat.spps_keepprobe++;
                        (void) spp_output(cb, (struct mbuf *) 0);
                } else
                        cb->s_idle = 0;
                                goto dropit;
                        sppstat.spps_keepprobe++;
                        (void) spp_output(cb, (struct mbuf *) 0);
                } else
                        cb->s_idle = 0;
-               cb->s_timer[TCPT_KEEP] = TCPTV_KEEP;
+               cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
                break;
        dropit:
                sppstat.spps_keepdrops++;
                break;
        dropit:
                sppstat.spps_keepdrops++;
@@ -1709,4 +1801,4 @@ spp_timers(cb, timer)
 #ifndef lint
 int SppcbSize = sizeof (struct sppcb);
 int NspcbSize = sizeof (struct nspcb);
 #ifndef lint
 int SppcbSize = sizeof (struct sppcb);
 int NspcbSize = sizeof (struct nspcb);
-#endif lint
+#endif /* lint */