BSD 4_3_Tahoe release
[unix-history] / usr / src / sys / netinet / tcp_timer.c
index 7723bab..45f827f 100644 (file)
@@ -1,9 +1,20 @@
 /*
  * Copyright (c) 1982, 1986 Regents of the University of California.
 /*
  * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
  *
  *
- *     @(#)tcp_timer.c 7.10 (Berkeley) %G%
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *     @(#)tcp_timer.c 7.14 (Berkeley) 6/29/88
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -29,7 +40,9 @@
 #include "tcp_var.h"
 #include "tcpip.h"
 
 #include "tcp_var.h"
 #include "tcpip.h"
 
-int    tcpnodelack = 0;
+int    tcp_keepidle = TCPTV_KEEP_IDLE;
+int    tcp_keepintvl = TCPTV_KEEPINTVL;
+int    tcp_maxidle;
 /*
  * Fast timeout routine for processing delayed acks
  */
 /*
  * Fast timeout routine for processing delayed acks
  */
@@ -64,6 +77,7 @@ tcp_slowtimo()
        int s = splnet();
        register int i;
 
        int s = splnet();
        register int i;
 
+       tcp_maxidle = TCPTV_KEEPCNT * tcp_keepintvl;
        /*
         * Search through tcb's and update active timers.
         */
        /*
         * Search through tcb's and update active timers.
         */
@@ -135,8 +149,8 @@ tcp_timers(tp, timer)
         */
        case TCPT_2MSL:
                if (tp->t_state != TCPS_TIME_WAIT &&
         */
        case TCPT_2MSL:
                if (tp->t_state != TCPS_TIME_WAIT &&
-                   tp->t_idle <= TCPTV_MAXIDLE)
-                       tp->t_timer[TCPT_2MSL] = TCPTV_KEEP;
+                   tp->t_idle <= tcp_maxidle)
+                       tp->t_timer[TCPT_2MSL] = tcp_keepintvl;
                else
                        tp = tcp_close(tp);
                break;
                else
                        tp = tcp_close(tp);
                break;
@@ -232,7 +246,7 @@ tcp_timers(tp, timer)
                        goto dropit;
                if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE &&
                    tp->t_state <= TCPS_CLOSE_WAIT) {
                        goto dropit;
                if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE &&
                    tp->t_state <= TCPS_CLOSE_WAIT) {
-                       if (tp->t_idle >= TCPTV_MAXIDLE)
+                       if (tp->t_idle >= tcp_keepidle + tcp_maxidle)
                                goto dropit;
                        /*
                         * Send a packet designed to force a response
                                goto dropit;
                        /*
                         * Send a packet designed to force a response
@@ -258,8 +272,9 @@ tcp_timers(tp, timer)
                        tcp_respond(tp, tp->t_template,
                            tp->rcv_nxt, tp->snd_una - 1, 0);
 #endif
                        tcp_respond(tp, tp->t_template,
                            tp->rcv_nxt, tp->snd_una - 1, 0);
 #endif
-               }
-               tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
+                       tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
+               } else
+                       tp->t_timer[TCPT_KEEP] = tcp_keepidle;
                break;
        dropit:
                tcpstat.tcps_keepdrops++;
                break;
        dropit:
                tcpstat.tcps_keepdrops++;