Index: tcp_input.c
===================================================================
RCS file: /cvs/Darwin/System/xnu/bsd/netinet/tcp_input.c,v
retrieving revision 1.1.1.8
diff -u -d -b -w -r1.1.1.8 tcp_input.c
--- tcp_input.c 2001/04/05 01:08:42     1.1.1.8
+++ tcp_input.c 2001/05/10 19:43:29
@@ -1187,9 +1187,14 @@
                        tcp_mss(tp, to.to_maxseg, isipv6);      /* sets t_maxseg */
                if (iss)
                        tp->iss = iss;
-               else
+               else {
+#ifdef TCP_COMPAT_42
+                       tcp_iss += TCP_ISSINCR/2;
                        tp->iss = tcp_iss;
-               tcp_iss += TCP_ISSINCR/4;
+#else
+                       tp->iss = tcp_rndiss_next();
+#endif /* TCP_COMPAT_42 */
+               }
                tp->irs = th->th_seq;
                tcp_sendseqinit(tp);
                tcp_rcvseqinit(tp);
@@ -1720,7 +1725,11 @@
                        if (thflags & TH_SYN &&
                            tp->t_state == TCPS_TIME_WAIT &&
                            SEQ_GT(th->th_seq, tp->rcv_nxt)) {
+#ifdef TCP_COMPAT_42
                                iss = tp->rcv_nxt + TCP_ISSINCR;
+#else
+                               iss = tcp_rndiss_next();
+#endif /* TCP_COMPAT_42 */
                                tp = tcp_close(tp);
                                goto findpcb;
                        }
Index: tcp_seq.h
===================================================================
RCS file: /cvs/Darwin/System/xnu/bsd/netinet/tcp_seq.h,v
retrieving revision 1.1.1.1
diff -u -d -b -w -r1.1.1.1 tcp_seq.h
--- tcp_seq.h   2000/03/25 21:02:27     1.1.1.1
+++ tcp_seq.h   2001/05/10 19:43:29
@@ -101,6 +101,7 @@
 #ifdef KERNEL
 extern tcp_cc  tcp_ccgen;              /* global connection count */
 
+#ifdef TCP_COMPAT_42
 /*
  * Increment for tcp_iss each second.
  * This is designed to increment at the standard 250 KB/s,
@@ -116,6 +117,7 @@
 #define        TCP_ISSINCR     (122*1024 + tcp_random18())
 
 extern tcp_seq tcp_iss;                /* tcp initial send seq # */
+#endif /* TCP_COMPAT_42 */
 #else
 #define        TCP_ISSINCR     (250*1024)      /* increment for tcp_iss each second */
 #endif /* KERNEL */
Index: tcp_subr.c
===================================================================
RCS file: /cvs/Darwin/System/xnu/bsd/netinet/tcp_subr.c,v
retrieving revision 1.1.1.5
diff -u -d -b -w -r1.1.1.5 tcp_subr.c
--- tcp_subr.c  2000/11/30 01:46:08     1.1.1.5
+++ tcp_subr.c  2001/05/10 19:43:29
@@ -203,7 +203,9 @@
        vm_size_t       str_size;
        int  i;
 
-       tcp_iss = random();     /* wrong, but better than a constant */
+#ifdef TCP_COMPAT_42
+       tcp_iss = 1;
+#endif /* TCP_COMPAT_42 */
        tcp_ccgen = 1;
        tcp_cleartaocache();
        LIST_INIT(&tcb);
@@ -995,6 +997,63 @@
                              0, cmd, notify);
 }
 #endif /* INET6 */
+
+#define TCP_RNDISS_ROUNDS      16
+#define TCP_RNDISS_OUT 7200
+#define TCP_RNDISS_MAX 30000
+
+u_int8_t tcp_rndiss_sbox[128];
+u_int16_t tcp_rndiss_msb;
+u_int16_t tcp_rndiss_cnt;
+long tcp_rndiss_reseed;
+
+u_int16_t
+tcp_rndiss_encrypt(val)
+       u_int16_t val;
+{
+       u_int16_t sum = 0, i;
+  
+       for (i = 0; i < TCP_RNDISS_ROUNDS; i++) {
+               sum += 0x79b9;
+               val ^= ((u_int16_t)tcp_rndiss_sbox[(val^sum) & 0x7f]) << 7;
+               val = ((val & 0xff) << 7) | (val >> 8);
+       }
+
+       return val;
+}
+
+void
+tcp_rndiss_init()
+{
+       struct timeval time;
+
+       getmicrotime(&time);
+       read_random_unlimited(tcp_rndiss_sbox, sizeof(tcp_rndiss_sbox));
+
+       tcp_rndiss_reseed = time.tv_sec + TCP_RNDISS_OUT;
+       tcp_rndiss_msb = tcp_rndiss_msb == 0x8000 ? 0 : 0x8000; 
+       tcp_rndiss_cnt = 0;
+}
+
+tcp_seq
+tcp_rndiss_next()
+{
+       u_int32_t tmp;
+       struct timeval time;
+
+       getmicrotime(&time);
+
+        if (tcp_rndiss_cnt >= TCP_RNDISS_MAX ||
+           time.tv_sec > tcp_rndiss_reseed)
+                tcp_rndiss_init();
+
+       tmp = arc4random();
+
+       /* (tmp & 0x7fff) ensures a 32768 byte gap between ISS */
+       return ((tcp_rndiss_encrypt(tcp_rndiss_cnt++) | tcp_rndiss_msb) <<16) |
+               (tmp & 0x7fff);
+}
+
 
 /*
  * When a source quench is received, close congestion window
Index: tcp_timer.c
===================================================================
RCS file: /cvs/Darwin/System/xnu/bsd/netinet/tcp_timer.c,v
retrieving revision 1.1.1.4
diff -u -d -b -w -r1.1.1.4 tcp_timer.c
--- tcp_timer.c 2000/11/30 00:47:19     1.1.1.4
+++ tcp_timer.c 2001/05/10 19:43:29
@@ -307,8 +307,8 @@
        if (++cur_tw_slot >= N_TIME_WAIT_SLOTS)
                cur_tw_slot = 0;
 
-       tcp_iss += TCP_ISSINCR/PR_SLOWHZ;               /* increment iss */
 #if TCP_COMPAT_42
+       tcp_iss += TCP_ISSINCR/PR_SLOWHZ;               /* increment iss */
        if ((int)tcp_iss < 0)
                tcp_iss = TCP_ISSINCR;                  /* XXX */
 #endif
Index: tcp_usrreq.c
===================================================================
RCS file: /cvs/Darwin/System/xnu/bsd/netinet/tcp_usrreq.c,v
retrieving revision 1.1.1.4
diff -u -d -b -w -r1.1.1.4 tcp_usrreq.c
--- tcp_usrreq.c        2001/01/26 22:40:41     1.1.1.4
+++ tcp_usrreq.c        2001/05/10 19:43:29
@@ -749,7 +749,12 @@
        tcpstat.tcps_connattempt++;
        tp->t_state = TCPS_SYN_SENT;
        tp->t_timer[TCPT_KEEP] = tcp_keepinit;
-       tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2;
+#ifdef TCP_COMPAT_42
+       tp->iss = tcp_iss;
+       tcp_iss =+ TCP_ISSINCR/2;
+#else /* TCP_COMPAT_42 */
+       tp->iss = tcp_rndiss_next();
+#endif /* !TCP_COMPAT_42 */
        tcp_sendseqinit(tp);
 
        /*
@@ -845,7 +850,11 @@
        tcpstat.tcps_connattempt++;
        tp->t_state = TCPS_SYN_SENT;
        tp->t_timer[TCPT_KEEP] = tcp_keepinit;
+#ifdef TCP_COMPAT_42
        tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2;
+#else
+       tp->iss = tcp_rndiss_next();
+#endif /* TCP_COMPAT_42 */
        tcp_sendseqinit(tp);
 
        /*
Index: tcp_var.h
===================================================================
RCS file: /cvs/Darwin/System/xnu/bsd/netinet/tcp_var.h,v
retrieving revision 1.1.1.3
diff -u -d -b -w -r1.1.1.3 tcp_var.h
--- tcp_var.h   2000/11/30 00:47:20     1.1.1.3
+++ tcp_var.h   2001/05/10 19:43:30
@@ -480,6 +480,10 @@
 #endif /* INET6 */
 extern u_long tcp_sendspace;
 extern u_long tcp_recvspace;
+void   tcp_rndiss_init __P((void));
+tcp_seq        tcp_rndiss_next __P((void));
+u_int16_t
+       tcp_rndiss_encrypt __P((u_int16_t));
 
 #endif /* KERNEL */
 

