branch for FTP release (#ifdefs for non-4.3)
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Mon, 8 Feb 1988 12:00:07 +0000 (04:00 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Mon, 8 Feb 1988 12:00:07 +0000 (04:00 -0800)
SCCS-vsn: sys/netinet/tcp.h 7.4.1.1
SCCS-vsn: sys/netinet/tcp_input.c 7.15.1.1
SCCS-vsn: sys/netinet/tcp_output.c 7.13.1.1
SCCS-vsn: sys/netinet/tcp_subr.c 7.13.1.1
SCCS-vsn: sys/netinet/tcp_timer.c 7.12
SCCS-vsn: sys/netinet/tcp_usrreq.c 7.7.1.1
SCCS-vsn: sys/netinet/tcp_var.h 7.6.1.1
SCCS-vsn: sys/netinet/tcp_timer.c 7.11.1.1

usr/src/sys/netinet/tcp.h
usr/src/sys/netinet/tcp_input.c
usr/src/sys/netinet/tcp_output.c
usr/src/sys/netinet/tcp_subr.c
usr/src/sys/netinet/tcp_timer.c
usr/src/sys/netinet/tcp_usrreq.c
usr/src/sys/netinet/tcp_var.h

index f25c837..3d5aab7 100644 (file)
@@ -9,8 +9,23 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)tcp.h       7.4 (Berkeley) %G%
+ *     @(#)tcp.h       7.4.1.1 (Berkeley) %G%
  */
  */
+#ifndef BYTE_ORDER
+/*
+ * Definitions for byte order,
+ * according to byte significance from low address to high.
+ */
+#define        LITTLE_ENDIAN   1234    /* least-significant byte first (vax) */
+#define        BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
+#define        PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp) */
+
+#ifdef vax
+#define        BYTE_ORDER      LITTLE_ENDIAN
+#else
+#define        BYTE_ORDER      BIG_ENDIAN      /* mc68000, tahoe, most others */
+#endif
+#endif BYTE_ORDER
 
 typedef        u_long  tcp_seq;
 /*
 
 typedef        u_long  tcp_seq;
 /*
@@ -22,11 +37,11 @@ struct tcphdr {
        u_short th_dport;               /* destination port */
        tcp_seq th_seq;                 /* sequence number */
        tcp_seq th_ack;                 /* acknowledgement number */
        u_short th_dport;               /* destination port */
        tcp_seq th_seq;                 /* sequence number */
        tcp_seq th_ack;                 /* acknowledgement number */
-#if BYTE_ORDER == LITTLE_ENDIAN 
+#if BYTE_ORDER == LITTLE_ENDIAN
        u_char  th_x2:4,                /* (unused) */
                th_off:4;               /* data offset */
 #endif
        u_char  th_x2:4,                /* (unused) */
                th_off:4;               /* data offset */
 #endif
-#if BYTE_ORDER == BIG_ENDIAN 
+#if BYTE_ORDER == BIG_ENDIAN
        u_char  th_off:4,               /* data offset */
                th_x2:4;                /* (unused) */
 #endif
        u_char  th_off:4,               /* data offset */
                th_x2:4;                /* (unused) */
 #endif
@@ -54,6 +69,9 @@ struct tcphdr {
 #ifdef lint
 #define        TCP_MSS 536
 #else
 #ifdef lint
 #define        TCP_MSS 536
 #else
+#ifndef IP_MSS
+#define        IP_MSS  576
+#endif
 #define        TCP_MSS MIN(512, IP_MSS - sizeof (struct tcpiphdr))
 #endif
 
 #define        TCP_MSS MIN(512, IP_MSS - sizeof (struct tcpiphdr))
 #endif
 
index 18dab8b..843d8ce 100644 (file)
@@ -9,7 +9,7 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)tcp_input.c 7.15 (Berkeley) %G%
+ *     @(#)tcp_input.c 7.15.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -319,7 +319,9 @@ findpcb:
                inp = (struct inpcb *)so->so_pcb;
                inp->inp_laddr = ti->ti_dst;
                inp->inp_lport = ti->ti_dport;
                inp = (struct inpcb *)so->so_pcb;
                inp->inp_laddr = ti->ti_dst;
                inp->inp_lport = ti->ti_dport;
+#if BSD>=43
                inp->inp_options = ip_srcroute();
                inp->inp_options = ip_srcroute();
+#endif
                tp = intotcpcb(inp);
                tp->t_state = TCPS_LISTEN;
        }
                tp = intotcpcb(inp);
                tp->t_state = TCPS_LISTEN;
        }
@@ -487,7 +489,17 @@ trimthenstep6:
                ti->ti_seq++;
                if (ti->ti_len > tp->rcv_wnd) {
                        todrop = ti->ti_len - tp->rcv_wnd;
                ti->ti_seq++;
                if (ti->ti_len > tp->rcv_wnd) {
                        todrop = ti->ti_len - tp->rcv_wnd;
+#if BSD>=43
                        m_adj(m, -todrop);
                        m_adj(m, -todrop);
+#else
+                       /* XXX work around 4.2 m_adj bug */
+                       if (m->m_len) {
+                               m_adj(m, -todrop);
+                       } else {
+                               /* skip tcp/ip header in first mbuf */
+                               m_adj(m->m_next, -todrop);
+                       }
+#endif
                        ti->ti_len = tp->rcv_wnd;
                        tiflags &= ~TH_FIN;
                        tcpstat.tcps_rcvpackafterwin++;
                        ti->ti_len = tp->rcv_wnd;
                        tiflags &= ~TH_FIN;
                        tcpstat.tcps_rcvpackafterwin++;
@@ -591,7 +603,17 @@ trimthenstep6:
                                goto dropafterack;
                } else
                        tcpstat.tcps_rcvbyteafterwin += todrop;
                                goto dropafterack;
                } else
                        tcpstat.tcps_rcvbyteafterwin += todrop;
+#if BSD>=43
                m_adj(m, -todrop);
                m_adj(m, -todrop);
+#else
+               /* XXX work around m_adj bug */
+               if (m->m_len) {
+                       m_adj(m, -todrop);
+               } else {
+                       /* skip tcp/ip header in first mbuf */
+                       m_adj(m->m_next, -todrop);
+               }
+#endif
                ti->ti_len -= todrop;
                tiflags &= ~(TH_PUSH|TH_FIN);
        }
                ti->ti_len -= todrop;
                tiflags &= ~(TH_PUSH|TH_FIN);
        }
@@ -974,8 +996,11 @@ step6:
                 * but if two URG's are pending at once, some out-of-band
                 * data may creep in... ick.
                 */
                 * but if two URG's are pending at once, some out-of-band
                 * data may creep in... ick.
                 */
-               if (ti->ti_urp <= ti->ti_len &&
-                   (so->so_options & SO_OOBINLINE) == 0)
+               if (ti->ti_urp <= ti->ti_len
+#ifdef SO_OOBINLINE
+                    && (so->so_options & SO_OOBINLINE) == 0
+#endif
+                                                          )
                        tcp_pulloutofband(so, ti);
        } else
                /*
                        tcp_pulloutofband(so, ti);
        } else
                /*
@@ -1253,3 +1278,34 @@ tcp_mss(tp)
        tp->snd_cwnd = mss;
        return (mss);
 }
        tp->snd_cwnd = mss;
        return (mss);
 }
+
+#if BSD<43
+/* XXX this belongs in netinet/in.c */
+in_localaddr(in)
+       struct in_addr in;
+{
+       register u_long i = ntohl(in.s_addr);
+       register struct ifnet *ifp;
+       register struct sockaddr_in *sin;
+       register u_long mask;
+
+       if (IN_CLASSA(i))
+               mask = IN_CLASSA_NET;
+       else if (IN_CLASSB(i))
+               mask = IN_CLASSB_NET;
+       else if (IN_CLASSC(i))
+               mask = IN_CLASSC_NET;
+       else
+               return (0);
+
+       i &= mask;
+       for (ifp = ifnet; ifp; ifp = ifp->if_next) {
+               if (ifp->if_addr.sa_family != AF_INET)
+                       continue;
+               sin = (struct sockaddr_in *)&ifp->if_addr;
+               if ((sin->sin_addr.s_addr & mask) == i)
+                       return (1);
+       }
+       return (0);
+}
+#endif
index 4cc2c52..27836e5 100644 (file)
@@ -9,7 +9,7 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)tcp_output.c        7.13 (Berkeley) %G%
+ *     @(#)tcp_output.c        7.13.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -387,8 +387,13 @@ send:
         */
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + optlen + len;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
         */
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + optlen + len;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
+#if BSD>=43
        error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
            so->so_options & SO_DONTROUTE);
        error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
            so->so_options & SO_DONTROUTE);
+#else
+       error = ip_output(m, (struct mbuf *)0, &tp->t_inpcb->inp_route, 
+                         so->so_options & SO_DONTROUTE);
+#endif
        if (error) {
                if (error == ENOBUFS) {
                        tcp_quench(tp->t_inpcb);
        if (error) {
                if (error == ENOBUFS) {
                        tcp_quench(tp->t_inpcb);
index 7a19e9b..08037d7 100644 (file)
@@ -9,7 +9,7 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)tcp_subr.c  7.13 (Berkeley) %G%
+ *     @(#)tcp_subr.c  7.13.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -290,7 +290,9 @@ tcp_ctlinput(cmd, sa)
        case PRC_REDIRECT_HOST:
        case PRC_REDIRECT_TOSNET:
        case PRC_REDIRECT_TOSHOST:
        case PRC_REDIRECT_HOST:
        case PRC_REDIRECT_TOSNET:
        case PRC_REDIRECT_TOSHOST:
+#if BSD>=43
                in_pcbnotify(&tcb, &sin->sin_addr, 0, in_rtchange);
                in_pcbnotify(&tcb, &sin->sin_addr, 0, in_rtchange);
+#endif
                break;
 
        default:
                break;
 
        default:
@@ -301,6 +303,15 @@ tcp_ctlinput(cmd, sa)
        }
 }
 
        }
 }
 
+#if BSD<43
+/* XXX fake routine */
+tcp_abort(inp)
+       struct inpcb *inp;
+{
+       return;
+}
+#endif
+
 /*
  * When a source quench is received, close congestion window
  * to one segment.  We will gradually open it again as we proceed.
 /*
  * When a source quench is received, close congestion window
  * to one segment.  We will gradually open it again as we proceed.
index 9133efb..ca92942 100644 (file)
@@ -9,7 +9,7 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)tcp_timer.c 7.11 (Berkeley) %G%
+ *     @(#)tcp_timer.c 7.11.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -173,7 +173,9 @@ tcp_timers(tp, timer)
                 * retransmit times until then.
                 */
                if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) {
                 * retransmit times until then.
                 */
                if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) {
+#if BSD>=43
                        in_losing(tp->t_inpcb);
                        in_losing(tp->t_inpcb);
+#endif
                        tp->t_rttvar += (tp->t_srtt >> 2);
                        tp->t_srtt = 0;
                }
                        tp->t_rttvar += (tp->t_srtt >> 2);
                        tp->t_srtt = 0;
                }
index 1adba6b..6877d59 100644 (file)
@@ -9,7 +9,7 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)tcp_usrreq.c        7.7 (Berkeley) %G%
+ *     @(#)tcp_usrreq.c        7.7.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -60,9 +60,14 @@ tcp_usrreq(so, req, m, nam, rights)
        int error = 0;
        int ostate;
 
        int error = 0;
        int ostate;
 
+#if BSD>=43
        if (req == PRU_CONTROL)
                return (in_control(so, (int)m, (caddr_t)nam,
                        (struct ifnet *)rights));
        if (req == PRU_CONTROL)
                return (in_control(so, (int)m, (caddr_t)nam,
                        (struct ifnet *)rights));
+#else
+       if (req == PRU_CONTROL)
+               return(EOPNOTSUPP);
+#endif
        if (rights && rights->m_len)
                return (EINVAL);
 
        if (rights && rights->m_len)
                return (EINVAL);
 
@@ -247,7 +252,9 @@ tcp_usrreq(so, req, m, nam, rights)
        case PRU_RCVOOB:
                if ((so->so_oobmark == 0 &&
                    (so->so_state & SS_RCVATMARK) == 0) ||
        case PRU_RCVOOB:
                if ((so->so_oobmark == 0 &&
                    (so->so_state & SS_RCVATMARK) == 0) ||
+#ifdef SO_OOBINLINE
                    so->so_options & SO_OOBINLINE ||
                    so->so_options & SO_OOBINLINE ||
+#endif
                    tp->t_oobflags & TCPOOB_HADDATA) {
                        error = EINVAL;
                        break;
                    tp->t_oobflags & TCPOOB_HADDATA) {
                        error = EINVAL;
                        break;
@@ -309,6 +316,7 @@ tcp_usrreq(so, req, m, nam, rights)
        return (error);
 }
 
        return (error);
 }
 
+#if BSD>=43
 tcp_ctloutput(op, so, level, optname, mp)
        int op;
        struct socket *so;
 tcp_ctloutput(op, so, level, optname, mp)
        int op;
        struct socket *so;
@@ -366,6 +374,7 @@ tcp_ctloutput(op, so, level, optname, mp)
        }
        return (error);
 }
        }
        return (error);
 }
+#endif
 
 int    tcp_sendspace = 1024*4;
 int    tcp_recvspace = 1024*4;
 
 int    tcp_sendspace = 1024*4;
 int    tcp_recvspace = 1024*4;
index 6738c1b..6ef78e0 100644 (file)
@@ -9,9 +9,56 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)tcp_var.h   7.6 (Berkeley) %G%
+ *     @(#)tcp_var.h   7.6.1.1 (Berkeley) %G%
  */
 
  */
 
+/*
+ * TCP configuration:  This is a half-assed attempt to make TCP
+ * self-configure for a few varieties of 4.2 and 4.3-based unixes.
+ * If you don't have a) a 4.3bsd vax or b) a 3.x Sun (x<6), check
+ * this carefully (it's probably not right).  Please send me mail
+ * if you run into configuration problems.
+ *  - Van Jacobson (van@lbl-csam.arpa)
+ */
+
+#ifndef BSD
+#define BSD 42 /* if we're not 4.3, pretend we're 4.2 */
+#endif
+
+#if sun || BSD < 43
+#define TCP_COMPAT_42  /* set if we have to interop w/4.2 systems */
+#endif
+
+#ifndef SB_MAX
+#ifdef SB_MAXCOUNT
+#define        SB_MAX  SB_MAXCOUNT     /* Sun has to be a little bit different... */
+#else
+#define SB_MAX 32767           /* XXX */
+#endif SB_MAXCOUNT
+#endif SB_MAX
+
+/*
+ * Bill Nowicki pointed out that the page size (CLBYTES) has
+ * nothing to do with the mbuf cluster size.  So, we followed
+ * Sun's lead and made the new define MCLBYTES stand for the mbuf
+ * cluster size.  The following define makes up backwards compatible
+ * with 4.3 and 4.2.  If CLBYTES is >1024 on your machine, check
+ * this against the mbuf cluster definitions in /usr/include/sys/mbuf.h.
+ */
+#ifndef MCLBYTES
+#define        MCLBYTES CLBYTES        /* XXX */
+#endif
+
+/*
+ * The routine in_localaddr is broken in Sun's 3.4.  We redefine ours
+ * (in tcp_input.c) so we use can it but won't have a name conflict.
+ */
+#ifdef sun
+#define in_localaddr tcp_in_localaddr
+#endif
+
+/* --------------- end of TCP config ---------------- */
+
 /*
  * Kernel variables for tcp.
  */
 /*
  * Kernel variables for tcp.
  */